@mmmbuto/nexuscrew 0.8.19 → 0.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -3
- package/frontend/dist/assets/index-CQnOyaXz.js +93 -0
- package/frontend/dist/assets/index-DQbVJLji.css +32 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/cli/init.js +9 -1
- package/lib/decks/routes.js +2 -2
- package/lib/decks/store.js +34 -5
- package/lib/fleet/builtin.js +18 -4
- package/lib/fleet/catalogs/openrouter-kimi-k3.json +44 -0
- package/lib/fleet/managed.js +109 -5
- package/lib/fleet/openrouter-auth-helper.js +21 -0
- package/lib/nodes/commands.js +35 -2
- package/lib/nodes/peering.js +45 -3
- package/lib/nodes/store.js +51 -10
- package/lib/nodes/tunnel-supervisor.js +47 -4
- package/lib/nodes/tunnel.js +38 -1
- package/lib/proxy/federation.js +123 -18
- package/lib/server.js +11 -0
- package/lib/settings/pairing-coordinator.js +3 -3
- package/lib/settings/public-peering-routes.js +39 -11
- package/lib/settings/routes.js +31 -29
- package/lib/tmux/list.js +11 -2
- package/package.json +1 -1
- package/frontend/dist/assets/index-DOHx885g.js +0 -91
- package/frontend/dist/assets/index-kxpt4ezv.css +0 -32
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function i(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=i(o);fetch(o.href,a)}})();function Fh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gc={exports:{}},Hs={},Qc={exports:{}},Qe={};/**
|
|
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 em;function Pw(){if(em)return Qe;em=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),S=Symbol.iterator;function y(j){return j===null||typeof j!="object"?null:(j=S&&j[S]||j["@@iterator"],typeof j=="function"?j:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,x={};function b(j,$,re){this.props=j,this.context=$,this.refs=x,this.updater=re||k}b.prototype.isReactComponent={},b.prototype.setState=function(j,$){if(typeof j!="object"&&typeof j!="function"&&j!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,j,$,"setState")},b.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function C(){}C.prototype=b.prototype;function M(j,$,re){this.props=j,this.context=$,this.refs=x,this.updater=re||k}var L=M.prototype=new C;L.constructor=M,w(L,b.prototype),L.isPureReactComponent=!0;var T=Array.isArray,J=Object.prototype.hasOwnProperty,H={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(j,$,re){var le,se={},pe=null,ye=null;if($!=null)for(le in $.ref!==void 0&&(ye=$.ref),$.key!==void 0&&(pe=""+$.key),$)J.call($,le)&&!F.hasOwnProperty(le)&&(se[le]=$[le]);var ce=arguments.length-2;if(ce===1)se.children=re;else if(1<ce){for(var Ce=Array(ce),Oe=0;Oe<ce;Oe++)Ce[Oe]=arguments[Oe+2];se.children=Ce}if(j&&j.defaultProps)for(le in ce=j.defaultProps,ce)se[le]===void 0&&(se[le]=ce[le]);return{$$typeof:e,type:j,key:pe,ref:ye,props:se,_owner:H.current}}function W(j,$){return{$$typeof:e,type:j.type,key:$,ref:j.ref,props:j.props,_owner:j._owner}}function V(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function X(j){var $={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(re){return $[re]})}var A=/\/+/g;function N(j,$){return typeof j=="object"&&j!==null&&j.key!=null?X(""+j.key):$.toString(36)}function R(j,$,re,le,se){var pe=typeof j;(pe==="undefined"||pe==="boolean")&&(j=null);var ye=!1;if(j===null)ye=!0;else switch(pe){case"string":case"number":ye=!0;break;case"object":switch(j.$$typeof){case e:case t:ye=!0}}if(ye)return ye=j,se=se(ye),j=le===""?"."+N(ye,0):le,T(se)?(re="",j!=null&&(re=j.replace(A,"$&/")+"/"),R(se,$,re,"",function(Oe){return Oe})):se!=null&&(V(se)&&(se=W(se,re+(!se.key||ye&&ye.key===se.key?"":(""+se.key).replace(A,"$&/")+"/")+j)),$.push(se)),1;if(ye=0,le=le===""?".":le+":",T(j))for(var ce=0;ce<j.length;ce++){pe=j[ce];var Ce=le+N(pe,ce);ye+=R(pe,$,re,Ce,se)}else if(Ce=y(j),typeof Ce=="function")for(j=Ce.call(j),ce=0;!(pe=j.next()).done;)pe=pe.value,Ce=le+N(pe,ce++),ye+=R(pe,$,re,Ce,se);else if(pe==="object")throw $=String(j),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.");return ye}function O(j,$,re){if(j==null)return j;var le=[],se=0;return R(j,le,"","",function(pe){return $.call(re,pe,se++)}),le}function D(j){if(j._status===-1){var $=j._result;$=$(),$.then(function(re){(j._status===0||j._status===-1)&&(j._status=1,j._result=re)},function(re){(j._status===0||j._status===-1)&&(j._status=2,j._result=re)}),j._status===-1&&(j._status=0,j._result=$)}if(j._status===1)return j._result.default;throw j._result}var z={current:null},B={transition:null},te={ReactCurrentDispatcher:z,ReactCurrentBatchConfig:B,ReactCurrentOwner:H};function q(){throw Error("act(...) is not supported in production builds of React.")}return Qe.Children={map:O,forEach:function(j,$,re){O(j,function(){$.apply(this,arguments)},re)},count:function(j){var $=0;return O(j,function(){$++}),$},toArray:function(j){return O(j,function($){return $})||[]},only:function(j){if(!V(j))throw Error("React.Children.only expected to receive a single React element child.");return j}},Qe.Component=b,Qe.Fragment=i,Qe.Profiler=o,Qe.PureComponent=M,Qe.StrictMode=s,Qe.Suspense=m,Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=te,Qe.act=q,Qe.cloneElement=function(j,$,re){if(j==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+j+".");var le=w({},j.props),se=j.key,pe=j.ref,ye=j._owner;if($!=null){if($.ref!==void 0&&(pe=$.ref,ye=H.current),$.key!==void 0&&(se=""+$.key),j.type&&j.type.defaultProps)var ce=j.type.defaultProps;for(Ce in $)J.call($,Ce)&&!F.hasOwnProperty(Ce)&&(le[Ce]=$[Ce]===void 0&&ce!==void 0?ce[Ce]:$[Ce])}var Ce=arguments.length-2;if(Ce===1)le.children=re;else if(1<Ce){ce=Array(Ce);for(var Oe=0;Oe<Ce;Oe++)ce[Oe]=arguments[Oe+2];le.children=ce}return{$$typeof:e,type:j.type,key:se,ref:pe,props:le,_owner:ye}},Qe.createContext=function(j){return j={$$typeof:c,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},j.Provider={$$typeof:a,_context:j},j.Consumer=j},Qe.createElement=G,Qe.createFactory=function(j){var $=G.bind(null,j);return $.type=j,$},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function(j){return{$$typeof:d,render:j}},Qe.isValidElement=V,Qe.lazy=function(j){return{$$typeof:_,_payload:{_status:-1,_result:j},_init:D}},Qe.memo=function(j,$){return{$$typeof:p,type:j,compare:$===void 0?null:$}},Qe.startTransition=function(j){var $=B.transition;B.transition={};try{j()}finally{B.transition=$}},Qe.unstable_act=q,Qe.useCallback=function(j,$){return z.current.useCallback(j,$)},Qe.useContext=function(j){return z.current.useContext(j)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function(j){return z.current.useDeferredValue(j)},Qe.useEffect=function(j,$){return z.current.useEffect(j,$)},Qe.useId=function(){return z.current.useId()},Qe.useImperativeHandle=function(j,$,re){return z.current.useImperativeHandle(j,$,re)},Qe.useInsertionEffect=function(j,$){return z.current.useInsertionEffect(j,$)},Qe.useLayoutEffect=function(j,$){return z.current.useLayoutEffect(j,$)},Qe.useMemo=function(j,$){return z.current.useMemo(j,$)},Qe.useReducer=function(j,$,re){return z.current.useReducer(j,$,re)},Qe.useRef=function(j){return z.current.useRef(j)},Qe.useState=function(j){return z.current.useState(j)},Qe.useSyncExternalStore=function(j,$,re){return z.current.useSyncExternalStore(j,$,re)},Qe.useTransition=function(){return z.current.useTransition()},Qe.version="18.3.1",Qe}var tm;function Hh(){return tm||(tm=1,Qc.exports=Pw()),Qc.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 im;function Dw(){if(im)return Hs;im=1;var e=Hh(),t=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(d,m,p){var _,S={},y=null,k=null;p!==void 0&&(y=""+p),m.key!==void 0&&(y=""+m.key),m.ref!==void 0&&(k=m.ref);for(_ in m)s.call(m,_)&&!a.hasOwnProperty(_)&&(S[_]=m[_]);if(d&&d.defaultProps)for(_ in m=d.defaultProps,m)S[_]===void 0&&(S[_]=m[_]);return{$$typeof:t,type:d,key:y,ref:k,props:S,_owner:o.current}}return Hs.Fragment=i,Hs.jsx=c,Hs.jsxs=c,Hs}var nm;function Mw(){return nm||(nm=1,Gc.exports=Dw()),Gc.exports}var h=Mw(),P=Hh();const Lw=Fh(P);var ka={},Jc={exports:{}},li={},Zc={exports:{}},eu={};/**
|
|
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 rm;function jw(){return rm||(rm=1,(function(e){function t(B,te){var q=B.length;B.push(te);e:for(;0<q;){var j=q-1>>>1,$=B[j];if(0<o($,te))B[j]=te,B[q]=$,q=j;else break e}}function i(B){return B.length===0?null:B[0]}function s(B){if(B.length===0)return null;var te=B[0],q=B.pop();if(q!==te){B[0]=q;e:for(var j=0,$=B.length,re=$>>>1;j<re;){var le=2*(j+1)-1,se=B[le],pe=le+1,ye=B[pe];if(0>o(se,q))pe<$&&0>o(ye,se)?(B[j]=ye,B[pe]=q,j=pe):(B[j]=se,B[le]=q,j=le);else if(pe<$&&0>o(ye,q))B[j]=ye,B[pe]=q,j=pe;else break e}}return te}function o(B,te){var q=B.sortIndex-te.sortIndex;return q!==0?q:B.id-te.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],p=[],_=1,S=null,y=3,k=!1,w=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(B){for(var te=i(p);te!==null;){if(te.callback===null)s(p);else if(te.startTime<=B)s(p),te.sortIndex=te.expirationTime,t(m,te);else break;te=i(p)}}function T(B){if(x=!1,L(B),!w)if(i(m)!==null)w=!0,D(J);else{var te=i(p);te!==null&&z(T,te.startTime-B)}}function J(B,te){w=!1,x&&(x=!1,C(G),G=-1),k=!0;var q=y;try{for(L(te),S=i(m);S!==null&&(!(S.expirationTime>te)||B&&!X());){var j=S.callback;if(typeof j=="function"){S.callback=null,y=S.priorityLevel;var $=j(S.expirationTime<=te);te=e.unstable_now(),typeof $=="function"?S.callback=$:S===i(m)&&s(m),L(te)}else s(m);S=i(m)}if(S!==null)var re=!0;else{var le=i(p);le!==null&&z(T,le.startTime-te),re=!1}return re}finally{S=null,y=q,k=!1}}var H=!1,F=null,G=-1,W=5,V=-1;function X(){return!(e.unstable_now()-V<W)}function A(){if(F!==null){var B=e.unstable_now();V=B;var te=!0;try{te=F(!0,B)}finally{te?N():(H=!1,F=null)}}else H=!1}var N;if(typeof M=="function")N=function(){M(A)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,O=R.port2;R.port1.onmessage=A,N=function(){O.postMessage(null)}}else N=function(){b(A,0)};function D(B){F=B,H||(H=!0,N())}function z(B,te){G=b(function(){B(e.unstable_now())},te)}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(B){B.callback=null},e.unstable_continueExecution=function(){w||k||(w=!0,D(J))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return i(m)},e.unstable_next=function(B){switch(y){case 1:case 2:case 3:var te=3;break;default:te=y}var q=y;y=te;try{return B()}finally{y=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,te){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var q=y;y=B;try{return te()}finally{y=q}},e.unstable_scheduleCallback=function(B,te,q){var j=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?j+q:j):q=j,B){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=q+$,B={id:_++,callback:te,priorityLevel:B,startTime:q,expirationTime:$,sortIndex:-1},q>j?(B.sortIndex=q,t(p,B),i(m)===null&&B===i(p)&&(x?(C(G),G=-1):x=!0,z(T,q-j))):(B.sortIndex=$,t(m,B),w||k||(w=!0,D(J))),B},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(B){var te=y;return function(){var q=y;y=te;try{return B.apply(this,arguments)}finally{y=q}}}})(eu)),eu}var sm;function Tw(){return sm||(sm=1,Zc.exports=jw()),Zc.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 om;function Aw(){if(om)return li;om=1;var e=Hh(),t=Tw();function i(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(n,r){c(n,r),c(n+"Capture",r)}function c(n,r){for(o[n]=r,n=0;n<r.length;n++)s.add(r[n])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,_={},S={};function y(n){return m.call(S,n)?!0:m.call(_,n)?!1:p.test(n)?S[n]=!0:(_[n]=!0,!1)}function k(n,r,l,u){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return u?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function w(n,r,l,u){if(r===null||typeof r>"u"||k(n,r,l,u))return!0;if(u)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function x(n,r,l,u,f,g,E){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=u,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=E}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){b[n]=new x(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];b[r]=new x(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){b[n]=new x(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){b[n]=new x(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){b[n]=new x(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){b[n]=new x(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){b[n]=new x(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){b[n]=new x(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){b[n]=new x(n,5,!1,n.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function M(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace(C,M);b[r]=new x(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(C,M);b[r]=new x(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(C,M);b[r]=new x(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){b[n]=new x(n,1,!1,n.toLowerCase(),null,!1,!1)}),b.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){b[n]=new x(n,1,!1,n.toLowerCase(),null,!0,!0)});function L(n,r,l,u){var f=b.hasOwnProperty(r)?b[r]:null;(f!==null?f.type!==0:u||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(w(r,l,f,u)&&(l=null),u||f===null?y(r)&&(l===null?n.removeAttribute(r):n.setAttribute(r,""+l)):f.mustUseProperty?n[f.propertyName]=l===null?f.type===3?!1:"":l:(r=f.attributeName,u=f.attributeNamespace,l===null?n.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,u?n.setAttributeNS(u,r,l):n.setAttribute(r,l))))}var T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,J=Symbol.for("react.element"),H=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),X=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),z=Symbol.for("react.offscreen"),B=Symbol.iterator;function te(n){return n===null||typeof n!="object"?null:(n=B&&n[B]||n["@@iterator"],typeof n=="function"?n:null)}var q=Object.assign,j;function $(n){if(j===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);j=r&&r[1]||""}return`
|
|
34
|
+
`+j+n}var re=!1;function le(n,r){if(!n||re)return"";re=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(ne){var u=ne}Reflect.construct(n,[],r)}else{try{r.call()}catch(ne){u=ne}n.call(r.prototype)}else{try{throw Error()}catch(ne){u=ne}n()}}catch(ne){if(ne&&u&&typeof ne.stack=="string"){for(var f=ne.stack.split(`
|
|
35
|
+
`),g=u.stack.split(`
|
|
36
|
+
`),E=f.length-1,I=g.length-1;1<=E&&0<=I&&f[E]!==g[I];)I--;for(;1<=E&&0<=I;E--,I--)if(f[E]!==g[I]){if(E!==1||I!==1)do if(E--,I--,0>I||f[E]!==g[I]){var U=`
|
|
37
|
+
`+f[E].replace(" at new "," at ");return n.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",n.displayName)),U}while(1<=E&&0<=I);break}}}finally{re=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?$(n):""}function se(n){switch(n.tag){case 5:return $(n.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return n=le(n.type,!1),n;case 11:return n=le(n.type.render,!1),n;case 1:return n=le(n.type,!0),n;default:return""}}function pe(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case F:return"Fragment";case H:return"Portal";case W:return"Profiler";case G:return"StrictMode";case N:return"Suspense";case R:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case X:return(n.displayName||"Context")+".Consumer";case V:return(n._context.displayName||"Context")+".Provider";case A:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case O:return r=n.displayName||null,r!==null?r:pe(n.type)||"Memo";case D:r=n._payload,n=n._init;try{return pe(n(r))}catch{}}return null}function ye(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(r);case 8:return r===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function ce(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Ce(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Oe(n){var r=Ce(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),u=""+n[r];if(!n.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,g=l.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return f.call(this)},set:function(E){u=""+E,g.call(this,E)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return u},setValue:function(E){u=""+E},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function Ze(n){n._valueTracker||(n._valueTracker=Oe(n))}function Ve(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),u="";return n&&(u=Ce(n)?n.checked?"true":"false":n.value),n=u,n!==l?(r.setValue(n),!0):!1}function Ae(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function ot(n,r){var l=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function Et(n,r){var l=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;l=ce(r.value!=null?r.value:l),n._wrapperState={initialChecked:u,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function ie(n,r){r=r.checked,r!=null&&L(n,"checked",r,!1)}function ae(n,r){ie(n,r);var l=ce(r.value),u=r.type;if(l!=null)u==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(u==="submit"||u==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?Q(n,r.type,l):r.hasOwnProperty("defaultValue")&&Q(n,r.type,ce(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function ze(n,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,l||r===n.value||(n.value=r),n.defaultValue=r}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function Q(n,r,l){(r!=="number"||Ae(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var ue=Array.isArray;function K(n,r,l,u){if(n=n.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<n.length;l++)f=r.hasOwnProperty("$"+n[l].value),n[l].selected!==f&&(n[l].selected=f),f&&u&&(n[l].defaultSelected=!0)}else{for(l=""+ce(l),r=null,f=0;f<n.length;f++){if(n[f].value===l){n[f].selected=!0,u&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function me(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return q({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function be(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(i(92));if(ue(l)){if(1<l.length)throw Error(i(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:ce(l)}}function Pe(n,r){var l=ce(r.value),u=ce(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),u!=null&&(n.defaultValue=""+u)}function he(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Ee(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function xe(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Ee(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var $e,Je=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,u,f){MSApp.execUnsafeLocalFunction(function(){return n(r,l,u,f)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for($e=$e||document.createElement("div"),$e.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=$e.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function De(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var fe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Be=["Webkit","ms","Moz","O"];Object.keys(fe).forEach(function(n){Be.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),fe[r]=fe[n]})});function je(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||fe.hasOwnProperty(n)&&fe[n]?(""+r).trim():r+"px"}function oe(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var u=l.indexOf("--")===0,f=je(l,r[l],u);l==="float"&&(l="cssFloat"),u?n.setProperty(l,f):n[l]=f}}var ke=q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ke(n,r){if(r){if(ke[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function ut(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Qt=null;function hl(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var dl=null,_r=null,yr=null;function gd(n){if(n=Es(n)){if(typeof dl!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Oo(r),dl(n.stateNode,n.type,r))}}function vd(n){_r?yr?yr.push(n):yr=[n]:_r=n}function _d(){if(_r){var n=_r,r=yr;if(yr=_r=null,gd(n),r)for(n=0;n<r.length;n++)gd(r[n])}}function yd(n,r){return n(r)}function Sd(){}var fl=!1;function wd(n,r,l){if(fl)return n(r,l);fl=!0;try{return yd(n,r,l)}finally{fl=!1,(_r!==null||yr!==null)&&(Sd(),_d())}}function ss(n,r){var l=n.stateNode;if(l===null)return null;var u=Oo(l);if(u===null)return null;l=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var pl=!1;if(d)try{var os={};Object.defineProperty(os,"passive",{get:function(){pl=!0}}),window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{pl=!1}function Ay(n,r,l,u,f,g,E,I,U){var ne=Array.prototype.slice.call(arguments,3);try{r.apply(l,ne)}catch(ve){this.onError(ve)}}var as=!1,go=null,vo=!1,ml=null,Iy={onError:function(n){as=!0,go=n}};function By(n,r,l,u,f,g,E,I,U){as=!1,go=null,Ay.apply(Iy,arguments)}function Oy(n,r,l,u,f,g,E,I,U){if(By.apply(this,arguments),as){if(as){var ne=go;as=!1,go=null}else throw Error(i(198));vo||(vo=!0,ml=ne)}}function Un(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function bd(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function kd(n){if(Un(n)!==n)throw Error(i(188))}function zy(n){var r=n.alternate;if(!r){if(r=Un(n),r===null)throw Error(i(188));return r!==n?null:n}for(var l=n,u=r;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(u=f.return,u!==null){l=u;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return kd(f),n;if(g===u)return kd(f),r;g=g.sibling}throw Error(i(188))}if(l.return!==u.return)l=f,u=g;else{for(var E=!1,I=f.child;I;){if(I===l){E=!0,l=f,u=g;break}if(I===u){E=!0,u=f,l=g;break}I=I.sibling}if(!E){for(I=g.child;I;){if(I===l){E=!0,l=g,u=f;break}if(I===u){E=!0,u=g,l=f;break}I=I.sibling}if(!E)throw Error(i(189))}}if(l.alternate!==u)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:r}function Cd(n){return n=zy(n),n!==null?xd(n):null}function xd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=xd(n);if(r!==null)return r;n=n.sibling}return null}var Ed=t.unstable_scheduleCallback,Nd=t.unstable_cancelCallback,Fy=t.unstable_shouldYield,Hy=t.unstable_requestPaint,St=t.unstable_now,$y=t.unstable_getCurrentPriorityLevel,gl=t.unstable_ImmediatePriority,Rd=t.unstable_UserBlockingPriority,_o=t.unstable_NormalPriority,Wy=t.unstable_LowPriority,Pd=t.unstable_IdlePriority,yo=null,Fi=null;function Uy(n){if(Fi&&typeof Fi.onCommitFiberRoot=="function")try{Fi.onCommitFiberRoot(yo,n,void 0,(n.current.flags&128)===128)}catch{}}var Li=Math.clz32?Math.clz32:Vy,Ky=Math.log,qy=Math.LN2;function Vy(n){return n>>>=0,n===0?32:31-(Ky(n)/qy|0)|0}var So=64,wo=4194304;function ls(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function bo(n,r){var l=n.pendingLanes;if(l===0)return 0;var u=0,f=n.suspendedLanes,g=n.pingedLanes,E=l&268435455;if(E!==0){var I=E&~f;I!==0?u=ls(I):(g&=E,g!==0&&(u=ls(g)))}else E=l&~f,E!==0?u=ls(E):g!==0&&(u=ls(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&f)===0&&(f=u&-u,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=u;0<r;)l=31-Li(r),f=1<<l,u|=n[l],r&=~f;return u}function Yy(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xy(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var E=31-Li(g),I=1<<E,U=f[E];U===-1?((I&l)===0||(I&u)!==0)&&(f[E]=Yy(I,r)):U<=r&&(n.expiredLanes|=I),g&=~I}}function vl(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Dd(){var n=So;return So<<=1,(So&4194240)===0&&(So=64),n}function _l(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function cs(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Li(r),n[r]=l}function Gy(n,r){var l=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var u=n.eventTimes;for(n=n.expirationTimes;0<l;){var f=31-Li(l),g=1<<f;r[f]=0,u[f]=-1,n[f]=-1,l&=~g}}function yl(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var u=31-Li(l),f=1<<u;f&r|n[u]&r&&(n[u]|=r),l&=~f}}var nt=0;function Md(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Ld,Sl,jd,Td,Ad,wl=!1,ko=[],mn=null,gn=null,vn=null,us=new Map,hs=new Map,_n=[],Qy="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 Id(n,r){switch(n){case"focusin":case"focusout":mn=null;break;case"dragenter":case"dragleave":gn=null;break;case"mouseover":case"mouseout":vn=null;break;case"pointerover":case"pointerout":us.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":hs.delete(r.pointerId)}}function ds(n,r,l,u,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Es(r),r!==null&&Sl(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function Jy(n,r,l,u,f){switch(r){case"focusin":return mn=ds(mn,n,r,l,u,f),!0;case"dragenter":return gn=ds(gn,n,r,l,u,f),!0;case"mouseover":return vn=ds(vn,n,r,l,u,f),!0;case"pointerover":var g=f.pointerId;return us.set(g,ds(us.get(g)||null,n,r,l,u,f)),!0;case"gotpointercapture":return g=f.pointerId,hs.set(g,ds(hs.get(g)||null,n,r,l,u,f)),!0}return!1}function Bd(n){var r=Kn(n.target);if(r!==null){var l=Un(r);if(l!==null){if(r=l.tag,r===13){if(r=bd(l),r!==null){n.blockedOn=r,Ad(n.priority,function(){jd(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Co(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=kl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var u=new l.constructor(l.type,l);Qt=u,l.target.dispatchEvent(u),Qt=null}else return r=Es(l),r!==null&&Sl(r),n.blockedOn=l,!1;r.shift()}return!0}function Od(n,r,l){Co(n)&&l.delete(r)}function Zy(){wl=!1,mn!==null&&Co(mn)&&(mn=null),gn!==null&&Co(gn)&&(gn=null),vn!==null&&Co(vn)&&(vn=null),us.forEach(Od),hs.forEach(Od)}function fs(n,r){n.blockedOn===r&&(n.blockedOn=null,wl||(wl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Zy)))}function ps(n){function r(f){return fs(f,n)}if(0<ko.length){fs(ko[0],n);for(var l=1;l<ko.length;l++){var u=ko[l];u.blockedOn===n&&(u.blockedOn=null)}}for(mn!==null&&fs(mn,n),gn!==null&&fs(gn,n),vn!==null&&fs(vn,n),us.forEach(r),hs.forEach(r),l=0;l<_n.length;l++)u=_n[l],u.blockedOn===n&&(u.blockedOn=null);for(;0<_n.length&&(l=_n[0],l.blockedOn===null);)Bd(l),l.blockedOn===null&&_n.shift()}var Sr=T.ReactCurrentBatchConfig,xo=!0;function eS(n,r,l,u){var f=nt,g=Sr.transition;Sr.transition=null;try{nt=1,bl(n,r,l,u)}finally{nt=f,Sr.transition=g}}function tS(n,r,l,u){var f=nt,g=Sr.transition;Sr.transition=null;try{nt=4,bl(n,r,l,u)}finally{nt=f,Sr.transition=g}}function bl(n,r,l,u){if(xo){var f=kl(n,r,l,u);if(f===null)Fl(n,r,u,Eo,l),Id(n,u);else if(Jy(f,n,r,l,u))u.stopPropagation();else if(Id(n,u),r&4&&-1<Qy.indexOf(n)){for(;f!==null;){var g=Es(f);if(g!==null&&Ld(g),g=kl(n,r,l,u),g===null&&Fl(n,r,u,Eo,l),g===f)break;f=g}f!==null&&u.stopPropagation()}else Fl(n,r,u,null,l)}}var Eo=null;function kl(n,r,l,u){if(Eo=null,n=hl(u),n=Kn(n),n!==null)if(r=Un(n),r===null)n=null;else if(l=r.tag,l===13){if(n=bd(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return Eo=n,null}function zd(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($y()){case gl:return 1;case Rd:return 4;case _o:case Wy:return 16;case Pd:return 536870912;default:return 16}default:return 16}}var yn=null,Cl=null,No=null;function Fd(){if(No)return No;var n,r=Cl,l=r.length,u,f="value"in yn?yn.value:yn.textContent,g=f.length;for(n=0;n<l&&r[n]===f[n];n++);var E=l-n;for(u=1;u<=E&&r[l-u]===f[g-u];u++);return No=f.slice(n,1<u?1-u:void 0)}function Ro(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Po(){return!0}function Hd(){return!1}function di(n){function r(l,u,f,g,E){this._reactName=l,this._targetInst=f,this.type=u,this.nativeEvent=g,this.target=E,this.currentTarget=null;for(var I in n)n.hasOwnProperty(I)&&(l=n[I],this[I]=l?l(g):g[I]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Po:Hd,this.isPropagationStopped=Hd,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Po)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Po)},persist:function(){},isPersistent:Po}),r}var wr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xl=di(wr),ms=q({},wr,{view:0,detail:0}),iS=di(ms),El,Nl,gs,Do=q({},ms,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Pl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==gs&&(gs&&n.type==="mousemove"?(El=n.screenX-gs.screenX,Nl=n.screenY-gs.screenY):Nl=El=0,gs=n),El)},movementY:function(n){return"movementY"in n?n.movementY:Nl}}),$d=di(Do),nS=q({},Do,{dataTransfer:0}),rS=di(nS),sS=q({},ms,{relatedTarget:0}),Rl=di(sS),oS=q({},wr,{animationName:0,elapsedTime:0,pseudoElement:0}),aS=di(oS),lS=q({},wr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),cS=di(lS),uS=q({},wr,{data:0}),Wd=di(uS),hS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dS={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"},fS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=fS[n])?!!r[n]:!1}function Pl(){return pS}var mS=q({},ms,{key:function(n){if(n.key){var r=hS[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Ro(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?dS[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Pl,charCode:function(n){return n.type==="keypress"?Ro(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Ro(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),gS=di(mS),vS=q({},Do,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ud=di(vS),_S=q({},ms,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Pl}),yS=di(_S),SS=q({},wr,{propertyName:0,elapsedTime:0,pseudoElement:0}),wS=di(SS),bS=q({},Do,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),kS=di(bS),CS=[9,13,27,32],Dl=d&&"CompositionEvent"in window,vs=null;d&&"documentMode"in document&&(vs=document.documentMode);var xS=d&&"TextEvent"in window&&!vs,Kd=d&&(!Dl||vs&&8<vs&&11>=vs),qd=" ",Vd=!1;function Yd(n,r){switch(n){case"keyup":return CS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var br=!1;function ES(n,r){switch(n){case"compositionend":return Xd(r);case"keypress":return r.which!==32?null:(Vd=!0,qd);case"textInput":return n=r.data,n===qd&&Vd?null:n;default:return null}}function NS(n,r){if(br)return n==="compositionend"||!Dl&&Yd(n,r)?(n=Fd(),No=Cl=yn=null,br=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Kd&&r.locale!=="ko"?null:r.data;default:return null}}var RS={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 Gd(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!RS[n.type]:r==="textarea"}function Qd(n,r,l,u){vd(u),r=Ao(r,"onChange"),0<r.length&&(l=new xl("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var _s=null,ys=null;function PS(n){gf(n,0)}function Mo(n){var r=Nr(n);if(Ve(r))return n}function DS(n,r){if(n==="change")return r}var Jd=!1;if(d){var Ml;if(d){var Ll="oninput"in document;if(!Ll){var Zd=document.createElement("div");Zd.setAttribute("oninput","return;"),Ll=typeof Zd.oninput=="function"}Ml=Ll}else Ml=!1;Jd=Ml&&(!document.documentMode||9<document.documentMode)}function ef(){_s&&(_s.detachEvent("onpropertychange",tf),ys=_s=null)}function tf(n){if(n.propertyName==="value"&&Mo(ys)){var r=[];Qd(r,ys,n,hl(n)),wd(PS,r)}}function MS(n,r,l){n==="focusin"?(ef(),_s=r,ys=l,_s.attachEvent("onpropertychange",tf)):n==="focusout"&&ef()}function LS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Mo(ys)}function jS(n,r){if(n==="click")return Mo(r)}function TS(n,r){if(n==="input"||n==="change")return Mo(r)}function AS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var ji=typeof Object.is=="function"?Object.is:AS;function Ss(n,r){if(ji(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),u=Object.keys(r);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var f=l[u];if(!m.call(r,f)||!ji(n[f],r[f]))return!1}return!0}function nf(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function rf(n,r){var l=nf(n);n=0;for(var u;l;){if(l.nodeType===3){if(u=n+l.textContent.length,n<=r&&u>=r)return{node:l,offset:r-n};n=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=nf(l)}}function sf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?sf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function of(){for(var n=window,r=Ae();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=Ae(n.document)}return r}function jl(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function IS(n){var r=of(),l=n.focusedElem,u=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&sf(l.ownerDocument.documentElement,l)){if(u!==null&&jl(l)){if(r=u.start,n=u.end,n===void 0&&(n=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(n,l.value.length);else if(n=(r=l.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var f=l.textContent.length,g=Math.min(u.start,f);u=u.end===void 0?g:Math.min(u.end,f),!n.extend&&g>u&&(f=u,u=g,g=f),f=rf(l,g);var E=rf(l,u);f&&E&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==E.node||n.focusOffset!==E.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),n.removeAllRanges(),g>u?(n.addRange(r),n.extend(E.node,E.offset)):(r.setEnd(E.node,E.offset),n.addRange(r)))}}for(r=[],n=l;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)n=r[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var BS=d&&"documentMode"in document&&11>=document.documentMode,kr=null,Tl=null,ws=null,Al=!1;function af(n,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Al||kr==null||kr!==Ae(u)||(u=kr,"selectionStart"in u&&jl(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ws&&Ss(ws,u)||(ws=u,u=Ao(Tl,"onSelect"),0<u.length&&(r=new xl("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=kr)))}function Lo(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Cr={animationend:Lo("Animation","AnimationEnd"),animationiteration:Lo("Animation","AnimationIteration"),animationstart:Lo("Animation","AnimationStart"),transitionend:Lo("Transition","TransitionEnd")},Il={},lf={};d&&(lf=document.createElement("div").style,"AnimationEvent"in window||(delete Cr.animationend.animation,delete Cr.animationiteration.animation,delete Cr.animationstart.animation),"TransitionEvent"in window||delete Cr.transitionend.transition);function jo(n){if(Il[n])return Il[n];if(!Cr[n])return n;var r=Cr[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in lf)return Il[n]=r[l];return n}var cf=jo("animationend"),uf=jo("animationiteration"),hf=jo("animationstart"),df=jo("transitionend"),ff=new Map,pf="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 Sn(n,r){ff.set(n,r),a(r,[n])}for(var Bl=0;Bl<pf.length;Bl++){var Ol=pf[Bl],OS=Ol.toLowerCase(),zS=Ol[0].toUpperCase()+Ol.slice(1);Sn(OS,"on"+zS)}Sn(cf,"onAnimationEnd"),Sn(uf,"onAnimationIteration"),Sn(hf,"onAnimationStart"),Sn("dblclick","onDoubleClick"),Sn("focusin","onFocus"),Sn("focusout","onBlur"),Sn(df,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bs="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(" "),FS=new Set("cancel close invalid load scroll toggle".split(" ").concat(bs));function mf(n,r,l){var u=n.type||"unknown-event";n.currentTarget=l,Oy(u,r,void 0,n),n.currentTarget=null}function gf(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var u=n[l],f=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var E=u.length-1;0<=E;E--){var I=u[E],U=I.instance,ne=I.currentTarget;if(I=I.listener,U!==g&&f.isPropagationStopped())break e;mf(f,I,ne),g=U}else for(E=0;E<u.length;E++){if(I=u[E],U=I.instance,ne=I.currentTarget,I=I.listener,U!==g&&f.isPropagationStopped())break e;mf(f,I,ne),g=U}}}if(vo)throw n=ml,vo=!1,ml=null,n}function at(n,r){var l=r[ql];l===void 0&&(l=r[ql]=new Set);var u=n+"__bubble";l.has(u)||(vf(r,n,2,!1),l.add(u))}function zl(n,r,l){var u=0;r&&(u|=4),vf(l,n,u,r)}var To="_reactListening"+Math.random().toString(36).slice(2);function ks(n){if(!n[To]){n[To]=!0,s.forEach(function(l){l!=="selectionchange"&&(FS.has(l)||zl(l,!1,n),zl(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[To]||(r[To]=!0,zl("selectionchange",!1,r))}}function vf(n,r,l,u){switch(zd(r)){case 1:var f=eS;break;case 4:f=tS;break;default:f=bl}l=f.bind(null,r,l,n),f=void 0,!pl||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),u?f!==void 0?n.addEventListener(r,l,{capture:!0,passive:f}):n.addEventListener(r,l,!0):f!==void 0?n.addEventListener(r,l,{passive:f}):n.addEventListener(r,l,!1)}function Fl(n,r,l,u,f){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var E=u.tag;if(E===3||E===4){var I=u.stateNode.containerInfo;if(I===f||I.nodeType===8&&I.parentNode===f)break;if(E===4)for(E=u.return;E!==null;){var U=E.tag;if((U===3||U===4)&&(U=E.stateNode.containerInfo,U===f||U.nodeType===8&&U.parentNode===f))return;E=E.return}for(;I!==null;){if(E=Kn(I),E===null)return;if(U=E.tag,U===5||U===6){u=g=E;continue e}I=I.parentNode}}u=u.return}wd(function(){var ne=g,ve=hl(l),_e=[];e:{var ge=ff.get(n);if(ge!==void 0){var Re=xl,Le=n;switch(n){case"keypress":if(Ro(l)===0)break e;case"keydown":case"keyup":Re=gS;break;case"focusin":Le="focus",Re=Rl;break;case"focusout":Le="blur",Re=Rl;break;case"beforeblur":case"afterblur":Re=Rl;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Re=$d;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Re=rS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Re=yS;break;case cf:case uf:case hf:Re=aS;break;case df:Re=wS;break;case"scroll":Re=iS;break;case"wheel":Re=kS;break;case"copy":case"cut":case"paste":Re=cS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Re=Ud}var Te=(r&4)!==0,wt=!Te&&n==="scroll",Z=Te?ge!==null?ge+"Capture":null:ge;Te=[];for(var Y=ne,ee;Y!==null;){ee=Y;var Se=ee.stateNode;if(ee.tag===5&&Se!==null&&(ee=Se,Z!==null&&(Se=ss(Y,Z),Se!=null&&Te.push(Cs(Y,Se,ee)))),wt)break;Y=Y.return}0<Te.length&&(ge=new Re(ge,Le,null,l,ve),_e.push({event:ge,listeners:Te}))}}if((r&7)===0){e:{if(ge=n==="mouseover"||n==="pointerover",Re=n==="mouseout"||n==="pointerout",ge&&l!==Qt&&(Le=l.relatedTarget||l.fromElement)&&(Kn(Le)||Le[tn]))break e;if((Re||ge)&&(ge=ve.window===ve?ve:(ge=ve.ownerDocument)?ge.defaultView||ge.parentWindow:window,Re?(Le=l.relatedTarget||l.toElement,Re=ne,Le=Le?Kn(Le):null,Le!==null&&(wt=Un(Le),Le!==wt||Le.tag!==5&&Le.tag!==6)&&(Le=null)):(Re=null,Le=ne),Re!==Le)){if(Te=$d,Se="onMouseLeave",Z="onMouseEnter",Y="mouse",(n==="pointerout"||n==="pointerover")&&(Te=Ud,Se="onPointerLeave",Z="onPointerEnter",Y="pointer"),wt=Re==null?ge:Nr(Re),ee=Le==null?ge:Nr(Le),ge=new Te(Se,Y+"leave",Re,l,ve),ge.target=wt,ge.relatedTarget=ee,Se=null,Kn(ve)===ne&&(Te=new Te(Z,Y+"enter",Le,l,ve),Te.target=ee,Te.relatedTarget=wt,Se=Te),wt=Se,Re&&Le)t:{for(Te=Re,Z=Le,Y=0,ee=Te;ee;ee=xr(ee))Y++;for(ee=0,Se=Z;Se;Se=xr(Se))ee++;for(;0<Y-ee;)Te=xr(Te),Y--;for(;0<ee-Y;)Z=xr(Z),ee--;for(;Y--;){if(Te===Z||Z!==null&&Te===Z.alternate)break t;Te=xr(Te),Z=xr(Z)}Te=null}else Te=null;Re!==null&&_f(_e,ge,Re,Te,!1),Le!==null&&wt!==null&&_f(_e,wt,Le,Te,!0)}}e:{if(ge=ne?Nr(ne):window,Re=ge.nodeName&&ge.nodeName.toLowerCase(),Re==="select"||Re==="input"&&ge.type==="file")var Ie=DS;else if(Gd(ge))if(Jd)Ie=TS;else{Ie=LS;var Fe=MS}else(Re=ge.nodeName)&&Re.toLowerCase()==="input"&&(ge.type==="checkbox"||ge.type==="radio")&&(Ie=jS);if(Ie&&(Ie=Ie(n,ne))){Qd(_e,Ie,l,ve);break e}Fe&&Fe(n,ge,ne),n==="focusout"&&(Fe=ge._wrapperState)&&Fe.controlled&&ge.type==="number"&&Q(ge,"number",ge.value)}switch(Fe=ne?Nr(ne):window,n){case"focusin":(Gd(Fe)||Fe.contentEditable==="true")&&(kr=Fe,Tl=ne,ws=null);break;case"focusout":ws=Tl=kr=null;break;case"mousedown":Al=!0;break;case"contextmenu":case"mouseup":case"dragend":Al=!1,af(_e,l,ve);break;case"selectionchange":if(BS)break;case"keydown":case"keyup":af(_e,l,ve)}var He;if(Dl)e:{switch(n){case"compositionstart":var We="onCompositionStart";break e;case"compositionend":We="onCompositionEnd";break e;case"compositionupdate":We="onCompositionUpdate";break e}We=void 0}else br?Yd(n,l)&&(We="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(We="onCompositionStart");We&&(Kd&&l.locale!=="ko"&&(br||We!=="onCompositionStart"?We==="onCompositionEnd"&&br&&(He=Fd()):(yn=ve,Cl="value"in yn?yn.value:yn.textContent,br=!0)),Fe=Ao(ne,We),0<Fe.length&&(We=new Wd(We,n,null,l,ve),_e.push({event:We,listeners:Fe}),He?We.data=He:(He=Xd(l),He!==null&&(We.data=He)))),(He=xS?ES(n,l):NS(n,l))&&(ne=Ao(ne,"onBeforeInput"),0<ne.length&&(ve=new Wd("onBeforeInput","beforeinput",null,l,ve),_e.push({event:ve,listeners:ne}),ve.data=He))}gf(_e,r)})}function Cs(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Ao(n,r){for(var l=r+"Capture",u=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=ss(n,l),g!=null&&u.unshift(Cs(n,g,f)),g=ss(n,r),g!=null&&u.push(Cs(n,g,f))),n=n.return}return u}function xr(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function _f(n,r,l,u,f){for(var g=r._reactName,E=[];l!==null&&l!==u;){var I=l,U=I.alternate,ne=I.stateNode;if(U!==null&&U===u)break;I.tag===5&&ne!==null&&(I=ne,f?(U=ss(l,g),U!=null&&E.unshift(Cs(l,U,I))):f||(U=ss(l,g),U!=null&&E.push(Cs(l,U,I)))),l=l.return}E.length!==0&&n.push({event:r,listeners:E})}var HS=/\r\n?/g,$S=/\u0000|\uFFFD/g;function yf(n){return(typeof n=="string"?n:""+n).replace(HS,`
|
|
38
|
+
`).replace($S,"")}function Io(n,r,l){if(r=yf(r),yf(n)!==r&&l)throw Error(i(425))}function Bo(){}var Hl=null,$l=null;function Wl(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Ul=typeof setTimeout=="function"?setTimeout:void 0,WS=typeof clearTimeout=="function"?clearTimeout:void 0,Sf=typeof Promise=="function"?Promise:void 0,US=typeof queueMicrotask=="function"?queueMicrotask:typeof Sf<"u"?function(n){return Sf.resolve(null).then(n).catch(KS)}:Ul;function KS(n){setTimeout(function(){throw n})}function Kl(n,r){var l=r,u=0;do{var f=l.nextSibling;if(n.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(u===0){n.removeChild(f),ps(r);return}u--}else l!=="$"&&l!=="$?"&&l!=="$!"||u++;l=f}while(l);ps(r)}function wn(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function wf(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Er=Math.random().toString(36).slice(2),Hi="__reactFiber$"+Er,xs="__reactProps$"+Er,tn="__reactContainer$"+Er,ql="__reactEvents$"+Er,qS="__reactListeners$"+Er,VS="__reactHandles$"+Er;function Kn(n){var r=n[Hi];if(r)return r;for(var l=n.parentNode;l;){if(r=l[tn]||l[Hi]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=wf(n);n!==null;){if(l=n[Hi])return l;n=wf(n)}return r}n=l,l=n.parentNode}return null}function Es(n){return n=n[Hi]||n[tn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Nr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Oo(n){return n[xs]||null}var Vl=[],Rr=-1;function bn(n){return{current:n}}function lt(n){0>Rr||(n.current=Vl[Rr],Vl[Rr]=null,Rr--)}function st(n,r){Rr++,Vl[Rr]=n.current,n.current=r}var kn={},qt=bn(kn),ni=bn(!1),qn=kn;function Pr(n,r){var l=n.type.contextTypes;if(!l)return kn;var u=n.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in l)f[g]=r[g];return u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function ri(n){return n=n.childContextTypes,n!=null}function zo(){lt(ni),lt(qt)}function bf(n,r,l){if(qt.current!==kn)throw Error(i(168));st(qt,r),st(ni,l)}function kf(n,r,l){var u=n.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return l;u=u.getChildContext();for(var f in u)if(!(f in r))throw Error(i(108,ye(n)||"Unknown",f));return q({},l,u)}function Fo(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||kn,qn=qt.current,st(qt,n),st(ni,ni.current),!0}function Cf(n,r,l){var u=n.stateNode;if(!u)throw Error(i(169));l?(n=kf(n,r,qn),u.__reactInternalMemoizedMergedChildContext=n,lt(ni),lt(qt),st(qt,n)):lt(ni),st(ni,l)}var nn=null,Ho=!1,Yl=!1;function xf(n){nn===null?nn=[n]:nn.push(n)}function YS(n){Ho=!0,xf(n)}function Cn(){if(!Yl&&nn!==null){Yl=!0;var n=0,r=nt;try{var l=nn;for(nt=1;n<l.length;n++){var u=l[n];do u=u(!0);while(u!==null)}nn=null,Ho=!1}catch(f){throw nn!==null&&(nn=nn.slice(n+1)),Ed(gl,Cn),f}finally{nt=r,Yl=!1}}return null}var Dr=[],Mr=0,$o=null,Wo=0,wi=[],bi=0,Vn=null,rn=1,sn="";function Yn(n,r){Dr[Mr++]=Wo,Dr[Mr++]=$o,$o=n,Wo=r}function Ef(n,r,l){wi[bi++]=rn,wi[bi++]=sn,wi[bi++]=Vn,Vn=n;var u=rn;n=sn;var f=32-Li(u)-1;u&=~(1<<f),l+=1;var g=32-Li(r)+f;if(30<g){var E=f-f%5;g=(u&(1<<E)-1).toString(32),u>>=E,f-=E,rn=1<<32-Li(r)+f|l<<f|u,sn=g+n}else rn=1<<g|l<<f|u,sn=n}function Xl(n){n.return!==null&&(Yn(n,1),Ef(n,1,0))}function Gl(n){for(;n===$o;)$o=Dr[--Mr],Dr[Mr]=null,Wo=Dr[--Mr],Dr[Mr]=null;for(;n===Vn;)Vn=wi[--bi],wi[bi]=null,sn=wi[--bi],wi[bi]=null,rn=wi[--bi],wi[bi]=null}var fi=null,pi=null,ht=!1,Ti=null;function Nf(n,r){var l=Ei(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function Rf(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,fi=n,pi=wn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,fi=n,pi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Vn!==null?{id:rn,overflow:sn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Ei(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,fi=n,pi=null,!0):!1;default:return!1}}function Ql(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Jl(n){if(ht){var r=pi;if(r){var l=r;if(!Rf(n,r)){if(Ql(n))throw Error(i(418));r=wn(l.nextSibling);var u=fi;r&&Rf(n,r)?Nf(u,l):(n.flags=n.flags&-4097|2,ht=!1,fi=n)}}else{if(Ql(n))throw Error(i(418));n.flags=n.flags&-4097|2,ht=!1,fi=n}}}function Pf(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;fi=n}function Uo(n){if(n!==fi)return!1;if(!ht)return Pf(n),ht=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!Wl(n.type,n.memoizedProps)),r&&(r=pi)){if(Ql(n))throw Df(),Error(i(418));for(;r;)Nf(n,r),r=wn(r.nextSibling)}if(Pf(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){pi=wn(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}pi=null}}else pi=fi?wn(n.stateNode.nextSibling):null;return!0}function Df(){for(var n=pi;n;)n=wn(n.nextSibling)}function Lr(){pi=fi=null,ht=!1}function Zl(n){Ti===null?Ti=[n]:Ti.push(n)}var XS=T.ReactCurrentBatchConfig;function Ns(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(i(309));var u=l.stateNode}if(!u)throw Error(i(147,n));var f=u,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(E){var I=f.refs;E===null?delete I[g]:I[g]=E},r._stringRef=g,r)}if(typeof n!="string")throw Error(i(284));if(!l._owner)throw Error(i(290,n))}return n}function Ko(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Mf(n){var r=n._init;return r(n._payload)}function Lf(n){function r(Z,Y){if(n){var ee=Z.deletions;ee===null?(Z.deletions=[Y],Z.flags|=16):ee.push(Y)}}function l(Z,Y){if(!n)return null;for(;Y!==null;)r(Z,Y),Y=Y.sibling;return null}function u(Z,Y){for(Z=new Map;Y!==null;)Y.key!==null?Z.set(Y.key,Y):Z.set(Y.index,Y),Y=Y.sibling;return Z}function f(Z,Y){return Z=Ln(Z,Y),Z.index=0,Z.sibling=null,Z}function g(Z,Y,ee){return Z.index=ee,n?(ee=Z.alternate,ee!==null?(ee=ee.index,ee<Y?(Z.flags|=2,Y):ee):(Z.flags|=2,Y)):(Z.flags|=1048576,Y)}function E(Z){return n&&Z.alternate===null&&(Z.flags|=2),Z}function I(Z,Y,ee,Se){return Y===null||Y.tag!==6?(Y=Uc(ee,Z.mode,Se),Y.return=Z,Y):(Y=f(Y,ee),Y.return=Z,Y)}function U(Z,Y,ee,Se){var Ie=ee.type;return Ie===F?ve(Z,Y,ee.props.children,Se,ee.key):Y!==null&&(Y.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===D&&Mf(Ie)===Y.type)?(Se=f(Y,ee.props),Se.ref=Ns(Z,Y,ee),Se.return=Z,Se):(Se=ma(ee.type,ee.key,ee.props,null,Z.mode,Se),Se.ref=Ns(Z,Y,ee),Se.return=Z,Se)}function ne(Z,Y,ee,Se){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==ee.containerInfo||Y.stateNode.implementation!==ee.implementation?(Y=Kc(ee,Z.mode,Se),Y.return=Z,Y):(Y=f(Y,ee.children||[]),Y.return=Z,Y)}function ve(Z,Y,ee,Se,Ie){return Y===null||Y.tag!==7?(Y=ir(ee,Z.mode,Se,Ie),Y.return=Z,Y):(Y=f(Y,ee),Y.return=Z,Y)}function _e(Z,Y,ee){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return Y=Uc(""+Y,Z.mode,ee),Y.return=Z,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case J:return ee=ma(Y.type,Y.key,Y.props,null,Z.mode,ee),ee.ref=Ns(Z,null,Y),ee.return=Z,ee;case H:return Y=Kc(Y,Z.mode,ee),Y.return=Z,Y;case D:var Se=Y._init;return _e(Z,Se(Y._payload),ee)}if(ue(Y)||te(Y))return Y=ir(Y,Z.mode,ee,null),Y.return=Z,Y;Ko(Z,Y)}return null}function ge(Z,Y,ee,Se){var Ie=Y!==null?Y.key:null;if(typeof ee=="string"&&ee!==""||typeof ee=="number")return Ie!==null?null:I(Z,Y,""+ee,Se);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case J:return ee.key===Ie?U(Z,Y,ee,Se):null;case H:return ee.key===Ie?ne(Z,Y,ee,Se):null;case D:return Ie=ee._init,ge(Z,Y,Ie(ee._payload),Se)}if(ue(ee)||te(ee))return Ie!==null?null:ve(Z,Y,ee,Se,null);Ko(Z,ee)}return null}function Re(Z,Y,ee,Se,Ie){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return Z=Z.get(ee)||null,I(Y,Z,""+Se,Ie);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case J:return Z=Z.get(Se.key===null?ee:Se.key)||null,U(Y,Z,Se,Ie);case H:return Z=Z.get(Se.key===null?ee:Se.key)||null,ne(Y,Z,Se,Ie);case D:var Fe=Se._init;return Re(Z,Y,ee,Fe(Se._payload),Ie)}if(ue(Se)||te(Se))return Z=Z.get(ee)||null,ve(Y,Z,Se,Ie,null);Ko(Y,Se)}return null}function Le(Z,Y,ee,Se){for(var Ie=null,Fe=null,He=Y,We=Y=0,Tt=null;He!==null&&We<ee.length;We++){He.index>We?(Tt=He,He=null):Tt=He.sibling;var it=ge(Z,He,ee[We],Se);if(it===null){He===null&&(He=Tt);break}n&&He&&it.alternate===null&&r(Z,He),Y=g(it,Y,We),Fe===null?Ie=it:Fe.sibling=it,Fe=it,He=Tt}if(We===ee.length)return l(Z,He),ht&&Yn(Z,We),Ie;if(He===null){for(;We<ee.length;We++)He=_e(Z,ee[We],Se),He!==null&&(Y=g(He,Y,We),Fe===null?Ie=He:Fe.sibling=He,Fe=He);return ht&&Yn(Z,We),Ie}for(He=u(Z,He);We<ee.length;We++)Tt=Re(He,Z,We,ee[We],Se),Tt!==null&&(n&&Tt.alternate!==null&&He.delete(Tt.key===null?We:Tt.key),Y=g(Tt,Y,We),Fe===null?Ie=Tt:Fe.sibling=Tt,Fe=Tt);return n&&He.forEach(function(jn){return r(Z,jn)}),ht&&Yn(Z,We),Ie}function Te(Z,Y,ee,Se){var Ie=te(ee);if(typeof Ie!="function")throw Error(i(150));if(ee=Ie.call(ee),ee==null)throw Error(i(151));for(var Fe=Ie=null,He=Y,We=Y=0,Tt=null,it=ee.next();He!==null&&!it.done;We++,it=ee.next()){He.index>We?(Tt=He,He=null):Tt=He.sibling;var jn=ge(Z,He,it.value,Se);if(jn===null){He===null&&(He=Tt);break}n&&He&&jn.alternate===null&&r(Z,He),Y=g(jn,Y,We),Fe===null?Ie=jn:Fe.sibling=jn,Fe=jn,He=Tt}if(it.done)return l(Z,He),ht&&Yn(Z,We),Ie;if(He===null){for(;!it.done;We++,it=ee.next())it=_e(Z,it.value,Se),it!==null&&(Y=g(it,Y,We),Fe===null?Ie=it:Fe.sibling=it,Fe=it);return ht&&Yn(Z,We),Ie}for(He=u(Z,He);!it.done;We++,it=ee.next())it=Re(He,Z,We,it.value,Se),it!==null&&(n&&it.alternate!==null&&He.delete(it.key===null?We:it.key),Y=g(it,Y,We),Fe===null?Ie=it:Fe.sibling=it,Fe=it);return n&&He.forEach(function(Rw){return r(Z,Rw)}),ht&&Yn(Z,We),Ie}function wt(Z,Y,ee,Se){if(typeof ee=="object"&&ee!==null&&ee.type===F&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case J:e:{for(var Ie=ee.key,Fe=Y;Fe!==null;){if(Fe.key===Ie){if(Ie=ee.type,Ie===F){if(Fe.tag===7){l(Z,Fe.sibling),Y=f(Fe,ee.props.children),Y.return=Z,Z=Y;break e}}else if(Fe.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===D&&Mf(Ie)===Fe.type){l(Z,Fe.sibling),Y=f(Fe,ee.props),Y.ref=Ns(Z,Fe,ee),Y.return=Z,Z=Y;break e}l(Z,Fe);break}else r(Z,Fe);Fe=Fe.sibling}ee.type===F?(Y=ir(ee.props.children,Z.mode,Se,ee.key),Y.return=Z,Z=Y):(Se=ma(ee.type,ee.key,ee.props,null,Z.mode,Se),Se.ref=Ns(Z,Y,ee),Se.return=Z,Z=Se)}return E(Z);case H:e:{for(Fe=ee.key;Y!==null;){if(Y.key===Fe)if(Y.tag===4&&Y.stateNode.containerInfo===ee.containerInfo&&Y.stateNode.implementation===ee.implementation){l(Z,Y.sibling),Y=f(Y,ee.children||[]),Y.return=Z,Z=Y;break e}else{l(Z,Y);break}else r(Z,Y);Y=Y.sibling}Y=Kc(ee,Z.mode,Se),Y.return=Z,Z=Y}return E(Z);case D:return Fe=ee._init,wt(Z,Y,Fe(ee._payload),Se)}if(ue(ee))return Le(Z,Y,ee,Se);if(te(ee))return Te(Z,Y,ee,Se);Ko(Z,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"?(ee=""+ee,Y!==null&&Y.tag===6?(l(Z,Y.sibling),Y=f(Y,ee),Y.return=Z,Z=Y):(l(Z,Y),Y=Uc(ee,Z.mode,Se),Y.return=Z,Z=Y),E(Z)):l(Z,Y)}return wt}var jr=Lf(!0),jf=Lf(!1),qo=bn(null),Vo=null,Tr=null,ec=null;function tc(){ec=Tr=Vo=null}function ic(n){var r=qo.current;lt(qo),n._currentValue=r}function nc(n,r,l){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===l)break;n=n.return}}function Ar(n,r){Vo=n,ec=Tr=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(si=!0),n.firstContext=null)}function ki(n){var r=n._currentValue;if(ec!==n)if(n={context:n,memoizedValue:r,next:null},Tr===null){if(Vo===null)throw Error(i(308));Tr=n,Vo.dependencies={lanes:0,firstContext:n}}else Tr=Tr.next=n;return r}var Xn=null;function rc(n){Xn===null?Xn=[n]:Xn.push(n)}function Tf(n,r,l,u){var f=r.interleaved;return f===null?(l.next=l,rc(r)):(l.next=f.next,f.next=l),r.interleaved=l,on(n,u)}function on(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var xn=!1;function sc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Af(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function an(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function En(n,r,l){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(et&2)!==0){var f=u.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),u.pending=r,on(n,l)}return f=u.interleaved,f===null?(r.next=r,rc(u)):(r.next=f.next,f.next=r),u.interleaved=r,on(n,l)}function Yo(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,yl(n,l)}}function If(n,r){var l=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var E={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};g===null?f=g=E:g=g.next=E,l=l.next}while(l!==null);g===null?f=g=r:g=g.next=r}else f=g=r;l={baseState:u.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:u.shared,effects:u.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function Xo(n,r,l,u){var f=n.updateQueue;xn=!1;var g=f.firstBaseUpdate,E=f.lastBaseUpdate,I=f.shared.pending;if(I!==null){f.shared.pending=null;var U=I,ne=U.next;U.next=null,E===null?g=ne:E.next=ne,E=U;var ve=n.alternate;ve!==null&&(ve=ve.updateQueue,I=ve.lastBaseUpdate,I!==E&&(I===null?ve.firstBaseUpdate=ne:I.next=ne,ve.lastBaseUpdate=U))}if(g!==null){var _e=f.baseState;E=0,ve=ne=U=null,I=g;do{var ge=I.lane,Re=I.eventTime;if((u&ge)===ge){ve!==null&&(ve=ve.next={eventTime:Re,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var Le=n,Te=I;switch(ge=r,Re=l,Te.tag){case 1:if(Le=Te.payload,typeof Le=="function"){_e=Le.call(Re,_e,ge);break e}_e=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=Te.payload,ge=typeof Le=="function"?Le.call(Re,_e,ge):Le,ge==null)break e;_e=q({},_e,ge);break e;case 2:xn=!0}}I.callback!==null&&I.lane!==0&&(n.flags|=64,ge=f.effects,ge===null?f.effects=[I]:ge.push(I))}else Re={eventTime:Re,lane:ge,tag:I.tag,payload:I.payload,callback:I.callback,next:null},ve===null?(ne=ve=Re,U=_e):ve=ve.next=Re,E|=ge;if(I=I.next,I===null){if(I=f.shared.pending,I===null)break;ge=I,I=ge.next,ge.next=null,f.lastBaseUpdate=ge,f.shared.pending=null}}while(!0);if(ve===null&&(U=_e),f.baseState=U,f.firstBaseUpdate=ne,f.lastBaseUpdate=ve,r=f.shared.interleaved,r!==null){f=r;do E|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Jn|=E,n.lanes=E,n.memoizedState=_e}}function Bf(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var u=n[r],f=u.callback;if(f!==null){if(u.callback=null,u=l,typeof f!="function")throw Error(i(191,f));f.call(u)}}}var Rs={},$i=bn(Rs),Ps=bn(Rs),Ds=bn(Rs);function Gn(n){if(n===Rs)throw Error(i(174));return n}function oc(n,r){switch(st(Ds,r),st(Ps,n),st($i,Rs),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:xe(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=xe(r,n)}lt($i),st($i,r)}function Ir(){lt($i),lt(Ps),lt(Ds)}function Of(n){Gn(Ds.current);var r=Gn($i.current),l=xe(r,n.type);r!==l&&(st(Ps,n),st($i,l))}function ac(n){Ps.current===n&&(lt($i),lt(Ps))}var ft=bn(0);function Go(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var lc=[];function cc(){for(var n=0;n<lc.length;n++)lc[n]._workInProgressVersionPrimary=null;lc.length=0}var Qo=T.ReactCurrentDispatcher,uc=T.ReactCurrentBatchConfig,Qn=0,pt=null,Nt=null,Lt=null,Jo=!1,Ms=!1,Ls=0,GS=0;function Vt(){throw Error(i(321))}function hc(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!ji(n[l],r[l]))return!1;return!0}function dc(n,r,l,u,f,g){if(Qn=g,pt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Qo.current=n===null||n.memoizedState===null?ew:tw,n=l(u,f),Ms){g=0;do{if(Ms=!1,Ls=0,25<=g)throw Error(i(301));g+=1,Lt=Nt=null,r.updateQueue=null,Qo.current=iw,n=l(u,f)}while(Ms)}if(Qo.current=ta,r=Nt!==null&&Nt.next!==null,Qn=0,Lt=Nt=pt=null,Jo=!1,r)throw Error(i(300));return n}function fc(){var n=Ls!==0;return Ls=0,n}function Wi(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lt===null?pt.memoizedState=Lt=n:Lt=Lt.next=n,Lt}function Ci(){if(Nt===null){var n=pt.alternate;n=n!==null?n.memoizedState:null}else n=Nt.next;var r=Lt===null?pt.memoizedState:Lt.next;if(r!==null)Lt=r,Nt=n;else{if(n===null)throw Error(i(310));Nt=n,n={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},Lt===null?pt.memoizedState=Lt=n:Lt=Lt.next=n}return Lt}function js(n,r){return typeof r=="function"?r(n):r}function pc(n){var r=Ci(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var u=Nt,f=u.baseQueue,g=l.pending;if(g!==null){if(f!==null){var E=f.next;f.next=g.next,g.next=E}u.baseQueue=f=g,l.pending=null}if(f!==null){g=f.next,u=u.baseState;var I=E=null,U=null,ne=g;do{var ve=ne.lane;if((Qn&ve)===ve)U!==null&&(U=U.next={lane:0,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),u=ne.hasEagerState?ne.eagerState:n(u,ne.action);else{var _e={lane:ve,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null};U===null?(I=U=_e,E=u):U=U.next=_e,pt.lanes|=ve,Jn|=ve}ne=ne.next}while(ne!==null&&ne!==g);U===null?E=u:U.next=I,ji(u,r.memoizedState)||(si=!0),r.memoizedState=u,r.baseState=E,r.baseQueue=U,l.lastRenderedState=u}if(n=l.interleaved,n!==null){f=n;do g=f.lane,pt.lanes|=g,Jn|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function mc(n){var r=Ci(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var u=l.dispatch,f=l.pending,g=r.memoizedState;if(f!==null){l.pending=null;var E=f=f.next;do g=n(g,E.action),E=E.next;while(E!==f);ji(g,r.memoizedState)||(si=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,u]}function zf(){}function Ff(n,r){var l=pt,u=Ci(),f=r(),g=!ji(u.memoizedState,f);if(g&&(u.memoizedState=f,si=!0),u=u.queue,gc(Wf.bind(null,l,u,n),[n]),u.getSnapshot!==r||g||Lt!==null&&Lt.memoizedState.tag&1){if(l.flags|=2048,Ts(9,$f.bind(null,l,u,f,r),void 0,null),jt===null)throw Error(i(349));(Qn&30)!==0||Hf(l,r,f)}return f}function Hf(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=pt.updateQueue,r===null?(r={lastEffect:null,stores:null},pt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function $f(n,r,l,u){r.value=l,r.getSnapshot=u,Uf(r)&&Kf(n)}function Wf(n,r,l){return l(function(){Uf(r)&&Kf(n)})}function Uf(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!ji(n,l)}catch{return!0}}function Kf(n){var r=on(n,1);r!==null&&Oi(r,n,1,-1)}function qf(n){var r=Wi();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:js,lastRenderedState:n},r.queue=n,n=n.dispatch=ZS.bind(null,pt,n),[r.memoizedState,n]}function Ts(n,r,l,u){return n={tag:n,create:r,destroy:l,deps:u,next:null},r=pt.updateQueue,r===null?(r={lastEffect:null,stores:null},pt.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(u=l.next,l.next=n,n.next=u,r.lastEffect=n)),n}function Vf(){return Ci().memoizedState}function Zo(n,r,l,u){var f=Wi();pt.flags|=n,f.memoizedState=Ts(1|r,l,void 0,u===void 0?null:u)}function ea(n,r,l,u){var f=Ci();u=u===void 0?null:u;var g=void 0;if(Nt!==null){var E=Nt.memoizedState;if(g=E.destroy,u!==null&&hc(u,E.deps)){f.memoizedState=Ts(r,l,g,u);return}}pt.flags|=n,f.memoizedState=Ts(1|r,l,g,u)}function Yf(n,r){return Zo(8390656,8,n,r)}function gc(n,r){return ea(2048,8,n,r)}function Xf(n,r){return ea(4,2,n,r)}function Gf(n,r){return ea(4,4,n,r)}function Qf(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Jf(n,r,l){return l=l!=null?l.concat([n]):null,ea(4,4,Qf.bind(null,r,n),l)}function vc(){}function Zf(n,r){var l=Ci();r=r===void 0?null:r;var u=l.memoizedState;return u!==null&&r!==null&&hc(r,u[1])?u[0]:(l.memoizedState=[n,r],n)}function ep(n,r){var l=Ci();r=r===void 0?null:r;var u=l.memoizedState;return u!==null&&r!==null&&hc(r,u[1])?u[0]:(n=n(),l.memoizedState=[n,r],n)}function tp(n,r,l){return(Qn&21)===0?(n.baseState&&(n.baseState=!1,si=!0),n.memoizedState=l):(ji(l,r)||(l=Dd(),pt.lanes|=l,Jn|=l,n.baseState=!0),r)}function QS(n,r){var l=nt;nt=l!==0&&4>l?l:4,n(!0);var u=uc.transition;uc.transition={};try{n(!1),r()}finally{nt=l,uc.transition=u}}function ip(){return Ci().memoizedState}function JS(n,r,l){var u=Dn(n);if(l={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null},np(n))rp(r,l);else if(l=Tf(n,r,l,u),l!==null){var f=Zt();Oi(l,n,u,f),sp(l,r,u)}}function ZS(n,r,l){var u=Dn(n),f={lane:u,action:l,hasEagerState:!1,eagerState:null,next:null};if(np(n))rp(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var E=r.lastRenderedState,I=g(E,l);if(f.hasEagerState=!0,f.eagerState=I,ji(I,E)){var U=r.interleaved;U===null?(f.next=f,rc(r)):(f.next=U.next,U.next=f),r.interleaved=f;return}}catch{}finally{}l=Tf(n,r,f,u),l!==null&&(f=Zt(),Oi(l,n,u,f),sp(l,r,u))}}function np(n){var r=n.alternate;return n===pt||r!==null&&r===pt}function rp(n,r){Ms=Jo=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function sp(n,r,l){if((l&4194240)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,yl(n,l)}}var ta={readContext:ki,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},ew={readContext:ki,useCallback:function(n,r){return Wi().memoizedState=[n,r===void 0?null:r],n},useContext:ki,useEffect:Yf,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,Zo(4194308,4,Qf.bind(null,r,n),l)},useLayoutEffect:function(n,r){return Zo(4194308,4,n,r)},useInsertionEffect:function(n,r){return Zo(4,2,n,r)},useMemo:function(n,r){var l=Wi();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var u=Wi();return r=l!==void 0?l(r):r,u.memoizedState=u.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},u.queue=n,n=n.dispatch=JS.bind(null,pt,n),[u.memoizedState,n]},useRef:function(n){var r=Wi();return n={current:n},r.memoizedState=n},useState:qf,useDebugValue:vc,useDeferredValue:function(n){return Wi().memoizedState=n},useTransition:function(){var n=qf(!1),r=n[0];return n=QS.bind(null,n[1]),Wi().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var u=pt,f=Wi();if(ht){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),jt===null)throw Error(i(349));(Qn&30)!==0||Hf(u,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,Yf(Wf.bind(null,u,g,n),[n]),u.flags|=2048,Ts(9,$f.bind(null,u,g,l,r),void 0,null),l},useId:function(){var n=Wi(),r=jt.identifierPrefix;if(ht){var l=sn,u=rn;l=(u&~(1<<32-Li(u)-1)).toString(32)+l,r=":"+r+"R"+l,l=Ls++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=GS++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},tw={readContext:ki,useCallback:Zf,useContext:ki,useEffect:gc,useImperativeHandle:Jf,useInsertionEffect:Xf,useLayoutEffect:Gf,useMemo:ep,useReducer:pc,useRef:Vf,useState:function(){return pc(js)},useDebugValue:vc,useDeferredValue:function(n){var r=Ci();return tp(r,Nt.memoizedState,n)},useTransition:function(){var n=pc(js)[0],r=Ci().memoizedState;return[n,r]},useMutableSource:zf,useSyncExternalStore:Ff,useId:ip,unstable_isNewReconciler:!1},iw={readContext:ki,useCallback:Zf,useContext:ki,useEffect:gc,useImperativeHandle:Jf,useInsertionEffect:Xf,useLayoutEffect:Gf,useMemo:ep,useReducer:mc,useRef:Vf,useState:function(){return mc(js)},useDebugValue:vc,useDeferredValue:function(n){var r=Ci();return Nt===null?r.memoizedState=n:tp(r,Nt.memoizedState,n)},useTransition:function(){var n=mc(js)[0],r=Ci().memoizedState;return[n,r]},useMutableSource:zf,useSyncExternalStore:Ff,useId:ip,unstable_isNewReconciler:!1};function Ai(n,r){if(n&&n.defaultProps){r=q({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function _c(n,r,l,u){r=n.memoizedState,l=l(u,r),l=l==null?r:q({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var ia={isMounted:function(n){return(n=n._reactInternals)?Un(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var u=Zt(),f=Dn(n),g=an(u,f);g.payload=r,l!=null&&(g.callback=l),r=En(n,g,f),r!==null&&(Oi(r,n,f,u),Yo(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=Zt(),f=Dn(n),g=an(u,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=En(n,g,f),r!==null&&(Oi(r,n,f,u),Yo(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=Zt(),u=Dn(n),f=an(l,u);f.tag=2,r!=null&&(f.callback=r),r=En(n,f,u),r!==null&&(Oi(r,n,u,l),Yo(r,n,u))}};function op(n,r,l,u,f,g,E){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,E):r.prototype&&r.prototype.isPureReactComponent?!Ss(l,u)||!Ss(f,g):!0}function ap(n,r,l){var u=!1,f=kn,g=r.contextType;return typeof g=="object"&&g!==null?g=ki(g):(f=ri(r)?qn:qt.current,u=r.contextTypes,g=(u=u!=null)?Pr(n,f):kn),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ia,n.stateNode=r,r._reactInternals=n,u&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function lp(n,r,l,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,u),r.state!==n&&ia.enqueueReplaceState(r,r.state,null)}function yc(n,r,l,u){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},sc(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=ki(g):(g=ri(r)?qn:qt.current,f.context=Pr(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(_c(n,r,g,l),f.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&ia.enqueueReplaceState(f,f.state,null),Xo(n,l,f,u),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Br(n,r){try{var l="",u=r;do l+=se(u),u=u.return;while(u);var f=l}catch(g){f=`
|
|
39
|
+
Error generating stack: `+g.message+`
|
|
40
|
+
`+g.stack}return{value:n,source:r,stack:f,digest:null}}function Sc(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function wc(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var nw=typeof WeakMap=="function"?WeakMap:Map;function cp(n,r,l){l=an(-1,l),l.tag=3,l.payload={element:null};var u=r.value;return l.callback=function(){ca||(ca=!0,Ic=u),wc(n,r)},l}function up(n,r,l){l=an(-1,l),l.tag=3;var u=n.type.getDerivedStateFromError;if(typeof u=="function"){var f=r.value;l.payload=function(){return u(f)},l.callback=function(){wc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){wc(n,r),typeof u!="function"&&(Rn===null?Rn=new Set([this]):Rn.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})}),l}function hp(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new nw;var f=new Set;u.set(r,f)}else f=u.get(r),f===void 0&&(f=new Set,u.set(r,f));f.has(l)||(f.add(l),n=vw.bind(null,n,r,l),r.then(n,n))}function dp(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function fp(n,r,l,u,f){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=an(-1,1),r.tag=2,En(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var rw=T.ReactCurrentOwner,si=!1;function Jt(n,r,l,u){r.child=n===null?jf(r,null,l,u):jr(r,n.child,l,u)}function pp(n,r,l,u,f){l=l.render;var g=r.ref;return Ar(r,f),u=dc(n,r,l,u,g,f),l=fc(),n!==null&&!si?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,ln(n,r,f)):(ht&&l&&Xl(r),r.flags|=1,Jt(n,r,u,f),r.child)}function mp(n,r,l,u,f){if(n===null){var g=l.type;return typeof g=="function"&&!Wc(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,gp(n,r,g,u,f)):(n=ma(l.type,null,u,r,r.mode,f),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&f)===0){var E=g.memoizedProps;if(l=l.compare,l=l!==null?l:Ss,l(E,u)&&n.ref===r.ref)return ln(n,r,f)}return r.flags|=1,n=Ln(g,u),n.ref=r.ref,n.return=r,r.child=n}function gp(n,r,l,u,f){if(n!==null){var g=n.memoizedProps;if(Ss(g,u)&&n.ref===r.ref)if(si=!1,r.pendingProps=u=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(si=!0);else return r.lanes=n.lanes,ln(n,r,f)}return bc(n,r,l,u,f)}function vp(n,r,l){var u=r.pendingProps,f=u.children,g=n!==null?n.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(zr,mi),mi|=l;else{if((l&1073741824)===0)return n=g!==null?g.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,st(zr,mi),mi|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:l,st(zr,mi),mi|=u}else g!==null?(u=g.baseLanes|l,r.memoizedState=null):u=l,st(zr,mi),mi|=u;return Jt(n,r,f,l),r.child}function _p(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function bc(n,r,l,u,f){var g=ri(l)?qn:qt.current;return g=Pr(r,g),Ar(r,f),l=dc(n,r,l,u,g,f),u=fc(),n!==null&&!si?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,ln(n,r,f)):(ht&&u&&Xl(r),r.flags|=1,Jt(n,r,l,f),r.child)}function yp(n,r,l,u,f){if(ri(l)){var g=!0;Fo(r)}else g=!1;if(Ar(r,f),r.stateNode===null)ra(n,r),ap(r,l,u),yc(r,l,u,f),u=!0;else if(n===null){var E=r.stateNode,I=r.memoizedProps;E.props=I;var U=E.context,ne=l.contextType;typeof ne=="object"&&ne!==null?ne=ki(ne):(ne=ri(l)?qn:qt.current,ne=Pr(r,ne));var ve=l.getDerivedStateFromProps,_e=typeof ve=="function"||typeof E.getSnapshotBeforeUpdate=="function";_e||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(I!==u||U!==ne)&&lp(r,E,u,ne),xn=!1;var ge=r.memoizedState;E.state=ge,Xo(r,u,E,f),U=r.memoizedState,I!==u||ge!==U||ni.current||xn?(typeof ve=="function"&&(_c(r,l,ve,u),U=r.memoizedState),(I=xn||op(r,l,I,u,ge,U,ne))?(_e||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(r.flags|=4194308)):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=U),E.props=u,E.state=U,E.context=ne,u=I):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{E=r.stateNode,Af(n,r),I=r.memoizedProps,ne=r.type===r.elementType?I:Ai(r.type,I),E.props=ne,_e=r.pendingProps,ge=E.context,U=l.contextType,typeof U=="object"&&U!==null?U=ki(U):(U=ri(l)?qn:qt.current,U=Pr(r,U));var Re=l.getDerivedStateFromProps;(ve=typeof Re=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(I!==_e||ge!==U)&&lp(r,E,u,U),xn=!1,ge=r.memoizedState,E.state=ge,Xo(r,u,E,f);var Le=r.memoizedState;I!==_e||ge!==Le||ni.current||xn?(typeof Re=="function"&&(_c(r,l,Re,u),Le=r.memoizedState),(ne=xn||op(r,l,ne,u,ge,Le,U)||!1)?(ve||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(u,Le,U),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(u,Le,U)),typeof E.componentDidUpdate=="function"&&(r.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof E.componentDidUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=Le),E.props=u,E.state=Le,E.context=U,u=ne):(typeof E.componentDidUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||I===n.memoizedProps&&ge===n.memoizedState||(r.flags|=1024),u=!1)}return kc(n,r,l,u,g,f)}function kc(n,r,l,u,f,g){_p(n,r);var E=(r.flags&128)!==0;if(!u&&!E)return f&&Cf(r,l,!1),ln(n,r,g);u=r.stateNode,rw.current=r;var I=E&&typeof l.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,n!==null&&E?(r.child=jr(r,n.child,null,g),r.child=jr(r,null,I,g)):Jt(n,r,I,g),r.memoizedState=u.state,f&&Cf(r,l,!0),r.child}function Sp(n){var r=n.stateNode;r.pendingContext?bf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&bf(n,r.context,!1),oc(n,r.containerInfo)}function wp(n,r,l,u,f){return Lr(),Zl(f),r.flags|=256,Jt(n,r,l,u),r.child}var Cc={dehydrated:null,treeContext:null,retryLane:0};function xc(n){return{baseLanes:n,cachePool:null,transitions:null}}function bp(n,r,l){var u=r.pendingProps,f=ft.current,g=!1,E=(r.flags&128)!==0,I;if((I=E)||(I=n!==null&&n.memoizedState===null?!1:(f&2)!==0),I?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),st(ft,f&1),n===null)return Jl(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(E=u.children,n=u.fallback,g?(u=r.mode,g=r.child,E={mode:"hidden",children:E},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=E):g=ga(E,u,0,null),n=ir(n,u,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=xc(l),r.memoizedState=Cc,n):Ec(r,E));if(f=n.memoizedState,f!==null&&(I=f.dehydrated,I!==null))return sw(n,r,E,u,I,f,l);if(g){g=u.fallback,E=r.mode,f=n.child,I=f.sibling;var U={mode:"hidden",children:u.children};return(E&1)===0&&r.child!==f?(u=r.child,u.childLanes=0,u.pendingProps=U,r.deletions=null):(u=Ln(f,U),u.subtreeFlags=f.subtreeFlags&14680064),I!==null?g=Ln(I,g):(g=ir(g,E,l,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,E=n.child.memoizedState,E=E===null?xc(l):{baseLanes:E.baseLanes|l,cachePool:null,transitions:E.transitions},g.memoizedState=E,g.childLanes=n.childLanes&~l,r.memoizedState=Cc,u}return g=n.child,n=g.sibling,u=Ln(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=l),u.return=r,u.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=u,r.memoizedState=null,u}function Ec(n,r){return r=ga({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function na(n,r,l,u){return u!==null&&Zl(u),jr(r,n.child,null,l),n=Ec(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function sw(n,r,l,u,f,g,E){if(l)return r.flags&256?(r.flags&=-257,u=Sc(Error(i(422))),na(n,r,E,u)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=u.fallback,f=r.mode,u=ga({mode:"visible",children:u.children},f,0,null),g=ir(g,f,E,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&jr(r,n.child,null,E),r.child.memoizedState=xc(E),r.memoizedState=Cc,g);if((r.mode&1)===0)return na(n,r,E,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var I=u.dgst;return u=I,g=Error(i(419)),u=Sc(g,u,void 0),na(n,r,E,u)}if(I=(E&n.childLanes)!==0,si||I){if(u=jt,u!==null){switch(E&-E){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(u.suspendedLanes|E))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,on(n,f),Oi(u,n,f,-1))}return $c(),u=Sc(Error(i(421))),na(n,r,E,u)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=_w.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,pi=wn(f.nextSibling),fi=r,ht=!0,Ti=null,n!==null&&(wi[bi++]=rn,wi[bi++]=sn,wi[bi++]=Vn,rn=n.id,sn=n.overflow,Vn=r),r=Ec(r,u.children),r.flags|=4096,r)}function kp(n,r,l){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),nc(n.return,r,l)}function Nc(n,r,l,u,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=l,g.tailMode=f)}function Cp(n,r,l){var u=r.pendingProps,f=u.revealOrder,g=u.tail;if(Jt(n,r,u.children,l),u=ft.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&kp(n,l,r);else if(n.tag===19)kp(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}u&=1}if(st(ft,u),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(l=r.child,f=null;l!==null;)n=l.alternate,n!==null&&Go(n)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),Nc(r,!1,f,l,g);break;case"backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(n=f.alternate,n!==null&&Go(n)===null){r.child=f;break}n=f.sibling,f.sibling=l,l=f,f=n}Nc(r,!0,l,null,g);break;case"together":Nc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ra(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function ln(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),Jn|=r.lanes,(l&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,l=Ln(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Ln(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function ow(n,r,l){switch(r.tag){case 3:Sp(r),Lr();break;case 5:Of(r);break;case 1:ri(r.type)&&Fo(r);break;case 4:oc(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,f=r.memoizedProps.value;st(qo,u._currentValue),u._currentValue=f;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(st(ft,ft.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?bp(n,r,l):(st(ft,ft.current&1),n=ln(n,r,l),n!==null?n.sibling:null);st(ft,ft.current&1);break;case 19:if(u=(l&r.childLanes)!==0,(n.flags&128)!==0){if(u)return Cp(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),st(ft,ft.current),u)break;return null;case 22:case 23:return r.lanes=0,vp(n,r,l)}return ln(n,r,l)}var xp,Rc,Ep,Np;xp=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Rc=function(){},Ep=function(n,r,l,u){var f=n.memoizedProps;if(f!==u){n=r.stateNode,Gn($i.current);var g=null;switch(l){case"input":f=ot(n,f),u=ot(n,u),g=[];break;case"select":f=q({},f,{value:void 0}),u=q({},u,{value:void 0}),g=[];break;case"textarea":f=me(n,f),u=me(n,u),g=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(n.onclick=Bo)}Ke(l,u);var E;l=null;for(ne in f)if(!u.hasOwnProperty(ne)&&f.hasOwnProperty(ne)&&f[ne]!=null)if(ne==="style"){var I=f[ne];for(E in I)I.hasOwnProperty(E)&&(l||(l={}),l[E]="")}else ne!=="dangerouslySetInnerHTML"&&ne!=="children"&&ne!=="suppressContentEditableWarning"&&ne!=="suppressHydrationWarning"&&ne!=="autoFocus"&&(o.hasOwnProperty(ne)?g||(g=[]):(g=g||[]).push(ne,null));for(ne in u){var U=u[ne];if(I=f!=null?f[ne]:void 0,u.hasOwnProperty(ne)&&U!==I&&(U!=null||I!=null))if(ne==="style")if(I){for(E in I)!I.hasOwnProperty(E)||U&&U.hasOwnProperty(E)||(l||(l={}),l[E]="");for(E in U)U.hasOwnProperty(E)&&I[E]!==U[E]&&(l||(l={}),l[E]=U[E])}else l||(g||(g=[]),g.push(ne,l)),l=U;else ne==="dangerouslySetInnerHTML"?(U=U?U.__html:void 0,I=I?I.__html:void 0,U!=null&&I!==U&&(g=g||[]).push(ne,U)):ne==="children"?typeof U!="string"&&typeof U!="number"||(g=g||[]).push(ne,""+U):ne!=="suppressContentEditableWarning"&&ne!=="suppressHydrationWarning"&&(o.hasOwnProperty(ne)?(U!=null&&ne==="onScroll"&&at("scroll",n),g||I===U||(g=[])):(g=g||[]).push(ne,U))}l&&(g=g||[]).push("style",l);var ne=g;(r.updateQueue=ne)&&(r.flags|=4)}},Np=function(n,r,l,u){l!==u&&(r.flags|=4)};function As(n,r){if(!ht)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function Yt(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,u=0;if(r)for(var f=n.child;f!==null;)l|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)l|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=u,n.childLanes=l,r}function aw(n,r,l){var u=r.pendingProps;switch(Gl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(r),null;case 1:return ri(r.type)&&zo(),Yt(r),null;case 3:return u=r.stateNode,Ir(),lt(ni),lt(qt),cc(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Uo(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ti!==null&&(zc(Ti),Ti=null))),Rc(n,r),Yt(r),null;case 5:ac(r);var f=Gn(Ds.current);if(l=r.type,n!==null&&r.stateNode!=null)Ep(n,r,l,u,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(i(166));return Yt(r),null}if(n=Gn($i.current),Uo(r)){u=r.stateNode,l=r.type;var g=r.memoizedProps;switch(u[Hi]=r,u[xs]=g,n=(r.mode&1)!==0,l){case"dialog":at("cancel",u),at("close",u);break;case"iframe":case"object":case"embed":at("load",u);break;case"video":case"audio":for(f=0;f<bs.length;f++)at(bs[f],u);break;case"source":at("error",u);break;case"img":case"image":case"link":at("error",u),at("load",u);break;case"details":at("toggle",u);break;case"input":Et(u,g),at("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},at("invalid",u);break;case"textarea":be(u,g),at("invalid",u)}Ke(l,g),f=null;for(var E in g)if(g.hasOwnProperty(E)){var I=g[E];E==="children"?typeof I=="string"?u.textContent!==I&&(g.suppressHydrationWarning!==!0&&Io(u.textContent,I,n),f=["children",I]):typeof I=="number"&&u.textContent!==""+I&&(g.suppressHydrationWarning!==!0&&Io(u.textContent,I,n),f=["children",""+I]):o.hasOwnProperty(E)&&I!=null&&E==="onScroll"&&at("scroll",u)}switch(l){case"input":Ze(u),ze(u,g,!0);break;case"textarea":Ze(u),he(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=Bo)}u=f,r.updateQueue=u,u!==null&&(r.flags|=4)}else{E=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Ee(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=E.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof u.is=="string"?n=E.createElement(l,{is:u.is}):(n=E.createElement(l),l==="select"&&(E=n,u.multiple?E.multiple=!0:u.size&&(E.size=u.size))):n=E.createElementNS(n,l),n[Hi]=r,n[xs]=u,xp(n,r,!1,!1),r.stateNode=n;e:{switch(E=ut(l,u),l){case"dialog":at("cancel",n),at("close",n),f=u;break;case"iframe":case"object":case"embed":at("load",n),f=u;break;case"video":case"audio":for(f=0;f<bs.length;f++)at(bs[f],n);f=u;break;case"source":at("error",n),f=u;break;case"img":case"image":case"link":at("error",n),at("load",n),f=u;break;case"details":at("toggle",n),f=u;break;case"input":Et(n,u),f=ot(n,u),at("invalid",n);break;case"option":f=u;break;case"select":n._wrapperState={wasMultiple:!!u.multiple},f=q({},u,{value:void 0}),at("invalid",n);break;case"textarea":be(n,u),f=me(n,u),at("invalid",n);break;default:f=u}Ke(l,f),I=f;for(g in I)if(I.hasOwnProperty(g)){var U=I[g];g==="style"?oe(n,U):g==="dangerouslySetInnerHTML"?(U=U?U.__html:void 0,U!=null&&Je(n,U)):g==="children"?typeof U=="string"?(l!=="textarea"||U!=="")&&De(n,U):typeof U=="number"&&De(n,""+U):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?U!=null&&g==="onScroll"&&at("scroll",n):U!=null&&L(n,g,U,E))}switch(l){case"input":Ze(n),ze(n,u,!1);break;case"textarea":Ze(n),he(n);break;case"option":u.value!=null&&n.setAttribute("value",""+ce(u.value));break;case"select":n.multiple=!!u.multiple,g=u.value,g!=null?K(n,!!u.multiple,g,!1):u.defaultValue!=null&&K(n,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=Bo)}switch(l){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Yt(r),null;case 6:if(n&&r.stateNode!=null)Np(n,r,n.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(i(166));if(l=Gn(Ds.current),Gn($i.current),Uo(r)){if(u=r.stateNode,l=r.memoizedProps,u[Hi]=r,(g=u.nodeValue!==l)&&(n=fi,n!==null))switch(n.tag){case 3:Io(u.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Io(u.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else u=(l.nodeType===9?l:l.ownerDocument).createTextNode(u),u[Hi]=r,r.stateNode=u}return Yt(r),null;case 13:if(lt(ft),u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(ht&&pi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Df(),Lr(),r.flags|=98560,g=!1;else if(g=Uo(r),u!==null&&u.dehydrated!==null){if(n===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[Hi]=r}else Lr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),g=!1}else Ti!==null&&(zc(Ti),Ti=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(u=u!==null,u!==(n!==null&&n.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(ft.current&1)!==0?Rt===0&&(Rt=3):$c())),r.updateQueue!==null&&(r.flags|=4),Yt(r),null);case 4:return Ir(),Rc(n,r),n===null&&ks(r.stateNode.containerInfo),Yt(r),null;case 10:return ic(r.type._context),Yt(r),null;case 17:return ri(r.type)&&zo(),Yt(r),null;case 19:if(lt(ft),g=r.memoizedState,g===null)return Yt(r),null;if(u=(r.flags&128)!==0,E=g.rendering,E===null)if(u)As(g,!1);else{if(Rt!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(E=Go(n),E!==null){for(r.flags|=128,As(g,!1),u=E.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=l,l=r.child;l!==null;)g=l,n=u,g.flags&=14680066,E=g.alternate,E===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=E.childLanes,g.lanes=E.lanes,g.child=E.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=E.memoizedProps,g.memoizedState=E.memoizedState,g.updateQueue=E.updateQueue,g.type=E.type,n=E.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return st(ft,ft.current&1|2),r.child}n=n.sibling}g.tail!==null&&St()>Fr&&(r.flags|=128,u=!0,As(g,!1),r.lanes=4194304)}else{if(!u)if(n=Go(E),n!==null){if(r.flags|=128,u=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),As(g,!0),g.tail===null&&g.tailMode==="hidden"&&!E.alternate&&!ht)return Yt(r),null}else 2*St()-g.renderingStartTime>Fr&&l!==1073741824&&(r.flags|=128,u=!0,As(g,!1),r.lanes=4194304);g.isBackwards?(E.sibling=r.child,r.child=E):(l=g.last,l!==null?l.sibling=E:r.child=E,g.last=E)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=St(),r.sibling=null,l=ft.current,st(ft,u?l&1|2:l&1),r):(Yt(r),null);case 22:case 23:return Hc(),u=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(mi&1073741824)!==0&&(Yt(r),r.subtreeFlags&6&&(r.flags|=8192)):Yt(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function lw(n,r){switch(Gl(r),r.tag){case 1:return ri(r.type)&&zo(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Ir(),lt(ni),lt(qt),cc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return ac(r),null;case 13:if(lt(ft),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Lr()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return lt(ft),null;case 4:return Ir(),null;case 10:return ic(r.type._context),null;case 22:case 23:return Hc(),null;case 24:return null;default:return null}}var sa=!1,Xt=!1,cw=typeof WeakSet=="function"?WeakSet:Set,Me=null;function Or(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(u){vt(n,r,u)}else l.current=null}function Pc(n,r,l){try{l()}catch(u){vt(n,r,u)}}var Rp=!1;function uw(n,r){if(Hl=xo,n=of(),jl(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var f=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var E=0,I=-1,U=-1,ne=0,ve=0,_e=n,ge=null;t:for(;;){for(var Re;_e!==l||f!==0&&_e.nodeType!==3||(I=E+f),_e!==g||u!==0&&_e.nodeType!==3||(U=E+u),_e.nodeType===3&&(E+=_e.nodeValue.length),(Re=_e.firstChild)!==null;)ge=_e,_e=Re;for(;;){if(_e===n)break t;if(ge===l&&++ne===f&&(I=E),ge===g&&++ve===u&&(U=E),(Re=_e.nextSibling)!==null)break;_e=ge,ge=_e.parentNode}_e=Re}l=I===-1||U===-1?null:{start:I,end:U}}else l=null}l=l||{start:0,end:0}}else l=null;for($l={focusedElem:n,selectionRange:l},xo=!1,Me=r;Me!==null;)if(r=Me,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Me=n;else for(;Me!==null;){r=Me;try{var Le=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Le!==null){var Te=Le.memoizedProps,wt=Le.memoizedState,Z=r.stateNode,Y=Z.getSnapshotBeforeUpdate(r.elementType===r.type?Te:Ai(r.type,Te),wt);Z.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var ee=r.stateNode.containerInfo;ee.nodeType===1?ee.textContent="":ee.nodeType===9&&ee.documentElement&&ee.removeChild(ee.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(Se){vt(r,r.return,Se)}if(n=r.sibling,n!==null){n.return=r.return,Me=n;break}Me=r.return}return Le=Rp,Rp=!1,Le}function Is(n,r,l){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&Pc(r,l,g)}f=f.next}while(f!==u)}}function oa(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&n)===n){var u=l.create;l.destroy=u()}l=l.next}while(l!==r)}}function Dc(n){var r=n.ref;if(r!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof r=="function"?r(n):r.current=n}}function Pp(n){var r=n.alternate;r!==null&&(n.alternate=null,Pp(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Hi],delete r[xs],delete r[ql],delete r[qS],delete r[VS])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Dp(n){return n.tag===5||n.tag===3||n.tag===4}function Mp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Dp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Mc(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(n,r):l.insertBefore(n,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(n,l)):(r=l,r.appendChild(n)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Bo));else if(u!==4&&(n=n.child,n!==null))for(Mc(n,r,l),n=n.sibling;n!==null;)Mc(n,r,l),n=n.sibling}function Lc(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(u!==4&&(n=n.child,n!==null))for(Lc(n,r,l),n=n.sibling;n!==null;)Lc(n,r,l),n=n.sibling}var Ht=null,Ii=!1;function Nn(n,r,l){for(l=l.child;l!==null;)Lp(n,r,l),l=l.sibling}function Lp(n,r,l){if(Fi&&typeof Fi.onCommitFiberUnmount=="function")try{Fi.onCommitFiberUnmount(yo,l)}catch{}switch(l.tag){case 5:Xt||Or(l,r);case 6:var u=Ht,f=Ii;Ht=null,Nn(n,r,l),Ht=u,Ii=f,Ht!==null&&(Ii?(n=Ht,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Ht.removeChild(l.stateNode));break;case 18:Ht!==null&&(Ii?(n=Ht,l=l.stateNode,n.nodeType===8?Kl(n.parentNode,l):n.nodeType===1&&Kl(n,l),ps(n)):Kl(Ht,l.stateNode));break;case 4:u=Ht,f=Ii,Ht=l.stateNode.containerInfo,Ii=!0,Nn(n,r,l),Ht=u,Ii=f;break;case 0:case 11:case 14:case 15:if(!Xt&&(u=l.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var g=f,E=g.destroy;g=g.tag,E!==void 0&&((g&2)!==0||(g&4)!==0)&&Pc(l,r,E),f=f.next}while(f!==u)}Nn(n,r,l);break;case 1:if(!Xt&&(Or(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=l.memoizedProps,u.state=l.memoizedState,u.componentWillUnmount()}catch(I){vt(l,r,I)}Nn(n,r,l);break;case 21:Nn(n,r,l);break;case 22:l.mode&1?(Xt=(u=Xt)||l.memoizedState!==null,Nn(n,r,l),Xt=u):Nn(n,r,l);break;default:Nn(n,r,l)}}function jp(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new cw),r.forEach(function(u){var f=yw.bind(null,n,u);l.has(u)||(l.add(u),u.then(f,f))})}}function Bi(n,r){var l=r.deletions;if(l!==null)for(var u=0;u<l.length;u++){var f=l[u];try{var g=n,E=r,I=E;e:for(;I!==null;){switch(I.tag){case 5:Ht=I.stateNode,Ii=!1;break e;case 3:Ht=I.stateNode.containerInfo,Ii=!0;break e;case 4:Ht=I.stateNode.containerInfo,Ii=!0;break e}I=I.return}if(Ht===null)throw Error(i(160));Lp(g,E,f),Ht=null,Ii=!1;var U=f.alternate;U!==null&&(U.return=null),f.return=null}catch(ne){vt(f,r,ne)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Tp(r,n),r=r.sibling}function Tp(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Bi(r,n),Ui(n),u&4){try{Is(3,n,n.return),oa(3,n)}catch(Te){vt(n,n.return,Te)}try{Is(5,n,n.return)}catch(Te){vt(n,n.return,Te)}}break;case 1:Bi(r,n),Ui(n),u&512&&l!==null&&Or(l,l.return);break;case 5:if(Bi(r,n),Ui(n),u&512&&l!==null&&Or(l,l.return),n.flags&32){var f=n.stateNode;try{De(f,"")}catch(Te){vt(n,n.return,Te)}}if(u&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,E=l!==null?l.memoizedProps:g,I=n.type,U=n.updateQueue;if(n.updateQueue=null,U!==null)try{I==="input"&&g.type==="radio"&&g.name!=null&&ie(f,g),ut(I,E);var ne=ut(I,g);for(E=0;E<U.length;E+=2){var ve=U[E],_e=U[E+1];ve==="style"?oe(f,_e):ve==="dangerouslySetInnerHTML"?Je(f,_e):ve==="children"?De(f,_e):L(f,ve,_e,ne)}switch(I){case"input":ae(f,g);break;case"textarea":Pe(f,g);break;case"select":var ge=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Re=g.value;Re!=null?K(f,!!g.multiple,Re,!1):ge!==!!g.multiple&&(g.defaultValue!=null?K(f,!!g.multiple,g.defaultValue,!0):K(f,!!g.multiple,g.multiple?[]:"",!1))}f[xs]=g}catch(Te){vt(n,n.return,Te)}}break;case 6:if(Bi(r,n),Ui(n),u&4){if(n.stateNode===null)throw Error(i(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(Te){vt(n,n.return,Te)}}break;case 3:if(Bi(r,n),Ui(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{ps(r.containerInfo)}catch(Te){vt(n,n.return,Te)}break;case 4:Bi(r,n),Ui(n);break;case 13:Bi(r,n),Ui(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Ac=St())),u&4&&jp(n);break;case 22:if(ve=l!==null&&l.memoizedState!==null,n.mode&1?(Xt=(ne=Xt)||ve,Bi(r,n),Xt=ne):Bi(r,n),Ui(n),u&8192){if(ne=n.memoizedState!==null,(n.stateNode.isHidden=ne)&&!ve&&(n.mode&1)!==0)for(Me=n,ve=n.child;ve!==null;){for(_e=Me=ve;Me!==null;){switch(ge=Me,Re=ge.child,ge.tag){case 0:case 11:case 14:case 15:Is(4,ge,ge.return);break;case 1:Or(ge,ge.return);var Le=ge.stateNode;if(typeof Le.componentWillUnmount=="function"){u=ge,l=ge.return;try{r=u,Le.props=r.memoizedProps,Le.state=r.memoizedState,Le.componentWillUnmount()}catch(Te){vt(u,l,Te)}}break;case 5:Or(ge,ge.return);break;case 22:if(ge.memoizedState!==null){Bp(_e);continue}}Re!==null?(Re.return=ge,Me=Re):Bp(_e)}ve=ve.sibling}e:for(ve=null,_e=n;;){if(_e.tag===5){if(ve===null){ve=_e;try{f=_e.stateNode,ne?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(I=_e.stateNode,U=_e.memoizedProps.style,E=U!=null&&U.hasOwnProperty("display")?U.display:null,I.style.display=je("display",E))}catch(Te){vt(n,n.return,Te)}}}else if(_e.tag===6){if(ve===null)try{_e.stateNode.nodeValue=ne?"":_e.memoizedProps}catch(Te){vt(n,n.return,Te)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===n)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===n)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===n)break e;ve===_e&&(ve=null),_e=_e.return}ve===_e&&(ve=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:Bi(r,n),Ui(n),u&4&&jp(n);break;case 21:break;default:Bi(r,n),Ui(n)}}function Ui(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(Dp(l)){var u=l;break e}l=l.return}throw Error(i(160))}switch(u.tag){case 5:var f=u.stateNode;u.flags&32&&(De(f,""),u.flags&=-33);var g=Mp(n);Lc(n,g,f);break;case 3:case 4:var E=u.stateNode.containerInfo,I=Mp(n);Mc(n,I,E);break;default:throw Error(i(161))}}catch(U){vt(n,n.return,U)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function hw(n,r,l){Me=n,Ap(n)}function Ap(n,r,l){for(var u=(n.mode&1)!==0;Me!==null;){var f=Me,g=f.child;if(f.tag===22&&u){var E=f.memoizedState!==null||sa;if(!E){var I=f.alternate,U=I!==null&&I.memoizedState!==null||Xt;I=sa;var ne=Xt;if(sa=E,(Xt=U)&&!ne)for(Me=f;Me!==null;)E=Me,U=E.child,E.tag===22&&E.memoizedState!==null?Op(f):U!==null?(U.return=E,Me=U):Op(f);for(;g!==null;)Me=g,Ap(g),g=g.sibling;Me=f,sa=I,Xt=ne}Ip(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Me=g):Ip(n)}}function Ip(n){for(;Me!==null;){var r=Me;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Xt||oa(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!Xt)if(l===null)u.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Ai(r.type,l.memoizedProps);u.componentDidUpdate(f,l.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Bf(r,g,u);break;case 3:var E=r.updateQueue;if(E!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}Bf(r,E,l)}break;case 5:var I=r.stateNode;if(l===null&&r.flags&4){l=I;var U=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":U.autoFocus&&l.focus();break;case"img":U.src&&(l.src=U.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var ne=r.alternate;if(ne!==null){var ve=ne.memoizedState;if(ve!==null){var _e=ve.dehydrated;_e!==null&&ps(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}Xt||r.flags&512&&Dc(r)}catch(ge){vt(r,r.return,ge)}}if(r===n){Me=null;break}if(l=r.sibling,l!==null){l.return=r.return,Me=l;break}Me=r.return}}function Bp(n){for(;Me!==null;){var r=Me;if(r===n){Me=null;break}var l=r.sibling;if(l!==null){l.return=r.return,Me=l;break}Me=r.return}}function Op(n){for(;Me!==null;){var r=Me;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{oa(4,r)}catch(U){vt(r,l,U)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var f=r.return;try{u.componentDidMount()}catch(U){vt(r,f,U)}}var g=r.return;try{Dc(r)}catch(U){vt(r,g,U)}break;case 5:var E=r.return;try{Dc(r)}catch(U){vt(r,E,U)}}}catch(U){vt(r,r.return,U)}if(r===n){Me=null;break}var I=r.sibling;if(I!==null){I.return=r.return,Me=I;break}Me=r.return}}var dw=Math.ceil,aa=T.ReactCurrentDispatcher,jc=T.ReactCurrentOwner,xi=T.ReactCurrentBatchConfig,et=0,jt=null,kt=null,$t=0,mi=0,zr=bn(0),Rt=0,Bs=null,Jn=0,la=0,Tc=0,Os=null,oi=null,Ac=0,Fr=1/0,cn=null,ca=!1,Ic=null,Rn=null,ua=!1,Pn=null,ha=0,zs=0,Bc=null,da=-1,fa=0;function Zt(){return(et&6)!==0?St():da!==-1?da:da=St()}function Dn(n){return(n.mode&1)===0?1:(et&2)!==0&&$t!==0?$t&-$t:XS.transition!==null?(fa===0&&(fa=Dd()),fa):(n=nt,n!==0||(n=window.event,n=n===void 0?16:zd(n.type)),n)}function Oi(n,r,l,u){if(50<zs)throw zs=0,Bc=null,Error(i(185));cs(n,l,u),((et&2)===0||n!==jt)&&(n===jt&&((et&2)===0&&(la|=l),Rt===4&&Mn(n,$t)),ai(n,u),l===1&&et===0&&(r.mode&1)===0&&(Fr=St()+500,Ho&&Cn()))}function ai(n,r){var l=n.callbackNode;Xy(n,r);var u=bo(n,n===jt?$t:0);if(u===0)l!==null&&Nd(l),n.callbackNode=null,n.callbackPriority=0;else if(r=u&-u,n.callbackPriority!==r){if(l!=null&&Nd(l),r===1)n.tag===0?YS(Fp.bind(null,n)):xf(Fp.bind(null,n)),US(function(){(et&6)===0&&Cn()}),l=null;else{switch(Md(u)){case 1:l=gl;break;case 4:l=Rd;break;case 16:l=_o;break;case 536870912:l=Pd;break;default:l=_o}l=Yp(l,zp.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function zp(n,r){if(da=-1,fa=0,(et&6)!==0)throw Error(i(327));var l=n.callbackNode;if(Hr()&&n.callbackNode!==l)return null;var u=bo(n,n===jt?$t:0);if(u===0)return null;if((u&30)!==0||(u&n.expiredLanes)!==0||r)r=pa(n,u);else{r=u;var f=et;et|=2;var g=$p();(jt!==n||$t!==r)&&(cn=null,Fr=St()+500,er(n,r));do try{mw();break}catch(I){Hp(n,I)}while(!0);tc(),aa.current=g,et=f,kt!==null?r=0:(jt=null,$t=0,r=Rt)}if(r!==0){if(r===2&&(f=vl(n),f!==0&&(u=f,r=Oc(n,f))),r===1)throw l=Bs,er(n,0),Mn(n,u),ai(n,St()),l;if(r===6)Mn(n,u);else{if(f=n.current.alternate,(u&30)===0&&!fw(f)&&(r=pa(n,u),r===2&&(g=vl(n),g!==0&&(u=g,r=Oc(n,g))),r===1))throw l=Bs,er(n,0),Mn(n,u),ai(n,St()),l;switch(n.finishedWork=f,n.finishedLanes=u,r){case 0:case 1:throw Error(i(345));case 2:tr(n,oi,cn);break;case 3:if(Mn(n,u),(u&130023424)===u&&(r=Ac+500-St(),10<r)){if(bo(n,0)!==0)break;if(f=n.suspendedLanes,(f&u)!==u){Zt(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=Ul(tr.bind(null,n,oi,cn),r);break}tr(n,oi,cn);break;case 4:if(Mn(n,u),(u&4194240)===u)break;for(r=n.eventTimes,f=-1;0<u;){var E=31-Li(u);g=1<<E,E=r[E],E>f&&(f=E),u&=~g}if(u=f,u=St()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*dw(u/1960))-u,10<u){n.timeoutHandle=Ul(tr.bind(null,n,oi,cn),u);break}tr(n,oi,cn);break;case 5:tr(n,oi,cn);break;default:throw Error(i(329))}}}return ai(n,St()),n.callbackNode===l?zp.bind(null,n):null}function Oc(n,r){var l=Os;return n.current.memoizedState.isDehydrated&&(er(n,r).flags|=256),n=pa(n,r),n!==2&&(r=oi,oi=l,r!==null&&zc(r)),n}function zc(n){oi===null?oi=n:oi.push.apply(oi,n)}function fw(n){for(var r=n;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var u=0;u<l.length;u++){var f=l[u],g=f.getSnapshot;f=f.value;try{if(!ji(g(),f))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Mn(n,r){for(r&=~Tc,r&=~la,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Li(r),u=1<<l;n[l]=-1,r&=~u}}function Fp(n){if((et&6)!==0)throw Error(i(327));Hr();var r=bo(n,0);if((r&1)===0)return ai(n,St()),null;var l=pa(n,r);if(n.tag!==0&&l===2){var u=vl(n);u!==0&&(r=u,l=Oc(n,u))}if(l===1)throw l=Bs,er(n,0),Mn(n,r),ai(n,St()),l;if(l===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,tr(n,oi,cn),ai(n,St()),null}function Fc(n,r){var l=et;et|=1;try{return n(r)}finally{et=l,et===0&&(Fr=St()+500,Ho&&Cn())}}function Zn(n){Pn!==null&&Pn.tag===0&&(et&6)===0&&Hr();var r=et;et|=1;var l=xi.transition,u=nt;try{if(xi.transition=null,nt=1,n)return n()}finally{nt=u,xi.transition=l,et=r,(et&6)===0&&Cn()}}function Hc(){mi=zr.current,lt(zr)}function er(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,WS(l)),kt!==null)for(l=kt.return;l!==null;){var u=l;switch(Gl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&zo();break;case 3:Ir(),lt(ni),lt(qt),cc();break;case 5:ac(u);break;case 4:Ir();break;case 13:lt(ft);break;case 19:lt(ft);break;case 10:ic(u.type._context);break;case 22:case 23:Hc()}l=l.return}if(jt=n,kt=n=Ln(n.current,null),$t=mi=r,Rt=0,Bs=null,Tc=la=Jn=0,oi=Os=null,Xn!==null){for(r=0;r<Xn.length;r++)if(l=Xn[r],u=l.interleaved,u!==null){l.interleaved=null;var f=u.next,g=l.pending;if(g!==null){var E=g.next;g.next=f,u.next=E}l.pending=u}Xn=null}return n}function Hp(n,r){do{var l=kt;try{if(tc(),Qo.current=ta,Jo){for(var u=pt.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Jo=!1}if(Qn=0,Lt=Nt=pt=null,Ms=!1,Ls=0,jc.current=null,l===null||l.return===null){Rt=1,Bs=r,kt=null;break}e:{var g=n,E=l.return,I=l,U=r;if(r=$t,I.flags|=32768,U!==null&&typeof U=="object"&&typeof U.then=="function"){var ne=U,ve=I,_e=ve.tag;if((ve.mode&1)===0&&(_e===0||_e===11||_e===15)){var ge=ve.alternate;ge?(ve.updateQueue=ge.updateQueue,ve.memoizedState=ge.memoizedState,ve.lanes=ge.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Re=dp(E);if(Re!==null){Re.flags&=-257,fp(Re,E,I,g,r),Re.mode&1&&hp(g,ne,r),r=Re,U=ne;var Le=r.updateQueue;if(Le===null){var Te=new Set;Te.add(U),r.updateQueue=Te}else Le.add(U);break e}else{if((r&1)===0){hp(g,ne,r),$c();break e}U=Error(i(426))}}else if(ht&&I.mode&1){var wt=dp(E);if(wt!==null){(wt.flags&65536)===0&&(wt.flags|=256),fp(wt,E,I,g,r),Zl(Br(U,I));break e}}g=U=Br(U,I),Rt!==4&&(Rt=2),Os===null?Os=[g]:Os.push(g),g=E;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var Z=cp(g,U,r);If(g,Z);break e;case 1:I=U;var Y=g.type,ee=g.stateNode;if((g.flags&128)===0&&(typeof Y.getDerivedStateFromError=="function"||ee!==null&&typeof ee.componentDidCatch=="function"&&(Rn===null||!Rn.has(ee)))){g.flags|=65536,r&=-r,g.lanes|=r;var Se=up(g,I,r);If(g,Se);break e}}g=g.return}while(g!==null)}Up(l)}catch(Ie){r=Ie,kt===l&&l!==null&&(kt=l=l.return);continue}break}while(!0)}function $p(){var n=aa.current;return aa.current=ta,n===null?ta:n}function $c(){(Rt===0||Rt===3||Rt===2)&&(Rt=4),jt===null||(Jn&268435455)===0&&(la&268435455)===0||Mn(jt,$t)}function pa(n,r){var l=et;et|=2;var u=$p();(jt!==n||$t!==r)&&(cn=null,er(n,r));do try{pw();break}catch(f){Hp(n,f)}while(!0);if(tc(),et=l,aa.current=u,kt!==null)throw Error(i(261));return jt=null,$t=0,Rt}function pw(){for(;kt!==null;)Wp(kt)}function mw(){for(;kt!==null&&!Fy();)Wp(kt)}function Wp(n){var r=Vp(n.alternate,n,mi);n.memoizedProps=n.pendingProps,r===null?Up(n):kt=r,jc.current=null}function Up(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=aw(l,r,mi),l!==null){kt=l;return}}else{if(l=lw(l,r),l!==null){l.flags&=32767,kt=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Rt=6,kt=null;return}}if(r=r.sibling,r!==null){kt=r;return}kt=r=n}while(r!==null);Rt===0&&(Rt=5)}function tr(n,r,l){var u=nt,f=xi.transition;try{xi.transition=null,nt=1,gw(n,r,l,u)}finally{xi.transition=f,nt=u}return null}function gw(n,r,l,u){do Hr();while(Pn!==null);if((et&6)!==0)throw Error(i(327));l=n.finishedWork;var f=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var g=l.lanes|l.childLanes;if(Gy(n,g),n===jt&&(kt=jt=null,$t=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||ua||(ua=!0,Yp(_o,function(){return Hr(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=xi.transition,xi.transition=null;var E=nt;nt=1;var I=et;et|=4,jc.current=null,uw(n,l),Tp(l,n),IS($l),xo=!!Hl,$l=Hl=null,n.current=l,hw(l),Hy(),et=I,nt=E,xi.transition=g}else n.current=l;if(ua&&(ua=!1,Pn=n,ha=f),g=n.pendingLanes,g===0&&(Rn=null),Uy(l.stateNode),ai(n,St()),r!==null)for(u=n.onRecoverableError,l=0;l<r.length;l++)f=r[l],u(f.value,{componentStack:f.stack,digest:f.digest});if(ca)throw ca=!1,n=Ic,Ic=null,n;return(ha&1)!==0&&n.tag!==0&&Hr(),g=n.pendingLanes,(g&1)!==0?n===Bc?zs++:(zs=0,Bc=n):zs=0,Cn(),null}function Hr(){if(Pn!==null){var n=Md(ha),r=xi.transition,l=nt;try{if(xi.transition=null,nt=16>n?16:n,Pn===null)var u=!1;else{if(n=Pn,Pn=null,ha=0,(et&6)!==0)throw Error(i(331));var f=et;for(et|=4,Me=n.current;Me!==null;){var g=Me,E=g.child;if((Me.flags&16)!==0){var I=g.deletions;if(I!==null){for(var U=0;U<I.length;U++){var ne=I[U];for(Me=ne;Me!==null;){var ve=Me;switch(ve.tag){case 0:case 11:case 15:Is(8,ve,g)}var _e=ve.child;if(_e!==null)_e.return=ve,Me=_e;else for(;Me!==null;){ve=Me;var ge=ve.sibling,Re=ve.return;if(Pp(ve),ve===ne){Me=null;break}if(ge!==null){ge.return=Re,Me=ge;break}Me=Re}}}var Le=g.alternate;if(Le!==null){var Te=Le.child;if(Te!==null){Le.child=null;do{var wt=Te.sibling;Te.sibling=null,Te=wt}while(Te!==null)}}Me=g}}if((g.subtreeFlags&2064)!==0&&E!==null)E.return=g,Me=E;else e:for(;Me!==null;){if(g=Me,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Is(9,g,g.return)}var Z=g.sibling;if(Z!==null){Z.return=g.return,Me=Z;break e}Me=g.return}}var Y=n.current;for(Me=Y;Me!==null;){E=Me;var ee=E.child;if((E.subtreeFlags&2064)!==0&&ee!==null)ee.return=E,Me=ee;else e:for(E=Y;Me!==null;){if(I=Me,(I.flags&2048)!==0)try{switch(I.tag){case 0:case 11:case 15:oa(9,I)}}catch(Ie){vt(I,I.return,Ie)}if(I===E){Me=null;break e}var Se=I.sibling;if(Se!==null){Se.return=I.return,Me=Se;break e}Me=I.return}}if(et=f,Cn(),Fi&&typeof Fi.onPostCommitFiberRoot=="function")try{Fi.onPostCommitFiberRoot(yo,n)}catch{}u=!0}return u}finally{nt=l,xi.transition=r}}return!1}function Kp(n,r,l){r=Br(l,r),r=cp(n,r,1),n=En(n,r,1),r=Zt(),n!==null&&(cs(n,1,r),ai(n,r))}function vt(n,r,l){if(n.tag===3)Kp(n,n,l);else for(;r!==null;){if(r.tag===3){Kp(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Rn===null||!Rn.has(u))){n=Br(l,n),n=up(r,n,1),r=En(r,n,1),n=Zt(),r!==null&&(cs(r,1,n),ai(r,n));break}}r=r.return}}function vw(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),r=Zt(),n.pingedLanes|=n.suspendedLanes&l,jt===n&&($t&l)===l&&(Rt===4||Rt===3&&($t&130023424)===$t&&500>St()-Ac?er(n,0):Tc|=l),ai(n,r)}function qp(n,r){r===0&&((n.mode&1)===0?r=1:(r=wo,wo<<=1,(wo&130023424)===0&&(wo=4194304)));var l=Zt();n=on(n,r),n!==null&&(cs(n,r,l),ai(n,l))}function _w(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),qp(n,l)}function yw(n,r){var l=0;switch(n.tag){case 13:var u=n.stateNode,f=n.memoizedState;f!==null&&(l=f.retryLane);break;case 19:u=n.stateNode;break;default:throw Error(i(314))}u!==null&&u.delete(r),qp(n,l)}var Vp;Vp=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||ni.current)si=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return si=!1,ow(n,r,l);si=(n.flags&131072)!==0}else si=!1,ht&&(r.flags&1048576)!==0&&Ef(r,Wo,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;ra(n,r),n=r.pendingProps;var f=Pr(r,qt.current);Ar(r,l),f=dc(null,r,u,n,f,l);var g=fc();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,ri(u)?(g=!0,Fo(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,sc(r),f.updater=ia,r.stateNode=f,f._reactInternals=r,yc(r,u,n,l),r=kc(null,r,u,!0,g,l)):(r.tag=0,ht&&g&&Xl(r),Jt(null,r,f,l),r=r.child),r;case 16:u=r.elementType;e:{switch(ra(n,r),n=r.pendingProps,f=u._init,u=f(u._payload),r.type=u,f=r.tag=ww(u),n=Ai(u,n),f){case 0:r=bc(null,r,u,n,l);break e;case 1:r=yp(null,r,u,n,l);break e;case 11:r=pp(null,r,u,n,l);break e;case 14:r=mp(null,r,u,Ai(u.type,n),l);break e}throw Error(i(306,u,""))}return r;case 0:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),bc(n,r,u,f,l);case 1:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),yp(n,r,u,f,l);case 3:e:{if(Sp(r),n===null)throw Error(i(387));u=r.pendingProps,g=r.memoizedState,f=g.element,Af(n,r),Xo(r,u,null,l);var E=r.memoizedState;if(u=E.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:E.cache,pendingSuspenseBoundaries:E.pendingSuspenseBoundaries,transitions:E.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Br(Error(i(423)),r),r=wp(n,r,u,l,f);break e}else if(u!==f){f=Br(Error(i(424)),r),r=wp(n,r,u,l,f);break e}else for(pi=wn(r.stateNode.containerInfo.firstChild),fi=r,ht=!0,Ti=null,l=jf(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Lr(),u===f){r=ln(n,r,l);break e}Jt(n,r,u,l)}r=r.child}return r;case 5:return Of(r),n===null&&Jl(r),u=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,E=f.children,Wl(u,f)?E=null:g!==null&&Wl(u,g)&&(r.flags|=32),_p(n,r),Jt(n,r,E,l),r.child;case 6:return n===null&&Jl(r),null;case 13:return bp(n,r,l);case 4:return oc(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=jr(r,null,u,l):Jt(n,r,u,l),r.child;case 11:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),pp(n,r,u,f,l);case 7:return Jt(n,r,r.pendingProps,l),r.child;case 8:return Jt(n,r,r.pendingProps.children,l),r.child;case 12:return Jt(n,r,r.pendingProps.children,l),r.child;case 10:e:{if(u=r.type._context,f=r.pendingProps,g=r.memoizedProps,E=f.value,st(qo,u._currentValue),u._currentValue=E,g!==null)if(ji(g.value,E)){if(g.children===f.children&&!ni.current){r=ln(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var I=g.dependencies;if(I!==null){E=g.child;for(var U=I.firstContext;U!==null;){if(U.context===u){if(g.tag===1){U=an(-1,l&-l),U.tag=2;var ne=g.updateQueue;if(ne!==null){ne=ne.shared;var ve=ne.pending;ve===null?U.next=U:(U.next=ve.next,ve.next=U),ne.pending=U}}g.lanes|=l,U=g.alternate,U!==null&&(U.lanes|=l),nc(g.return,l,r),I.lanes|=l;break}U=U.next}}else if(g.tag===10)E=g.type===r.type?null:g.child;else if(g.tag===18){if(E=g.return,E===null)throw Error(i(341));E.lanes|=l,I=E.alternate,I!==null&&(I.lanes|=l),nc(E,l,r),E=g.sibling}else E=g.child;if(E!==null)E.return=g;else for(E=g;E!==null;){if(E===r){E=null;break}if(g=E.sibling,g!==null){g.return=E.return,E=g;break}E=E.return}g=E}Jt(n,r,f.children,l),r=r.child}return r;case 9:return f=r.type,u=r.pendingProps.children,Ar(r,l),f=ki(f),u=u(f),r.flags|=1,Jt(n,r,u,l),r.child;case 14:return u=r.type,f=Ai(u,r.pendingProps),f=Ai(u.type,f),mp(n,r,u,f,l);case 15:return gp(n,r,r.type,r.pendingProps,l);case 17:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),ra(n,r),r.tag=1,ri(u)?(n=!0,Fo(r)):n=!1,Ar(r,l),ap(r,u,f),yc(r,u,f,l),kc(null,r,u,!0,n,l);case 19:return Cp(n,r,l);case 22:return vp(n,r,l)}throw Error(i(156,r.tag))};function Yp(n,r){return Ed(n,r)}function Sw(n,r,l,u){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(n,r,l,u){return new Sw(n,r,l,u)}function Wc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function ww(n){if(typeof n=="function")return Wc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===A)return 11;if(n===O)return 14}return 2}function Ln(n,r){var l=n.alternate;return l===null?(l=Ei(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function ma(n,r,l,u,f,g){var E=2;if(u=n,typeof n=="function")Wc(n)&&(E=1);else if(typeof n=="string")E=5;else e:switch(n){case F:return ir(l.children,f,g,r);case G:E=8,f|=8;break;case W:return n=Ei(12,l,r,f|2),n.elementType=W,n.lanes=g,n;case N:return n=Ei(13,l,r,f),n.elementType=N,n.lanes=g,n;case R:return n=Ei(19,l,r,f),n.elementType=R,n.lanes=g,n;case z:return ga(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case V:E=10;break e;case X:E=9;break e;case A:E=11;break e;case O:E=14;break e;case D:E=16,u=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Ei(E,l,r,f),r.elementType=n,r.type=u,r.lanes=g,r}function ir(n,r,l,u){return n=Ei(7,n,u,r),n.lanes=l,n}function ga(n,r,l,u){return n=Ei(22,n,u,r),n.elementType=z,n.lanes=l,n.stateNode={isHidden:!1},n}function Uc(n,r,l){return n=Ei(6,n,null,r),n.lanes=l,n}function Kc(n,r,l){return r=Ei(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function bw(n,r,l,u,f){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=_l(0),this.expirationTimes=_l(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_l(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function qc(n,r,l,u,f,g,E,I,U){return n=new bw(n,r,l,I,U),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ei(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:u,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},sc(g),n}function kw(n,r,l){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:u==null?null:""+u,children:n,containerInfo:r,implementation:l}}function Xp(n){if(!n)return kn;n=n._reactInternals;e:{if(Un(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(ri(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var l=n.type;if(ri(l))return kf(n,l,r)}return r}function Gp(n,r,l,u,f,g,E,I,U){return n=qc(l,u,!0,n,f,g,E,I,U),n.context=Xp(null),l=n.current,u=Zt(),f=Dn(l),g=an(u,f),g.callback=r??null,En(l,g,f),n.current.lanes=f,cs(n,f,u),ai(n,u),n}function va(n,r,l,u){var f=r.current,g=Zt(),E=Dn(f);return l=Xp(l),r.context===null?r.context=l:r.pendingContext=l,r=an(g,E),r.payload={element:n},u=u===void 0?null:u,u!==null&&(r.callback=u),n=En(f,r,E),n!==null&&(Oi(n,f,E,g),Yo(n,f,E)),E}function _a(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Qp(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function Vc(n,r){Qp(n,r),(n=n.alternate)&&Qp(n,r)}function Cw(){return null}var Jp=typeof reportError=="function"?reportError:function(n){console.error(n)};function Yc(n){this._internalRoot=n}ya.prototype.render=Yc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));va(n,r,null,null)},ya.prototype.unmount=Yc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;Zn(function(){va(null,n,null,null)}),r[tn]=null}};function ya(n){this._internalRoot=n}ya.prototype.unstable_scheduleHydration=function(n){if(n){var r=Td();n={blockedOn:null,target:n,priority:r};for(var l=0;l<_n.length&&r!==0&&r<_n[l].priority;l++);_n.splice(l,0,n),l===0&&Bd(n)}};function Xc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Sa(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Zp(){}function xw(n,r,l,u,f){if(f){if(typeof u=="function"){var g=u;u=function(){var ne=_a(E);g.call(ne)}}var E=Gp(r,u,n,0,null,!1,!1,"",Zp);return n._reactRootContainer=E,n[tn]=E.current,ks(n.nodeType===8?n.parentNode:n),Zn(),E}for(;f=n.lastChild;)n.removeChild(f);if(typeof u=="function"){var I=u;u=function(){var ne=_a(U);I.call(ne)}}var U=qc(n,0,!1,null,null,!1,!1,"",Zp);return n._reactRootContainer=U,n[tn]=U.current,ks(n.nodeType===8?n.parentNode:n),Zn(function(){va(r,U,l,u)}),U}function wa(n,r,l,u,f){var g=l._reactRootContainer;if(g){var E=g;if(typeof f=="function"){var I=f;f=function(){var U=_a(E);I.call(U)}}va(r,E,n,f)}else E=xw(l,r,n,f,u);return _a(E)}Ld=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=ls(r.pendingLanes);l!==0&&(yl(r,l|1),ai(r,St()),(et&6)===0&&(Fr=St()+500,Cn()))}break;case 13:Zn(function(){var u=on(n,1);if(u!==null){var f=Zt();Oi(u,n,1,f)}}),Vc(n,1)}},Sl=function(n){if(n.tag===13){var r=on(n,134217728);if(r!==null){var l=Zt();Oi(r,n,134217728,l)}Vc(n,134217728)}},jd=function(n){if(n.tag===13){var r=Dn(n),l=on(n,r);if(l!==null){var u=Zt();Oi(l,n,r,u)}Vc(n,r)}},Td=function(){return nt},Ad=function(n,r){var l=nt;try{return nt=n,r()}finally{nt=l}},dl=function(n,r,l){switch(r){case"input":if(ae(n,l),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var u=l[r];if(u!==n&&u.form===n.form){var f=Oo(u);if(!f)throw Error(i(90));Ve(u),ae(u,f)}}}break;case"textarea":Pe(n,l);break;case"select":r=l.value,r!=null&&K(n,!!l.multiple,r,!1)}},yd=Fc,Sd=Zn;var Ew={usingClientEntryPoint:!1,Events:[Es,Nr,Oo,vd,_d,Fc]},Fs={findFiberByHostInstance:Kn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Nw={bundleType:Fs.bundleType,version:Fs.version,rendererPackageName:Fs.rendererPackageName,rendererConfig:Fs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=Cd(n),n===null?null:n.stateNode},findFiberByHostInstance:Fs.findFiberByHostInstance||Cw,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 ba=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ba.isDisabled&&ba.supportsFiber)try{yo=ba.inject(Nw),Fi=ba}catch{}}return li.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ew,li.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Xc(r))throw Error(i(200));return kw(n,r,null,l)},li.createRoot=function(n,r){if(!Xc(n))throw Error(i(299));var l=!1,u="",f=Jp;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=qc(n,1,!1,null,null,l,!1,u,f),n[tn]=r.current,ks(n.nodeType===8?n.parentNode:n),new Yc(r)},li.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=Cd(r),n=n===null?null:n.stateNode,n},li.flushSync=function(n){return Zn(n)},li.hydrate=function(n,r,l){if(!Sa(r))throw Error(i(200));return wa(null,n,r,!0,l)},li.hydrateRoot=function(n,r,l){if(!Xc(n))throw Error(i(405));var u=l!=null&&l.hydratedSources||null,f=!1,g="",E=Jp;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(E=l.onRecoverableError)),r=Gp(r,null,n,1,l??null,f,!1,g,E),n[tn]=r.current,ks(n),u)for(n=0;n<u.length;n++)l=u[n],f=l._getVersion,f=f(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,f]:r.mutableSourceEagerHydrationData.push(l,f);return new ya(r)},li.render=function(n,r,l){if(!Sa(r))throw Error(i(200));return wa(null,n,r,!1,l)},li.unmountComponentAtNode=function(n){if(!Sa(n))throw Error(i(40));return n._reactRootContainer?(Zn(function(){wa(null,null,n,!1,function(){n._reactRootContainer=null,n[tn]=null})}),!0):!1},li.unstable_batchedUpdates=Fc,li.unstable_renderSubtreeIntoContainer=function(n,r,l,u){if(!Sa(l))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return wa(n,r,l,!1,u)},li.version="18.3.1-next-f1338f8080-20240426",li}var am;function Iw(){if(am)return Jc.exports;am=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(),Jc.exports=Aw(),Jc.exports}var lm;function Bw(){if(lm)return ka;lm=1;var e=Iw();return ka.createRoot=e.createRoot,ka.hydrateRoot=e.hydrateRoot,ka}var Ow=Bw();const zw=Fh(Ow);function zt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const Lv=e=>`nc_seen_${e}`;async function qe(e,t,i={}){const s=await zt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const hi=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Kt=(e,t)=>`${hi(e)}/fleet/${t}`,pr=(e,t)=>qe(Kt(t,"status"),e),$h=(e,t,i)=>qe(Kt(i,"up"),e,{method:"POST",body:t}),$a=(e,t,i)=>qe(Kt(i,"down"),e,{method:"POST",body:t}),Qs=(e,t,i)=>qe(Kt(i,"restart"),e,{method:"POST",body:{cell:t}}),Wh=(e,t)=>qe(Kt(t,"definitions"),e),Fw=(e,t)=>qe(Kt(t,"credentials/status"),e),cm=(e,t,i,s)=>qe(Kt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),Hw=(e,t,i)=>qe(Kt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),$w=(e,t,i)=>qe(Kt(i,"define-engine"),e,{method:"POST",body:{def:t}}),Ww=(e,t,i,s,o)=>qe(Kt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),Uw=(e,t,i)=>qe(Kt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),Kw=(e,t,i)=>qe(Kt(i,"define-cell"),e,{method:"POST",body:{def:t}}),qw=(e,t,i,s)=>qe(Kt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),jv=(e,t,i=!1,s)=>qe(Kt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Vw=(e,t,i)=>qe(Kt(i,"import-cell"),e,{method:"POST",body:t}),Yw=(e,t,i)=>qe(Kt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),Xw=(e,t,i,s)=>qe(Kt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),Uh=(e,t,i)=>qe(`${hi(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Tv=(e,t,i,s)=>qe(`${hi(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Av=(e,t,i)=>qe(`${hi(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Iv=e=>qe("/api/settings",e),Bv=e=>qe("/api/nodes",e),Gw=e=>qe("/api/topology",e),Ov=(e,t)=>qe(`${hi(t)}/sessions`,e),Kh=(e,t)=>qe(`${hi(t)}/config`,e),um=(e,t)=>qe(`${hi(t)}/topology`,e),zv=(e,t)=>qe("/api/settings/config",e,{method:"POST",body:t}),Qw=e=>qe("/api/settings/token/rotate",e,{method:"POST"}),Jw=(e,t)=>qe("/api/settings/nodes/pair",e,{method:"POST",body:t}),hm=(e,t,i=[])=>qe(`${hi(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Zw=(e,t,i)=>qe(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),e0=(e,t)=>qe(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),qh=(e,t,i)=>qe(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),t0=(e,t,i)=>qe(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),dm=(e,t,i,s=[])=>qe(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),i0=e=>qe("/api/settings/service/regenerate",e,{method:"POST"}),n0=e=>qe("/api/settings/update/check",e,{method:"POST"}),r0=e=>qe("/api/settings/update/apply",e,{method:"POST"}),s0=(e,t=!0)=>qe(`/api/asks${t?"?open=1":""}`,e),o0=(e,t,i)=>qe(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),Ca=(e,t=[])=>qe(`${hi(t)}/decks`,e),fm=(e,t,i=[])=>qe(`${hi(i)}/decks`,e,{method:"POST",body:{name:t}}),xa=(e,t,i,s,o=[])=>qe(`${hi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),a0=(e,t,i,s,o=[])=>qe(`${hi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),l0=(e,t,i,s=[])=>qe(`${hi(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),c0={power:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 3v8"}),h.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:h.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),h.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),h.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),h.jsx("path",{d:"M12 18v3"})]}),enter:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),h.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),h.jsx("path",{d:"M22 2 11 13"})]}),trash:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),h.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),h.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:h.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),h.jsx("polyline",{points:"21 3 21 8 16 8"})]}),upload:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 16V5"}),h.jsx("polyline",{points:"8 9 12 5 16 9"}),h.jsx("path",{d:"M5 20h14"})]}),chevronLeft:h.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:h.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:h.jsx("polyline",{points:"6 10 12 16 18 10"}),history:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),h.jsx("polyline",{points:"3 3 3 8 8 8"}),h.jsx("path",{d:"M12 7v5l3 2"})]}),attach:h.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),h.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),h.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),h.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),h.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6"})]}),gear:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"12",cy:"12",r:"3"}),h.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),h.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function tt({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:c0[e]||null})}const u0=["all","pinned","active","off","technical"],Fv="nc_sidebar_views_v1",Hv="nc_sidebar_order_v1";function $v(e){return u0.includes(e)?e:"all"}function h0(e,t=[],i="all"){const s=$v(i);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function d0(e,t,i=[],s=[]){const o=i.indexOf(e.key),a=i.indexOf(t.key),c=o===-1?Number.MAX_SAFE_INTEGER:o,d=a===-1?Number.MAX_SAFE_INTEGER:a,m=s.indexOf(e.key),p=s.indexOf(t.key),_=m===-1?Number.MAX_SAFE_INTEGER:m,S=p===-1?Number.MAX_SAFE_INTEGER:p;return c-d||_-S||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function f0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Hv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);a.length&&(i[s]=a)}return i}catch{return{}}}function Hn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function p0(e,t=globalThis.localStorage){try{t.setItem(Hv,JSON.stringify(e))}catch{}return e}function m0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const a=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!a.includes(i)||!a.includes(s))return e;const c=Hn(e,t).filter(y=>a.includes(y)),d=[...c,...a.filter(y=>!c.includes(y))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const _=d.indexOf(s),S=m<p?_+1:_;return d.splice(S,0,i),{...e,[t]:d}}function g0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Fv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function pm(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:$v((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function v0(e,t=globalThis.localStorage){try{t.setItem(Fv,JSON.stringify(e))}catch{}return e}function mm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function cr(e=[],t=[],i="all",s=[]){return[...e].filter(o=>h0(o,t,i)).sort((o,a)=>d0(o,a,t,s))}const Vh=["it","en","es"];function _0(){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 Aa=_0(),Wv="nc_lang",Wu="nc-lang";function Uv(){return typeof localStorage<"u"?localStorage:null}const Ea={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nome del nodo solo su questa interfaccia","rename-node-reset":"Lascia vuoto per ripristinare il nome originale.","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"Node name on this interface only","rename-node-reset":"Leave empty to restore the original name.","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-private":"Private: only this device can use its hub connection.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-external-hint":"External provider: engine/model are configured in the external fleet.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nombre del nodo solo en esta interfaz","rename-node-reset":"Déjalo vacío para restaurar el nombre original.","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","node-display-label":"Nombre (etiqueta)","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-external-hint":"Proveedor externo: motor/modelo se configuran en el fleet externo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación completa de un solo uso. Si este dispositivo ya está unido a un hub, se usa automáticamente; si no, solo hace falta su dirección SSH alcanzable.","invite-network-hint":"Crea una invitación para la red a la que ya estás conectado. El nuevo dispositivo entra por el hub y no se conecta directamente a este dispositivo.","invite-network-label":"Red de destino","invite-network-via":"Hub","invite-network-route":"Una sola conexión al hub; nodos, celdas y decks se enrutan internamente.","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function Uu(){const e=Uv(),t=e?e.getItem(Wv):null;return Vh.includes(t)?t:Aa}function y0(e){const t=Uv();if(t)try{t.setItem(Wv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Wu))}function v(e){const t=Uu(),i=Ea[t]||Ea[Aa];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(Ea[Aa],e)?Ea[Aa][e]:e}function S0(e){return typeof window>"u"?()=>{}:(window.addEventListener(Wu,e),()=>window.removeEventListener(Wu,e))}const Kv=Vh;function Si(){return[P.useSyncExternalStore(S0,Uu,Uu),y0]}function Wa({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var O,D;Si();const a=!!(e&&e.active),c=Array.isArray(i)?i.join("/"):"",[d,m]=P.useState([]),[p,_]=P.useState(!1);P.useEffect(()=>{let z=!0;return(async()=>{if(t)try{const B=await pr(t,c?c.split("/"):[]);if(!z)return;if(_(B.provider==="builtin"&&(B.capabilities||[]).includes("edit")),B.provider==="builtin"&&(B.capabilities||[]).includes("definitions")){const te=await Wh(t,c?c.split("/"):[]);if(!z)return;const q=new Map((B.engines||[]).map(j=>[j.id,j]));m((te.engines||[]).map(j=>{var $,re,le,se,pe,ye,ce;return{id:j.id,label:j.label||j.id,client:(($=j.managed)==null?void 0:$.client)||"",models:[...new Set([...((re=q.get(j.id))==null?void 0:re.models)||[],...((le=j.managedInfo)==null?void 0:le.models)||[]])].filter(Boolean),defaultModel:((se=j.managed)==null?void 0:se.model)||((pe=j.managedInfo)==null?void 0:pe.defaultModel)||"",policyDefault:((ye=j.managed)==null?void 0:ye.permissionPolicy)||((ce=j.managed)!=null&&ce.client&&j.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{z=!1}},[t,c]);const S=(e==null?void 0:e.engine)||((O=d[0])==null?void 0:O.id)||"",y=z=>(e==null?void 0:e.models)&&e.models[z]||"",k=z=>{const B=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[z];if(B==="standard"||B==="unsafe")return B;const te=d.find(q=>q.id===z);return te?te.policyDefault:"standard"},[w,x]=P.useState(S),[b,C]=P.useState((e==null?void 0:e.model)||""),M=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((D=e==null?void 0:e.permissionPolicies)==null?void 0:D[e==null?void 0:e.engine])||"",[L,T]=P.useState(M),[J,H]=P.useState((e==null?void 0:e.boot)??!0),[F,G]=P.useState(!1),[W,V]=P.useState(null);P.useEffect(()=>{d.length&&(x(z=>z||S),C(z=>z||y((e==null?void 0:e.engine)||S)||""),T(z=>z==="standard"||z==="unsafe"?z:k((e==null?void 0:e.engine)||S)))},[d.length]);const X=P.useMemo(()=>d.find(z=>z.id===w)||null,[d,w]),A=!!(X&&["claude","codex","codex-vl"].includes(X.client));function N(z){x(z);const B=d.find(te=>te.id===z);C(y(z)||(B==null?void 0:B.defaultModel)||""),T(k(z))}async function R(z){z.preventDefault(),G(!0),V(null);try{if(a)await s({action:"down",boot:J});else{const B=L==="standard"||L==="unsafe"?L:(X==null?void 0:X.policyDefault)||"standard";await s({action:"up",...p?{engine:w,model:b||"",...A?{permissionPolicy:B}:(X==null?void 0:X.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:J})}o()}catch(B){V(String(B&&B.message||B)),G(!1)}}return h.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:h.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:z=>z.stopPropagation(),onSubmit:R,children:[h.jsxs("div",{className:"nc-sheet-head",children:[h.jsx("b",{children:e==null?void 0:e.cell}),h.jsx("span",{className:"nc-sheet-state",children:v(a?"state-on":"state-off")})]}),a?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:v("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[v("model"),": ",e.model]}),h.jsx("small",{children:v("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:J,onChange:z=>H(z.target.checked)}),v("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[p&&d.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[v("engine"),h.jsx("select",{value:w,onChange:z=>N(z.target.value),children:d.map(z=>h.jsx("option",{value:z.id,children:z.label},z.id))})]}),h.jsxs("label",{className:"nc-field",children:[v("model"),h.jsx("input",{value:b,list:"nc-launch-models",placeholder:v("model-default"),onChange:z=>C(z.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((X==null?void 0:X.models)||[]).map(z=>h.jsx("option",{value:z},z))})]}),A?h.jsxs("label",{className:"nc-field",children:[v("permissions"),h.jsxs("select",{value:L,onChange:z=>T(z.target.value),children:[h.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:v("fleet-standard-permissions")}),A&&L==="unsafe"&&h.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:v("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:v("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[v("model"),": ",e.model]}),h.jsx("small",{children:v("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:J,onChange:z=>H(z.target.checked)}),v("boot-persist")]})]}),W&&h.jsx("div",{className:"nc-err",children:W}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:F,children:v("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:F,children:v(a?"power-off":"save-and-start")})]})]})})}const gm=/^[a-z0-9-]{1,32}$/;function Ua(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function w0(e,t,i){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const c=a.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!m&&(s[c]=e&&e[c]||i)}return s}function vm(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function _m({nodes:e,topology:t,remote:i,down:s,fleet:o}={}){var m,p,_,S;const a=[],c=new Set,d=new Set;for(const y of Array.isArray(e)?e:[]){if(!y||typeof y.name!="string"||!gm.test(y.name)||y.direction==="inbound"&&y.shared!==!0)continue;const k=[y.name],w=y.name;c.add(w);const x=((m=y.tunnel)==null?void 0:m.status)||"unknown",b=x==="up",C={name:y.name,label:y.label||y.name,route:k,direct:!0,instanceId:y.nodeId||null,shared:y.shared===!0,tunnelStatus:x,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,direction:y.direction||"outbound",roles:y.roles||null,rolesKnown:y.rolesKnown===!0};if(y.nodeId&&d.add(y.nodeId),!y.nodeId&&y.paired===!1){a.push({...C,status:"needs-repair",downSince:s&&s[w]||null});continue}if(((p=y.health)==null?void 0:p.auth)==="failed"||x==="degraded"&&((_=y.health)==null?void 0:_.status)==="degraded"){a.push({...C,status:"needs-repair",downSince:s&&s[w]||null});continue}if(x==="passive"||((S=y.health)==null?void 0:S.status)==="passive"){a.push({...C,status:"passive",downSince:null});continue}if(!b){a.push({...C,status:"down",downSince:s&&s[w]||null});continue}const M=i&&(i[w]||i[y.name])||null,L=o&&(o[w]||o[y.name]),T=!!(M&&!M.error&&Array.isArray(M.sessions)),J=!!(L&&L.available===!0&&Array.isArray(L.cells));if(!T&&!J){a.push({...C,status:"unreachable"});continue}const H=(T?M.sessions:[]).filter(W=>W&&typeof W.name=="string"&&W.name).map(W=>({...W,node:w,route:k,key:`${w}:${W.name}`})),F=vm(L,k,w),G=new Set(F.map(W=>W.tmuxSession).filter(Boolean));a.push({...C,status:"up",sessions:H,cells:F,unmanaged:H.filter(W=>!G.has(W.name)),fleetAvailable:!!(L&&L.available),capabilities:L&&L.capabilities||[],engines:L&&L.engines||[],fleetProvider:L&&L.provider||null,sessionsAvailable:T,inventoryPartial:!T})}for(const y of Array.isArray(t)?t:[]){if(!y||!Array.isArray(y.route)||y.route.length<1||y.route.some(H=>!gm.test(H)))continue;const k=y.route.join("/");if(c.has(k)||y.instanceId&&d.has(y.instanceId))continue;y.instanceId&&d.add(y.instanceId);const w={name:y.name,label:y.label||y.route.join(" › "),route:[...y.route],direct:!1,instanceId:y.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,lastSeen:y.lastSeen||null};if(y.stale){a.push({...w,status:"offline",downSince:s&&s[k]||y.lastSeen||null});continue}const x=i&&i[k]||null,b=o&&o[k],C=!!(x&&!x.error&&Array.isArray(x.sessions)),M=!!(b&&b.available===!0&&Array.isArray(b.cells));if(!C&&!M){a.push({...w,status:"unreachable",downSince:s&&s[k]||null});continue}const L=(C?x.sessions:[]).filter(H=>H&&typeof H.name=="string"&&H.name).map(H=>({...H,node:k,route:y.route,key:`${k}:${H.name}`})),T=vm(b,y.route,k),J=new Set(T.map(H=>H.tmuxSession).filter(Boolean));a.push({...w,status:"up",sessions:L,cells:T,unmanaged:L.filter(H=>!J.has(H.name)),fleetAvailable:!!(b&&b.available),capabilities:b&&b.capabilities||[],engines:b&&b.engines||[],fleetProvider:b&&b.provider||null,lastSeen:y.lastSeen||null,sessionsAvailable:C,inventoryPartial:!C})}return a.sort((y,k)=>y.label.localeCompare(k.label))}const b0=4e3;function Yh(e,t=!0){const[i,s]=P.useState([]),o=P.useRef({});return P.useEffect(()=>{if(!t||!e){s([]);return}let a=!0;async function c(){var x;let m=[],p=[];if(await Promise.all([Bv(e).then(b=>{m=Array.isArray(b.nodes)?b.nodes:[]}).catch(()=>{}),Gw(e).then(b=>{p=Array.isArray(b.nodes)?b.nodes:[]}).catch(()=>{})]),!a)return;const _={},S={},y=new Set(m.map(b=>b.name)),k=[];for(const b of m)((x=b.tunnel)==null?void 0:x.status)==="up"&&(b.nodeId||b.paired!==!1)&&(b.direction!=="inbound"||b.shared===!0)&&k.push([b.name]);for(const b of p)!b.stale&&Array.isArray(b.route)&&!(b.route.length===1&&y.has(b.route[0]))&&k.push(b.route);if(await Promise.all(k.map(async b=>{const C=b.join("/");try{_[C]=await Ov(e,b)}catch{_[C]={error:"unreachable"}}try{S[C]=await pr(e,b)}catch{S[C]={available:!1}}})),!a)return;const w=_m({nodes:m,topology:p,remote:_,fleet:S,down:o.current});o.current=w0(o.current,w,Math.floor(Date.now()/1e3)),s(_m({nodes:m,topology:p,remote:_,fleet:S,down:o.current}))}c();const d=setInterval(c,b0);return()=>{a=!1,clearInterval(d)}},[e,t]),i}const ym=52,Sm=14;function zn({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:a=()=>!0,scope:c="roster"}){const d=P.useRef(null),m=P.useRef(0),[p,_]=P.useState(!1),S=()=>{var C,M,L,T;const b=d.current;(M=(C=b==null?void 0:b.over)==null?void 0:C.classList)==null||M.remove("nc-roster-over"),(T=(L=b==null?void 0:b.source)==null?void 0:L.classList)==null||T.remove("nc-roster-dragging"),m.current&&cancelAnimationFrame(m.current),m.current=0},y=(b=!1)=>{const C=d.current;if(!C)return;const M=C.target;S(),d.current=null,_(!1);try{C.handle.releasePointerCapture(C.pointerId)}catch{}b&&M&&M!==t&&a(t,M)&&s(t,M)},k=(b,C)=>{var G,W,V,X,A,N,R,O,D;const M=d.current;if(!M)return;M.x=b,M.y=C;const L=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",T=(W=(G=document.elementFromPoint(b,C))==null?void 0:G.closest)==null?void 0:W.call(G,L),J=c==="node"?(V=T==null?void 0:T.dataset)==null?void 0:V.nodeOrderKey:(X=T==null?void 0:T.dataset)==null?void 0:X.rosterKey,F=(c==="node"||((A=T==null?void 0:T.dataset)==null?void 0:A.position)===e)&&J&&J!==t&&a(t,J);M.over!==(F?T:null)&&((R=(N=M.over)==null?void 0:N.classList)==null||R.remove("nc-roster-over"),M.over=F?T:null,(D=(O=M.over)==null?void 0:O.classList)==null||D.add("nc-roster-over")),M.target=F?J:null},w=()=>{const b=d.current;if(!b){m.current=0;return}const C=b.container;if(C){const M=C.getBoundingClientRect(),L=b.y<M.top+ym?-Sm:b.y>M.bottom-ym?Sm:0;L&&(C.scrollTop+=L,k(b.x,b.y))}m.current=requestAnimationFrame(w)};P.useEffect(()=>{const b=M=>{M.key==="Escape"&&d.current&&(M.preventDefault(),y(!1))},C=()=>y(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",C),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",C),S(),d.current=null}},[t,e,c]);const x=b=>{var T;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const C=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",M=b.currentTarget.closest(C),L=b.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");d.current={pointerId:b.pointerId,handle:b.currentTarget,source:M,container:L,target:null,over:null,x:b.clientX,y:b.clientY},(T=M==null?void 0:M.classList)==null||T.add("nc-roster-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}_(!0),m.current=requestAnimationFrame(w)};return h.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:v("reorder-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowUp"&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowUp"?-1:1))},onPointerDown:x,onPointerMove:b=>{!d.current||b.pointerId!==d.current.pointerId||(b.preventDefault(),b.stopPropagation(),k(b.clientX,b.clientY))},onPointerUp:b=>{!d.current||b.pointerId!==d.current.pointerId||(b.preventDefault(),b.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{d.current&&y(!1)},children:"↕"})}const Xh="nc_pins";function k0(){try{const e=JSON.parse(localStorage.getItem(Xh));return Array.isArray(e)?e:[]}catch{return[]}}function C0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Xh,JSON.stringify(i))}catch{}return i}function x0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(i);s.splice(o,1);const c=s.indexOf(i);s.splice(o<a?c+1:c,0,t);try{localStorage.setItem(Xh,JSON.stringify(s))}catch{}return s}function E0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function N0(e,t){return e[0]-t[0]||e[1]-t[1]}function qv(){const[e,t]=P.useState(k0),[i,s]=P.useState(g0),[o,a]=P.useState(f0),c=y=>t(k=>C0(k,y)),d=y=>pm(i,y),m=(y,k)=>s(w=>{const x={...w,[y]:{...pm(w,y),...k}};return v0(x)}),p=(y,k)=>e.includes(y)===e.includes(k);function _(y,k,w,x){const b=e.includes(k),C=e.includes(w);if(b===C){if(b){t(M=>x0(M,k,w));return}a(M=>{var J;const L=((J=x.find(H=>H.key===k))==null?void 0:J.technical)===!0,T=cr(x,e,L?"technical":"all",Hn(M,y)).map(H=>H.key);return p0(m0(M,y,k,w,T))})}}function S(y,k,w,x){var J;const b=((J=x.find(H=>H.key===k))==null?void 0:J.technical)===!0,C=e.includes(k),M=cr(x,e,b?"technical":"all",Hn(o,y)).map(H=>H.key).filter(H=>e.includes(H)===C),L=M.indexOf(k),T=M[L+w];L>=0&&T&&_(y,k,T,x)}return{pins:e,views:i,orders:o,togglePin:c,viewFor:d,updateView:m,canMoveRoster:p,moveRoster:_,stepRoster:S}}const Vv="nc_node_aliases_v1",Yv="nc_node_order_v1",R0=64,P0=/^[a-f0-9]{16,64}$/;function Xi(e){if(P0.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(i=>typeof i=="string"&&i):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Gh(e){if(typeof e!="string")return null;const t=e.trim();return t?t.length>R0||/[\x00-\x1f\x7f]/.test(t)?null:t:""}function wm(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Vv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,128)){const a=Gh(o);typeof s=="string"&&s.length<=192&&a&&(i[s]=a)}return i}catch{return{}}}function D0(e,t=globalThis.localStorage){try{t.setItem(Vv,JSON.stringify(e))}catch{}return e}function M0(e,t,i){const s=Xi(t),o=Gh(i);if(!s||o===null)return e;const a={...e||{}};return o?a[s]=o:delete a[s],a}function L0(e,t={}){return t[Xi(e)]||(e==null?void 0:e.label)||(e==null?void 0:e.name)||""}function bm(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Yv));return Array.isArray(t)?[...new Set(t.filter(i=>typeof i=="string"&&i&&i.length<=192))].slice(0,128):[]}catch{return[]}}function j0(e,t=globalThis.localStorage){try{t.setItem(Yv,JSON.stringify(e))}catch{}return e}function km(e=[],t=[]){const i=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=i.has(Xi(s.group))?i.get(Xi(s.group)):Number.MAX_SAFE_INTEGER,c=i.has(Xi(o.group))?i.get(Xi(o.group)):Number.MAX_SAFE_INTEGER;return a-c||s.index-o.index}).map(({group:s})=>s)}function T0(e,t,i,s=[]){if(!t||!i||t===i)return e;const o=s.map(Xi).filter(Boolean);if(!o.includes(t)||!o.includes(i))return e;const a=[...e.filter(p=>o.includes(p)),...o.filter(p=>!e.includes(p))],c=a.indexOf(t),d=a.indexOf(i);a.splice(c,1);const m=a.indexOf(i);return a.splice(c<d?m+1:m,0,t),a}const Ku="nexuscrew-node-preferences";function Cm(){try{window.dispatchEvent(new Event(Ku))}catch{}}function Xv(){const[e,t]=P.useState(wm),[i,s]=P.useState(bm);P.useEffect(()=>{const p=()=>{t(wm()),s(bm())};return window.addEventListener("storage",p),window.addEventListener(Ku,p),()=>{window.removeEventListener("storage",p),window.removeEventListener(Ku,p)}},[]);const o=p=>L0(p,e),a=p=>km(p,i).map(_=>({..._,label:o(_)})),c=(p,_)=>Gh(_)===null||!Xi(p)?!1:(t(S=>{const y=M0(S,p,_);return D0(y),Cm(),y}),!0),d=(p,_,S)=>s(y=>{const k=T0(y,p,_,S);return j0(k),Cm(),k});return{aliases:e,order:i,labelFor:o,groupsFor:a,renameNode:c,moveNode:d,stepNode:(p,_,S)=>{const y=km(S,i).map(Xi),k=y.indexOf(p),w=y[k+_];k>=0&&w&&d(p,w,S)},nodeKey:Xi}}function Qr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function Vr(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",Qr(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",Qr(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function Gv(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Ka(e){return e&&(e.detail||e.status)||""}function qa(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(Lv(t))||0);return e.outbox.latest>s}function Qv(e,t={}){const i=e||{};if(!i.tmux){const s=`${i.engine||""}${i.key?`·${i.key}`:""}`,o=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||v("cell-off")).trim()}}if(t.working===!0){const s=v("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:v("cell-idle")}:{working:!1,subtitle:String(t.preview||i.preview||v("cell-on")).trim()}}function Jv(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function Zv(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=i.get(o.tmuxSession)||{},c=Ua([],o.tmuxSession),d=Qv(o,a);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:qa(a,c,s),activity:a.activity||0,working:d.working,subtitle:d.subtitle,searchText:Jv(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=Ua([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:qa(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function e_(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(c=>[c.name,c])),a=[...(i.cells||[]).map(c=>{const d=o.get(c.tmuxSession)||{},m=Ua(s,c.tmuxSession||c.cell),p=Qv(c,d);return{type:"cell",value:c,key:m,label:c.cell,live:!!c.tmux,fresh:qa(d,m,t),activity:d.activity||c.activity||0,working:p.working,subtitle:p.subtitle,searchText:Jv(c,d)}}),...(i.unmanaged||[]).map(c=>{const d=Ua(s,c.name);return{type:"session",value:c,key:d,label:c.name,live:!0,technical:c.technical===!0,fresh:qa(c,d,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:a}}const Qh=9,Va=.2,A0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Jr=/^[a-f0-9]{16,64}$/,qu=e=>A0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Wn(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!qu(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Jr.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&qu(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function _i(e){const t=Wn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const t_=9,i_=24,lo=11,I0=e=>{const t=Number(e);return t>=t_&&t<=i_?t:lo};function Yr(){return{columns:[]}}function Qi(e){return e.columns.flatMap(t=>t.tiles.map(i=>_i(i)))}function B0(e){const t=[],i=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<i;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(_i(o.tiles[s]));return t}const ts=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function Jh(e,t,i,s){const o=Wn(t);if(!o||Qi(e).includes(_i(o))||Qi(e).length>=Qh)return e;const a=ts(e),c={session:o.session,height:1,fontSize:lo,...s||{}};if(o.node&&(c.node=o.node),o.ownerId&&(c.ownerId=o.ownerId),i==="end")return a.columns.push({width:1,tiles:[c]}),a;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&a.columns[i.col])return a.columns[i.col].tiles.splice(i.row,0,c),a;if(i&&typeof i.col=="number"){const d=Math.max(0,Math.min(a.columns.length,i.col));return a.columns.splice(d,0,{width:1,tiles:[c]}),a}return a.columns.push({width:1,tiles:[c]}),a}function n_(e,t){const i=_i(t);if(!i||Qi(e).includes(i)||Qi(e).length>=Qh)return e;const s=Qi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let _=0;for(let S=1;S<e.columns.length;S+=1)e.columns[S].tiles.length<e.columns[_].tiles.length&&(_=S);return Jh(e,t,{col:_,row:e.columns[_].tiles.length})}const a=[...B0(e),i],c=new Map(e.columns.flatMap(_=>_.tiles.map(S=>[_i(S),S]))),d=Wn(t),m=e.columns.length?e.columns.reduce((_,S)=>_+(Number(S.width)||1),0)/e.columns.length:1,p=Array.from({length:o},(_,S)=>{var y;return{width:((y=e.columns[S])==null?void 0:y.width)||m,tiles:[]}});return a.forEach((_,S)=>{const y=Wn(_);if(!y)return;const k=c.get(_)||(_===i?d:{})||{},w={session:y.session,height:k.height||1,fontSize:k.fontSize||lo};y.node&&(w.node=y.node),k.ownerId&&(w.ownerId=k.ownerId),k.unavailable===!0&&(w.unavailable=!0),p[S%o].tiles.push(w)}),{columns:p.filter(_=>_.tiles.length)}}function Ya(e,t){const i=_i(t),s=ts(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>_i(a)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function O0(e,t,i){const s=_i(t);if(!Qi(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>_i(a)===s);return Jh(Ya(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function z0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=ts(e);for(const o of s.columns)for(const a of o.tiles){const c=t.get(_i(a));if(!c)continue;const d=Wn(c);d&&(a.session=d.session,d.node?a.node=d.node:delete a.node,d.ownerId&&(a.ownerId=d.ownerId),i=!0)}return i?ur(s):e}function F0(e,t,i){const s=ts(e);return s.columns[t]&&(s.columns[t].width=Math.max(Va,Number(i)||1)),s}function H0(e,t,i,s){const o=ts(e),a=o.columns[t]&&o.columns[t].tiles[i];return a&&(a.height=Math.max(Va,Number(s)||1)),o}function $0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const a=ts(e),c=a.columns[t].tiles[i],d=Number(c.fontSize)||lo;return c.fontSize=Math.max(t_,Math.min(i_,d+(Number(s)||0))),a}function W0(e,t,i,s){const o=e.columns[t];if(!o||!o.tiles[i])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:i};case"bottom":return{col:t,row:i+1};default:return null}}function xm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function ur(e){if(!e||!Array.isArray(e.columns))return Yr();const t=e.columns.map(s=>({width:Math.max(Va,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&qu(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Jr.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(Va,Number(o.height)||1),fontSize:I0(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(_i(o))&&i.add(_i(o))&&i.size<=Qh);return{columns:t.filter(s=>s.tiles.length>0)}}function U0({onPick:e,token:t,onSettings:i}){const[s,o]=Si(),a=Yh(t),[c,d]=P.useState(null),[m,p]=P.useState(null),[_,S]=P.useState(""),[y,k]=P.useState(""),[w,x]=P.useState({bind:"127.0.0.1",port:""}),[b,C]=P.useState(""),[M,L]=P.useState([]),[T,J]=P.useState(null),[H,F]=P.useState(null),{pins:G,orders:W,togglePin:V,viewFor:X,updateView:A,canMoveRoster:N,moveRoster:R,stepRoster:O}=qv(),{groupsFor:D,renameNode:z,moveNode:B,stepNode:te,nodeKey:q}=Xv(),j=D(a);async function $(){try{const me=await(await zt("/api/sessions",t)).json();me.error?(p(me.error),d([])):(p(null),d(me.sessions||[]))}catch(K){p(String(K)),d([])}try{const K=await pr(t);L(K.available?K.cells||[]:[])}catch{L([])}}P.useEffect(()=>{$(),zt("/api/config",t).then(me=>me.json()).then(me=>{k(me.version||""),x({bind:me.bind||"127.0.0.1",port:me.port||""}),C(Jr.test(String(me.instanceId||""))?me.instanceId:"")}).catch(()=>{});const K=setInterval($,4e3);return()=>clearInterval(K)},[]);async function re(){if(!w.port)return;const K=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(K)}catch{}}async function le(K){if(!T)return;const{cell:me}=T,be=Array.isArray(T.route)?T.route:[];K.action==="up"?await $h(t,{cell:me,boot:!!K.boot,...K.engine?{engine:K.engine}:{},...K.model!==void 0?{model:K.model}:{},...K.permissionPolicy?{permissionPolicy:K.permissionPolicy}:{}},be):await $a(t,{cell:me,boot:!!K.boot},be),$()}async function se(K,me=[]){try{await Uh(t,K,me)}catch{return}$()}async function pe(K,me,be=[]){try{await Tv(t,K,me,be)}catch{return}$()}async function ye(K){if(!(!(K!=null&&K.direct)||H)){F(K.name);try{await qh(t,K.name,K.tunnelStatus==="up"?"down":"up")}catch{}F(null)}}function ce(K){const me=window.prompt(`${v("rename-node-prompt")}
|
|
41
|
+
${v("rename-node-reset")}`,K.label||K.name);me!==null&&(z(K,me)||window.alert(v("rename-node-invalid")))}const Ce=P.useMemo(()=>new Map((c||[]).map(K=>[K.name,K])),[c]),Oe=P.useMemo(()=>new Set(M.map(K=>K.tmuxSession)),[M]),Ze=P.useMemo(()=>(c||[]).filter(K=>!Oe.has(K.name)),[c,Oe]),Ve=P.useMemo(()=>Zv(M,Ze,Ce),[M,Ze,Ce]),Ae=X("local"),ot=P.useMemo(()=>cr(Ve,G,Ae.filter,Hn(W,"local")).filter(K=>mm(K,_)),[Ve,G,Ae.filter,_,W]),Et=j.reduce((K,me)=>K+(me.cells||[]).length+(me.unmanaged||[]).filter(be=>!be.technical).length,0),ie=cr(Ve,G,"all",Hn(W,"local")).length+Et,ae=c?c.length:0,ze=(c||[]).filter(K=>K.attached).length,Q=w.port?`${w.bind}:${w.port}`:w.bind;function ue(K,me=null,be=Ve){var fe,Be;const Pe=Array.isArray(me==null?void 0:me.route)?me.route:[],he=Pe.join("/"),Ee=he||"local",xe=Pe.length?me==null?void 0:me.instanceId:b,$e=je=>e({session:je,...he?{node:he}:{},...Jr.test(String(xe||""))?{ownerId:xe}:{}}),Je=N;if(K.type==="cell"){const je=K.value,oe=Pe.length?((me==null?void 0:me.sessions)||[]).find(ut=>ut.name===je.tmuxSession):Ce.get(je.tmuxSession),ke=je.degraded?v("cell-degraded"):K.working?K.subtitle:je.tmux?v("cell-idle"):v("cell-off"),Ke=Pe.length===0||((me==null?void 0:me.capabilities)||[]).includes(je.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":K.key,"data-position":Ee,children:[h.jsx(zn,{position:Ee,itemKey:K.key,label:je.cell,canMove:Je,onMove:(ut,Qt)=>R(Ee,ut,Qt,be),onStep:ut=>O(Ee,K.key,ut,be)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>je.tmux&&$e(je.tmuxSession),title:ke,"aria-label":`${je.cell}, ${ke}`,children:[h.jsx("span",{className:`dot ${je.degraded?"warn":je.tmux?`on${K.working?" working":""}`:""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:je.cell}),h.jsx("small",{title:K.subtitle,children:K.subtitle})]})]}),K.activity?h.jsx("span",{className:"nc-rel",children:Qr(K.activity)}):null,K.fresh&&((fe=oe==null?void 0:oe.outbox)==null?void 0:fe.count)>0&&h.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:oe.outbox.count}),h.jsx("button",{className:`nc-act pin${G.includes(K.key)?" on":""}`,"aria-label":`${v("pin")} ${je.cell}`,title:v("pin"),onClick:()=>V(K.key),children:G.includes(K.key)?"★":"☆"}),Ke&&h.jsx("button",{className:`nc-act power${je.tmux?" on":""}${je.degraded?" warn":""}`,onClick:()=>J(Pe.length?{...je,route:Pe,availableEngines:(me==null?void 0:me.engines)||[]}:je),title:je.active?v("power-off"):v("power-on"),"aria-label":`${je.active?v("power-off"):v("power-on")} ${je.cell}`,children:h.jsx(tt,{name:"power",size:16})})]},K.key)}const De=K.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":K.key,"data-position":Ee,children:[h.jsx(zn,{position:Ee,itemKey:K.key,label:De.name,canMove:Je,onMove:(je,oe)=>R(Ee,je,oe,be),onStep:je=>O(Ee,K.key,je,be)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>$e(De.name),children:[h.jsx("span",{className:De.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:De.name}),h.jsx("small",{children:De.preview?De.preview:De.cmd?De.cmd:v("windows").replace("{n}",String(De.windows||0))})]})]}),K.activity?h.jsx("span",{className:"nc-rel",children:Qr(K.activity)}):null,K.fresh&&((Be=De.outbox)==null?void 0:Be.count)>0&&h.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:De.outbox.count}),h.jsx("button",{className:`nc-act pin${G.includes(K.key)?" on":""}`,"aria-label":`${v("pin")} ${De.name}`,title:v("pin"),onClick:()=>V(K.key),children:G.includes(K.key)?"★":"☆"}),h.jsx("button",{className:`nc-act technical${De.technical?" on":""}`,title:De.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${De.technical?v("mark-normal"):v("mark-technical")} ${De.name}`,onClick:()=>pe(De.name,!De.technical,Pe),children:"T"}),h.jsx("button",{className:"nc-menu",title:v("terminate"),"aria-label":`${v("terminate")} ${De.name}`,onClick:()=>{window.confirm(v("terminate-confirm").replace("{name}",De.name))&&se(De.name,Pe)},children:"⋯"})]},K.key)}return h.jsxs("div",{className:"nc-home",children:[h.jsxs("header",{className:"nc-home-head",children:[h.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",h.jsx("span",{className:"nc-cursor"})]}),h.jsxs("div",{className:"nc-home-sub",children:[v("fleet-tmux")," · ",ae," ",v("sessions"),ze>0&&` · ${ze} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:v("settings"),children:h.jsx(tt,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:$,title:v("refresh"),children:h.jsx(tt,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[ie>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:v("filter-placeholder"),"aria-label":v("filter-placeholder"),value:_,onChange:K=>S(K.target.value)}),m&&h.jsx("div",{className:"nc-err",children:m}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(Em,{label:v("position-local"),count:ot.length,state:Ae,dotClass:"on",onToggle:()=>A("local",{open:!Ae.open}),onFilter:K=>A("local",{filter:K})}),Ae.open&&ot.map(K=>ue(K,null,Ve)),Ae.open&&c===null&&h.jsx("div",{className:"nc-empty",children:v("loading-fleet")}),Ae.open&&c!==null&&ot.length===0&&!m&&h.jsx("div",{className:"nc-empty",children:_?v("no-match").replace("{q}",_):v("no-sessions-short")})]}),j.map(K=>{const be=Gv(K.health,{passive:"warn"})||(K.status==="up"?"on":K.status==="passive"?"":"warn"),Pe=K.health?Ka(K.health):K.status==="up"?"":Vr(K),Ee=(K.route||[K.name]).join("/"),xe=X(Ee),{rawItems:$e}=e_(K),Je=cr($e,G,xe.filter,Hn(W,Ee)).filter(Be=>mm(Be,_)),De=K.direct&&K.health&&K.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${K.tunnelStatus==="up"?" on":""}`,disabled:H===K.name,title:K.tunnelStatus==="up"?v("power-off"):v("power-on"),"aria-label":`${K.tunnelStatus==="up"?v("power-off"):v("power-on")} ${K.label||K.name}`,onClick:()=>ye(K),children:h.jsx(tt,{name:"power",size:15})}):null,fe=h.jsxs("span",{className:"nc-node-actions",children:[h.jsx(zn,{scope:"node",position:"nodes",itemKey:q(K),label:K.label||K.name,onMove:(Be,je)=>B(Be,je,a),onStep:Be=>te(q(K),Be,a)}),h.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${K.label||K.name}`,onClick:()=>ce(K),children:"✎"}),De]});return h.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":Ee,"data-node-order-key":q(K),children:[h.jsx(Em,{label:K.label||K.name,count:Je.length,state:xe,dotClass:be,dotTitle:Pe,detail:K.status==="up"?"":K.health&&Ka(K.health)||Vr(K),onToggle:()=>A(Ee,{open:!xe.open}),onFilter:Be=>A(Ee,{filter:Be}),onRename:()=>ce(K),action:fe}),K.status==="up"&&xe.open&&Je.map(Be=>ue(Be,K,$e)),K.status==="up"&&xe.open&&Je.length===0&&h.jsx("div",{className:"nc-empty",children:_?v("no-match").replace("{q}",_):v("no-sessions-short")})]},`nodo-${Ee}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:re,title:v("copy-url"),children:[h.jsxs("span",{className:"nc-home-meta",children:[y&&h.jsxs("span",{className:"nc-home-version",children:["v",y]}),h.jsxs("span",{className:"nc-home-endpoint",children:[Q," · ",v("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:K=>K.stopPropagation(),children:Kv.map((K,me)=>h.jsxs("span",{children:[me>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===K?" on":""}`,onClick:()=>o(K),title:K,children:K.toUpperCase()})]},K))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:v("fleet-new-cell"),"aria-label":v("fleet-new-cell"),children:"+"}),T&&h.jsx(Wa,{cell:T,token:t,route:Array.isArray(T.route)?T.route:[],onConfirm:le,onClose:()=>J(null)})]})}function Em({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:a="",onToggle:c,onFilter:d,onRename:m=null,action:p=null}){return h.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:m?_=>{_.preventDefault(),m()}:void 0,children:[h.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":i.open,"aria-label":`${e} · ${v("node-sessions").replace("{n}",String(t))}`,children:[h.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.open?"⌄":"›"}),h.jsx("span",{className:`dot ${s}`,title:o}),h.jsxs("span",{className:"nc-mobile-position-copy",children:[h.jsx("b",{children:e}),h.jsx("small",{children:a||v("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${v("filter-placeholder")}`,title:v(`view-${i.filter}`),onChange:_=>d(_.target.value),children:[h.jsx("option",{value:"all",children:v("view-all")}),h.jsx("option",{value:"pinned",children:v("view-pinned")}),h.jsx("option",{value:"active",children:v("view-active")}),h.jsx("option",{value:"off",children:v("view-off")}),h.jsx("option",{value:"technical",children:v("view-technical")})]}),p]})}/**
|
|
42
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
43
|
+
* @license MIT
|
|
44
|
+
*
|
|
45
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
46
|
+
* @license MIT
|
|
47
|
+
*
|
|
48
|
+
* Originally forked from (with the author's permission):
|
|
49
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
50
|
+
* http://bellard.org/jslinux/
|
|
51
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
52
|
+
*/var r_=Object.defineProperty,K0=Object.getOwnPropertyDescriptor,q0=(e,t)=>{for(var i in t)r_(e,i,{get:t[i],enumerable:!0})},yt=(e,t,i,s)=>{for(var o=s>1?void 0:s?K0(t,i):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(o=(s?c(t,i,o):c(o))||o);return s&&o&&r_(t,i,o),o},Ne=(e,t)=>(i,s)=>t(i,s,e),Nm="Terminal input",Vu={get:()=>Nm,set:e=>Nm=e},Rm="Too much output to announce, navigate to rows manually to read",Yu={get:()=>Rm,set:e=>Rm=e};function V0(e){return e.replace(/\r?\n/g,"\r")}function Y0(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function X0(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function G0(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");s_(o,t,i,s)}}function s_(e,t,i,s){e=V0(e),e=Y0(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function o_(e,t,i){let s=i.getBoundingClientRect(),o=e.clientX-s.left-10,a=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function Pm(e,t,i,s,o){o_(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function On(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function nl(e,t=0,i=e.length){let s="";for(let o=t;o<i;++o){let a=e[o];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var Q0=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o=0;if(this._interim){let a=e.charCodeAt(o++);56320<=a&&a<=57343?t[s++]=(this._interim-55296)*1024+a-56320+65536:(t[s++]=this._interim,t[s++]=a),this._interim=0}for(let a=o;a<i;++a){let c=e.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=i)return this._interim=c,s;let d=e.charCodeAt(a);56320<=d&&d<=57343?t[s++]=(c-55296)*1024+d-56320+65536:(t[s++]=c,t[s++]=d);continue}c!==65279&&(t[s++]=c)}return s}},J0=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o,a,c,d,m=0,p=0;if(this.interim[0]){let y=!1,k=this.interim[0];k&=(k&224)===192?31:(k&240)===224?15:7;let w=0,x;for(;(x=this.interim[++w]&63)&&w<4;)k<<=6,k|=x;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=b-w;for(;p<C;){if(p>=i)return 0;if(x=e[p++],(x&192)!==128){p--,y=!0;break}else this.interim[w++]=x,k<<=6,k|=x&63}y||(b===2?k<128?p--:t[s++]=k:b===3?k<2048||k>=55296&&k<=57343||k===65279||(t[s++]=k):k<65536||k>1114111||(t[s++]=k)),this.interim.fill(0)}let _=i-4,S=p;for(;S<i;){for(;S<_&&!((o=e[S])&128)&&!((a=e[S+1])&128)&&!((c=e[S+2])&128)&&!((d=e[S+3])&128);)t[s++]=o,t[s++]=a,t[s++]=c,t[s++]=d,S+=4;if(o=e[S++],o<128)t[s++]=o;else if((o&224)===192){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(m=(o&31)<<6|a&63,m<128){S--;continue}t[s++]=m}else if((o&240)===224){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,s;if(c=e[S++],(c&192)!==128){S--;continue}if(m=(o&15)<<12|(a&63)<<6|c&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[s++]=m}else if((o&248)===240){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,s;if(c=e[S++],(c&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=c,s;if(d=e[S++],(d&192)!==128){S--;continue}if(m=(o&7)<<18|(a&63)<<12|(c&63)<<6|d&63,m<65536||m>1114111)continue;t[s++]=m}}return s}},a_="",Fn=" ",co=class l_{constructor(){this.fg=0,this.bg=0,this.extended=new Xa}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new l_;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Xa=class c_{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new c_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Di=class u_ extends co{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Xa,this.combinedData=""}static fromCharData(t){let i=new u_;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?On(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Dm="di$target",Xu="di$dependencies",tu=new Map;function Z0(e){return e[Xu]||[]}function Ft(e){if(tu.has(e))return tu.get(e);let t=function(i,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");eb(t,i,o)};return t._id=e,tu.set(e,t),t}function eb(e,t,i){t[Dm]===t?t[Xu].push({id:e,index:i}):(t[Xu]=[{id:e,index:i}],t[Dm]=t)}var ti=Ft("BufferService"),h_=Ft("CoreMouseService"),mr=Ft("CoreService"),tb=Ft("CharsetService"),Zh=Ft("InstantiationService"),d_=Ft("LogService"),ii=Ft("OptionsService"),f_=Ft("OscLinkService"),ib=Ft("UnicodeService"),uo=Ft("DecorationService"),Gu=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var _;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new Di,c=i.getTrimmedLength(),d=-1,m=-1,p=!1;for(let S=0;S<c;S++)if(!(m===-1&&!i.hasContent(S))){if(i.loadCell(S,a),a.hasExtendedAttrs()&&a.extended.urlId)if(m===-1){m=S,d=a.extended.urlId;continue}else p=a.extended.urlId!==d;else m!==-1&&(p=!0);if(p||m!==-1&&S===c-1){let y=(_=this._oscLinkService.getLinkData(d))==null?void 0:_.uri;if(y){let k={start:{x:m+1,y:e},end:{x:S+(!p&&S===c-1?1:0),y:e}},w=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let x=new URL(y);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:y,range:k,activate:(x,b)=>o?o.activate(x,b,k):nb(x,b),hover:(x,b)=>{var C;return(C=o==null?void 0:o.hover)==null?void 0:C.call(o,x,b,k)},leave:(x,b)=>{var C;return(C=o==null?void 0:o.leave)==null?void 0:C.call(o,x,b,k)}})}p=!1,a.hasExtendedAttrs()&&a.extended.urlId?(m=S,d=a.extended.urlId):(m=-1,d=-1)}}t(s)}};Gu=yt([Ne(0,ti),Ne(1,ii),Ne(2,f_)],Gu);function nb(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
53
|
+
|
|
54
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var rl=Ft("CharSizeService"),fn=Ft("CoreBrowserService"),ed=Ft("MouseService"),pn=Ft("RenderService"),rb=Ft("SelectionService"),p_=Ft("CharacterJoinerService"),is=Ft("ThemeService"),m_=Ft("LinkProviderService"),sb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Mm.isErrorNoTelemetry(e)?new Mm(e.message+`
|
|
55
|
+
|
|
56
|
+
`+e.stack):new Error(e.message+`
|
|
57
|
+
|
|
58
|
+
`+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)}},ob=new sb;function Ia(e){ab(e)||ob.onUnexpectedError(e)}var Qu="Canceled";function ab(e){return e instanceof lb?!0:e instanceof Error&&e.name===Qu&&e.message===Qu}var lb=class extends Error{constructor(){super(Qu),this.name=this.message}};function cb(e){return new Error(`Illegal argument: ${e}`)}var Mm=class Ju extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ju)return t;let i=new Ju;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Zu=class g_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,g_.prototype)}};function gi(e,t=0){return e[e.length-(1+t)]}var ub;(e=>{function t(a){return a<0}e.isLessThan=t;function i(a){return a<=0}e.isLessThanOrEqual=i;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(ub||(ub={}));function hb(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var v_;(e=>{function t(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(T){yield T}e.single=o;function a(T){return t(T)?T:o(T)}e.wrap=a;function c(T){return T||i}e.from=c;function*d(T){for(let J=T.length-1;J>=0;J--)yield T[J]}e.reverse=d;function m(T){return!T||T[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(T){return T[Symbol.iterator]().next().value}e.first=p;function _(T,J){let H=0;for(let F of T)if(J(F,H++))return!0;return!1}e.some=_;function S(T,J){for(let H of T)if(J(H))return H}e.find=S;function*y(T,J){for(let H of T)J(H)&&(yield H)}e.filter=y;function*k(T,J){let H=0;for(let F of T)yield J(F,H++)}e.map=k;function*w(T,J){let H=0;for(let F of T)yield*J(F,H++)}e.flatMap=w;function*x(...T){for(let J of T)yield*J}e.concat=x;function b(T,J,H){let F=H;for(let G of T)F=J(F,G);return F}e.reduce=b;function*C(T,J,H=T.length){for(J<0&&(J+=T.length),H<0?H+=T.length:H>T.length&&(H=T.length);J<H;J++)yield T[J]}e.slice=C;function M(T,J=Number.POSITIVE_INFINITY){let H=[];if(J===0)return[H,T];let F=T[Symbol.iterator]();for(let G=0;G<J;G++){let W=F.next();if(W.done)return[H,e.empty()];H.push(W.value)}return[H,{[Symbol.iterator](){return F}}]}e.consume=M;async function L(T){let J=[];for await(let H of T)J.push(H);return Promise.resolve(J)}e.asyncToArray=L})(v_||(v_={}));function dr(e){if(v_.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function db(...e){return dt(()=>dr(e))}function dt(e){return{dispose:hb(()=>{e()})}}var __=class y_{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{dr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?y_.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};__.DISABLE_DISPOSED_WARNING=!1;var $n=__,Ge=class{constructor(){this._store=new $n,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)}};Ge.None=Object.freeze({dispose(){}});var Zr=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}},dn=typeof window=="object"?window:globalThis,eh=class th{constructor(t){this.element=t,this.next=th.Undefined,this.prev=th.Undefined}};eh.Undefined=new eh(void 0);var mt=eh,Lm=class{constructor(){this._first=mt.Undefined,this._last=mt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mt.Undefined}clear(){let e=this._first;for(;e!==mt.Undefined;){let t=e.next;e.prev=mt.Undefined,e.next=mt.Undefined,e=t}this._first=mt.Undefined,this._last=mt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new mt(e);if(this._first===mt.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==mt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mt.Undefined&&e.next!==mt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mt.Undefined&&e.next===mt.Undefined?(this._first=mt.Undefined,this._last=mt.Undefined):e.next===mt.Undefined?(this._last=this._last.prev,this._last.next=mt.Undefined):e.prev===mt.Undefined&&(this._first=this._first.next,this._first.prev=mt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==mt.Undefined;)yield e.element,e=e.next}},fb=globalThis.performance&&typeof globalThis.performance.now=="function",pb=class S_{static create(t){return new S_(t)}constructor(t){this._now=fb&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ut;(e=>{e.None=()=>Ge.None;function t(A,N){return S(A,()=>{},0,void 0,!0,void 0,N)}e.defer=t;function i(A){return(N,R=null,O)=>{let D=!1,z;return z=A(B=>{if(!D)return z?z.dispose():D=!0,N.call(R,B)},null,O),D&&z.dispose(),z}}e.once=i;function s(A,N,R){return p((O,D=null,z)=>A(B=>O.call(D,N(B)),null,z),R)}e.map=s;function o(A,N,R){return p((O,D=null,z)=>A(B=>{N(B),O.call(D,B)},null,z),R)}e.forEach=o;function a(A,N,R){return p((O,D=null,z)=>A(B=>N(B)&&O.call(D,B),null,z),R)}e.filter=a;function c(A){return A}e.signal=c;function d(...A){return(N,R=null,O)=>{let D=db(...A.map(z=>z(B=>N.call(R,B))));return _(D,O)}}e.any=d;function m(A,N,R,O){let D=R;return s(A,z=>(D=N(D,z),D),O)}e.reduce=m;function p(A,N){let R,O={onWillAddFirstListener(){R=A(D.fire,D)},onDidRemoveLastListener(){R==null||R.dispose()}},D=new we(O);return N==null||N.add(D),D.event}function _(A,N){return N instanceof Array?N.push(A):N&&N.add(A),A}function S(A,N,R=100,O=!1,D=!1,z,B){let te,q,j,$=0,re,le={leakWarningThreshold:z,onWillAddFirstListener(){te=A(pe=>{$++,q=N(q,pe),O&&!j&&(se.fire(q),q=void 0),re=()=>{let ye=q;q=void 0,j=void 0,(!O||$>1)&&se.fire(ye),$=0},typeof R=="number"?(clearTimeout(j),j=setTimeout(re,R)):j===void 0&&(j=0,queueMicrotask(re))})},onWillRemoveListener(){D&&$>0&&(re==null||re())},onDidRemoveLastListener(){re=void 0,te.dispose()}},se=new we(le);return B==null||B.add(se),se.event}e.debounce=S;function y(A,N=0,R){return e.debounce(A,(O,D)=>O?(O.push(D),O):[D],N,void 0,!0,void 0,R)}e.accumulate=y;function k(A,N=(O,D)=>O===D,R){let O=!0,D;return a(A,z=>{let B=O||!N(z,D);return O=!1,D=z,B},R)}e.latch=k;function w(A,N,R){return[e.filter(A,N,R),e.filter(A,O=>!N(O),R)]}e.split=w;function x(A,N=!1,R=[],O){let D=R.slice(),z=A(q=>{D?D.push(q):te.fire(q)});O&&O.add(z);let B=()=>{D==null||D.forEach(q=>te.fire(q)),D=null},te=new we({onWillAddFirstListener(){z||(z=A(q=>te.fire(q)),O&&O.add(z))},onDidAddFirstListener(){D&&(N?setTimeout(B):B())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return O&&O.add(te),te.event}e.buffer=x;function b(A,N){return(R,O,D)=>{let z=N(new M);return A(function(B){let te=z.evaluate(B);te!==C&&R.call(O,te)},void 0,D)}}e.chain=b;let C=Symbol("HaltChainable");class M{constructor(){this.steps=[]}map(N){return this.steps.push(N),this}forEach(N){return this.steps.push(R=>(N(R),R)),this}filter(N){return this.steps.push(R=>N(R)?R:C),this}reduce(N,R){let O=R;return this.steps.push(D=>(O=N(O,D),O)),this}latch(N=(R,O)=>R===O){let R=!0,O;return this.steps.push(D=>{let z=R||!N(D,O);return R=!1,O=D,z?D:C}),this}evaluate(N){for(let R of this.steps)if(N=R(N),N===C)break;return N}}function L(A,N,R=O=>O){let O=(...te)=>B.fire(R(...te)),D=()=>A.on(N,O),z=()=>A.removeListener(N,O),B=new we({onWillAddFirstListener:D,onDidRemoveLastListener:z});return B.event}e.fromNodeEventEmitter=L;function T(A,N,R=O=>O){let O=(...te)=>B.fire(R(...te)),D=()=>A.addEventListener(N,O),z=()=>A.removeEventListener(N,O),B=new we({onWillAddFirstListener:D,onDidRemoveLastListener:z});return B.event}e.fromDOMEventEmitter=T;function J(A){return new Promise(N=>i(A)(N))}e.toPromise=J;function H(A){let N=new we;return A.then(R=>{N.fire(R)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=H;function F(A,N){return A(R=>N.fire(R))}e.forward=F;function G(A,N,R){return N(R),A(O=>N(O))}e.runAndSubscribe=G;class W{constructor(N,R){this._observable=N,this._counter=0,this._hasChanged=!1;let O={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new we(O),R&&R.add(this.emitter)}beginUpdate(N){this._counter++}handlePossibleChange(N){}handleChange(N,R){this._hasChanged=!0}endUpdate(N){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function V(A,N){return new W(A,N).emitter.event}e.fromObservable=V;function X(A){return(N,R,O)=>{let D=0,z=!1,B={beginUpdate(){D++},endUpdate(){D--,D===0&&(A.reportChanges(),z&&(z=!1,N.call(R)))},handlePossibleChange(){},handleChange(){z=!0}};A.addObserver(B),A.reportChanges();let te={dispose(){A.removeObserver(B)}};return O instanceof $n?O.add(te):Array.isArray(O)&&O.push(te),te}}e.fromObservableLight=X})(Ut||(Ut={}));var ih=class nh{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${nh._idPool++}`,nh.all.add(this)}start(t){this._stopWatch=new pb,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}}};ih.all=new Set,ih._idPool=0;var mb=ih,gb=-1,w_=class b_{constructor(t,i,s=(b_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(a);let m=new yb(d,a);this._errorHandler(m)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};w_._idPool=1;var vb=w_,_b=class k_{constructor(t){this.value=t}static create(){let t=new Error;return new k_(t.stack??"")}print(){console.warn(this.value.split(`
|
|
59
|
+
`).slice(2).join(`
|
|
60
|
+
`))}},yb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Sb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},wb=0,iu=class{constructor(e){this.value=e,this.id=wb++}},bb=2,kb,we=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new vb((e==null?void 0:e.onListenerError)??Ia,((i=this._options)==null?void 0:i.leakWarningThreshold)??gb):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new mb(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var c,d,m,p,_;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 y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],k=new Sb(`${S}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Ia)(k),Ge.None}if(this._disposed)return Ge.None;t&&(e=e.bind(t));let s=new iu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=_b.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof iu?(this._deliveryQueue??(this._deliveryQueue=new Cb),this._listeners=[this._listeners,s]):this._listeners.push(s):((m=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||m.call(d,this),this._listeners=s,(_=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||_.call(p,this)),this._size++;let a=dt(()=>{o==null||o(),this._removeListener(s)});return i instanceof $n?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(e){var o,a,c,d;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*bb<=t.length){let m=0;for(let p=0;p<t.length;p++)t[p]?t[m++]=t[p]:s&&(this._deliveryQueue.end--,m<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=m}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Ia;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof iu)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},Cb=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},rh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};rh.INSTANCE=new rh;var td=rh;function xb(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}td.INSTANCE.onDidChangeZoomLevel;function Eb(e){return td.INSTANCE.getZoomFactor(e)}td.INSTANCE.onDidChangeFullscreen;var ns=typeof navigator=="object"?navigator.userAgent:"",sh=ns.indexOf("Firefox")>=0,Nb=ns.indexOf("AppleWebKit")>=0,id=ns.indexOf("Chrome")>=0,Rb=!id&&ns.indexOf("Safari")>=0;ns.indexOf("Electron/")>=0;ns.indexOf("Android")>=0;var nu=!1;if(typeof dn.matchMedia=="function"){let e=dn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=dn.matchMedia("(display-mode: fullscreen)");nu=e.matches,xb(dn,e,({matches:i})=>{nu&&t.matches||(nu=i)})}var qr="en",oh=!1,ah=!1,Ba=!1,C_=!1,Na,Oa=qr,jm=qr,Pb,zi,hr=globalThis,Wt,Pv;typeof hr.vscode<"u"&&typeof hr.vscode.process<"u"?Wt=hr.vscode.process:typeof process<"u"&&typeof((Pv=process==null?void 0:process.versions)==null?void 0:Pv.node)=="string"&&(Wt=process);var Dv,Db=typeof((Dv=Wt==null?void 0:Wt.versions)==null?void 0:Dv.electron)=="string",Mb=Db&&(Wt==null?void 0:Wt.type)==="renderer",Mv;if(typeof Wt=="object"){oh=Wt.platform==="win32",ah=Wt.platform==="darwin",Ba=Wt.platform==="linux",Ba&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Na=qr,Oa=qr;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Na=t.userLocale,jm=t.osLocale,Oa=t.resolvedLanguage||qr,Pb=(Mv=t.languagePack)==null?void 0:Mv.translationsConfigFile}catch{}C_=!0}else typeof navigator=="object"&&!Mb?(zi=navigator.userAgent,oh=zi.indexOf("Windows")>=0,ah=zi.indexOf("Macintosh")>=0,(zi.indexOf("Macintosh")>=0||zi.indexOf("iPad")>=0||zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ba=zi.indexOf("Linux")>=0,(zi==null?void 0:zi.indexOf("Mobi"))>=0,Oa=globalThis._VSCODE_NLS_LANGUAGE||qr,Na=navigator.language.toLowerCase(),jm=Na):console.error("Unable to resolve platform.");var x_=oh,Ji=ah,Lb=Ba,Tm=C_,en=zi,Tn=Oa,jb;(e=>{function t(){return Tn}e.value=t;function i(){return Tn.length===2?Tn==="en":Tn.length>=3?Tn[0]==="e"&&Tn[1]==="n"&&Tn[2]==="-":!1}e.isDefaultVariant=i;function s(){return Tn==="en"}e.isDefault=s})(jb||(jb={}));var Tb=typeof hr.postMessage=="function"&&!hr.importScripts;(()=>{if(Tb){let e=[];hr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),hr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Ab=!!(en&&en.indexOf("Chrome")>=0);en&&en.indexOf("Firefox")>=0;!Ab&&en&&en.indexOf("Safari")>=0;en&&en.indexOf("Edg/")>=0;en&&en.indexOf("Android")>=0;var $r=typeof navigator=="object"?navigator:{};Tm||document.queryCommandSupported&&document.queryCommandSupported("copy")||$r&&$r.clipboard&&$r.clipboard.writeText,Tm||$r&&$r.clipboard&&$r.clipboard.readText;var nd=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}},ru=new nd,Am=new nd,Im=new nd,Ib=new Array(230),E_;(e=>{function t(d){return ru.keyCodeToStr(d)}e.toString=t;function i(d){return ru.strToKeyCode(d)}e.fromString=i;function s(d){return Am.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return Im.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function a(d){return Am.strToKeyCode(d)||Im.strToKeyCode(d)}e.fromUserSettings=a;function c(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ru.keyCodeToStr(d)}e.toElectronAccelerator=c})(E_||(E_={}));var Bb=class N_{constructor(t,i,s,o,a){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof N_&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Ob([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Ob=class{constructor(e){if(e.length===0)throw cb("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function zb(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return E_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(sh)switch(t){case 59:return 85;case 60:if(Lb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ji)return 57;break}else if(Nb&&(Ji&&t===93||!Ji&&t===92))return 57;return Ib[t]||0}var Fb=Ji?256:2048,Hb=512,$b=1024,Wb=Ji?2048:256,Bm=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=zb(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|=Fb),this.altKey&&(t|=Hb),this.shiftKey&&(t|=$b),this.metaKey&&(t|=Wb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Bb(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Om=new WeakMap;function Ub(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Kb=class{static getSameOriginWindowChain(e){let t=Om.get(e);if(!t){t=[],Om.set(e,t);let i=e,s;do s=Ub(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let c=a.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();i+=d.top,s+=d.left}return{top:i,left:s}}},Ra=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Kb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},zm=class{constructor(e,t=0,i=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(id){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,c=e,d=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*d):this.deltaY=a.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?sh&&!Ji?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Rb&&x_?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*d):this.deltaX=a.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?sh&&!Ji?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},R_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),qb;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Vb?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ut.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:R_})})(qb||(qb={}));var Vb=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?R_:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},rd=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 Zu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Zu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Yb=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Zu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=dt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Xb;(e=>{async function t(s){let o,a=await Promise.all(s.map(c=>c.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return a}e.settled=t;function i(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(c){a(c)}})}e.withAsyncBody=i})(Xb||(Xb={}));var Fm=class Ri{static fromArray(t){return new Ri(i=>{i.emitMany(t)})}static fromPromise(t){return new Ri(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Ri(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Ri(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new we,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ut.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Ri(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return Ri.map(this,t)}static filter(t,i){return new Ri(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return Ri.filter(this,t)}static coalesce(t){return Ri.filter(t,i=>!!i)}coalesce(){return Ri.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Ri.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Fm.EMPTY=Fm.fromArray([]);var{getWindow:Gi,getWindowId:Gb,onDidRegisterWindow:Qb}=(function(){let e=new Map,t={window:dn,disposables:new $n};e.set(dn.vscodeWindowId,t);let i=new we,s=new we,o=new we;function a(c,d){return(typeof c=="number"?e.get(c):void 0)??(d?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Ge.None;let d=new $n,m={window:c,disposables:d.add(new $n)};return e.set(c.vscodeWindowId,m),d.add(dt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),d.add(Ue(c,At.BEFORE_UNLOAD,()=>{o.fire(c)})),i.fire(m),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:a,getWindow(c){var p;let d=c;if((p=d==null?void 0:d.ownerDocument)!=null&&p.defaultView)return d.ownerDocument.defaultView.window;let m=c;return m!=null&&m.view?m.view.window:dn},getDocument(c){return Gi(c).document}}})(),Jb=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ue(e,t,i,s){return new Jb(e,t,i,s)}var Hm=function(e,t,i,s){return Ue(e,t,i,s)},sd,Zb=class extends Yb{constructor(e){super(),this.defaultTarget=e&&Gi(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},$m=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){Ia(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=a=>{i.set(a,!1);let c=e.get(a)??[];for(t.set(a,c),e.set(a,[]),s.set(a,!0);c.length>0;)c.sort($m.sort),c.shift().execute();s.set(a,!1)};sd=(a,c,d=0)=>{let m=Gb(a),p=new $m(c,d),_=e.get(m);return _||(_=[],e.set(m,_)),_.push(p),i.get(m)||(i.set(m,!0),a.requestAnimationFrame(()=>o(m))),p}})();function e1(e){let t=e.getBoundingClientRect(),i=Gi(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var At={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},t1=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let i=ci(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=ci(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=ci(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=ci(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=ci(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=ci(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=ci(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=ci(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=ci(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=ci(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=ci(t);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let i=ci(t);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let i=ci(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=ci(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function ci(e){return typeof e=="number"?`${e}px`:e}function no(e){return new t1(e)}var P_=class{constructor(){this._hooks=new $n,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(dt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Gi(e)}this._hooks.add(Ue(a,At.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ue(a,At.POINTER_UP,c=>this.stopMonitoring(!0)))}};function i1(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,c)}),this[a]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Js=class Gt extends Ge{constructor(){super(),this.dispatched=!1,this.targets=new Lm,this.ignoreTargets=new Lm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ut.runAndSubscribe(Qb,({window:t,disposables:i})=>{i.add(Ue(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ue(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ue(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:dn,disposables:this._store}))}static addTarget(t){if(!Gt.isTouchDevice())return Ge.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let i=Gt.INSTANCE.targets.push(t);return dt(i)}static ignoreTarget(t){if(!Gt.isTouchDevice())return Ge.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let i=Gt.INSTANCE.ignoreTargets.push(t);return dt(i)}static isTouchDevice(){return"ontouchstart"in dn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:i,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[i],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let c=this.newGestureEvent(Yi.Start,a.target);c.pageX=a.pageX,c.pageY=a.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,c=i.changedTouches.length;a<c;a++){let d=i.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let m=this.activeTouches[d.identifier],p=Date.now()-m.initialTimeStamp;if(p<Gt.HOLD_DELAY&&Math.abs(m.initialPageX-gi(m.rollingPageX))<30&&Math.abs(m.initialPageY-gi(m.rollingPageY))<30){let _=this.newGestureEvent(Yi.Tap,m.initialTarget);_.pageX=gi(m.rollingPageX),_.pageY=gi(m.rollingPageY),this.dispatchEvent(_)}else if(p>=Gt.HOLD_DELAY&&Math.abs(m.initialPageX-gi(m.rollingPageX))<30&&Math.abs(m.initialPageY-gi(m.rollingPageY))<30){let _=this.newGestureEvent(Yi.Contextmenu,m.initialTarget);_.pageX=gi(m.rollingPageX),_.pageY=gi(m.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=gi(m.rollingPageX),S=gi(m.rollingPageY),y=gi(m.rollingTimestamps)-m.rollingTimestamps[0],k=_-m.rollingPageX[0],w=S-m.rollingPageY[0],x=[...this.targets].filter(b=>m.initialTarget instanceof Node&&b.contains(m.initialTarget));this.inertia(t,x,s,Math.abs(k)/y,k>0?1:-1,_,Math.abs(w)/y,w>0?1:-1,S)}this.dispatchEvent(this.newGestureEvent(Yi.End,m.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Yi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Gt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,a,c,d,m,p){this.handle=sd(t,()=>{let _=Date.now(),S=_-s,y=0,k=0,w=!0;o+=Gt.SCROLL_FRICTION*S,d+=Gt.SCROLL_FRICTION*S,o>0&&(w=!1,y=a*o*S),d>0&&(w=!1,k=m*d*S);let x=this.newGestureEvent(Yi.Change);x.translationX=y,x.translationY=k,i.forEach(b=>b.dispatchEvent(x)),w||this.inertia(t,i,_,o,a,c+y,d,m,p+k)})}onTouchMove(t){let i=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],d=this.newGestureEvent(Yi.Change,c.initialTarget);d.translationX=a.pageX-gi(c.rollingPageX),d.translationY=a.pageY-gi(c.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(a.pageX),c.rollingPageY.push(a.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Js.SCROLL_FRICTION=-.005,Js.HOLD_DELAY=700,Js.CLEAR_TAP_COUNT_TIME=400,yt([i1],Js,"isTouchDevice",1);var n1=Js,od=class extends Ge{onclick(e,t){this._register(Ue(e,At.CLICK,i=>t(new Ra(Gi(e),i))))}onmousedown(e,t){this._register(Ue(e,At.MOUSE_DOWN,i=>t(new Ra(Gi(e),i))))}onmouseover(e,t){this._register(Ue(e,At.MOUSE_OVER,i=>t(new Ra(Gi(e),i))))}onmouseleave(e,t){this._register(Ue(e,At.MOUSE_LEAVE,i=>t(new Ra(Gi(e),i))))}onkeydown(e,t){this._register(Ue(e,At.KEY_DOWN,i=>t(new Bm(i))))}onkeyup(e,t){this._register(Ue(e,At.KEY_UP,i=>t(new Bm(i))))}oninput(e,t){this._register(Ue(e,At.INPUT,t))}onblur(e,t){this._register(Ue(e,At.BLUR,t))}onfocus(e,t){this._register(Ue(e,At.FOCUS,t))}onchange(e,t){this._register(Ue(e,At.CHANGE,t))}ignoreGesture(e){return n1.ignoreTarget(e)}},Wm=11,r1=class extends od{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=Wm+"px",this.domNode.style.height=Wm+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new P_),this._register(Hm(this.bgDomNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Hm(this.domNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Zb),this._pointerdownScheduleRepeatTimer=this._register(new rd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Gi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},s1=class lh{constructor(t,i,s,o,a,c,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,a=a|0,c=c|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),a<0&&(a=0),d+a>c&&(d=c-a),d<0&&(d=0),this.width=i,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=c,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new lh(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new lh(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:m}}},o1=class extends Ge{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new s1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new Km(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Km.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Um=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function su(e,t){let i=t-e;return function(s){return e+i*c1(s)}}function a1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Km=class ch{constructor(t,i,s,o){this.from=t,this.to=i,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let o,a;return t<i?(o=t+.75*s,a=i-.75*s):(o=t-.75*s,a=i+.75*s),a1(su(t,o),su(a,i),.33)}return su(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),o=this.scrollTop(i);return new Um(s,o,!1)}return new Um(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return ch.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new ch(t,i,o,s)}};function l1(e){return Math.pow(e,3)}function c1(e){return 1-l1(1-e)}var u1=class extends Ge{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new rd)}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":"")))}},h1=140,D_=class extends od{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 u1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new P_),this._shouldRender=!0,this.domNode=no(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ue(this.domNode.domNode,At.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new r1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=no(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ue(this.slider.domNode,At.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=e1(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),c=Math.abs(a-i);if(x_&&c>h1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},M_=class uh{constructor(t,i,s,o,a,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new uh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,a){let c=Math.max(0,s-t),d=Math.max(0,c-2*i),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*d/o))),_=(d-p)/(o-s),S=a*_;return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:_,computedSliderPosition:Math.round(S)}}_refreshComputedValues(){let t=uh._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},d1=class extends D_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new M_(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},f1=class extends D_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new M_(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},p1=500,qm=50,m1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},hh=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,i+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(id){let i=Gi(t.browserEvent),s=Eb(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,a=new m1(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,o)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),c=Math.abs(i.deltaX),d=Math.abs(i.deltaY),m=Math.max(Math.min(o,c),1),p=Math.max(Math.min(a,d),1),_=Math.max(o,c),S=Math.max(a,d);_%m===0&&S%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};hh.INSTANCE=new hh;var g1=hh,v1=class extends od{constructor(e,t,i){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=y1(t),this._scrollable=i,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new f1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new d1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=no(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=no(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=no(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 rd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=dr(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,Ji&&(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 zm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=dr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new zm(i))};this._mouseWheelToDispose.push(Ue(this._listenOnDomNode,At.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=g1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+a===0?c=a=0:Math.abs(a)>=Math.abs(c)?c=0:a=0),this._options.flipAxes&&([a,c]=[c,a]);let d=!Ji&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),p={};if(a){let _=qm*a,S=m.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(p,S)}if(c){let _=qm*c,S=m.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(p,S)}p=this._scrollable.validateScrollPosition(p),(m.scrollLeft!==p.scrollLeft||m.scrollTop!==p.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(p):this._scrollable.setScrollPositionNow(p),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",o=t?" top":"",a=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),p1)}},_1=class extends v1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function y1(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,Ji&&(t.className+=" mac"),t}var dh=class extends Ge{constructor(e,t,i,s,o,a,c,d){super(),this._bufferService=i,this._optionsService=c,this._renderService=d,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new o1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>sd(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new _1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},m)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ut.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(dt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(dt(()=>this._styleElement.remove())),this._register(Ut.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
61
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};dh=yt([Ne(2,ti),Ne(3,fn),Ne(4,h_),Ne(5,is),Ne(6,ii),Ne(7,pn)],dh);var fh=class extends Ge{constructor(e,t,i,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(a=>this._removeDecoration(a))),this._register(dt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};fh=yt([Ne(1,ti),Ne(2,fn),Ne(3,uo),Ne(4,pn)],fh);var S1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ki={full:0,left:0,center:0,right:0},An={full:0,left:0,center:0,right:0},$s={full:0,left:0,center:0,right:0},Ga=class extends Ge{constructor(e,t,i,s,o,a,c,d){var p;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=c,this._coreBrowserService=d,this._colorZoneStore=new S1,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(dt(()=>{var _;return(_=this._canvas)==null?void 0:_.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);An.full=this._canvas.width,An.left=e,An.center=t,An.right=e,this._refreshDrawHeightConstants(),$s.full=1,$s.left=1,$s.center=1+An.left,$s.right=1+An.left+An.center}_refreshDrawHeightConstants(){Ki.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect($s[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),An[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ga=yt([Ne(2,ti),Ne(3,uo),Ne(4,pn),Ne(5,ii),Ne(6,is),Ne(7,fn)],Ga);var de;(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=`
|
|
62
|
+
`,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=""))(de||(de={}));var za;(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=""))(za||(za={}));var L_;(e=>e.ST=`${de.ESC}\\`)(L_||(L_={}));var ph=class{constructor(e,t,i,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${de.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};ph=yt([Ne(2,ti),Ne(3,ii),Ne(4,mr),Ne(5,pn)],ph);var It=0,Bt=0,Ot=0,_t=0,Vm={css:"#00000000",rgba:0},xt;(e=>{function t(o,a,c,d){return d!==void 0?`#${nr(o)}${nr(a)}${nr(c)}${nr(d)}`:`#${nr(o)}${nr(a)}${nr(c)}`}e.toCss=t;function i(o,a,c,d=255){return(o<<24|a<<16|c<<8|d)>>>0}e.toRgba=i;function s(o,a,c,d){return{css:e.toCss(o,a,c,d),rgba:e.toRgba(o,a,c,d)}}e.toColor=s})(xt||(xt={}));var ct;(e=>{function t(m,p){if(_t=(p.rgba&255)/255,_t===1)return{css:p.css,rgba:p.rgba};let _=p.rgba>>24&255,S=p.rgba>>16&255,y=p.rgba>>8&255,k=m.rgba>>24&255,w=m.rgba>>16&255,x=m.rgba>>8&255;It=k+Math.round((_-k)*_t),Bt=w+Math.round((S-w)*_t),Ot=x+Math.round((y-x)*_t);let b=xt.toCss(It,Bt,Ot),C=xt.toRgba(It,Bt,Ot);return{css:b,rgba:C}}e.blend=t;function i(m){return(m.rgba&255)===255}e.isOpaque=i;function s(m,p,_){let S=Fa.ensureContrastRatio(m.rgba,p.rgba,_);if(S)return xt.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[It,Bt,Ot]=Fa.toChannels(p),{css:xt.toCss(It,Bt,Ot),rgba:p}}e.opaque=o;function a(m,p){return _t=Math.round(p*255),[It,Bt,Ot]=Fa.toChannels(m.rgba),{css:xt.toCss(It,Bt,Ot,_t),rgba:xt.toRgba(It,Bt,Ot,_t)}}e.opacity=a;function c(m,p){return _t=m.rgba&255,a(m,_t*p/255)}e.multiplyOpacity=c;function d(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=d})(ct||(ct={}));var gt;(e=>{let t,i;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return It=parseInt(o.slice(1,2).repeat(2),16),Bt=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),xt.toColor(It,Bt,Ot);case 5:return It=parseInt(o.slice(1,2).repeat(2),16),Bt=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),_t=parseInt(o.slice(4,5).repeat(2),16),xt.toColor(It,Bt,Ot,_t);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let a=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return It=parseInt(a[1]),Bt=parseInt(a[2]),Ot=parseInt(a[3]),_t=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),xt.toColor(It,Bt,Ot,_t);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[It,Bt,Ot,_t]=t.getImageData(0,0,1,1).data,_t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:xt.toRgba(It,Bt,Ot,_t),css:o}}e.toColor=s})(gt||(gt={}));var ei;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,a){let c=s/255,d=o/255,m=a/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),_=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),S=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return p*.2126+_*.7152+S*.0722}e.relativeLuminance2=i})(ei||(ei={}));var Fa;(e=>{function t(c,d){if(_t=(d&255)/255,_t===1)return d;let m=d>>24&255,p=d>>16&255,_=d>>8&255,S=c>>24&255,y=c>>16&255,k=c>>8&255;return It=S+Math.round((m-S)*_t),Bt=y+Math.round((p-y)*_t),Ot=k+Math.round((_-k)*_t),xt.toRgba(It,Bt,Ot)}e.blend=t;function i(c,d,m){let p=ei.relativeLuminance(c>>8),_=ei.relativeLuminance(d>>8);if(un(p,_)<m){if(_<p){let k=s(c,d,m),w=un(p,ei.relativeLuminance(k>>8));if(w<m){let x=o(c,d,m),b=un(p,ei.relativeLuminance(x>>8));return w>b?k:x}return k}let S=o(c,d,m),y=un(p,ei.relativeLuminance(S>>8));if(y<m){let k=s(c,d,m),w=un(p,ei.relativeLuminance(k>>8));return y>w?S:k}return S}}e.ensureContrastRatio=i;function s(c,d,m){let p=c>>24&255,_=c>>16&255,S=c>>8&255,y=d>>24&255,k=d>>16&255,w=d>>8&255,x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));for(;x<m&&(y>0||k>0||w>0);)y-=Math.max(0,Math.ceil(y*.1)),k-=Math.max(0,Math.ceil(k*.1)),w-=Math.max(0,Math.ceil(w*.1)),x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));return(y<<24|k<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(c,d,m){let p=c>>24&255,_=c>>16&255,S=c>>8&255,y=d>>24&255,k=d>>16&255,w=d>>8&255,x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));for(;x<m&&(y<255||k<255||w<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));return(y<<24|k<<16|w<<8|255)>>>0}e.increaseLuminance=o;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=a})(Fa||(Fa={}));function nr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function un(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var w1=class extends co{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Qa=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),o=0,a=0,c=0,d=t.getFg(0),m=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==m){if(p-o>1){let _=this._getJoinedRanges(s,c,a,t,o);for(let S=0;S<_.length;S++)i.push(_[S])}o=p,c=a,d=this._workCell.fg,m=this._workCell.bg}a+=this._workCell.getChars().length||Fn.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(s,c,a,t,o);for(let _=0;_<p.length;_++)i.push(p[_])}return i}_getJoinedRanges(e,t,i,s,o){let a=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let m=this._characterJoiners[d].handler(a);for(let p=0;p<m.length;p++)Qa._mergeRanges(c,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(c,s,o),c}_stringRangesToCellRanges(e,t,i){let s=0,o=!1,a=0,c=e[s];if(c){for(let d=i;d<this._bufferService.cols;d++){let m=t.getWidth(d),p=t.getString(d).length||Fn.length;if(m!==0){if(!o&&c[0]<=a&&(c[0]=d,o=!0),c[1]<=a){if(c[1]=d,c=e[++s],!c)break;c[0]<=a?(c[0]=d,o=!0):o=!1}a+=p}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Qa=yt([Ne(0,ti)],Qa);function b1(e){return 57508<=e&&e<=57558}function k1(e){return 9472<=e&&e<=9631}function C1(e){return b1(e)||k1(e)}function x1(){return{css:{canvas:Pa(),cell:Pa()},device:{canvas:Pa(),cell:Pa(),char:{width:0,height:0,left:0,top:0}}}}function Pa(){return{width:0,height:0}}var mh=class{constructor(e,t,i,s,o,a,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=c,this._workCell=new Di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,a,c,d,m,p,_){let S=[],y=this._characterJoinerService.getJoinedCharacters(t),k=this._themeService.colors,w=e.getNoBgTrimmedLength();i&&w<a+1&&(w=a+1);let x,b=0,C="",M=0,L=0,T=0,J=0,H=!1,F=0,G=!1,W=0,V=0,X=[],A=p!==-1&&_!==-1;for(let N=0;N<w;N++){e.loadCell(N,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let O=!1,D=N>=V,z=N,B=this._workCell;if(y.length>0&&N===y[0][0]&&D){let Ae=y.shift(),ot=this._isCellInSelection(Ae[0],t);for(M=Ae[0]+1;M<Ae[1];M++)D&&(D=ot===this._isCellInSelection(M,t));D&&(D=!i||a<Ae[0]||a>=Ae[1]),D?(O=!0,B=new w1(this._workCell,e.translateToString(!0,Ae[0],Ae[1]),Ae[1]-Ae[0]),z=Ae[1]-1,R=B.getWidth()):V=Ae[1]}let te=this._isCellInSelection(N,t),q=i&&N===a,j=A&&N>=p&&N<=_,$=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Ae=>{$=!0});let re=B.getChars()||Fn;if(re===" "&&(B.isUnderline()||B.isOverline())&&(re=" "),W=R*d-m.get(re,B.isBold(),B.isItalic()),!x)x=this._document.createElement("span");else if(b&&(te&&G||!te&&!G&&B.bg===L)&&(te&&G&&k.selectionForeground||B.fg===T)&&B.extended.ext===J&&j===H&&W===F&&!q&&!O&&!$&&D){B.isInvisible()?C+=Fn:C+=re,b++;continue}else b&&(x.textContent=C),x=this._document.createElement("span"),b=0,C="";if(L=B.bg,T=B.fg,J=B.extended.ext,H=j,F=W,G=te,O&&a>=N&&a<=z&&(a=N),!this._coreService.isCursorHidden&&q&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&X.push("xterm-cursor-blink"),X.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":X.push("xterm-cursor-outline");break;case"block":X.push("xterm-cursor-block");break;case"bar":X.push("xterm-cursor-bar");break;case"underline":X.push("xterm-cursor-underline");break}}if(B.isBold()&&X.push("xterm-bold"),B.isItalic()&&X.push("xterm-italic"),B.isDim()&&X.push("xterm-dim"),B.isInvisible()?C=Fn:C=B.getChars()||Fn,B.isUnderline()&&(X.push(`xterm-underline-${B.extended.underlineStyle}`),C===" "&&(C=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${co.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let Ae=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&Ae<8&&(Ae+=8),x.style.textDecorationColor=k.ansi[Ae].css}B.isOverline()&&(X.push("xterm-overline"),C===" "&&(C=" ")),B.isStrikethrough()&&X.push("xterm-strikethrough"),j&&(x.style.textDecoration="underline");let le=B.getFgColor(),se=B.getFgColorMode(),pe=B.getBgColor(),ye=B.getBgColorMode(),ce=!!B.isInverse();if(ce){let Ae=le;le=pe,pe=Ae;let ot=se;se=ye,ye=ot}let Ce,Oe,Ze=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Ae=>{Ae.options.layer!=="top"&&Ze||(Ae.backgroundColorRGB&&(ye=50331648,pe=Ae.backgroundColorRGB.rgba>>8&16777215,Ce=Ae.backgroundColorRGB),Ae.foregroundColorRGB&&(se=50331648,le=Ae.foregroundColorRGB.rgba>>8&16777215,Oe=Ae.foregroundColorRGB),Ze=Ae.options.layer==="top")}),!Ze&&te&&(Ce=this._coreBrowserService.isFocused?k.selectionBackgroundOpaque:k.selectionInactiveBackgroundOpaque,pe=Ce.rgba>>8&16777215,ye=50331648,Ze=!0,k.selectionForeground&&(se=50331648,le=k.selectionForeground.rgba>>8&16777215,Oe=k.selectionForeground)),Ze&&X.push("xterm-decoration-top");let Ve;switch(ye){case 16777216:case 33554432:Ve=k.ansi[pe],X.push(`xterm-bg-${pe}`);break;case 50331648:Ve=xt.toColor(pe>>16,pe>>8&255,pe&255),this._addStyle(x,`background-color:#${Ym((pe>>>0).toString(16),"0",6)}`);break;case 0:default:ce?(Ve=k.foreground,X.push("xterm-bg-257")):Ve=k.background}switch(Ce||B.isDim()&&(Ce=ct.multiplyOpacity(Ve,.5)),se){case 16777216:case 33554432:B.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(x,Ve,k.ansi[le],B,Ce,void 0)||X.push(`xterm-fg-${le}`);break;case 50331648:let Ae=xt.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(x,Ve,Ae,B,Ce,Oe)||this._addStyle(x,`color:#${Ym(le.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,Ve,k.foreground,B,Ce,Oe)||ce&&X.push("xterm-fg-257")}X.length&&(x.className=X.join(" "),X.length=0),!q&&!O&&!$&&D?b++:x.textContent=C,W!==this.defaultSpacing&&(x.style.letterSpacing=`${W}px`),S.push(x),N=z}return x&&b&&(x.textContent=C),S}_applyMinimumContrast(e,t,i,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||C1(s.getCode()))return!1;let c=this._getContrastCache(s),d;if(!o&&!a&&(d=c.getColor(t.rgba,i.rgba)),d===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=ct.ensureContrastRatio(o||t,a||i,m),c.setColor((o||t).rgba,(a||i).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};mh=yt([Ne(1,p_),Ne(2,ii),Ne(3,fn),Ne(4,mr),Ne(5,uo),Ne(6,is)],mh);function Ym(e,t,i){for(;e.length<i;)e=t+e;return e}var E1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[i,s,o,a],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let o=e;t&&(o+="B"),i&&(o+="I");let a=this._holey.get(o);if(a===void 0){let c=0;t&&(c|=1),i&&(c|=2),a=this._measure(e,c),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},N1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,c=i[1]-o,d=Math.max(a,0),m=Math.min(c,e.rows-1);if(d>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=c,this.viewportCappedStartRow=d,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function R1(){return new N1}var ou="xterm-dom-renderer-owner-",Ni="xterm-rows",Da="xterm-fg-",Xm="xterm-bg-",Ws="xterm-focus",Ma="xterm-selection",P1=1,gh=class extends Ge{constructor(e,t,i,s,o,a,c,d,m,p,_,S,y,k){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=c,this._charSizeService=m,this._optionsService=p,this._bufferService=_,this._coreService=S,this._coreBrowserService=y,this._themeService=k,this._terminalClass=P1++,this._rowElements=[],this._selectionRenderModel=R1(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ni),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ma),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=x1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(mh,document),this._element.classList.add(ou+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(dt(()=>{this._element.classList.remove(ou+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new E1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ni} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ni} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ni} .xterm-dim { color: ${ct.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ni}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ma} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ma} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ma} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Da}${a} { color: ${c.css}; }${this._terminalSelector} .${Da}${a}.xterm-dim { color: ${ct.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Xm}${a} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Da}257 { color: ${ct.opaque(e.background).css}; }${this._terminalSelector} .${Da}257.xterm-dim { color: ${ct.multiplyOpacity(ct.opaque(e.background),.5).css}; }${this._terminalSelector} .${Xm}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ws),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ws),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(i){let m=e[0]>t[0];d.appendChild(this._createSelectionElement(a,m?t[0]:e[0],m?e[0]:t[0],c-a+1))}else{let m=s===a?e[0]:0,p=a===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(a,m,p));let _=c-a-1;if(d.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,_)),a!==c){let S=o===c?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,0,S))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,i,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return a+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${c}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,o=Math.min(i.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+i.ydisp,_=this._rowElements[m],S=i.lines.get(p);if(!_||!S)break;_.replaceChildren(...this._rowFactory.createRow(S,p,p===s,c,d,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${ou}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,o,a){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,m=d.ybase+d.y,p=Math.min(d.x,o-1),_=this._optionsService.rawOptions.cursorBlink,S=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let k=i;k<=s;++k){let w=k+d.ydisp,x=this._rowElements[k],b=d.lines.get(w);if(!x||!b)break;x.replaceChildren(...this._rowFactory.createRow(b,w,w===m,S,y,p,_,this.dimensions.css.cell.width,this._widthCache,a?k===i?e:0:-1,a?(k===s?t:o)-1:-1))}}};gh=yt([Ne(7,Zh),Ne(8,rl),Ne(9,ii),Ne(10,ti),Ne(11,mr),Ne(12,fn),Ne(13,is)],gh);var vh=class extends Ge{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new M1(this._optionsService))}catch{this._measureStrategy=this._register(new D1(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())}};vh=yt([Ne(2,ii)],vh);var j_=class extends Ge{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)}},D1=class extends j_{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},M1=class extends j_{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},L1=class extends Ge{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new j1(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ue(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ue(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},j1=class extends Ge{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zr),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(dt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ue(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},T1=class extends Ge{constructor(){super(),this.linkProviders=[],this._register(dt(()=>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 ad(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),a=parseInt(o.getPropertyValue("padding-left")),c=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-c]}function A1(e,t,i,s,o,a,c,d,m){if(!a)return;let p=ad(e,t,i);if(p)return p[0]=Math.ceil((p[0]+(m?c/2:0))/c),p[1]=Math.ceil(p[1]/d),p[0]=Math.min(Math.max(p[0],1),s+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var _h=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return A1(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=ad(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};_h=yt([Ne(0,pn),Ne(1,rl)],_h);var I1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},T_={};q0(T_,{getSafariVersion:()=>O1,isChromeOS:()=>O_,isFirefox:()=>A_,isIpad:()=>z1,isIphone:()=>F1,isLegacyEdge:()=>B1,isLinux:()=>ld,isMac:()=>Ja,isNode:()=>sl,isSafari:()=>I_,isWindows:()=>B_});var sl=typeof process<"u"&&"title"in process,ho=sl?"node":navigator.userAgent,fo=sl?"node":navigator.platform,A_=ho.includes("Firefox"),B1=ho.includes("Edge"),I_=/^((?!chrome|android).)*safari/i.test(ho);function O1(){if(!I_)return 0;let e=ho.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ja=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(fo),z1=fo==="iPad",F1=fo==="iPhone",B_=["Windows","Win16","Win32","WinCE"].includes(fo),ld=fo.indexOf("Linux")>=0,O_=/\bCrOS\b/.test(ho),z_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),o=e.timeRemaining(),i*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},H1=class extends z_{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},$1=class extends z_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Za=!sl&&"requestIdleCallback"in window?$1:H1,W1=class{constructor(){this._queue=new Za}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},yh=class extends Ge{constructor(e,t,i,s,o,a,c,d,m){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new Zr),this._pausedResizeTask=new W1,this._observerDisposable=this._register(new Zr),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new I1((p,_)=>this._renderRows(p,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new U1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(dt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var p;return(p=this._renderer.value)==null?void 0:p.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(m.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=dt(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};yh=yt([Ne(2,ii),Ne(3,rl),Ne(4,mr),Ne(5,uo),Ne(6,ti),Ne(7,fn),Ne(8,is)],yh);var U1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function K1(e,t,i,s){let o=i.buffer.x,a=i.buffer.y;if(!i.buffer.hasScrollback)return Y1(o,a,e,t,i,s)+ol(a,t,i,s)+X1(o,a,e,t,i,s);let c;if(a===t)return c=o>e?"D":"C",so(Math.abs(o-e),ro(c,s));c=a>t?"D":"C";let d=Math.abs(a-t),m=V1(a>t?e:o,i)+(d-1)*i.cols+1+q1(a>t?o:e);return so(m,ro(c,s))}function q1(e,t){return e-1}function V1(e,t){return t.cols-e}function Y1(e,t,i,s,o,a){return ol(t,s,o,a).length===0?"":so(H_(e,t,e,t-fr(t,o),!1,o).length,ro("D",a))}function ol(e,t,i,s){let o=e-fr(e,i),a=t-fr(t,i),c=Math.abs(o-a)-G1(e,t,i);return so(c,ro(F_(e,t),s))}function X1(e,t,i,s,o,a){let c;ol(t,s,o,a).length>0?c=s-fr(s,o):c=t;let d=s,m=Q1(e,t,i,s,o,a);return so(H_(e,c,i,d,m==="C",o).length,ro(m,a))}function G1(e,t,i){var c;let s=0,o=e-fr(e,i),a=t-fr(t,i);for(let d=0;d<Math.abs(o-a);d++){let m=F_(e,t)==="A"?-1:1;(c=i.buffer.lines.get(o+m*d))!=null&&c.isWrapped&&s++}return s}function fr(e,t){let i=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return i}function Q1(e,t,i,s,o,a){let c;return ol(i,s,o,a).length>0?c=s-fr(s,o):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function F_(e,t){return e>t?"A":"B"}function H_(e,t,i,s,o,a){let c=e,d=t,m="";for(;(c!==i||d!==s)&&d>=0&&d<a.buffer.lines.length;)c+=o?1:-1,o&&c>a.cols-1?(m+=a.buffer.translateBufferLineToString(d,!1,e,c),c=0,e=0,d++):!o&&c<0&&(m+=a.buffer.translateBufferLineToString(d,!1,0,e+1),c=a.cols-1,e=c,d--);return m+a.buffer.translateBufferLineToString(d,!1,e,c)}function ro(e,t){let i=t?"O":"[";return de.ESC+i+e}function so(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var J1=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Gm(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 au=50,Z1=15,ek=50,tk=500,ik=" ",nk=new RegExp(ik,"g"),Sh=class extends Ge{constructor(e,t,i,s,o,a,c,d,m){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=c,this._renderService=d,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new J1(this._bufferService),this._activeSelectionMode=0,this._register(dt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let d=i.translateBufferLineToString(c,!0,o,a);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let c=i.lines.get(a),d=i.translateBufferLineToString(a,!0);c!=null&&c.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let a=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(o=>o.replace(nk," ")).join(B_?`\r
|
|
63
|
+
`:`
|
|
64
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),ld&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let i=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Gm(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ad(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-au),au),t/=au,t/Math.abs(t)+Math.round(t*(Z1-1)))}shouldForceSelection(e){return Ja?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(),ek)}_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&&!(Ja&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<tk&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=K1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let c=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(a,e[0]),m=d,p=e[0]-d,_=0,S=0,y=0,k=0;if(c.charAt(d)===" "){for(;d>0&&c.charAt(d-1)===" ";)d--;for(;m<c.length&&c.charAt(m+1)===" ";)m++}else{let b=e[0],C=e[0];a.getWidth(b)===0&&(_++,b--),a.getWidth(C)===2&&(S++,C++);let M=a.getString(C).length;for(M>1&&(k+=M-1,m+=M-1);b>0&&d>0&&!this._isCharWordSeparator(a.loadCell(b-1,this._workCell));){a.loadCell(b-1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,b--):L>1&&(y+=L-1,d-=L-1),d--,b--}for(;C<a.length&&m+1<c.length&&!this._isCharWordSeparator(a.loadCell(C+1,this._workCell));){a.loadCell(C+1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,C++):L>1&&(k+=L-1,m+=L-1),m++,C++}}m++;let w=d+p-_+y,x=Math.min(this._bufferService.cols,m-d+_+S-y-k);if(!(!t&&c.slice(d,m).trim()==="")){if(i&&w===0&&a.getCodePoint(0)!==32){let b=o.lines.get(e[1]-1);if(b&&a.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let M=this._bufferService.cols-C.start;w-=M,x+=M}}}if(s&&w+x===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let b=o.lines.get(e[1]+1);if(b!=null&&b.isWrapped&&b.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(x+=C.length)}}return{start:w,length:x}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Gm(i,this._bufferService.cols)}};Sh=yt([Ne(3,ti),Ne(4,mr),Ne(5,ed),Ne(6,ii),Ne(7,pn),Ne(8,fn)],Sh);var Qm=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Jm=class{constructor(){this._color=new Qm,this._css=new Qm}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Pt=Object.freeze((()=>{let e=[gt.toColor("#2e3436"),gt.toColor("#cc0000"),gt.toColor("#4e9a06"),gt.toColor("#c4a000"),gt.toColor("#3465a4"),gt.toColor("#75507b"),gt.toColor("#06989a"),gt.toColor("#d3d7cf"),gt.toColor("#555753"),gt.toColor("#ef2929"),gt.toColor("#8ae234"),gt.toColor("#fce94f"),gt.toColor("#729fcf"),gt.toColor("#ad7fa8"),gt.toColor("#34e2e2"),gt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],a=t[i%6];e.push({css:xt.toCss(s,o,a),rgba:xt.toRgba(s,o,a)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:xt.toCss(s,s,s),rgba:xt.toRgba(s,s,s)})}return e})()),sr=gt.toColor("#ffffff"),Zs=gt.toColor("#000000"),Zm=gt.toColor("#ffffff"),eg=Zs,Us={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},rk=sr,wh=class extends Ge{constructor(e){super(),this._optionsService=e,this._contrastCache=new Jm,this._halfContrastCache=new Jm,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:sr,background:Zs,cursor:Zm,cursorAccent:eg,selectionForeground:void 0,selectionBackgroundTransparent:Us,selectionBackgroundOpaque:ct.blend(Zs,Us),selectionInactiveBackgroundTransparent:Us,selectionInactiveBackgroundOpaque:ct.blend(Zs,Us),scrollbarSliderBackground:ct.opacity(sr,.2),scrollbarSliderHoverBackground:ct.opacity(sr,.4),scrollbarSliderActiveBackground:ct.opacity(sr,.5),overviewRulerBorder:sr,ansi:Pt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=rt(e.foreground,sr),t.background=rt(e.background,Zs),t.cursor=ct.blend(t.background,rt(e.cursor,Zm)),t.cursorAccent=ct.blend(t.background,rt(e.cursorAccent,eg)),t.selectionBackgroundTransparent=rt(e.selectionBackground,Us),t.selectionBackgroundOpaque=ct.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=rt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ct.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?rt(e.selectionForeground,Vm):void 0,t.selectionForeground===Vm&&(t.selectionForeground=void 0),ct.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ct.opacity(t.selectionBackgroundTransparent,.3)),ct.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ct.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=rt(e.scrollbarSliderBackground,ct.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=rt(e.scrollbarSliderHoverBackground,ct.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=rt(e.scrollbarSliderActiveBackground,ct.opacity(t.foreground,.5)),t.overviewRulerBorder=rt(e.overviewRulerBorder,rk),t.ansi=Pt.slice(),t.ansi[0]=rt(e.black,Pt[0]),t.ansi[1]=rt(e.red,Pt[1]),t.ansi[2]=rt(e.green,Pt[2]),t.ansi[3]=rt(e.yellow,Pt[3]),t.ansi[4]=rt(e.blue,Pt[4]),t.ansi[5]=rt(e.magenta,Pt[5]),t.ansi[6]=rt(e.cyan,Pt[6]),t.ansi[7]=rt(e.white,Pt[7]),t.ansi[8]=rt(e.brightBlack,Pt[8]),t.ansi[9]=rt(e.brightRed,Pt[9]),t.ansi[10]=rt(e.brightGreen,Pt[10]),t.ansi[11]=rt(e.brightYellow,Pt[11]),t.ansi[12]=rt(e.brightBlue,Pt[12]),t.ansi[13]=rt(e.brightMagenta,Pt[13]),t.ansi[14]=rt(e.brightCyan,Pt[14]),t.ansi[15]=rt(e.brightWhite,Pt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=rt(e.extendedAnsi[s],Pt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};wh=yt([Ne(0,ii)],wh);function rt(e,t){if(e!==void 0)try{return gt.toColor(e)}catch{}return t}var sk=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ok=class{constructor(){this._services=new sk,this._services.set(Zh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=Z0(e).sort((a,c)=>a.index-c.index),s=[];for(let a of i){let c=this._services.get(a.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(c)}let o=i.length>0?i[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},ak={trace:0,debug:1,info:2,warn:3,error:4,off:5},lk="xterm.js: ",bh=class extends Ge{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=ak[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":lk)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};bh=yt([Ne(0,ii)],bh);var tg=class extends Ge{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Xe=3,Ct=Object.freeze(new co),La=0,lu=2,eo=class $_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Xe);let o=i||Di.fromCharData([0,a_,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let i=this._data[t*Xe+0],s=i&2097151;return[this._data[t*Xe+1],i&2097152?this._combined[t]:s?On(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Xe+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Xe+0]=t|2097152|i[2]<<22):this._data[t*Xe+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Xe+0]>>22}hasWidth(t){return this._data[t*Xe+0]&12582912}getFg(t){return this._data[t*Xe+1]}getBg(t){return this._data[t*Xe+2]}hasContent(t){return this._data[t*Xe+0]&4194303}getCodePoint(t){let i=this._data[t*Xe+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Xe+0]&2097152}getString(t){let i=this._data[t*Xe+0];return i&2097152?this._combined[t]:i&2097151?On(i&2097151):""}isProtected(t){return this._data[t*Xe+2]&536870912}loadCell(t,i){return La=t*Xe,i.content=this._data[La+0],i.fg=this._data[La+1],i.bg=this._data[La+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Xe+0]=i.content,this._data[t*Xe+1]=i.fg,this._data[t*Xe+2]=i.bg}setCellFromCodepoint(t,i,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Xe+0]=i|s<<22,this._data[t*Xe+1]=o.fg,this._data[t*Xe+2]=o.bg}addCodepointToCell(t,i,s){let o=this._data[t*Xe+0];o&2097152?this._combined[t]+=On(i):o&2097151?(this._combined[t]=On(o&2097151)+On(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Xe+0]=o}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let o=new Di;for(let a=this.length-t-i-1;a>=0;--a)this.setCell(t+i+a,this.loadCell(t+a,o));for(let a=0;a<i;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let o=new Di;for(let a=0;a<this.length-t-i;++a)this.setCell(t+a,this.loadCell(t+i+a,o));for(let a=this.length-i;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*lu<this._data.buffer.byteLength;let s=t*Xe;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,i)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let c=0;c<o.length;c++){let d=parseInt(o[c],10);d>=t&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let c=0;c<a.length;c++){let d=parseInt(a[c],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*lu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*lu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new $_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Xe+0]&4194303)return t+(this._data[t*Xe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Xe+0]&4194303||this._data[t*Xe+2]&50331648)return t+(this._data[t*Xe+0]>>22);return 0}copyCellsFrom(t,i,s,o,a){let c=t._data;if(a)for(let m=o-1;m>=0;m--){for(let p=0;p<Xe;p++)this._data[(s+m)*Xe+p]=c[(i+m)*Xe+p];c[(i+m)*Xe+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}else for(let m=0;m<o;m++){for(let p=0;p<Xe;p++)this._data[(s+m)*Xe+p]=c[(i+m)*Xe+p];c[(i+m)*Xe+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}let d=Object.keys(t._combined);for(let m=0;m<d.length;m++){let p=parseInt(d[m],10);p>=i&&(this._combined[p-i+s]=t._combined[p])}}translateToString(t,i,s,o){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;i<s;){let c=this._data[i*Xe+0],d=c&2097151,m=c&2097152?this._combined[i]:d?On(d):Fn;if(a+=m,o)for(let p=0;p<m.length;++p)o.push(i);i+=c>>22||1}return o&&o.push(i),a}};function ck(e,t,i,s,o,a){let c=[];for(let d=0;d<e.length-1;d++){let m=d,p=e.get(++m);if(!p.isWrapped)continue;let _=[e.get(d)];for(;m<e.length&&p.isWrapped;)_.push(p),p=e.get(++m);if(!a&&s>=d&&s<m){d+=_.length-1;continue}let S=0,y=oo(_,S,t),k=1,w=0;for(;k<_.length;){let b=oo(_,k,t),C=b-w,M=i-y,L=Math.min(C,M);_[S].copyCellsFrom(_[k],w,y,L,!1),y+=L,y===i&&(S++,y=0),w+=L,w===b&&(k++,w=0),y===0&&S!==0&&_[S-1].getWidth(i-1)===2&&(_[S].copyCellsFrom(_[S-1],i-1,y++,1,!1),_[S-1].setCell(i-1,o))}_[S].replaceCells(y,i,o);let x=0;for(let b=_.length-1;b>0&&(b>S||_[b].getTrimmedLength()===0);b--)x++;x>0&&(c.push(d+_.length-x),c.push(x)),d+=_.length-1}return c}function uk(e,t){let i=[],s=0,o=t[s],a=0;for(let c=0;c<e.length;c++)if(o===c){let d=t[++s];e.onDeleteEmitter.fire({index:c-a,amount:d}),c+=d-1,a+=d,o=t[++s]}else i.push(c);return{layout:i,countRemoved:a}}function hk(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function dk(e,t,i){let s=[],o=e.map((m,p)=>oo(e,p,t)).reduce((m,p)=>m+p),a=0,c=0,d=0;for(;d<o;){if(o-d<i){s.push(o-d);break}a+=i;let m=oo(e,c,t);a>m&&(a-=m,c++);let p=e[c].getWidth(a-1)===2;p&&a--;let _=p?i-1:i;s.push(_),d+=_}return s}function oo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?i-1:i}var W_=class U_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=U_._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),dr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};W_._nextId=1;var fk=W_,Mt={},or=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 ig=4294967295,ng=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ct.clone(),this.savedCharset=or,this.markers=[],this._nullCell=Di.fromCharData([0,a_,1,0]),this._whitespaceCell=Di.fromCharData([0,Fn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Za,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new tg(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 Xa),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 Xa),this._whitespaceCell}getBlankLine(e,t){return new eo(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>ig?ig:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ct);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 tg(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Ct),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,i);let a=0;if(this._rows<t)for(let c=this._rows;c<t;c++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new eo(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new eo(e,i)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let c=this.lines.length-o;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=ck(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ct),i);if(s.length>0){let o=uk(this.lines,s);hk(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Ct),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new eo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Ct),o=[],a=0;for(let c=this.lines.length-1;c>=0;c--){let d=this.lines.get(c);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let m=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),m.unshift(d);if(!i){let L=this.ybase+this.y;if(L>=c&&L<c+m.length)continue}let p=m[m.length-1].getTrimmedLength(),_=dk(m,this._cols,e),S=_.length-m.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+S):y=Math.max(0,this.lines.length-this.lines.maxLength+S);let k=[];for(let L=0;L<S;L++){let T=this.getBlankLine(Ct,!0);k.push(T)}k.length>0&&(o.push({start:c+m.length+a,newLines:k}),a+=k.length),m.push(...k);let w=_.length-1,x=_[w];x===0&&(w--,x=_[w]);let b=m.length-S-1,C=p;for(;b>=0;){let L=Math.min(C,x);if(m[w]===void 0)break;if(m[w].copyCellsFrom(m[b],C-L,x-L,L,!0),x-=L,x===0&&(w--,x=_[w]),C-=L,C===0){b--;let T=Math.max(b,0);C=oo(m,T,this._cols)}}for(let L=0;L<m.length;L++)_[L]<e&&m[L].setCell(_[L],s);let M=S-y;for(;M-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+S,this.ybase+t-1)}if(o.length>0){let c=[],d=[];for(let x=0;x<this.lines.length;x++)d.push(this.lines.get(x));let m=this.lines.length,p=m-1,_=0,S=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let x=Math.min(this.lines.maxLength-1,m+a-1);x>=0;x--)if(S&&S.start>p+y){for(let b=S.newLines.length-1;b>=0;b--)this.lines.set(x--,S.newLines[b]);x++,c.push({index:p+1,amount:S.newLines.length}),y+=S.newLines.length,S=o[++_]}else this.lines.set(x,d[p--]);let k=0;for(let x=c.length-1;x>=0;x--)c[x].index+=k,this.lines.onInsertEmitter.fire(c[x]),k+=c[x].amount;let w=Math.max(0,m+a-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,i=0,s){let o=this.lines.get(e);return o?o.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new fk(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},pk=class extends Ge{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new ng(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ng(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},K_=2,q_=1,kh=class extends Ge{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,K_),this.rows=Math.max(e.rawOptions.rows||0,q_),this.buffers=this._register(new pk(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,a=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;a===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(a+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=a-o+1;i.lines.shiftElements(o+1,c-1,-1),i.lines.set(a,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};kh=yt([Ne(0,ii)],kh);var Wr={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:Ja,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},mk=["normal","bold","100","200","300","400","500","600","700","800","900"],gk=class extends Ge{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...Wr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(dt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Wr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Wr))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Wr[e]),!vk(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Wr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=mk.includes(t)?t:Wr[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 vk(e){return e==="block"||e==="underline"||e==="bar"}function to(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&to(e[s],t-1);return i}var rg=Object.freeze({insertMode:!1}),sg=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ch=class extends Ge{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=to(rg),this.decPrivateModes=to(sg)}reset(){this.modes=to(rg),this.decPrivateModes=to(sg)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Ch=yt([Ne(0,ti),Ne(1,d_),Ne(2,ii)],Ch);var og={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 cu(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var uu=String.fromCharCode,ag={DEFAULT:e=>{let t=[cu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${uu(t[0])}${uu(t[1])}${uu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${cu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${cu(e,!0)};${e.x};${e.y}${t}`}},xh=class extends Ge{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new we),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(og))this.addProtocol(s,og[s]);for(let s of Object.keys(ag))this.addEncoding(s,ag[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};xh=yt([Ne(0,ti),Ne(1,mr),Ne(2,ii)],xh);var hu=[[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]],_k=[[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]],Dt;function yk(e,t){let i=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(o=i+s>>1,e>t[o][1])i=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var Sk=class{constructor(){if(this.version="6",!Dt){Dt=new Uint8Array(65536),Dt.fill(1),Dt[0]=0,Dt.fill(0,1,32),Dt.fill(0,127,160),Dt.fill(2,4352,4448),Dt[9001]=2,Dt[9002]=2,Dt.fill(2,11904,42192),Dt[12351]=1,Dt.fill(2,44032,55204),Dt.fill(2,63744,64256),Dt.fill(2,65040,65050),Dt.fill(2,65072,65136),Dt.fill(2,65280,65377),Dt.fill(2,65504,65511);for(let e=0;e<hu.length;++e)Dt.fill(0,hu[e][0],hu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Dt[e]:yk(e,_k)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=lr.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return lr.createPropertyValue(0,i,s)}},lr=class Ha{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new Sk;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,o=t.length;for(let a=0;a<o;++a){let c=t.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=o)return i+this.wcwidth(c);let p=t.charCodeAt(a);56320<=p&&p<=57343?c=(c-55296)*1024+p-56320+65536:i+=this.wcwidth(p)}let d=this.charProperties(c,s),m=Ha.extractWidth(d);Ha.extractShouldJoin(d)&&(m-=Ha.extractWidth(s)),i+=m,s=d}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},wk=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 lg(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Ks=2147483647,bk=256,V_=class Eh{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>bk)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Eh;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)i.addSubParam(o[a]);else i.addParam(o)}return i}clone(){let t=new Eh(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Ks?Ks: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>Ks?Ks:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&(t[i]=this._subParams.slice(s,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[i-1];s[i-1]=~o?Math.min(o*10+t,Ks):t}},qs=[],kk=class{constructor(){this._state=0,this._active=qs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qs}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=qs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||qs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",nl(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=qs,this._id=-1,this._state=0}}},vi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=nl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Vs=[],Ck=class{constructor(){this._handlers=Object.create(null),this._active=Vs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Vs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Vs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",nl(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Vs,this._ident=0}},io=new V_;io.addParam(0);var cg=class{constructor(e){this._handler=e,this._data="",this._params=io,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():io,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=nl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=io,this._data="",this._hitLimit=!1,i));return this._params=io,this._data="",this._hitLimit=!1,t}},xk=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Pi=160,Ek=(function(){let e=new xk(4095),t=Array.apply(null,Array(256)).map((d,m)=>m),i=(d,m)=>t.slice(d,m),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let a=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in a)e.addMany([24,26,153,154],c,3,0),e.addMany(i(128,144),c,3,0),e.addMany(i(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pi,0,2,0),e.add(Pi,8,5,8),e.add(Pi,6,0,6),e.add(Pi,11,0,11),e.add(Pi,13,13,13),e})(),Nk=class extends Ge{constructor(e=Ek){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new V_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(dt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kk),this._dcsParser=this._register(new Ck),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){let s=0,o=0,a=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](this._params),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=a;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Pi)],o>>4){case 2:for(let y=d+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(c=m[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._preserveStack(3,m,p,o,d),c;p<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],S=_?_.length-1:-1;for(;S>=0&&(c=_[S](),c!==!0);S--)if(c instanceof Promise)return this._preserveStack(4,_,S,o,d),c;S<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=d+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<Pi){this._dcsParser.put(e,d,y),d=y-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,o,d),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let y=d+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<Pi){this._oscParser.put(e,d,y),d=y-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,o,d),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},Rk=/^([\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})$/,Pk=/^[\da-f]+$/;function ug(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Rk.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Pk.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?a<<4:i===2?a:i===3?a>>4:a>>8}return s}}function du(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Dk(e,t=16){let[i,s,o]=e;return`rgb:${du(i,t)}/${du(s,t)}/${du(o,t)}`}var Mk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},In=131072,hg=10;function dg(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 fg=5e3,pg=0,Lk=class extends Ge{constructor(e,t,i,s,o,a,c,d,m=new Nk){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=c,this._unicodeService=d,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Q0,this._utf8Decoder=new J0,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ct.clone(),this._eraseAttrDataInternal=Ct.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Nh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:_.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,_,S)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:_,data:S})}),this._parser.setDcsHandlerFallback((p,_,S)=>{_==="HOOK"&&(S=S.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:_,payload:S})}),this._parser.setPrintHandler((p,_,S)=>this.print(p,_,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(de.BEL,()=>this.bell()),this._parser.setExecuteHandler(de.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(de.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(de.BS,()=>this.backspace()),this._parser.setExecuteHandler(de.HT,()=>this.tab()),this._parser.setExecuteHandler(de.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(de.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(za.IND,()=>this.index()),this._parser.setExecuteHandler(za.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(za.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new vi(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new vi(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new vi(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new vi(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new vi(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new vi(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new vi(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new vi(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new vi(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new vi(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new vi(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new vi(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in 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 cg((p,_)=>this.requestStatusString(p,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),fg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${fg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>In&&(a=this._parseStack.position+In)}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<In&&(this._parseBuffer=new Uint32Array(Math.min(e.length,In))),c||this._dirtyRowTracker.clearRange(),e.length>In)for(let p=a;p<e.length;p+=In){let _=p+In<e.length?p+In:e.length,S=typeof e=="string"?this._stringDecoder.decode(e.substring(p,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,S))return this._preserveStack(s,o,S,p),this._logSlowResolvingAsync(i),i}else if(!c){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,p))return this._preserveStack(s,o,p,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,i){let s,o,a=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,m=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,_=this._curAttrData,S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&S.getWidth(this._activeBuffer.x-1)===2&&S.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let y=this._parser.precedingJoinState;for(let k=t;k<i;++k){if(s=e[k],s<127&&a){let C=a[String.fromCharCode(s)];C&&(s=C.charCodeAt(0))}let w=this._unicodeService.charProperties(s,y);o=lr.extractWidth(w);let x=lr.extractShouldJoin(w),b=x?lr.extractWidth(y):0;if(y=w,c&&this._onA11yChar.fire(On(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-b>d){if(m){let C=S,M=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),b>0&&S instanceof eo&&S.copyCellsFrom(C,M,0,b,!1);M<d;)C.setCellFromCodepoint(M++,0,1,_)}else if(this._activeBuffer.x=d-1,o===2)continue}if(x&&this._activeBuffer.x){let C=S.getWidth(this._activeBuffer.x-1)?1:2;S.addCodepointToCell(this._activeBuffer.x-C,s,o);for(let M=o-b;--M>=0;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(p&&(S.insertCells(this._activeBuffer.x,o-b,this._activeBuffer.getNullCell(_)),S.getWidth(d-1)===2&&S.setCellFromCodepoint(d-1,0,1,_)),S.setCellFromCodepoint(this._activeBuffer.x++,s,o,_),o>0)for(;--o;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=y,this._activeBuffer.x<d&&i-t>0&&S.getWidth(this._activeBuffer.x)===0&&!S.hasContent(this._activeBuffer.x)&&S.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>dg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new cg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new vi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ct));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=lr.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),c=new Uint32Array(a.length*i),d=0;for(let p=0;p<a.length;){let _=a.codePointAt(p)||0;c[d++]=_,p+=_>65535?2:1}let m=d;for(let p=1;p<i;++p)c.copyWithin(m,0,d),m+=d;return this.print(c,0,m),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(de.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(de.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(de.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(de.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(de.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,or),this._charsetService.setgCharset(1,or),this._charsetService.setgCharset(2,or),this._charsetService.setgCharset(3,or);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(x=>(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,c=this._coreService,{buffers:d,cols:m}=this._bufferService,{active:p,alt:_}=d,S=this._optionsService.rawOptions,y=(x,b)=>(c.triggerDataEvent(`${de.ESC}[${t?"":"?"}${x};${b}$y`),!0),k=x=>x?1:2,w=e.params[0];return t?w===2?y(w,4):w===4?y(w,k(c.modes.insertMode)):w===12?y(w,3):w===20?y(w,k(S.convertEol)):y(w,0):w===1?y(w,k(s.applicationCursorKeys)):w===3?y(w,S.windowOptions.setWinLines?m===80?2:m===132?1:0:0):w===6?y(w,k(s.origin)):w===7?y(w,k(s.wraparound)):w===8?y(w,3):w===9?y(w,k(o==="X10")):w===12?y(w,k(S.cursorBlink)):w===25?y(w,k(!c.isCursorHidden)):w===45?y(w,k(s.reverseWraparound)):w===66?y(w,k(s.applicationKeypad)):w===67?y(w,4):w===1e3?y(w,k(o==="VT200")):w===1002?y(w,k(o==="DRAG")):w===1003?y(w,k(o==="ANY")):w===1004?y(w,k(s.sendFocus)):w===1005?y(w,4):w===1006?y(w,k(a==="SGR")):w===1015?y(w,4):w===1016?y(w,k(a==="SGR_PIXELS")):w===1048?y(w,1):w===47||w===1047||w===1049?y(w,k(p===_)):w===2004?y(w,k(s.bracketedPasteMode)):w===2026?y(w,k(s.synchronizedOutput)):y(w,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=co.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let c=e.getSubParams(t+a),d=0;do s[1]===5&&(o=1),s[a+d+1+o]=c[d];while(++d<c.length&&d+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ct.fg,e.bg=Ct.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Ct.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Ct.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Ct.fg&16777215,s.bg&=-67108864,s.bg|=Ct.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${de.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ct.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!dg(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(`${de.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>hg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>hg&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(mg(a))if(o==="?")t.push({type:0,index:a});else{let c=ug(o);c&&t.push({type:1,index:a,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=ug(i[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);mg(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,or),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Mk[e[0]],Mt[e[1]]||or),!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=Ct.clone(),this._eraseAttrDataInternal=Ct.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=c=>(this._coreService.triggerDataEvent(`${de.ESC}${c}${de.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Nh=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&&(pg=e,e=t,t=pg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Nh=yt([Ne(0,ti)],Nh);function mg(e){return 0<=e&&e<256}var jk=5e7,gg=12,Tk=50,Ak=class extends Ge{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>jk)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let c=d=>performance.now()-i>=gg?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(i,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(c);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=gg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Tk&&(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 d=t.addMarker(t.ybase+t.y),m={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(m,d)),this._dataByLinkId.set(m.id,m),m.id}let i=e,s=this._getEntryIdKey(i),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Rh=yt([Ne(0,ti)],Rh);var vg=!1,Ik=class extends Ge{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zr),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new ok,this.optionsService=this._register(new gk(e)),this._instantiationService.setService(ii,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(kh)),this._instantiationService.setService(ti,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(bh)),this._instantiationService.setService(d_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ch)),this._instantiationService.setService(mr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(xh)),this._instantiationService.setService(h_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(lr)),this._instantiationService.setService(ib,this.unicodeService),this._charsetService=this._instantiationService.createInstance(wk),this._instantiationService.setService(tb,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Rh),this._instantiationService.setService(f_,this._oscLinkService),this._inputHandler=this._register(new Lk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ut.forward(this._bufferService.onResize,this._onResize)),this._register(Ut.forward(this.coreService.onData,this._onData)),this._register(Ut.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Ak((t,i)=>this._inputHandler.parse(t,i))),this._register(Ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!vg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),vg=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,K_),t=Math.max(t,q_),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(lg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(lg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=dt(()=>{for(let t of e)t.dispose()})}}},Bk={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 Ok(e,t,i,s){var c;let o={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=de.ESC+"OA":o.key=de.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=de.ESC+"OD":o.key=de.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=de.ESC+"OC":o.key=de.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=de.ESC+"OB":o.key=de.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":de.DEL,e.altKey&&(o.key=de.ESC+o.key);break;case 9:if(e.shiftKey){o.key=de.ESC+"[Z";break}o.key=de.HT,o.cancel=!0;break;case 13:o.key=e.altKey?de.ESC+de.CR:de.CR,o.cancel=!0;break;case 27:o.key=de.ESC,e.altKey&&(o.key=de.ESC+de.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=de.ESC+"[1;"+(a+1)+"D":t?o.key=de.ESC+"OD":o.key=de.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=de.ESC+"[1;"+(a+1)+"C":t?o.key=de.ESC+"OC":o.key=de.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=de.ESC+"[1;"+(a+1)+"A":t?o.key=de.ESC+"OA":o.key=de.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=de.ESC+"[1;"+(a+1)+"B":t?o.key=de.ESC+"OB":o.key=de.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=de.ESC+"[2~");break;case 46:a?o.key=de.ESC+"[3;"+(a+1)+"~":o.key=de.ESC+"[3~";break;case 36:a?o.key=de.ESC+"[1;"+(a+1)+"H":t?o.key=de.ESC+"OH":o.key=de.ESC+"[H";break;case 35:a?o.key=de.ESC+"[1;"+(a+1)+"F":t?o.key=de.ESC+"OF":o.key=de.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=de.ESC+"[5;"+(a+1)+"~":o.key=de.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=de.ESC+"[6;"+(a+1)+"~":o.key=de.ESC+"[6~";break;case 112:a?o.key=de.ESC+"[1;"+(a+1)+"P":o.key=de.ESC+"OP";break;case 113:a?o.key=de.ESC+"[1;"+(a+1)+"Q":o.key=de.ESC+"OQ";break;case 114:a?o.key=de.ESC+"[1;"+(a+1)+"R":o.key=de.ESC+"OR";break;case 115:a?o.key=de.ESC+"[1;"+(a+1)+"S":o.key=de.ESC+"OS";break;case 116:a?o.key=de.ESC+"[15;"+(a+1)+"~":o.key=de.ESC+"[15~";break;case 117:a?o.key=de.ESC+"[17;"+(a+1)+"~":o.key=de.ESC+"[17~";break;case 118:a?o.key=de.ESC+"[18;"+(a+1)+"~":o.key=de.ESC+"[18~";break;case 119:a?o.key=de.ESC+"[19;"+(a+1)+"~":o.key=de.ESC+"[19~";break;case 120:a?o.key=de.ESC+"[20;"+(a+1)+"~":o.key=de.ESC+"[20~";break;case 121:a?o.key=de.ESC+"[21;"+(a+1)+"~":o.key=de.ESC+"[21~";break;case 122:a?o.key=de.ESC+"[23;"+(a+1)+"~":o.key=de.ESC+"[23~";break;case 123:a?o.key=de.ESC+"[24;"+(a+1)+"~":o.key=de.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=de.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=de.DEL:e.keyCode===219?o.key=de.ESC:e.keyCode===220?o.key=de.FS:e.keyCode===221&&(o.key=de.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let d=(c=Bk[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(d)o.key=de.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,p=String.fromCharCode(m);e.shiftKey&&(p=p.toUpperCase()),o.key=de.ESC+p}else if(e.keyCode===32)o.key=de.ESC+(e.ctrlKey?de.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=de.ESC+m,o.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=de.US),e.key==="@"&&(o.key=de.NUL));break}return o}var bt=0,zk=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Za,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Za,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,a)=>this._getKey(o)-this._getKey(a)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(bt=this._search(t),bt===-1)||this._getKey(this._array[bt])!==t)return!1;do if(this._array[bt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(bt),!0;while(++bt<this._array.length&&this._getKey(this._array[bt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bt=this._search(e),!(bt<0||bt>=this._array.length)&&this._getKey(this._array[bt])===e))do yield this._array[bt];while(++bt<this._array.length&&this._getKey(this._array[bt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bt=this._search(e),!(bt<0||bt>=this._array.length)&&this._getKey(this._array[bt])===e))do t(this._array[bt]);while(++bt<this._array.length&&this._getKey(this._array[bt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,o=this._getKey(this._array[s]);if(o>e)i=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},fu=0,_g=0,Fk=class extends Ge{constructor(){super(),this._decorations=new zk(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(dt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Hk(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!i||(a.options.layer??"bottom")===i)&&(yield a)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{fu=o.options.x??0,_g=fu+(o.options.width??1),e>=fu&&e<_g&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},Hk=class extends $n{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=gt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=gt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},$k=1e3,Wk=class{constructor(e,t=$k){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},yg=20,el=class extends Ge{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Wk(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
65
|
+
`))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ue(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(dt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<yg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
66
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===yg+1&&(this._liveRegion.textContent+=Yu.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let a=i.lines.get(i.ydisp+o),c=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,c))||"",m=(i.ydisp+o+1).toString(),p=this._rowElements[o];p&&(d.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=d,this._rowColumns.set(p,c)),p.setAttribute("aria-posinset",m),p.setAttribute("aria-setsize",s),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=i.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let c,d;if(t===0?(c=i,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:m,offset:p})=>{let _=m instanceof Text?m.parentNode:m,S=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(S))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(_);if(!y)return console.warn("columns is null. Race condition?"),null;let k=p<y.length?y[p]:y.slice(-1)[0]+1;return k>=this._terminal.cols&&(++S,k=0),{row:S,column:k}},a=o(t),c=o(i);if(!(!a||!c)){if(a.row>c.row||a.row===c.row&&a.column>=c.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(c.row-a.row)*this._terminal.cols-a.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var o,a;e.style.transform="";let t=e.getBoundingClientRect().width,i=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};el=yt([Ne(1,Zh),Ne(2,fn),Ne(3,pn)],el);var Ph=class extends Ge{constructor(e,t,i,s,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(dt(()=>{var a;dr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ue(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ue(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ue(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ue(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[a,c]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(i=this._checkLinkProviderResult(a,e,i)):c.provideLinks(e.y,d=>{var p,_;if(this._isMouseOut)return;let m=d==null?void 0:d.map(S=>({link:S}));(p=this._activeProviderReplies)==null||p.set(a,m),i=this._checkLinkProviderResult(a,e,i),((_=this._activeProviderReplies)==null?void 0:_.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let c=o[a],d=c.link.range.start.y<e?0:c.link.range.start.x,m=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let p=d;p<=m;p++){if(i.has(p)){o.splice(a--,1);break}i.add(p)}}}}_checkLinkProviderResult(e,t,i){var a;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let d=(a=this._activeProviderReplies.get(c))==null?void 0:a.find(m=>this._linkAtPosition(m.link,t));if(d){i=!0,this._handleNewLink(d);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Uk(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,dr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};Ph=yt([Ne(1,ed),Ne(2,pn),Ne(3,ti),Ne(4,m_)],Ph);function Uk(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 Kk=class extends Ik{constructor(e={}){super(e),this._linkifier=this._register(new Zr),this.browser=T_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zr),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(Fk),this._instantiationService.setService(uo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(T1),this._instantiationService.setService(m_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Gu)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(dt(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=ct.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${de.ESC}]${s};${Dk(o)}${L_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=xt.toColor(...t.color));else{let a=i;this._themeService.modifyColors(c=>c[a]=xt.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(el,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(de.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(de.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),a=this._renderService.dimensions.css.cell.width*o,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ue(this.element,"copy",t=>{this.hasSelection()&&X0(t,this._selectionService)}));let e=t=>G0(t,this.textarea,this.coreService,this.optionsService);this._register(Ue(this.textarea,"paste",e)),this._register(Ue(this.element,"paste",e)),A_?this._register(Ue(this.element,"mousedown",t=>{t.button===2&&Pm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ue(this.element,"contextmenu",t=>{Pm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ld&&this._register(Ue(this.element,"auxclick",t=>{t.button===1&&o_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ue(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ue(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ue(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ue(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ue(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ue(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ue(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ue(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Vu.get()),O_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(L1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(fn,this._coreBrowserService),this._register(Ue(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ue(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(vh,this._document,this._helperContainer),this._instantiationService.setService(rl,this._charSizeService),this._themeService=this._instantiationService.createInstance(wh),this._instantiationService.setService(is,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Qa),this._instantiationService.setService(p_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(yh,this.rows,this.screenElement)),this._instantiationService.setService(pn,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(ph,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(_h),this._instantiationService.setService(ed,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Ph,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(dh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Sh,this.element,this.screenElement,s)),this._instantiationService.setService(rb,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(fh,this.screenElement)),this._register(Ue(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(el,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ga,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ga,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(gh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(a){var p,_,S,y,k;let c=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!c)return!1;let d,m;switch(a.overrideType||a.type){case"mousemove":m=32,a.buttons===void 0?(d=3,a.button!==void 0&&(d=a.button<3?a.button:3)):d=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":m=0,d=a.button<3?a.button:3;break;case"mousedown":m=1,d=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let w=a.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(a,(y=(S=(_=(p=e._renderService)==null?void 0:p.dimensions)==null?void 0:_.device)==null?void 0:S.cell)==null?void 0:y.height,(k=e._coreBrowserService)==null?void 0:k.dpr)===0)return!1;m=w<0?0:1,d=4;break;default:return!1}return m===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:d,action:m,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(i(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(i(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&i(a)},mousemove:a=>{a.buttons||i(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ue(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return i(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(Ue(t,"wheel",a=>{var c,d,m,p,_;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(p=(m=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:m.cell)==null?void 0:p.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(a,!0);let S=de.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(S,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){s_(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=Ok(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===de.ETX||i.key===de.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(qk(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ct));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(de.ESC+"[I"):this.coreService.triggerDataEvent(de.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function qk(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Vk=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Yk=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Di)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Sg=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 Yk(t)}getNullCell(){return new Di}},Xk=class extends Ge{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new Sg(this._core.buffers.normal,"normal"),this._alternate=new Sg(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)}},Gk=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Qk=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}},Jk=["cols","rows"],qi=0,Zk=class extends Ge{constructor(e){super(),this._core=this._register(new Kk(e)),this._addonManager=this._register(new Vk),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(Jk.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 Gk(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Qk(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 Xk(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
67
|
+
`,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 Vu.get()},set promptLabel(e){Vu.set(e)},get tooMuchOutput(){return Yu.get()},set tooMuchOutput(e){Yu.set(e)}}}_verifyIntegers(...e){for(qi of e)if(qi===1/0||isNaN(qi)||qi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qi of e)if(qi&&(qi===1/0||isNaN(qi)||qi%1!==0||qi<0))throw new Error("This API only accepts positive integers")}};/**
|
|
68
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
69
|
+
* @license MIT
|
|
70
|
+
*
|
|
71
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
72
|
+
* @license MIT
|
|
73
|
+
*
|
|
74
|
+
* Originally forked from (with the author's permission):
|
|
75
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
76
|
+
* http://bellard.org/jslinux/
|
|
77
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
78
|
+
*/var eC=2,tC=1,iC=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var S;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((S=this._terminal.options.overviewRuler)==null?void 0:S.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),c={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},d=c.top+c.bottom,m=c.right+c.left,p=s-d,_=o-m-t;return{cols:Math.max(eC,Math.floor(_/e.css.cell.width)),rows:Math.max(tC,Math.floor(p/e.css.cell.height))}}};function nC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function rC({session:e,node:t,token:i,cols:s,rows:o,readonly:a=!1,takeSize:c,focused:d,onData:m,onExit:p,onFiles:_,retryBaseMs:S=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const w=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${nC(t,i)}`;let x=null,b=!1,C=!1,M=null,L=0,T=d;const J=()=>{if(b||C||M)return;const F=Math.min(5e3,Math.max(0,S)*2**Math.min(L++,5));M=setTimeout(()=>{M=null,H()},F)},H=()=>{if(b||C)return;const F=new WebSocket(w);x=F,F.binaryType="arraybuffer",F.onopen=()=>{if(x!==F||b)return;L=0;const G={type:"attach",session:e,token:i,cols:s,rows:o,readonly:a};c!==void 0&&(G.takeSize=c),F.send(JSON.stringify(G)),T!==void 0&&F.send(JSON.stringify({type:"focus",on:!!T}))},F.onmessage=G=>{if(!(x!==F||b))if(typeof G.data=="string"){let W;try{W=JSON.parse(G.data)}catch{return}W.type==="exit"&&(C=!0,p&&p(W.code)),W.type==="files"&&_&&_(W)}else m&&m(new Uint8Array(G.data))},F.onerror=()=>{if(x===F)try{F.close()}catch{}},F.onclose=G=>{x!==F||b||C||[1e3,1002,4401,4404].includes(G==null?void 0:G.code)||J()}};return H(),{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,G)=>{s=F,o=G,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:F,rows:G}))},action:F=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:F}))},focus:F=>{T=F,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!F}))},close:()=>{if(b=!0,M&&clearTimeout(M),M=null,x)try{x.close()}catch{}},get raw(){return x}}}async function wg(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const i=document.createElement("textarea");i.value=t,i.readOnly=!0,i.style.position="fixed",i.style.opacity="0",i.style.pointerEvents="none",document.body.appendChild(i),i.select();const s=document.execCommand&&document.execCommand("copy");if(i.remove(),s)return!0}catch{}return!1}const sC="\r";function oC(e){const t=String(e||"");let i=t.length;for(;i>0;){const s=t.charCodeAt(i-1);if(s===10||s===13)i-=1;else break}return t.slice(0,i)}function aC({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i(sC)!==!1}catch{return!1}}}function lC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function cC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const uC=450,bg=8;function hC(e,t,i,s){return Math.abs(Number(i)-Number(e))>bg||Math.abs(Number(s)-Number(t))>bg}const dC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function pu(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 kg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(i=>i&&i.kind==="file"&&typeof i.getAsFile=="function").map(i=>i.getAsFile()).filter(Boolean)}function fC(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=dC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function Y_({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:a=zt,onProgress:c=()=>{},now:d=Date.now()}={}){const m=Array.from(e||[]).filter(Boolean),p=[],_=[];if(!i||!m.length)return{paths:p,errors:_};const S=hi(s?String(s).split("/"):[]);for(let y=0;y<m.length;y+=1){const k=m[y],w=fC(k,y,d);c({index:y,total:m.length,name:w,state:"uploading"});try{const x=new FormData;x.append("session",i),x.append("paste",o?"true":"false"),x.append("file",k,w);const b=await a(`${S}/files/upload`,t,{method:"POST",body:x}),C=await b.json().catch(()=>({}));if(!b.ok||C.error)throw new Error(C.error||`HTTP ${b.status}`);p.push(C.path),c({index:y,total:m.length,name:w,state:"done",path:C.path})}catch(x){const b=String((x==null?void 0:x.message)||x);_.push({name:w,message:b}),c({index:y,total:m.length,name:w,state:"error",error:b})}}return{paths:p,errors:_}}function X_({session:e,node:t,token:i,readonly:s,takeSize:o,focused:a,sendRef:c,composerRef:d,actionRef:m,ctrlRef:p,setCtrlArmed:_,onFiles:S,fontSize:y=13,selectionMode:k=!1,onSelectionModeChange:w}){const x=P.useRef(null),b=P.useRef(null),C=P.useRef(y);C.current=y;const M=P.useRef(a);M.current=a;const L=P.useRef(k);L.current=k;const[T,J]=P.useState(""),[H,F]=P.useState(""),[G,W]=P.useState(null),V=async()=>{var R,O,D,z;const A=((O=(R=b.current)==null?void 0:R.term)==null?void 0:O.getSelection())||T;if(!A){F(v("copy-empty")),setTimeout(()=>F(""),1500);return}const N=await wg(A);F(v(N?"copied":"copy-manual")),N&&((z=(D=b.current)==null?void 0:D.term)==null||z.clearSelection(),w==null||w(!1)),setTimeout(()=>F(""),1800)},X=P.useRef(V);return X.current=V,P.useEffect(()=>{const A=b.current;A&&A.sock&&A.sock.focus&&A.sock.focus(!!a)},[a]),P.useEffect(()=>{const A=b.current;A&&(A.term.options.fontSize=y,A.fit.fit(),A.sock.resize(A.term.cols,A.term.rows))},[y]),P.useEffect(()=>{const A=new Zk({cursorBlink:!0,fontSize:C.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),N=new iC;A.loadAddon(N),A.open(x.current),N.fit();const R=new TextDecoder;let O;try{O=rC({session:e,node:t,token:i,readonly:s,takeSize:o,focused:M.current,onFiles:S,cols:A.cols,rows:A.rows,onData:fe=>A.write(R.decode(fe)),onExit:()=>A.write(`\r
|
|
79
|
+
\x1B[33m[sessione finita]\x1B[0m\r
|
|
80
|
+
`)})}catch(fe){return A.write(`\r
|
|
81
|
+
\x1B[31m${fe.message}\x1B[0m\r
|
|
82
|
+
`),()=>A.dispose()}b.current={term:A,fit:N,sock:O};let D=null;const z=A.onData(fe=>{if(s){D&&(D.ok=!1);return}if(!D&&p&&p.current&&fe.length===1){const je=fe.charCodeAt(0);let oe=je;je>=97&&je<=122?oe=je-96:je>=64&&je<=95?oe=je-64:je===32&&(oe=0),fe=String.fromCharCode(oe),p.current=!1,_&&_(!1)}const Be=O.sendInput(fe);D&&(D.seen=!0,D.ok=D.ok&&Be)});c&&(c.current=fe=>O.sendInput(fe)),m&&(m.current=fe=>O.action(fe)),d&&(d.current=aC({isReady:()=>!s&&O.isReady(),paste:fe=>{const Be={seen:!1,ok:!0};D=Be;try{A.paste(fe)}catch{Be.ok=!1}finally{D=null}return Be.seen&&Be.ok},send:fe=>O.sendInput(fe)}));const B=A.onSelectionChange(()=>J(A.getSelection()));A.attachCustomKeyEventHandler(fe=>(fe.ctrlKey||fe.metaKey)&&fe.key.toLowerCase()==="c"&&A.getSelection()?(fe.type==="keydown"&&wg(A.getSelection()),!1):!0);const te=x.current;let q=!1;const j=async fe=>{if(!fe.length||q)return;if(s){W({error:v("settings-readonly")});return}q=!0,W({current:0,total:fe.length,name:""});const Be=await Y_({files:fe,token:i,session:e,node:t,paste:!0,onProgress:({index:je,total:oe,name:ke,state:Ke,error:ut})=>W({current:je+1,total:oe,name:ke,...Ke==="error"?{error:ut}:{}})});q=!1,Be.errors.length?W({error:Be.errors.map(je=>`${je.name}: ${je.message}`).join(" · ")}):(W({done:!0,total:Be.paths.length}),setTimeout(()=>W(null),1600))},$=fe=>{const Be=fe.clipboardData;if(!pu(Be))return;const je=kg(Be);je.length&&(fe.preventDefault(),fe.stopPropagation(),j(je))},re=fe=>{pu(fe.dataTransfer)&&(fe.preventDefault(),fe.stopPropagation())},le=fe=>{pu(fe.dataTransfer)&&(fe.preventDefault(),fe.stopPropagation(),j(kg(fe.dataTransfer)))};te.addEventListener("paste",$,!0),te.addEventListener("dragenter",re,!0),te.addEventListener("dragover",re,!0),te.addEventListener("drop",le,!0);const se=24;let pe=null,ye=null,ce=0,Ce=null,Oe=null,Ze=null,Ve=!1;const Ae=()=>{Ze&&clearTimeout(Ze),Ze=null},ot=(fe,Be)=>{const oe=(te.querySelector(".xterm-screen")||te).getBoundingClientRect(),ke=Math.max(0,Math.min(A.cols-1,Math.floor((fe-oe.left)/Math.max(1,oe.width)*A.cols))),Ke=Math.max(0,Math.min(A.rows-1,Math.floor((Be-oe.top)/Math.max(1,oe.height)*A.rows)));return{col:ke,row:A.buffer.active.viewportY+Ke}},Et=fe=>ot(fe.clientX,fe.clientY),ie=fe=>{if(Ae(),Ve=!1,fe.touches.length!==1){pe=null;return}if(L.current){fe.preventDefault(),fe.stopPropagation(),Oe=Et(fe.touches[0]),A.clearSelection();return}pe=fe.touches[0].clientY,ye=fe.touches[0].clientX,ce=0,Ce=null;const Be={x:ye,y:pe};Ze=setTimeout(()=>{Ze=null,Ve=!0,L.current=!0,w==null||w(!0),Oe=ot(Be.x,Be.y),A.clearSelection(),A.select(Oe.col,Oe.row,1),pe=null,ye=null,Ce=null,ce=0},uC)},ae=fe=>{if((L.current||Ve)&&Oe&&fe.touches.length===1){fe.preventDefault(),fe.stopPropagation();const je=Et(fe.touches[0]),oe=Oe.row*A.cols+Oe.col,ke=je.row*A.cols+je.col,Ke=oe<=ke?Oe:je;A.select(Ke.col,Ke.row,Math.abs(ke-oe)+1);return}if(pe===null||fe.touches.length!==1)return;fe.preventDefault(),fe.stopPropagation();const Be=fe.touches[0];if(Ze&&hC(ye,pe,Be.clientX,Be.clientY)&&Ae(),Ce===null&&(Math.abs(Be.clientY-pe)>8||Math.abs(Be.clientX-ye)>8)&&(Ce=Math.abs(Be.clientY-pe)>Math.abs(Be.clientX-ye)),!!Ce){for(ce+=Be.clientY-pe,pe=Be.clientY;ce>=se;)O.action("scroll-up"),ce-=se;for(;ce<=-se;)O.action("scroll-down"),ce+=se}},ze=()=>{Ae(),pe=null,ye=null,Oe=null,Ve=!1};let Q=0;const ue=fe=>{for(fe.preventDefault(),fe.stopPropagation(),Q+=fe.deltaY;Q<=-se;)O.action("scroll-up"),Q+=se;for(;Q>=se;)O.action("scroll-down"),Q-=se};te.addEventListener("touchstart",ie,{passive:!1}),te.addEventListener("touchmove",ae,{passive:!1,capture:!0}),te.addEventListener("touchend",ze,{passive:!0}),te.addEventListener("touchcancel",ze,{passive:!0});const K=fe=>{(L.current||Ve)&&(fe.preventDefault(),fe.stopPropagation())};te.addEventListener("contextmenu",K,!0),te.addEventListener("wheel",ue,{passive:!1,capture:!0});let me=null;const be=fe=>{lC(fe)&&(fe.preventDefault(),fe.stopPropagation(),me=ot(fe.clientX,fe.clientY),A.clearSelection())},Pe=fe=>{if(!me)return;fe.preventDefault(),fe.stopPropagation();const Be=ot(fe.clientX,fe.clientY),je=me.row*A.cols+me.col,oe=Be.row*A.cols+Be.col,ke=je<=oe?me:Be;A.select(ke.col,ke.row,Math.abs(oe-je)+1)},he=fe=>{me&&(fe.stopPropagation(),me=null)};te.addEventListener("mousedown",be,!0),te.addEventListener("mousemove",Pe,!0),te.addEventListener("mouseup",he,!0);const Ee=fe=>{!cC(fe)||!(b.current&&b.current.term&&b.current.term.getSelection())||(fe.preventDefault(),fe.stopPropagation(),X.current&&X.current())};te.addEventListener("keydown",Ee,!0);const xe=()=>{N.fit(),O.resize(A.cols,A.rows)};window.addEventListener("resize",xe);const $e=window.visualViewport;$e&&($e.addEventListener("resize",xe),$e.addEventListener("scroll",xe));let Je=null,De=0;return typeof ResizeObserver<"u"&&(Je=new ResizeObserver(()=>{De&&cancelAnimationFrame(De),De=requestAnimationFrame(xe)}),Je.observe(te)),()=>{b.current=null,c&&(c.current=()=>!1),d&&(d.current=()=>!1),m&&(m.current=()=>!1),z.dispose(),B.dispose(),te.removeEventListener("touchstart",ie),te.removeEventListener("touchmove",ae,{capture:!0}),te.removeEventListener("touchend",ze),te.removeEventListener("touchcancel",ze),te.removeEventListener("contextmenu",K,!0),Ae(),te.removeEventListener("wheel",ue,{capture:!0}),te.removeEventListener("mousedown",be,!0),te.removeEventListener("mousemove",Pe,!0),te.removeEventListener("mouseup",he,!0),te.removeEventListener("keydown",Ee,!0),te.removeEventListener("paste",$,!0),te.removeEventListener("dragenter",re,!0),te.removeEventListener("dragover",re,!0),te.removeEventListener("drop",le,!0),window.removeEventListener("resize",xe),$e&&($e.removeEventListener("resize",xe),$e.removeEventListener("scroll",xe)),Je&&Je.disconnect(),De&&cancelAnimationFrame(De),O.close(),A.dispose()}},[e,t,i,s,o,c,d,m,p,_,S]),h.jsxs("div",{className:`nc-terminal${k?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:x}),G&&h.jsx("div",{className:`nc-upload-state${G.error?" error":""}`,role:"status",children:G.error?G.error:G.done?v("attach-uploaded").replace("{n}",String(G.total||0)):v("attach-upload-progress").replace("{n}",String(G.current||0)).replace("{total}",String(G.total||0))}),(T||k)&&h.jsxs("div",{className:"nc-selection-tools",children:[T?h.jsx("button",{type:"button",onClick:V,children:H||v("copy")}):h.jsx("span",{children:v("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var A,N;(N=(A=b.current)==null?void 0:A.term)==null||N.clearSelection(),J(""),w==null||w(!1)},children:v("cancel")}),H===v("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:T,onFocus:A=>A.target.select()})]})]})}const Cg="",ui="\x1B",pC=[{label:"↑",seq:ui+"[A"},{label:"↓",seq:ui+"[B"},{label:"PGUP",seq:ui+"[5~"},{label:"PGDN",seq:ui+"[6~"}];function mC({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:c}){const[d,m]=P.useState(!1),[p,_]=P.useState(!1),[S,y]=P.useState(!1),k=b=>{S?(e(ui+b),y(!1)):e(b)},w=(b,C,M)=>h.jsx("button",{onMouseDown:L=>{L.preventDefault(),k(C),M&&M()},children:b},b),x=(b,C)=>h.jsx("button",{onMouseDown:M=>{M.preventDefault(),t(C),_(!1)},children:b},b);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),pC.map(b=>w(b.label,b.seq)),w("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"),w("SCROLL",Cg+"[",()=>{m(!0),_(!1)}),h.jsx("button",{className:a?"armed":"",onMouseDown:b=>{b.preventDefault(),c==null||c(!a),_(!1)},children:"SELECT"}),w("⌃C","",()=>_(!1)),w("DETACH",Cg+"d",()=>_(!1))]}),h.jsxs("div",{className:"row",children:[w("ESC",ui),h.jsx("button",{className:p?"armed":"",onMouseDown:b=>{b.preventDefault(),_(C=>!C)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",ui+"[H"),w("↑",ui+"[A"),w("END",ui+"[F"),w("PGUP",ui+"[5~")]}),h.jsxs("div",{className:"row",children:[w("⇥"," "),h.jsx("button",{onMouseDown:b=>{b.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:i?"armed":"",onMouseDown:b=>{b.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:S?"armed":"",onMouseDown:b=>{b.preventDefault(),y(C=>!C)},children:"ALT"},"alt"),w("←",ui+"[D"),w("↓",ui+"[B"),w("→",ui+"[C"),w("PGDN",ui+"[6~")]})]})}const gC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function G_({session:e,node:t,token:i,filesEvent:s,onClose:o}){Si();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=t?`${t}:${e}`:e,[d,m]=P.useState("outbox"),[p,_]=P.useState({inbox:[],outbox:[]}),[S,y]=P.useState(""),k=P.useRef(null);async function w(){try{const L=await(await zt(`${a}/files?session=${encodeURIComponent(e)}`,i)).json();if(L.error){y(L.error);return}_(L);const T=L.outbox[0]?L.outbox[0].mtime:0;localStorage.setItem(Lv(c),String(T))}catch(M){y(String(M))}}P.useEffect(()=>{w()},[e,t]),P.useEffect(()=>{s&&s.session===e&&w()},[s]);async function x(M){for(const L of M){y(`carico ${L.name}…`);const T=new FormData;T.append("session",e),T.append("file",L);try{const H=await(await zt(`${a}/files/upload`,i,{method:"POST",body:T})).json();y(H.error?`errore: ${H.error}`:"")}catch(J){y(String(J))}}w()}async function b(M){const L=await zt(`${a}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(M)}`,i);if(!L.ok){y("errore download");return}const T=await L.blob(),J=URL.createObjectURL(T),H=document.createElement("a");H.href=J,H.download=M,H.click(),URL.revokeObjectURL(J)}async function C(M){await zt(`${a}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(M)}`,i,{method:"DELETE"}),w()}return h.jsxs("div",{className:"nc-files",children:[h.jsxs("header",{children:[h.jsx("b",{children:t?`${t}:${e}`:e}),h.jsx("button",{onClick:o,title:v("close"),children:h.jsx(tt,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),h.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>k.current&&k.current.click(),children:[h.jsx(tt,{name:"upload",size:18})," ",v("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:k,style:{display:"none"},onChange:M=>{x(Array.from(M.target.files||[])),M.target.value=""}})]}),S&&h.jsx("div",{className:"nc-busy",children:S}),h.jsxs("ul",{children:[p[d].map(M=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>b(M.name),children:M.name}),h.jsx("small",{children:gC(M.size)}),h.jsx("button",{onClick:()=>C(M.name),title:"elimina",children:h.jsx(tt,{name:"trash",size:18})})]},M.name)),p[d].length===0&&h.jsx("li",{className:"empty",children:v("empty-files")})]})]})}const al="nc_composer_v1",Dh="nc-composer-reset",vC=50,Q_=256*1024,J_=512*1024,_C=768*1024,xg=2*1024*1024,Z_=720*60*60*1e3,Mh=1;function ey(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function cd(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function tl(){return{version:Mh,cells:{}}}function ty(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=ey(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>Q_)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=vC))break}let i=0;return t.filter(s=>i+s.text.length>_C?!1:(i+=s.text.length,!0))}function il(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=J_?e.draft:"",i=ty(e.history),s=ey(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function yC(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return tl()}if(!t||typeof t!="object"||t.version!==Mh||!t.cells||typeof t.cells!="object")return tl();const i=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=il(o);a&&(i[s]=a)}return{version:Mh,cells:i}}function iy(e){const t=cd(e);if(!t)return tl();try{return yC(t.getItem(al))}catch{return tl()}}function Eg(e){try{return JSON.stringify(e).length}catch{return 1/0}}function SC(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>Z_&&delete e.cells[s]}function ny(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function wC(e,t){for(;Eg(e)>xg;){const i=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!i.length)break;i[0][1].history.pop()}for(const i of ny(e,t)){if(Eg(e)<=xg)break;delete e.cells[i]}}function ry(e,t,i){const s=cd(e);if(!s)return!1;wC(t,i);const o=()=>(s.setItem(al,JSON.stringify(t)),!0);try{return o()}catch{for(const c of ny(t,i)){delete t.cells[c];try{return o()}catch{}}return!1}}function po(e,t,i,s){const o=iy(t);SC(o,i,e);const a=il(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...a,history:[...a.history]}),d=il(c);return d?o.cells[e]={...d,updatedAt:i}:delete o.cells[e],{ok:ry(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function bC({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=Jr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Ys(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=iy(t),o=il(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>Z_?(s.cells[e]&&(delete s.cells[e],ry(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Ng(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>J_?!1:po(e,i,s,a=>({...a,draft:o})).ok}function Rg(e,t,i=Date.now()){return e?po(e,t,i,s=>({...s,draft:""})).ok:!1}function kC(e,t,i,s=Date.now()){return e?po(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function CC(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>Q_?!1:po(e,i,s,a=>{const c=a.history.filter(d=>d.text!==o);return c.unshift({text:o,at:s}),{...a,history:ty(c)}}).ok}function xC(e,t,i=Date.now()){return e?po(e,t,i,s=>({...s,history:[]})).ok:!1}function EC(e){const t=cd(e);if(!t)return!1;try{return t.removeItem(al),!0}catch{return!1}}const NC=300;function RC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function PC({ownerId:e,node:t,session:i,storage:s=RC()}){const o=P.useMemo(()=>bC({ownerId:e,node:t,session:i}),[e,t,i]),a=P.useMemo(()=>Ys(o,s),[]),[c,d]=P.useState(a.draft),[m,p]=P.useState(a.expanded),[_,S]=P.useState(a.history),[y,k]=P.useState(-1),w=P.useRef(o),x=P.useRef(a.draft),b=P.useRef(null),C=P.useRef(a.updatedAt||0),M=P.useRef(a.draft),L=P.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=null},[]),T=P.useCallback(()=>{L(),Ng(w.current,x.current,s)},[L,s]),J=P.useCallback(()=>{L(),b.current=setTimeout(()=>{b.current=null,Ng(w.current,x.current,s)},NC)},[L,s]),H=P.useCallback(R=>{const O=String(typeof R=="function"?R(x.current):R||"");x.current=O,C.current=Date.now(),M.current=O,k(-1),d(O),J()},[J]),F=P.useCallback((R,O)=>{L(),x.current=R,C.current=Date.now(),d(R),k(O),J()},[L,J]),G=P.useCallback(()=>{if(!_.length)return!1;const R=Math.min(y+1,_.length-1);return y<0&&(M.current=x.current),F(_[R].text,R),!0},[F,_,y]),W=P.useCallback(()=>{if(y<0)return!1;const R=y-1;return F(R<0?M.current:_[R].text,R),!0},[F,_,y]),V=P.useCallback(R=>{M.current=x.current;const O=_.findIndex(D=>D.text===R);F(String(R||""),O)},[F,_]),X=P.useCallback(()=>{p(R=>{const O=!R;return kC(w.current,O,s),O})},[s]),A=P.useCallback((R,O,D)=>{if(!R)return;if(CC(R,D,s),!(w.current===R)){Ys(R,s).draft===O&&Rg(R,s);return}S(Ys(R,s).history),M.current="",k(-1),x.current===O?(L(),x.current="",C.current=Date.now(),d(""),Rg(R,s)):J()},[L,J,s]),N=P.useCallback(()=>{xC(w.current,s),S([]),k(-1),M.current=x.current},[s]);return P.useEffect(()=>{if(w.current===o)return;T(),w.current=o;const R=Ys(o,s);x.current=R.draft,C.current=R.updatedAt||0,M.current=R.draft,d(R.draft),p(R.expanded),S(R.history),k(-1)},[o,T,s]),P.useEffect(()=>{const R=()=>T(),O=()=>{document.visibilityState==="hidden"&&T()};return window.addEventListener("pagehide",R),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("pagehide",R),document.removeEventListener("visibilitychange",O),T()}},[T]),P.useEffect(()=>{const R=()=>{L(),x.current="",C.current=0,M.current="",d(""),p(!1),S([]),k(-1)},O=z=>{if(z.key!==al)return;if(z.newValue==null){R();return}const B=Ys(w.current,s);B.updatedAt<C.current||(L(),x.current=B.draft,C.current=B.updatedAt,M.current=B.draft,d(B.draft),p(B.expanded),S(B.history),k(-1))},D=()=>R();return window.addEventListener("storage",O),window.addEventListener(Dh,D),()=>{window.removeEventListener("storage",O),window.removeEventListener(Dh,D)}},[L,s]),{cellKey:o,text:c,setText:H,expanded:m,toggleExpanded:X,history:_,historyCursor:y,recallPrevious:G,recallNext:W,selectHistory:V,confirmSubmitted:A,clearHistory:N,flush:T}}function sy({submitText:e,token:t,session:i,node:s,ownerId:o}){Si();const a=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:c,text:d,setText:m,expanded:p,toggleExpanded:_,history:S,historyCursor:y,recallPrevious:k,recallNext:w,selectHistory:x,confirmSubmitted:b,clearHistory:C,flush:M}=PC({ownerId:o,node:s,session:i}),[L,T]=P.useState(!1),[J,H]=P.useState(""),[F,G]=P.useState(!1),W=P.useRef(null),V=P.useRef(null),X=P.useRef(null),[A,N]=P.useState(!1),[R,O]=P.useState({left:0,bottom:0}),[D,z]=P.useState(!1),[B,te]=P.useState(!1),q=P.useRef(null),j=P.useRef(null),$=P.useRef(null),re=P.useRef(null),le=P.useRef(null),se=P.useRef(null),pe=P.useRef(null),ye=P.useRef(!1),[ce,Ce]=P.useState(!1),[Oe,Ze]=P.useState({left:0,bottom:0,width:320}),Ve=P.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);P.useEffect(()=>{let he=!1;if(s){G(!1);return}return zt(`${a}/voice/status`,t).then(Ee=>Ee.json()).then(Ee=>{he||G(!!Ee.serverSttConfigured)}).catch(()=>{he||G(!1)}),()=>{he=!0}},[t,a]);const ot=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||F);async function Et(){const he=d,Ee=oC(he);if(!Ee||B)return;te(!0),H("");let xe=!1;try{xe=!!await e(Ee)}catch{xe=!1}xe?b(c,he,Ee):H(v("composer-send-failed")),te(!1),requestAnimationFrame(()=>{var $e;return($e=X.current)==null?void 0:$e.focus({preventScroll:!0})})}function ie(){const he=q.current&&q.current.getBoundingClientRect();he&&O({left:Math.max(6,Math.min(he.left,window.innerWidth-186)),bottom:window.innerHeight-he.top+6}),N(!0)}function ae(he){N(!1),he&&q.current&&q.current.focus()}function ze(){const he=$.current&&$.current.getBoundingClientRect();if(he){const Ee=Math.max(220,Math.min(360,window.innerWidth-12));Ze({left:Math.max(6,Math.min(he.right-Ee,window.innerWidth-Ee-6)),bottom:window.innerHeight-he.top+6,width:Ee})}Ce(!0)}function Q(he){Ce(!1),he&&$.current&&$.current.focus()}P.useEffect(()=>{if(!A)return;const he=xe=>{xe.key==="Escape"&&ae(!0)},Ee=xe=>{const $e=j.current&&j.current.contains(xe.target),Je=q.current&&q.current.contains(xe.target);!$e&&!Je&&ae(!1)};return document.addEventListener("keydown",he),document.addEventListener("pointerdown",Ee),()=>{document.removeEventListener("keydown",he),document.removeEventListener("pointerdown",Ee)}},[A]),P.useEffect(()=>{if(!ce)return;const he=xe=>{xe.key==="Escape"&&Q(!0)},Ee=xe=>{const $e=re.current&&re.current.contains(xe.target),Je=$.current&&$.current.contains(xe.target);!$e&&!Je&&Q(!1)};return document.addEventListener("keydown",he),document.addEventListener("pointerdown",Ee),()=>{document.removeEventListener("keydown",he),document.removeEventListener("pointerdown",Ee)}},[ce]);function ue(he){if(!(he.isComposing||ye.current||he.altKey||he.ctrlKey||he.metaKey)){if(he.key==="ArrowUp"&&he.currentTarget.selectionStart===0&&he.currentTarget.selectionEnd===0){k()&&he.preventDefault();return}he.key==="ArrowDown"&&y>=0&&he.currentTarget.selectionStart===d.length&&he.currentTarget.selectionEnd===d.length&&w()&&he.preventDefault()}}function K(he){ae(!1),he.current&&he.current.click()}async function me(he){if(!he.length||!i)return;z(!0),H("");const{paths:Ee,errors:xe}=await Y_({files:he,token:t,session:i,node:s,paste:!1});xe.length&&H(xe.map($e=>`${$e.name}: ${$e.message}`).join(" · ")),Ee.length&&m($e=>$e+($e&&!$e.endsWith(" ")?" ":"")+Ee.join(" ")),z(!1)}function be(){W.current&&W.current.stop(),V.current&&V.current.stop(),T(!1)}async function Pe(){H("");const he=window.SpeechRecognition||window.webkitSpeechRecognition;if(he){const Ee=new he;Ee.lang="it-IT",Ee.continuous=!1,Ee.interimResults=!0;const xe=d?`${d} `:"";Ee.onresult=$e=>{const Je=Array.from($e.results).map(De=>De[0].transcript).join("");m(xe+Je)},Ee.onend=()=>T(!1),Ee.onerror=$e=>{H(`voice: ${$e.error||"errore"}`),T(!1)},W.current=Ee,Ee.start(),T(!0);return}try{const Ee=await navigator.mediaDevices.getUserMedia({audio:!0}),xe=new MediaRecorder(Ee),$e=[];xe.ondataavailable=Je=>$e.push(Je.data),xe.onstop=async()=>{Ee.getTracks().forEach(Je=>Je.stop()),T(!1),H("trascrivo…");try{const Je=new Blob($e,{type:xe.mimeType||"audio/webm"}),fe=await(await zt(`${a}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:Je})).json();fe.error?H(fe.error):(H(""),m(Be=>Be+(Be?" ":"")+(fe.text||"")))}catch(Je){H(String(Je))}},V.current={stop:()=>xe.state!=="inactive"&&xe.stop()},xe.start(),T(!0)}catch{H("microfono non disponibile"),T(!1)}}return h.jsxs("div",{className:"nc-composer",children:[J&&h.jsx("div",{className:"nc-composer-err",children:J}),h.jsxs("div",{className:"nc-composer-row",children:[i&&h.jsx("button",{ref:q,className:D?"attach busy":"attach",disabled:D,onClick:()=>A?ae(!1):ie(),title:v(D?"attach-uploading":"attach"),"aria-label":v("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":Ve.current,children:h.jsx(tt,{name:"attach",size:22})}),A&&h.jsxs("div",{ref:j,id:Ve.current,role:"menu",className:"nc-attach-menu",style:{left:R.left,bottom:R.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>K(le),children:[h.jsx(tt,{name:"file",size:18})," ",v("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>K(se),children:[h.jsx(tt,{name:"camera",size:18})," ",v("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>K(pe),children:[h.jsx(tt,{name:"image",size:18})," ",v("attach-gallery")]})]}),h.jsx("button",{ref:$,type:"button",className:"history",onPointerDown:he=>he.preventDefault(),onClick:()=>ce?Q(!1):ze(),title:v("composer-history-tools"),"aria-label":v("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":ce,children:h.jsx(tt,{name:"history",size:21})}),ce&&h.jsxs("div",{ref:re,role:"menu",className:"nc-composer-history-menu",style:{left:Oe.left,bottom:Oe.bottom,width:Oe.width},children:[h.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:he=>he.preventDefault(),onClick:()=>{_(),Q(!1),requestAnimationFrame(()=>{var he;return(he=X.current)==null?void 0:he.focus({preventScroll:!0})})},children:[h.jsx(tt,{name:p?"chevronDown":"chevronUp",size:18}),v(p?"composer-collapse":"composer-expand")]}),h.jsx("div",{className:"nc-composer-history-title",children:v("composer-history")}),S.length===0&&h.jsx("div",{className:"nc-composer-history-empty",children:v("composer-history-empty")}),S.map((he,Ee)=>h.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:xe=>xe.preventDefault(),onClick:()=>{x(he.text),Q(!1),requestAnimationFrame(()=>{var xe;return(xe=X.current)==null?void 0:xe.focus({preventScroll:!0})})},children:[h.jsx("span",{children:he.text.replace(/\s+/g," ").slice(0,180)}),he.at>0&&h.jsx("small",{children:new Date(he.at).toLocaleString()})]},`${he.at}:${Ee}`)),S.length>0&&h.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:he=>he.preventDefault(),onClick:()=>{C(),Q(!1)},children:v("composer-history-clear")})]}),h.jsx("input",{ref:le,type:"file",multiple:!0,hidden:!0,onChange:he=>{me(Array.from(he.target.files||[])),he.target.value=""}}),h.jsx("input",{ref:se,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:he=>{me(Array.from(he.target.files||[])),he.target.value=""}}),h.jsx("input",{ref:pe,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:he=>{me(Array.from(he.target.files||[])),he.target.value=""}}),h.jsx("textarea",{ref:X,className:p?"expanded":"",rows:p?8:2,value:d,placeholder:v("composer-placeholder"),onChange:he=>m(he.target.value),onKeyDown:ue,onCompositionStart:()=>{ye.current=!0},onCompositionEnd:()=>{ye.current=!1},onBlur:M}),ot&&h.jsx("button",{className:L?"mic on":"mic",onClick:L?be:Pe,title:v("voice"),children:h.jsx(tt,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:B,onPointerDown:he=>he.preventDefault(),onClick:Et,title:v("send"),children:h.jsx(tt,{name:"enter",size:22})})]})]})}function Pg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const DC=180,MC=480;function LC({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:c,onNodePower:d,onKill:m,onVisibility:p,onNew:_,onSettings:S,localNodeId:y,width:k=240,collapsed:w=!1,onResize:x,onToggleCollapse:b}){const[C,M]=Si(),{pins:L,orders:T,togglePin:J,viewFor:H,updateView:F,canMoveRoster:G,moveRoster:W,stepRoster:V}=qv(),{groupsFor:X,renameNode:A,moveNode:N,stepNode:R,nodeKey:O}=Xv(),D=new Set((t||[]).map(ie=>ie.tmuxSession)),z=new Map((e||[]).map(ie=>[ie.name,ie])),B=(ie,ae)=>E0(L,ie,ae),te=N0,q=[...t||[]].sort((ie,ae)=>te(B(ie.tmuxSession,(z.get(ie.tmuxSession)||{}).activity),B(ae.tmuxSession,(z.get(ae.tmuxSession)||{}).activity))),j=(e||[]).filter(ie=>!D.has(ie.name)).sort((ie,ae)=>te(B(ie.name,ie.activity),B(ae.name,ae.activity))||ie.name.localeCompare(ae.name)),$=new Set(i||[]),re=Zv(q,j,z),le=cr(re,L,H("local").filter,Hn(T,"local")),pe=X(s||[]).map(ie=>{const ae=(ie.route||[ie.name]).join("/"),ze=H(ae),{rawItems:Q}=e_(ie),ue=cr(Q,L,ze.filter,Hn(T,ae));return{g:ie,nodeRoute:ae,groupView:ze,rawItems:Q,items:ue}}),ye=(ie,ae,ze)=>o&&o({session:ie,...ae?{node:ae}:{},...Jr.test(String(ze||""))?{ownerId:ze}:{}}),ce=ie=>{const ae=window.prompt(`${v("rename-node-prompt")}
|
|
83
|
+
${v("rename-node-reset")}`,ie.label||ie.name);ae!==null&&(A(ie,ae)||window.alert(v("rename-node-invalid")))},[Ce,Oe]=P.useState(null),Ze=(ie,ae)=>{const ze=ie.currentTarget.getBoundingClientRect();Oe({text:ae,y:ze.top+ze.height/2})},Ve=()=>Oe(null),Ae=P.useRef(null);P.useEffect(()=>()=>{Ae.current&&Ae.current()},[]);function ot(ie){ie.preventDefault(),ie.stopPropagation();const ae=ie.clientX,ze=k,Q=K=>{const me=Math.max(DC,Math.min(MC,ze+(K.clientX-ae)));x&&x(me)},ue=()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",ue),window.removeEventListener("pointercancel",ue),window.removeEventListener("blur",ue),Ae.current=null};window.addEventListener("pointermove",Q),window.addEventListener("pointerup",ue),window.addEventListener("pointercancel",ue),window.addEventListener("blur",ue),Ae.current=ue}const Et=w?{width:48,flex:"0 0 48px"}:{width:k,flex:`0 0 ${k}px`};return w?h.jsxs("aside",{className:"nc-sidebar mini",style:Et,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:v("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>S&&S("nodes",!1),title:v("settings"),onMouseEnter:ie=>Ze(ie,v("settings")),onMouseLeave:Ve,children:h.jsx(tt,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[H("local").open&&le.map(ie=>ie.type==="cell"?(()=>{const ae=ie.value,ze=ae.degraded?"warn":ae.tmux?"on":"",Q=!!ae.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${$.has(ae.tmuxSession)?" active":""}`,onMouseEnter:ue=>Ze(ue,`${ae.cell}: ${ie.subtitle}`),onMouseLeave:Ve,draggable:Q,onDragStart:Q?ue=>ue.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:Q?()=>a&&a(ae.tmuxSession):()=>c&&c(ae),onDoubleClick:Q?()=>ye(ae.tmuxSession,"",y):void 0,children:h.jsx("span",{className:`nc-dot ${ze}${ie.working?" working":""}`})},ie.key)})():(()=>{const ae=ie.value;return h.jsx("button",{type:"button",className:`nc-mini-init${$.has(ae.name)?" active":""}`,onMouseEnter:ze=>Ze(ze,ae.name),onMouseLeave:Ve,draggable:!0,onDragStart:ze=>ze.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>ye(ae.name,"",y),children:Pg(ae.name)},ie.key)})()),pe.flatMap(({g:ie,nodeRoute:ae,groupView:ze,items:Q})=>ie.status==="up"?ze.open?Q.map(ue=>ue.type==="cell"?(()=>{const K=ue.value,me=!!K.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${$.has(ue.key)?" active":""}`,onMouseEnter:be=>Ze(be,`${ie.label||ae}: ${K.cell} · ${ue.subtitle}`),onMouseLeave:Ve,draggable:me,onDragStart:me?be=>be.dataTransfer.setData("text/nc-session",ue.key):void 0,onClick:me?()=>a&&a(ue.key):()=>c&&c({...K,route:ie.route,availableEngines:ie.engines||[]}),onDoubleClick:me?()=>ye(K.tmuxSession,ae,ie.instanceId):void 0,children:h.jsx("span",{className:`nc-dot ${K.degraded?"warn":me?`on${ue.working?" working":""}`:""}`})},ue.key)})():(()=>{const K=ue.value;return h.jsx("button",{type:"button",className:`nc-mini-init${$.has(ue.key)?" active":""}`,onMouseEnter:me=>Ze(me,`${ie.label||ae}: ${K.name}`),onMouseLeave:Ve,draggable:!0,onDragStart:me=>me.dataTransfer.setData("text/nc-session",ue.key),onClick:()=>a&&a(ue.key),onDoubleClick:()=>ye(K.name,ae,ie.instanceId),children:Pg(K.name)},ue.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ue=>Ze(ue,`${ie.label||(ie.route||[ie.name]).join(" › ")}: ${Vr(ie)}`),onMouseLeave:Ve,children:h.jsx("span",{className:`nc-dot${ie.status==="passive"?"":" warn"}`})},`nodo-${(ie.route||[ie.name]).join("/")}`)])]})}),Ce&&h.jsx("div",{className:"nc-mini-tip",style:{top:Ce.y},children:Ce.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:Et,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:b,title:v("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:v("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:_,title:v("fleet-new-cell"),children:["+ ",v("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>S&&S("nodes",!1),title:v("settings"),children:[h.jsx(tt,{name:"gear",size:15})," ",v("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(jC,{label:v("position-local"),count:le.length,state:H("local"),onToggle:()=>F("local",{open:!H("local").open}),onFilter:ie=>F("local",{filter:ie})}),H("local").open&&h.jsxs("div",{className:"nc-side-group",children:[le.map(ie=>ie.type==="cell"?(()=>{const ae=ie.value,ze=ae.degraded?"warn":ae.tmux?"on":"",Q=ae.degraded?v("cell-degraded"):ie.working?ie.subtitle:ae.tmux?v("cell-idle"):v("cell-off"),ue=!!ae.tmux;return h.jsxs("div",{"data-roster-key":ie.key,"data-position":"local",className:`nc-cell${ue?" live":""}${$.has(ae.tmuxSession)?" active":""}`,title:`${ae.cell} · ${ie.subtitle}${Q===ie.subtitle?"":` · ${Q}`}`,"aria-label":`${ae.cell}, ${ie.subtitle}${Q===ie.subtitle?"":`, ${Q}`}`,draggable:ue,onDragStart:ue?K=>K.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:ue?()=>a&&a(ae.tmuxSession):void 0,onDoubleClick:ue?()=>ye(ae.tmuxSession,"",y):void 0,children:[h.jsx(zn,{position:"local",itemKey:ie.key,label:ae.cell,canMove:G,onMove:(K,me)=>W("local",K,me,re),onStep:K=>V("local",ie.key,K,re)}),h.jsx("span",{className:`nc-dot ${ze}${ie.working?" working":""}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:ae.cell,children:ae.cell}),h.jsx("small",{title:ie.subtitle,children:ie.subtitle})]}),h.jsx("button",{className:`nc-pin${L.includes(ie.key)?" on":""}`,title:v("pin"),onClick:K=>{K.stopPropagation(),J(ie.key)},children:L.includes(ie.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${ae.tmux?" on":""}${ae.degraded?" warn":""}`,onClick:K=>{K.stopPropagation(),c&&c(ae)},title:ae.active?v("power-off"):v("power-on"),children:h.jsx(tt,{name:"power",size:14})})]},ie.key)})():(()=>{var ze;const ae=ie.value;return h.jsxs("div",{"data-roster-key":ie.key,"data-position":"local",className:`nc-side-card${$.has(ae.name)?" active":""}`,draggable:!0,onDragStart:Q=>Q.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>ye(ae.name,"",y),children:[h.jsx(zn,{position:"local",itemKey:ie.key,label:ae.name,canMove:G,onMove:(Q,ue)=>W("local",Q,ue,re),onStep:Q=>V("local",ie.key,Q,re)}),h.jsx("span",{className:ae.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ae.name}),h.jsxs("small",{children:[ae.preview||ae.cmd||v("windows").replace("{n}",String(ae.windows||0)),((ze=ae.outbox)==null?void 0:ze.count)>0?` · 📦${ae.outbox.count}`:""]})]}),ae.activity?h.jsx("span",{className:"nc-rel",children:Qr(ae.activity)}):null,h.jsx("button",{className:`nc-pin${L.includes(ie.key)?" on":""}`,title:v("pin"),onClick:Q=>{Q.stopPropagation(),J(ie.key)},children:L.includes(ie.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${ae.technical?" on":""}`,title:ae.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${ae.technical?v("mark-normal"):v("mark-technical")} ${ae.name}`,onClick:Q=>{Q.stopPropagation(),p&&p(ae.name,!ae.technical,[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:Q=>{Q.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",ae.name))&&m&&m(ae.name)},children:"⋯"})]},ie.key)})()),le.length===0&&h.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]}),pe.map(({g:ie,nodeRoute:ae,groupView:ze,rawItems:Q,items:ue})=>{const me=Gv(ie.health)||(ie.status==="up"?"on":ie.status==="passive"?"":"warn");return h.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":O(ie),children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:be=>{be.preventDefault(),ce(ie)},onClick:()=>F(ae,{open:!ze.open}),onKeyDown:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),F(ae,{open:!ze.open}))},children:[h.jsx(zn,{scope:"node",position:"nodes",itemKey:O(ie),label:ie.label||ie.name,onMove:(be,Pe)=>N(be,Pe,s||[]),onStep:be=>R(O(ie),be,s||[])}),h.jsx("span",{className:"nc-node-chevron",children:ze.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${me}`,title:ie.health?Ka(ie.health):""}),h.jsx("b",{children:ie.label||ie.name}),h.jsxs("small",{children:[" · ",ie.status==="up"?v("node-sessions").replace("{n}",String(ue.length)):ie.health&&Ka(ie.health)||Vr(ie)]}),h.jsxs("select",{className:"nc-node-filter",value:ze.filter,title:v(`view-${ze.filter}`),onClick:be=>be.stopPropagation(),onChange:be=>F(ae,{filter:be.target.value}),children:[h.jsx("option",{value:"all",children:v("view-all")}),h.jsx("option",{value:"pinned",children:v("view-pinned")}),h.jsx("option",{value:"active",children:v("view-active")}),h.jsx("option",{value:"off",children:v("view-off")}),h.jsx("option",{value:"technical",children:v("view-technical")})]}),h.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${ie.label||ie.name}`,onClick:be=>{be.stopPropagation(),ce(ie)},children:"✎"}),ie.direct&&ie.health&&ie.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${ie.tunnelStatus==="up"?" on":""}`,title:ie.tunnelStatus==="up"?v("power-off"):v("power-on"),onClick:be=>{be.stopPropagation(),d&&d(ie)},children:h.jsx(tt,{name:"power",size:14})})]}),ie.status==="up"&&ze.open&&h.jsxs("div",{className:"nc-side-group",children:[ue.map(be=>be.type==="cell"?(()=>{const Pe=be.value,he=!!Pe.tmux,Ee=Pe.degraded?"warn":Pe.tmux?"on":"";return h.jsxs("div",{"data-roster-key":be.key,"data-position":ae,className:`nc-side-card nc-cell${he?" live":""}${$.has(Pe.key)?" active":""}`,title:be.working?be.subtitle:Pe.tmux?v("cell-idle"):v("cell-off"),draggable:he,onDragStart:he?xe=>xe.dataTransfer.setData("text/nc-session",Pe.key):void 0,onClick:he?()=>a&&a(Pe.key):void 0,onDoubleClick:he?()=>ye(Pe.tmuxSession,ae,ie.instanceId):void 0,children:[h.jsx(zn,{position:ae,itemKey:be.key,label:Pe.cell,canMove:G,onMove:(xe,$e)=>W(ae,xe,$e,Q),onStep:xe=>V(ae,be.key,xe,Q)}),h.jsx("span",{className:`nc-dot ${Ee}${be.working?" working":""}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:Pe.cell}),h.jsx("small",{title:be.subtitle,children:be.subtitle})]}),h.jsx("button",{className:`nc-pin${L.includes(be.key)?" on":""}`,title:v("pin"),onClick:xe=>{xe.stopPropagation(),J(be.key)},children:L.includes(be.key)?"★":"☆"}),(ie.capabilities||[]).includes(Pe.active?"down":"up")&&h.jsx("button",{className:`nc-power${Pe.active?" on":""}${Pe.degraded?" warn":""}`,onClick:xe=>{xe.stopPropagation(),c&&c({...Pe,route:ie.route,availableEngines:ie.engines||[]})},title:Pe.active?v("power-off"):v("power-on"),children:h.jsx(tt,{name:"power",size:14})})]},be.key)})():(()=>{const Pe=be.value;return h.jsxs("div",{"data-roster-key":be.key,"data-position":ae,className:`nc-side-card${$.has(Pe.key)?" active":""}`,draggable:!0,onDragStart:he=>he.dataTransfer.setData("text/nc-session",Pe.key),onClick:()=>a&&a(Pe.key),onDoubleClick:()=>ye(Pe.name,Pe.node||ae,ie.instanceId),children:[h.jsx(zn,{position:ae,itemKey:be.key,label:Pe.name,canMove:G,onMove:(he,Ee)=>W(ae,he,Ee,Q),onStep:he=>V(ae,be.key,he,Q)}),h.jsx("span",{className:Pe.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:Pe.name}),h.jsx("small",{children:Pe.preview?Pe.preview:Pe.cmd?Pe.cmd:v("windows").replace("{n}",String(Pe.windows||0))})]}),Pe.activity?h.jsx("span",{className:"nc-rel",children:Qr(Pe.activity)}):null,h.jsx("button",{className:`nc-pin${L.includes(be.key)?" on":""}`,title:v("pin"),onClick:he=>{he.stopPropagation(),J(be.key)},children:L.includes(be.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${Pe.technical?" on":""}`,title:Pe.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Pe.technical?v("mark-normal"):v("mark-technical")} ${Pe.name}`,onClick:he=>{he.stopPropagation(),p&&p(Pe.name,!Pe.technical,ie.route||[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:he=>{he.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",Pe.name))&&m&&m(Pe.name,ie.route)},children:"⋯"})]},be.key)})()),ue.length===0&&h.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]})]},`nodo-${(ie.route||[ie.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:Kv.map((ie,ae)=>h.jsxs("span",{children:[ae>0&&" · ",h.jsx("button",{className:`nc-lang-btn${C===ie?" on":""}`,onClick:()=>M(ie),title:ie,children:ie.toUpperCase()})]},ie))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:ot,title:""})]})}function jC({label:e,count:t,state:i,onToggle:s,onFilter:o}){return h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[h.jsx("span",{className:"nc-node-chevron",children:i.open?"⌄":"›"}),h.jsx("span",{className:"nc-dot on"}),h.jsx("b",{children:e}),h.jsxs("small",{children:[" · ",v("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:i.filter,title:v(`view-${i.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[h.jsx("option",{value:"all",children:v("view-all")}),h.jsx("option",{value:"pinned",children:v("view-pinned")}),h.jsx("option",{value:"active",children:v("view-active")}),h.jsx("option",{value:"off",children:v("view-off")}),h.jsx("option",{value:"technical",children:v("view-technical")})]})]})}function TC(e,t,i){return!e&&t?i+1:i}function AC({session:e,node:t,ownerId:i,token:s,readonly:o=!1,focused:a,onFocus:c,onClose:d,onOpenSingle:m,alive:p=!0,available:_=!0,fontSize:S=lo,onZoom:y,decks:k=[],currentDeck:w,onSendToDeck:x}){const b=P.useRef(()=>{}),C=P.useRef(()=>!1),M=P.useRef(()=>{}),L=P.useRef(!1),[T,J]=P.useState(!1),[H,F]=P.useState(!1),[G,W]=P.useState(!1),[V,X]=P.useState(null),[A,N]=P.useState(0),R=P.useRef(p),O=t?`${t}:${e}`:e,D=k.filter(z=>z.id!==w&&z.available!==!1);return P.useEffect(()=>{const z=R.current;!z&&p&&N(B=>TC(z,p,B)),R.current=p},[p]),h.jsxs("div",{className:`nc-tile${a?" focused":""}`,onMouseDown:()=>c&&c(O),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:z=>{z.dataTransfer.setData("text/nc-session",O),z.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>c&&c(O),children:[h.jsx("span",{className:p?"nc-dot on":"nc-dot"}),h.jsx("b",{children:e}),t&&h.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),h.jsxs("span",{className:"nc-tile-actions",children:[y&&h.jsx("button",{onClick:()=>y(-1),title:v("zoom-out"),children:h.jsx(tt,{name:"zoomOut",size:14})}),y&&h.jsx("button",{onClick:()=>y(1),title:v("zoom-in"),children:h.jsx(tt,{name:"zoomIn",size:14})}),x&&D.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:v("send-to-deck"),value:"",onMouseDown:z=>z.stopPropagation(),onChange:z=>{const B=z.target.value;B&&x(O,B),z.target.value=""},children:[h.jsx("option",{value:"",children:v("send-to-deck")}),D.map(z=>h.jsxs("option",{value:z.id,children:[z.ownerLabel," · ",z.name]},z.id))]}),h.jsx("button",{onClick:()=>F(z=>!z),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>W(z=>!z),title:"file",children:"📁"}),m&&h.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),d&&h.jsx("button",{className:"nc-tile-close",onClick:()=>d(O),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[_?h.jsx(X_,{session:e,node:t,token:s,readonly:o,takeSize:!1,focused:a,sendRef:b,composerRef:C,actionRef:M,ctrlRef:L,setCtrlArmed:J,onFiles:X,fontSize:S},`${O}:${A}`):h.jsx("div",{className:"nc-tile-unavailable",children:v("deck-owner-unavailable")}),_&&G&&h.jsx("div",{className:"nc-tile-files",onMouseDown:z=>z.stopPropagation(),children:h.jsx(G_,{session:e,node:t,token:s,filesEvent:V,onClose:()=>W(!1)})})]}),_&&H&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:z=>z.stopPropagation(),children:h.jsx(sy,{submitText:z=>C.current(z),token:s,session:e,node:t,ownerId:i})})]})}const Dg=.2,Mg=.28,oy=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),mu=e=>oy(e,"text/nc-session"),Lg=e=>{var t;return oy(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function IC(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Mg?"left":s>1-Mg?"right":o<.5?"top":"bottom"}function BC({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:c,onOpenSingle:d,decks:m=[],currentDeck:p,onSendToDeck:_}){Si();const[S,y]=P.useState(null),k=P.useRef(null),w=P.useRef([]),x=P.useRef(null);function b(W,V){const X=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("blur",X),x.current=null};window.addEventListener("pointermove",W),window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),window.addEventListener("blur",X),x.current=X}P.useEffect(()=>()=>{x.current&&x.current()},[]),P.useEffect(()=>{const W=()=>y(null);return window.addEventListener("dragend",W),window.addEventListener("drop",W),()=>{window.removeEventListener("dragend",W),window.removeEventListener("drop",W)}},[]);const C=e.columns.length,M=W=>S&&S.col===W&&S.row===void 0,L=!!S&&S.col===C,T=(W,V)=>S&&S.col===W&&S.row===V&&S.quadrant?` drop-${S.quadrant}`:"";function J(W){if(W.preventDefault(),Lg(W.dataTransfer)){y(null);return}const V=W.dataTransfer.getData("text/nc-session"),X=S;if(y(null),!V||!X)return;let A;if(X.quadrant){if(A=W0(e,X.col,X.row,X.quadrant),!A)return}else A={col:X.col};t(Qi(e).includes(V)?O0(e,V,A):Jh(e,V,A))}function H(W,V){W.preventDefault(),W.stopPropagation();const X=W.clientX,A=e.columns[V].width,N=k.current&&k.current.clientWidth||1,R=e.columns[V+1];b(D=>{let z=Math.max(Dg,A+(D.clientX-X)/N);if(R){const B=xm(z/(z+R.width));z=B/(1-B)*R.width}t(F0(e,V,z))})}function F(W,V,X){W.preventDefault(),W.stopPropagation();const A=W.clientY,N=e.columns[V].tiles[X].height,R=w.current[V],O=R&&R.clientHeight||1,D=e.columns[V].tiles[X+1];b(B=>{let te=Math.max(Dg,N+(B.clientY-A)/O);if(D){const q=xm(te/(te+D.height));te=q/(1-q)*D.height}t(H0(e,V,X,te))})}function G(W){t(Ya(e,W))}return h.jsxs("div",{className:"nc-grid",ref:k,onDragOver:W=>{if(Lg(W.dataTransfer)){W.preventDefault(),y(null);return}mu(W.dataTransfer)&&(W.preventDefault(),S&&S.col===C||y({col:C}))},onDrop:J,onDragLeave:W=>{const V=W.relatedTarget;(!V||!(k.current&&k.current.contains(V)))&&y(null)},children:[e.columns.flatMap((W,V)=>{const X=[];return X.push(h.jsx("div",{className:`nc-col${M(V)?" drop-newcol":""}`,ref:A=>{w.current[V]=A},style:{flexGrow:W.width,flexBasis:0},onDragOver:A=>{mu(A.dataTransfer)&&(A.preventDefault(),A.stopPropagation(),S&&S.col===V&&S.row===void 0||y({col:V}))},children:W.tiles.flatMap((A,N)=>{const R=[],O=_i(A);return R.push(h.jsx("div",{className:`nc-tile-slot${T(V,N)}`,style:{flexGrow:A.height,flexBasis:0},onDragOver:D=>{if(!mu(D.dataTransfer))return;D.preventDefault(),D.stopPropagation();const z=IC(D.clientX,D.clientY,D.currentTarget.getBoundingClientRect());S&&S.col===V&&S.row===N&&S.quadrant===z||y({col:V,row:N,quadrant:z})},children:h.jsx(AC,{session:A.session,node:A.node,ownerId:A.ownerId,token:i,readonly:s,focused:a===O,onFocus:c,onClose:G,onOpenSingle:d,available:A.unavailable!==!0,alive:A.unavailable!==!0&&(!o||o.has(O)),fontSize:A.fontSize,onZoom:D=>t($0(e,V,N,D)),decks:m,currentDeck:p,onSendToDeck:_})},O)),N<W.tiles.length-1&&R.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:D=>F(D,V,N)},`h${N}`)),R})},`c${V}`)),V<C-1&&X.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:A=>H(A,V)},`v${V}`)),X}),L&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),C===0&&h.jsx("div",{className:"nc-grid-empty",children:v("grid-empty")})]})}const hn="local",Mi=/^[a-f0-9]{16,64}$/;function Xr(e,t){return`${e&&Mi.test(e)?e:hn}:${t}`}function ud(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==hn&&!Mi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===hn?null:s,name:o}}function ll(e){return Array.isArray(e)&&e.length?e.join("/"):""}function hd(e){return{columns:ur(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function OC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Mi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(ll(i.route),i.instanceId);return t}function zC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Mi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function Lh(e,t,i=[]){const s=hd(e),o=OC(i);for(const a of s.columns)for(const c of a.tiles)c.ownerId||(!c.node&&Mi.test(String(t||""))?c.ownerId=t:c.node&&o.has(c.node)&&(c.ownerId=o.get(c.node)));return s}function jh(e,t,i=[]){const s=hd(e),o=new Map;for(const a of i)a&&Mi.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const c of a.tiles)c.ownerId&&(c.ownerId===t?(delete c.node,delete c.unavailable):o.has(c.ownerId)?(c.node=ll(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function jg(e,t,i=[]){const s=hd(e),o=zC(i);for(const a of s.columns)for(const c of a.tiles)delete c.unavailable,c.ownerId&&(c.ownerId===t?delete c.node:o.has(c.ownerId)&&(c.node=ll(o.get(c.ownerId))));return s}function ay(e,t,i=[]){const s=Wn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Mi.test(String(t||""))?{ownerId:t}:{}};const o=i.find(a=>ll(a&&a.route)===s.node);return{...s,...o&&Mi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const FC=/^[a-z0-9-]{1,32}$/,yi="main",ly="nc_decks",cy="nc_deck_order_v1",uy=24;function Tg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function es(e){return typeof e=="string"&&FC.test(e)}function HC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return es(i)?i:yi}return yi}function $C(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Xr(null,yi),ownerId:null,name:yi}}if(Mi.test(s)&&es(o))return{id:Xr(s,o),ownerId:s,name:o}}const i=HC(e);return{id:Xr(null,i),ownerId:null,name:i}}function gu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:ud(e)||{ownerId:null,name:e},s=es(i.name)?i.name:yi,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===yi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function hy(e){return e===yi?"nc_grid_v1":`nc_grid_v1__${e}`}function dy(e){const t=[yi];if(Array.isArray(e)){for(const i of e)if(es(i)&&i!==yi&&!t.includes(i)&&t.push(i),t.length>=uy)break}return t}function rs(){return typeof localStorage<"u"?localStorage:null}function WC(){const e=rs();if(!e)return[yi];try{return dy(JSON.parse(e.getItem(ly)||"null"))}catch{return[yi]}}function UC(e){const t=rs();if(t)try{t.setItem(ly,JSON.stringify(dy(e)))}catch{}}function mo(e){return e==="local"||Mi.test(String(e||""))}function cl(e,t){const i=ud(e);return!!i&&(i.ownerId||"local")===t}function Zi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!mo(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&cl(a,i)))].slice(0,uy);o.length&&(t[i]=o)}return t}function ja(e=rs()){if(!e)return{};try{return Zi(JSON.parse(e.getItem(cy)||"null"))}catch{return{}}}function vu(e,t=rs()){const i=Zi(e);if(t)try{t.setItem(cy,JSON.stringify(i))}catch{}return i}function ul(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function KC(e,t,i,s,o=[]){if(!mo(t)||i===s)return Zi(e);const a=[...new Set(o.filter(S=>cl(S,t)))];if(!a.includes(i)||!a.includes(s))return Zi(e);const c=ul(e,t).filter(S=>a.includes(S)),d=[...c,...a.filter(S=>!c.includes(S))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const _=d.indexOf(s);return d.splice(m<p?_+1:_,0,i),Zi({...e,[t]:d})}function qC(e,t,i,s){if(!mo(t)||!cl(s,t))return Zi(e);const o=ul(e,t);return o.includes(i)?Zi({...e,[t]:o.map(a=>a===i?s:a)}):Zi(e)}function VC(e,t,i){return mo(t)?Zi({...e,[t]:ul(e,t).filter(s=>s!==i)}):Zi(e)}function Ag(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!mo(a)||!cl(o==null?void 0:o.id,a)||(i.has(a)||i.set(a,[]),i.get(a).push(o))}const s=[];for(const[,o]of i){const a=o[0].local?"local":o[0].ownerId,c=ul(t,a),d=new Map(c.map((m,p)=>[m,p]));o.sort((m,p)=>{const _=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER,S=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER;return _-S}),s.push(...o)}return s}function Th(e){const t=rs();if(!t)return null;try{return JSON.parse(t.getItem(hy(e))||"null")}catch{return null}}function YC(e,t){const i=rs();if(i)try{i.setItem(hy(e),JSON.stringify(t))}catch{}}const Ig=52,Bg=18;function XC({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const a=P.useRef(null),c=P.useRef(0),[d,m]=P.useState(!1),p=()=>{var x,b,C,M;const w=a.current;(b=(x=w==null?void 0:w.over)==null?void 0:x.classList)==null||b.remove("nc-deck-over"),(M=(C=w==null?void 0:w.source)==null?void 0:C.classList)==null||M.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},_=(w=!1)=>{const x=a.current;if(!x)return;const b=x.target;p(),a.current=null,m(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}w&&b&&b!==t&&s(t,b)},S=(w,x)=>{var T,J,H,F,G,W,V,X;const b=a.current;if(!b)return;b.x=w,b.y=x;const C=(J=(T=document.elementFromPoint(w,x))==null?void 0:T.closest)==null?void 0:J.call(T,"[data-deck-id][data-owner-key]"),M=(H=C==null?void 0:C.dataset)==null?void 0:H.deckId,L=((F=C==null?void 0:C.dataset)==null?void 0:F.ownerKey)===e&&M&&M!==t;b.over!==(L?C:null)&&((W=(G=b.over)==null?void 0:G.classList)==null||W.remove("nc-deck-over"),b.over=L?C:null,(X=(V=b.over)==null?void 0:V.classList)==null||X.add("nc-deck-over")),b.target=L?M:null},y=()=>{var b,C;const w=a.current;if(!w){c.current=0;return}const x=(C=(b=w.container)==null?void 0:b.getBoundingClientRect)==null?void 0:C.call(b);if(x){const M=w.x<x.left+Ig?-Bg:w.x>x.right-Ig?Bg:0;M&&(w.container.scrollLeft+=M,S(w.x,w.y))}c.current=requestAnimationFrame(y)};P.useEffect(()=>{const w=b=>{b.key==="Escape"&&a.current&&(b.preventDefault(),_(!1))},x=()=>_(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",x),p(),a.current=null}},[t,e]);const k=w=>{var C;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const x=w.currentTarget.closest("[data-deck-id][data-owner-key]"),b=w.currentTarget.closest(".nc-deckbar");a.current={pointerId:w.pointerId,handle:w.currentTarget,source:x,container:b,target:null,over:null,x:w.clientX,y:w.clientY},(C=x==null?void 0:x.classList)==null||C.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}m(!0),c.current=requestAnimationFrame(y)};return h.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:v("reorder-deck-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowLeft"?-1:1))},onPointerDown:k,onPointerMove:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(w.clientX,w.clientY))},onPointerUp:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{a.current&&_(!1)},children:"↔"})}function GC({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:a,onOpenWindow:c,onNavigate:d,saveState:m="idle",error:p="",sidebarVisible:_,onToggleSidebar:S}){Si();const[y,k]=P.useState(null),[w,x]=P.useState(""),[b,C]=P.useState(!1),[M,L]=P.useState(""),[T,J]=P.useState(""),H=Tg(w),F=es(H),G=[];for(const N of e){const R=N.local?"local":N.ownerId;let O=G.find(D=>D.key===R);O||(O={key:R,label:N.ownerLabel||(N.local?"Local":R),local:!!N.local,decks:[]},G.push(O)),O.decks.push(N)}const W=async()=>{if(F){C(!0),L("");try{i&&await i(H,y),x(""),k(null)}catch(N){L(String(N.message||N))}C(!1)}},V=N=>{J(""),c&&c(N.id)||J(N.id)},X=async N=>{if(!(N.id===t||!d||b||N.available===!1)){C(!0),L("");try{await d(N.id)}catch(R){L(String((R==null?void 0:R.message)||R))}C(!1)}},A=(N,R,O)=>{const D=N.decks.findIndex(B=>B.id===R.id),z=N.decks[D+O];D>=0&&z&&a&&!b&&a(R.id,z.id)};return h.jsxs("div",{className:"nc-deckbar",children:[S&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:v("toggle-sidebar"),onClick:S,children:_?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:v("decks")}),h.jsx("div",{className:"nc-deck-chips",children:G.map(N=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:N.local?"Local":N.label}),N.decks.map(R=>h.jsxs("span",{"data-deck-id":R.id,"data-owner-key":N.key,className:`nc-deck-chip${R.id===t?" current":""}${R.available===!1?" offline":""}`,children:[h.jsx(XC,{ownerKey:N.key,deckId:R.id,label:`${N.label} · ${R.name}`,onMove:(O,D)=>{a&&!b&&a(O,D)},onStep:O=>A(N,R,O)}),h.jsxs("button",{className:"nc-deck-open",title:R.available===!1?`${R.ownerLabel} offline`:R.id===t?v("deck-current"):`${R.ownerLabel} · ${R.name}`,disabled:b||R.available===!1,onClick:()=>X(R),children:[R.name,R.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:v("detach-deck"),onClick:()=>V(R),children:"↗"}),R.name!==yi&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:v("rename-deck"),onClick:()=>{const O=(typeof window<"u"?window.prompt(v("rename-deck"),R.name):"")||"",D=Tg(O);es(D)&&D!==R.name&&s&&s(R.id,D).catch(z=>L(String(z.message||z)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:R.available===!1,title:v("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(v("delete-deck-confirm").replace("{name}",`${R.ownerLabel} · ${R.name}`)))&&o&&o(R.id).catch(O=>L(String(O.message||O)))},children:"✕"})]})]},R.id)),y===N.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:F||!w?"":"invalid",placeholder:v("deck-name"),value:w,onChange:R=>x(R.target.value),onKeyDown:R=>{R.key==="Enter"&&W(),R.key==="Escape"&&(x(""),k(null))}}),w&&F&&H!==w&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",H]}),h.jsx("button",{className:"nc-deck-ok",disabled:!F||b,onClick:W,children:v("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{x(""),k(null)},children:v("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:b||N.decks.every(R=>R.available===!1),title:`${v("new-deck")} · ${N.label}`,onClick:()=>{x(""),k(N.key)},children:["+ ",v("new")]})]},N.key))}),h.jsx("span",{className:`nc-deck-state ${m}`,title:v("deck-autosave"),children:v(m==="saving"?"saving":m==="saved"?"saved":"deck-autosave")}),(M||p)&&h.jsx("span",{className:"nc-deck-error",children:M||p}),T&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(T),children:v("popup-blocked")})]})}var Ur={},_u,Og;function QC(){return Og||(Og=1,_u=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),_u}var yu={},Bn={},zg;function gr(){if(zg)return Bn;zg=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Bn.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},Bn.getSymbolTotalCodewords=function(s){return t[s]},Bn.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},Bn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Bn.isKanjiModeEnabled=function(){return typeof e<"u"},Bn.toSJIS=function(s){return e(s)},Bn}var Su={},Fg;function dd(){return Fg||(Fg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(Su)),Su}var wu,Hg;function JC(){if(Hg)return wu;Hg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},wu=e,wu}var bu,$g;function ZC(){if($g)return bu;$g=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,o){const a=t*this.size+i;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},bu=e,bu}var ku={},Wg;function ex(){return Wg||(Wg=1,(function(e){const t=gr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),c=a===145?26:Math.ceil((a-13)/(2*o-2))*2,d=[a-7];for(let m=1;m<o-1;m++)d[m]=d[m-1]-c;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),c=a.length;for(let d=0;d<c;d++)for(let m=0;m<c;m++)d===0&&m===0||d===0&&m===c-1||d===c-1&&m===0||o.push([a[d],a[m]]);return o}})(ku)),ku}var Cu={},Ug;function tx(){if(Ug)return Cu;Ug=1;const e=gr().getSymbolSize,t=7;return Cu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Cu}var xu={},Kg;function ix(){return Kg||(Kg=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let c=0,d=0,m=0,p=null,_=null;for(let S=0;S<a;S++){d=m=0,p=_=null;for(let y=0;y<a;y++){let k=o.get(S,y);k===p?d++:(d>=5&&(c+=t.N1+(d-5)),p=k,d=1),k=o.get(y,S),k===_?m++:(m>=5&&(c+=t.N1+(m-5)),_=k,m=1)}d>=5&&(c+=t.N1+(d-5)),m>=5&&(c+=t.N1+(m-5))}return c},e.getPenaltyN2=function(o){const a=o.size;let c=0;for(let d=0;d<a-1;d++)for(let m=0;m<a-1;m++){const p=o.get(d,m)+o.get(d,m+1)+o.get(d+1,m)+o.get(d+1,m+1);(p===4||p===0)&&c++}return c*t.N2},e.getPenaltyN3=function(o){const a=o.size;let c=0,d=0,m=0;for(let p=0;p<a;p++){d=m=0;for(let _=0;_<a;_++)d=d<<1&2047|o.get(p,_),_>=10&&(d===1488||d===93)&&c++,m=m<<1&2047|o.get(_,p),_>=10&&(m===1488||m===93)&&c++}return c*t.N3},e.getPenaltyN4=function(o){let a=0;const c=o.data.length;for(let m=0;m<c;m++)a+=o.data[m];return Math.abs(Math.ceil(a*100/c/5)-10)*t.N4};function i(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const c=a.size;for(let d=0;d<c;d++)for(let m=0;m<c;m++)a.isReserved(m,d)||a.xor(m,d,i(o,m,d))},e.getBestMask=function(o,a){const c=Object.keys(e.Patterns).length;let d=0,m=1/0;for(let p=0;p<c;p++){a(p),e.applyMask(p,o);const _=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(p,o),_<m&&(m=_,d=p)}return d}})(xu)),xu}var Ta={},qg;function fy(){if(qg)return Ta;qg=1;const e=dd(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Ta.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Ta.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},Ta}var Eu={},Xs={},Vg;function nx(){if(Vg)return Xs;Vg=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let o=0;o<255;o++)e[o]=s,t[s]=o,s<<=1,s&256&&(s^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Xs.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Xs.exp=function(s){return e[s]},Xs.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Xs}var Yg;function rx(){return Yg||(Yg=1,(function(e){const t=nx();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let c=0;c<s.length;c++)for(let d=0;d<o.length;d++)a[c+d]^=t.mul(s[c],o[d]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const c=a[0];for(let m=0;m<o.length;m++)a[m]^=t.mul(o[m],c);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Eu)),Eu}var Nu,Xg;function sx(){if(Xg)return Nu;Xg=1;const e=rx();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),c=this.degree-a.length;if(c>0){const d=new Uint8Array(this.degree);return d.set(a,c),d}return a},Nu=t,Nu}var Ru={},Pu={},Du={},Gg;function py(){return Gg||(Gg=1,Du.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Du}var Vi={},Qg;function my(){if(Qg)return Vi;Qg=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
84
|
+
]))+`;Vi.KANJI=new RegExp(i,"g"),Vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Vi.BYTE=new RegExp(s,"g"),Vi.NUMERIC=new RegExp(e,"g"),Vi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),a=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Vi.testKanji=function(m){return o.test(m)},Vi.testNumeric=function(m){return a.test(m)},Vi.testAlphanumeric=function(m){return c.test(m)},Vi}var Jg;function vr(){return Jg||(Jg=1,(function(e){const t=py(),i=my();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return i.testNumeric(a)?e.NUMERIC:i.testAlphanumeric(a)?e.ALPHANUMERIC:i.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,c){if(e.isValid(a))return a;try{return s(a)}catch{return c}}})(Pu)),Pu}var Zg;function ox(){return Zg||(Zg=1,(function(e){const t=gr(),i=fy(),s=dd(),o=vr(),a=py(),c=7973,d=t.getBCHDigit(c);function m(y,k,w){for(let x=1;x<=40;x++)if(k<=e.getCapacity(x,w,y))return x}function p(y,k){return o.getCharCountIndicator(y,k)+4}function _(y,k){let w=0;return y.forEach(function(x){const b=p(x.mode,k);w+=b+x.getBitsLength()}),w}function S(y,k){for(let w=1;w<=40;w++)if(_(y,w)<=e.getCapacity(w,k,o.MIXED))return w}e.from=function(k,w){return a.isValid(k)?parseInt(k,10):w},e.getCapacity=function(k,w,x){if(!a.isValid(k))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=o.BYTE);const b=t.getSymbolTotalCodewords(k),C=i.getTotalCodewordsCount(k,w),M=(b-C)*8;if(x===o.MIXED)return M;const L=M-p(x,k);switch(x){case o.NUMERIC:return Math.floor(L/10*3);case o.ALPHANUMERIC:return Math.floor(L/11*2);case o.KANJI:return Math.floor(L/13);case o.BYTE:default:return Math.floor(L/8)}},e.getBestVersionForData=function(k,w){let x;const b=s.from(w,s.M);if(Array.isArray(k)){if(k.length>1)return S(k,b);if(k.length===0)return 1;x=k[0]}else x=k;return m(x.mode,x.getLength(),b)},e.getEncodedBits=function(k){if(!a.isValid(k)||k<7)throw new Error("Invalid QR Code version");let w=k<<12;for(;t.getBCHDigit(w)-d>=0;)w^=c<<t.getBCHDigit(w)-d;return k<<12|w}})(Ru)),Ru}var Mu={},ev;function ax(){if(ev)return Mu;ev=1;const e=gr(),t=1335,i=21522,s=e.getBCHDigit(t);return Mu.getEncodedBits=function(a,c){const d=a.bit<<3|c;let m=d<<10;for(;e.getBCHDigit(m)-s>=0;)m^=t<<e.getBCHDigit(m)-s;return(d<<10|m)^i},Mu}var Lu={},ju,tv;function lx(){if(tv)return ju;tv=1;const e=vr();function t(i){this.mode=e.NUMERIC,this.data=i.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,c;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),c=parseInt(a,10),s.put(c,10);const d=this.data.length-o;d>0&&(a=this.data.substr(o),c=parseInt(a,10),s.put(c,d*3+1))},ju=t,ju}var Tu,iv;function cx(){if(iv)return Tu;iv=1;const e=vr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let c=t.indexOf(this.data[a])*45;c+=t.indexOf(this.data[a+1]),o.put(c,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},Tu=i,Tu}var Au,nv;function ux(){if(nv)return Au;nv=1;const e=vr();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){for(let s=0,o=this.data.length;s<o;s++)i.put(this.data[s],8)},Au=t,Au}var Iu,rv;function hx(){if(rv)return Iu;rv=1;const e=vr(),t=gr();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
85
|
+
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},Iu=i,Iu}var Bu={exports:{}},sv;function dx(){return sv||(sv=1,(function(e){var t={single_source_shortest_paths:function(i,s,o){var a={},c={};c[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var m,p,_,S,y,k,w,x,b;!d.empty();){m=d.pop(),p=m.value,S=m.cost,y=i[p]||{};for(_ in y)y.hasOwnProperty(_)&&(k=y[_],w=S+k,x=c[_],b=typeof c[_]>"u",(b||x>w)&&(c[_]=w,d.push(_,w),a[_]=p))}if(typeof o<"u"&&typeof c[o]>"u"){var C=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(C)}return a},extract_shortest_path_from_predecessor_list:function(i,s){for(var o=[],a=s;a;)o.push(a),i[a],a=i[a];return o.reverse(),o},find_path:function(i,s,o){var a=t.single_source_shortest_paths(i,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,o={},a;i=i||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=i.sorter||s.default_sorter,o},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var o={value:i,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Bu)),Bu.exports}var ov;function fx(){return ov||(ov=1,(function(e){const t=vr(),i=lx(),s=cx(),o=ux(),a=hx(),c=my(),d=gr(),m=dx();function p(C){return unescape(encodeURIComponent(C)).length}function _(C,M,L){const T=[];let J;for(;(J=C.exec(L))!==null;)T.push({data:J[0],index:J.index,mode:M,length:J[0].length});return T}function S(C){const M=_(c.NUMERIC,t.NUMERIC,C),L=_(c.ALPHANUMERIC,t.ALPHANUMERIC,C);let T,J;return d.isKanjiModeEnabled()?(T=_(c.BYTE,t.BYTE,C),J=_(c.KANJI,t.KANJI,C)):(T=_(c.BYTE_KANJI,t.BYTE,C),J=[]),M.concat(L,T,J).sort(function(F,G){return F.index-G.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function y(C,M){switch(M){case t.NUMERIC:return i.getBitsLength(C);case t.ALPHANUMERIC:return s.getBitsLength(C);case t.KANJI:return a.getBitsLength(C);case t.BYTE:return o.getBitsLength(C)}}function k(C){return C.reduce(function(M,L){const T=M.length-1>=0?M[M.length-1]:null;return T&&T.mode===L.mode?(M[M.length-1].data+=L.data,M):(M.push(L),M)},[])}function w(C){const M=[];for(let L=0;L<C.length;L++){const T=C[L];switch(T.mode){case t.NUMERIC:M.push([T,{data:T.data,mode:t.ALPHANUMERIC,length:T.length},{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.ALPHANUMERIC:M.push([T,{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.KANJI:M.push([T,{data:T.data,mode:t.BYTE,length:p(T.data)}]);break;case t.BYTE:M.push([{data:T.data,mode:t.BYTE,length:p(T.data)}])}}return M}function x(C,M){const L={},T={start:{}};let J=["start"];for(let H=0;H<C.length;H++){const F=C[H],G=[];for(let W=0;W<F.length;W++){const V=F[W],X=""+H+W;G.push(X),L[X]={node:V,lastCount:0},T[X]={};for(let A=0;A<J.length;A++){const N=J[A];L[N]&&L[N].node.mode===V.mode?(T[N][X]=y(L[N].lastCount+V.length,V.mode)-y(L[N].lastCount,V.mode),L[N].lastCount+=V.length):(L[N]&&(L[N].lastCount=V.length),T[N][X]=y(V.length,V.mode)+4+t.getCharCountIndicator(V.mode,M))}}J=G}for(let H=0;H<J.length;H++)T[J[H]].end=0;return{map:T,table:L}}function b(C,M){let L;const T=t.getBestModeForData(C);if(L=t.from(M,T),L!==t.BYTE&&L.bit<T.bit)throw new Error('"'+C+'" cannot be encoded with mode '+t.toString(L)+`.
|
|
86
|
+
Suggested mode is: `+t.toString(T));switch(L===t.KANJI&&!d.isKanjiModeEnabled()&&(L=t.BYTE),L){case t.NUMERIC:return new i(C);case t.ALPHANUMERIC:return new s(C);case t.KANJI:return new a(C);case t.BYTE:return new o(C)}}e.fromArray=function(M){return M.reduce(function(L,T){return typeof T=="string"?L.push(b(T,null)):T.data&&L.push(b(T.data,T.mode)),L},[])},e.fromString=function(M,L){const T=S(M,d.isKanjiModeEnabled()),J=w(T),H=x(J,L),F=m.find_path(H.map,"start","end"),G=[];for(let W=1;W<F.length-1;W++)G.push(H.table[F[W]].node);return e.fromArray(k(G))},e.rawSplit=function(M){return e.fromArray(S(M,d.isKanjiModeEnabled()))}})(Lu)),Lu}var av;function px(){if(av)return yu;av=1;const e=gr(),t=dd(),i=JC(),s=ZC(),o=ex(),a=tx(),c=ix(),d=fy(),m=sx(),p=ox(),_=ax(),S=vr(),y=fx();function k(H,F){const G=H.size,W=a.getPositions(F);for(let V=0;V<W.length;V++){const X=W[V][0],A=W[V][1];for(let N=-1;N<=7;N++)if(!(X+N<=-1||G<=X+N))for(let R=-1;R<=7;R++)A+R<=-1||G<=A+R||(N>=0&&N<=6&&(R===0||R===6)||R>=0&&R<=6&&(N===0||N===6)||N>=2&&N<=4&&R>=2&&R<=4?H.set(X+N,A+R,!0,!0):H.set(X+N,A+R,!1,!0))}}function w(H){const F=H.size;for(let G=8;G<F-8;G++){const W=G%2===0;H.set(G,6,W,!0),H.set(6,G,W,!0)}}function x(H,F){const G=o.getPositions(F);for(let W=0;W<G.length;W++){const V=G[W][0],X=G[W][1];for(let A=-2;A<=2;A++)for(let N=-2;N<=2;N++)A===-2||A===2||N===-2||N===2||A===0&&N===0?H.set(V+A,X+N,!0,!0):H.set(V+A,X+N,!1,!0)}}function b(H,F){const G=H.size,W=p.getEncodedBits(F);let V,X,A;for(let N=0;N<18;N++)V=Math.floor(N/3),X=N%3+G-8-3,A=(W>>N&1)===1,H.set(V,X,A,!0),H.set(X,V,A,!0)}function C(H,F,G){const W=H.size,V=_.getEncodedBits(F,G);let X,A;for(X=0;X<15;X++)A=(V>>X&1)===1,X<6?H.set(X,8,A,!0):X<8?H.set(X+1,8,A,!0):H.set(W-15+X,8,A,!0),X<8?H.set(8,W-X-1,A,!0):X<9?H.set(8,15-X-1+1,A,!0):H.set(8,15-X-1,A,!0);H.set(W-8,8,1,!0)}function M(H,F){const G=H.size;let W=-1,V=G-1,X=7,A=0;for(let N=G-1;N>0;N-=2)for(N===6&&N--;;){for(let R=0;R<2;R++)if(!H.isReserved(V,N-R)){let O=!1;A<F.length&&(O=(F[A]>>>X&1)===1),H.set(V,N-R,O),X--,X===-1&&(A++,X=7)}if(V+=W,V<0||G<=V){V-=W,W=-W;break}}}function L(H,F,G){const W=new i;G.forEach(function(R){W.put(R.mode.bit,4),W.put(R.getLength(),S.getCharCountIndicator(R.mode,H)),R.write(W)});const V=e.getSymbolTotalCodewords(H),X=d.getTotalCodewordsCount(H,F),A=(V-X)*8;for(W.getLengthInBits()+4<=A&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const N=(A-W.getLengthInBits())/8;for(let R=0;R<N;R++)W.put(R%2?17:236,8);return T(W,H,F)}function T(H,F,G){const W=e.getSymbolTotalCodewords(F),V=d.getTotalCodewordsCount(F,G),X=W-V,A=d.getBlocksCount(F,G),N=W%A,R=A-N,O=Math.floor(W/A),D=Math.floor(X/A),z=D+1,B=O-D,te=new m(B);let q=0;const j=new Array(A),$=new Array(A);let re=0;const le=new Uint8Array(H.buffer);for(let Ce=0;Ce<A;Ce++){const Oe=Ce<R?D:z;j[Ce]=le.slice(q,q+Oe),$[Ce]=te.encode(j[Ce]),q+=Oe,re=Math.max(re,Oe)}const se=new Uint8Array(W);let pe=0,ye,ce;for(ye=0;ye<re;ye++)for(ce=0;ce<A;ce++)ye<j[ce].length&&(se[pe++]=j[ce][ye]);for(ye=0;ye<B;ye++)for(ce=0;ce<A;ce++)se[pe++]=$[ce][ye];return se}function J(H,F,G,W){let V;if(Array.isArray(H))V=y.fromArray(H);else if(typeof H=="string"){let O=F;if(!O){const D=y.rawSplit(H);O=p.getBestVersionForData(D,G)}V=y.fromString(H,O||40)}else throw new Error("Invalid data");const X=p.getBestVersionForData(V,G);if(!X)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=X;else if(F<X)throw new Error(`
|
|
87
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
88
|
+
Minimum version required to store current data is: `+X+`.
|
|
89
|
+
`);const A=L(F,G,V),N=e.getSymbolSize(F),R=new s(N);return k(R,F),w(R),x(R,F),C(R,G,0),F>=7&&b(R,F),M(R,A),isNaN(W)&&(W=c.getBestMask(R,C.bind(null,R,G))),c.applyMask(W,R),C(R,G,W),{modules:R,version:F,errorCorrectionLevel:G,maskPattern:W,segments:V}}return yu.create=function(F,G){if(typeof F>"u"||F==="")throw new Error("No input text");let W=t.M,V,X;return typeof G<"u"&&(W=t.from(G.errorCorrectionLevel,t.M),V=p.from(G.version),X=c.from(G.maskPattern),G.toSJISFunc&&e.setToSJISFunction(G.toSJISFunc)),J(F,V,W,X)},yu}var Ou={},zu={},lv;function gy(){return lv||(lv=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,c=s.scale||4;return{width:a,scale:a?4:c,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const c=o.modules.size,d=o.modules.data,m=e.getScale(c,a),p=Math.floor((c+a.margin*2)*m),_=a.margin*m,S=[a.color.light,a.color.dark];for(let y=0;y<p;y++)for(let k=0;k<p;k++){let w=(y*p+k)*4,x=a.color.light;if(y>=_&&k>=_&&y<p-_&&k<p-_){const b=Math.floor((y-_)/m),C=Math.floor((k-_)/m);x=S[d[b*c+C]?1:0]}s[w++]=x.r,s[w++]=x.g,s[w++]=x.b,s[w]=x.a}}})(zu)),zu}var cv;function mx(){return cv||(cv=1,(function(e){const t=gy();function i(o,a,c){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.style.width=c+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,c,d){let m=d,p=c;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),c||(p=s()),m=t.getOptions(m);const _=t.getImageWidth(a.modules.size,m),S=p.getContext("2d"),y=S.createImageData(_,_);return t.qrToImageData(y.data,a,m),i(S,p,_),S.putImageData(y,0,0),p},e.renderToDataURL=function(a,c,d){let m=d;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),m||(m={});const p=e.render(a,c,m),_=m.type||"image/png",S=m.rendererOpts||{};return p.toDataURL(_,S.quality)}})(Ou)),Ou}var Fu={},uv;function gx(){if(uv)return Fu;uv=1;const e=gy();function t(o,a){const c=o.a/255,d=a+'="'+o.hex+'"';return c<1?d+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function i(o,a,c){let d=o+a;return typeof c<"u"&&(d+=" "+c),d}function s(o,a,c){let d="",m=0,p=!1,_=0;for(let S=0;S<o.length;S++){const y=Math.floor(S%a),k=Math.floor(S/a);!y&&!p&&(p=!0),o[S]?(_++,S>0&&y>0&&o[S-1]||(d+=p?i("M",y+c,.5+k+c):i("m",m,0),m=0,p=!1),y+1<a&&o[S+1]||(d+=i("h",_),_=0)):m++}return d}return Fu.render=function(a,c,d){const m=e.getOptions(c),p=a.modules.size,_=a.modules.data,S=p+m.margin*2,y=m.color.light.a?"<path "+t(m.color.light,"fill")+' d="M0 0h'+S+"v"+S+'H0z"/>':"",k="<path "+t(m.color.dark,"stroke")+' d="'+s(_,p,m.margin)+'"/>',w='viewBox="0 0 '+S+" "+S+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(m.width?'width="'+m.width+'" height="'+m.width+'" ':"")+w+' shape-rendering="crispEdges">'+y+k+`</svg>
|
|
90
|
+
`;return typeof d=="function"&&d(null,b),b},Fu}var hv;function vx(){if(hv)return Ur;hv=1;const e=QC(),t=px(),i=mx(),s=gx();function o(a,c,d,m,p){const _=[].slice.call(arguments,1),S=_.length,y=typeof _[S-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(S<2)throw new Error("Too few arguments provided");S===2?(p=d,d=c,c=m=void 0):S===3&&(c.getContext&&typeof p>"u"?(p=m,m=void 0):(p=m,m=d,d=c,c=void 0))}else{if(S<1)throw new Error("Too few arguments provided");return S===1?(d=c,c=m=void 0):S===2&&!c.getContext&&(m=d,d=c,c=void 0),new Promise(function(k,w){try{const x=t.create(d,m);k(a(x,c,m))}catch(x){w(x)}})}try{const k=t.create(d,m);p(null,a(k,c,m))}catch(k){p(k)}}return Ur.create=t.create,Ur.toCanvas=o.bind(null,i.render),Ur.toDataURL=o.bind(null,i.renderToDataURL),Ur.toString=o.bind(null,function(a,c,d){return s.render(a,d)}),Ur}var _x=vx();const yx=Fh(_x),vy=/^[a-z0-9-]{1,32}$/,Sx=/^[A-Za-z0-9._-]{1,32}$/,wx=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,bx=320;function kx(e){return typeof e=="string"&&vy.test(e)}const Cx=64;function Ah(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=Cx&&!/[\x00-\x1f\x7f]/.test(t)}function Gr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function _y(e){if(typeof e!="string"||!e||e.length>bx||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:Sx.test(e.slice(0,t))&&wx.test(e.slice(t+1))}function dv(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const i=Number(t);return Number.isInteger(i)&&i>=1&&i<=65535?i:void 0}function fv({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!kx(o))return{ok:!1,error:"err-node-name"};if(!_y(a))return{ok:!1,error:"err-ssh"};const c=dv(i);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const d=dv(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:a};return c!==null&&(m.sshPort=c),d!==null&&(m.remotePort=d),{ok:!0,value:m}}function xx(e,t){if(!e||!t||t<e)return null;const i=Math.floor((t-e)/1e3);return i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function pv(e,t){const i=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:i,...s?{passive:!0}:{},label:i?"tunnel-up":s?"node-passive":"tunnel-down",since:i?xx(e.since,t):null}}const Ex=new Set(["v","instanceId","port","label","invite"]),Nx=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Rx(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function Px(e){let t="";try{const c=new URL(String(e));t=new URLSearchParams(c.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let i;try{i=JSON.parse(Rx(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?Ex:i.v===2?Nx:null;if(!s)return{ok:!1};for(const c of Object.keys(i))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(i.instanceId)))return{ok:!1};const o=Number(i.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof i.label!="string")return{ok:!1};if(typeof i.invite!="string"||!i.invite)return{ok:!1};const a={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!vy.test(i.name))return{ok:!1};a.name=i.name}if(i.ssh!==void 0){if(!_y(i.ssh))return{ok:!1};a.ssh=String(i.ssh).trim()}if(i.sshPort!==void 0){const c=Number(i.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};a.sshPort=c}}return a}function Dx(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,c)=>{c==null||c===""||i.has(a)||(s[a]=c)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Gr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function mv(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Mx(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=Px(t);if(!i||!i.ok)return{kind:"invalid"};const s=[];return i.ssh||s.push("ssh"),i.name||s.push("name"),s.length?{kind:"partial",decoded:i,missing:s}:{kind:"complete",decoded:i}}function Lx(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=Dx(e,t,i);return t.version===2&&t.name&&!i.has("name")&&!s&&(o.name=t.name),!i.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function gv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),a=Mx(o);let c={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(c={...Lx(c,a.decoded,i,s),pairingUrl:o}),{classification:a,form:c}}function jx(e,{deviceDefault:t=""}={}){const i={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},s=e.localLabel||t;return s&&(i.localLabel=s),i}function Tx(){const e=new Set;let t=!1;return{canAuto(i){return!t&&!e.has(String(i||""))},start(i){return t?!1:(t=!0,e.add(String(i||"")),!0)},finish(){t=!1},reset(i){e.delete(String(i||""))},isBusy(){return t}}}const Ax=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Ix(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!i,message:s||String(e&&e.message||e)}}const Bx="modulepreload",Ox=function(e){return"/"+e},vv={},zx=function(t,i,s){let o=Promise.resolve();if(i&&i.length>0){let c=function(p){return Promise.all(p.map(_=>Promise.resolve(_).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=c(i.map(p=>{if(p=Ox(p),p in vv)return;vv[p]=!0;const _=p.endsWith(".css"),S=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${S}`))return;const y=document.createElement("link");if(y.rel=_?"stylesheet":Bx,_||(y.as="script"),y.crossOrigin="",y.href=p,m&&y.setAttribute("nonce",m),document.head.appendChild(y),_)return new Promise((k,w)=>{y.addEventListener("load",k),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${p}`)))})}))}function a(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})};class Ye{constructor(t,i,s,o,a){this._legacyCanvasSize=Ye.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=i:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let c=!1;if(t.hidden&&(t.hidden=!1,c=!0),document.body.contains(t)||(document.body.appendChild(t),c=!0),s=t.parentElement,i.highlightScanRegion||i.highlightCodeOutline){if(o=!!i.overlay,this.$overlay=i.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),c=!0),d.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),c=!0),c&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Ye.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await Ye.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Ye._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),Ye._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),Ye._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:i}=await this._getCameraStream();!this._active||this._paused?Ye._stopVideoStream(t):(this._setVideoMirror(i),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(Ye._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,a=!1,c=!1){let d,m=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(d=i.scanRegion,s=i.qrEngine,o=i.canvas,a=i.disallowCanvasResizing||!1,c=i.alsoTryWithoutScanRegion||!1,m=!0):console.warn(i||s||o||a||c?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),i=!!s;try{let p,_;[s,p]=await Promise.all([s||Ye.createQrEngine(),Ye._loadImage(t)]),[o,_]=Ye._drawToCanvas(p,d,o,a);let S;if(s instanceof Worker){let y=s;i||Ye._postWorkerMessageSync(y,"inversionMode","both"),S=await new Promise((k,w)=>{let x,b,C,M=-1;b=T=>{T.data.id===M&&(y.removeEventListener("message",b),y.removeEventListener("error",C),clearTimeout(x),T.data.data!==null?k({data:T.data.data,cornerPoints:Ye._convertPoints(T.data.cornerPoints,d)}):w(Ye.NO_QR_CODE_FOUND))},C=T=>{y.removeEventListener("message",b),y.removeEventListener("error",C),clearTimeout(x),w("Scanner error: "+(T?T.message||T:"Unknown Error"))},y.addEventListener("message",b),y.addEventListener("error",C),x=setTimeout(()=>C("timeout"),1e4);let L=_.getImageData(0,0,o.width,o.height);M=Ye._postWorkerMessageSync(y,"decode",L,[L.data.buffer])})}else S=await Promise.race([new Promise((y,k)=>window.setTimeout(()=>k("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw Ye.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:Ye._convertPoints(y.cornerPoints,d)}}catch(k){if(y=k.message||k,/not implemented|service unavailable/.test(y))return Ye._disableBarcodeDetector=!0,Ye.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:c});throw`Scanner error: ${y}`}})()]);return m?S:S.data}catch(p){if(!d||!c)throw p;let _=await Ye.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return m?_:_.data}finally{i||Ye._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Ye._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ye._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>zx(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ye._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,c=t.offsetLeft,d=t.offsetTop,m=window.getComputedStyle(t),p=m.objectFit,_=i/s,S=o/a;switch(p){case"none":var y=i,k=s;break;case"fill":y=o,k=a;break;default:(p==="cover"?_>S:_<S)?(k=a,y=k*_):(y=o,k=y/_),p==="scale-down"&&(y=Math.min(y,i),k=Math.min(k,s))}var[w,x]=m.objectPosition.split(" ").map((C,M)=>{const L=parseFloat(C);return C.endsWith("%")?(M?a-k:o-y)*L/100:L});m=this._scanRegion.width||i,S=this._scanRegion.height||s,p=this._scanRegion.x||0;var b=this._scanRegion.y||0;_=this.$overlay.style,_.width=`${m/i*y}px`,_.height=`${S/s*k}px`,_.top=`${d+x+b/s*k}px`,s=/scaleX\(-1\)/.test(t.style.transform),_.left=`${c+(s?o-w-y:w)+(s?i-p-m:p)/i*y}px`,_.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,a=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let c of t)c.x=c.x*a+s,c.y=c.y*i+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,i=1e3/this._maxScansPerSecond;t<i&&await new Promise(o=>setTimeout(o,i-t)),this._lastScanTimestamp=Date.now();try{var s=await Ye.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ye._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ye.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==Ye.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),c=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:c}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let i of t.getTracks())i.stop(),t.removeTrack(i)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,i,s,o=!1){s=s||document.createElement("canvas");let a=i&&i.x?i.x:0,c=i&&i.y?i.y:0,d=i&&i.width?i.width:t.videoWidth||t.width,m=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:d,i=i&&i.downScaledHeight?i.downScaledHeight:m,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,a,c,d,m,0,0,s.width,s.height),[s,i]}static async _loadImage(t){if(t instanceof Image)return await Ye._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Ye._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Ye._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let a=Ye._workerMessageId++;return t.postMessage({id:a,type:i,data:s},o),a}}Ye.DEFAULT_CANVAS_SIZE=400;Ye.NO_QR_CODE_FOUND="No QR code found";Ye._disableBarcodeDetector=!1;Ye._workerMessageId=0;function Fx({onResult:e,onClose:t}){const i=P.useRef(null),s=P.useRef(null),o=P.useRef(!1),[a,c]=P.useState("");P.useEffect(()=>{let m=!1;const p=i.current,_=S=>{m||o.current||(o.current=!0,e(S))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(v("qr-unsupported"));return}let S=!1;try{S=await Ye.hasCamera()}catch{S=!1}if(!S){c(v("qr-no-camera"));return}if(m||!p)return;const y=new Ye(p,k=>{const w=mv(k);w&&_(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:k=>{const w=k.videoWidth||640,x=k.videoHeight||480,b=Math.max(1,Math.round(Math.min(w,x)*.92));return{x:Math.round((w-b)/2),y:Math.round((x-b)/2),width:b,height:b,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(k){if(m)return;const w=k&&k.name||"";c(v(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const S=s.current;if(S){try{S.stop()}catch{}try{S.destroy()}catch{}s.current=null}const y=p,k=y&&y.srcObject;if(k&&typeof k.getTracks=="function"){for(const w of k.getTracks())try{w.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const d=async m=>{const p=m.target.files&&m.target.files[0];if(m.target.value="",!!p)try{const _=await Ye.scanImage(p,{returnDetailedScanResult:!0}),S=mv(_);if(!S)throw new Error("empty");o.current||(o.current=!0,e(S))}catch{c(v("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:v("scan-qr")})}),h.jsx("video",{ref:i,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&h.jsx("div",{className:"nc-err",role:"alert",children:a}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[v("qr-upload"),h.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:v("cancel")})]})]})})}const _v=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function yy({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",readonly:o=!1,onSuccess:a,onBusyChange:c}){const[d,m]=P.useState(_v),[p,_]=P.useState(!1),[S,y]=P.useState(!1),[k,w]=P.useState("idle"),[x,b]=P.useState(null),[C,M]=P.useState(""),[L,T]=P.useState(!1),J=P.useRef(Tx()),H=P.useRef(new Set),F=k==="busy";P.useEffect(()=>(c&&c(F),()=>{c&&c(!1)}),[F,c]);const G=async R=>{const O=String(R.pairingUrl||"").trim();if(J.current.start(O)){w("busy"),b(null),M("");try{await Jw(e,jx(R,{deviceDefault:s})),w("ok"),_(!1),m(_v()),H.current=new Set,T(!1),J.current.finish(),a&&await a()}catch(D){const z=Ix(D);b(z),w("idle"),J.current.finish(),(z.stage==="validation"||z.stage==="conflict"||z.stage==="ssh-start"||z.stage==="ssh-ready"||String(z.code||"").startsWith("ssh-"))&&_(!0)}}},W=(R,O=!0)=>{const{classification:D,form:z}=gv(d,R,H.current,L),B=z.pairingUrl;if(b(null),M(""),k==="ok"&&w("idle"),m(z),D.kind==="invalid"){b({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(D.kind==="partial"){_(!0),M(D.missing.includes("ssh")?v("pair-missing-ssh"):v("pair-missing-name"));return}D.kind==="complete"&&O&&!o&&J.current.canAuto(B)&&G(z)};P.useEffect(()=>{t&&W(t,i)},[]);const V=()=>{const R=String(d.pairingUrl||"").trim(),{classification:O,form:D}=gv(d,R,H.current,L);if(m(D),M(""),b(null),O.kind==="empty"){b({stage:"validation",message:v("pairing-required"),retryable:!0});return}if(O.kind==="invalid"){b({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(!D.ssh||!D.name){_(!0),M(D.ssh?v("pair-missing-name"):v("pair-missing-ssh"));return}if(D.label&&!Ah(D.label)){b({stage:"validation",message:v("err-label"),retryable:!0});return}if(D.localLabel&&!Ah(D.localLabel)){b({stage:"validation",message:v("err-label"),retryable:!0});return}J.current.reset(R),G(D)},X=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const R=await navigator.clipboard.readText();R&&R.trim()?W(R):M(v("pair-clipboard-empty"))}catch{M(v("pair-clipboard-denied"))}},A=(R,O)=>{H.current.add(R),m(D=>({...D,[R]:O}))},N=x&&x.stage&&(Ax.includes(x.stage)||x.stage==="internal")?v(`pair-stage-${x.stage}`):v("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:v("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:v("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:v("pair-paste-ph"),value:d.pairingUrl,disabled:o||F,onChange:R=>{m({...d,pairingUrl:R.target.value}),b(null),M("")},onPaste:R=>{const O=R.clipboardData&&R.clipboardData.getData("text")||"";O.trim()&&(R.preventDefault(),W(O))},onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),V())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:X,children:v("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:()=>y(!0),children:v("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||F,title:o?v("settings-readonly"):"",onClick:V,children:v("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[F&&h.jsx("div",{className:"nc-pair-progress",children:v("pair-progress")}),k==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:v("node-connected")}),C&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:C}),x&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:N})," — ",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:V,children:v("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:F,onClick:()=>_(R=>!R),children:[p?"▾":"▸"," ",v("pair-advanced")]}),p&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[v("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||F,onChange:R=>{H.current.add("label"),m(O=>({...O,label:R.target.value,name:L?O.name:Gr(R.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[v("node-name-label"),h.jsx("input",{placeholder:v("node-name-ph"),value:d.name,disabled:o||F,onChange:R=>{T(!0),H.current.add("name"),m(O=>({...O,name:R.target.value?Gr(R.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:v("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[v("pair-ssh-local-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||F,onChange:R=>{H.current.add("ssh"),A("ssh",R.target.value)}}),h.jsx("small",{className:"nc-set-hint",children:v("node-ssh-local-help")})]}),h.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:v("node-ssh-port-help"),value:d.sshPort,disabled:o||F,onChange:R=>A("sshPort",R.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[v("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||F,onChange:R=>A("localLabel",R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]})]}),S&&h.jsx(Fx,{onResult:R=>{y(!1),W(R)},onClose:()=>y(!1)})]})}function fd(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Hx(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function $x(){if(!fd())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Wx(e){if(!fd())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await zt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Hx(s)}),c=await zt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!c.ok){try{await a.unsubscribe()}catch{}const d=await c.json().catch(()=>({}));throw new Error(d.error||`HTTP ${c.status}`)}return!0}async function Ux(e){if(!fd())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await zt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Sy="nexuscrew.fleet",wy=2,Kx="nexuscrew.cells",qx=/^[A-Za-z0-9._-]{1,32}$/,pd=/^[a-z0-9._-]{1,32}$/,by=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Vx=new Set(["standard","unsafe"]),Yx=4096,yv=256,Xx=8192,Gx=32,Qx=24,Jx=new Set(["format","version","exportedAt","cells","engines"]),Zx=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),eE=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),tE=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function ar(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function ky(e){const t=String(e||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(t)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(t)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(t)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(t)}function Sv(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,a]of i){if(!pd.test(o)||!t(a))return null;s[o]=a}return s}function Cy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!Zx.has(a))||!qx.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Yx||!pd.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>yv)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const t=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof t!="string"||t.length>Xx)return null;const i=Sv(e.models,a=>typeof a=="string"&&!!a&&a.length<=yv),s=Sv(e.permissionPolicies,a=>Vx.has(a));if(i===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function iE(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!tE.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!ar(s,i==="baseUrl"?512:128)||ky(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!by.test(t.envKey)?null:t}function xy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!eE.has(s))||!pd.test(String(e.id||""))||!ar(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=iE(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!ar(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!ar(s,1024)||ky(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!ar(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!ar(e.model.flag,32)||/\s/.test(e.model.flag)||!ar(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!by.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(i)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function Ey(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},i=xy(t);return i||null}function nE(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),c=s instanceof Set?s:new Set(s||[]),d=[];for(const p of Array.isArray(e)?e:[]){if(!a.has(p.id))continue;const _=Cy({id:p.id,cwd:p.cwd,engine:p.engine,boot:p.boot===!0,...p.model?{model:p.model}:{},...p.models?{models:p.models}:{},...p.permissionPolicies?{permissionPolicies:p.permissionPolicies}:{},systemPrompt:p.prompt||""});_&&d.push(_)}const m=[];for(const p of Array.isArray(i)?i:[]){if(!c.has(p.id))continue;const _=Ey(p);_&&m.push(_)}return{format:Sy,version:wy,exportedAt:o.toISOString(),cells:d,engines:m}}function rE(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const i=(t==null?void 0:t.format)===Kx&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!Jx.has(d))||!i&&(t.format!==Sy||t.version!==wy)||!Array.isArray(t.cells)||t.cells.length>Gx||!i&&(!Array.isArray(t.engines)||t.engines.length>Qx))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const m=Cy(d);if(!m)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(m.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(m.id),s.push(m)}const a=[],c=new Set;for(const d of i?[]:t.engines){const m=xy(d);if(!m)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(c.has(m.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};c.add(m.id),a.push(m)}return{ok:!0,cells:s,engines:a,legacy:i,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function sE(e,t,i){const s=new Set(i||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([p])=>s.has(p))),a={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const c=o(e.models),d=o(e.permissionPolicies);return Object.keys(c).length&&(a.models=c),Object.keys(d).length&&(a.permissionPolicies=d),a}const oE=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}),wv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),Ny=e=>e==="claude"?"unsafe":"standard",ao=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),aE=(e,t)=>{var i;return((i=ao(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function lE(e){var t,i,s,o,a,c,d,m,p,_,S,y,k,w;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
91
|
+
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((i=e.managed)==null?void 0:i.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||Ny((c=e.managed)==null?void 0:c.client),displayName:((d=e.managed)==null?void 0:d.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((p=e.managed)==null?void 0:p.baseUrl)||"",envKey:((_=e.managed)==null?void 0:_.envKey)||"",providerId:((S=e.managed)==null?void 0:S.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((y=e.managedInfo)==null?void 0:y.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((k=e.model)==null?void 0:k.flag)||"",modelValue:((w=e.model)==null?void 0:w.value)||"",envRows:(e.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function cE(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||Ny(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=ao(i,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||aE(i,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
|
|
92
|
+
`).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function Kr({children:e,onClose:t,label:i,error:s=""}){const o=P.useRef(null),a=P.useRef(null),c=P.useRef(t);return c.current=t,P.useEffect(()=>{const d=document.activeElement,m=o.current,p=()=>Array.from((m==null?void 0:m.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(y=>y.offsetParent!==null),_=requestAnimationFrame(()=>{var y;return(y=p()[0]||m)==null?void 0:y.focus({preventScroll:!0})}),S=y=>{var b;if(y.key==="Escape"){y.preventDefault(),(b=c.current)==null||b.call(c);return}if(y.key!=="Tab")return;const k=p();if(!k.length){y.preventDefault(),m==null||m.focus();return}const w=k[0],x=k[k.length-1];y.shiftKey&&document.activeElement===w?(y.preventDefault(),x.focus()):!y.shiftKey&&document.activeElement===x&&(y.preventDefault(),w.focus())};return document.addEventListener("keydown",S),()=>{cancelAnimationFrame(_),document.removeEventListener("keydown",S),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),P.useEffect(()=>{s&&requestAnimationFrame(()=>{var d;return(d=a.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[s]),h.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&t()},children:h.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":i||v("settings"),tabIndex:-1,children:[e,s&&h.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function bv({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[a,c]=P.useState([]),[d,m]=P.useState(0);P.useEffect(()=>{let b=!0;async function C(){const L=[{route:[],label:v("local")}].concat((t||[]).map(J=>({route:Array.isArray(J.route)?J.route:[],label:J.label||(J.route||[]).join(" › ")}))),T=await Promise.all(L.map(async J=>{const H={...J,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const F=await pr(e,J.route);H.available=!!F.available,H.capabilities=F.capabilities||[],H.provider=F.provider||null,H.cells=(F.cells||[]).map(G=>({...G,route:J.route}));try{H.readonly=!!(await Kh(e,J.route)).readonlyDefault}catch{}try{const G=await Ov(e,J.route),W=new Set(H.cells.map(V=>V.tmuxSession).filter(Boolean));H.unmanaged=(G.sessions||[]).filter(V=>V&&!W.has(V.name))}catch{}}catch(F){H.err=String(F&&F.message||F)}return H}));b&&c(T)}C();const M=setInterval(C,6e3);return()=>{b=!1,clearInterval(M)}},[e,t,d]);const p=(b,C)=>Array.isArray(b.capabilities)&&b.capabilities.includes(C)&&!i&&!b.readonly,_=()=>m(b=>b+1),S=(b,C)=>{s&&s({...b,route:C})},y=(b,C)=>{s&&s({...b,route:C})},k=async(b,C)=>{try{await Qs(e,b.cell,C)}catch{}_()},w=async(b,C)=>{if(window.confirm(v("fleet-remove-cell").replace("{id}",b.cell))){try{await jv(e,b.cell,!0,C)}catch{}_()}},x=async(b,C)=>{if(window.confirm(v("terminate-confirm").replace("{name}",b.name))){try{await Uh(e,b.name,C)}catch{}_()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:v("fleet-inventory")}),h.jsx("small",{children:v("fleet-inventory-help")})]}),a.map(b=>{const C=b.route.length?b.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 ${b.available?"on":"warn"}`}),h.jsx("b",{children:b.label}),h.jsx("small",{children:b.available?`${b.cells.length} ${v("fleet-cells")} · ${b.unmanaged.length} ${v("fleet-tmux")}`:b.err||v("fleet-not-available")})]}),b.cells.map(M=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:M.cell}),h.jsx("small",{children:`${M.engine||""}${M.key?`·${M.key}`:""}${M.active?"":` · ${v("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[M.active&&p(b,"down")&&h.jsx("button",{className:"nc-btn ghost",title:v("power-off"),onClick:()=>y(M,b.route),children:v("stop")}),!M.active&&p(b,"up")&&h.jsx("button",{className:"nc-btn ghost",title:v("power-on"),onClick:()=>S(M,b.route),children:v("start")}),p(b,"restart")&&M.active&&h.jsx("button",{className:"nc-btn ghost",title:v("restart"),onClick:()=>k(M,b.route),children:v("restart")}),p(b,"remove")&&h.jsx("button",{className:"nc-btn danger",title:v("delete"),onClick:()=>w(M,b.route),children:"×"})]})]},`${C}:${M.cell}`)),b.unmanaged.map(M=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:M.name}),h.jsx("small",{children:v("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(b,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:v("import-as-cell"),onClick:()=>o(M,b.route),children:v("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:v("terminate"),onClick:()=>x(M,b.route),children:"×"})]})]},`${C}:u:${M.name}`)),b.available&&b.cells.length===0&&b.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:v("fleet-inventory-empty")})]},C)})]})}function uE({cells:e=[],engines:t=[],busy:i,canRestore:s=!1,onRestore:o,onClose:a}){const[c,d]=P.useState("export"),[m,p]=P.useState(()=>new Set(e.map(N=>N.id))),[_,S]=P.useState(()=>new Set(t.map(N=>N.id))),[y,k]=P.useState([]),[w,x]=P.useState([]),[b,C]=P.useState(""),M=new Set(t.map(N=>N.id)),L=new Set(e.map(N=>N.id)),T=(N,R)=>N(O=>{const D=new Set(O);return D.has(R)?D.delete(R):D.add(R),D}),J=()=>{const N=nE(e,m,t,_),R=t.filter(B=>_.has(B.id)).length;if(N.engines.length!==R){C(v("fleet-backup-invalid-engine"));return}if(!N.cells.length&&!N.engines.length){C(v("fleet-backup-select-one"));return}const O=new Blob([`${JSON.stringify(N,null,2)}
|
|
93
|
+
`],{type:"application/json"}),D=URL.createObjectURL(O),z=document.createElement("a");z.href=D,z.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(z),z.click(),z.remove(),setTimeout(()=>URL.revokeObjectURL(D),0),C("")},H=async N=>{if(C(""),k([]),x([]),!!N){if(N.size>1024*1024){C(v("fleet-backup-too-large"));return}try{const R=rE(await N.text());if(!R.ok){C(v(`fleet-backup-${R.error}`));return}const O=new Set(R.engines.map(D=>D.id));x(R.engines.map(D=>({engine:D,exists:M.has(D.id),selected:!M.has(D.id)}))),k(R.cells.map(D=>{const z=M.has(D.engine)||O.has(D.engine),B=L.has(D.id);return{cell:D,engine:z?D.engine:"",selected:z&&!B,exists:B}}))}catch(R){C(String(R.message||R))}}},F=(N,R)=>k(O=>O.map((D,z)=>z===N?{...D,...R}:D)),G=(N,R)=>x(O=>O.map((D,z)=>z===N?{...D,...R}:D)),W=new Set([...M,...w.filter(N=>N.selected).map(N=>N.engine.id)]),V=y.filter(N=>N.selected&&N.engine&&W.has(N.engine)),X=w.filter(N=>N.selected),A=[...new Map([...t.map(N=>[N.id,N.label||N.id]),...w.filter(N=>N.selected).map(N=>[N.engine.id,N.engine.label||N.engine.id])]).entries()];return h.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[h.jsx("b",{children:v("fleet-backup")}),h.jsx("small",{children:v("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="export"?" on":""}`,onClick:()=>{d("export"),C("")},children:v("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="import"?" on":""}`,disabled:!s,title:s?"":v("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),C("")},children:v("fleet-backup-import")})]}),c==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set(e.map(N=>N.id))),S(new Set(t.map(N=>N.id)))},children:v("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set),S(new Set)},children:v("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:v("fleet-engines")}),t.map(N=>{var R;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:_.has(N.id),onChange:()=>T(S,N.id)}),h.jsxs("span",{children:[h.jsx("b",{children:N.label||N.id}),h.jsxs("small",{children:[N.id,(R=N.envKeys)!=null&&R.length?` · ${N.envKeys.length} ${v("fleet-backup-env-names")}`:""]})]})]},N.id)}),h.jsx("b",{children:v("fleet-cells")}),e.map(N=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:m.has(N.id),onChange:()=>T(p,N.id)}),h.jsxs("span",{children:[h.jsx("b",{children:N.id}),h.jsxs("small",{children:[N.engine," · ",v("fleet-system-prompt")," ",(N.prompt||"").length," ",v("characters")]})]})]},N.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:v("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size&&!_.size,onClick:J,children:v("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:N=>H(N.target.files&&N.target.files[0])}),h.jsx("small",{children:v("fleet-backup-import-help")}),!!(y.length||w.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(N=>N.map(R=>({...R,selected:!0}))),k(N=>N.map(R=>({...R,selected:!!R.engine})))},children:v("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(N=>N.map(R=>({...R,selected:!1}))),k(N=>N.map(R=>({...R,selected:!1})))},children:v("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&h.jsx("b",{children:v("fleet-engines")}),w.map((N,R)=>{var O;return h.jsx("div",{className:"nc-backup-import-row",children:h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:N.selected,onChange:D=>G(R,{selected:D.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:N.engine.label||N.engine.id}),h.jsxs("small",{children:[N.engine.id," · ",N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new"),(O=N.engine.envKeys)!=null&&O.length?` · ${v("fleet-backup-env-values-required")}`:""]})]})]})},N.engine.id)}),!!y.length&&h.jsx("b",{children:v("fleet-cells")}),y.map((N,R)=>h.jsxs("div",{className:"nc-backup-import-row",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:N.selected,disabled:!N.engine||!W.has(N.engine),onChange:O=>F(R,{selected:O.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:N.cell.id}),h.jsxs("small",{children:[N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new")," · ",v("fleet-system-prompt")," ",N.cell.systemPrompt.length," ",v("characters")]})]})]}),h.jsxs("select",{value:N.engine,onChange:O=>F(R,{engine:O.target.value,selected:!!O.target.value}),children:[h.jsx("option",{value:"",children:v("fleet-backup-engine-missing")}),A.map(([O,D])=>h.jsx("option",{value:O,children:D},O))]})]},N.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!V.length&&!X.length,onClick:()=>o({engineRows:w,cellRows:y}),children:v("fleet-backup-restore")})]})]}),b&&h.jsx("div",{className:"nc-err",children:b})]})}function hE({state:e,setState:t,busy:i,onSave:s,catalog:o}){var b;const a=e.form,c=C=>t({...e,form:{...a,...C}}),d=a.envRows||[],m=[...new Map(o.map(C=>[C.client,C.clientLabel||C.client])).entries()],p=o.filter(C=>C.client===a.client),_=ao(o,a),S=typeof(_==null?void 0:_.credentialEnv)=="string"?_.credentialEnv:"",y=Array.isArray(_==null?void 0:_.credentialUsedBy)?_.credentialUsedBy:[],k=(_==null?void 0:_.credentialSource)||"missing",w=!!S&&e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,x=C=>{C&&c({client:C.client,provider:C.provider,credentialProfile:C.credentialProfile||"",managedModel:C.model||"",protocol:C.protocol||"",permissionPolicy:C.permissionPolicyDefault||"standard",rc:!!C.rc,displayName:C.custom?v("fleet-custom-provider-default"):"",baseUrl:C.custom?"":C.endpoint||"",envKey:C.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:C.id,label:""}:{}})};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:e.mode==="new"?v("fleet-new-engine"):`${v("edit")} ${a.id}`}),h.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:C=>c({id:C.target.value})}),h.jsx("input",{value:a.label,placeholder:v("label"),onChange:C=>c({label:C.target.value})}),h.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:C=>c({kind:C.target.value}),children:[h.jsx("option",{value:"managed",children:v("fleet-managed")}),h.jsx("option",{value:"custom",children:v("fleet-custom")})]}),a.kind==="managed"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:C=>x(o.find(M=>M.client===C.target.value&&M.default)||o.find(M=>M.client===C.target.value)),children:m.map(([C,M])=>h.jsx("option",{value:C,children:M},C))}),h.jsx("select",{value:((b=ao(o,a))==null?void 0:b.id)||"",disabled:e.mode!=="new",onChange:C=>x(o.find(M=>M.id===C.target.value)),children:p.map(C=>h.jsx("option",{value:C.id,children:C.label},C.id))})]}),h.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:v(_!=null&&_.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:C=>c({managedModel:C.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(_==null?void 0:_.models)||[],...a.modelOptions||[]].filter((C,M,L)=>C&&L.indexOf(C)===M).map(C=>h.jsx("option",{value:C},C))}),_!=null&&_.supportsUnsafe?h.jsxs("select",{value:a.permissionPolicy,onChange:C=>c({permissionPolicy:C.target.value}),children:[h.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]}):h.jsx("small",{children:v("fleet-standard-permissions")}),(_==null?void 0:_.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),(_==null?void 0:_.credentialEnv)===!0&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:C=>c({envKey:C.target.value})}),h.jsx("small",{children:v("fleet-custom-secret-help")})]}),S&&h.jsxs("section",{className:"nc-fleet-key","aria-label":v("fleet-key-section"),children:[h.jsxs("div",{className:"nc-fleet-key-head",children:[h.jsx("b",{children:v("fleet-key-section")}),h.jsx("span",{children:v(`fleet-credential-source-${k}`)})]}),h.jsxs("label",{className:"nc-field",children:[v("fleet-key-variable"),h.jsx("input",{value:S,readOnly:!0,"aria-label":v("fleet-key-variable")})]}),h.jsx("small",{children:y.length?v("fleet-key-used-by").replace("{engines}",y.join(", ")):v("fleet-key-used-by-none")}),y.length>0&&h.jsx("small",{children:v("fleet-key-shared-impact").replace("{key}",S).replace("{engines}",y.join(", "))}),h.jsxs("div",{className:"nc-fleet-key-input",children:[h.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":v("fleet-key-value").replace("{key}",S),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:_!=null&&_.authConfigured||e.mode==="edit"?v("fleet-key-blank-keeps"):v("fleet-key-enter"),onChange:C=>c({credentialValue:C.target.value,allowMissingCredential:C.target.value?!1:a.allowMissingCredential})}),h.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>c({credentialReveal:!a.credentialReveal}),children:v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),h.jsx("small",{children:v("fleet-key-local-help")}),e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&h.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[h.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:C=>c({allowMissingCredential:C.target.checked})}),v("fleet-key-create-missing")]}),(_==null?void 0:_.notice)&&h.jsx("small",{className:"nc-fleet-provider-notice",children:v(`fleet-provider-notice-${_.notice}`)})]}),a.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:a.displayName,placeholder:v("fleet-provider-display"),onChange:C=>c({displayName:C.target.value})}),h.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:C=>c({baseUrl:C.target.value})}),((_==null?void 0:_.protocols)||[]).length>1&&h.jsx("select",{value:a.protocol,onChange:C=>c({protocol:C.target.value}),children:_.protocols.map(C=>h.jsx("option",{value:C,children:C},C))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:C=>c({envKey:C.target.value})}),h.jsx("input",{value:a.providerId,placeholder:v("fleet-provider-id"),onChange:C=>c({providerId:C.target.value})})]}),h.jsxs("small",{children:[a.protocol," · ",v("fleet-custom-secret-help")]})]}),h.jsx("small",{children:v("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:a.command,placeholder:v("command-path"),onChange:C=>c({command:C.target.value})}),h.jsx("textarea",{value:a.argsText,placeholder:v("args-lines"),onChange:C=>c({argsText:C.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:a.rc,onChange:C=>c({rc:C.target.checked})})," remote control"]}),h.jsxs("select",{value:a.promptMode,onChange:C=>c({promptMode:C.target.value}),children:[h.jsx("option",{value:"send-keys",children:"send-keys"}),h.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&h.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:C=>c({promptFlag:C.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:C=>c({modelFlag:C.target.value})}),h.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:C=>c({modelValue:C.target.value})})]}),h.jsx("small",{children:v("env-write-only")}),d.map((C,M)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:C.key,disabled:C.configured,placeholder:"ENV_KEY",onChange:L=>{const T=d.slice();T[M]={...C,key:L.target.value},c({envRows:T})}}),h.jsx("input",{type:"password",value:C.value,placeholder:C.configured?"•••••• (unchanged)":"value",onChange:L=>{const T=d.slice();T[M]={...C,value:L.target.value},c({envRows:T})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:d.filter((L,T)=>T!==M)}),children:"×"})]},`${C.key}-${M}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>c({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:i||!a.id||w||a.kind==="custom"&&!a.command||a.kind==="managed"&&(_==null?void 0:_.requiresModel)&&!a.managedModel||a.kind==="managed"&&(_==null?void 0:_.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:v("save")})]})]})}function dE({token:e,route:t,targets:i=[],location:s,setLocation:o,state:a,setState:c,engines:d,busy:m,onSave:p}){const[_,S]=P.useState(null),[y,k]=P.useState(""),w=a.form,x=L=>c({...a,form:{...w,...L}}),b=d.find(L=>L.id===w.engine),C=L=>{var J,H,F;const T=d.find(G=>G.id===L);x({engine:L,model:((J=w.models)==null?void 0:J[L])||((H=T==null?void 0:T.managed)==null?void 0:H.model)||((F=T==null?void 0:T.model)==null?void 0:F.value)||""})},M=async L=>{try{const T=await Av(e,L,t);S(T),x({cwd:T.path}),k("")}catch(T){k(String(T.message||T))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:a.mode==="new"?v("fleet-new-cell"):`${v("edit")} ${w.id}`}),a.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[v("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:L=>{o(L.target.value),x({engine:""})},children:[h.jsx("option",{value:"",children:v("local")}),i.map(L=>h.jsxs("option",{value:L.route.join("/"),disabled:L.status&&L.status!=="up",children:[L.label,L.status&&L.status!=="up"?` · ${v("node-offline")}`:""]},L.route.join("/")))]})]}),h.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:L=>x({id:L.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:w.cwd,placeholder:v("cwd"),onChange:L=>x({cwd:L.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>_?S(null):M(w.cwd),children:v("browse")})]}),_&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:_.path}),h.jsxs("div",{className:"nc-fs-list",children:[_.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>M(_.parent),children:["↑ ",v("fs-parent")]}),(_.dirs||[]).map(L=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>M(`${_.path.replace(/\/$/,"")}/${L}`),children:["📁 ",L]},L))]})]}),y&&h.jsx("div",{className:"nc-err",children:y}),h.jsx("select",{value:w.engine,onChange:L=>C(L.target.value),children:d.map(L=>h.jsx("option",{value:L.id,children:L.label},L.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:L=>x({boot:L.target.checked})})," boot"]}),h.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:v("fleet-model-override"),onChange:L=>x({model:L.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((b==null?void 0:b.availableModels)||[]).map(L=>h.jsx("option",{value:L},L))}),h.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:L=>x({prompt:L.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:m||!w.id||!w.cwd||!w.engine,onClick:p,children:v("save")})]})]})}function kv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:a}){const[c,d]=P.useState(null),[m,p]=P.useState([]),[_,S]=P.useState(""),y=Array.isArray(t)?t.join("/"):"";P.useEffect(()=>{let C=!0;return Wh(e,y?y.split("/"):[]).then(M=>{C&&(p(M.engines||[]),S(""))}).catch(M=>{C&&(p([]),S(String(M.message||M)))}),()=>{C=!1}},[e,y]);const k=i.form,w=C=>s({...i,form:{...k,...C}}),x=async C=>{try{const M=await Av(e,C,t);d(M),w({cwd:M.path})}catch{}},b=!k.id&&k.tmuxSession?k.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):k.id;return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsxs("b",{children:[v("import-as-cell")," · ",k.tmuxSession]}),h.jsx("small",{children:v("import-help")}),h.jsx("input",{value:k.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:k.id,placeholder:v("name"),onChange:C=>w({id:C.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:k.cwd,placeholder:v("cwd"),onChange:C=>w({cwd:C.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?d(null):x(k.cwd),children:v("browse")})]}),c&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:c.path}),h.jsxs("div",{className:"nc-fs-list",children:[c.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>x(c.parent),children:["↑ ",v("fs-parent")]}),(c.dirs||[]).map(C=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>x(`${c.path.replace(/\/$/,"")}/${C}`),children:["📁 ",C]},C))]})]}),h.jsxs("select",{value:k.engine,onChange:C=>w({engine:C.target.value}),children:[h.jsx("option",{value:"",children:v("import-engine-required")}),m.map(C=>h.jsx("option",{value:C.id,children:C.label},C.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!k.boot,onChange:C=>w({boot:C.target.checked})})," boot"]}),(i.err||_)&&h.jsx("div",{className:"nc-err",children:i.err||_}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!k.tmuxSession||!k.engine||!m.length,onClick:a,children:v(b?"import-as-cell":"save")})]})]})}function fE({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[a,c]=P.useState({engines:[],cells:[],managedCatalog:[]}),[d,m]=P.useState({available:!1,capabilities:[]}),[p,_]=P.useState(null),[S,y]=P.useState(null),[k,w]=P.useState(!1),[x,b]=P.useState(""),[C,M]=P.useState(""),[L,T]=P.useState(o),[J,H]=P.useState(!1),[F,G]=P.useState(null),[W,V]=P.useState(null),[X,A]=P.useState(!1),[N,R]=P.useState([]),[O,D]=P.useState(null),[z,B]=P.useState("manage"),te=P.useRef(!1),q=L?L.split("/"):[],j=P.useCallback(async()=>{try{const Q=await pr(e,q);m(Q);try{const ue=await Kh(e,q);H(!!ue.readonlyDefault)}catch{H(!1)}if(Q.provider==="builtin"&&(Q.capabilities||[]).includes("definitions")){const ue=await Wh(e,q),K=new Map((Q.engines||[]).map(me=>[me.id,me]));if(ue.engines=(ue.engines||[]).map(me=>{var be;return{...me,availableModels:((be=K.get(me.id))==null?void 0:be.models)||[]}}),c(ue),(Q.capabilities||[]).includes("credentials"))try{R((await Fw(e,q)).credentials||[])}catch{R([])}else R([])}}catch(Q){b(String(Q.message||Q))}},[e,L]);P.useEffect(()=>{j();const Q=setInterval(j,5e3);return()=>clearInterval(Q)},[j]);const $=new Set((d.cells||[]).filter(Q=>Q.active).map(Q=>Q.cell)),re=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),le=(d.capabilities||[]).includes("restore");P.useEffect(()=>{!s||te.current||!re||!a.engines.length||(te.current=!0,y({mode:"new",form:wv(a.engines[0].id)}))},[s,re,a.engines]);const se=async Q=>{w(!0),b(""),M("");try{await Q(),await j()}catch(ue){b(String(ue.message||ue))}w(!1)},pe=()=>se(async()=>{var De;const Q=p.mode==="new",ue=p.form,K=a.managedCatalog||[],me=ue.kind==="managed"?ao(K,ue):null,be=typeof(me==null?void 0:me.credentialEnv)=="string"?me.credentialEnv:"",Pe=be&&ue.credentialValue||"",he=cE(ue,Q,K);!Q&&p.form.kind==="custom"&&!p.form.modelFlag&&(he.model=null),!Q&&p.form.kind==="custom"&&p.form.promptMode!=="flag"&&(he.promptFlag=null);let Ee;if(Q)Ee=await $w(e,he,q);else{const fe=p.original,Be=new Set(p.form.envRows.filter(ke=>!ke.remove).map(ke=>ke.key)),je=(fe.envKeys||[]).filter(ke=>!Be.has(ke)),oe=Object.fromEntries(p.form.envRows.filter(ke=>!ke.remove&&ke.key&&(!ke.configured||ke.value!=="")).map(ke=>[ke.key,ke.value]));Ee=await Ww(e,fe.id,he,p.form.kind==="custom"?{set:oe,remove:je}:void 0,q)}let xe=null;if(be&&Pe)try{xe=await cm(e,be,Pe,q),R(xe.credentials||[])}catch{throw await j(),Q&&_({mode:"edit",original:{...he,id:ue.id},form:{...ue,credentialReveal:!1}}),new Error(v(Q?"fleet-key-partial-create":"fleet-key-partial-edit"))}await j(),_(null),M(v("fleet-saved"));const $e=((De=((xe==null?void 0:xe.credentials)||[]).find(fe=>fe.envKey===be))==null?void 0:De.activeCells)||[],Je=[...new Set([...(Ee==null?void 0:Ee.activeCells)||[],...$e])];if(Je.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",Je.join(", "))))for(const fe of Je)await Qs(e,fe,q)}),ye=()=>se(async()=>{const Q=S.mode==="new",ue=S.form,K={...Q?{id:ue.id}:{},cwd:ue.cwd,engine:ue.engine,boot:!!ue.boot};Q?(ue.model&&(K.model=ue.model),ue.prompt&&(K.prompt=ue.prompt)):(K.model=ue.model||null,K.prompt=ue.prompt||null);const me=Q?await Kw(e,K,q):await qw(e,S.original.id,K,q),be=Q?ue.id:S.original.id;y(null),M(v("fleet-saved")),!Q&&(me!=null&&me.active)&&window.confirm(v("fleet-restart-confirm").replace("{cells}",be))&&await Qs(e,be,q)}),ce=t||J,Ce=Q=>N.find(ue=>{var K;return(K=ue.engines)==null?void 0:K.includes(Q.id)})||null,Oe=()=>se(async()=>{var K;const Q=await cm(e,O.envKey,O.value,q);R(Q.credentials||[]),D(null),M(v("fleet-credential-saved"));const ue=((K=(Q.credentials||[]).find(me=>me.envKey===O.envKey))==null?void 0:K.activeCells)||[];if(ue.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",ue.join(", "))))for(const me of ue)await Qs(e,me,q)}),Ze=Q=>se(async()=>{if(!window.confirm(v("fleet-credential-remove-confirm").replace("{key}",Q.envKey)))return;const ue=await Hw(e,Q.envKey,q);R(ue.credentials||[]),M(v("fleet-credential-removed"))}),Ve=Q=>G({...Q,route:Array.isArray(Q==null?void 0:Q.route)?Q.route:q}),Ae=async Q=>{if(!F)return;const ue=F.cell||F.id,K=Array.isArray(F.route)?F.route:q;Q.action==="up"?await $h(e,{cell:ue,boot:!!Q.boot,...Q.engine?{engine:Q.engine}:{},...Q.model!==void 0?{model:Q.model}:{},...Q.permissionPolicy?{permissionPolicy:Q.permissionPolicy}:{}},K):await $a(e,{cell:ue,boot:!!Q.boot},K)},ot=(Q,ue)=>{b(""),V({mode:"new",route:Array.isArray(ue)?ue:q,form:{tmuxSession:Q.name,id:"",engine:"",cwd:"",boot:!1},err:""})},Et=()=>se(async()=>{const Q=W.form;if(!Q.engine){V({...W,err:v("import-engine-required")});return}await Vw(e,{tmuxSession:Q.tmuxSession,id:Q.id||void 0,engine:Q.engine,cwd:Q.cwd||void 0,boot:!!Q.boot},Q.route||q),V(null),M(v("fleet-saved"))}),ie=({engineRows:Q=[],cellRows:ue=[]})=>se(async()=>{const K=Q.filter(De=>De.selected),me=K.map(De=>Ey(De.engine));if(me.some(De=>!De))throw new Error(v("fleet-backup-invalid-engine"));const be=K.filter(De=>De.exists).map(De=>De.engine.id);if(be.length&&!window.confirm(v("fleet-backup-confirm-engine-overwrite").replace("{engines}",be.join(", "))))return;const Pe=[...new Set([...a.engines.map(De=>De.id),...me.map(De=>De.id)])],he=[];for(const De of ue.filter(fe=>fe.selected)){const fe=sE(De.cell,De.engine,Pe);if(!fe)throw new Error(`${De.cell.id}: ${v("fleet-backup-engine-missing")}`);he.push(fe)}const Ee=ue.filter(De=>De.selected&&De.exists).map(De=>De.cell.id);if(Ee.length&&!window.confirm(v("fleet-backup-confirm-overwrite").replace("{cells}",Ee.join(", "))))return;const xe=me.length?await Xw(e,me,be.length>0,q):{needsRestart:[]},$e=he.length?await Yw(e,he,q):{needsRestart:[]},Je=[...new Set([...xe.needsRestart||[],...$e.needsRestart||[]])];A(!1),M(`${v("fleet-backup-restored").replace("{n}",String(he.length))}${me.length?` · ${me.length} ${v("fleet-engines").toLowerCase()}`:""}${Je.length?` · ${v("fleet-backup-needs-restart").replace("{cells}",Je.join(", "))}`:""}`)}),ae=h.jsxs("label",{className:"nc-field",children:[v("location"),h.jsxs("select",{value:L,onChange:Q=>{T(Q.target.value),_(null),y(null),b(""),M(""),H(!1),m({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),R([]),D(null)},children:[h.jsx("option",{value:"",children:v("local")}),i.map(Q=>h.jsxs("option",{value:Q.route.join("/"),disabled:Q.status&&Q.status!=="up",children:[Q.label,Q.status&&Q.status!=="up"?` · ${v("node-offline")}`:""]},Q.route.join("/")))]})]}),ze=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":v("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":z==="manage",className:`nc-set-tabbtn${z==="manage"?" on":""}`,onClick:()=>B("manage"),children:v("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":z==="overview",className:`nc-set-tabbtn${z==="overview"?" on":""}`,onClick:()=>B("overview"),children:v("fleet-network-overview")})]});return re?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ze,z==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),h.jsx(bv,{token:e,targets:i,readonly:t,onPower:Ve,onImport:ot})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:v("fleet-manage-help")}),ae,h.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:ce||k,onClick:()=>{b(""),A(!0)},children:v("fleet-backup")}),h.jsx("small",{children:v("fleet-backup-help")})]}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:v("fleet-cells")}),h.jsx("span",{className:"nc-fleet-head-actions",children:h.jsxs("button",{className:"nc-btn primary",disabled:ce||k||!a.engines.length,onClick:()=>{var Q;b(""),y({mode:"new",form:wv((Q=a.engines[0])==null?void 0:Q.id)})},children:["+ ",v("add")]})})]}),a.cells.map(Q=>{const ue=$.has(Q.id),K=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:Q.id}),h.jsxs("small",{children:[Q.engine," · ",Q.cwd,ue?` · ${v("service-active")}`:` · ${v("cell-off")}`]})]}),h.jsxs("span",{children:[ue&&K.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||k,onClick:()=>se(()=>$a(e,{cell:Q.id},q)),children:v("stop")}),!ue&&K.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:ce||k,onClick:()=>Ve({cell:Q.id,id:Q.id,engine:Q.engine,model:Q.model,models:Q.models,permissionPolicies:Q.permissionPolicies,active:!1,boot:Q.boot}),children:v("start")}),ue&&K.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||k,onClick:()=>se(()=>Qs(e,Q.id,q)),children:v("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||k,onClick:()=>{b(""),y({mode:"edit",original:Q,form:{...Q}})},children:v("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||k,onClick:()=>se(async()=>{window.confirm(v("fleet-remove-cell").replace("{id}",Q.id))&&await jv(e,Q.id,!0,q)}),children:"×"})]})]},Q.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:v("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:ce||k,onClick:()=>{b(""),_({mode:"new",form:oE()})},children:["+ ",v("add")]})]}),a.engines.map(Q=>{var K,me;const ue=Ce(Q);return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:Q.label}),h.jsx("small",{children:Q.managed?`${Q.id} · ${Q.managed.client} / ${Q.managed.provider} · ${(K=Q.managedInfo)!=null&&K.configured?v("fleet-ready"):((me=Q.managedInfo)==null?void 0:me.reason)||v("fleet-not-ready")}`:`${Q.id} · ${Q.command}`}),ue&&h.jsxs("small",{children:[ue.envKey," · ",v(`fleet-credential-source-${ue.source||"missing"}`)]})]}),h.jsxs("span",{children:[ue&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||k,onClick:()=>{b(""),D({envKey:ue.envKey,value:""})},children:ue.configured?v("fleet-credential-change"):v("fleet-credential-set")}),(ue==null?void 0:ue.source)==="local"&&h.jsx("button",{className:"nc-btn danger",disabled:ce||k,onClick:()=>Ze(ue),children:v("fleet-credential-forget")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||k,onClick:()=>{b(""),_({mode:"edit",original:Q,form:lE(Q)})},children:v("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||k,onClick:()=>se(async()=>{window.confirm(v("fleet-remove-engine").replace("{id}",Q.id))&&await Uw(e,Q.id,q)}),children:"×"})]})]},Q.id)})]}),p&&h.jsx(Kr,{onClose:()=>_(null),label:v("fleet-new-engine"),error:x,children:h.jsx(hE,{state:p,setState:_,busy:k,onSave:pe,catalog:a.managedCatalog||[]})}),S&&h.jsx(Kr,{onClose:()=>y(null),label:v("fleet-new-cell"),error:x,children:h.jsx(dE,{token:e,route:q,targets:i,location:L,setLocation:T,state:S,setState:y,engines:a.engines,busy:k,onSave:ye})}),C&&h.jsx("div",{className:"nc-set-note",children:C}),x&&h.jsx("div",{className:"nc-err",children:x}),X&&h.jsx(Kr,{onClose:()=>A(!1),label:v("fleet-backup"),error:x,children:h.jsx(uE,{cells:a.cells,engines:a.engines,busy:k,canRestore:le,onRestore:ie,onClose:()=>A(!1)})}),O&&h.jsx(Kr,{onClose:()=>D(null),label:v("fleet-credential-title"),error:x,children:h.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[h.jsx("b",{children:v("fleet-credential-title")}),h.jsx("small",{children:v("fleet-credential-help")}),h.jsxs("label",{className:"nc-field",children:[O.envKey,h.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:O.value,onChange:Q=>D({...O,value:Q.target.value})})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>D(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:k||!O.value,onClick:Oe,children:v("save")})]})]})}),W&&h.jsx(Kr,{onClose:()=>V(null),label:v("import-as-cell"),error:x,children:h.jsx(kv,{token:e,route:W.route||q,state:W,setState:V,busy:k,onSave:Et})}),F&&h.jsx(Wa,{cell:F,token:e,route:Array.isArray(F.route)?F.route:q,onConfirm:async Q=>{try{await Ae(Q)}finally{await j()}},onClose:()=>G(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[ze,z==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),h.jsx(bv,{token:e,targets:i,readonly:t,onPower:Ve,onImport:ot})]}):h.jsxs(h.Fragment,{children:[ae,h.jsx("div",{className:"nc-set-info",children:v("fleet-editor-unavailable")})]}),x&&h.jsx("div",{className:"nc-err",children:x}),W&&h.jsx(Kr,{onClose:()=>V(null),label:v("import-as-cell"),error:x,children:h.jsx(kv,{token:e,route:W.route||q,state:W,setState:V,busy:k,onSave:Et})}),F&&h.jsx(Wa,{cell:F,token:e,route:Array.isArray(F.route)?F.route:q,onConfirm:async Q=>{try{await Ae(Q)}finally{await j()}},onClose:()=>G(null)})]})}function pE({text:e}){const[t,i]=P.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return h.jsxs("div",{className:"nc-set-copyline",children:[h.jsx("code",{children:e}),h.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[h.jsx(tt,{name:"copy",size:14})," ",v(t?"copied":"copy")]})]})}function mE({value:e}){const[t,i]=P.useState("");return P.useEffect(()=>{let s=!0;return yx.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function gE({token:e,nodes:t,settings:i,readonly:s,refresh:o}){const[a,c]=P.useState(null),[d,m]=P.useState(null),[p,_]=P.useState({}),[S,y]=P.useState(null),[k,w]=P.useState({ssh:"",sshPort:"",name:""}),[x,b]=P.useState(""),[C,M]=P.useState(""),[L,T]=P.useState(""),[J,H]=P.useState(!1),F=Date.now(),G=i&&i.deviceName||"",W=(t||[]).filter(D=>D&&D.direction==="outbound"&&D.name&&D.ssh),V=W.find(D=>D.name===x)||W[0]||null,X=W.find(D=>D.name===C)||W[0]||null,A=X?pv(X.tunnel,F):null,N=async(D,z)=>{c(null),m(`${D}:${z}`);try{const B=await qh(e,D,z);z==="test"&&_(te=>({...te,[D]:B})),await o()}catch(B){c(`${D}: ${String(B.message||B)}`)}m(null)},R=async D=>{if(window.confirm(v("node-remove-confirm").replace("{name}",D))){c(null),m(`${D}:remove`);try{await e0(e,D),await o()}catch(z){c(`${D}: ${String(z.message||z)}`)}m(null)}},O=async()=>{if(c(null),V){const B=fv({name:V.name,ssh:V.ssh,sshPort:V.sshPort||""});if(!B.ok){c(v(B.error));return}m("invite");try{y(await hm(e,{ssh:B.value.ssh,...B.value.sshPort?{sshPort:B.value.sshPort}:{}},[V.name]))}catch(te){c(String(te.message||te))}m(null);return}const D=Gr(k.name||L||G||"NexusCrew"),z=fv({name:D,ssh:k.ssh,sshPort:k.sshPort});if(!z.ok){c(v(z.error));return}m("invite");try{y(await hm(e,{...L||G?{label:L||G}:{},name:D,ssh:z.value.ssh,...z.value.sshPort?{sshPort:z.value.sshPort}:{}}))}catch(B){c(String(B.message||B))}m(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(yy,{token:e,deviceDefault:G,readonly:s,onSuccess:o}),X&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:v("share-local-heading")}),W.length>1&&h.jsxs("label",{className:"nc-field",children:[v("share-local-hub"),h.jsx("select",{value:X.name,disabled:s||!!d,onChange:D=>M(D.target.value),children:W.map(D=>h.jsx("option",{value:D.name,children:D.label||D.name},D.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:X.shared===!0,disabled:s||!!d||!(A!=null&&A.up)&&!X.shared,onChange:async D=>{c(null),m(`${X.name}:share`);try{await t0(e,X.name,D.target.checked),await o()}catch(z){c(`${X.name}: ${String(z.message||z)}`)}m(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:v("share-local-through").replace("{device}",G||v("local")).replace("{hub}",X.label||X.name)}),h.jsx("small",{children:v(X.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${X.shared&&(A!=null&&A.up)?" ok":""}`,children:X.shared?v("share-local-active"):v("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:v("no-nodes")}),(t||[]).map(D=>{var te,q,j,$,re;const z=pv(D.tunnel,F),B=p[D.name];return h.jsxs("div",{className:"nc-set-node",children:[h.jsxs("div",{className:"nc-set-node-head",children:[h.jsx("span",{className:`nc-dot ${z.up?"on":""}`}),h.jsx("b",{children:D.label||D.name}),h.jsxs("small",{children:[D.name,D.direction==="outbound"?` · SSH ${D.ssh||""}`:` · ${v("node-connected-client")}`,(te=D.tunnel)!=null&&te.transport?` · ${D.tunnel.transport} ${v("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${z.up?" up":""}`,children:[v(z.label),z.since?` · ${z.since}`:""]})]}),D.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:v(D.shared?"peer-shared":"peer-private")}),D.direction==="inbound"&&D.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:D.visibility||"network",disabled:s||!!d,onChange:async le=>{m(`${D.name}:visibility`);try{await dm(e,D.name,le.target.value),await o()}catch(se){c(String(se.message||se))}m(null)},children:[h.jsx("option",{value:"network",children:v("visibility-network")}),h.jsx("option",{value:"relay-only",children:v("visibility-relay")}),h.jsx("option",{value:"selected",children:v("visibility-selected")})]}),D.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(le=>le.name!==D.name&&le.nodeId).map(le=>{const se=(D.selected||[]).includes(le.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:se,disabled:s||!!d,onChange:async pe=>{const ye=pe.target.checked?[...D.selected||[],le.nodeId]:(D.selected||[]).filter(ce=>ce!==le.nodeId);m(`${D.name}:visibility`);try{await dm(e,D.name,"selected",ye),await o()}catch(ce){c(String(ce.message||ce))}m(null)}})," ",le.label||le.name]},le.nodeId)})})]}),h.jsxs("div",{className:"nc-set-node-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:async()=>{const le=window.prompt(v("node-display-label"),D.label||D.name);if(le!=null){if(!Ah(le)){c(v("err-label"));return}m(`${D.name}:label`);try{await Zw(e,D.name,le),await o()}catch(se){c(String(se.message||se))}m(null)}},children:v("edit")}),((q=D.health)==null?void 0:q.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>N(D.name,"test"),children:v("node-test")}),((j=D.health)==null?void 0:j.managed)!==!1&&(z.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>N(D.name,"down"),children:v("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>N(D.name,"up"),children:v("tunnel-start")})),(($=D.health)==null?void 0:$.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>N(D.name,"restart"),children:v("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:v(s?"settings-readonly":"terminate"),onClick:()=>R(D.name),children:h.jsx(tt,{name:"trash",size:14})})]}),((re=D.health)==null?void 0:re.detail)&&h.jsx("div",{className:`nc-set-test${D.health.status==="healthy"?" ok":D.health.status==="passive"?"":" ko"}`,children:D.health.detail}),B&&h.jsxs("div",{className:`nc-set-test${B.ok?" ok":" ko"}`,children:[B.result,B.detail?` — ${B.detail}`:""]})]},D.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:v("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:v(V?"invite-network-hint":"invite-v2-hint")}),V?h.jsxs(h.Fragment,{children:[W.length>1&&h.jsxs("label",{className:"nc-field",children:[v("invite-network-label"),h.jsx("select",{value:V.name,disabled:s||!!d,onChange:D=>{b(D.target.value),y(null)},children:W.map(D=>h.jsx("option",{value:D.name,children:D.label||D.name},D.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[v("invite-network-via"),": ",h.jsx("b",{children:V.label||V.name})," · ",V.ssh,V.sshPort?`:${V.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:v("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[v("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:k.ssh,disabled:s,onChange:D=>w({...k,ssh:D.target.value})}),h.jsx("small",{className:"nc-set-hint",children:v("invite-endpoint-needed")})]}),!V&&J&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:k.sshPort,disabled:s,onChange:D=>w({...k,sshPort:D.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[v("device-name-label"),h.jsx("input",{placeholder:G||"NexusCrew",value:L,disabled:s,onChange:D=>T(D.target.value)}),h.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[v("node-name-label"),h.jsx("input",{placeholder:Gr(L||G||v("node-name-ph")),value:k.name,disabled:s,onChange:D=>w({...k,name:D.target.value?Gr(D.target.value):""})})]})]}),h.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[h.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!d||!V&&!k.ssh.trim(),onClick:O,children:v("create-pairing-link")}),!V&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>H(D=>!D),children:[J?"▾":"▸"," ",v("pair-advanced")]})]}),S&&h.jsxs(h.Fragment,{children:[h.jsx(mE,{value:S.pairingUrl}),h.jsx(pE,{text:S.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:v("invite-next-steps")})]})]}),a&&h.jsx("div",{className:"nc-err",children:a})]})}function vE({token:e,readonly:t}){const[i,s]=P.useState("idle"),[o,a]=P.useState(!1),[c,d]=P.useState(null);P.useEffect(()=>{let p=!1;return $x().then(_=>{p||s(_)}),()=>{p=!0}},[]);const m=async()=>{d(null),a(!0);try{i==="subscribed"?(await Ux(e),s("idle")):(await Wx(e),s("subscribed"))}catch(p){const _=String(p.message||p);_==="push-denied"?(s("denied"),d(v("push-denied"))):_==="push-unsupported"?(s("unsupported"),d(v("push-unsupported"))):d(_)}a(!1)};return i==="unsupported"?h.jsx("div",{className:"nc-set-info",children:v("push-unsupported")}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||i==="denied",title:t?v("settings-readonly"):"",onClick:m,children:v(i==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:v(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),c&&h.jsx("div",{className:"nc-err",children:c})]})}function _E({token:e,settings:t,readonly:i,refresh:s}){const[o,a]=P.useState(null),[c,d]=P.useState(null),[m,p]=P.useState(!1),[_,S]=P.useState(!1),[y,k]=P.useState(null),[w,x]=P.useState(!0);P.useEffect(()=>{k(t&&t.update||null),x(!t||t.autoUpdate!==!1)},[t]);const b=async()=>{a(null),d(null),S(!0);try{const F=await Qw(e);d(F.note||"ok"),p(!1)}catch(F){a(String(F.message||F))}S(!1)},C=async()=>{a(null),d(null),S(!0);try{const F=await i0(e);d(`${F.note||"ok"}${F.target?` (${F.target})`:""}`)}catch(F){a(String(F.message||F))}S(!1)},M=async F=>{a(null),d(null),S(!0);try{await zv(e,{autoUpdate:F}),x(F),s&&await s()}catch(G){a(String(G.message||G))}S(!1)},L=async()=>{a(null),d(null),S(!0);try{k(await n0(e))}catch(F){a(String(F.message||F))}S(!1)},T=async()=>{a(null),d(null),S(!0);try{const F=await r0(e);k(F),d(v("npm-update-restarting"))}catch(F){a(String(F.message||F))}S(!1)},J=()=>{window.confirm(v("composer-clear-confirm"))&&(a(null),EC()?(window.dispatchEvent(new Event(Dh)),d(v("composer-clear-done"))):a(v("composer-clear-failed")))},H=t&&t.service;return h.jsxs("div",{className:"nc-set-tab",children:[t&&h.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,h.jsx("br",{}),H&&H.installed?v("service-installed"):v("service-missing"),H&&H.installed?` · ${H.active?v("service-active"):v("service-inactive")}`:"",H?` · boot ${H.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?v("settings-readonly"):"",onClick:()=>{a(null),d(null),p(!0)},children:v("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?v("settings-readonly"):"",onClick:C,children:v("service-regenerate")})]}),h.jsxs("div",{className:"nc-set-form nc-update-settings",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:w,disabled:i||_||y&&!y.supported,onChange:F=>M(F.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:v("npm-auto-update")}),h.jsx("small",{children:v("npm-auto-update-help")})]})]}),y&&h.jsxs("div",{className:"nc-set-info",children:[v("npm-update-current")," v",y.current,y.latest?` · ${v("npm-update-latest")} v${y.latest}`:""," · ",v(`npm-update-${y.supported?y.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_||!y||!y.supported,onClick:L,children:v("npm-update-check")}),y&&y.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||_||y.phase==="installing",onClick:T,children:v("npm-update-install")})]}),y&&y.lastError&&h.jsx("div",{className:"nc-err",children:y.lastError})]}),h.jsx(vE,{token:e,readonly:i}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:v("composer-clear-data")}),h.jsx("small",{className:"nc-set-hint",children:v("composer-clear-data-help")}),h.jsx("div",{className:"nc-set-row",children:h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:J,children:v("composer-clear-data")})})]}),m&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:v("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>p(!1),children:v("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:_,onClick:b,children:v("confirm")})]})]}),c&&h.jsx("div",{className:"nc-set-note",children:c}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function yE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){Si();const[a,c]=P.useState(i),[d,m]=P.useState(null),[p,_]=P.useState([]),[S,y]=P.useState(!1),[k,w]=P.useState(null),x=Yh(e),b=P.useCallback(async()=>{try{const C=await Iv(e);m(C),w(null)}catch(C){w(String(C.message||C))}try{const C=await Bv(e);_(C.nodes||[])}catch(C){w(String(C.message||C))}},[e]);return P.useEffect(()=>{b();const C=setInterval(b,5e3);return()=>clearInterval(C)},[b]),P.useEffect(()=>{let C=!1;return zt("/api/config",e).then(M=>M.json()).then(M=>{C||y(!!M.readonlyDefault)}).catch(()=>{}),()=>{C=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:C=>C.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(tt,{name:"gear",size:18}),h.jsx("b",{children:v("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:v("close"),children:h.jsx(tt,{name:"x",size:18})})]}),S&&h.jsx("div",{className:"nc-set-readonly",children:v("settings-readonly")}),k&&h.jsx("div",{className:"nc-err",children:k}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(C=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${a===C?" on":""}`,onClick:()=>c(C),children:v(`tab-${C}`)},C))}),h.jsxs("div",{className:"nc-set-body",children:[a==="nodes"&&h.jsx(gE,{token:e,nodes:p,settings:d,readonly:S,refresh:b}),a==="fleet"&&h.jsx(fE,{token:e,readonly:S,startNewCell:o,initialLocation:s,targets:x.map(C=>({route:C.route,label:C.label||C.name,status:C.status}))}),a==="system"&&h.jsx(_E,{token:e,settings:d,readonly:S,refresh:b})]})]})})}function SE({token:e,initialPair:t,onPairDone:i,onDone:s}){Si();const[o,a]=P.useState(t?"pair":"welcome"),[c,d]=P.useState(!1),[m,p]=P.useState(null),_=async()=>{d(!0),p(null);try{await zv(e,{wizardDone:!0}),i&&i(),s()}catch(S){p(String(S.message||S)),d(!1)}};return h.jsx("div",{className:"nc-wiz-overlay",children:h.jsxs("div",{className:"nc-wiz",children:[h.jsxs("div",{className:"nc-wiz-head",children:[h.jsx("b",{children:v("wizard-title")}),h.jsx("small",{children:v("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:v("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:_,children:v("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:()=>a("pair"),children:v("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(yy,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{i&&i(),a("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:()=>{i&&i(),a("welcome")},children:v("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:v("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:_,children:v("finish")})})]}),m&&h.jsx("div",{className:"nc-err",children:m})]})})}function wE(e,t){if(typeof EventSource>"u"||!e)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return i.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{i.close()}catch{}}}const bE=6e3,kE=12e3;function CE({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:v("close"),children:h.jsx(tt,{name:"x",size:14})})]})}function xE({ask:e,token:t,onAnswered:i}){const[s,o]=P.useState(""),[a,c]=P.useState(!1),[d,m]=P.useState(null),p=async _=>{const S=String(_||"").trim();if(!(!S||a)){m(null),c(!0);try{await o0(t,e.id,S),i(e.id)}catch(y){m(String(y.message||y))}c(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(_=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:a,onClick:()=>p(_),children:_},_))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:v("ask-reply-ph"),value:s,disabled:a,onChange:_=>o(_.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:a||!s.trim(),onClick:()=>p(s),children:v("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function EE({token:e}){Si();const[t,i]=P.useState([]),[s,o]=P.useState([]),[a,c]=P.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=P.useRef(0),m=P.useCallback(S=>{i(y=>y.filter(k=>k.key!==S))},[]),p=P.useCallback(S=>{const y=`t${d.current+=1}`;i(k=>[...k.slice(-3),{...S,key:y}]),setTimeout(()=>m(y),S.urgency==="high"?kE:bE)},[m]);P.useEffect(()=>{if(!e)return;let S=!1;s0(e).then(k=>{S||o(k.asks||[])}).catch(()=>{});const y=wE(e,k=>{k.type==="notify"?p(k):k.type==="ask"&&k.ask&&k.ask.id?o(w=>w.some(x=>x.id===k.ask.id)?w:[...w,k.ask]):k.type==="ask-answered"&&k.id&&o(w=>w.filter(x=>x.id!==k.id))});return()=>{S=!0,y()}},[e,p]);const _=S=>o(y=>y.filter(k=>k.id!==S));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(S=>h.jsx(CE,{n:S,onClose:()=>m(S.key)},S.key))}),s.length>0&&!a&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>c(!0),title:v("asks-title"),children:["? ",h.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&a&&h.jsxs("div",{className:"nc-ask-panel",children:[h.jsxs("div",{className:"nc-ask-panel-head",children:[h.jsx("b",{children:v("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:s.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>c(!1),title:v("close"),children:h.jsx(tt,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(S=>h.jsx(xE,{ask:S,token:e,onAnswered:_},S.id))})]})]})}const Hu=e=>Qi(ur(e)).length===0,$u=e=>Array.isArray(e)?e.join("/"):"";function NE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Mi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),i.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return i.sort((s,o)=>s.label.localeCompare(o.label))}function Gs(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function rr(e,t,i,s=!1,o=!0){const a=t.instanceId;return{...e,id:Xr(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:Lh(e.layout,a,i)}}function RE(e,t,i,s,o=[]){const[a,c]=P.useState([]),[d,m]=P.useState(!1),[p,_]=P.useState("idle"),[S,y]=P.useState(""),[k,w]=P.useState(""),x=P.useRef([]),b=P.useRef([]),C=P.useRef(""),M=P.useRef(t),L=P.useRef(i),T=P.useRef(!1),J=P.useRef(!0),H=P.useRef(""),F=P.useMemo(()=>NE(o),[o]),G=F.map(q=>`${q.instanceId}:${$u(q.route)}:${q.status}:${q.label}`).join("|");b.current=F,L.current=i,M.current=t,x.current=a;const W=P.useCallback(q=>jh(q.layout,C.current,b.current),[]),V=P.useCallback((q,j=!0,$=M.current)=>{const re=Ag(q,ja()),le=x.current.some(pe=>pe.id===$);x.current=re,c(re);const se=re.find(pe=>pe.id===$);if(j&&se){J.current=!0;const pe=W(se);s(pe),se.local&&YC(se.name,pe)}else le&&!se&&(J.current=!0,s(Yr()),y("deck non più condiviso dal nodo owner"));UC(re.filter(pe=>pe.local).map(pe=>pe.name))},[s,W]),X=P.useCallback(async q=>{let j=await Ca(e);const $=j.decks.find(re=>re.name==="main");if(j.decks.length===1&&$&&$.revision===0&&Hu($.layout)){const re=WC(),le=ur(Th("main")||Yr());if(!Hu(le)){const se=Lh(le,q,[]);j.decks[0]=await xa(e,"main",se,0,[])}for(const se of re.filter(pe=>pe!=="main"))try{let pe=await fm(e,se,[]);const ye=ur(Th(se)||Yr());Hu(ye)||(pe=await xa(e,se,Lh(ye,q,[]),pe.revision,[]))}catch{}j=await Ca(e)}return j},[e]),A=P.useCallback(async({migrate:q=!1}={})=>{const j=await Kh(e,[]),$=Mi.test(String(j.instanceId||""))?j.instanceId:"";if(!$)throw new Error("instanceId locale non disponibile");C.current=$,w($);const[re,le]=await Promise.all([q?X($):Ca(e),um(e,[]).catch(()=>({nodes:[]}))]),se={instanceId:$,route:[],label:"Local"},pe=re.decks.map(ce=>rr(ce,se,le.nodes,!0,!0)),ye=x.current;return await Promise.all(b.current.map(async ce=>{if(ce.status!=="up"){pe.push(...ye.filter(Ce=>!Ce.local&&Ce.ownerId===ce.instanceId).map(Ce=>({...Ce,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})));return}try{const[Ce,Oe]=await Promise.all([Ca(e,ce.route),um(e,ce.route).catch(()=>({nodes:[]}))]);pe.push(...Ce.decks.map(Ze=>rr(Ze,ce,Oe.nodes,!1,!0)))}catch{pe.push(...ye.filter(Oe=>!Oe.local&&Oe.ownerId===ce.instanceId).map(Oe=>({...Oe,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})))}})),pe.sort((ce,Ce)=>ce.local===Ce.local?ce.ownerLabel.localeCompare(Ce.ownerLabel)||(ce.name==="main"?-1:Ce.name==="main"?1:ce.name.localeCompare(Ce.name)):ce.local?-1:1),pe},[e,X,G]);P.useEffect(()=>{if(!e)return;let q=!1;const j=H.current!==e;return H.current=e,A({migrate:j}).then($=>{if(q)return;const re=x.current.find(pe=>pe.id===M.current),le=$.find(pe=>pe.id===M.current),se=le&&(!re||le.revision>re.revision||re.available!==le.available||$u(re.ownerRoute)!==$u(le.ownerRoute));V($,j||!!se&&!T.current),m(!0),le&&y("")}).catch($=>{q||(m(!0),y(String($.message||$)))}),()=>{q=!0}},[V,A,G,e]);const N=P.useCallback(async(q=M.current)=>{if(!d||!T.current)return!0;const j=x.current.find($=>$.id===q);if(!j)return y(`deck inesistente: ${q}`),!1;if(j.available===!1)return y(`nodo owner offline: ${j.ownerLabel}`),!1;_("saving");try{const $=jg(ur(L.current),j.ownerId,j.ownerTopology),re=await xa(e,j.name,$,j.revision,j.ownerRoute),le=rr(re,Gs(j),j.ownerTopology,j.local,!0);return V(x.current.map(se=>se.id===q?le:se),!1),T.current=!1,_("saved"),y(""),setTimeout(()=>_("idle"),1500),!0}catch($){if(_("error"),y(String($.message||$)),$.status===409&&$.data&&$.data.current){const re=x.current.find(se=>se.id===q),le=rr($.data.current,Gs(re),re.ownerTopology,re.local,!0);V(x.current.map(se=>se.id===q?le:se),!1)}return!1}},[d,e,V]);return P.useEffect(()=>{if(!d)return;if(J.current){J.current=!1;return}T.current=!0,_("saving");const q=setTimeout(N,650);return()=>clearTimeout(q)},[i,d,N]),P.useEffect(()=>{if(!d)return;const q=setInterval(async()=>{try{const j=await A(),$=x.current.find(se=>se.id===M.current),re=j.find(se=>se.id===M.current),le=re&&(!$||re.revision>$.revision||$.available!==re.available);V(j,le&&!T.current)}catch{}},5e3);return()=>clearInterval(q)},[d,A,V]),{decks:a,records:a,localNodeId:k,ready:d,saveState:p,error:S,setError:y,saveNow:N,select:async q=>{if(T.current&&!await N(M.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const j=x.current.find($=>$.id===q);if(!j)throw new Error(`deck inesistente: ${q}`);return T.current=!1,J.current=!0,W(j)},add:async(q,j=null)=>{const $=j===hn?x.current.find(se=>se.local):j?x.current.find(se=>se.ownerId===j):null;if(!$||$.available===!1)throw new Error("nodo owner non disponibile");const re=await fm(e,q,$.ownerRoute),le=rr(re,Gs($),$.ownerTopology,$.local,!0);return V([...x.current,le],!1),le},rename:async(q,j)=>{const $=x.current.find(ye=>ye.id===q);if(!$)throw new Error("deck inesistente");if(q===M.current&&T.current&&!await N(q))throw new Error(`salvataggio di "${$.name}" fallito: rinomina annullata`);const re=x.current.find(ye=>ye.id===q);if(!re)throw new Error("deck inesistente");const le=await a0(e,re.name,j,re.revision,re.ownerRoute),se=rr(le,Gs(re),re.ownerTopology,re.local,!0),pe=re.local?hn:re.ownerId;return vu(qC(ja(),pe,q,se.id)),V(x.current.map(ye=>ye.id===q?se:ye),!1),se},remove:async q=>{const j=x.current.find(re=>re.id===q);if(!j)throw new Error("deck inesistente");q===M.current&&(T.current=!1),await l0(e,j.name,j.revision,j.ownerRoute);const $=j.local?hn:j.ownerId;vu(VC(ja(),$,q)),V(x.current.filter(re=>re.id!==q),!1)},reorder:(q,j)=>{const $=x.current.find(ce=>ce.id===q),re=x.current.find(ce=>ce.id===j);if(!$||!re)return!1;const le=$.local?hn:$.ownerId,se=re.local?hn:re.ownerId;if(le!==se)return!1;const pe=x.current.filter(ce=>(ce.local?hn:ce.ownerId)===le).map(ce=>ce.id),ye=vu(KC(ja(),le,q,j,pe));return V(Ag(x.current,ye),!1),!0},addTileTo:async(q,j)=>{const $=x.current.find(ce=>ce.id===q);if(!$)throw new Error("deck inesistente");if($.available===!1)throw new Error(`nodo owner offline: ${$.ownerLabel}`);const re=ay(j,C.current,b.current);if(!re)throw new Error("riferimento sessione non valido");const le=W($),se=jg(n_(le,re),$.ownerId,$.ownerTopology),pe=await xa(e,$.name,se,$.revision,$.ownerRoute),ye=rr(pe,Gs($),$.ownerTopology,$.local,!0);return V(x.current.map(ce=>ce.id===q?ye:ce),!1),ye},localMainId:Xr(null,"main"),parseDeckId:ud}}const PE="/sw.js",Ih="nc-sw-update";let Bh=null,Oh=!1,zh=null,Ry=Object.freeze({needed:!1,kind:null,version:""}),Py=!1;function Dy(){typeof window<"u"&&window.dispatchEvent(new Event(Ih))}function My(){const e=zh||(Oh?{kind:"reload",version:""}:null);Ry=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function Cv(){return Ry}function DE(e){return typeof window>"u"?()=>{}:(window.addEventListener(Ih,e),()=>window.removeEventListener(Ih,e))}function md(e){Oh!==e&&(Oh=e,My(),Dy())}function ME(e,t,i){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&i&&t!==i&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(zh);zh=s,My(),o||Dy()}function LE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&md(!0)})}function jE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Py&&location.reload()}),navigator.serviceWorker.register(PE).then(e=>{Bh=e,e.waiting&&md(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&LE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function TE(){Py=!0,md(!1);const e=Bh&&Bh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function AE({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const c=new URLSearchParams(o),d=c.get("token")||"",m=c.get("pair")||"",p=m?`${t||""}${i||""}#pair=${m}`:"";return{token:d,pair:p,nextUrl:a}}const Ly=9,jy=24,Ty="nc_side_w",xv="nc_side_min",IE=240,Ev="(min-width:1024px) and (pointer:fine)";function BE(){const e=Number(localStorage.getItem(Ty));return e>=180&&e<=480?e:IE}function OE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Ly&&e<=jy?e:13}function zE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=AE({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(i){e.pair=i;try{sessionStorage.setItem("nc_pair",i)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function FE(e){try{return ur(Th(e))}catch{return Yr()}}function Nv(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 HE(){const[e,t]=P.useState(()=>window.matchMedia(Ev).matches);return P.useEffect(()=>{const i=window.matchMedia(Ev),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function Rv({session:e,node:t,ownerId:i,token:s,readonly:o=!1,onBack:a}){Si();const[c,d]=P.useState(!1),[m,p]=P.useState(()=>window.matchMedia("(pointer: coarse)").matches),[_,S]=P.useState(null),[y,k]=P.useState(OE),[w,x]=P.useState(""),b=V=>k(X=>{const A=Math.max(Ly,Math.min(jy,X+V));return localStorage.setItem("nc_fontsize",String(A)),A}),C=P.useRef(()=>{}),M=P.useRef(()=>!1),L=P.useRef(()=>{}),T=P.useRef(!1),[J,H]=P.useState(!1),[F,G]=P.useState(!1),W=()=>{T.current=!T.current,H(T.current)};return P.useEffect(()=>{let V=!0;const X=t?t.split("/"):[],A=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function N(){let O=null,D=null;try{const te=await(await zt(`${A}/sessions`,s)).json();Array.isArray(te.sessions)&&(O=te.sessions.find(q=>q.name===e))}catch{}try{const B=await pr(s,X);B.available&&Array.isArray(B.cells)&&(D=B.cells.find(te=>te.tmuxSession===e))}catch{}if(!V)return;let z="";D?z=`${D.engine}${D.key?`·${D.key}`:""}`:O&&(z=O.attached?`attached · ${Nv(O.activity)}`:O.activity?Nv(O.activity):""),x(z)}N();const R=setInterval(N,4e3);return()=>{V=!1,clearInterval(R)}},[e,t,s]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:a,title:v("sessions"),children:[h.jsx(tt,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:v("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),w&&h.jsx("small",{className:"nc-bar-sub",children:w})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>b(-1),title:v("zoom-out"),children:h.jsx(tt,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>b(1),title:v("zoom-in"),children:h.jsx(tt,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(V=>!V),title:v("composer"),children:h.jsx(tt,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>d(V=>!V),title:v("files"),children:h.jsx(tt,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(X_,{session:e,node:t,token:s,readonly:o,takeSize:!0,sendRef:C,composerRef:M,actionRef:L,ctrlRef:T,setCtrlArmed:H,onFiles:S,fontSize:y,selectionMode:F,onSelectionModeChange:G})}),h.jsx(mC,{onKeyboard:()=>p(V=>!V),send:V=>C.current(V),action:V=>L.current(V),ctrlArmed:J,onCtrl:W,selectionMode:F,onSelectionMode:G}),m&&h.jsx(sy,{submitText:V=>M.current(V),token:s,session:e,node:t,ownerId:i}),c&&h.jsx(G_,{session:e,node:t,token:s,filesEvent:_,onClose:()=>d(!1)})]})}function $E(){Si();const[e]=P.useState(zE),[t,i]=P.useState(e.token),[s,o]=P.useState(e.pair||""),a=P.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,d]=P.useState(!1),m=HE(),[p]=P.useState(()=>$C(typeof location<"u"?location.pathname:"/")),[_,S]=P.useState(p.id),y=_===Xr(null,yi),[k,w]=P.useState(null),x=oe=>w(Wn(oe)),[b,C]=P.useState([]),[M,L]=P.useState([]),[T,J]=P.useState(()=>p.ownerId?Yr():FE(p.name)),[H,F]=P.useState(null),[G,W]=P.useState(null),V=oe=>W(Wn(oe)),X=Yh(t,m),A=P.useMemo(()=>(X||[]).filter(oe=>oe.instanceId).map(oe=>({instanceId:oe.instanceId,route:oe.route,label:oe.label,status:oe.status})),[X]),N=RE(t,_,T,J,A),R=N.decks;P.useEffect(()=>{const oe=new Map;for(const ke of X||[]){const Ke=(ke.route||[ke.name]).join("/"),ut=new Set((ke.sessions||[]).map(Qt=>Qt.name));for(const Qt of ke.cells||[])!Qt.cell||!Qt.tmuxSession||Qt.cell===Qt.tmuxSession||ut.has(Qt.cell)||oe.set(`${Ke}:${Qt.cell}`,`${Ke}:${Qt.tmuxSession}`)}J(ke=>z0(ke,oe))},[X]),P.useEffect(()=>{N.localNodeId&&J(oe=>{const ke=jh(oe,N.localNodeId,A);return JSON.stringify(ke)===JSON.stringify(oe)?oe:ke})},[A,N.localNodeId]);const[O,D]=P.useState(null),[z,B]=P.useState(!1),[te,q]=P.useState(BE),[j,$]=P.useState(!y),[re,le]=P.useState(()=>y?localStorage.getItem(xv)==="1":!0),[se,pe]=P.useState(!1),[ye,ce]=P.useState("nodes"),[Ce,Oe]=P.useState(!1),[Ze,Ve]=P.useState(""),Ae=(oe="nodes",ke=!1,Ke="")=>{ce(oe),Oe(ke),Ve(Ke),pe(!0)},[ot,Et]=P.useState(!1),[ie,ae]=P.useState(!1);P.useEffect(()=>{try{localStorage.setItem(Ty,String(te))}catch{}},[te]),P.useEffect(()=>{try{localStorage.setItem(xv,re?"1":"")}catch{}},[re]),P.useEffect(()=>{if(!t)return;let oe=!1;return Promise.all([Iv(t),zt("/api/config",t).then(ke=>ke.json())]).then(([ke,Ke])=>{oe||(ae(!!Ke.readonlyDefault),(ke.firstRun===!0&&!Ke.readonlyDefault||s)&&Et(!0))}).catch(()=>{}),()=>{oe=!0}},[t,s]);const ze=P.useCallback(async()=>{try{const ke=await(await zt("/api/sessions",t)).json();ke.error||C(ke.sessions||[])}catch{}try{const oe=await pr(t);L(oe.available?oe.cells||[]:[])}catch{L([])}},[t]);P.useEffect(()=>{if(!m)return;ze();const oe=setInterval(ze,4e3);return()=>clearInterval(oe)},[m,ze]),P.useEffect(()=>{let oe=!1;return zt("/api/config",t).then(ke=>ke.json()).then(ke=>{oe||ME(ke.version,ke.uiVersion,"0.8.20")}).catch(()=>{}),()=>{oe=!0}},[t]);const Q=new Set([...b.map(oe=>oe.name),...X.flatMap(oe=>oe.sessions.map(ke=>ke.key))]),ue=Qi(T),K=oe=>J(ke=>{const Ke=ay(oe,N.localNodeId,A)||oe,ut=n_(ke,Ke);return ut===ke&&Qi(ke).length>=9&&N.setError(v("grid-full")),ut}),me=async(oe,ke=[])=>{try{await Uh(t,oe,ke)}catch{return}const Ke=ke.length?`${ke.join("/")}:${oe}`:oe;J(ut=>Ya(ut,Ke)),ze()},be=async(oe,ke,Ke=[])=>{try{await Tv(t,oe,ke,Ke)}catch{return}ze()},Pe=async oe=>{if(!O)return;const{cell:ke}=O,Ke=Array.isArray(O.route)?O.route:[];oe.action==="up"?await $h(t,{cell:ke,boot:!!oe.boot,...oe.engine?{engine:oe.engine}:{},...oe.model!==void 0?{model:oe.model}:{},...oe.permissionPolicy?{permissionPolicy:oe.permissionPolicy}:{}},Ke):await $a(t,{cell:ke,boot:!!oe.boot},Ke),ze()},he=async oe=>{if(!(!(oe!=null&&oe.direct)||z)){B(!0);try{await qh(t,oe.name,oe.tunnelStatus==="up"?"down":"up")}finally{B(!1)}}},Ee=oe=>{const ke=R.find(Ke=>Ke.id===oe);if(!ke)return!1;try{const Ke=window.open(gu(ke,t),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},xe=async oe=>{if(!oe||oe===_)return;const ke=await N.select(oe),Ke=N.records.find(ut=>ut.id===oe);S(oe),J(ke),F(null),W(null);try{history.replaceState(null,"",gu(Ke||oe,null))}catch{}},$e=async(oe,ke)=>{const Ke=await N.add(oe,ke);await xe(Ke.id)},Je=async(oe,ke)=>{const Ke=await N.rename(oe,ke);if(oe===_){S(Ke.id),J(jh(Ke.layout,N.localNodeId,A)),F(null),W(null);try{history.replaceState(null,"",gu(Ke,null))}catch{}}},De=async oe=>{await N.remove(oe),oe===_&&await xe(N.localMainId)},fe=async(oe,ke)=>{!ke||ke===_||(await N.addTileTo(ke,oe),J(Ke=>Ya(Ke,oe)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:v("auth-prompt")}),h.jsx("input",{onChange:oe=>i(oe.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:c,onChange:oe=>d(oe.target.checked)})," ",v("remember-device")]}),h.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Be=h.jsxs(h.Fragment,{children:[se&&h.jsx(yE,{token:t,initialTab:ye,initialLocation:Ze,startNewCell:Ce,onClose:()=>{pe(!1),Oe(!1),Ve("")}}),ot&&h.jsx(SE,{token:t,initialPair:s,onPairDone:a,onDone:()=>Et(!1)}),h.jsx(EE,{token:t})]});if(!m)return k?h.jsxs(h.Fragment,{children:[h.jsx(Rv,{session:k.session,node:k.node,ownerId:k.ownerId,token:t,readonly:ie,onBack:()=>w(null)}),Be]}):h.jsxs(h.Fragment,{children:[h.jsx(U0,{onPick:x,token:t,onSettings:Ae}),Be]});const je=y||!j;return h.jsxs("div",{className:"nc-workspace",children:[je&&h.jsx(LC,{sessions:b,cells:M,activeSessions:ue,nodeGroups:X,localNodeId:N.localNodeId,onPick:V,onAddTile:K,onPower:D,onNodePower:he,onKill:me,onVisibility:be,onNew:()=>Ae("fleet",!0),onSettings:Ae,width:te,collapsed:re,onResize:q,onToggleCollapse:()=>le(oe=>!oe)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(GC,{decks:R,currentDeck:_,onCreate:$e,onRename:Je,onDelete:De,onReorder:N.reorder,onOpenWindow:Ee,onNavigate:xe,saveState:N.saveState,error:N.error,sidebarVisible:je,onToggleSidebar:y?null:()=>$(oe=>!oe)}),h.jsx(BC,{layout:T,onLayoutChange:J,token:t,readonly:ie,sessionsAlive:Q,focusSession:H,onFocus:F,onOpenSingle:V,decks:R,currentDeck:_,onSendToDeck:fe})]}),G&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(Rv,{session:G.session,node:G.node,ownerId:G.ownerId,token:t,readonly:ie,onBack:()=>W(null)})}),O&&h.jsx(Wa,{cell:O,token:t,route:Array.isArray(O.route)?O.route:[],onConfirm:Pe,onClose:()=>D(null)}),Be]})}function WE(){Si();const e=P.useSyncExternalStore(DE,Cv,Cv);if(!e.needed)return null;const t=e.kind==="install"?v("install-version-mismatch").replace("{v}",e.version):v("update-available").replace("{v}",e.version).replace(" "," ").trim();return 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:TE,children:v("reload")})]})}jE();zw.createRoot(document.getElementById("root")).render(h.jsxs(Lw.StrictMode,{children:[h.jsx($E,{}),h.jsx(WE,{})]}));
|