herdr-remote 0.3.34 → 0.3.36
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 +4 -0
- package/README.zh-CN.md +2 -0
- package/dist/chunks/{MHS44P3Y.js → 37NKZLLR.js} +1 -1
- package/dist/chunks/{6M7I477E.js → 4CO2WAXZ.js} +1 -1
- package/dist/chunks/{IRV2W3ZL.js → 54QMQDOL.js} +1 -1
- package/dist/chunks/{S57VTPH5.js → 5RGV2MW6.js} +1 -1
- package/dist/chunks/67FHQKXM.js +6 -0
- package/dist/chunks/{UK7XZS2G.js → B6LZOIKD.js} +1 -1
- package/dist/chunks/{QXMBBOKS.js → CUXGXJMW.js} +1 -1
- package/dist/chunks/{WDPLLWBV.js → D3LUHIKR.js} +1 -1
- package/dist/chunks/{72JMGTAK.js → ETEPTJGZ.js} +2 -2
- package/dist/chunks/GZIFCN7B.js +3 -0
- package/dist/chunks/{FN6VM2O7.js → HDHNFESR.js} +1 -1
- package/dist/chunks/{MLSLOPR7.js → HRFNURKU.js} +1 -1
- package/dist/chunks/{S3V2O6BK.js → IONXNA5T.js} +1 -1
- package/dist/chunks/KEUAW3VO.js +3 -0
- package/dist/chunks/{TSP3KNDA.js → KUDVTWG4.js} +1 -1
- package/dist/chunks/N3C7MVSO.js +3 -0
- package/dist/chunks/{MRXHG2UD.js → NYAKZHLQ.js} +1 -1
- package/dist/chunks/ODOBBR6N.js +9 -0
- package/dist/chunks/{2IM3AVNW.js → PDOEV4QJ.js} +1 -1
- package/dist/chunks/{2RUREFQO.js → QL4I7VLD.js} +1 -1
- package/dist/chunks/{42KARAL4.js → QOPTXTL7.js} +6 -6
- package/dist/chunks/{NY3SVG3W.js → QP6NLV4R.js} +2 -2
- package/dist/chunks/{I6K6O3EE.js → S4TW5MHM.js} +1 -1
- package/dist/chunks/SWVUDSHP.js +3 -0
- package/dist/chunks/{Y5CEFDIU.js → VSBBDPSE.js} +1 -1
- package/dist/chunks/{QRQJLJWT.js → W2FYGFNZ.js} +1 -1
- package/dist/chunks/{ZZOEVJ3V.js → ZAAEQP3M.js} +1 -1
- package/dist/chunks/{W24FRSKQ.js → ZUTRSLCH.js} +1 -1
- package/dist/cli.js +13 -13
- package/dist/connector/admin-broker.js +1 -1
- package/dist/connector/main.js +14 -14
- package/herdr-plugin.toml +2 -2
- package/node_modules/herdr-remote-relay/bin/herdr-remote-relay.js +11 -11
- package/node_modules/herdr-remote-relay/package.json +1 -1
- package/node_modules/herdr-remote-relay/web/dist/assets/{index-CnRQXj8k.js → index-DMbkU5R6.js} +11 -11
- package/node_modules/herdr-remote-relay/web/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/chunks/3FQAXVGC.js +0 -3
- package/dist/chunks/J427SPKK.js +0 -3
- package/dist/chunks/NKDFWWLU.js +0 -3
- package/dist/chunks/W27D73NQ.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{b as Rl,c as Rg,d as Ng,f as wg,g as vg}from"./2RUREFQO.js";import{a as yl,b as Ig}from"./3FQAXVGC.js";import{h as Dg,i as Rs}from"./UK7XZS2G.js";import{a as fg,f as Eg,g as Sl,h as Bg}from"./S57VTPH5.js";import"./JJGEV4EZ.js";import"./S3V2O6BK.js";import"./ZZOEVJ3V.js";import{d as ml,e as gr,f as gg}from"./U6QAYG3E.js";import{k as Mn}from"./2IM3AVNW.js";import"./6M7I477E.js";import"./MLSLOPR7.js";import{b as Cg,c as dg,d as Qg,e as hg,f as pg,h as Dl,j as mg,k as yg,o as Sg}from"./72JMGTAK.js";import{a as Ss,b as Ds,c as FC,d as ag,e as sg,f as kC,g as KC,j as JC,k as Ri,l as ug,m as so,o as Zn,p as cg}from"./MHS44P3Y.js";import"./KRVF37OW.js";import{a as YC,b as zC,c as qC}from"./QRGNEKME.js";import{s as lg}from"./NKDFWWLU.js";import{b as OC,c as og,d as vn}from"./TNLCNVA2.js";import{a as Qt,b as $,c as $S,d as iA}from"./I6NRCYLI.js";var VC=$(Ns=>{"use strict";var AD=Symbol.for("react.transitional.element"),tD=Symbol.for("react.fragment");function XC(A,e,i){var r=null;if(i!==void 0&&(r=""+i),e.key!==void 0&&(r=""+e.key),"key"in e){i={};for(var l in e)l!=="key"&&(i[l]=e[l])}else i=e;return e=i.ref,{$$typeof:AD,type:A,key:r,ref:e!==void 0?e:null,props:i}}Ns.Fragment=tD;Ns.jsx=XC;Ns.jsxs=XC});var ye=$((BG,ZC)=>{"use strict";ZC.exports=VC()});var od=$(CA=>{"use strict";var Gg=Symbol.for("react.transitional.element"),eD=Symbol.for("react.portal"),nD=Symbol.for("react.fragment"),iD=Symbol.for("react.strict_mode"),rD=Symbol.for("react.profiler"),oD=Symbol.for("react.consumer"),lD=Symbol.for("react.context"),aD=Symbol.for("react.forward_ref"),sD=Symbol.for("react.suspense"),uD=Symbol.for("react.memo"),Ad=Symbol.for("react.lazy"),cD=Symbol.for("react.activity"),jC=Symbol.iterator;function gD(A){return A===null||typeof A!="object"?null:(A=jC&&A[jC]||A["@@iterator"],typeof A=="function"?A:null)}var td={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ed=Object.assign,nd={};function co(A,e,i){this.props=A,this.context=e,this.refs=nd,this.updater=i||td}co.prototype.isReactComponent={};co.prototype.setState=function(A,e){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,e,"setState")};co.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function id(){}id.prototype=co.prototype;function bg(A,e,i){this.props=A,this.context=e,this.refs=nd,this.updater=i||td}var Ug=bg.prototype=new id;Ug.constructor=bg;ed(Ug,co.prototype);Ug.isPureReactComponent=!0;var WC=Array.isArray;function Tg(){}var tt={H:null,A:null,T:null,S:null},rd=Object.prototype.hasOwnProperty;function Hg(A,e,i){var r=i.ref;return{$$typeof:Gg,type:A,key:e,ref:r!==void 0?r:null,props:i}}function fD(A,e){return Hg(A.type,e,A.props)}function xg(A){return typeof A=="object"&&A!==null&&A.$$typeof===Gg}function ED(A){var e={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(i){return e[i]})}var PC=/\/+/g;function Mg(A,e){return typeof A=="object"&&A!==null&&A.key!=null?ED(""+A.key):e.toString(36)}function ID(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(Tg,Tg):(A.status="pending",A.then(function(e){A.status==="pending"&&(A.status="fulfilled",A.value=e)},function(e){A.status==="pending"&&(A.status="rejected",A.reason=e)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function uo(A,e,i,r,l){var s=typeof A;(s==="undefined"||s==="boolean")&&(A=null);var u=!1;if(A===null)u=!0;else switch(s){case"bigint":case"string":case"number":u=!0;break;case"object":switch(A.$$typeof){case Gg:case eD:u=!0;break;case Ad:return u=A._init,uo(u(A._payload),e,i,r,l)}}if(u)return l=l(A),u=r===""?"."+Mg(A,0):r,WC(l)?(i="",u!=null&&(i=u.replace(PC,"$&/")+"/"),uo(l,e,i,"",function(d){return d})):l!=null&&(xg(l)&&(l=fD(l,i+(l.key==null||A&&A.key===l.key?"":(""+l.key).replace(PC,"$&/")+"/")+u)),e.push(l)),1;u=0;var f=r===""?".":r+":";if(WC(A))for(var E=0;E<A.length;E++)r=A[E],s=f+Mg(r,E),u+=uo(r,e,i,s,l);else if(E=gD(A),typeof E=="function")for(A=E.call(A),E=0;!(r=A.next()).done;)r=r.value,s=f+Mg(r,E++),u+=uo(r,e,i,s,l);else if(s==="object"){if(typeof A.then=="function")return uo(ID(A),e,i,r,l);throw e=String(A),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return u}function ws(A,e,i){if(A==null)return A;var r=[],l=0;return uo(A,r,"","",function(s){return e.call(i,s,l++)}),r}function BD(A){if(A._status===-1){var e=A._result;e=e(),e.then(function(i){(A._status===0||A._status===-1)&&(A._status=1,A._result=i)},function(i){(A._status===0||A._status===-1)&&(A._status=2,A._result=i)}),A._status===-1&&(A._status=0,A._result=e)}if(A._status===1)return A._result.default;throw A._result}var $C=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},CD={map:ws,forEach:function(A,e,i){ws(A,function(){e.apply(this,arguments)},i)},count:function(A){var e=0;return ws(A,function(){e++}),e},toArray:function(A){return ws(A,function(e){return e})||[]},only:function(A){if(!xg(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};CA.Activity=cD;CA.Children=CD;CA.Component=co;CA.Fragment=nD;CA.Profiler=rD;CA.PureComponent=bg;CA.StrictMode=iD;CA.Suspense=sD;CA.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=tt;CA.__COMPILER_RUNTIME={__proto__:null,c:function(A){return tt.H.useMemoCache(A)}};CA.cache=function(A){return function(){return A.apply(null,arguments)}};CA.cacheSignal=function(){return null};CA.cloneElement=function(A,e,i){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var r=ed({},A.props),l=A.key;if(e!=null)for(s in e.key!==void 0&&(l=""+e.key),e)!rd.call(e,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&e.ref===void 0||(r[s]=e[s]);var s=arguments.length-2;if(s===1)r.children=i;else if(1<s){for(var u=Array(s),f=0;f<s;f++)u[f]=arguments[f+2];r.children=u}return Hg(A.type,l,r)};CA.createContext=function(A){return A={$$typeof:lD,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:oD,_context:A},A};CA.createElement=function(A,e,i){var r,l={},s=null;if(e!=null)for(r in e.key!==void 0&&(s=""+e.key),e)rd.call(e,r)&&r!=="key"&&r!=="__self"&&r!=="__source"&&(l[r]=e[r]);var u=arguments.length-2;if(u===1)l.children=i;else if(1<u){for(var f=Array(u),E=0;E<u;E++)f[E]=arguments[E+2];l.children=f}if(A&&A.defaultProps)for(r in u=A.defaultProps,u)l[r]===void 0&&(l[r]=u[r]);return Hg(A,s,l)};CA.createRef=function(){return{current:null}};CA.forwardRef=function(A){return{$$typeof:aD,render:A}};CA.isValidElement=xg;CA.lazy=function(A){return{$$typeof:Ad,_payload:{_status:-1,_result:A},_init:BD}};CA.memo=function(A,e){return{$$typeof:uD,type:A,compare:e===void 0?null:e}};CA.startTransition=function(A){var e=tt.T,i={};tt.T=i;try{var r=A(),l=tt.S;l!==null&&l(i,r),typeof r=="object"&&r!==null&&typeof r.then=="function"&&r.then(Tg,$C)}catch(s){$C(s)}finally{e!==null&&i.types!==null&&(e.types=i.types),tt.T=e}};CA.unstable_useCacheRefresh=function(){return tt.H.useCacheRefresh()};CA.use=function(A){return tt.H.use(A)};CA.useActionState=function(A,e,i){return tt.H.useActionState(A,e,i)};CA.useCallback=function(A,e){return tt.H.useCallback(A,e)};CA.useContext=function(A){return tt.H.useContext(A)};CA.useDebugValue=function(){};CA.useDeferredValue=function(A,e){return tt.H.useDeferredValue(A,e)};CA.useEffect=function(A,e){return tt.H.useEffect(A,e)};CA.useEffectEvent=function(A){return tt.H.useEffectEvent(A)};CA.useId=function(){return tt.H.useId()};CA.useImperativeHandle=function(A,e,i){return tt.H.useImperativeHandle(A,e,i)};CA.useInsertionEffect=function(A,e){return tt.H.useInsertionEffect(A,e)};CA.useLayoutEffect=function(A,e){return tt.H.useLayoutEffect(A,e)};CA.useMemo=function(A,e){return tt.H.useMemo(A,e)};CA.useOptimistic=function(A,e){return tt.H.useOptimistic(A,e)};CA.useReducer=function(A,e,i){return tt.H.useReducer(A,e,i)};CA.useRef=function(A){return tt.H.useRef(A)};CA.useState=function(A){return tt.H.useState(A)};CA.useSyncExternalStore=function(A,e,i){return tt.H.useSyncExternalStore(A,e,i)};CA.useTransition=function(){return tt.H.useTransition()};CA.version="19.2.8"});var EA=$((dG,ld)=>{"use strict";ld.exports=od()});var Qd=$((ZG,Gs)=>{Gs.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Gs.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Gs.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Kg=$((jG,Qo)=>{var at=global.process,Er=function(A){return A&&typeof A=="object"&&typeof A.removeListener=="function"&&typeof A.emit=="function"&&typeof A.reallyExit=="function"&&typeof A.listeners=="function"&&typeof A.kill=="function"&&typeof A.pid=="number"&&typeof A.on=="function"};Er(at)?(hd=Qt("assert"),Bo=Qd(),pd=/^win/i.test(at.platform),vl=Qt("events"),typeof vl!="function"&&(vl=vl.EventEmitter),at.__signal_exit_emitter__?qt=at.__signal_exit_emitter__:(qt=at.__signal_exit_emitter__=new vl,qt.count=0,qt.emitted={}),qt.infinite||(qt.setMaxListeners(1/0),qt.infinite=!0),Qo.exports=function(A,e){if(!Er(global.process))return function(){};hd.equal(typeof A,"function","a callback must be provided for exit handler"),Co===!1&&Fg();var i="exit";e&&e.alwaysLast&&(i="afterexit");var r=function(){qt.removeListener(i,A),qt.listeners("exit").length===0&&qt.listeners("afterexit").length===0&&bs()};return qt.on(i,A),r},bs=function(){!Co||!Er(global.process)||(Co=!1,Bo.forEach(function(e){try{at.removeListener(e,Us[e])}catch{}}),at.emit=Hs,at.reallyExit=kg,qt.count-=1)},Qo.exports.unload=bs,Ir=function(e,i,r){qt.emitted[e]||(qt.emitted[e]=!0,qt.emit(e,i,r))},Us={},Bo.forEach(function(A){Us[A]=function(){if(Er(global.process)){var i=at.listeners(A);i.length===qt.count&&(bs(),Ir("exit",null,A),Ir("afterexit",null,A),pd&&A==="SIGHUP"&&(A="SIGINT"),at.kill(at.pid,A))}}}),Qo.exports.signals=function(){return Bo},Co=!1,Fg=function(){Co||!Er(global.process)||(Co=!0,qt.count+=1,Bo=Bo.filter(function(e){try{return at.on(e,Us[e]),!0}catch{return!1}}),at.emit=yd,at.reallyExit=md)},Qo.exports.load=Fg,kg=at.reallyExit,md=function(e){Er(global.process)&&(at.exitCode=e||0,Ir("exit",at.exitCode,null),Ir("afterexit",at.exitCode,null),kg.call(at,at.exitCode))},Hs=at.emit,yd=function(e,i){if(e==="exit"&&Er(global.process)){i!==void 0&&(at.exitCode=i);var r=Hs.apply(this,arguments);return Ir("exit",at.exitCode,null),Ir("afterexit",at.exitCode,null),r}else return Hs.apply(this,arguments)}):Qo.exports=function(){return function(){}};var hd,Bo,pd,vl,qt,bs,Ir,Us,Co,Fg,kg,md,Hs,yd});var Nd=$(Ni=>{"use strict";Ni.ConcurrentRoot=1;Ni.ContinuousEventPriority=8;Ni.DefaultEventPriority=32;Ni.DiscreteEventPriority=2;Ni.IdleEventPriority=268435456;Ni.LegacyRoot=0;Ni.NoEventPriority=0});var xs=$((Ab,wd)=>{"use strict";wd.exports=Nd()});var bQ=$(ut=>{"use strict";function gf(A,e){var i=A.length;A.push(e);A:for(;0<i;){var r=i-1>>>1,l=A[r];if(0<Ks(l,e))A[r]=e,A[i]=l,i=r;else break A}}function Tn(A){return A.length===0?null:A[0]}function Ys(A){if(A.length===0)return null;var e=A[0],i=A.pop();if(i!==e){A[0]=i;A:for(var r=0,l=A.length,s=l>>>1;r<s;){var u=2*(r+1)-1,f=A[u],E=u+1,d=A[E];if(0>Ks(f,i))E<l&&0>Ks(d,f)?(A[r]=d,A[E]=i,r=E):(A[r]=f,A[u]=i,r=u);else if(E<l&&0>Ks(d,i))A[r]=d,A[E]=i,r=E;else break A}}return e}function Ks(A,e){var i=A.sortIndex-e.sortIndex;return i!==0?i:A.id-e.id}ut.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(SQ=performance,ut.unstable_now=function(){return SQ.now()}):(sf=Date,DQ=sf.now(),ut.unstable_now=function(){return sf.now()-DQ});var SQ,sf,DQ,$n=[],wi=[],AN=1,Xe=null,oe=3,ff=!1,Ll=!1,_l=!1,Ef=!1,wQ=typeof setTimeout=="function"?setTimeout:null,vQ=typeof clearTimeout=="function"?clearTimeout:null,RQ=typeof setImmediate<"u"?setImmediate:null;function Js(A){for(var e=Tn(wi);e!==null;){if(e.callback===null)Ys(wi);else if(e.startTime<=A)Ys(wi),e.sortIndex=e.expirationTime,gf($n,e);else break;e=Tn(wi)}}function If(A){if(_l=!1,Js(A),!Ll)if(Tn($n)!==null)Ll=!0,Ro||(Ro=!0,Do());else{var e=Tn(wi);e!==null&&Bf(If,e.startTime-A)}}var Ro=!1,Ol=-1,MQ=5,TQ=-1;function GQ(){return Ef?!0:!(ut.unstable_now()-TQ<MQ)}function uf(){if(Ef=!1,Ro){var A=ut.unstable_now();TQ=A;var e=!0;try{A:{Ll=!1,_l&&(_l=!1,vQ(Ol),Ol=-1),ff=!0;var i=oe;try{t:{for(Js(A),Xe=Tn($n);Xe!==null&&!(Xe.expirationTime>A&&GQ());){var r=Xe.callback;if(typeof r=="function"){Xe.callback=null,oe=Xe.priorityLevel;var l=r(Xe.expirationTime<=A);if(A=ut.unstable_now(),typeof l=="function"){Xe.callback=l,Js(A),e=!0;break t}Xe===Tn($n)&&Ys($n),Js(A)}else Ys($n);Xe=Tn($n)}if(Xe!==null)e=!0;else{var s=Tn(wi);s!==null&&Bf(If,s.startTime-A),e=!1}}break A}finally{Xe=null,oe=i,ff=!1}e=void 0}}finally{e?Do():Ro=!1}}}var Do;typeof RQ=="function"?Do=function(){RQ(uf)}:typeof MessageChannel<"u"?(cf=new MessageChannel,NQ=cf.port2,cf.port1.onmessage=uf,Do=function(){NQ.postMessage(null)}):Do=function(){wQ(uf,0)};var cf,NQ;function Bf(A,e){Ol=wQ(function(){A(ut.unstable_now())},e)}ut.unstable_IdlePriority=5;ut.unstable_ImmediatePriority=1;ut.unstable_LowPriority=4;ut.unstable_NormalPriority=3;ut.unstable_Profiling=null;ut.unstable_UserBlockingPriority=2;ut.unstable_cancelCallback=function(A){A.callback=null};ut.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):MQ=0<A?Math.floor(1e3/A):5};ut.unstable_getCurrentPriorityLevel=function(){return oe};ut.unstable_next=function(A){switch(oe){case 1:case 2:case 3:var e=3;break;default:e=oe}var i=oe;oe=e;try{return A()}finally{oe=i}};ut.unstable_requestPaint=function(){Ef=!0};ut.unstable_runWithPriority=function(A,e){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var i=oe;oe=A;try{return e()}finally{oe=i}};ut.unstable_scheduleCallback=function(A,e,i){var r=ut.unstable_now();switch(typeof i=="object"&&i!==null?(i=i.delay,i=typeof i=="number"&&0<i?r+i:r):i=r,A){case 1:var l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}return l=i+l,A={id:AN++,callback:e,priorityLevel:A,startTime:i,expirationTime:l,sortIndex:-1},i>r?(A.sortIndex=i,gf(wi,A),Tn($n)===null&&A===Tn(wi)&&(_l?(vQ(Ol),Ol=-1):_l=!0,Bf(If,i-r))):(A.sortIndex=l,gf($n,A),Ll||ff||(Ll=!0,Ro||(Ro=!0,Do()))),A};ut.unstable_shouldYield=GQ;ut.unstable_wrapCallback=function(A){var e=oe;return function(){var i=oe;oe=e;try{return A.apply(this,arguments)}finally{oe=i}}}});var Cf=$((zb,UQ)=>{"use strict";UQ.exports=bQ()});var HQ=$((qb,Fl)=>{"use strict";Fl.exports=function(A){function e(t,n,o,a){return new i1(t,n,o,a)}function i(){}function r(t){var n="https://react.dev/errors/"+t;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)n+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+t+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(t){var n=t,o=t;if(t.alternate)for(;n.return;)n=n.return;else{t=n;do n=t,(n.flags&4098)!==0&&(o=n.return),t=n.return;while(t)}return n.tag===3?o:null}function s(t){if(l(t)!==t)throw Error(r(188))}function u(t){var n=t.alternate;if(!n){if(n=l(t),n===null)throw Error(r(188));return n!==t?null:t}for(var o=t,a=n;;){var c=o.return;if(c===null)break;var g=c.alternate;if(g===null){if(a=c.return,a!==null){o=a;continue}break}if(c.child===g.child){for(g=c.child;g;){if(g===o)return s(c),t;if(g===a)return s(c),n;g=g.sibling}throw Error(r(188))}if(o.return!==a.return)o=c,a=g;else{for(var B=!1,y=c.child;y;){if(y===o){B=!0,o=c,a=g;break}if(y===a){B=!0,a=c,o=g;break}y=y.sibling}if(!B){for(y=g.child;y;){if(y===o){B=!0,o=g,a=c;break}if(y===a){B=!0,a=g,o=c;break}y=y.sibling}if(!B)throw Error(r(189))}}if(o.alternate!==a)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?t:n}function f(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t;for(t=t.child;t!==null;){if(n=f(t),n!==null)return n;t=t.sibling}return null}function E(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t;for(t=t.child;t!==null;){if(t.tag!==4&&(n=E(t),n!==null))return n;t=t.sibling}return null}function d(t){return t===null||typeof t!="object"?null:(t=iC&&t[iC]||t["@@iterator"],typeof t=="function"?t:null)}function h(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===s1?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Jr:return"Fragment";case Rc:return"Profiler";case eC:return"StrictMode";case wc:return"Suspense";case vc:return"SuspenseList";case Tc:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case Kr:return"Portal";case Ii:return t.displayName||"Context";case nC:return(t._context.displayName||"Context")+".Consumer";case Nc:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Mc:return n=t.displayName||null,n!==null?n:h(t.type)||"Memo";case Bi:n=t._payload,t=t._init;try{return h(t(n))}catch{}}return null}function S(t){return{current:t}}function Q(t){0>qr||(t.current=Lc[qr],Lc[qr]=null,qr--)}function p(t,n){qr++,Lc[qr]=t.current,t.current=n}function D(t){return t>>>=0,t===0?32:31-(LS(t)/_S|0)|0}function v(t){var n=t&42;if(n!==0)return n;switch(t&-t){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function N(t,n,o){var a=t.pendingLanes;if(a===0)return 0;var c=0,g=t.suspendedLanes,B=t.pingedLanes;t=t.warmLanes;var y=a&134217727;return y!==0?(a=y&~g,a!==0?c=v(a):(B&=y,B!==0?c=v(B):o||(o=y&~t,o!==0&&(c=v(o))))):(y=a&~g,y!==0?c=v(y):B!==0?c=v(B):o||(o=a&~t,o!==0&&(c=v(o)))),c===0?0:n!==0&&n!==c&&(n&g)===0&&(g=c&-c,o=n&-n,g>=o||g===32&&(o&4194048)!==0)?n:c}function L(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function uA(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32: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+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function J(){var t=rs;return rs<<=1,(rs&62914560)===0&&(rs=4194304),t}function G(t){for(var n=[],o=0;31>o;o++)n.push(t);return n}function q(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function V(t,n,o,a,c,g){var B=t.pendingLanes;t.pendingLanes=o,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=o,t.entangledLanes&=o,t.errorRecoveryDisabledLanes&=o,t.shellSuspendCounter=0;var y=t.entanglements,U=t.expirationTimes,O=t.hiddenUpdates;for(o=B&~o;0<o;){var W=31-Me(o),Y=1<<W;y[W]=0,U[W]=-1;var eA=O[W];if(eA!==null)for(O[W]=null,W=0;W<eA.length;W++){var BA=eA[W];BA!==null&&(BA.lane&=-536870913)}o&=~Y}a!==0&&fA(t,a,0),g!==0&&c===0&&t.tag!==0&&(t.suspendedLanes|=g&~(B&~n))}function fA(t,n,o){t.pendingLanes|=n,t.suspendedLanes&=~n;var a=31-Me(n);t.entangledLanes|=n,t.entanglements[a]=t.entanglements[a]|1073741824|o&261930}function TA(t,n){var o=t.entangledLanes|=n;for(t=t.entanglements;o;){var a=31-Me(o),c=1<<a;c&n|t[a]&n&&(t[a]|=n),o&=~c}}function AA(t,n){var o=n&-n;return o=(o&42)!==0?1:oA(o),(o&(t.suspendedLanes|n))!==0?0:o}function oA(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function OA(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function FA(t){if(typeof JS=="function"&&YS(t),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(ul,t)}catch{}}function rt(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}function PA(t){if(Fc===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);Fc=n&&n[1]||"",MC=-1<o.stack.indexOf(`
|
|
3
|
+
import{b as Rl,c as Rg,d as Ng,f as wg,g as vg}from"./QL4I7VLD.js";import{a as yl,b as Ig}from"./KEUAW3VO.js";import{h as Dg,i as Rs}from"./B6LZOIKD.js";import{a as fg,f as Eg,g as Sl,h as Bg}from"./5RGV2MW6.js";import"./JJGEV4EZ.js";import"./IONXNA5T.js";import"./ZAAEQP3M.js";import{d as ml,e as gr,f as gg}from"./U6QAYG3E.js";import{k as Mn}from"./PDOEV4QJ.js";import"./4CO2WAXZ.js";import"./HRFNURKU.js";import{b as Cg,c as dg,d as Qg,e as hg,f as pg,h as Dl,j as mg,k as yg,p as Sg}from"./ETEPTJGZ.js";import{a as Ss,b as Ds,c as FC,d as ag,e as sg,f as kC,g as KC,j as JC,k as Ri,l as ug,m as so,o as Zn,p as cg}from"./37NKZLLR.js";import"./KRVF37OW.js";import{a as YC,b as zC,c as qC}from"./QRGNEKME.js";import{t as lg}from"./SWVUDSHP.js";import{b as OC,c as og,d as vn}from"./TNLCNVA2.js";import{a as Qt,b as $,c as $S,d as iA}from"./I6NRCYLI.js";var VC=$(Ns=>{"use strict";var AD=Symbol.for("react.transitional.element"),tD=Symbol.for("react.fragment");function XC(A,e,i){var r=null;if(i!==void 0&&(r=""+i),e.key!==void 0&&(r=""+e.key),"key"in e){i={};for(var l in e)l!=="key"&&(i[l]=e[l])}else i=e;return e=i.ref,{$$typeof:AD,type:A,key:r,ref:e!==void 0?e:null,props:i}}Ns.Fragment=tD;Ns.jsx=XC;Ns.jsxs=XC});var ye=$((BG,ZC)=>{"use strict";ZC.exports=VC()});var od=$(CA=>{"use strict";var Gg=Symbol.for("react.transitional.element"),eD=Symbol.for("react.portal"),nD=Symbol.for("react.fragment"),iD=Symbol.for("react.strict_mode"),rD=Symbol.for("react.profiler"),oD=Symbol.for("react.consumer"),lD=Symbol.for("react.context"),aD=Symbol.for("react.forward_ref"),sD=Symbol.for("react.suspense"),uD=Symbol.for("react.memo"),Ad=Symbol.for("react.lazy"),cD=Symbol.for("react.activity"),jC=Symbol.iterator;function gD(A){return A===null||typeof A!="object"?null:(A=jC&&A[jC]||A["@@iterator"],typeof A=="function"?A:null)}var td={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ed=Object.assign,nd={};function co(A,e,i){this.props=A,this.context=e,this.refs=nd,this.updater=i||td}co.prototype.isReactComponent={};co.prototype.setState=function(A,e){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,e,"setState")};co.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function id(){}id.prototype=co.prototype;function bg(A,e,i){this.props=A,this.context=e,this.refs=nd,this.updater=i||td}var Ug=bg.prototype=new id;Ug.constructor=bg;ed(Ug,co.prototype);Ug.isPureReactComponent=!0;var WC=Array.isArray;function Tg(){}var tt={H:null,A:null,T:null,S:null},rd=Object.prototype.hasOwnProperty;function Hg(A,e,i){var r=i.ref;return{$$typeof:Gg,type:A,key:e,ref:r!==void 0?r:null,props:i}}function fD(A,e){return Hg(A.type,e,A.props)}function xg(A){return typeof A=="object"&&A!==null&&A.$$typeof===Gg}function ED(A){var e={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(i){return e[i]})}var PC=/\/+/g;function Mg(A,e){return typeof A=="object"&&A!==null&&A.key!=null?ED(""+A.key):e.toString(36)}function ID(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(Tg,Tg):(A.status="pending",A.then(function(e){A.status==="pending"&&(A.status="fulfilled",A.value=e)},function(e){A.status==="pending"&&(A.status="rejected",A.reason=e)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function uo(A,e,i,r,l){var s=typeof A;(s==="undefined"||s==="boolean")&&(A=null);var u=!1;if(A===null)u=!0;else switch(s){case"bigint":case"string":case"number":u=!0;break;case"object":switch(A.$$typeof){case Gg:case eD:u=!0;break;case Ad:return u=A._init,uo(u(A._payload),e,i,r,l)}}if(u)return l=l(A),u=r===""?"."+Mg(A,0):r,WC(l)?(i="",u!=null&&(i=u.replace(PC,"$&/")+"/"),uo(l,e,i,"",function(d){return d})):l!=null&&(xg(l)&&(l=fD(l,i+(l.key==null||A&&A.key===l.key?"":(""+l.key).replace(PC,"$&/")+"/")+u)),e.push(l)),1;u=0;var f=r===""?".":r+":";if(WC(A))for(var E=0;E<A.length;E++)r=A[E],s=f+Mg(r,E),u+=uo(r,e,i,s,l);else if(E=gD(A),typeof E=="function")for(A=E.call(A),E=0;!(r=A.next()).done;)r=r.value,s=f+Mg(r,E++),u+=uo(r,e,i,s,l);else if(s==="object"){if(typeof A.then=="function")return uo(ID(A),e,i,r,l);throw e=String(A),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return u}function ws(A,e,i){if(A==null)return A;var r=[],l=0;return uo(A,r,"","",function(s){return e.call(i,s,l++)}),r}function BD(A){if(A._status===-1){var e=A._result;e=e(),e.then(function(i){(A._status===0||A._status===-1)&&(A._status=1,A._result=i)},function(i){(A._status===0||A._status===-1)&&(A._status=2,A._result=i)}),A._status===-1&&(A._status=0,A._result=e)}if(A._status===1)return A._result.default;throw A._result}var $C=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},CD={map:ws,forEach:function(A,e,i){ws(A,function(){e.apply(this,arguments)},i)},count:function(A){var e=0;return ws(A,function(){e++}),e},toArray:function(A){return ws(A,function(e){return e})||[]},only:function(A){if(!xg(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};CA.Activity=cD;CA.Children=CD;CA.Component=co;CA.Fragment=nD;CA.Profiler=rD;CA.PureComponent=bg;CA.StrictMode=iD;CA.Suspense=sD;CA.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=tt;CA.__COMPILER_RUNTIME={__proto__:null,c:function(A){return tt.H.useMemoCache(A)}};CA.cache=function(A){return function(){return A.apply(null,arguments)}};CA.cacheSignal=function(){return null};CA.cloneElement=function(A,e,i){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var r=ed({},A.props),l=A.key;if(e!=null)for(s in e.key!==void 0&&(l=""+e.key),e)!rd.call(e,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&e.ref===void 0||(r[s]=e[s]);var s=arguments.length-2;if(s===1)r.children=i;else if(1<s){for(var u=Array(s),f=0;f<s;f++)u[f]=arguments[f+2];r.children=u}return Hg(A.type,l,r)};CA.createContext=function(A){return A={$$typeof:lD,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:oD,_context:A},A};CA.createElement=function(A,e,i){var r,l={},s=null;if(e!=null)for(r in e.key!==void 0&&(s=""+e.key),e)rd.call(e,r)&&r!=="key"&&r!=="__self"&&r!=="__source"&&(l[r]=e[r]);var u=arguments.length-2;if(u===1)l.children=i;else if(1<u){for(var f=Array(u),E=0;E<u;E++)f[E]=arguments[E+2];l.children=f}if(A&&A.defaultProps)for(r in u=A.defaultProps,u)l[r]===void 0&&(l[r]=u[r]);return Hg(A,s,l)};CA.createRef=function(){return{current:null}};CA.forwardRef=function(A){return{$$typeof:aD,render:A}};CA.isValidElement=xg;CA.lazy=function(A){return{$$typeof:Ad,_payload:{_status:-1,_result:A},_init:BD}};CA.memo=function(A,e){return{$$typeof:uD,type:A,compare:e===void 0?null:e}};CA.startTransition=function(A){var e=tt.T,i={};tt.T=i;try{var r=A(),l=tt.S;l!==null&&l(i,r),typeof r=="object"&&r!==null&&typeof r.then=="function"&&r.then(Tg,$C)}catch(s){$C(s)}finally{e!==null&&i.types!==null&&(e.types=i.types),tt.T=e}};CA.unstable_useCacheRefresh=function(){return tt.H.useCacheRefresh()};CA.use=function(A){return tt.H.use(A)};CA.useActionState=function(A,e,i){return tt.H.useActionState(A,e,i)};CA.useCallback=function(A,e){return tt.H.useCallback(A,e)};CA.useContext=function(A){return tt.H.useContext(A)};CA.useDebugValue=function(){};CA.useDeferredValue=function(A,e){return tt.H.useDeferredValue(A,e)};CA.useEffect=function(A,e){return tt.H.useEffect(A,e)};CA.useEffectEvent=function(A){return tt.H.useEffectEvent(A)};CA.useId=function(){return tt.H.useId()};CA.useImperativeHandle=function(A,e,i){return tt.H.useImperativeHandle(A,e,i)};CA.useInsertionEffect=function(A,e){return tt.H.useInsertionEffect(A,e)};CA.useLayoutEffect=function(A,e){return tt.H.useLayoutEffect(A,e)};CA.useMemo=function(A,e){return tt.H.useMemo(A,e)};CA.useOptimistic=function(A,e){return tt.H.useOptimistic(A,e)};CA.useReducer=function(A,e,i){return tt.H.useReducer(A,e,i)};CA.useRef=function(A){return tt.H.useRef(A)};CA.useState=function(A){return tt.H.useState(A)};CA.useSyncExternalStore=function(A,e,i){return tt.H.useSyncExternalStore(A,e,i)};CA.useTransition=function(){return tt.H.useTransition()};CA.version="19.2.8"});var EA=$((dG,ld)=>{"use strict";ld.exports=od()});var Qd=$((ZG,Gs)=>{Gs.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Gs.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Gs.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Kg=$((jG,Qo)=>{var at=global.process,Er=function(A){return A&&typeof A=="object"&&typeof A.removeListener=="function"&&typeof A.emit=="function"&&typeof A.reallyExit=="function"&&typeof A.listeners=="function"&&typeof A.kill=="function"&&typeof A.pid=="number"&&typeof A.on=="function"};Er(at)?(hd=Qt("assert"),Bo=Qd(),pd=/^win/i.test(at.platform),vl=Qt("events"),typeof vl!="function"&&(vl=vl.EventEmitter),at.__signal_exit_emitter__?qt=at.__signal_exit_emitter__:(qt=at.__signal_exit_emitter__=new vl,qt.count=0,qt.emitted={}),qt.infinite||(qt.setMaxListeners(1/0),qt.infinite=!0),Qo.exports=function(A,e){if(!Er(global.process))return function(){};hd.equal(typeof A,"function","a callback must be provided for exit handler"),Co===!1&&Fg();var i="exit";e&&e.alwaysLast&&(i="afterexit");var r=function(){qt.removeListener(i,A),qt.listeners("exit").length===0&&qt.listeners("afterexit").length===0&&bs()};return qt.on(i,A),r},bs=function(){!Co||!Er(global.process)||(Co=!1,Bo.forEach(function(e){try{at.removeListener(e,Us[e])}catch{}}),at.emit=Hs,at.reallyExit=kg,qt.count-=1)},Qo.exports.unload=bs,Ir=function(e,i,r){qt.emitted[e]||(qt.emitted[e]=!0,qt.emit(e,i,r))},Us={},Bo.forEach(function(A){Us[A]=function(){if(Er(global.process)){var i=at.listeners(A);i.length===qt.count&&(bs(),Ir("exit",null,A),Ir("afterexit",null,A),pd&&A==="SIGHUP"&&(A="SIGINT"),at.kill(at.pid,A))}}}),Qo.exports.signals=function(){return Bo},Co=!1,Fg=function(){Co||!Er(global.process)||(Co=!0,qt.count+=1,Bo=Bo.filter(function(e){try{return at.on(e,Us[e]),!0}catch{return!1}}),at.emit=yd,at.reallyExit=md)},Qo.exports.load=Fg,kg=at.reallyExit,md=function(e){Er(global.process)&&(at.exitCode=e||0,Ir("exit",at.exitCode,null),Ir("afterexit",at.exitCode,null),kg.call(at,at.exitCode))},Hs=at.emit,yd=function(e,i){if(e==="exit"&&Er(global.process)){i!==void 0&&(at.exitCode=i);var r=Hs.apply(this,arguments);return Ir("exit",at.exitCode,null),Ir("afterexit",at.exitCode,null),r}else return Hs.apply(this,arguments)}):Qo.exports=function(){return function(){}};var hd,Bo,pd,vl,qt,bs,Ir,Us,Co,Fg,kg,md,Hs,yd});var Nd=$(Ni=>{"use strict";Ni.ConcurrentRoot=1;Ni.ContinuousEventPriority=8;Ni.DefaultEventPriority=32;Ni.DiscreteEventPriority=2;Ni.IdleEventPriority=268435456;Ni.LegacyRoot=0;Ni.NoEventPriority=0});var xs=$((Ab,wd)=>{"use strict";wd.exports=Nd()});var bQ=$(ut=>{"use strict";function gf(A,e){var i=A.length;A.push(e);A:for(;0<i;){var r=i-1>>>1,l=A[r];if(0<Ks(l,e))A[r]=e,A[i]=l,i=r;else break A}}function Tn(A){return A.length===0?null:A[0]}function Ys(A){if(A.length===0)return null;var e=A[0],i=A.pop();if(i!==e){A[0]=i;A:for(var r=0,l=A.length,s=l>>>1;r<s;){var u=2*(r+1)-1,f=A[u],E=u+1,d=A[E];if(0>Ks(f,i))E<l&&0>Ks(d,f)?(A[r]=d,A[E]=i,r=E):(A[r]=f,A[u]=i,r=u);else if(E<l&&0>Ks(d,i))A[r]=d,A[E]=i,r=E;else break A}}return e}function Ks(A,e){var i=A.sortIndex-e.sortIndex;return i!==0?i:A.id-e.id}ut.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(SQ=performance,ut.unstable_now=function(){return SQ.now()}):(sf=Date,DQ=sf.now(),ut.unstable_now=function(){return sf.now()-DQ});var SQ,sf,DQ,$n=[],wi=[],AN=1,Xe=null,oe=3,ff=!1,Ll=!1,_l=!1,Ef=!1,wQ=typeof setTimeout=="function"?setTimeout:null,vQ=typeof clearTimeout=="function"?clearTimeout:null,RQ=typeof setImmediate<"u"?setImmediate:null;function Js(A){for(var e=Tn(wi);e!==null;){if(e.callback===null)Ys(wi);else if(e.startTime<=A)Ys(wi),e.sortIndex=e.expirationTime,gf($n,e);else break;e=Tn(wi)}}function If(A){if(_l=!1,Js(A),!Ll)if(Tn($n)!==null)Ll=!0,Ro||(Ro=!0,Do());else{var e=Tn(wi);e!==null&&Bf(If,e.startTime-A)}}var Ro=!1,Ol=-1,MQ=5,TQ=-1;function GQ(){return Ef?!0:!(ut.unstable_now()-TQ<MQ)}function uf(){if(Ef=!1,Ro){var A=ut.unstable_now();TQ=A;var e=!0;try{A:{Ll=!1,_l&&(_l=!1,vQ(Ol),Ol=-1),ff=!0;var i=oe;try{t:{for(Js(A),Xe=Tn($n);Xe!==null&&!(Xe.expirationTime>A&&GQ());){var r=Xe.callback;if(typeof r=="function"){Xe.callback=null,oe=Xe.priorityLevel;var l=r(Xe.expirationTime<=A);if(A=ut.unstable_now(),typeof l=="function"){Xe.callback=l,Js(A),e=!0;break t}Xe===Tn($n)&&Ys($n),Js(A)}else Ys($n);Xe=Tn($n)}if(Xe!==null)e=!0;else{var s=Tn(wi);s!==null&&Bf(If,s.startTime-A),e=!1}}break A}finally{Xe=null,oe=i,ff=!1}e=void 0}}finally{e?Do():Ro=!1}}}var Do;typeof RQ=="function"?Do=function(){RQ(uf)}:typeof MessageChannel<"u"?(cf=new MessageChannel,NQ=cf.port2,cf.port1.onmessage=uf,Do=function(){NQ.postMessage(null)}):Do=function(){wQ(uf,0)};var cf,NQ;function Bf(A,e){Ol=wQ(function(){A(ut.unstable_now())},e)}ut.unstable_IdlePriority=5;ut.unstable_ImmediatePriority=1;ut.unstable_LowPriority=4;ut.unstable_NormalPriority=3;ut.unstable_Profiling=null;ut.unstable_UserBlockingPriority=2;ut.unstable_cancelCallback=function(A){A.callback=null};ut.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):MQ=0<A?Math.floor(1e3/A):5};ut.unstable_getCurrentPriorityLevel=function(){return oe};ut.unstable_next=function(A){switch(oe){case 1:case 2:case 3:var e=3;break;default:e=oe}var i=oe;oe=e;try{return A()}finally{oe=i}};ut.unstable_requestPaint=function(){Ef=!0};ut.unstable_runWithPriority=function(A,e){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var i=oe;oe=A;try{return e()}finally{oe=i}};ut.unstable_scheduleCallback=function(A,e,i){var r=ut.unstable_now();switch(typeof i=="object"&&i!==null?(i=i.delay,i=typeof i=="number"&&0<i?r+i:r):i=r,A){case 1:var l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}return l=i+l,A={id:AN++,callback:e,priorityLevel:A,startTime:i,expirationTime:l,sortIndex:-1},i>r?(A.sortIndex=i,gf(wi,A),Tn($n)===null&&A===Tn(wi)&&(_l?(vQ(Ol),Ol=-1):_l=!0,Bf(If,i-r))):(A.sortIndex=l,gf($n,A),Ll||ff||(Ll=!0,Ro||(Ro=!0,Do()))),A};ut.unstable_shouldYield=GQ;ut.unstable_wrapCallback=function(A){var e=oe;return function(){var i=oe;oe=e;try{return A.apply(this,arguments)}finally{oe=i}}}});var Cf=$((zb,UQ)=>{"use strict";UQ.exports=bQ()});var HQ=$((qb,Fl)=>{"use strict";Fl.exports=function(A){function e(t,n,o,a){return new i1(t,n,o,a)}function i(){}function r(t){var n="https://react.dev/errors/"+t;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)n+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+t+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(t){var n=t,o=t;if(t.alternate)for(;n.return;)n=n.return;else{t=n;do n=t,(n.flags&4098)!==0&&(o=n.return),t=n.return;while(t)}return n.tag===3?o:null}function s(t){if(l(t)!==t)throw Error(r(188))}function u(t){var n=t.alternate;if(!n){if(n=l(t),n===null)throw Error(r(188));return n!==t?null:t}for(var o=t,a=n;;){var c=o.return;if(c===null)break;var g=c.alternate;if(g===null){if(a=c.return,a!==null){o=a;continue}break}if(c.child===g.child){for(g=c.child;g;){if(g===o)return s(c),t;if(g===a)return s(c),n;g=g.sibling}throw Error(r(188))}if(o.return!==a.return)o=c,a=g;else{for(var B=!1,y=c.child;y;){if(y===o){B=!0,o=c,a=g;break}if(y===a){B=!0,a=c,o=g;break}y=y.sibling}if(!B){for(y=g.child;y;){if(y===o){B=!0,o=g,a=c;break}if(y===a){B=!0,a=g,o=c;break}y=y.sibling}if(!B)throw Error(r(189))}}if(o.alternate!==a)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?t:n}function f(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t;for(t=t.child;t!==null;){if(n=f(t),n!==null)return n;t=t.sibling}return null}function E(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t;for(t=t.child;t!==null;){if(t.tag!==4&&(n=E(t),n!==null))return n;t=t.sibling}return null}function d(t){return t===null||typeof t!="object"?null:(t=iC&&t[iC]||t["@@iterator"],typeof t=="function"?t:null)}function h(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===s1?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Jr:return"Fragment";case Rc:return"Profiler";case eC:return"StrictMode";case wc:return"Suspense";case vc:return"SuspenseList";case Tc:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case Kr:return"Portal";case Ii:return t.displayName||"Context";case nC:return(t._context.displayName||"Context")+".Consumer";case Nc:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Mc:return n=t.displayName||null,n!==null?n:h(t.type)||"Memo";case Bi:n=t._payload,t=t._init;try{return h(t(n))}catch{}}return null}function S(t){return{current:t}}function Q(t){0>qr||(t.current=Lc[qr],Lc[qr]=null,qr--)}function p(t,n){qr++,Lc[qr]=t.current,t.current=n}function D(t){return t>>>=0,t===0?32:31-(LS(t)/_S|0)|0}function v(t){var n=t&42;if(n!==0)return n;switch(t&-t){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function N(t,n,o){var a=t.pendingLanes;if(a===0)return 0;var c=0,g=t.suspendedLanes,B=t.pingedLanes;t=t.warmLanes;var y=a&134217727;return y!==0?(a=y&~g,a!==0?c=v(a):(B&=y,B!==0?c=v(B):o||(o=y&~t,o!==0&&(c=v(o))))):(y=a&~g,y!==0?c=v(y):B!==0?c=v(B):o||(o=a&~t,o!==0&&(c=v(o)))),c===0?0:n!==0&&n!==c&&(n&g)===0&&(g=c&-c,o=n&-n,g>=o||g===32&&(o&4194048)!==0)?n:c}function L(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function uA(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32: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+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function J(){var t=rs;return rs<<=1,(rs&62914560)===0&&(rs=4194304),t}function G(t){for(var n=[],o=0;31>o;o++)n.push(t);return n}function q(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function V(t,n,o,a,c,g){var B=t.pendingLanes;t.pendingLanes=o,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=o,t.entangledLanes&=o,t.errorRecoveryDisabledLanes&=o,t.shellSuspendCounter=0;var y=t.entanglements,U=t.expirationTimes,O=t.hiddenUpdates;for(o=B&~o;0<o;){var W=31-Me(o),Y=1<<W;y[W]=0,U[W]=-1;var eA=O[W];if(eA!==null)for(O[W]=null,W=0;W<eA.length;W++){var BA=eA[W];BA!==null&&(BA.lane&=-536870913)}o&=~Y}a!==0&&fA(t,a,0),g!==0&&c===0&&t.tag!==0&&(t.suspendedLanes|=g&~(B&~n))}function fA(t,n,o){t.pendingLanes|=n,t.suspendedLanes&=~n;var a=31-Me(n);t.entangledLanes|=n,t.entanglements[a]=t.entanglements[a]|1073741824|o&261930}function TA(t,n){var o=t.entangledLanes|=n;for(t=t.entanglements;o;){var a=31-Me(o),c=1<<a;c&n|t[a]&n&&(t[a]|=n),o&=~c}}function AA(t,n){var o=n&-n;return o=(o&42)!==0?1:oA(o),(o&(t.suspendedLanes|n))!==0?0:o}function oA(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function OA(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function FA(t){if(typeof JS=="function"&&YS(t),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(ul,t)}catch{}}function rt(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}function PA(t){if(Fc===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);Fc=n&&n[1]||"",MC=-1<o.stack.indexOf(`
|
|
4
4
|
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
5
5
|
`+Fc+t+MC}function qA(t,n){if(!t||kc)return"";kc=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(n){var Y=function(){throw Error()};if(Object.defineProperty(Y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Y,[])}catch(BA){var eA=BA}Reflect.construct(t,[],Y)}else{try{Y.call()}catch(BA){eA=BA}t.call(Y.prototype)}}else{try{throw Error()}catch(BA){eA=BA}(Y=t())&&typeof Y.catch=="function"&&Y.catch(function(){})}}catch(BA){if(BA&&eA&&typeof BA.stack=="string")return[BA.stack,eA.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=a.DetermineComponentFrameRoot(),B=g[0],y=g[1];if(B&&y){var U=B.split(`
|
|
6
6
|
`),O=y.split(`
|
|
@@ -74,4 +74,4 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
74
74
|
`))}patchConsole(){this.options.debug||(this.restoreConsole=Rd((e,i)=>{e==="stdout"&&this.writeToStdout(i),e==="stderr"&&(i.startsWith("The above error occurred")||this.writeToStderr(i))}))}registerInputControl(e,i){this.pauseInput=e,this.resumeInput=i}async suspendTerminal(e){if(this.beginSuspend(),e){try{await e()}finally{await this.endSuspend()}return}let i=async()=>{await this.endSuspend()};return{resume:i,[Symbol.asyncDispose]:i}}setAlternateScreen(e){this.alternateScreen=this.resolveAlternateScreenOption(e,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,ZA.enterAlternativeScreen),this.writeBestEffort(this.options.stdout,dr))}resolveInteractiveOption(e){return e??(!Ts&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(e,i){return!!e&&i&&!!this.options.stdout.isTTY}shouldSync(){return Ph(this.options.stdout,this.interactive)}writeBestEffort(e,i){try{e.write(i)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){let e=this.container;return(e.pendingLanes??0)!==0&&e.callbackNode!==void 0&&e.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let e,i=new Promise(r=>{e=r});this.nextRenderCommit={promise:i,resolve:e}}return this.nextRenderCommit.promise}renderInteractiveFrame(e,i,r){let l=r!=="",s=this.options.stdout.isTTY,u=s?Pn(this.options.stdout).rows:24,E=s&&i>=u?e:e+`
|
|
75
75
|
`;if(lv({isTty:s,viewportRows:u,previousOutputHeight:this.lastOutputHeight,nextOutputHeight:i,isUnmounting:this.isUnmounting})){let h=this.shouldSync();h&&this.options.stdout.write(pr),this.options.stdout.write(ZA.clearTerminal+this.fullStaticOutput+E),this.lastOutput=e,this.lastOutputToRender=E,this.lastOutputHeight=i,this.log.sync(E),h&&this.options.stdout.write(Ti);return}if(l){let h=this.shouldSync();h&&this.options.stdout.write(pr),this.log.clear(),this.options.stdout.write(r),this.log(E),h&&this.options.stdout.write(Ti)}else(e!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(E);this.lastOutput=e,this.lastOutputToRender=E,this.lastOutputHeight=i}initKittyKeyboard(){if(!this.options.kittyKeyboard)return;let e=this.options.kittyKeyboard,i=e.mode??"auto";if(i==="disabled")return;let r=e.flags??["disambiguateEscapeCodes"];if(i==="enabled"){this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(r);return}!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(r)}confirmKittySupport(e){let{stdin:i,stdout:r}=this.options,l=[],s=()=>{this.cancelKittyDetection=void 0,clearTimeout(f),i.removeListener("data",u);let E=rv(l);l=[],E.length>0&&i.unshift(Uint8Array.from(E))},u=E=>{let d=typeof E=="string"?jw.encode(E):E;for(let h of d)l.push(h);iv(l)&&(s(),this.isUnmounted||this.enableKittyProtocol(e))};i.on("data",u);let f=setTimeout(s,200);this.cancelKittyDetection=s,r.write("\x1B[?u")}enableKittyProtocol(e){this.options.stdout.write(`\x1B[>${nE(e)}u`),this.kittyProtocolEnabled=!0,this.kittyFlags=e}beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{let e=this.options.stdout,{canWriteToStdout:i}=hu(e);Uo(this.throttledOnRender,i),Uo(this.throttledLog,i),i&&(this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&this.writeBestEffort(this.options.stdout,ZA.exitAlternativeScreen)),this.pauseInput?.()}catch(e){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw e}}async endSuspend(){if(!this.isSuspended||(this.isSuspended=!1,this.resumeInput?.(),!this.interactive||this.isUnmounted||this.isUnmounting))return;let e=this.options.stdout,{canWriteToStdout:i}=hu(e);i&&(this.alternateScreen&&this.writeBestEffort(this.options.stdout,ZA.enterAlternativeScreen),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${nE(this.kittyFlags)}u`)),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}};var sv=(A,e)=>{let i={stdout:ca.stdout,stdin:ca.stdin,stderr:ca.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,incrementalRendering:!1,concurrent:!1,alternateScreen:!1,...uv(e)},r=cv(i.stdout,()=>new ua(i));return r.render(A),{rerender:r.render,unmount(){r.unmount()},waitUntilExit:r.waitUntilExit,waitUntilRenderFlush:r.waitUntilRenderFlush,cleanup(){r.unmount()},clear:r.clear}},oE=sv,uv=(A={})=>A instanceof av?{stdout:A,stdin:ca.stdin}:A,cv=(A,e)=>{let i=ra.get(A);if(i===void 0){let r=e();return ra.set(A,r),r}return ca.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
|
|
76
76
|
`),i};var gv=iA(xs(),1);var mu=iA(EA(),1);var _p=iA(EA(),1);var fv=iA(EA(),1);var Ev=iA(EA(),1);var ga=iA(EA(),1);var Op=new TextDecoder,Iv=/^(?:\x1b)([a-zA-Z0-9])$/,Bv=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,kp={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},Kp=[...Object.values(kp),"backspace"],Cv=A=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(A),dv=A=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(A),Jp=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,Qv=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,hv={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},pv={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},Fp={27:"escape",9:"tab",127:"backspace",8:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},Yp=A=>A>=0&&A<=1114111&&!(A>=55296&&A<=57343),lE=A=>Yp(A)?String.fromCodePoint(A):"?";function zp(A){return A===3?"release":A===2?"repeat":"press"}function qp(A){return{ctrl:!!(A&Gn.ctrl),shift:!!(A&Gn.shift),meta:!!(A&(Gn.meta|Gn.alt)),super:!!(A&Gn.super),hyper:!!(A&Gn.hyper),capsLock:!!(A&Gn.capsLock),numLock:!!(A&Gn.numLock)}}var mv=A=>{let e=Jp.exec(A);if(!e)return null;let i=parseInt(e[1],10),r=e[2]?Math.max(0,parseInt(e[2],10)-1):0,l=e[3]?parseInt(e[3],10):1,s=e[4];if(!Yp(i))return null;let u;s&&(u=s.split(":").map(d=>lE(parseInt(d,10))).join(""));let f,E;return i===32?(f="space",E=!0):i===13?(f="return",E=!0):Fp[i]?(f=Fp[i],E=!1):i>=1&&i<=26?(f=String.fromCodePoint(i+96),E=!1):(f=lE(i).toLowerCase(),E=!0),E&&!u&&(u=lE(i)),{name:f,...qp(r),eventType:zp(l),sequence:A,raw:A,isKittyProtocol:!0,isPrintable:E,text:u}},yv=A=>{let e=Qv.exec(A);if(!e)return null;let i=parseInt(e[1],10),r=Math.max(0,parseInt(e[2],10)-1),l=parseInt(e[3],10),s=e[4],u=s==="~"?pv[i]:hv[s];return u?{name:u,...qp(r),eventType:zp(l),sequence:A,raw:A,isKittyProtocol:!0,isPrintable:!1}:null},Sv=(A="")=>{let e;A instanceof Uint8Array?A[0]>127&&A[1]===void 0?(A[0]-=128,A="\x1B"+Op.decode(A)):A=Op.decode(A):A!==void 0&&typeof A!="string"?A=String(A):A||(A="");let i=mv(A);if(i)return i;let r=yv(A);if(r)return r;if(Jp.test(A))return{name:"",ctrl:!1,meta:!1,shift:!1,sequence:A,raw:A,isKittyProtocol:!0,isPrintable:!1};let l={name:"",ctrl:!1,meta:!1,shift:!1,sequence:A,raw:A};if(l.sequence=l.sequence||A||l.name,A==="\r"||A==="\x1B\r")l.raw=void 0,l.name="return",l.meta=A.length===2;else if(A===`
|
|
77
|
-
`)l.name="enter";else if(A===" ")l.name="tab";else if(A==="\b"||A==="\x1B\b")l.name="backspace",l.meta=A.charAt(0)==="\x1B";else if(A==="\x7F"||A==="\x1B\x7F")l.name="backspace",l.meta=A.charAt(0)==="\x1B";else if(A==="\x1B"||A==="\x1B\x1B")l.name="escape",l.meta=A.length===2;else if(A===" "||A==="\x1B ")l.name="space",l.meta=A.length===2;else if(A.length===1&&A<="")l.name=String.fromCharCode(A.charCodeAt(0)+97-1),l.ctrl=!0;else if(A.length===1&&A>="0"&&A<="9")l.name="number";else if(A.length===1&&A>="a"&&A<="z")l.name=A;else if(A.length===1&&A>="A"&&A<="Z")l.name=A.toLowerCase(),l.shift=!0;else if(e=Iv.exec(A))l.name=e[1].toLowerCase(),l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=Bv.exec(A)){let s=[...A];s[0]==="\x1B"&&s[1]==="\x1B"&&(l.meta=!0);let u=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),f=(e[3]||e[5]||1)-1;l.ctrl=!!(f&4),l.meta=l.meta||!!(f&10),l.shift=!!(f&1),l.code=u,l.name=kp[u]??"",l.shift=Cv(u)||l.shift,l.ctrl=dv(u)||l.ctrl}return l},Xp=Sv;var Vp=iA(EA(),1);var aE=()=>(0,Vp.useContext)(Eu);var Dv=(A,e={})=>{let{setRawMode:i,internal_exitOnCtrlC:r,internal_eventEmitter:l}=aE();(0,ga.useEffect)(()=>{if(e.isActive!==!1)return i(!0),()=>{i(!1)}},[e.isActive,i]);let s=(0,ga.useEffectEvent)(u=>{let f=Xp(u),E={upArrow:f.name==="up",downArrow:f.name==="down",leftArrow:f.name==="left",rightArrow:f.name==="right",pageDown:f.name==="pagedown",pageUp:f.name==="pageup",home:f.name==="home",end:f.name==="end",return:f.name==="return",escape:f.name==="escape",ctrl:f.ctrl,shift:f.shift,tab:f.name==="tab",backspace:f.name==="backspace",delete:f.name==="delete",meta:f.meta,super:f.super??!1,hyper:f.hyper??!1,capsLock:f.capsLock??!1,numLock:f.numLock??!1,eventType:f.eventType},d;f.isKittyProtocol?f.isPrintable?d=f.text??f.name:f.ctrl&&f.name.length===1?d=f.name:d="":f.ctrl?d=f.name??"":d=f.sequence,!f.isKittyProtocol&&Kp.includes(f.name)&&(d=""),d.startsWith("\x1B")&&(d=d.slice(1)),d.length===1&&/[A-Z]/.test(d)&&(E.shift=!0),!(d==="c"&&E.ctrl&&r)&&le.discreteUpdates(()=>{A(d,E)})});(0,ga.useEffect)(()=>{if(e.isActive!==!1)return l.on("input",s),()=>{l.removeListener("input",s)}},[e.isActive,l])},mt=Dv;var Zp=iA(EA(),1);var jp=iA(EA(),1);var Rv=()=>(0,jp.useContext)(fu),sE=Rv;var Wp=iA(EA(),1);var Nv=()=>(0,Wp.useContext)(Iu),uE=Nv;var wv=iA(EA(),1);var cE=iA(EA(),1);var Mv=iA(EA(),1);var Tv=iA(EA(),1);var yu=iA(EA(),1);var fa=iA(EA(),1);var Su=iA(EA(),1);var Gv=()=>{let{stdout:A}=uE(),[e,i]=(0,Su.useState)(()=>Pn(A));return(0,Su.useEffect)(()=>{let r=()=>{i(Pn(A))};return A.on("resize",r),()=>{A.off("resize",r)}},[A]),e},gE=Gv;var Du=iA(EA(),1);var it=iA(ye(),1),zA=iA(EA(),1);var IE=iA(ye(),1),JA=iA(EA(),1);import{PassThrough as xv}from"node:stream";var Pp="\x1B[?1000h\x1B[?1002h\x1B[?1003h\x1B[?1006h",Ru="\x1B[?1006l\x1B[?1003l\x1B[?1002l\x1B[?1000l",bv=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])/;function Uv(A,e){if(A&64)return(A&3)===1?"wheel-down":"wheel-up";if(e)return"none";switch(A&3){case 0:return"left";case 1:return"middle";case 2:return"right";default:return"none"}}function Hv(A){return"\x1B[<".startsWith(A.slice(0,3))&&A.length<=32&&/^\x1b(\[(<[\d;]*)?)?$/.test(A)}function $p(A){let e=[],i="",r=0;for(;r<A.length;){let l=A.indexOf("\x1B",r);if(l===-1)return i+=A.slice(r),{events:e,passthrough:i,pending:""};i+=A.slice(r,l);let s=A.slice(l),u=bv.exec(s);if(u){let f=Number(u[1]),E=u[4]==="m",d=(f&32)!==0,h=(f&64)!==0;e.push({type:h?"wheel":d?"move":E?"release":"press",button:Uv(f,E),x:Number(u[2]),y:Number(u[3]),shift:(f&4)!==0,alt:(f&8)!==0,ctrl:(f&16)!==0}),r=l+u[0].length;continue}if(Hv(s))return{events:e,passthrough:i,pending:s};i+="\x1B",r=l+1}return{events:e,passthrough:i,pending:""}}function fE(){let A="";return e=>{let i=$p(A+e);return A=i.pending,{events:i.events,passthrough:i.passthrough}}}function EE(A=process.stdin,e=process.stdout){let i=!!(A.isTTY&&e.isTTY),r=new Set,l=fE(),s=new xv,u=S=>{let Q=typeof S=="string"?S:S.toString("utf8"),{events:p,passthrough:D}=l(Q);for(let v of p)for(let N of r)N(v);D.length>0&&s.write(D)};i&&(A.on("data",u),A.resume());let f=s;f.isTTY=A.isTTY,f.setRawMode=(S=>(A.setRawMode?.(S),f)),f.ref=(()=>(A.ref?.(),f)),f.unref=(()=>(A.unref?.(),f));let E=!1,d=()=>{!i||E||(e.write(Pp),E=!0)},h=()=>{E&&(e.write(Ru),E=!1)};return{stdin:f,supported:i,isEnabled:()=>E,enable:d,disable:h,subscribe(S){return r.add(S),()=>r.delete(S)},dispose(){h(),r.clear(),i&&A.off("data",u)}}}function Lv(A){if(!A?.yogaNode)return null;let e=A.yogaNode.getComputedLayout(),i=0,r=0,l=A;for(;l?.yogaNode;){let s=l.yogaNode.getComputedLayout();i+=s.left,r+=s.top,l=l.parentNode??void 0}return{left:i+1,top:r+1,width:e.width,height:e.height}}function _v(A,e,i){return e>=A.left&&e<A.left+A.width&&i>=A.top&&i<A.top+A.height}var Am=(0,JA.createContext)(null),tm=(0,JA.createContext)(null);function em({source:A,children:e}){let i=(0,JA.useRef)(new Set),r=(0,JA.useRef)(null),[l,s]=(0,JA.useState)(null),[u,f]=(0,JA.useState)(!1),E=(0,JA.useCallback)(D=>(i.current.add(D),()=>{i.current.delete(D),r.current===D&&(r.current=null),s(v=>v===D?null:v)}),[]),d=(0,JA.useCallback)((D,v)=>{let N=null,L=Number.POSITIVE_INFINITY;for(let uA of i.current){let J=Lv(uA.ref.current);if(!J||J.width<=0||J.height<=0||!_v(J,D,v))continue;let G=J.width*J.height;G<L&&(N=uA,L=G)}return N},[]);(0,JA.useEffect)(()=>{if(A)return A.subscribe(D=>{if(D.type==="wheel")return;let v=d(D.x,D.y);if(D.type==="move"){s(N=>N===v?N:v);return}if(D.type==="press"){if(D.button!=="left")return;r.current=v,s(v);return}r.current&&r.current===v&&v?.onClick?.(),r.current=null})},[A,d]),(0,JA.useEffect)(()=>{let D=l;return D?.onHover?.(!0),()=>D?.onHover?.(!1)},[l]);let h=(0,JA.useCallback)(()=>{A&&(A.enable(),f(A.isEnabled()))},[A]),S=(0,JA.useCallback)(()=>{A&&(A.disable(),f(A.isEnabled()))},[A]),Q=(0,JA.useMemo)(()=>({register:E}),[E]),p=(0,JA.useMemo)(()=>({supported:!!A?.supported,enabled:u,enable:h,disable:S}),[A,u,h,S]);return(0,IE.jsx)(Am.Provider,{value:Q,children:(0,IE.jsx)(tm.Provider,{value:p,children:e})})}var Ov={supported:!1,enabled:!1,enable:()=>{},disable:()=>{}};function nm(){return(0,JA.useContext)(tm)??Ov}function Ea(A,{onClick:e,disabled:i=!1}={}){let r=(0,JA.useContext)(Am),[l,s]=(0,JA.useState)(!1),u=(0,JA.useRef)(e);u.current=e;let f=(0,JA.useMemo)(()=>({ref:A,onClick:()=>u.current?.(),onHover:s}),[A]);return(0,JA.useEffect)(()=>{if(!(!r||i))return r.register(f)},[r,f,i]),(0,JA.useEffect)(()=>{i&&s(!1)},[i]),l&&!i}var k={accent:"cyan",border:"gray",muted:"gray",ok:"green",warn:"yellow",bad:"red"},BE="\u25B8",CE=" ",im={ok:k.ok,warn:k.warn,bad:k.bad,idle:k.muted},rm={ok:"\u25CF",warn:"\u25CF",bad:"\u25CF",idle:"\u25CB"};function dE(A,e){return A.includes(e)}var Fv=[{id:"mode",kind:"choice",choices:JC,labelKey:"field.mode"},{id:"port",kind:"text",labelKey:"field.port",visibleFor:["local","lan"]},{id:"lanHost",kind:"address",labelKey:"field.lanHost",visibleFor:["lan"]},{id:"remoteUrl",kind:"text",labelKey:"field.remoteUrl",visibleFor:["remote"]},{id:"publicUrl",kind:"text",labelKey:"field.publicUrl"},{id:"socketPath",kind:"text",labelKey:"field.socketPath"},{id:"herdrArgs",kind:"text",labelKey:"field.herdrArgs"},{id:"herdrAutoStart",kind:"toggle",labelKey:"field.herdrAutoStart"},{id:"language",kind:"choice",choices:ug,labelKey:"field.language"},{id:"keepaliveManager",kind:"choice",choices:so,labelKey:"field.keepalive"}],je="",kv=["local","lan","official","remote"];function mr(A){return A.relay.mode==="remote"&&A.relay.remoteUrl===Ri?"official":A.relay.mode}function QE(A){return mr(A)==="official"}function lm(A){return JSON.parse(JSON.stringify(A))}function Nu(A=Zn()){return lm(A)}function hE(A){return Fv.filter(e=>!e.visibleFor||e.visibleFor.includes(A))}function Ho(A,e){switch(e){case"mode":return A.relay.mode;case"port":return String(A.relay.port);case"lanHost":return A.relay.lanHost||je;case"remoteUrl":return A.relay.remoteUrl||je;case"publicUrl":return A.relay.publicUrl||je;case"socketPath":return A.herdr.socketPath||je;case"herdrArgs":return(A.herdr.args||[]).join(" ");case"herdrAutoStart":return A.herdr.autoStart?"on":"off";case"language":return A.ui.language;case"keepaliveManager":return A.keepalive.manager;default:return je}}function Ia(A,e){switch(e){case"lanHost":return Bg()||"0.0.0.0";case"publicUrl":return kC(A,Bg());case"socketPath":return"placeholder.autoDiscovered";case"herdrArgs":return"placeholder.none";case"remoteUrl":return"wss://relay.example.com";default:return je}}function om(A,e){try{let i=new URL(A);return e.includes(i.protocol)}catch{return!1}}function dn(A,e,i){let r=lm(A),l=typeof i=="string"?i.trim():i,s=l;switch(e){case"mode":{if(!dE(kv,l))return{draft:A,errorKey:"error.invalidMode"};if(l==="official"){r.relay.mode="remote",r.relay.remoteUrl=Ri,r.relay.publicUrl=je;break}l==="remote"&&r.relay.remoteUrl===Ri&&(r.relay.remoteUrl=je),r.relay.mode=l,l==="lan"&&(Ss(r.relay.lanHost)||Ds(r.relay.lanHost))&&(r.relay.lanHost=je),r.relay.publicUrl=je;break}case"port":{let u=Number.parseInt(s,10);if(!Number.isInteger(u)||u<1||u>65535)return{draft:A,errorKey:"error.invalidPort"};r.relay.port=u;break}case"lanHost":{if(s&&(Ss(s)||Ds(s)))return{draft:A,errorKey:"error.invalidLanHost"};r.relay.lanHost=s||je;break}case"remoteUrl":{if(s&&!om(s,["ws:","wss:","http:","https:"]))return{draft:A,errorKey:"error.invalidRelayUrl"};r.relay.remoteUrl=s.replace(/\/+$/,"");break}case"publicUrl":{if(s&&(!om(s,["http:","https:"])||FC(s)))return{draft:A,errorKey:"error.invalidPublicUrl"};r.relay.publicUrl=s.replace(/\/+$/,"");break}case"socketPath":{r.herdr.socketPath=s||null;break}case"herdrArgs":{let u=s?s.split(/\s+/).filter(Boolean):[];if(u.includes("--no-session"))return{draft:A,errorKey:"error.removedHerdrArg"};r.herdr.args=u;break}case"herdrAutoStart":{if(l!==!0&&l!==!1&&l!=="on"&&l!=="off")return{draft:A,errorKey:"error.unknownField"};r.herdr.autoStart=l===!0||l==="on";break}case"language":{if(!dE(ug,l))return{draft:A,errorKey:"error.invalidLanguage"};r.ui.language=l;break}case"keepaliveManager":{if(!dE(so,l))return{draft:A,errorKey:"error.invalidKeepalive"};r.keepalive.manager=l;break}default:return{draft:A,errorKey:"error.unknownField"}}return{draft:r,errorKey:null}}function Kv(A){let e=[];return A.relay.mode==="remote"&&!A.relay.remoteUrl&&e.push("error.remoteUrlRequired"),e}function Qn(A){let e=Kv(A);if(e.length>0)throw Object.assign(new Error(`configuration is incomplete: ${e.join(", ")}`),{problems:e});let i=qC(vn(),{})||{},r={...i};r.ui={...i.ui||{},language:A.ui.language};let l={...i.relay||{},mode:A.relay.mode,port:A.relay.port,lanHost:A.relay.mode==="lan"&&(Ss(A.relay.lanHost)||Ds(A.relay.lanHost))?je:A.relay.lanHost,publicUrl:A.relay.publicUrl,remoteUrl:A.relay.remoteUrl};r.relay=l,delete l.local,delete l.host,delete l.url,delete r.patch;let s={...i.herdr||{},socketPath:A.herdr.socketPath,args:A.herdr.args,autoStart:A.herdr.autoStart===!0};return r.herdr=s,s.socketPath||delete s.socketPath,r.keepalive={...i.keepalive||{},manager:A.keepalive.manager},YC(OC()),zC(vn(),r),{ok:!0,path:vn()}}function pE(A,e){return A.relay.mode!==e.relay.mode||A.relay.port!==e.relay.port||A.relay.lanHost!==e.relay.lanHost||A.relay.remoteUrl!==e.relay.remoteUrl||A.relay.publicUrl!==e.relay.publicUrl||A.herdr.socketPath!==e.herdr.socketPath||A.herdr.args.join(" ")!==e.herdr.args.join(" ")}async function mE({waitForStart:A=!1}={}){if(process.platform!=="win32")return!1;let e=await import("../connector/admin-broker.js");return A?e.waitForAdminBroker():e.adminBrokerStatus()}async function am(A,e){return(await import("./QRQJLJWT.js")).configureAdminBroker(A,e)}function sm(A,e){let r=["herdr-remote-relay",`--public-url ${A.relay.remoteUrl?A.relay.remoteUrl.replace(/^ws/,"http"):"https://relay.example.com"}`,"--trust-proxy"];return e&&r.push(`--password '${e.replace(/'/g,"'\\''")}'`),r.join(" ")}async function um(A){let e=KC(A),i;try{i=await fg(`${e}/healthz`,{timeout:4e3})}catch(r){return{ok:!1,message:r.message}}try{let r=ml(),l=await fg(`${e}/api/status`,{timeout:4e3,headers:{"X-Herdr-Host-Id":r.hostId,"X-Herdr-Host-Token":r.hostToken}});return{ok:!0,version:String(i.version||l.version||""),hosts:Array.isArray(l.hosts)?l.hosts.length:0}}catch{return{ok:!0,version:String(i.version||""),hosts:void 0}}}function cm(A,e){if(!Number.isFinite(A))return e("common.unknown");let i=Math.max(0,Math.floor(A)),r=Math.floor(i/3600),l=Math.floor(i%3600/60);return r>0?`${r}h ${l}m`:l>0?`${l}m ${i%60}s`:`${i}s`}var IA=iA(ye(),1);var ht=iA(ye(),1),xo=iA(EA(),1);function Ai({level:A}){return(0,ht.jsx)(x,{color:im[A],children:rm[A]})}var Jv=20;function et({label:A,labelWidth:e=Jv,children:i}){return(0,ht.jsxs)(X,{children:[(0,ht.jsx)(X,{width:e,flexShrink:0,children:(0,ht.jsx)(x,{color:k.muted,wrap:"truncate-end",children:A})}),(0,ht.jsx)(X,{flexGrow:1,children:i})]})}function xe({selected:A,disabled:e=!1,onSelect:i,onHover:r,children:l}){let s=(0,xo.useRef)(null),u=Ea(s,{disabled:e,onClick:i});gm(u,r);let f=A||u,E=e?k.muted:f?k.accent:void 0;return(0,ht.jsxs)(X,{ref:s,children:[(0,ht.jsxs)(x,{color:f?k.accent:void 0,children:[f?BE:CE," "]}),(0,ht.jsx)(x,{color:E,bold:f,dimColor:e,children:l})]})}function gm(A,e){let i=(0,xo.useRef)(e);i.current=e,(0,xo.useEffect)(()=>{A&&i.current?.()},[A])}function Lo({items:A,selectedId:e,onChange:i,onSelect:r}){return(0,ht.jsx)(X,{flexDirection:"column",children:A.map(l=>(0,ht.jsx)(xe,{selected:l.id===e,disabled:l.disabled,onSelect:()=>r(l.id),onHover:()=>i(l.id),children:l.label},l.id))})}function Ui({label:A,selected:e,disabled:i=!1,labelWidth:r=22,onSelect:l,onHover:s,children:u}){let f=(0,xo.useRef)(null),E=Ea(f,{disabled:i,onClick:l});gm(E,s);let d=e||E;return(0,ht.jsxs)(X,{ref:f,children:[(0,ht.jsxs)(X,{width:r,flexShrink:0,children:[(0,ht.jsxs)(x,{color:d?k.accent:void 0,children:[d?BE:CE," "]}),(0,ht.jsx)(x,{color:d?k.accent:k.muted,bold:d,wrap:"truncate-end",children:A})]}),(0,ht.jsx)(X,{flexGrow:1,children:u})]})}function nt({title:A,children:e}){return(0,ht.jsxs)(X,{flexDirection:"column",borderStyle:"round",borderColor:k.border,paddingX:1,flexGrow:1,children:[A?(0,ht.jsx)(X,{marginBottom:1,children:(0,ht.jsx)(x,{bold:!0,children:A})}):null,e]})}function yt({text:A,level:e}){if(!A)return null;let i=e==="error"?k.bad:e==="success"?k.ok:k.muted;return(0,ht.jsx)(X,{marginTop:1,children:(0,ht.jsx)(x,{color:i,children:A})})}function fm(A){return A==null?"idle":A?"ok":"bad"}function Em({ctx:A}){let{t:e,status:i,config:r}=A;if(!i)return(0,IA.jsx)(nt,{title:e("overview.title"),children:(0,IA.jsx)(x,{color:k.muted,children:e("common.loading")})});let l=i.relay.health||{},s=l.ok!==!1,u=i.relay.local?fm(i.relay.alive):s?"ok":"bad",f=i.keepalive.active?"ok":i.keepalive.installed?"warn":"idle",E=!i.host.alive&&(i.relay.local?!i.relay.alive:!s);return(0,IA.jsxs)(nt,{title:e("overview.title"),children:[(0,IA.jsx)(et,{label:e("overview.mode"),children:(0,IA.jsx)(x,{children:e(`mode.${i.mode}`)})}),(0,IA.jsx)(et,{label:e("overview.relay"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:u}),(0,IA.jsxs)(x,{children:[" ",i.relay.local?e("overview.relayLocal",{bind:i.relay.bind??"",port:i.relay.port}):e("overview.relayRemote",{url:i.relay.remoteUrl??""})]}),i.relay.local&&i.relay.pid?(0,IA.jsx)(x,{color:k.muted,children:` ${e("common.pid",{pid:i.relay.pid})}`}):null]})}),(0,IA.jsx)(et,{label:e("overview.host"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:fm(i.host.alive)}),(0,IA.jsx)(x,{children:` ${i.host.alive?e("common.running"):e("common.stopped")}`}),i.host.pid?(0,IA.jsx)(x,{color:k.muted,children:` ${e("common.pid",{pid:i.host.pid})}`}):null]})}),(0,IA.jsx)(et,{label:e("overview.socket"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:i.host.socketExists?"ok":"warn"}),(0,IA.jsx)(x,{color:k.muted,children:` ${i.host.socketPath}`}),i.host.socketExists?null:(0,IA.jsx)(x,{color:k.warn,children:` ${e("overview.socketMissing")}`})]})}),(0,IA.jsx)(et,{label:e("overview.webUrl"),children:(0,IA.jsx)(x,{color:k.accent,children:i.publicUrl})}),(0,IA.jsx)(et,{label:e("overview.keepalive"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:f}),(0,IA.jsxs)(x,{children:[` ${i.keepalive.manager} \u2014 `,i.keepalive.active?e("common.running"):i.keepalive.installed?e("common.installed"):e("common.notInstalled")]})]})}),(0,IA.jsx)(X,{marginTop:1,flexDirection:"column",children:s?(0,IA.jsxs)(IA.Fragment,{children:[typeof l.hosts=="number"?(0,IA.jsx)(et,{label:e("overview.hosts"),children:(0,IA.jsx)(x,{children:l.hosts})}):null,typeof l.clients=="number"?(0,IA.jsx)(et,{label:e("overview.devices"),children:(0,IA.jsx)(x,{children:l.clients})}):null,(0,IA.jsx)(et,{label:e("overview.uptime"),children:(0,IA.jsx)(x,{color:k.muted,children:cm(l.uptimeSeconds,e)})})]}):(0,IA.jsx)(x,{color:k.warn,children:e("overview.unreachable",{message:l.message??""})})}),E?(0,IA.jsx)(X,{marginTop:1,children:(0,IA.jsx)(x,{color:k.muted,children:e("overview.notStarted")})}):null,r.relay.mode==="local"?(0,IA.jsx)(X,{marginTop:1,children:(0,IA.jsx)(x,{color:k.muted,children:e("mode.local.description")})}):null,(0,IA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var St=iA(ye(),1),Ki=iA(EA(),1);var Dy=iA(yy(),1);var Sy=44;function Ry({ctx:A}){let{t:e,run:i}=A,{columns:r}=gE(),[l,s]=(0,Ki.useState)(null),[u,f]=(0,Ki.useState)(null),[E,d]=(0,Ki.useState)(0),[h,S]=(0,Ki.useState)("generate");(0,Ki.useEffect)(()=>{if(!l)return;let N=()=>d(Math.max(0,l.expiresAt-Date.now()));N();let L=setInterval(N,1e3);return()=>clearInterval(L)},[l]),(0,Ki.useEffect)(()=>{if(!l||r<Sy){f(null);return}let N=!1;return Dy.default.toString(l.pairUrl,{type:"terminal",small:!0,errorCorrectionLevel:"L"}).then(L=>{N||f(L.replace(/\n$/,""))}).catch(()=>{N||f(null)}),()=>{N=!0}},[l,r]);let Q=()=>i(async()=>{A.notify(N=>N("pair.working"));try{let N=await Dg(),L=Eg(N);s({...N,code:L}),A.notify("","info")}catch(N){let L=N.message;throw s(null),new Error(/host_offline|no Herdr host|did not register/i.test(L)?e("pair.hostOffline"):e("pair.failed",{message:L}))}});mt((N,L)=>{L.return&&Q()},{isActive:A.editingId===null});let p=l!==null&&E<=0,D=Math.floor(E/6e4),v=Math.floor(E%6e4/1e3);return(0,St.jsxs)(nt,{title:e("pair.title"),children:[(0,St.jsx)(Lo,{items:[{id:"generate",label:e(l?"pair.regenerate":"pair.generate")}],selectedId:h,onChange:S,onSelect:Q}),l?(0,St.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,St.jsxs)(X,{children:[(0,St.jsx)(x,{color:k.muted,children:`${e("pair.code")} `}),(0,St.jsx)(x,{bold:!0,color:p?k.muted:k.accent,children:l.code.split("").join(" ")})]}),(0,St.jsxs)(X,{children:[(0,St.jsx)(x,{color:k.muted,children:`${e("pair.url")} `}),(0,St.jsx)(x,{children:l.pairUrl})]}),(0,St.jsx)(X,{marginTop:1,children:(0,St.jsx)(x,{color:p?k.bad:k.muted,children:p?e("pair.expired"):e("pair.expires",{minutes:`${D}:${String(v).padStart(2,"0")}`,time:new Date(l.expiresAt).toLocaleTimeString()})})}),!p&&u?(0,St.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,St.jsx)(x,{children:u}),(0,St.jsx)(x,{color:k.muted,children:e("pair.qrHint")})]}):null,!p&&!u&&r<Sy?(0,St.jsx)(X,{marginTop:1,children:(0,St.jsx)(x,{color:k.muted,children:e("pair.qrUnavailable")})}):null,(0,St.jsx)(X,{marginTop:1,children:(0,St.jsx)(x,{color:k.muted,children:e("pair.instructions")})})]}):null,(0,St.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var Pt=iA(ye(),1),vy=iA(EA(),1);var Ny=8;function My({ctx:A}){let{t:e,run:i,status:r}=A,[l,s]=(0,vy.useState)("start"),u=[{id:"start",label:e("services.start")},{id:"stop",label:e("services.stop")},{id:"restart",label:e("services.restart")}],f=h=>{if(A.dirty&&h!=="stop"){A.notify(S=>S("services.unsavedBlocked"),"error");return}return i(()=>{let S=A.config;if(h==="start"){let p=Rl(S);A.notify(D=>p.managed?D("services.managedNotice",{manager:p.manager??""}):D("services.started"),"success");return}if(h==="stop"){let p=Rg(S);A.notify(D=>p.managed?D("services.managedNotice",{manager:p.manager??""}):D("services.stopped"),"success");return}let Q=Ng(S);A.notify(p=>Q.managed?p("services.managedNotice",{manager:Q.manager??""}):p("services.restarted"),"success")})};mt((h,S)=>{let Q=u.findIndex(p=>p.id===l);S.upArrow?s(u[(Q-1+u.length)%u.length].id):S.downArrow?s(u[(Q+1)%u.length].id):S.return&&f(l)},{isActive:A.editingId===null});let E=Rs("relay",Ny),d=Rs("host",Ny);return(0,Pt.jsxs)(nt,{title:e("services.title"),children:[(0,Pt.jsx)(Lo,{items:u,selectedId:l,onChange:s,onSelect:f}),A.dirty?(0,Pt.jsx)(X,{marginTop:1,children:(0,Pt.jsx)(x,{color:k.warn,children:e("services.unsavedBlocked")})}):null,r?.keepalive.installed?(0,Pt.jsx)(X,{marginTop:1,children:(0,Pt.jsx)(x,{color:k.muted,children:e("services.managedNotice",{manager:r.keepalive.manager})})}):null,(0,Pt.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,Pt.jsx)(x,{color:k.muted,children:e("services.logs")}),(0,Pt.jsx)(wy,{title:e("services.logRelay"),lines:E,emptyText:e("services.logEmpty")}),(0,Pt.jsx)(wy,{title:e("services.logHost"),lines:d,emptyText:e("services.logEmpty")})]}),(0,Pt.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}function wy({title:A,lines:e,emptyText:i}){return(0,Pt.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,Pt.jsx)(x,{bold:!0,color:k.muted,children:A}),e.length===0?(0,Pt.jsx)(x,{color:k.muted,children:i}):e.map((r,l)=>(0,Pt.jsx)(x,{color:k.muted,wrap:"truncate-end",children:r},l))]})}var vA=iA(ye(),1),ei=iA(EA(),1);var vr=iA(ye(),1),Ku=iA(EA(),1);var rG=/[\x00-\x1f\x7f]/;function Ji({value:A,placeholder:e,active:i,mask:r=!1,onSubmit:l,onCancel:s}){let[u,f]=(0,Ku.useState)(A);(0,Ku.useEffect)(()=>{i&&f(A)},[i,A]),mt((h,S)=>{if(S.return){l(u);return}if(S.escape){f(A),s();return}if(S.backspace||S.delete){f(Q=>Q.slice(0,-1));return}if(S.ctrl&&h==="u"){f("");return}h&&!S.ctrl&&!S.meta&&!rG.test(h)&&f(Q=>Q+h)},{isActive:i});let E=i?u:A,d=r&&E?"\u2022".repeat(Math.min(E.length,32)):E;return i?(0,vr.jsxs)(X,{children:[(0,vr.jsx)(x,{color:k.accent,children:d}),(0,vr.jsx)(x,{color:k.accent,inverse:!0,children:" "})]}):d?(0,vr.jsx)(x,{children:d}):(0,vr.jsx)(x,{color:k.muted,children:e??""})}function Gy({ctx:A}){let{t:e,draft:i,editingId:r}=A,[l,s]=(0,ei.useState)("mode"),[u,f]=(0,ei.useState)(!1),[E,d]=(0,ei.useState)(!1),[h,S]=(0,ei.useState)(A.runtime.relayPassword||""),Q=QE(i),D=[...(0,ei.useMemo)(()=>hE(i.relay.mode).filter(G=>["mode","port","lanHost","remoteUrl","publicUrl"].includes(G.id)),[i.relay.mode]).map(G=>({id:G.id,kind:Q&&(G.id==="remoteUrl"||G.id==="publicUrl")?"readonly":"field",fieldKind:G.kind,label:e(G.labelKey)})),...i.relay.mode==="remote"&&!Q?[{id:"password",kind:"password",label:e("relay.password")}]:[],{id:"save",kind:"action",label:e("common.save")},{id:"test",kind:"action",label:e("relay.test")},...i.relay.mode==="remote"&&!Q?[{id:"reveal",kind:"action",label:e(u?"relay.hidePassword":"relay.showPassword")},{id:"env",kind:"action",label:e("relay.envSnippet")}]:[],{id:"regenerate",kind:"action",label:e("relay.regenerate")}],v=(0,ei.useMemo)(()=>Sl({includeLoopback:!1}),[]),N=G=>{let q=i;for(let[V,fA]of G){let TA=dn(q,V,fA),{errorKey:AA}=TA;if(AA)return A.notify(oA=>oA(AA),"error"),!1;q=TA.draft}return A.updateDraft(q),A.notify("","info"),!0},L=(G,q)=>N([[G,q]]),uA=()=>{try{let G=Qn(i);A.reloadConfig(),A.notify(q=>q("common.saved",{path:G.path}),"success")}catch(G){let q=G.problems;A.notify(V=>q?q.map(fA=>V(fA)).join(" "):V("error.saveFailed",{message:G.message}),"error")}},J=G=>{let q=D.find(V=>V.id===G);if(q){if(q.kind==="readonly"){A.notify(V=>V("relay.officialFixed"),"info");return}if(q.kind==="field"||q.kind==="password"){A.setEditing(G);return}if(G==="save"){uA();return}if(G==="reveal"){f(V=>!V);return}if(G==="env"){d(V=>!V);return}if(G==="regenerate"){A.run(()=>{gg(),A.reloadConfig(),A.notify(V=>V("relay.regenerated"),"success")});return}G==="test"&&A.run(async()=>{let V=await um(A.config);A.notify(fA=>V.ok?fA("relay.testOk",{version:V.version??"?",hosts:V.hosts??0}):fA("relay.testFailed",{message:V.message??""}),V.ok?"success":"error")})}};if(mt((G,q)=>{let V=D.findIndex(fA=>fA.id===l);q.upArrow?s(D[(V-1+D.length)%D.length].id):q.downArrow?s(D[(V+1)%D.length].id):q.return?J(l):G==="s"&&uA()},{isActive:r===null}),r==="mode")return(0,vA.jsx)(nt,{title:e("field.mode"),children:(0,vA.jsx)(Yi,{options:[...["local","lan"].map(G=>({id:G,label:e(`mode.${G}`),description:e(`mode.${G}.description`)})),{id:"official",label:e("mode.official"),description:e("mode.official.description")},{id:"remote",label:e("mode.remote"),description:e("mode.remote.description")}],current:mr(i),onPick:G=>{L("mode",G)&&(G==="official"&&(S(""),gr("")),A.setEditing(null))},onCancel:()=>A.setEditing(null)})});if(r==="lanHost"){let G=v.map(q=>({id:q.address,label:`${q.address} (${q.name}, ${e(oG(q.kind))})`}));return(0,vA.jsx)(nt,{title:e("relay.selectAddress"),children:G.length===0?(0,vA.jsx)(x,{color:k.warn,children:e("relay.noAddresses")}):(0,vA.jsx)(Yi,{options:G,current:i.relay.lanHost||G[0].id,onPick:q=>{L("lanHost",q),A.setEditing(null)},onCancel:()=>A.setEditing(null)})})}return(0,vA.jsxs)(nt,{title:e("relay.title"),children:[i.relay.mode!=="remote"?(0,vA.jsxs)(X,{flexDirection:"column",marginBottom:1,children:[(0,vA.jsx)(et,{label:e("relay.listenAddress"),children:(0,vA.jsx)(x,{color:k.muted,children:`${sg(i)}:${i.relay.port}`})}),(0,vA.jsx)(x,{color:k.muted,children:e("relay.listenAddressHint")})]}):null,D.map(G=>G.kind==="action"?(0,vA.jsx)(xe,{selected:l===G.id,onSelect:()=>{s(G.id),J(G.id)},onHover:()=>s(G.id),children:G.label},G.id):(0,vA.jsx)(Ui,{label:G.label,selected:l===G.id,onSelect:()=>J(G.id),onHover:()=>s(G.id),children:G.kind==="password"?(0,vA.jsx)(Ji,{value:h,placeholder:e("relay.passwordEmpty"),active:r==="password",mask:!u,onSubmit:q=>{S(q),gr(q),A.setEditing(null),A.notify(V=>V("relay.passwordSaved"),"success")},onCancel:()=>A.setEditing(null)}):G.kind==="readonly"?(0,vA.jsx)(x,{color:k.muted,children:`${Ho(i,G.id)||Ty(A,G.id)} (${e("relay.locked")})`}):G.fieldKind==="choice"?(0,vA.jsx)(x,{children:e(`mode.${mr(i)}`)}):(0,vA.jsx)(Ji,{value:Ho(i,G.id),placeholder:Ty(A,G.id),active:r===G.id,onSubmit:q=>{L(G.id,q)&&A.setEditing(null)},onCancel:()=>A.setEditing(null)})},G.id)),A.dirty?(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.warn,children:e("hint.unsavedChanges")})}):null,i.relay.mode==="remote"?(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.muted,children:e(Q?"relay.officialHint":"relay.passwordHint")})}):null,(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(et,{label:e("relay.identity"),children:(0,vA.jsx)(x,{color:k.muted,children:A.runtime.hostId})})}),E?(0,vA.jsxs)(X,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:k.border,paddingX:1,children:[(0,vA.jsx)(x,{color:k.muted,children:e("relay.envHint")}),(0,vA.jsx)(x,{children:sm(A.config,h)})]}):null,Q?null:(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.muted,children:e("relay.docsHint")})}),(0,vA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}function Ty(A,e){let i=Ia(A.draft,e);return i.startsWith("placeholder.")?A.t(i):i}function oG(A){return`relay.address${A.charAt(0).toUpperCase()}${A.slice(1)}`}function Yi({options:A,current:e,onPick:i,onCancel:r}){let[l,s]=(0,ei.useState)(()=>{let f=A.findIndex(E=>E.id===e);return f>=0?f:0}),u=A[Math.min(l,A.length-1)];return mt((f,E)=>{if(E.escape){r();return}E.upArrow?s(d=>(d-1+A.length)%A.length):E.downArrow?s(d=>(d+1)%A.length):E.return&&u&&i(u.id)}),(0,vA.jsxs)(X,{flexDirection:"column",children:[(0,vA.jsx)(Lo,{items:A.map(f=>({id:f.id,label:f.label})),selectedId:u?.id??"",onChange:f=>s(A.findIndex(E=>E.id===f)),onSelect:i}),u?.description?(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.muted,children:u.description})}):null]})}var YA=iA(ye(),1),wa=iA(EA(),1);function by({ctx:A}){let{t:e,status:i,draft:r,editingId:l}=A,[s,u]=(0,wa.useState)("install"),[f,E]=(0,wa.useState)(null);(0,wa.useEffect)(()=>{if(process.platform!=="win32")return;let Q=!1;return mE().then(p=>{Q||E(p)}).catch(()=>{Q||E(!1)}),()=>{Q=!0}},[]);let d=i?.keepalive,h=[{id:"install",label:e("keepalive.install")},{id:"restart",label:e("keepalive.restart")},{id:"uninstall",label:e("keepalive.uninstall")},{id:"manager",label:`${e("keepalive.manager")}: ${r.keepalive.manager}`},...process.platform==="linux"&&d?.manager==="systemd"&&!d?.linger?[{id:"linger",label:e("keepalive.enableLinger")}]:[],...process.platform==="win32"?[{id:"adminBrokerInstall",label:e("adminBroker.install")},{id:"adminBrokerUninstall",label:e("adminBroker.uninstall")}]:[]],S=Q=>{if(Q==="manager"){A.setEditing("keepaliveManager");return}if(Q==="adminBrokerInstall"||Q==="adminBrokerUninstall"){let p=Q==="adminBrokerInstall"?"install":"uninstall";A.run(async()=>{let D=!1;try{await am(p,e),D=p==="install"&&await mE({waitForStart:!0})}catch(v){if(v.code==="ELEVATION_CANCELLED"){A.notify(N=>N("adminBroker.elevationCancelled"),"info");return}throw v}E(D),A.notify(v=>v(`adminBroker.${p}Done`),"success")});return}A.run(async()=>{if(Q==="install"){Mn.detectManager(A.config.keepalive.manager)==="windows-service"&&A.notify(p=>p("keepalive.serviceWindowHint"),"info");try{let p=await Mn.install(A.config);A.notify(D=>D("keepalive.installed",{manager:p.manager}),"success")}catch(p){if(p.code==="ELEVATION_CANCELLED"){A.notify(D=>D("keepalive.elevationCancelled"),"info");return}throw p}return}if(Q==="uninstall"){await Mn.uninstall(A.config),A.notify(p=>p("keepalive.uninstalled"),"success");return}if(Q==="restart"){Mn.restart(A.config),A.notify(p=>p("keepalive.restarted"),"success");return}if(Q==="linger"){let p=Mn.enableLinger();A.notify(D=>D("keepalive.lingerDone",{username:p.username}),"success")}})};return mt((Q,p)=>{let D=h.findIndex(v=>v.id===s);p.upArrow?u(h[(D-1+h.length)%h.length].id):p.downArrow?u(h[(D+1)%h.length].id):p.return&&S(s)},{isActive:l===null}),l==="keepaliveManager"?(0,YA.jsx)(nt,{title:e("field.keepalive"),children:(0,YA.jsx)(Yi,{options:so.map(Q=>({id:Q,label:Q})),current:r.keepalive.manager,onPick:Q=>{let p=dn(r,"keepaliveManager",Q),{errorKey:D}=p;if(D){A.notify(v=>v(D),"error");return}A.updateDraft(p.draft);try{Qn(p.draft),A.reloadConfig()}catch(v){A.notify(N=>N("error.saveFailed",{message:v.message}),"error")}A.setEditing(null)},onCancel:()=>A.setEditing(null)})}):(0,YA.jsxs)(nt,{title:e("keepalive.title"),children:[(0,YA.jsx)(et,{label:e("keepalive.manager"),children:(0,YA.jsx)(x,{children:d?.manager??e("common.unknown")})}),(0,YA.jsx)(et,{label:e("keepalive.state"),children:(0,YA.jsxs)(X,{children:[(0,YA.jsx)(Ai,{level:d?.active?"ok":d?.installed?"warn":"idle"}),(0,YA.jsxs)(x,{children:[" ",d?.active?e("common.running"):d?.installed?e("common.installed"):e("common.notInstalled")]})]})}),process.platform==="win32"?(0,YA.jsxs)(YA.Fragment,{children:[(0,YA.jsx)(et,{label:e("adminBroker.title"),children:(0,YA.jsx)(x,{color:f?k.ok:k.warn,children:e(f===null?"adminBroker.checking":f?"adminBroker.ready":"adminBroker.notReady")})}),(0,YA.jsx)(x,{color:k.muted,children:e("adminBroker.tuiHint")})]}):null,d?.unitPath?(0,YA.jsx)(et,{label:e("keepalive.unitPath"),children:(0,YA.jsx)(x,{color:k.muted,children:d.unitPath})}):null,(0,YA.jsx)(X,{marginTop:1,flexDirection:"column",children:h.map(Q=>(0,YA.jsx)(xe,{selected:s===Q.id,onSelect:()=>{u(Q.id),S(Q.id)},onHover:()=>u(Q.id),children:Q.label},Q.id))}),(0,YA.jsxs)(X,{marginTop:1,flexDirection:"column",children:[d?.manager==="systemd"?(0,YA.jsx)(x,{color:d.linger?k.muted:k.warn,children:d.linger?e("keepalive.lingerEnabled"):e("keepalive.lingerDisabled")}):null,d?.manager==="supervisor"?(0,YA.jsx)(x,{color:k.warn,children:e("keepalive.fallbackNote")}):null,d?.manager==="windows-task"?(0,YA.jsx)(x,{color:k.muted,children:e("keepalive.windowsTaskNote")}):null,d?.manager==="windows-service"?(0,YA.jsx)(x,{color:k.warn,children:e("keepalive.serviceNote")}):null,(0,YA.jsx)(x,{color:k.muted,children:e("keepalive.logsHint",{command:i?.logsHint??""})})]}),(0,YA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var Dt=iA(ye(),1),va=iA(EA(),1);function Uy({ctx:A}){let{t:e,draft:i,editingId:r}=A,[l,s]=(0,va.useState)("socketPath"),[u,f]=(0,va.useState)(null);(0,va.useEffect)(()=>{f(Sg())},[]);let E=[{id:"socketPath",kind:"field",label:e("herdr.socketPath")},{id:"herdrArgs",kind:"field",label:e("herdr.args")},{id:"herdrAutoStart",kind:"toggle",label:e("field.herdrAutoStart")},{id:"save",kind:"action",label:e("common.save")}],d=(Q,p)=>{let D=dn(i,Q,p),{errorKey:v}=D;return v?(A.notify(N=>N(v),"error"),!1):(A.updateDraft(D.draft),!0)},h=()=>{try{let Q=Qn(i);A.reloadConfig(),A.notify(p=>p("common.saved",{path:Q.path}),"success")}catch(Q){A.notify(p=>p("error.saveFailed",{message:Q.message}),"error")}},S=Q=>{if(Q==="socketPath"||Q==="herdrArgs"){A.setEditing(Q);return}if(Q==="herdrAutoStart"){d(Q,i.herdr.autoStart?"off":"on");return}Q==="save"&&h()};return mt((Q,p)=>{let D=E.findIndex(N=>N.id===l),v=D>=0?D:0;p.upArrow?s(E[(v-1+E.length)%E.length].id):p.downArrow?s(E[(v+1)%E.length].id):p.return?S(l):Q==="s"&&h()},{isActive:r===null}),(0,Dt.jsxs)(nt,{title:e("herdr.title"),children:[E.map(Q=>Q.kind==="toggle"?(0,Dt.jsx)(Ui,{label:Q.label,selected:l===Q.id,onSelect:()=>{s(Q.id),S(Q.id)},onHover:()=>s(Q.id),children:(0,Dt.jsx)(x,{color:i.herdr.autoStart?k.ok:k.muted,children:i.herdr.autoStart?`[\xD7] ${e("common.on")}`:`[ ] ${e("common.off")}`})},Q.id):Q.kind==="field"?(0,Dt.jsx)(Ui,{label:Q.label,selected:l===Q.id,onSelect:()=>S(Q.id),onHover:()=>s(Q.id),children:(0,Dt.jsx)(Ji,{value:Ho(i,Q.id),placeholder:A.t(Ia(i,Q.id)),active:r===Q.id,onSubmit:p=>{d(Q.id,p)&&A.setEditing(null)},onCancel:()=>A.setEditing(null)})},Q.id):(0,Dt.jsx)(X,{marginTop:1,children:(0,Dt.jsx)(xe,{selected:l===Q.id,onSelect:()=>{s(Q.id),S(Q.id)},onHover:()=>s(Q.id),children:Q.label})},Q.id)),l==="herdrAutoStart"?(0,Dt.jsx)(X,{marginTop:1,children:(0,Dt.jsx)(x,{color:k.muted,children:e("herdr.autoStartHint")})}):null,A.dirty?(0,Dt.jsx)(X,{marginTop:1,children:(0,Dt.jsx)(x,{color:k.warn,children:e("hint.unsavedChanges")})}):null,(0,Dt.jsxs)(X,{marginTop:1,flexDirection:"column",children:[u?.version?(0,Dt.jsx)(et,{label:e("herdr.version"),children:(0,Dt.jsxs)(X,{children:[(0,Dt.jsx)(Ai,{level:u.supported?"ok":"warn"}),(0,Dt.jsx)(x,{children:` ${u.version}`})]})}):null,u?.version&&!u.supported?(0,Dt.jsx)(x,{color:k.warn,children:e("herdr.versionOutdated",{version:u.version,minimum:yg})}):null,u&&!u.ok?(0,Dt.jsx)(x,{color:k.warn,children:e("herdr.cliMissing")}):null]}),(0,Dt.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var Gt=iA(ye(),1),qo=iA(EA(),1);function Hy({ctx:A}){let{t:e,draft:i}=A,[r,l]=(0,qo.useState)("auto"),[s,u]=(0,qo.useState)({phase:"idle"}),f=(0,qo.useState)(()=>({current:{source:""}}))[0],E=yl({preference:"auto"}),d=[{id:"auto",label:e("about.languageAuto",{detected:E})},{id:"zh",label:e("about.languageZh")},{id:"en",label:e("about.languageEn")}],h=pg(),S=(()=>{switch(s.phase){case"checking":return e("update.checking");case"current":return e("update.upToDate",{version:s.latest});case"available":return e("update.available",{version:s.latest});case"updating":return s.attempt>1?e("update.updatingRetry",{version:s.latest,attempt:s.attempt}):e("update.updating",{version:s.latest});case"done":return e("update.done",{version:s.latest});case"error":return e(s.messageKey,s.params);default:return e("update.check")}})(),Q=[...d,{id:"update",label:S}],p=J=>{f.current={source:J.source??""},u(J.updateAvailable?{phase:"available",latest:J.latest}:{phase:"current",latest:J.latest})};(0,qo.useEffect)(()=>{A.updateCheck?.ok&&s.phase==="idle"&&p(A.updateCheck)},[A.updateCheck]);let D=async()=>{u({phase:"checking"});let J=await Dl();if(!J.ok){u({phase:"error",messageKey:J.errorKey??"update.errorNetwork"});let{message:G}=J;G&&A.notify(q=>q("update.errorNetworkDetail",{message:G}),"error");return}A.setUpdateCheck(J),p(J)},v=async J=>{u({phase:"updating",latest:J,attempt:1});let G=await wg(A.config,()=>mg({source:f.current.source,version:J,onAttempt:({attempt:q})=>u({phase:"updating",latest:J,attempt:q})}));if(!G.ok){let q={version:J,installed:G.installed??"",url:lg(J)};u({phase:"error",messageKey:G.errorKey??"update.errorFailed",params:q}),A.notify(V=>G.summary?V("update.errorFailedDetail",{message:G.summary}):V(G.errorKey??"update.errorFailed",q),"error");return}u({phase:"done",latest:J}),A.setUpdateCheck(null),A.notify(q=>q("update.restartHint"),"success")},N=()=>{if(!(s.phase==="checking"||s.phase==="updating")){if(s.phase==="available"){if(!h){u({phase:"error",messageKey:`update.cannot.${Qg()}`});return}v(s.latest);return}D()}},L=J=>{let G=dn(i,"language",J),{errorKey:q}=G;if(q){A.notify(V=>V(q),"error");return}A.updateDraft(G.draft);try{Qn(G.draft),A.reloadConfig(),A.notify(V=>V("common.saved",{path:vn()}),"success")}catch(V){A.notify(fA=>fA("error.saveFailed",{message:V.message}),"error")}},uA=J=>{if(J==="update"){N();return}L(J)};return mt((J,G)=>{let q=Q.findIndex(V=>V.id===r);G.upArrow?l(Q[(q-1+Q.length)%Q.length].id):G.downArrow?l(Q[(q+1)%Q.length].id):G.return&&uA(r)},{isActive:A.editingId===null}),(0,Gt.jsxs)(nt,{title:e("about.title"),children:[(0,Gt.jsx)(x,{color:k.muted,children:e("about.language")}),(0,Gt.jsx)(X,{flexDirection:"column",marginTop:1,marginBottom:1,children:d.map(J=>(0,Gt.jsx)(xe,{selected:r===J.id,onSelect:()=>{l(J.id),L(J.id)},onHover:()=>l(J.id),children:`${J.label}${i.ui.language===J.id?" \u2713":""}`},J.id))}),(0,Gt.jsx)(x,{color:k.muted,children:e("update.title")}),(0,Gt.jsx)(X,{flexDirection:"column",marginTop:1,marginBottom:1,children:(0,Gt.jsx)(xe,{selected:r==="update",onSelect:()=>{l("update"),N()},onHover:()=>l("update"),children:S})}),(0,Gt.jsx)(et,{label:e("about.version"),children:(0,Gt.jsx)(x,{color:k.muted,children:Cg()})}),ag(A.config)?(0,Gt.jsx)(et,{label:e("about.relayPackage"),children:(0,Gt.jsx)(x,{color:k.muted,children:dg()??"?"})}):null,(0,Gt.jsx)(et,{label:e("about.configPath"),children:(0,Gt.jsx)(x,{color:k.muted,children:vn()})}),(0,Gt.jsx)(et,{label:e("about.statePath"),children:(0,Gt.jsx)(x,{color:k.muted,children:og()})}),(0,Gt.jsx)(X,{marginTop:1,children:(0,Gt.jsx)(x,{color:k.muted,children:e("about.docs")})}),(0,Gt.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var pA=iA(ye(),1),ni=iA(EA(),1);function fI(A,e){let i=["language","access"];return A==="lan"&&i.push("address"),A==="remote"&&e!==Ri&&i.push("relayUrl","password"),i.push("finish"),i}function EI({ctx:A,onDone:e}){let{t:i,draft:r}=A,[l,s]=(0,ni.useState)("language"),[u,f]=(0,ni.useState)(A.runtime.relayPassword||""),[E,d]=(0,ni.useState)(!0),[h,S]=(0,ni.useState)(!0),[Q,p]=(0,ni.useState)("startNow"),D=(0,ni.useMemo)(()=>Sl({includeLoopback:!1}),[]),v=(0,ni.useMemo)(()=>fI(r.relay.mode,r.relay.remoteUrl),[r.relay.mode,r.relay.remoteUrl]),N=Math.max(0,v.indexOf(l)),L=AA=>{let oA=r;for(let[OA,FA]of AA){let rt=dn(oA,OA,FA),{errorKey:PA}=rt;if(PA)return A.notify(qA=>qA(PA),"error"),!1;oA=rt.draft}return A.updateDraft(oA),A.notify("","info"),!0},uA=(AA,oA)=>L([[AA,oA]]),J=(AA,oA=v)=>{let OA=oA.indexOf(AA);s(oA[Math.min(oA.length-1,OA+1)])},G=()=>{let AA=v.indexOf(l);AA>0&&s(v[AA-1])},q=()=>{A.run(async()=>{r.relay.mode==="remote"&&gr(u),Qn(r),A.reloadConfig();let AA=Zn(),oA=!1;if(h)try{Mn.detectManager(AA.keepalive.manager)==="windows-service"&&A.notify(OA=>OA("keepalive.serviceWindowHint"),"info"),await Mn.install(AA),oA=!0}catch(OA){OA.code==="ELEVATION_CANCELLED"?A.notify(FA=>FA("keepalive.elevationCancelled"),"info"):A.notify(FA=>FA("keepalive.failed",{message:OA.message}),"error")}E&&!oA&&Rl(AA),e()})},V=(0,pA.jsxs)(X,{flexDirection:"column",marginBottom:1,children:[(0,pA.jsx)(x,{bold:!0,children:i("wizard.title")}),(0,pA.jsx)(x,{color:k.muted,children:i("wizard.step",{current:N+1,total:v.length})})]});if(l==="language")return(0,pA.jsxs)(nt,{title:i("wizard.languageTitle"),children:[V,(0,pA.jsx)(Yi,{options:[{id:"auto",label:i("about.languageAuto",{detected:A.locale})},{id:"zh",label:i("about.languageZh")},{id:"en",label:i("about.languageEn")}],current:r.ui.language,onPick:AA=>{uA("language",AA)&&J("language")},onCancel:()=>{}}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="access")return(0,pA.jsxs)(nt,{title:i("wizard.accessTitle"),children:[V,(0,pA.jsx)(Yi,{options:[...["local","lan"].map(AA=>({id:AA,label:i(`mode.${AA}`),description:i(`mode.${AA}.description`)})),{id:"official",label:i("mode.official"),description:i("mode.official.description")},{id:"remote",label:i("mode.remote"),description:i("mode.remote.description")}],current:mr(r),onPick:AA=>{if(AA==="official"){if(!uA("mode","official"))return;gr(""),J("access",fI("remote",Ri));return}uA("mode",AA)&&J("access",fI(AA,AA==="remote"?"":r.relay.remoteUrl))},onCancel:G}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.accessHint")})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="address")return(0,pA.jsxs)(nt,{title:i("wizard.addressTitle"),children:[V,D.length===0?(0,pA.jsxs)(X,{flexDirection:"column",children:[(0,pA.jsx)(x,{color:k.warn,children:i("relay.noAddresses")}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(xe,{selected:!0,onSelect:()=>J("address"),children:i("wizard.finish")})}),(0,pA.jsx)(aG,{onSkip:()=>J("address"),onBack:G})]}):(0,pA.jsx)(Yi,{options:D.map(AA=>({id:AA.address,label:`${AA.address} (${AA.name}, ${AA.kind})`})),current:r.relay.lanHost||D[0].address,onPick:AA=>{uA("lanHost",AA)&&J("address")},onCancel:G}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="relayUrl")return(0,pA.jsxs)(nt,{title:i("wizard.relayTitle"),children:[V,(0,pA.jsx)(Ui,{label:i("wizard.relayUrlLabel"),selected:!0,onSelect:()=>{},children:(0,pA.jsx)(Ji,{value:r.relay.remoteUrl,placeholder:"wss://relay.example.com",active:!0,onSubmit:AA=>{if(!AA){A.notify(oA=>oA("error.remoteUrlRequired"),"error");return}uA("remoteUrl",AA)&&J("relayUrl")},onCancel:G})}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.relayHint")})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="password")return(0,pA.jsxs)(nt,{title:i("wizard.passwordTitle"),children:[V,(0,pA.jsx)(Ui,{label:i("relay.password"),selected:!0,onSelect:()=>{},children:(0,pA.jsx)(Ji,{value:u,placeholder:i("relay.passwordEmpty"),active:!0,mask:!0,onSubmit:AA=>{f(AA),J("password")},onCancel:G})}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.passwordHint")})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});let fA=[{id:"startNow",label:`${i("wizard.startNow")} [${E?"\xD7":" "}]`},{id:"installKeepalive",label:`${i("wizard.installKeepalive")} [${h?"\xD7":" "}]`},{id:"finish",label:i("wizard.finish")}],TA=AA=>{if(AA==="startNow"){d(oA=>!oA);return}if(AA==="installKeepalive"){S(oA=>!oA);return}q()};return(0,pA.jsxs)(nt,{title:i("wizard.finishTitle"),children:[V,(0,pA.jsx)(lG,{items:fA.map(AA=>AA.id),selected:Q,onSelect:p,onActivate:TA,onBack:G}),fA.map(AA=>(0,pA.jsx)(xe,{selected:Q===AA.id,onSelect:()=>{p(AA.id),TA(AA.id)},onHover:()=>p(AA.id),children:AA.label},AA.id)),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.finishHint",{path:vn()})})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}function lG({items:A,selected:e,onSelect:i,onActivate:r,onBack:l}){return mt((s,u)=>{let f=Math.max(0,A.indexOf(e));u.escape?l():u.upArrow?i(A[(f-1+A.length)%A.length]):u.downArrow?i(A[(f+1)%A.length]):u.return&&r(e)}),null}function aG({onSkip:A,onBack:e}){return mt((i,r)=>{r.return?A():r.escape&&e()}),null}var sG=3e3,ii=[{id:"overview",labelKey:"nav.overview"},{id:"pair",labelKey:"nav.pair"},{id:"services",labelKey:"nav.services"},{id:"relay",labelKey:"nav.relay"},{id:"keepalive",labelKey:"nav.keepalive"},{id:"herdr",labelKey:"nav.herdr"},{id:"about",labelKey:"nav.about"}];function uG({label:A,active:e,onSelect:i}){let r=(0,zA.useRef)(null),l=Ea(r,{onClick:i});return(0,it.jsx)(X,{ref:r,marginRight:2,children:(0,it.jsx)(x,{color:e||l?k.accent:k.muted,bold:e,underline:e||l,children:A})})}function cG({hints:A}){return(0,it.jsx)(X,{marginTop:1,paddingX:1,children:(0,it.jsx)(x,{color:k.muted,children:A.join(" \xB7 ")})})}function II({initialLanguage:A,needsWizard:e,updateChecker:i=hg()?Dl:null}){let{exit:r}=sE(),l=nm(),[s,u]=(0,zA.useState)(()=>Zn()),[f,E]=(0,zA.useState)(()=>Nu()),[d,h]=(0,zA.useState)(()=>ml()),[S,Q]=(0,zA.useState)(null),[p,D]=(0,zA.useState)("overview"),[v,N]=(0,zA.useState)(null),[L,uA]=(0,zA.useState)(!1),[J,G]=(0,zA.useState)(null),[q,V]=(0,zA.useState)(!e),[fA,TA]=(0,zA.useState)(null);(0,zA.useEffect)(()=>{if(!i)return;let hA=!1;return i().then(LA=>{!hA&&LA?.ok&&TA(LA)}).catch(()=>{}),()=>{hA=!0}},[i]);let AA=(0,zA.useMemo)(()=>yl({preference:A??f.ui.language}),[A,f.ui.language]),oA=(0,zA.useMemo)(()=>Ig(AA),[AA]),OA=(0,zA.useMemo)(()=>JSON.stringify(s)!==JSON.stringify(f),[s,f]),FA=(0,zA.useMemo)(()=>OA&&pE(s,f),[s,f,OA]),rt=(0,zA.useCallback)((hA,LA="info")=>{N({notice:hA,level:LA})},[]),PA=v&&{text:typeof v.notice=="string"?v.notice:v.notice(oA),level:v.level},qA=(0,zA.useCallback)(()=>{vg(Zn()).then(hA=>Q(hA)).catch(hA=>rt(hA.message,"error"))},[rt]),$t=(0,zA.useCallback)(()=>{let hA=Zn();u(hA),E(Nu(hA)),h(ml())},[]),$e=(0,zA.useCallback)(hA=>{uA(!0),Promise.resolve().then(hA).catch(LA=>rt(LA.message,"error")).finally(()=>{uA(!1),qA()})},[rt,qA]);(0,zA.useEffect)(()=>{if(!q)return;qA();let hA=setInterval(()=>{J||qA()},sG);return()=>clearInterval(hA)},[q,qA,J]);let mA=(0,zA.useRef)(null);(0,zA.useEffect)(()=>{mA.current===null&&l.supported&&!l.enabled&&l.enable()},[l.supported,l.enabled,l]);let ot={t:oA,locale:AA,config:s,draft:f,status:S,runtime:d,busy:L,dirty:OA,editingId:J,updateDraft:E,reloadConfig:$t,setEditing:G,notify:rt,run:$e,refresh:qA,message:PA,updateCheck:fA,setUpdateCheck:TA};if(mt((hA,LA)=>{if(LA.ctrl&&hA==="c"){r();return}if(hA==="q"){r();return}if(hA==="r"){N(null),qA();return}if(hA==="m"){if(!l.supported){rt($A=>$A("hint.mouseUnsupported"),"info");return}mA.current=!l.enabled,l.enabled?l.disable():l.enable();return}let An=ii.findIndex($A=>$A.id===p);if(LA.rightArrow||LA.tab&&!LA.shift){D(ii[(An+1)%ii.length].id);return}if(LA.leftArrow||LA.tab&&LA.shift){D(ii[(An-1+ii.length)%ii.length].id);return}let bt=Number.parseInt(hA,10);Number.isInteger(bt)&&bt>=1&&bt<=ii.length&&D(ii[bt-1].id)},{isActive:q&&J===null}),!q)return(0,it.jsx)(EI,{ctx:ot,onDone:()=>{$t(),V(!0),qA()}});let Ee=[oA("hint.navigate"),oA("hint.select"),oA("hint.tabs"),OA?oA("hint.save"):null,l.supported?l.enabled?oA("hint.mouseOn"):oA("hint.mouseOff"):oA("hint.mouseUnsupported"),oA("hint.quit")].filter(Boolean);return(0,it.jsxs)(X,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,it.jsxs)(X,{marginBottom:1,flexDirection:"column",children:[(0,it.jsxs)(X,{children:[(0,it.jsx)(x,{bold:!0,children:oA("app.name")}),(0,it.jsx)(x,{color:k.muted,children:` ${oA("app.tagline")}`})]}),fA?.updateAvailable?(0,it.jsx)(x,{color:k.warn,children:oA("update.banner",{latest:fA.latest??"",current:fA.current})}):null]}),(0,it.jsx)(X,{marginBottom:1,children:ii.map((hA,LA)=>(0,it.jsx)(uG,{label:`${LA+1} ${oA(hA.labelKey)}`,active:hA.id===p,onSelect:()=>D(hA.id)},hA.id))}),p==="overview"?(0,it.jsx)(Em,{ctx:ot}):null,p==="pair"?(0,it.jsx)(Ry,{ctx:ot}):null,p==="services"?(0,it.jsx)(My,{ctx:ot}):null,p==="relay"?(0,it.jsx)(Gy,{ctx:ot}):null,p==="keepalive"?(0,it.jsx)(by,{ctx:ot}):null,p==="herdr"?(0,it.jsx)(Uy,{ctx:ot}):null,p==="about"?(0,it.jsx)(Hy,{ctx:ot}):null,FA?(0,it.jsx)(X,{marginTop:1,children:(0,it.jsx)(x,{color:k.warn,children:oA("hint.restartRequired")})}):null,(0,it.jsx)(cG,{hints:Ee})]})}var Ju="\x1B",gG=`${Ju}[?1049h${Ju}[H`,fG=`${Ju}[?1049l`,EG=`${Ju}[?25h`;function xy(A=process.stdout){try{A.write(gG)}catch{}}function Ly(A=process.stdout){try{A.write(`${Ru}${EG}${fG}`)}catch{}}async function j_({language:A=null}={}){let e=!cg(),i=EE(process.stdin,process.stdout);xy();let r=oE((0,BI.jsx)(em,{source:i,children:(0,BI.jsx)(II,{initialLanguage:A,needsWizard:e})}),{stdin:i.stdin,exitOnCtrlC:!1}),l=()=>{i.dispose(),Ly()},s=()=>{r.unmount(),l(),process.exit(0)};process.once("SIGINT",s),process.once("SIGTERM",s),process.once("exit",l);try{await r.waitUntilExit()}finally{l(),process.off("SIGINT",s),process.off("SIGTERM",s)}}export{II as App,EI as Wizard,j_ as startTui};
|
|
77
|
+
`)l.name="enter";else if(A===" ")l.name="tab";else if(A==="\b"||A==="\x1B\b")l.name="backspace",l.meta=A.charAt(0)==="\x1B";else if(A==="\x7F"||A==="\x1B\x7F")l.name="backspace",l.meta=A.charAt(0)==="\x1B";else if(A==="\x1B"||A==="\x1B\x1B")l.name="escape",l.meta=A.length===2;else if(A===" "||A==="\x1B ")l.name="space",l.meta=A.length===2;else if(A.length===1&&A<="")l.name=String.fromCharCode(A.charCodeAt(0)+97-1),l.ctrl=!0;else if(A.length===1&&A>="0"&&A<="9")l.name="number";else if(A.length===1&&A>="a"&&A<="z")l.name=A;else if(A.length===1&&A>="A"&&A<="Z")l.name=A.toLowerCase(),l.shift=!0;else if(e=Iv.exec(A))l.name=e[1].toLowerCase(),l.meta=!0,l.shift=/^[A-Z]$/.test(e[1]);else if(e=Bv.exec(A)){let s=[...A];s[0]==="\x1B"&&s[1]==="\x1B"&&(l.meta=!0);let u=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),f=(e[3]||e[5]||1)-1;l.ctrl=!!(f&4),l.meta=l.meta||!!(f&10),l.shift=!!(f&1),l.code=u,l.name=kp[u]??"",l.shift=Cv(u)||l.shift,l.ctrl=dv(u)||l.ctrl}return l},Xp=Sv;var Vp=iA(EA(),1);var aE=()=>(0,Vp.useContext)(Eu);var Dv=(A,e={})=>{let{setRawMode:i,internal_exitOnCtrlC:r,internal_eventEmitter:l}=aE();(0,ga.useEffect)(()=>{if(e.isActive!==!1)return i(!0),()=>{i(!1)}},[e.isActive,i]);let s=(0,ga.useEffectEvent)(u=>{let f=Xp(u),E={upArrow:f.name==="up",downArrow:f.name==="down",leftArrow:f.name==="left",rightArrow:f.name==="right",pageDown:f.name==="pagedown",pageUp:f.name==="pageup",home:f.name==="home",end:f.name==="end",return:f.name==="return",escape:f.name==="escape",ctrl:f.ctrl,shift:f.shift,tab:f.name==="tab",backspace:f.name==="backspace",delete:f.name==="delete",meta:f.meta,super:f.super??!1,hyper:f.hyper??!1,capsLock:f.capsLock??!1,numLock:f.numLock??!1,eventType:f.eventType},d;f.isKittyProtocol?f.isPrintable?d=f.text??f.name:f.ctrl&&f.name.length===1?d=f.name:d="":f.ctrl?d=f.name??"":d=f.sequence,!f.isKittyProtocol&&Kp.includes(f.name)&&(d=""),d.startsWith("\x1B")&&(d=d.slice(1)),d.length===1&&/[A-Z]/.test(d)&&(E.shift=!0),!(d==="c"&&E.ctrl&&r)&&le.discreteUpdates(()=>{A(d,E)})});(0,ga.useEffect)(()=>{if(e.isActive!==!1)return l.on("input",s),()=>{l.removeListener("input",s)}},[e.isActive,l])},mt=Dv;var Zp=iA(EA(),1);var jp=iA(EA(),1);var Rv=()=>(0,jp.useContext)(fu),sE=Rv;var Wp=iA(EA(),1);var Nv=()=>(0,Wp.useContext)(Iu),uE=Nv;var wv=iA(EA(),1);var cE=iA(EA(),1);var Mv=iA(EA(),1);var Tv=iA(EA(),1);var yu=iA(EA(),1);var fa=iA(EA(),1);var Su=iA(EA(),1);var Gv=()=>{let{stdout:A}=uE(),[e,i]=(0,Su.useState)(()=>Pn(A));return(0,Su.useEffect)(()=>{let r=()=>{i(Pn(A))};return A.on("resize",r),()=>{A.off("resize",r)}},[A]),e},gE=Gv;var Du=iA(EA(),1);var it=iA(ye(),1),zA=iA(EA(),1);var IE=iA(ye(),1),JA=iA(EA(),1);import{PassThrough as xv}from"node:stream";var Pp="\x1B[?1000h\x1B[?1002h\x1B[?1003h\x1B[?1006h",Ru="\x1B[?1006l\x1B[?1003l\x1B[?1002l\x1B[?1000l",bv=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])/;function Uv(A,e){if(A&64)return(A&3)===1?"wheel-down":"wheel-up";if(e)return"none";switch(A&3){case 0:return"left";case 1:return"middle";case 2:return"right";default:return"none"}}function Hv(A){return"\x1B[<".startsWith(A.slice(0,3))&&A.length<=32&&/^\x1b(\[(<[\d;]*)?)?$/.test(A)}function $p(A){let e=[],i="",r=0;for(;r<A.length;){let l=A.indexOf("\x1B",r);if(l===-1)return i+=A.slice(r),{events:e,passthrough:i,pending:""};i+=A.slice(r,l);let s=A.slice(l),u=bv.exec(s);if(u){let f=Number(u[1]),E=u[4]==="m",d=(f&32)!==0,h=(f&64)!==0;e.push({type:h?"wheel":d?"move":E?"release":"press",button:Uv(f,E),x:Number(u[2]),y:Number(u[3]),shift:(f&4)!==0,alt:(f&8)!==0,ctrl:(f&16)!==0}),r=l+u[0].length;continue}if(Hv(s))return{events:e,passthrough:i,pending:s};i+="\x1B",r=l+1}return{events:e,passthrough:i,pending:""}}function fE(){let A="";return e=>{let i=$p(A+e);return A=i.pending,{events:i.events,passthrough:i.passthrough}}}function EE(A=process.stdin,e=process.stdout){let i=!!(A.isTTY&&e.isTTY),r=new Set,l=fE(),s=new xv,u=S=>{let Q=typeof S=="string"?S:S.toString("utf8"),{events:p,passthrough:D}=l(Q);for(let v of p)for(let N of r)N(v);D.length>0&&s.write(D)};i&&(A.on("data",u),A.resume());let f=s;f.isTTY=A.isTTY,f.setRawMode=(S=>(A.setRawMode?.(S),f)),f.ref=(()=>(A.ref?.(),f)),f.unref=(()=>(A.unref?.(),f));let E=!1,d=()=>{!i||E||(e.write(Pp),E=!0)},h=()=>{E&&(e.write(Ru),E=!1)};return{stdin:f,supported:i,isEnabled:()=>E,enable:d,disable:h,subscribe(S){return r.add(S),()=>r.delete(S)},dispose(){h(),r.clear(),i&&A.off("data",u)}}}function Lv(A){if(!A?.yogaNode)return null;let e=A.yogaNode.getComputedLayout(),i=0,r=0,l=A;for(;l?.yogaNode;){let s=l.yogaNode.getComputedLayout();i+=s.left,r+=s.top,l=l.parentNode??void 0}return{left:i+1,top:r+1,width:e.width,height:e.height}}function _v(A,e,i){return e>=A.left&&e<A.left+A.width&&i>=A.top&&i<A.top+A.height}var Am=(0,JA.createContext)(null),tm=(0,JA.createContext)(null);function em({source:A,children:e}){let i=(0,JA.useRef)(new Set),r=(0,JA.useRef)(null),[l,s]=(0,JA.useState)(null),[u,f]=(0,JA.useState)(!1),E=(0,JA.useCallback)(D=>(i.current.add(D),()=>{i.current.delete(D),r.current===D&&(r.current=null),s(v=>v===D?null:v)}),[]),d=(0,JA.useCallback)((D,v)=>{let N=null,L=Number.POSITIVE_INFINITY;for(let uA of i.current){let J=Lv(uA.ref.current);if(!J||J.width<=0||J.height<=0||!_v(J,D,v))continue;let G=J.width*J.height;G<L&&(N=uA,L=G)}return N},[]);(0,JA.useEffect)(()=>{if(A)return A.subscribe(D=>{if(D.type==="wheel")return;let v=d(D.x,D.y);if(D.type==="move"){s(N=>N===v?N:v);return}if(D.type==="press"){if(D.button!=="left")return;r.current=v,s(v);return}r.current&&r.current===v&&v?.onClick?.(),r.current=null})},[A,d]),(0,JA.useEffect)(()=>{let D=l;return D?.onHover?.(!0),()=>D?.onHover?.(!1)},[l]);let h=(0,JA.useCallback)(()=>{A&&(A.enable(),f(A.isEnabled()))},[A]),S=(0,JA.useCallback)(()=>{A&&(A.disable(),f(A.isEnabled()))},[A]),Q=(0,JA.useMemo)(()=>({register:E}),[E]),p=(0,JA.useMemo)(()=>({supported:!!A?.supported,enabled:u,enable:h,disable:S}),[A,u,h,S]);return(0,IE.jsx)(Am.Provider,{value:Q,children:(0,IE.jsx)(tm.Provider,{value:p,children:e})})}var Ov={supported:!1,enabled:!1,enable:()=>{},disable:()=>{}};function nm(){return(0,JA.useContext)(tm)??Ov}function Ea(A,{onClick:e,disabled:i=!1}={}){let r=(0,JA.useContext)(Am),[l,s]=(0,JA.useState)(!1),u=(0,JA.useRef)(e);u.current=e;let f=(0,JA.useMemo)(()=>({ref:A,onClick:()=>u.current?.(),onHover:s}),[A]);return(0,JA.useEffect)(()=>{if(!(!r||i))return r.register(f)},[r,f,i]),(0,JA.useEffect)(()=>{i&&s(!1)},[i]),l&&!i}var k={accent:"cyan",border:"gray",muted:"gray",ok:"green",warn:"yellow",bad:"red"},BE="\u25B8",CE=" ",im={ok:k.ok,warn:k.warn,bad:k.bad,idle:k.muted},rm={ok:"\u25CF",warn:"\u25CF",bad:"\u25CF",idle:"\u25CB"};function dE(A,e){return A.includes(e)}var Fv=[{id:"mode",kind:"choice",choices:JC,labelKey:"field.mode"},{id:"port",kind:"text",labelKey:"field.port",visibleFor:["local","lan"]},{id:"lanHost",kind:"address",labelKey:"field.lanHost",visibleFor:["lan"]},{id:"remoteUrl",kind:"text",labelKey:"field.remoteUrl",visibleFor:["remote"]},{id:"publicUrl",kind:"text",labelKey:"field.publicUrl"},{id:"socketPath",kind:"text",labelKey:"field.socketPath"},{id:"herdrArgs",kind:"text",labelKey:"field.herdrArgs"},{id:"herdrAutoStart",kind:"toggle",labelKey:"field.herdrAutoStart"},{id:"language",kind:"choice",choices:ug,labelKey:"field.language"},{id:"keepaliveManager",kind:"choice",choices:so,labelKey:"field.keepalive"}],je="",kv=["local","lan","official","remote"];function mr(A){return A.relay.mode==="remote"&&A.relay.remoteUrl===Ri?"official":A.relay.mode}function QE(A){return mr(A)==="official"}function lm(A){return JSON.parse(JSON.stringify(A))}function Nu(A=Zn()){return lm(A)}function hE(A){return Fv.filter(e=>!e.visibleFor||e.visibleFor.includes(A))}function Ho(A,e){switch(e){case"mode":return A.relay.mode;case"port":return String(A.relay.port);case"lanHost":return A.relay.lanHost||je;case"remoteUrl":return A.relay.remoteUrl||je;case"publicUrl":return A.relay.publicUrl||je;case"socketPath":return A.herdr.socketPath||je;case"herdrArgs":return(A.herdr.args||[]).join(" ");case"herdrAutoStart":return A.herdr.autoStart?"on":"off";case"language":return A.ui.language;case"keepaliveManager":return A.keepalive.manager;default:return je}}function Ia(A,e){switch(e){case"lanHost":return Bg()||"0.0.0.0";case"publicUrl":return kC(A,Bg());case"socketPath":return"placeholder.autoDiscovered";case"herdrArgs":return"placeholder.none";case"remoteUrl":return"wss://relay.example.com";default:return je}}function om(A,e){try{let i=new URL(A);return e.includes(i.protocol)}catch{return!1}}function dn(A,e,i){let r=lm(A),l=typeof i=="string"?i.trim():i,s=l;switch(e){case"mode":{if(!dE(kv,l))return{draft:A,errorKey:"error.invalidMode"};if(l==="official"){r.relay.mode="remote",r.relay.remoteUrl=Ri,r.relay.publicUrl=je;break}l==="remote"&&r.relay.remoteUrl===Ri&&(r.relay.remoteUrl=je),r.relay.mode=l,l==="lan"&&(Ss(r.relay.lanHost)||Ds(r.relay.lanHost))&&(r.relay.lanHost=je),r.relay.publicUrl=je;break}case"port":{let u=Number.parseInt(s,10);if(!Number.isInteger(u)||u<1||u>65535)return{draft:A,errorKey:"error.invalidPort"};r.relay.port=u;break}case"lanHost":{if(s&&(Ss(s)||Ds(s)))return{draft:A,errorKey:"error.invalidLanHost"};r.relay.lanHost=s||je;break}case"remoteUrl":{if(s&&!om(s,["ws:","wss:","http:","https:"]))return{draft:A,errorKey:"error.invalidRelayUrl"};r.relay.remoteUrl=s.replace(/\/+$/,"");break}case"publicUrl":{if(s&&(!om(s,["http:","https:"])||FC(s)))return{draft:A,errorKey:"error.invalidPublicUrl"};r.relay.publicUrl=s.replace(/\/+$/,"");break}case"socketPath":{r.herdr.socketPath=s||null;break}case"herdrArgs":{let u=s?s.split(/\s+/).filter(Boolean):[];if(u.includes("--no-session"))return{draft:A,errorKey:"error.removedHerdrArg"};r.herdr.args=u;break}case"herdrAutoStart":{if(l!==!0&&l!==!1&&l!=="on"&&l!=="off")return{draft:A,errorKey:"error.unknownField"};r.herdr.autoStart=l===!0||l==="on";break}case"language":{if(!dE(ug,l))return{draft:A,errorKey:"error.invalidLanguage"};r.ui.language=l;break}case"keepaliveManager":{if(!dE(so,l))return{draft:A,errorKey:"error.invalidKeepalive"};r.keepalive.manager=l;break}default:return{draft:A,errorKey:"error.unknownField"}}return{draft:r,errorKey:null}}function Kv(A){let e=[];return A.relay.mode==="remote"&&!A.relay.remoteUrl&&e.push("error.remoteUrlRequired"),e}function Qn(A){let e=Kv(A);if(e.length>0)throw Object.assign(new Error(`configuration is incomplete: ${e.join(", ")}`),{problems:e});let i=qC(vn(),{})||{},r={...i};r.ui={...i.ui||{},language:A.ui.language};let l={...i.relay||{},mode:A.relay.mode,port:A.relay.port,lanHost:A.relay.mode==="lan"&&(Ss(A.relay.lanHost)||Ds(A.relay.lanHost))?je:A.relay.lanHost,publicUrl:A.relay.publicUrl,remoteUrl:A.relay.remoteUrl};r.relay=l,delete l.local,delete l.host,delete l.url,delete r.patch;let s={...i.herdr||{},socketPath:A.herdr.socketPath,args:A.herdr.args,autoStart:A.herdr.autoStart===!0};return r.herdr=s,s.socketPath||delete s.socketPath,r.keepalive={...i.keepalive||{},manager:A.keepalive.manager},YC(OC()),zC(vn(),r),{ok:!0,path:vn()}}function pE(A,e){return A.relay.mode!==e.relay.mode||A.relay.port!==e.relay.port||A.relay.lanHost!==e.relay.lanHost||A.relay.remoteUrl!==e.relay.remoteUrl||A.relay.publicUrl!==e.relay.publicUrl||A.herdr.socketPath!==e.herdr.socketPath||A.herdr.args.join(" ")!==e.herdr.args.join(" ")}async function mE({waitForStart:A=!1}={}){if(process.platform!=="win32")return!1;let e=await import("../connector/admin-broker.js");return A?e.waitForAdminBroker():e.adminBrokerStatus()}async function am(A,e){return(await import("./W2FYGFNZ.js")).configureAdminBroker(A,e)}function sm(A,e){let r=["herdr-remote-relay",`--public-url ${A.relay.remoteUrl?A.relay.remoteUrl.replace(/^ws/,"http"):"https://relay.example.com"}`,"--trust-proxy"];return e&&r.push(`--password '${e.replace(/'/g,"'\\''")}'`),r.join(" ")}async function um(A){let e=KC(A),i;try{i=await fg(`${e}/healthz`,{timeout:4e3})}catch(r){return{ok:!1,message:r.message}}try{let r=ml(),l=await fg(`${e}/api/status`,{timeout:4e3,headers:{"X-Herdr-Host-Id":r.hostId,"X-Herdr-Host-Token":r.hostToken}});return{ok:!0,version:String(i.version||l.version||""),hosts:Array.isArray(l.hosts)?l.hosts.length:0}}catch{return{ok:!0,version:String(i.version||""),hosts:void 0}}}function cm(A,e){if(!Number.isFinite(A))return e("common.unknown");let i=Math.max(0,Math.floor(A)),r=Math.floor(i/3600),l=Math.floor(i%3600/60);return r>0?`${r}h ${l}m`:l>0?`${l}m ${i%60}s`:`${i}s`}var IA=iA(ye(),1);var ht=iA(ye(),1),xo=iA(EA(),1);function Ai({level:A}){return(0,ht.jsx)(x,{color:im[A],children:rm[A]})}var Jv=20;function et({label:A,labelWidth:e=Jv,children:i}){return(0,ht.jsxs)(X,{children:[(0,ht.jsx)(X,{width:e,flexShrink:0,children:(0,ht.jsx)(x,{color:k.muted,wrap:"truncate-end",children:A})}),(0,ht.jsx)(X,{flexGrow:1,children:i})]})}function xe({selected:A,disabled:e=!1,onSelect:i,onHover:r,children:l}){let s=(0,xo.useRef)(null),u=Ea(s,{disabled:e,onClick:i});gm(u,r);let f=A||u,E=e?k.muted:f?k.accent:void 0;return(0,ht.jsxs)(X,{ref:s,children:[(0,ht.jsxs)(x,{color:f?k.accent:void 0,children:[f?BE:CE," "]}),(0,ht.jsx)(x,{color:E,bold:f,dimColor:e,children:l})]})}function gm(A,e){let i=(0,xo.useRef)(e);i.current=e,(0,xo.useEffect)(()=>{A&&i.current?.()},[A])}function Lo({items:A,selectedId:e,onChange:i,onSelect:r}){return(0,ht.jsx)(X,{flexDirection:"column",children:A.map(l=>(0,ht.jsx)(xe,{selected:l.id===e,disabled:l.disabled,onSelect:()=>r(l.id),onHover:()=>i(l.id),children:l.label},l.id))})}function Ui({label:A,selected:e,disabled:i=!1,labelWidth:r=22,onSelect:l,onHover:s,children:u}){let f=(0,xo.useRef)(null),E=Ea(f,{disabled:i,onClick:l});gm(E,s);let d=e||E;return(0,ht.jsxs)(X,{ref:f,children:[(0,ht.jsxs)(X,{width:r,flexShrink:0,children:[(0,ht.jsxs)(x,{color:d?k.accent:void 0,children:[d?BE:CE," "]}),(0,ht.jsx)(x,{color:d?k.accent:k.muted,bold:d,wrap:"truncate-end",children:A})]}),(0,ht.jsx)(X,{flexGrow:1,children:u})]})}function nt({title:A,children:e}){return(0,ht.jsxs)(X,{flexDirection:"column",borderStyle:"round",borderColor:k.border,paddingX:1,flexGrow:1,children:[A?(0,ht.jsx)(X,{marginBottom:1,children:(0,ht.jsx)(x,{bold:!0,children:A})}):null,e]})}function yt({text:A,level:e}){if(!A)return null;let i=e==="error"?k.bad:e==="success"?k.ok:k.muted;return(0,ht.jsx)(X,{marginTop:1,children:(0,ht.jsx)(x,{color:i,children:A})})}function fm(A){return A==null?"idle":A?"ok":"bad"}function Em({ctx:A}){let{t:e,status:i,config:r}=A;if(!i)return(0,IA.jsx)(nt,{title:e("overview.title"),children:(0,IA.jsx)(x,{color:k.muted,children:e("common.loading")})});let l=i.relay.health||{},s=l.ok!==!1,u=i.relay.local?fm(i.relay.alive):s?"ok":"bad",f=i.keepalive.active?"ok":i.keepalive.installed?"warn":"idle",E=!i.host.alive&&(i.relay.local?!i.relay.alive:!s);return(0,IA.jsxs)(nt,{title:e("overview.title"),children:[(0,IA.jsx)(et,{label:e("overview.mode"),children:(0,IA.jsx)(x,{children:e(`mode.${i.mode}`)})}),(0,IA.jsx)(et,{label:e("overview.relay"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:u}),(0,IA.jsxs)(x,{children:[" ",i.relay.local?e("overview.relayLocal",{bind:i.relay.bind??"",port:i.relay.port}):e("overview.relayRemote",{url:i.relay.remoteUrl??""})]}),i.relay.local&&i.relay.pid?(0,IA.jsx)(x,{color:k.muted,children:` ${e("common.pid",{pid:i.relay.pid})}`}):null]})}),(0,IA.jsx)(et,{label:e("overview.host"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:fm(i.host.alive)}),(0,IA.jsx)(x,{children:` ${i.host.alive?e("common.running"):e("common.stopped")}`}),i.host.pid?(0,IA.jsx)(x,{color:k.muted,children:` ${e("common.pid",{pid:i.host.pid})}`}):null]})}),(0,IA.jsx)(et,{label:e("overview.socket"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:i.host.socketExists?"ok":"warn"}),(0,IA.jsx)(x,{color:k.muted,children:` ${i.host.socketPath}`}),i.host.socketExists?null:(0,IA.jsx)(x,{color:k.warn,children:` ${e("overview.socketMissing")}`})]})}),(0,IA.jsx)(et,{label:e("overview.webUrl"),children:(0,IA.jsx)(x,{color:k.accent,children:i.publicUrl})}),(0,IA.jsx)(et,{label:e("overview.keepalive"),children:(0,IA.jsxs)(X,{children:[(0,IA.jsx)(Ai,{level:f}),(0,IA.jsxs)(x,{children:[` ${i.keepalive.manager} \u2014 `,i.keepalive.active?e("common.running"):i.keepalive.installed?e("common.installed"):e("common.notInstalled")]})]})}),(0,IA.jsx)(X,{marginTop:1,flexDirection:"column",children:s?(0,IA.jsxs)(IA.Fragment,{children:[typeof l.hosts=="number"?(0,IA.jsx)(et,{label:e("overview.hosts"),children:(0,IA.jsx)(x,{children:l.hosts})}):null,typeof l.clients=="number"?(0,IA.jsx)(et,{label:e("overview.devices"),children:(0,IA.jsx)(x,{children:l.clients})}):null,(0,IA.jsx)(et,{label:e("overview.uptime"),children:(0,IA.jsx)(x,{color:k.muted,children:cm(l.uptimeSeconds,e)})})]}):(0,IA.jsx)(x,{color:k.warn,children:e("overview.unreachable",{message:l.message??""})})}),E?(0,IA.jsx)(X,{marginTop:1,children:(0,IA.jsx)(x,{color:k.muted,children:e("overview.notStarted")})}):null,r.relay.mode==="local"?(0,IA.jsx)(X,{marginTop:1,children:(0,IA.jsx)(x,{color:k.muted,children:e("mode.local.description")})}):null,(0,IA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var St=iA(ye(),1),Ki=iA(EA(),1);var Dy=iA(yy(),1);var Sy=44;function Ry({ctx:A}){let{t:e,run:i}=A,{columns:r}=gE(),[l,s]=(0,Ki.useState)(null),[u,f]=(0,Ki.useState)(null),[E,d]=(0,Ki.useState)(0),[h,S]=(0,Ki.useState)("generate");(0,Ki.useEffect)(()=>{if(!l)return;let N=()=>d(Math.max(0,l.expiresAt-Date.now()));N();let L=setInterval(N,1e3);return()=>clearInterval(L)},[l]),(0,Ki.useEffect)(()=>{if(!l||r<Sy){f(null);return}let N=!1;return Dy.default.toString(l.pairUrl,{type:"terminal",small:!0,errorCorrectionLevel:"L"}).then(L=>{N||f(L.replace(/\n$/,""))}).catch(()=>{N||f(null)}),()=>{N=!0}},[l,r]);let Q=()=>i(async()=>{A.notify(N=>N("pair.working"));try{let N=await Dg(),L=Eg(N);s({...N,code:L}),A.notify("","info")}catch(N){let L=N.message;throw s(null),new Error(/host_offline|no Herdr host|did not register/i.test(L)?e("pair.hostOffline"):e("pair.failed",{message:L}))}});mt((N,L)=>{L.return&&Q()},{isActive:A.editingId===null});let p=l!==null&&E<=0,D=Math.floor(E/6e4),v=Math.floor(E%6e4/1e3);return(0,St.jsxs)(nt,{title:e("pair.title"),children:[(0,St.jsx)(Lo,{items:[{id:"generate",label:e(l?"pair.regenerate":"pair.generate")}],selectedId:h,onChange:S,onSelect:Q}),l?(0,St.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,St.jsxs)(X,{children:[(0,St.jsx)(x,{color:k.muted,children:`${e("pair.code")} `}),(0,St.jsx)(x,{bold:!0,color:p?k.muted:k.accent,children:l.code.split("").join(" ")})]}),(0,St.jsxs)(X,{children:[(0,St.jsx)(x,{color:k.muted,children:`${e("pair.url")} `}),(0,St.jsx)(x,{children:l.pairUrl})]}),(0,St.jsx)(X,{marginTop:1,children:(0,St.jsx)(x,{color:p?k.bad:k.muted,children:p?e("pair.expired"):e("pair.expires",{minutes:`${D}:${String(v).padStart(2,"0")}`,time:new Date(l.expiresAt).toLocaleTimeString()})})}),!p&&u?(0,St.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,St.jsx)(x,{children:u}),(0,St.jsx)(x,{color:k.muted,children:e("pair.qrHint")})]}):null,!p&&!u&&r<Sy?(0,St.jsx)(X,{marginTop:1,children:(0,St.jsx)(x,{color:k.muted,children:e("pair.qrUnavailable")})}):null,(0,St.jsx)(X,{marginTop:1,children:(0,St.jsx)(x,{color:k.muted,children:e("pair.instructions")})})]}):null,(0,St.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var Pt=iA(ye(),1),vy=iA(EA(),1);var Ny=8;function My({ctx:A}){let{t:e,run:i,status:r}=A,[l,s]=(0,vy.useState)("start"),u=[{id:"start",label:e("services.start")},{id:"stop",label:e("services.stop")},{id:"restart",label:e("services.restart")}],f=h=>{if(A.dirty&&h!=="stop"){A.notify(S=>S("services.unsavedBlocked"),"error");return}return i(()=>{let S=A.config;if(h==="start"){let p=Rl(S);A.notify(D=>p.managed?D("services.managedNotice",{manager:p.manager??""}):D("services.started"),"success");return}if(h==="stop"){let p=Rg(S);A.notify(D=>p.managed?D("services.managedNotice",{manager:p.manager??""}):D("services.stopped"),"success");return}let Q=Ng(S);A.notify(p=>Q.managed?p("services.managedNotice",{manager:Q.manager??""}):p("services.restarted"),"success")})};mt((h,S)=>{let Q=u.findIndex(p=>p.id===l);S.upArrow?s(u[(Q-1+u.length)%u.length].id):S.downArrow?s(u[(Q+1)%u.length].id):S.return&&f(l)},{isActive:A.editingId===null});let E=Rs("relay",Ny),d=Rs("host",Ny);return(0,Pt.jsxs)(nt,{title:e("services.title"),children:[(0,Pt.jsx)(Lo,{items:u,selectedId:l,onChange:s,onSelect:f}),A.dirty?(0,Pt.jsx)(X,{marginTop:1,children:(0,Pt.jsx)(x,{color:k.warn,children:e("services.unsavedBlocked")})}):null,r?.keepalive.installed?(0,Pt.jsx)(X,{marginTop:1,children:(0,Pt.jsx)(x,{color:k.muted,children:e("services.managedNotice",{manager:r.keepalive.manager})})}):null,(0,Pt.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,Pt.jsx)(x,{color:k.muted,children:e("services.logs")}),(0,Pt.jsx)(wy,{title:e("services.logRelay"),lines:E,emptyText:e("services.logEmpty")}),(0,Pt.jsx)(wy,{title:e("services.logHost"),lines:d,emptyText:e("services.logEmpty")})]}),(0,Pt.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}function wy({title:A,lines:e,emptyText:i}){return(0,Pt.jsxs)(X,{flexDirection:"column",marginTop:1,children:[(0,Pt.jsx)(x,{bold:!0,color:k.muted,children:A}),e.length===0?(0,Pt.jsx)(x,{color:k.muted,children:i}):e.map((r,l)=>(0,Pt.jsx)(x,{color:k.muted,wrap:"truncate-end",children:r},l))]})}var vA=iA(ye(),1),ei=iA(EA(),1);var vr=iA(ye(),1),Ku=iA(EA(),1);var rG=/[\x00-\x1f\x7f]/;function Ji({value:A,placeholder:e,active:i,mask:r=!1,onSubmit:l,onCancel:s}){let[u,f]=(0,Ku.useState)(A);(0,Ku.useEffect)(()=>{i&&f(A)},[i,A]),mt((h,S)=>{if(S.return){l(u);return}if(S.escape){f(A),s();return}if(S.backspace||S.delete){f(Q=>Q.slice(0,-1));return}if(S.ctrl&&h==="u"){f("");return}h&&!S.ctrl&&!S.meta&&!rG.test(h)&&f(Q=>Q+h)},{isActive:i});let E=i?u:A,d=r&&E?"\u2022".repeat(Math.min(E.length,32)):E;return i?(0,vr.jsxs)(X,{children:[(0,vr.jsx)(x,{color:k.accent,children:d}),(0,vr.jsx)(x,{color:k.accent,inverse:!0,children:" "})]}):d?(0,vr.jsx)(x,{children:d}):(0,vr.jsx)(x,{color:k.muted,children:e??""})}function Gy({ctx:A}){let{t:e,draft:i,editingId:r}=A,[l,s]=(0,ei.useState)("mode"),[u,f]=(0,ei.useState)(!1),[E,d]=(0,ei.useState)(!1),[h,S]=(0,ei.useState)(A.runtime.relayPassword||""),Q=QE(i),D=[...(0,ei.useMemo)(()=>hE(i.relay.mode).filter(G=>["mode","port","lanHost","remoteUrl","publicUrl"].includes(G.id)),[i.relay.mode]).map(G=>({id:G.id,kind:Q&&(G.id==="remoteUrl"||G.id==="publicUrl")?"readonly":"field",fieldKind:G.kind,label:e(G.labelKey)})),...i.relay.mode==="remote"&&!Q?[{id:"password",kind:"password",label:e("relay.password")}]:[],{id:"save",kind:"action",label:e("common.save")},{id:"test",kind:"action",label:e("relay.test")},...i.relay.mode==="remote"&&!Q?[{id:"reveal",kind:"action",label:e(u?"relay.hidePassword":"relay.showPassword")},{id:"env",kind:"action",label:e("relay.envSnippet")}]:[],{id:"regenerate",kind:"action",label:e("relay.regenerate")}],v=(0,ei.useMemo)(()=>Sl({includeLoopback:!1}),[]),N=G=>{let q=i;for(let[V,fA]of G){let TA=dn(q,V,fA),{errorKey:AA}=TA;if(AA)return A.notify(oA=>oA(AA),"error"),!1;q=TA.draft}return A.updateDraft(q),A.notify("","info"),!0},L=(G,q)=>N([[G,q]]),uA=()=>{try{let G=Qn(i);A.reloadConfig(),A.notify(q=>q("common.saved",{path:G.path}),"success")}catch(G){let q=G.problems;A.notify(V=>q?q.map(fA=>V(fA)).join(" "):V("error.saveFailed",{message:G.message}),"error")}},J=G=>{let q=D.find(V=>V.id===G);if(q){if(q.kind==="readonly"){A.notify(V=>V("relay.officialFixed"),"info");return}if(q.kind==="field"||q.kind==="password"){A.setEditing(G);return}if(G==="save"){uA();return}if(G==="reveal"){f(V=>!V);return}if(G==="env"){d(V=>!V);return}if(G==="regenerate"){A.run(()=>{gg(),A.reloadConfig(),A.notify(V=>V("relay.regenerated"),"success")});return}G==="test"&&A.run(async()=>{let V=await um(A.config);A.notify(fA=>V.ok?fA("relay.testOk",{version:V.version??"?",hosts:V.hosts??0}):fA("relay.testFailed",{message:V.message??""}),V.ok?"success":"error")})}};if(mt((G,q)=>{let V=D.findIndex(fA=>fA.id===l);q.upArrow?s(D[(V-1+D.length)%D.length].id):q.downArrow?s(D[(V+1)%D.length].id):q.return?J(l):G==="s"&&uA()},{isActive:r===null}),r==="mode")return(0,vA.jsx)(nt,{title:e("field.mode"),children:(0,vA.jsx)(Yi,{options:[...["local","lan"].map(G=>({id:G,label:e(`mode.${G}`),description:e(`mode.${G}.description`)})),{id:"official",label:e("mode.official"),description:e("mode.official.description")},{id:"remote",label:e("mode.remote"),description:e("mode.remote.description")}],current:mr(i),onPick:G=>{L("mode",G)&&(G==="official"&&(S(""),gr("")),A.setEditing(null))},onCancel:()=>A.setEditing(null)})});if(r==="lanHost"){let G=v.map(q=>({id:q.address,label:`${q.address} (${q.name}, ${e(oG(q.kind))})`}));return(0,vA.jsx)(nt,{title:e("relay.selectAddress"),children:G.length===0?(0,vA.jsx)(x,{color:k.warn,children:e("relay.noAddresses")}):(0,vA.jsx)(Yi,{options:G,current:i.relay.lanHost||G[0].id,onPick:q=>{L("lanHost",q),A.setEditing(null)},onCancel:()=>A.setEditing(null)})})}return(0,vA.jsxs)(nt,{title:e("relay.title"),children:[i.relay.mode!=="remote"?(0,vA.jsxs)(X,{flexDirection:"column",marginBottom:1,children:[(0,vA.jsx)(et,{label:e("relay.listenAddress"),children:(0,vA.jsx)(x,{color:k.muted,children:`${sg(i)}:${i.relay.port}`})}),(0,vA.jsx)(x,{color:k.muted,children:e("relay.listenAddressHint")})]}):null,D.map(G=>G.kind==="action"?(0,vA.jsx)(xe,{selected:l===G.id,onSelect:()=>{s(G.id),J(G.id)},onHover:()=>s(G.id),children:G.label},G.id):(0,vA.jsx)(Ui,{label:G.label,selected:l===G.id,onSelect:()=>J(G.id),onHover:()=>s(G.id),children:G.kind==="password"?(0,vA.jsx)(Ji,{value:h,placeholder:e("relay.passwordEmpty"),active:r==="password",mask:!u,onSubmit:q=>{S(q),gr(q),A.setEditing(null),A.notify(V=>V("relay.passwordSaved"),"success")},onCancel:()=>A.setEditing(null)}):G.kind==="readonly"?(0,vA.jsx)(x,{color:k.muted,children:`${Ho(i,G.id)||Ty(A,G.id)} (${e("relay.locked")})`}):G.fieldKind==="choice"?(0,vA.jsx)(x,{children:e(`mode.${mr(i)}`)}):(0,vA.jsx)(Ji,{value:Ho(i,G.id),placeholder:Ty(A,G.id),active:r===G.id,onSubmit:q=>{L(G.id,q)&&A.setEditing(null)},onCancel:()=>A.setEditing(null)})},G.id)),A.dirty?(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.warn,children:e("hint.unsavedChanges")})}):null,i.relay.mode==="remote"?(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.muted,children:e(Q?"relay.officialHint":"relay.passwordHint")})}):null,(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(et,{label:e("relay.identity"),children:(0,vA.jsx)(x,{color:k.muted,children:A.runtime.hostId})})}),E?(0,vA.jsxs)(X,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:k.border,paddingX:1,children:[(0,vA.jsx)(x,{color:k.muted,children:e("relay.envHint")}),(0,vA.jsx)(x,{children:sm(A.config,h)})]}):null,Q?null:(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.muted,children:e("relay.docsHint")})}),(0,vA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}function Ty(A,e){let i=Ia(A.draft,e);return i.startsWith("placeholder.")?A.t(i):i}function oG(A){return`relay.address${A.charAt(0).toUpperCase()}${A.slice(1)}`}function Yi({options:A,current:e,onPick:i,onCancel:r}){let[l,s]=(0,ei.useState)(()=>{let f=A.findIndex(E=>E.id===e);return f>=0?f:0}),u=A[Math.min(l,A.length-1)];return mt((f,E)=>{if(E.escape){r();return}E.upArrow?s(d=>(d-1+A.length)%A.length):E.downArrow?s(d=>(d+1)%A.length):E.return&&u&&i(u.id)}),(0,vA.jsxs)(X,{flexDirection:"column",children:[(0,vA.jsx)(Lo,{items:A.map(f=>({id:f.id,label:f.label})),selectedId:u?.id??"",onChange:f=>s(A.findIndex(E=>E.id===f)),onSelect:i}),u?.description?(0,vA.jsx)(X,{marginTop:1,children:(0,vA.jsx)(x,{color:k.muted,children:u.description})}):null]})}var YA=iA(ye(),1),wa=iA(EA(),1);function by({ctx:A}){let{t:e,status:i,draft:r,editingId:l}=A,[s,u]=(0,wa.useState)("install"),[f,E]=(0,wa.useState)(null);(0,wa.useEffect)(()=>{if(process.platform!=="win32")return;let Q=!1;return mE().then(p=>{Q||E(p)}).catch(()=>{Q||E(!1)}),()=>{Q=!0}},[]);let d=i?.keepalive,h=[{id:"install",label:e("keepalive.install")},{id:"restart",label:e("keepalive.restart")},{id:"uninstall",label:e("keepalive.uninstall")},{id:"manager",label:`${e("keepalive.manager")}: ${r.keepalive.manager}`},...process.platform==="linux"&&d?.manager==="systemd"&&!d?.linger?[{id:"linger",label:e("keepalive.enableLinger")}]:[],...process.platform==="win32"?[{id:"adminBrokerInstall",label:e("adminBroker.install")},{id:"adminBrokerUninstall",label:e("adminBroker.uninstall")}]:[]],S=Q=>{if(Q==="manager"){A.setEditing("keepaliveManager");return}if(Q==="adminBrokerInstall"||Q==="adminBrokerUninstall"){let p=Q==="adminBrokerInstall"?"install":"uninstall";A.run(async()=>{let D=!1;try{await am(p,e),D=p==="install"&&await mE({waitForStart:!0})}catch(v){if(v.code==="ELEVATION_CANCELLED"){A.notify(N=>N("adminBroker.elevationCancelled"),"info");return}throw v}E(D),A.notify(v=>v(`adminBroker.${p}Done`),"success")});return}A.run(async()=>{if(Q==="install"){Mn.detectManager(A.config.keepalive.manager)==="windows-service"&&A.notify(p=>p("keepalive.serviceWindowHint"),"info");try{let p=await Mn.install(A.config);A.notify(D=>D("keepalive.installed",{manager:p.manager}),"success")}catch(p){if(p.code==="ELEVATION_CANCELLED"){A.notify(D=>D("keepalive.elevationCancelled"),"info");return}throw p}return}if(Q==="uninstall"){await Mn.uninstall(A.config),A.notify(p=>p("keepalive.uninstalled"),"success");return}if(Q==="restart"){Mn.restart(A.config),A.notify(p=>p("keepalive.restarted"),"success");return}if(Q==="linger"){let p=Mn.enableLinger();A.notify(D=>D("keepalive.lingerDone",{username:p.username}),"success")}})};return mt((Q,p)=>{let D=h.findIndex(v=>v.id===s);p.upArrow?u(h[(D-1+h.length)%h.length].id):p.downArrow?u(h[(D+1)%h.length].id):p.return&&S(s)},{isActive:l===null}),l==="keepaliveManager"?(0,YA.jsx)(nt,{title:e("field.keepalive"),children:(0,YA.jsx)(Yi,{options:so.map(Q=>({id:Q,label:Q})),current:r.keepalive.manager,onPick:Q=>{let p=dn(r,"keepaliveManager",Q),{errorKey:D}=p;if(D){A.notify(v=>v(D),"error");return}A.updateDraft(p.draft);try{Qn(p.draft),A.reloadConfig()}catch(v){A.notify(N=>N("error.saveFailed",{message:v.message}),"error")}A.setEditing(null)},onCancel:()=>A.setEditing(null)})}):(0,YA.jsxs)(nt,{title:e("keepalive.title"),children:[(0,YA.jsx)(et,{label:e("keepalive.manager"),children:(0,YA.jsx)(x,{children:d?.manager??e("common.unknown")})}),(0,YA.jsx)(et,{label:e("keepalive.state"),children:(0,YA.jsxs)(X,{children:[(0,YA.jsx)(Ai,{level:d?.active?"ok":d?.installed?"warn":"idle"}),(0,YA.jsxs)(x,{children:[" ",d?.active?e("common.running"):d?.installed?e("common.installed"):e("common.notInstalled")]})]})}),process.platform==="win32"?(0,YA.jsxs)(YA.Fragment,{children:[(0,YA.jsx)(et,{label:e("adminBroker.title"),children:(0,YA.jsx)(x,{color:f?k.ok:k.warn,children:e(f===null?"adminBroker.checking":f?"adminBroker.ready":"adminBroker.notReady")})}),(0,YA.jsx)(x,{color:k.muted,children:e("adminBroker.tuiHint")})]}):null,d?.unitPath?(0,YA.jsx)(et,{label:e("keepalive.unitPath"),children:(0,YA.jsx)(x,{color:k.muted,children:d.unitPath})}):null,(0,YA.jsx)(X,{marginTop:1,flexDirection:"column",children:h.map(Q=>(0,YA.jsx)(xe,{selected:s===Q.id,onSelect:()=>{u(Q.id),S(Q.id)},onHover:()=>u(Q.id),children:Q.label},Q.id))}),(0,YA.jsxs)(X,{marginTop:1,flexDirection:"column",children:[d?.manager==="systemd"?(0,YA.jsx)(x,{color:d.linger?k.muted:k.warn,children:d.linger?e("keepalive.lingerEnabled"):e("keepalive.lingerDisabled")}):null,d?.manager==="supervisor"?(0,YA.jsx)(x,{color:k.warn,children:e("keepalive.fallbackNote")}):null,d?.manager==="windows-task"?(0,YA.jsx)(x,{color:k.muted,children:e("keepalive.windowsTaskNote")}):null,d?.manager==="windows-service"?(0,YA.jsx)(x,{color:k.warn,children:e("keepalive.serviceNote")}):null,(0,YA.jsx)(x,{color:k.muted,children:e("keepalive.logsHint",{command:i?.logsHint??""})})]}),(0,YA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var Dt=iA(ye(),1),va=iA(EA(),1);function Uy({ctx:A}){let{t:e,draft:i,editingId:r}=A,[l,s]=(0,va.useState)("socketPath"),[u,f]=(0,va.useState)(null);(0,va.useEffect)(()=>{f(Sg())},[]);let E=[{id:"socketPath",kind:"field",label:e("herdr.socketPath")},{id:"herdrArgs",kind:"field",label:e("herdr.args")},{id:"herdrAutoStart",kind:"toggle",label:e("field.herdrAutoStart")},{id:"save",kind:"action",label:e("common.save")}],d=(Q,p)=>{let D=dn(i,Q,p),{errorKey:v}=D;return v?(A.notify(N=>N(v),"error"),!1):(A.updateDraft(D.draft),!0)},h=()=>{try{let Q=Qn(i);A.reloadConfig(),A.notify(p=>p("common.saved",{path:Q.path}),"success")}catch(Q){A.notify(p=>p("error.saveFailed",{message:Q.message}),"error")}},S=Q=>{if(Q==="socketPath"||Q==="herdrArgs"){A.setEditing(Q);return}if(Q==="herdrAutoStart"){d(Q,i.herdr.autoStart?"off":"on");return}Q==="save"&&h()};return mt((Q,p)=>{let D=E.findIndex(N=>N.id===l),v=D>=0?D:0;p.upArrow?s(E[(v-1+E.length)%E.length].id):p.downArrow?s(E[(v+1)%E.length].id):p.return?S(l):Q==="s"&&h()},{isActive:r===null}),(0,Dt.jsxs)(nt,{title:e("herdr.title"),children:[E.map(Q=>Q.kind==="toggle"?(0,Dt.jsx)(Ui,{label:Q.label,selected:l===Q.id,onSelect:()=>{s(Q.id),S(Q.id)},onHover:()=>s(Q.id),children:(0,Dt.jsx)(x,{color:i.herdr.autoStart?k.ok:k.muted,children:i.herdr.autoStart?`[\xD7] ${e("common.on")}`:`[ ] ${e("common.off")}`})},Q.id):Q.kind==="field"?(0,Dt.jsx)(Ui,{label:Q.label,selected:l===Q.id,onSelect:()=>S(Q.id),onHover:()=>s(Q.id),children:(0,Dt.jsx)(Ji,{value:Ho(i,Q.id),placeholder:A.t(Ia(i,Q.id)),active:r===Q.id,onSubmit:p=>{d(Q.id,p)&&A.setEditing(null)},onCancel:()=>A.setEditing(null)})},Q.id):(0,Dt.jsx)(X,{marginTop:1,children:(0,Dt.jsx)(xe,{selected:l===Q.id,onSelect:()=>{s(Q.id),S(Q.id)},onHover:()=>s(Q.id),children:Q.label})},Q.id)),l==="herdrAutoStart"?(0,Dt.jsx)(X,{marginTop:1,children:(0,Dt.jsx)(x,{color:k.muted,children:e("herdr.autoStartHint")})}):null,A.dirty?(0,Dt.jsx)(X,{marginTop:1,children:(0,Dt.jsx)(x,{color:k.warn,children:e("hint.unsavedChanges")})}):null,(0,Dt.jsxs)(X,{marginTop:1,flexDirection:"column",children:[u?.version?(0,Dt.jsx)(et,{label:e("herdr.version"),children:(0,Dt.jsxs)(X,{children:[(0,Dt.jsx)(Ai,{level:u.supported?"ok":"warn"}),(0,Dt.jsx)(x,{children:` ${u.version}`})]})}):null,u?.version&&!u.supported?(0,Dt.jsx)(x,{color:k.warn,children:e("herdr.versionOutdated",{version:u.version,minimum:yg})}):null,u&&!u.ok?(0,Dt.jsx)(x,{color:k.warn,children:e("herdr.cliMissing")}):null]}),(0,Dt.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var Gt=iA(ye(),1),qo=iA(EA(),1);function Hy({ctx:A}){let{t:e,draft:i}=A,[r,l]=(0,qo.useState)("auto"),[s,u]=(0,qo.useState)({phase:"idle"}),f=(0,qo.useState)(()=>({current:{source:""}}))[0],E=yl({preference:"auto"}),d=[{id:"auto",label:e("about.languageAuto",{detected:E})},{id:"zh",label:e("about.languageZh")},{id:"en",label:e("about.languageEn")}],h=pg(),S=(()=>{switch(s.phase){case"checking":return e("update.checking");case"current":return e("update.upToDate",{version:s.latest});case"available":return e("update.available",{version:s.latest});case"updating":return s.attempt>1?e("update.updatingRetry",{version:s.latest,attempt:s.attempt}):e("update.updating",{version:s.latest});case"done":return e("update.done",{version:s.latest});case"error":return e(s.messageKey,s.params);default:return e("update.check")}})(),Q=[...d,{id:"update",label:S}],p=J=>{f.current={source:J.source??""},u(J.updateAvailable?{phase:"available",latest:J.latest}:{phase:"current",latest:J.latest})};(0,qo.useEffect)(()=>{A.updateCheck?.ok&&s.phase==="idle"&&p(A.updateCheck)},[A.updateCheck]);let D=async()=>{u({phase:"checking"});let J=await Dl();if(!J.ok){u({phase:"error",messageKey:J.errorKey??"update.errorNetwork"});let{message:G}=J;G&&A.notify(q=>q("update.errorNetworkDetail",{message:G}),"error");return}A.setUpdateCheck(J),p(J)},v=async J=>{u({phase:"updating",latest:J,attempt:1});let G=await wg(A.config,()=>mg({source:f.current.source,version:J,onAttempt:({attempt:q})=>u({phase:"updating",latest:J,attempt:q})}));if(!G.ok){let q={version:J,installed:G.installed??"",url:lg(J)};u({phase:"error",messageKey:G.errorKey??"update.errorFailed",params:q}),A.notify(V=>G.summary?V("update.errorFailedDetail",{message:G.summary}):V(G.errorKey??"update.errorFailed",q),"error");return}u({phase:"done",latest:J}),A.setUpdateCheck(null),A.notify(q=>q("update.restartHint"),"success")},N=()=>{if(!(s.phase==="checking"||s.phase==="updating")){if(s.phase==="available"){if(!h){u({phase:"error",messageKey:`update.cannot.${Qg()}`});return}v(s.latest);return}D()}},L=J=>{let G=dn(i,"language",J),{errorKey:q}=G;if(q){A.notify(V=>V(q),"error");return}A.updateDraft(G.draft);try{Qn(G.draft),A.reloadConfig(),A.notify(V=>V("common.saved",{path:vn()}),"success")}catch(V){A.notify(fA=>fA("error.saveFailed",{message:V.message}),"error")}},uA=J=>{if(J==="update"){N();return}L(J)};return mt((J,G)=>{let q=Q.findIndex(V=>V.id===r);G.upArrow?l(Q[(q-1+Q.length)%Q.length].id):G.downArrow?l(Q[(q+1)%Q.length].id):G.return&&uA(r)},{isActive:A.editingId===null}),(0,Gt.jsxs)(nt,{title:e("about.title"),children:[(0,Gt.jsx)(x,{color:k.muted,children:e("about.language")}),(0,Gt.jsx)(X,{flexDirection:"column",marginTop:1,marginBottom:1,children:d.map(J=>(0,Gt.jsx)(xe,{selected:r===J.id,onSelect:()=>{l(J.id),L(J.id)},onHover:()=>l(J.id),children:`${J.label}${i.ui.language===J.id?" \u2713":""}`},J.id))}),(0,Gt.jsx)(x,{color:k.muted,children:e("update.title")}),(0,Gt.jsx)(X,{flexDirection:"column",marginTop:1,marginBottom:1,children:(0,Gt.jsx)(xe,{selected:r==="update",onSelect:()=>{l("update"),N()},onHover:()=>l("update"),children:S})}),(0,Gt.jsx)(et,{label:e("about.version"),children:(0,Gt.jsx)(x,{color:k.muted,children:Cg()})}),ag(A.config)?(0,Gt.jsx)(et,{label:e("about.relayPackage"),children:(0,Gt.jsx)(x,{color:k.muted,children:dg()??"?"})}):null,(0,Gt.jsx)(et,{label:e("about.configPath"),children:(0,Gt.jsx)(x,{color:k.muted,children:vn()})}),(0,Gt.jsx)(et,{label:e("about.statePath"),children:(0,Gt.jsx)(x,{color:k.muted,children:og()})}),(0,Gt.jsx)(X,{marginTop:1,children:(0,Gt.jsx)(x,{color:k.muted,children:e("about.docs")})}),(0,Gt.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}var pA=iA(ye(),1),ni=iA(EA(),1);function fI(A,e){let i=["language","access"];return A==="lan"&&i.push("address"),A==="remote"&&e!==Ri&&i.push("relayUrl","password"),i.push("finish"),i}function EI({ctx:A,onDone:e}){let{t:i,draft:r}=A,[l,s]=(0,ni.useState)("language"),[u,f]=(0,ni.useState)(A.runtime.relayPassword||""),[E,d]=(0,ni.useState)(!0),[h,S]=(0,ni.useState)(!0),[Q,p]=(0,ni.useState)("startNow"),D=(0,ni.useMemo)(()=>Sl({includeLoopback:!1}),[]),v=(0,ni.useMemo)(()=>fI(r.relay.mode,r.relay.remoteUrl),[r.relay.mode,r.relay.remoteUrl]),N=Math.max(0,v.indexOf(l)),L=AA=>{let oA=r;for(let[OA,FA]of AA){let rt=dn(oA,OA,FA),{errorKey:PA}=rt;if(PA)return A.notify(qA=>qA(PA),"error"),!1;oA=rt.draft}return A.updateDraft(oA),A.notify("","info"),!0},uA=(AA,oA)=>L([[AA,oA]]),J=(AA,oA=v)=>{let OA=oA.indexOf(AA);s(oA[Math.min(oA.length-1,OA+1)])},G=()=>{let AA=v.indexOf(l);AA>0&&s(v[AA-1])},q=()=>{A.run(async()=>{r.relay.mode==="remote"&&gr(u),Qn(r),A.reloadConfig();let AA=Zn(),oA=!1;if(h)try{Mn.detectManager(AA.keepalive.manager)==="windows-service"&&A.notify(OA=>OA("keepalive.serviceWindowHint"),"info"),await Mn.install(AA),oA=!0}catch(OA){OA.code==="ELEVATION_CANCELLED"?A.notify(FA=>FA("keepalive.elevationCancelled"),"info"):A.notify(FA=>FA("keepalive.failed",{message:OA.message}),"error")}E&&!oA&&Rl(AA),e()})},V=(0,pA.jsxs)(X,{flexDirection:"column",marginBottom:1,children:[(0,pA.jsx)(x,{bold:!0,children:i("wizard.title")}),(0,pA.jsx)(x,{color:k.muted,children:i("wizard.step",{current:N+1,total:v.length})})]});if(l==="language")return(0,pA.jsxs)(nt,{title:i("wizard.languageTitle"),children:[V,(0,pA.jsx)(Yi,{options:[{id:"auto",label:i("about.languageAuto",{detected:A.locale})},{id:"zh",label:i("about.languageZh")},{id:"en",label:i("about.languageEn")}],current:r.ui.language,onPick:AA=>{uA("language",AA)&&J("language")},onCancel:()=>{}}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="access")return(0,pA.jsxs)(nt,{title:i("wizard.accessTitle"),children:[V,(0,pA.jsx)(Yi,{options:[...["local","lan"].map(AA=>({id:AA,label:i(`mode.${AA}`),description:i(`mode.${AA}.description`)})),{id:"official",label:i("mode.official"),description:i("mode.official.description")},{id:"remote",label:i("mode.remote"),description:i("mode.remote.description")}],current:mr(r),onPick:AA=>{if(AA==="official"){if(!uA("mode","official"))return;gr(""),J("access",fI("remote",Ri));return}uA("mode",AA)&&J("access",fI(AA,AA==="remote"?"":r.relay.remoteUrl))},onCancel:G}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.accessHint")})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="address")return(0,pA.jsxs)(nt,{title:i("wizard.addressTitle"),children:[V,D.length===0?(0,pA.jsxs)(X,{flexDirection:"column",children:[(0,pA.jsx)(x,{color:k.warn,children:i("relay.noAddresses")}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(xe,{selected:!0,onSelect:()=>J("address"),children:i("wizard.finish")})}),(0,pA.jsx)(aG,{onSkip:()=>J("address"),onBack:G})]}):(0,pA.jsx)(Yi,{options:D.map(AA=>({id:AA.address,label:`${AA.address} (${AA.name}, ${AA.kind})`})),current:r.relay.lanHost||D[0].address,onPick:AA=>{uA("lanHost",AA)&&J("address")},onCancel:G}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="relayUrl")return(0,pA.jsxs)(nt,{title:i("wizard.relayTitle"),children:[V,(0,pA.jsx)(Ui,{label:i("wizard.relayUrlLabel"),selected:!0,onSelect:()=>{},children:(0,pA.jsx)(Ji,{value:r.relay.remoteUrl,placeholder:"wss://relay.example.com",active:!0,onSubmit:AA=>{if(!AA){A.notify(oA=>oA("error.remoteUrlRequired"),"error");return}uA("remoteUrl",AA)&&J("relayUrl")},onCancel:G})}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.relayHint")})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});if(l==="password")return(0,pA.jsxs)(nt,{title:i("wizard.passwordTitle"),children:[V,(0,pA.jsx)(Ui,{label:i("relay.password"),selected:!0,onSelect:()=>{},children:(0,pA.jsx)(Ji,{value:u,placeholder:i("relay.passwordEmpty"),active:!0,mask:!0,onSubmit:AA=>{f(AA),J("password")},onCancel:G})}),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.passwordHint")})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]});let fA=[{id:"startNow",label:`${i("wizard.startNow")} [${E?"\xD7":" "}]`},{id:"installKeepalive",label:`${i("wizard.installKeepalive")} [${h?"\xD7":" "}]`},{id:"finish",label:i("wizard.finish")}],TA=AA=>{if(AA==="startNow"){d(oA=>!oA);return}if(AA==="installKeepalive"){S(oA=>!oA);return}q()};return(0,pA.jsxs)(nt,{title:i("wizard.finishTitle"),children:[V,(0,pA.jsx)(lG,{items:fA.map(AA=>AA.id),selected:Q,onSelect:p,onActivate:TA,onBack:G}),fA.map(AA=>(0,pA.jsx)(xe,{selected:Q===AA.id,onSelect:()=>{p(AA.id),TA(AA.id)},onHover:()=>p(AA.id),children:AA.label},AA.id)),(0,pA.jsx)(X,{marginTop:1,children:(0,pA.jsx)(x,{color:k.muted,children:i("wizard.finishHint",{path:vn()})})}),(0,pA.jsx)(yt,{text:A.message?.text??null,level:A.message?.level??"info"})]})}function lG({items:A,selected:e,onSelect:i,onActivate:r,onBack:l}){return mt((s,u)=>{let f=Math.max(0,A.indexOf(e));u.escape?l():u.upArrow?i(A[(f-1+A.length)%A.length]):u.downArrow?i(A[(f+1)%A.length]):u.return&&r(e)}),null}function aG({onSkip:A,onBack:e}){return mt((i,r)=>{r.return?A():r.escape&&e()}),null}var sG=3e3,ii=[{id:"overview",labelKey:"nav.overview"},{id:"pair",labelKey:"nav.pair"},{id:"services",labelKey:"nav.services"},{id:"relay",labelKey:"nav.relay"},{id:"keepalive",labelKey:"nav.keepalive"},{id:"herdr",labelKey:"nav.herdr"},{id:"about",labelKey:"nav.about"}];function uG({label:A,active:e,onSelect:i}){let r=(0,zA.useRef)(null),l=Ea(r,{onClick:i});return(0,it.jsx)(X,{ref:r,marginRight:2,children:(0,it.jsx)(x,{color:e||l?k.accent:k.muted,bold:e,underline:e||l,children:A})})}function cG({hints:A}){return(0,it.jsx)(X,{marginTop:1,paddingX:1,children:(0,it.jsx)(x,{color:k.muted,children:A.join(" \xB7 ")})})}function II({initialLanguage:A,needsWizard:e,updateChecker:i=hg()?Dl:null}){let{exit:r}=sE(),l=nm(),[s,u]=(0,zA.useState)(()=>Zn()),[f,E]=(0,zA.useState)(()=>Nu()),[d,h]=(0,zA.useState)(()=>ml()),[S,Q]=(0,zA.useState)(null),[p,D]=(0,zA.useState)("overview"),[v,N]=(0,zA.useState)(null),[L,uA]=(0,zA.useState)(!1),[J,G]=(0,zA.useState)(null),[q,V]=(0,zA.useState)(!e),[fA,TA]=(0,zA.useState)(null);(0,zA.useEffect)(()=>{if(!i)return;let hA=!1;return i().then(LA=>{!hA&&LA?.ok&&TA(LA)}).catch(()=>{}),()=>{hA=!0}},[i]);let AA=(0,zA.useMemo)(()=>yl({preference:A??f.ui.language}),[A,f.ui.language]),oA=(0,zA.useMemo)(()=>Ig(AA),[AA]),OA=(0,zA.useMemo)(()=>JSON.stringify(s)!==JSON.stringify(f),[s,f]),FA=(0,zA.useMemo)(()=>OA&&pE(s,f),[s,f,OA]),rt=(0,zA.useCallback)((hA,LA="info")=>{N({notice:hA,level:LA})},[]),PA=v&&{text:typeof v.notice=="string"?v.notice:v.notice(oA),level:v.level},qA=(0,zA.useCallback)(()=>{vg(Zn()).then(hA=>Q(hA)).catch(hA=>rt(hA.message,"error"))},[rt]),$t=(0,zA.useCallback)(()=>{let hA=Zn();u(hA),E(Nu(hA)),h(ml())},[]),$e=(0,zA.useCallback)(hA=>{uA(!0),Promise.resolve().then(hA).catch(LA=>rt(LA.message,"error")).finally(()=>{uA(!1),qA()})},[rt,qA]);(0,zA.useEffect)(()=>{if(!q)return;qA();let hA=setInterval(()=>{J||qA()},sG);return()=>clearInterval(hA)},[q,qA,J]);let mA=(0,zA.useRef)(null);(0,zA.useEffect)(()=>{mA.current===null&&l.supported&&!l.enabled&&l.enable()},[l.supported,l.enabled,l]);let ot={t:oA,locale:AA,config:s,draft:f,status:S,runtime:d,busy:L,dirty:OA,editingId:J,updateDraft:E,reloadConfig:$t,setEditing:G,notify:rt,run:$e,refresh:qA,message:PA,updateCheck:fA,setUpdateCheck:TA};if(mt((hA,LA)=>{if(LA.ctrl&&hA==="c"){r();return}if(hA==="q"){r();return}if(hA==="r"){N(null),qA();return}if(hA==="m"){if(!l.supported){rt($A=>$A("hint.mouseUnsupported"),"info");return}mA.current=!l.enabled,l.enabled?l.disable():l.enable();return}let An=ii.findIndex($A=>$A.id===p);if(LA.rightArrow||LA.tab&&!LA.shift){D(ii[(An+1)%ii.length].id);return}if(LA.leftArrow||LA.tab&&LA.shift){D(ii[(An-1+ii.length)%ii.length].id);return}let bt=Number.parseInt(hA,10);Number.isInteger(bt)&&bt>=1&&bt<=ii.length&&D(ii[bt-1].id)},{isActive:q&&J===null}),!q)return(0,it.jsx)(EI,{ctx:ot,onDone:()=>{$t(),V(!0),qA()}});let Ee=[oA("hint.navigate"),oA("hint.select"),oA("hint.tabs"),OA?oA("hint.save"):null,l.supported?l.enabled?oA("hint.mouseOn"):oA("hint.mouseOff"):oA("hint.mouseUnsupported"),oA("hint.quit")].filter(Boolean);return(0,it.jsxs)(X,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,it.jsxs)(X,{marginBottom:1,flexDirection:"column",children:[(0,it.jsxs)(X,{children:[(0,it.jsx)(x,{bold:!0,children:oA("app.name")}),(0,it.jsx)(x,{color:k.muted,children:` ${oA("app.tagline")}`})]}),fA?.updateAvailable?(0,it.jsx)(x,{color:k.warn,children:oA("update.banner",{latest:fA.latest??"",current:fA.current})}):null]}),(0,it.jsx)(X,{marginBottom:1,children:ii.map((hA,LA)=>(0,it.jsx)(uG,{label:`${LA+1} ${oA(hA.labelKey)}`,active:hA.id===p,onSelect:()=>D(hA.id)},hA.id))}),p==="overview"?(0,it.jsx)(Em,{ctx:ot}):null,p==="pair"?(0,it.jsx)(Ry,{ctx:ot}):null,p==="services"?(0,it.jsx)(My,{ctx:ot}):null,p==="relay"?(0,it.jsx)(Gy,{ctx:ot}):null,p==="keepalive"?(0,it.jsx)(by,{ctx:ot}):null,p==="herdr"?(0,it.jsx)(Uy,{ctx:ot}):null,p==="about"?(0,it.jsx)(Hy,{ctx:ot}):null,FA?(0,it.jsx)(X,{marginTop:1,children:(0,it.jsx)(x,{color:k.warn,children:oA("hint.restartRequired")})}):null,(0,it.jsx)(cG,{hints:Ee})]})}var Ju="\x1B",gG=`${Ju}[?1049h${Ju}[H`,fG=`${Ju}[?1049l`,EG=`${Ju}[?25h`;function xy(A=process.stdout){try{A.write(gG)}catch{}}function Ly(A=process.stdout){try{A.write(`${Ru}${EG}${fG}`)}catch{}}async function j_({language:A=null}={}){let e=!cg(),i=EE(process.stdin,process.stdout);xy();let r=oE((0,BI.jsx)(em,{source:i,children:(0,BI.jsx)(II,{initialLanguage:A,needsWizard:e})}),{stdin:i.stdin,exitOnCtrlC:!1}),l=()=>{i.dispose(),Ly()},s=()=>{r.unmount(),l(),process.exit(0)};process.once("SIGINT",s),process.once("SIGTERM",s),process.once("exit",l);try{await r.waitUntilExit()}finally{l(),process.off("SIGINT",s),process.off("SIGTERM",s)}}export{II as App,EI as Wizard,j_ as startTui};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./ZAAEQP3M.js";import"./U6QAYG3E.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./SWVUDSHP.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{b as ANSI_KEYS,a as ANSI_SLOTS,n as captureTerminalPalette,h as collectPalette,o as hostTerminalPalette,f as paletteFromEnvironment,d as parseOscColorReply,c as parseXColor,j as probeConsolePalette,i as probeTerminalPalette,k as rememberTerminalPalette,l as rememberedTerminalPalette,m as resolveHostPalette,e as sanitizePalette,g as takeOscColorReply};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
var A=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],R=["regular","bold","italic","boldItalic"],S=["truetype","opentype"],I=["cjk","all"];var M=/^#[0-9a-f]{6}$/i,y=/["'\\;,{}<>@\u0000-\u001f\u007f]/,T=/^[0-9a-f]{64}$/;function E(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function l(e,t){return e.includes(t)}function h(e){return typeof e=="string"&&M.test(e)?e.toLowerCase():void 0}function L(e){if(!E(e))return null;let t={};for(let r of["background","foreground","cursor"]){let o=h(e[r]);o&&(t[r]=o)}let n=e.ansi;if(E(n)){let r={};for(let o of A){let i=h(n[o]);i&&(r[o]=i)}Object.keys(r).length===A.length&&(t.ansi=r)}return Object.keys(t).length>0?t:null}function x(e){let t=typeof e=="string"?e.trim():"";return!t||t.length>128||y.test(t)?null:t}function U(e){if(!E(e))return null;let t=x(e.family);if(!t)return null;let n=Number(e.sizePx),r=Number.isFinite(n)&&n>=4&&n<=96?Math.round(n*10)/10:null,o=typeof e.source=="string"&&/^[a-z0-9-]{1,32}$/.test(e.source)?e.source:null,i=[],m=new Set;for(let f of Array.isArray(e.faces)?e.faces.slice(0,16):[]){if(!E(f))continue;let{style:a,format:c,bytes:s,sha256:_}=f;!l(R,a)||m.has(a)||l(S,c)&&(typeof s!="number"||!Number.isInteger(s)||s<=0||s>16777216||typeof _!="string"||!T.test(_)||(m.add(a),i.push({style:a,format:c,bytes:s,sha256:_})))}let p=[];for(let f of Array.isArray(e.subsets)?e.subsets.slice(0,16):[]){if(!E(f))continue;let a=x(f.family),{scope:c,sha256:s}=f;!a||f.style!=="regular"||l(I,c)&&(typeof s!="string"||!T.test(s)||p.some(_=>_.scope===c)||p.push({family:a,style:"regular",scope:c,sha256:s}))}return{family:t,...r!==null&&{sizePx:r},...o!==null&&{source:o},faces:i,subsets:p}}var P=8192;function B(e){if(typeof e!="string"||e.length>P)return null;let t;try{t=new URL(e)}catch{return null}return t.protocol==="http:"||t.protocol==="https:"?e:null}var w="dibin666/herdr-remote",g=`https://github.com/${w}/releases`,Y=`${g}/latest/download/latest.json`,H=`${g}/latest/download/herdr-remote.tgz`;function C(e){return`${g}/download/herdr-remote-v${e}/herdr-remote-${e}.tgz`}function u(e){return Buffer.isBuffer(e)?e:(typeof e=="string"||e instanceof ArrayBuffer,Buffer.from(e))}function k(e,t,n=Buffer.alloc(0)){if(typeof e!="string"||!e||typeof t!="string"||!t)throw new TypeError("type and streamId must be non-empty strings");let r=u(n),o=Buffer.from(JSON.stringify({type:e,streamId:t}),"utf8");if(o.length>8192)throw new RangeError("stream frame header is too large");let i=Buffer.allocUnsafe(4);return i.writeUInt32BE(o.length,0),Buffer.concat([i,o,r])}function F(e){let t=u(e);if(t.length<4)throw new Error("stream frame is truncated");let n=t.readUInt32BE(0);if(n===0||n>8192||t.length<4+n)throw new Error("stream frame header is invalid");let r;try{r=JSON.parse(t.subarray(4,4+n).toString("utf8"))}catch(o){throw new Error(`stream frame header is not JSON: ${o.message}`)}if(!r||typeof r.type!="string"||typeof r.streamId!="string")throw new Error("stream frame header is missing routing fields");return{version:1,type:r.type,streamId:r.streamId,payload:t.subarray(4+n)}}function z(e,t,n=Buffer.alloc(0)){let r=e;if(e==="output"?r=0:e==="input"&&(r=1),r!==0&&r!==1)throw new TypeError("type must be FRAME_TYPE_OUTPUT (0) or FRAME_TYPE_INPUT (1)");if(!Number.isInteger(t)||t<0||t>65535)throw new RangeError("streamIndex must be an unsigned 16-bit integer (0-65535)");let o=u(n),i=Buffer.allocUnsafe(4+o.length);return i.writeUInt8(255,0),i.writeUInt8(r,1),i.writeUInt16BE(t,2),o.copy(i,4),i}function N(e){let t=u(e);if(t.length<4)throw new Error("v2 stream frame is truncated");if(t.readUInt8(0)!==255)throw new Error("invalid v2 stream frame magic byte");let r=t.readUInt8(1);if(r!==0&&r!==1)throw new Error(`unknown v2 stream frame type: ${r}`);let o=t.readUInt16BE(2);return{version:2,type:r===0?"output":"input",typeCode:r,streamIndex:o,payload:t.subarray(4)}}function $(e){let t=u(e);if(t.length<4)throw new Error("stream frame is truncated");return t[0]===255?N(t):F(t)}var O=/^[\x21-\x7e]+$/;function G(e){if(!Array.isArray(e))return;let t=new Set;for(let n of e){if(t.size>=8)break;if(typeof n!="string")continue;let r=n.replace(/\s+/g,"").toLowerCase();r.length<=32&&O.test(r)&&t.add(r)}return t.size>0?[...t]:void 0}var K="/ws/host";var V={hostHandoff:"host_handoff",idleHeartbeat:"idle_heartbeat",binaryFrameV2:"binary_frame_v2",adminTabs:"admin_tabs",pasteAnyFile:"paste_any_file",openLink:"open_link"};var W="application/octet-stream";function q(e){if(typeof e!="string")return"file";let n=(e.normalize("NFC").split(/[\\/]/).pop()??"").replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^[._]+|[._]+$/g,"");if([...n].length>120){let r=n.lastIndexOf("."),o=r>0&&n.length-r<=16?n.slice(r):"";n=[...n.slice(0,n.length-o.length)].slice(0,120-o.length).join("")+o}return n||"file"}var d={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","image/gif":".gif"},Q=Object.keys(d);function Z(e){return typeof e=="string"&&Object.hasOwn(d,e)}function v(e,t){switch(e){case"image/png":return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71;case"image/jpeg":return t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255;case"image/webp":return t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80;case"image/gif":return t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70&&t[3]===56;default:return!1}}export{k as a,z as b,$ as c,A as d,R as e,L as f,U as g,B as h,G as i,K as j,V as k,W as l,q as m,d as n,Z as o,v as p,g as q,Y as r,H as s,C as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{b as T,c as F,e as S}from"./
|
|
3
|
+
import{b as T,c as F,e as S}from"./QL4I7VLD.js";import{i as U,j as K,k as x}from"./QOPTXTL7.js";import"./B6LZOIKD.js";import"./5RGV2MW6.js";import"./JJGEV4EZ.js";import"./IONXNA5T.js";import"./ZAAEQP3M.js";import"./U6QAYG3E.js";import"./PDOEV4QJ.js";import"./4CO2WAXZ.js";import{a as h}from"./HRFNURKU.js";import{a as A,h as R,j as v}from"./ETEPTJGZ.js";import{o as B}from"./37NKZLLR.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import{t as b}from"./SWVUDSHP.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";import{spawnSync as N}from"node:child_process";var O=12e4;function W(){let e=N(process.execPath,[h(),"restart","--json"],{encoding:"utf8",timeout:O,windowsHide:!0});if(!e.error&&e.status===0)return{ok:!0,message:""};let i=String(e.stderr||e.stdout||"").trim();return{ok:!1,message:e.error?.message||i||`exit ${e.status}`}}async function Z(e,i={}){let u=()=>i.config??B(),{platform:l=process.platform,checkCli:C=()=>R(),installCli:D=(r,p)=>v({source:r.source,version:r.latest,onAttempt:p}),isRunning:E=()=>S(u()),stop:I=()=>F(u()),start:P=()=>T(u()),restartInstalled:_=W,stopBroker:M=U,startBroker:$=async()=>{try{K(e)}catch{}return x()},report:t=r=>process.stdout.write(`${r}
|
|
4
4
|
`)}=i;t(e("update.checking"));let o=await C(),{current:a}=o;if(!o.ok)return t(e("update.errorNetworkDetail",{message:o.message??""})),{ok:!1,current:a,updated:null,restarted:!1,errorKey:o.errorKey};if(!o.updateAvailable)return t(e("update.upToDate",{version:a})),{ok:!0,current:a,updated:null,restarted:!1};let c="cli",n=o.latest??"",m=E(),f=l==="win32"&&m;f&&(t(e("update.stoppingServices")),I());let d=l==="win32"?await M():"unavailable",k=async()=>{if(d!=="stopped")return d==="busy"?"busy":null;let r=await $();return t(e(r?"update.brokerRestarted":"update.brokerRestartFailed")),r?"restarted":"failed"};t(e("update.updating",{version:n}));let s=await D(o,({attempt:r})=>{r>1&&t(e("update.updatingRetry",{version:n,attempt:r}))});if(!s.ok){f&&P();let r=await k();t(e(s.errorKey??"update.errorFailed",{version:n,installed:s.installed??"",url:b(n)})),s.summary&&t(e("update.errorFailedDetail",{message:s.summary})),l==="win32"&&A(s.output)&&t(e("update.errorBusy"));let{errorKey:p,summary:H}=s;return{ok:!1,current:a,updated:c,restarted:!1,adminBroker:r,errorKey:p,summary:H}}let g=s.installed??n;t(e("update.done",{version:g}));let y=!0,w=!1;if(!m)t(e("update.notRunning"));else{t(e("update.restarting"));let r=_();y=r.ok,w=r.ok,t(r.ok?e("services.restarted"):e("update.restartFailed",{message:r.message}))}d==="busy"&&t(e("update.brokerBusy"));let j=await k();return{ok:y,current:a,updated:c,installed:g,restarted:w,adminBroker:j}}export{Z as runUpdate};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{g as c,h as s}from"./
|
|
3
|
+
import{g as c,h as s}from"./4CO2WAXZ.js";import{a as i}from"./HRFNURKU.js";import"./ETEPTJGZ.js";import"./QRGNEKME.js";import"./SWVUDSHP.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";import{spawn as a}from"node:child_process";function d(r){return new Promise((e,n)=>{r.once("error",n),r.once("close",o=>e(o??1))})}function l({action:r,nodePath:e,entryPoint:n}){let o=c,t=`"${n}" admin-broker ${r} --elevated`;return`$ErrorActionPreference = 'Stop'
|
|
4
4
|
try {
|
|
5
5
|
$process = Start-Process -FilePath '${o(e)}' -ArgumentList '${o(t)}' -Verb RunAs -Wait -PassThru -WindowStyle Hidden
|
|
6
6
|
} catch {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{a as g,c as S}from"./U6QAYG3E.js";import{d as p,f as b}from"./
|
|
3
|
+
import{a as g,c as S}from"./U6QAYG3E.js";import{d as p,f as b}from"./SWVUDSHP.js";import f from"node:fs";import{spawnSync as O}from"node:child_process";var A=p.length,D="3",M=2,h=3e3,P=p;function v(e){if(typeof e!="string")return null;let n=/^rgba?:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i.exec(e.trim());if(!n)return null;let t=n.slice(1,4).map(r=>{let l=r.length;if(l===0||l>4)return null;let i=Math.round(parseInt(r,16)/(16**l-1)*255);return Math.max(0,Math.min(255,i))});return t.some(r=>r===null)?null:`#${t.map(r=>r.toString(16).padStart(2,"0")).join("")}`}function R(e,n){if(typeof e!="string")return null;let t=e.indexOf(`${n};`);if(t===-1)return null;let r=e.indexOf("\x1B\\",t),l=e.indexOf("\x07",t),i=-1,s=-1;if(r!==-1&&(l===-1||r<l))i=r,s=r+2;else if(l!==-1)i=l,s=l+1;else return null;let o=v(e.slice(t+n.length+1,i).trim());return o?{color:o,start:t,end:s}:null}function C(e,n){return R(e,n)?.color??null}var d=b;function T(e=process.env){let n=e.HERDR_TERM_PALETTE_JSON;if(!n)return null;try{return d(JSON.parse(n))}catch{return null}}function m(e,n){return O("stty",[...e,"-F",n],{encoding:"utf8",timeout:1e3,windowsHide:!0})}function y(e,n){let t=R(e.pending,n);return t?(e.pending=e.pending.slice(0,t.start)+e.pending.slice(t.end),t.color):null}var _=[{query:"\x1B]10;?\x1B\\",prefix:"\x1B]10",paletteKey:"foreground"},{query:"\x1B]11;?\x1B\\",prefix:"\x1B]11",paletteKey:"background"},{query:"\x1B]12;?\x1B\\",prefix:"\x1B]12",paletteKey:"cursor"},...P.map((e,n)=>({query:`\x1B]4;${n};?\x1B\\`,prefix:`\x1B]4;${n}`,paletteKey:"ansi",ansiKey:e}))];function x(e){let n={},t={};for(let r of _){let l=e(r.query,r.prefix);if(r.paletteKey==="ansi"){if(!l)break;t[r.ansiKey]=l}else l&&(n[r.paletteKey]=l)}return Object.keys(t).length===A&&(n.ansi=t),d(n)}function N(e,n,t,r){f.writeSync(e,n);let l=Buffer.alloc(256),i=0;for(;i<M&&Date.now()<r.overallDeadline;){let s=y(r,t);if(s)return s;let o=0;try{o=f.readSync(e,l,0,l.length,null)}catch(a){if(a.code==="EAGAIN"){i+=1;continue}return null}o>0?(r.pending+=l.toString("latin1",0,o),i=0):i+=1}return y(r,t)}function E({ttyPath:e="/dev/tty",timeoutMs:n=h}={}){if(process.platform==="win32")return null;let t=null,r=null;try{t=f.openSync(e,"r+")}catch{return null}try{let l=m(["-g"],e);if(l.status!==0||(r=l.stdout.trim(),m(["raw","-echo","min","0","time",D],e).status!==0))return null;let i={pending:"",overallDeadline:Date.now()+n},s=t;return x((o,a)=>N(s,o,a,i))}catch{return null}finally{if(r&&m([r],e),t!==null)try{f.closeSync(t)}catch{}}}async function I({input:e=process.stdin,output:n=process.stdout,timeoutMs:t=h}={}){if(!e.isTTY||!n.isTTY)return null;let r={pending:"",overallDeadline:Date.now()+t},l=null,i;try{return e.setRawMode(!0),await new Promise(s=>{let o=!1,a=()=>{o||(o=!0,s())};l=c=>{r.pending+=typeof c=="string"?c:c.toString("latin1"),/\x1b\[\?[\d;]*c/.test(r.pending)&&a()},e.on("data",l),e.resume(),i=setTimeout(a,Math.max(0,r.overallDeadline-Date.now())),n.write(`${_.map(({query:c})=>c).join("")}\x1B[c`)}),x((s,o)=>y(r,o))}catch{return null}finally{i&&clearTimeout(i),l&&e.removeListener("data",l);try{e.setRawMode(!1)}catch{}e.pause()}}function w(e){let n=d(e);if(!n)return null;try{S(t=>{t.terminalPalette=n})}catch{}return n}function K(){try{return d(g().terminalPalette)}catch{return null}}function J({env:e=process.env,probe:n=E}={}){return T(e)||n()||null}async function $({env:e=process.env,probe:n=E,platform:t=process.platform,consoleProbe:r=I}={}){if(e.HERDR_TERM_PALETTE_JSON)return T(e);if(!process.stdin.isTTY||!process.stdout.isTTY)return null;let l=t==="win32"?await r():n();return l?(e.HERDR_TERM_PALETTE_JSON=JSON.stringify(l),w(l),l):null}var u;function j({refresh:e=!1}={}){if(!e&&u!==void 0)return u;let n=T();if(n)return u=n,u;let t=E();return u=t?w(t):K(),u}export{A as a,P as b,v as c,C as d,d as e,T as f,y as g,x as h,E as i,I as j,w as k,K as l,J as m,$ as n,j as o};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
2
|
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{n as g,p}from"./ETEPTJGZ.js";import"./SWVUDSHP.js";import{a as s}from"./TNLCNVA2.js";import"./I6NRCYLI.js";import m from"node:fs";import c from"node:path";import{spawnSync as h}from"node:child_process";var d="herdr.remote.web",S="herdr-plugin.toml";function w(){return c.join(s,S)}function a(t,{timeout:r=15e3}={}){let e=h(g(),t,{encoding:"utf8",timeout:r,windowsHide:!0});if(e.error?.code==="ENOENT")throw Object.assign(new Error("herdr command not found"),{code:"HERDR_NOT_FOUND"});return e}function b(t){let r=[];for(let e of String(t||"").split(`
|
|
4
4
|
`)){let n=/^-\s+(\S+)\s+\((.*?)\)\s+(\S+)(?:\s+\[(.*)\])?/.exec(e.trim());if(!n)continue;let[,f,i,o,l]=n,u=l?l.split(";")[0].trim():null;r.push({id:f,name:i,enabled:o==="enabled",source:u,warnings:l?.includes(";")?l.slice(l.indexOf(";")+1).trim():null,localPath:u?.startsWith("local:")?u.slice(6):null})}return r}function k(){if(!m.existsSync(w()))return{available:!1,registered:!1,reason:"manifest missing"};let{version:t,supported:r}=p(),e={version:t,versionSupported:r},n;try{n=a(["plugin","list"])}catch(o){if(o.code==="HERDR_NOT_FOUND")return{available:!1,registered:!1,reason:"herdr not found"};throw o}if(n.status!==0)return{available:!0,registered:!1,reason:String(n.stderr||"").trim(),...e};let i=b(n.stdout).find(o=>o.id===d);return i?{available:!0,registered:!0,enabled:i.enabled,linkedPath:i.localPath,stale:i.localPath?c.resolve(i.localPath)!==c.resolve(s):!1,packageRoot:s,...e}:{available:!0,registered:!1,packageRoot:s,...e}}function _(){let t=k();t.registered&&t.stale&&a(["plugin","unlink",d]);let r=a(["plugin","link",s]);if(r.status!==0)throw new Error(String(r.stderr||r.stdout||"").trim()||"herdr plugin link failed");return{ok:!0,path:s,output:String(r.stdout||"").trim()}}function R(){let t=a(["plugin","unlink",d]);if(t.status!==0)throw new Error(String(t.stderr||t.stdout||"").trim()||"herdr plugin unlink failed");return{ok:!0,output:String(t.stdout||"").trim()}}export{b as parsePluginList,_ as register,k as registrationStatus,R as unregister};
|