9remote 2.0.82 → 2.1.2
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/dist/cli.cjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const __importMetaUrl = require('url').pathToFileURL(__filename).href;
|
|
3
|
-
var
|
|
4
|
-
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return b.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(b){var k=c((0,d.execSync)(x[T]).toString());return b?k:a(k)}function u(b){return new p.default(function(k,S){return(0,d.exec)(x[T],{},function(g,_,O){if(g)return S(new Error("Error while obtaining machine id: "+g.stack));var F=c(_.toString());return k(b?F:a(F))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=t(35),p=i(f);o.machineIdSync=l,o.machineId=u;var d=t(70),h=t(71),v=process,T=v.platform,P={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},x={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:P[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(r,o,t){r.exports={default:t(36),__esModule:!0}},function(r,o,t){t(66),t(68),t(69),t(67),r.exports=t(6).Promise},function(r,o){r.exports=function(){}},function(r,o){r.exports=function(t,i,s,a){if(!(t instanceof i)||a!==void 0&&a in t)throw TypeError(s+": incorrect invocation!");return t}},function(r,o,t){var i=t(13),s=t(31),a=t(62);r.exports=function(c){return function(l,u,f){var p,d=i(l),h=s(d.length),v=a(f,h);if(c&&u!=u){for(;h>v;)if(p=d[v++],p!=p)return!0}else for(;h>v;v++)if((c||v in d)&&d[v]===u)return c||v||0;return!c&&-1}}},function(r,d,t){var i=t(7),s=t(44),a=t(43),c=t(3),l=t(31),u=t(64),f={},p={},d=r.exports=function(h,v,T,P,x){var b,k,S,g,_=x?function(){return h}:u(h),O=i(T,P,v?2:1),F=0;if(typeof _!="function")throw TypeError(h+" is not iterable!");if(a(_)){for(b=l(h.length);b>F;F++)if(g=v?O(c(k=h[F])[0],k[1]):O(h[F]),g===f||g===p)return g}else for(S=_.call(h);!(k=S.next()).done;)if(g=s(S,O,k.value,v),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(r,o){r.exports=function(t,i,s){var a=s===void 0;switch(i.length){case 0:return a?t():t.call(s);case 1:return a?t(i[0]):t.call(s,i[0]);case 2:return a?t(i[0],i[1]):t.call(s,i[0],i[1]);case 3:return a?t(i[0],i[1],i[2]):t.call(s,i[0],i[1],i[2]);case 4:return a?t(i[0],i[1],i[2],i[3]):t.call(s,i[0],i[1],i[2],i[3])}return t.apply(s,i)}},function(r,o,t){var i=t(11);r.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(r,o,t){var i=t(10),s=t(1)("iterator"),a=Array.prototype;r.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(r,o,t){var i=t(3);r.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(r,o,t){"use strict";var i=t(49),s=t(17),a=t(18),c={};t(5)(c,t(1)("iterator"),function(){return this}),r.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(r,o,t){var i=t(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}r.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],p=f[i]();p.next=function(){return{done:u=!0}},f[i]=function(){return p},c(f)}catch{}return u}},function(r,o){r.exports=function(t,i){return{value:i,done:!!t}}},function(r,o,t){var i=t(2),s=t(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=t(11)(c)=="process";r.exports=function(){var f,p,d,h=function(){var x,b;for(u&&(x=c.domain)&&x.exit();f;){b=f.fn,f=f.next;try{b()}catch(k){throw f?d():p=void 0,k}}p=void 0,x&&x.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var v=!0,T=document.createTextNode("");new a(h).observe(T,{characterData:!0}),d=function(){T.data=v=!v}}else if(l&&l.resolve){var P=l.resolve();d=function(){P.then(h)}}else d=function(){s.call(i,h)};return function(x){var b={fn:x,next:void 0};p&&(p.next=b),f||(f=b,d()),p=b}}},function(r,o,t){var i=t(3),s=t(50),a=t(22),c=t(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,d=t(16)("iframe"),h=a.length,v=">";for(d.style.display="none",t(25).appendChild(d),d.src="javascript:",p=d.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+v),p.close(),f=p.F;h--;)delete f[u][a[h]];return f()};r.exports=Object.create||function(p,d){var h;return p!==null?(l[u]=i(p),h=new l,l[u]=null,h[c]=p):h=f(),d===void 0?h:s(h,d)}},function(r,o,t){var i=t(12),s=t(3),a=t(54);r.exports=t(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),p=f.length,d=0;p>d;)i.f(c,u=f[d++],l[u]);return c}},function(r,o,t){var i=t(55),s=t(17),a=t(13),c=t(32),l=t(8),u=t(26),f=Object.getOwnPropertyDescriptor;o.f=t(4)?f:function(p,d){if(p=a(p),d=c(d,!0),u)try{return f(p,d)}catch{}if(l(p,d))return s(!i.f.call(p,d),p[d])}},function(r,o,t){var i=t(8),s=t(63),a=t(19)("IE_PROTO"),c=Object.prototype;r.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(r,o,t){var i=t(8),s=t(13),a=t(39)(!1),c=t(19)("IE_PROTO");r.exports=function(l,u){var f,p=s(l),d=0,h=[];for(f in p)f!=c&&i(p,f)&&h.push(f);for(;u.length>d;)i(p,f=u[d++])&&(~a(h,f)||h.push(f));return h}},function(r,o,t){var i=t(53),s=t(22);r.exports=Object.keys||function(a){return i(a,s)}},function(r,o){o.f={}.propertyIsEnumerable},function(r,o,t){var i=t(5);r.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(r,o,t){r.exports=t(5)},function(r,o,t){var i=t(9),s=t(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};r.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=t(7)(Function.call,t(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(r,o,t){"use strict";var i=t(2),s=t(6),a=t(12),c=t(4),l=t(1)("species");r.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(r,o,t){var i=t(3),s=t(14),a=t(1)("species");r.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(r,o,t){var i=t(20),s=t(15);r.exports=function(a){return function(c,l){var u,f,p=String(s(c)),d=i(l),h=p.length;return d<0||d>=h?a?"":void 0:(u=p.charCodeAt(d),u<55296||u>56319||d+1===h||(f=p.charCodeAt(d+1))<56320||f>57343?a?p.charAt(d):u:a?p.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(r,o,t){var i=t(20),s=Math.max,a=Math.min;r.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(r,o,t){var i=t(15);r.exports=function(s){return Object(i(s))}},function(r,o,t){var i=t(21),s=t(1)("iterator"),a=t(10);r.exports=t(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(r,o,t){"use strict";var i=t(37),s=t(47),a=t(10),c=t(13);r.exports=t(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(r,o){},function(r,o,t){"use strict";var i,s,a,c=t(28),l=t(2),u=t(7),f=t(21),p=t(23),d=t(9),h=(t(3),t(14)),v=t(38),T=t(40),P=(t(58).set,t(60)),x=t(30).set,b=t(48)(),k="Promise",S=l.TypeError,_=l.process,g=l[k],_=l.process,O=f(_)=="process",F=function(){},j=!!(function(){try{var y=g.resolve(1),w=(y.constructor={})[t(1)("species")]=function(R){R(F,F)};return(O||typeof PromiseRejectionEvent=="function")&&y.then(F)instanceof w}catch{}})(),de=function(y,w){return y===w||y===g&&w===a},me=function(y){var w;return!(!d(y)||typeof(w=y.then)!="function")&&w},ee=function(y){return de(g,y)?new ke(y):new s(y)},ke=s=function(y){var w,R;this.promise=new y(function(L,Y){if(w!==void 0||R!==void 0)throw S("Bad Promise constructor");w=L,R=Y}),this.resolve=h(w),this.reject=h(R)},gt=function(y){try{y()}catch(w){return{error:w}}},et=function(y,w){if(!y._n){y._n=!0;var R=y._c;b(function(){for(var L=y._v,Y=y._s==1,tt=0,yt=function(De){var ve,Rn,Kt=Y?De.ok:De.fail,Gt=De.resolve,wt=De.reject,bn=De.domain;try{Kt?(Y||(y._h==2&&Ne(y),y._h=1),Kt===!0?ve=L:(bn&&bn.enter(),ve=Kt(L),bn&&bn.exit()),ve===De.promise?wt(S("Promise-chain cycle")):(Rn=me(ve))?Rn.call(ve,Gt,wt):Gt(ve)):wt(L)}catch(Bs){wt(Bs)}};R.length>tt;)yt(R[tt++]);y._c=[],y._n=!1,w&&!y._h&&Ht(y)})}},Ht=function(y){x.call(l,function(){var w,R,L,Y=y._v;if(te(y)&&(w=gt(function(){O?_.emit("unhandledRejection",Y,y):(R=l.onunhandledrejection)?R({promise:y,reason:Y}):(L=l.console)&&L.error&&L.error("Unhandled promise rejection",Y)}),y._h=O||te(y)?2:1),y._a=void 0,w)throw w.error})},te=function(y){if(y._h==1)return!1;for(var w,R=y._a||y._c,L=0;R.length>L;)if(w=R[L++],w.fail||!te(w.promise))return!1;return!0},Ne=function(y){x.call(l,function(){var w;O?_.emit("rejectionHandled",y):(w=l.onrejectionhandled)&&w({promise:y,reason:y._v})})},se=function(y){var w=this;w._d||(w._d=!0,w=w._w||w,w._v=y,w._s=2,w._a||(w._a=w._c.slice()),et(w,!0))},jt=function(y){var w,R=this;if(!R._d){R._d=!0,R=R._w||R;try{if(R===y)throw S("Promise can't be resolved itself");(w=me(y))?b(function(){var L={_w:R,_d:!1};try{w.call(y,u(jt,L,1),u(se,L,1))}catch(Y){se.call(L,Y)}}):(R._v=y,R._s=1,et(R,!1))}catch(L){se.call({_w:R,_d:!1},L)}}};j||(g=function(y){v(this,g,k,"_h"),h(y),i.call(this);try{y(u(jt,this,1),u(se,this,1))}catch(w){se.call(this,w)}},i=function(y){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=t(56)(g.prototype,{then:function(y,w){var R=ee(P(this,g));return R.ok=typeof y!="function"||y,R.fail=typeof w=="function"&&w,R.domain=O?_.domain:void 0,this._c.push(R),this._a&&this._a.push(R),this._s&&et(this,!1),R.promise},catch:function(y){return this.then(void 0,y)}}),ke=function(){var y=new i;this.promise=y,this.resolve=u(jt,y,1),this.reject=u(se,y,1)}),p(p.G+p.W+p.F*!j,{Promise:g}),t(18)(g,k),t(59)(k),a=t(6)[k],p(p.S+p.F*!j,k,{reject:function(y){var w=ee(this),R=w.reject;return R(y),w.promise}}),p(p.S+p.F*(c||!j),k,{resolve:function(y){if(y instanceof g&&de(y.constructor,this))return y;var w=ee(this),R=w.resolve;return R(y),w.promise}}),p(p.S+p.F*!(j&&t(46)(function(y){g.all(y).catch(F)})),k,{all:function(y){var w=this,R=ee(w),L=R.resolve,Y=R.reject,tt=gt(function(){var yt=[],De=0,ve=1;T(y,!1,function(Rn){var Kt=De++,Gt=!1;yt.push(void 0),ve++,w.resolve(Rn).then(function(wt){Gt||(Gt=!0,yt[Kt]=wt,--ve||L(yt))},Y)}),--ve||L(yt)});return tt&&Y(tt.error),R.promise},race:function(y){var w=this,R=ee(w),L=R.reject,Y=gt(function(){T(y,!1,function(tt){w.resolve(tt).then(R.resolve,L)})});return Y&&L(Y.error),R.promise}})},function(r,o,t){"use strict";var i=t(61)(!0);t(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(r,o,t){t(65);for(var i=t(2),s=t(5),a=t(10),c=t(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=i[f],d=p&&p.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(r,o){r.exports=require("child_process")},function(r,o){r.exports=require("crypto")}])})});var Ji={};Ys(Ji,{initTray:()=>Vr,killTray:()=>gn,openBrowser:()=>yn,showTrayNotification:()=>Yr,updateTrayTooltip:()=>or});function Hi(e){for(let n of e)try{if(Mt.default.existsSync(n))return n}catch{}return null}function mc(){if(process.platform==="win32"){for(let e of Vi)try{if(Mt.default.existsSync(e))return Mt.default.readFileSync(e).toString("base64")}catch{}return Bi}return Bi}function hc(){let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function Yi(){let{port:e,tunnelUrl:n,running:r}=Nt,o=r?n?"Tunnel ON":"Local only":"Idle",t=`http://localhost:${e}`;return`9Remote \u2022 ${o}
|
|
3
|
+
var Gs=Object.create;var pr=Object.defineProperty;var Ws=Object.getOwnPropertyDescriptor;var Vs=Object.getOwnPropertyNames;var Ys=Object.getPrototypeOf,qs=Object.prototype.hasOwnProperty;var Js=(e,n)=>()=>(e&&(n=e(e=0)),n);var ce=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Qs=(e,n)=>{for(var r in n)pr(e,r,{get:n[r],enumerable:!0})},Xs=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Vs(n))!qs.call(e,t)&&t!==r&&pr(e,t,{get:()=>n[t],enumerable:!(o=Ws(n,t))||o.enumerable});return e};var A=(e,n,r)=>(r=e!=null?Gs(Ys(e)):{},Xs(n||!e||!e.__esModule?pr(r,"default",{value:e,enumerable:!0}):r,e));var wo=ce((qt,hr)=>{(function(e,n){typeof qt=="object"&&typeof hr=="object"?hr.exports=n(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],n):typeof qt=="object"?qt["electron-machine-id"]=n(require("child_process"),require("crypto")):e["electron-machine-id"]=n(e.child_process,e.crypto)})(qt,function(e,n){return(function(r){function o(i){if(t[i])return t[i].exports;var s=t[i]={exports:{},id:i,loaded:!1};return r[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var t={};return o.m=r,o.c=t,o.p="",o(0)})([function(r,o,t){r.exports=t(34)},function(r,o,t){var i=t(29)("wks"),s=t(33),a=t(2).Symbol,c=typeof a=="function",l=r.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(r,o){var t=r.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=t)},function(r,o,t){var i=t(9);r.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(r,o,t){r.exports=!t(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(r,o,t){var i=t(12),s=t(17);r.exports=t(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(r,o){var t=r.exports={version:"2.4.0"};typeof __e=="number"&&(__e=t)},function(r,o,t){var i=t(14);r.exports=function(s,a,c){if(i(s),a===void 0)return s;switch(c){case 1:return function(l){return s.call(a,l)};case 2:return function(l,u){return s.call(a,l,u)};case 3:return function(l,u,f){return s.call(a,l,u,f)}}return function(){return s.apply(a,arguments)}}},function(r,o){var t={}.hasOwnProperty;r.exports=function(i,s){return t.call(i,s)}},function(r,o){r.exports=function(t){return typeof t=="object"?t!==null:typeof t=="function"}},function(r,o){r.exports={}},function(r,o){var t={}.toString;r.exports=function(i){return t.call(i).slice(8,-1)}},function(r,o,t){var i=t(3),s=t(26),a=t(32),c=Object.defineProperty;o.f=t(4)?Object.defineProperty:function(l,u,f){if(i(l),u=a(u,!0),i(f),s)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(r,o,t){var i=t(42),s=t(15);r.exports=function(a){return i(s(a))}},function(r,o){r.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(r,o){r.exports=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}},function(r,o,t){var i=t(9),s=t(2).document,a=i(s)&&i(s.createElement);r.exports=function(c){return a?s.createElement(c):{}}},function(r,o){r.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}},function(r,o,t){var i=t(12).f,s=t(8),a=t(1)("toStringTag");r.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(r,o,t){var i=t(29)("keys"),s=t(33);r.exports=function(a){return i[a]||(i[a]=s(a))}},function(r,o){var t=Math.ceil,i=Math.floor;r.exports=function(s){return isNaN(s=+s)?0:(s>0?i:t)(s)}},function(r,o,t){var i=t(11),s=t(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};r.exports=function(l){var u,f,p;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(p=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":p}},function(r,o){r.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(r,o,t){var i=t(2),s=t(6),a=t(7),c=t(5),l="prototype",u=function(f,p,d){var h,w,T,P=f&u.F,x=f&u.G,b=f&u.S,k=f&u.P,S=f&u.B,g=f&u.W,_=x?s:s[p]||(s[p]={}),I=_[l],F=x?i:b?i[p]:(i[p]||{})[l];x&&(d=p);for(h in d)w=!P&&F&&F[h]!==void 0,w&&h in _||(T=w?F[h]:d[h],_[h]=x&&typeof F[h]!="function"?d[h]:S&&w?a(T,i):g&&F[h]==T?(function(j){var de=function(me,ee,ke){if(this instanceof j){switch(arguments.length){case 0:return new j;case 1:return new j(me);case 2:return new j(me,ee)}return new j(me,ee,ke)}return j.apply(this,arguments)};return de[l]=j[l],de})(T):k&&typeof T=="function"?a(Function.call,T):T,k&&((_.virtual||(_.virtual={}))[h]=T,f&u.R&&I&&!I[h]&&c(I,h,T)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,r.exports=u},function(r,o){r.exports=function(t){try{return!!t()}catch{return!0}}},function(r,o,t){r.exports=t(2).document&&document.documentElement},function(r,o,t){r.exports=!t(4)&&!t(24)(function(){return Object.defineProperty(t(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(r,o,t){"use strict";var i=t(28),s=t(23),a=t(57),c=t(5),l=t(8),u=t(10),f=t(45),p=t(18),d=t(52),h=t(1)("iterator"),w=!([].keys&&"next"in[].keys()),T="@@iterator",P="keys",x="values",b=function(){return this};r.exports=function(k,S,g,_,I,F,j){f(g,S,_);var de,me,ee,ke=function(v){if(!w&&v in te)return te[v];switch(v){case P:return function(){return new g(this,v)};case x:return function(){return new g(this,v)}}return function(){return new g(this,v)}},gt=S+" Iterator",et=I==x,jt=!1,te=k.prototype,Ne=te[h]||te[T]||I&&te[I],se=Ne||ke(I),Kt=I?et?ke("entries"):se:void 0,y=S=="Array"&&te.entries||Ne;if(y&&(ee=d(y.call(new k)),ee!==Object.prototype&&(p(ee,gt,!0),i||l(ee,h)||c(ee,h,b))),et&&Ne&&Ne.name!==x&&(jt=!0,se=function(){return Ne.call(this)}),i&&!j||!w&&!jt&&te[h]||c(te,h,se),u[S]=se,u[gt]=b,I)if(de={values:et?se:ke(x),keys:F?se:ke(P),entries:Kt},j)for(me in de)me in te||a(te,me,de[me]);else s(s.P+s.F*(w||jt),S,de);return de}},function(r,o){r.exports=!0},function(r,o,t){var i=t(2),s="__core-js_shared__",a=i[s]||(i[s]={});r.exports=function(c){return a[c]||(a[c]={})}},function(r,o,t){var i,s,a,c=t(7),l=t(41),u=t(25),f=t(16),p=t(2),d=p.process,h=p.setImmediate,w=p.clearImmediate,T=p.MessageChannel,P=0,x={},b="onreadystatechange",k=function(){var g=+this;if(x.hasOwnProperty(g)){var _=x[g];delete x[g],_()}},S=function(g){k.call(g.data)};h&&w||(h=function(g){for(var _=[],I=1;arguments.length>I;)_.push(arguments[I++]);return x[++P]=function(){l(typeof g=="function"?g:Function(g),_)},i(P),P},w=function(g){delete x[g]},t(11)(d)=="process"?i=function(g){d.nextTick(c(k,g,1))}:T?(s=new T,a=s.port2,s.port1.onmessage=S,i=c(a.postMessage,a,1)):p.addEventListener&&typeof postMessage=="function"&&!p.importScripts?(i=function(g){p.postMessage(g+"","*")},p.addEventListener("message",S,!1)):i=b in f("script")?function(g){u.appendChild(f("script"))[b]=function(){u.removeChild(this),k.call(g)}}:function(g){setTimeout(c(k,g,1),0)}),r.exports={set:h,clear:w}},function(r,o,t){var i=t(20),s=Math.min;r.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(r,o,t){var i=t(9);r.exports=function(s,a){if(!i(s))return s;var c,l;if(a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s))||typeof(c=s.valueOf)=="function"&&!i(l=c.call(s))||!a&&typeof(c=s.toString)=="function"&&!i(l=c.call(s)))return l;throw TypeError("Can't convert object to primitive value")}},function(r,o){var t=0,i=Math.random();r.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++t+i).toString(36))}},function(r,o,t){"use strict";function i(b){return b&&b.__esModule?b:{default:b}}function s(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(b){return(0,h.createHash)("sha256").update(b).digest("hex")}function c(b){switch(T){case"darwin":return b.split("IOPlatformUUID")[1].split(`
|
|
4
|
+
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return b.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return b.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(b){var k=c((0,d.execSync)(x[T]).toString());return b?k:a(k)}function u(b){return new p.default(function(k,S){return(0,d.exec)(x[T],{},function(g,_,I){if(g)return S(new Error("Error while obtaining machine id: "+g.stack));var F=c(_.toString());return k(b?F:a(F))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=t(35),p=i(f);o.machineIdSync=l,o.machineId=u;var d=t(70),h=t(71),w=process,T=w.platform,P={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},x={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:P[s()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(r,o,t){r.exports={default:t(36),__esModule:!0}},function(r,o,t){t(66),t(68),t(69),t(67),r.exports=t(6).Promise},function(r,o){r.exports=function(){}},function(r,o){r.exports=function(t,i,s,a){if(!(t instanceof i)||a!==void 0&&a in t)throw TypeError(s+": incorrect invocation!");return t}},function(r,o,t){var i=t(13),s=t(31),a=t(62);r.exports=function(c){return function(l,u,f){var p,d=i(l),h=s(d.length),w=a(f,h);if(c&&u!=u){for(;h>w;)if(p=d[w++],p!=p)return!0}else for(;h>w;w++)if((c||w in d)&&d[w]===u)return c||w||0;return!c&&-1}}},function(r,d,t){var i=t(7),s=t(44),a=t(43),c=t(3),l=t(31),u=t(64),f={},p={},d=r.exports=function(h,w,T,P,x){var b,k,S,g,_=x?function(){return h}:u(h),I=i(T,P,w?2:1),F=0;if(typeof _!="function")throw TypeError(h+" is not iterable!");if(a(_)){for(b=l(h.length);b>F;F++)if(g=w?I(c(k=h[F])[0],k[1]):I(h[F]),g===f||g===p)return g}else for(S=_.call(h);!(k=S.next()).done;)if(g=s(S,I,k.value,w),g===f||g===p)return g};d.BREAK=f,d.RETURN=p},function(r,o){r.exports=function(t,i,s){var a=s===void 0;switch(i.length){case 0:return a?t():t.call(s);case 1:return a?t(i[0]):t.call(s,i[0]);case 2:return a?t(i[0],i[1]):t.call(s,i[0],i[1]);case 3:return a?t(i[0],i[1],i[2]):t.call(s,i[0],i[1],i[2]);case 4:return a?t(i[0],i[1],i[2],i[3]):t.call(s,i[0],i[1],i[2],i[3])}return t.apply(s,i)}},function(r,o,t){var i=t(11);r.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(r,o,t){var i=t(10),s=t(1)("iterator"),a=Array.prototype;r.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(r,o,t){var i=t(3);r.exports=function(s,a,c,l){try{return l?a(i(c)[0],c[1]):a(c)}catch(f){var u=s.return;throw u!==void 0&&i(u.call(s)),f}}},function(r,o,t){"use strict";var i=t(49),s=t(17),a=t(18),c={};t(5)(c,t(1)("iterator"),function(){return this}),r.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(r,o,t){var i=t(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}r.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],p=f[i]();p.next=function(){return{done:u=!0}},f[i]=function(){return p},c(f)}catch{}return u}},function(r,o){r.exports=function(t,i){return{value:i,done:!!t}}},function(r,o,t){var i=t(2),s=t(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=t(11)(c)=="process";r.exports=function(){var f,p,d,h=function(){var x,b;for(u&&(x=c.domain)&&x.exit();f;){b=f.fn,f=f.next;try{b()}catch(k){throw f?d():p=void 0,k}}p=void 0,x&&x.enter()};if(u)d=function(){c.nextTick(h)};else if(a){var w=!0,T=document.createTextNode("");new a(h).observe(T,{characterData:!0}),d=function(){T.data=w=!w}}else if(l&&l.resolve){var P=l.resolve();d=function(){P.then(h)}}else d=function(){s.call(i,h)};return function(x){var b={fn:x,next:void 0};p&&(p.next=b),f||(f=b,d()),p=b}}},function(r,o,t){var i=t(3),s=t(50),a=t(22),c=t(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,d=t(16)("iframe"),h=a.length,w=">";for(d.style.display="none",t(25).appendChild(d),d.src="javascript:",p=d.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+w),p.close(),f=p.F;h--;)delete f[u][a[h]];return f()};r.exports=Object.create||function(p,d){var h;return p!==null?(l[u]=i(p),h=new l,l[u]=null,h[c]=p):h=f(),d===void 0?h:s(h,d)}},function(r,o,t){var i=t(12),s=t(3),a=t(54);r.exports=t(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),p=f.length,d=0;p>d;)i.f(c,u=f[d++],l[u]);return c}},function(r,o,t){var i=t(55),s=t(17),a=t(13),c=t(32),l=t(8),u=t(26),f=Object.getOwnPropertyDescriptor;o.f=t(4)?f:function(p,d){if(p=a(p),d=c(d,!0),u)try{return f(p,d)}catch{}if(l(p,d))return s(!i.f.call(p,d),p[d])}},function(r,o,t){var i=t(8),s=t(63),a=t(19)("IE_PROTO"),c=Object.prototype;r.exports=Object.getPrototypeOf||function(l){return l=s(l),i(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(r,o,t){var i=t(8),s=t(13),a=t(39)(!1),c=t(19)("IE_PROTO");r.exports=function(l,u){var f,p=s(l),d=0,h=[];for(f in p)f!=c&&i(p,f)&&h.push(f);for(;u.length>d;)i(p,f=u[d++])&&(~a(h,f)||h.push(f));return h}},function(r,o,t){var i=t(53),s=t(22);r.exports=Object.keys||function(a){return i(a,s)}},function(r,o){o.f={}.propertyIsEnumerable},function(r,o,t){var i=t(5);r.exports=function(s,a,c){for(var l in a)c&&s[l]?s[l]=a[l]:i(s,l,a[l]);return s}},function(r,o,t){r.exports=t(5)},function(r,o,t){var i=t(9),s=t(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};r.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=t(7)(Function.call,t(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(r,o,t){"use strict";var i=t(2),s=t(6),a=t(12),c=t(4),l=t(1)("species");r.exports=function(u){var f=typeof s[u]=="function"?s[u]:i[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(r,o,t){var i=t(3),s=t(14),a=t(1)("species");r.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(r,o,t){var i=t(20),s=t(15);r.exports=function(a){return function(c,l){var u,f,p=String(s(c)),d=i(l),h=p.length;return d<0||d>=h?a?"":void 0:(u=p.charCodeAt(d),u<55296||u>56319||d+1===h||(f=p.charCodeAt(d+1))<56320||f>57343?a?p.charAt(d):u:a?p.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(r,o,t){var i=t(20),s=Math.max,a=Math.min;r.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(r,o,t){var i=t(15);r.exports=function(s){return Object(i(s))}},function(r,o,t){var i=t(21),s=t(1)("iterator"),a=t(10);r.exports=t(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(r,o,t){"use strict";var i=t(37),s=t(47),a=t(10),c=t(13);r.exports=t(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,s(1)):u=="keys"?s(0,f):u=="values"?s(0,l[f]):s(0,[f,l[f]])},"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(r,o){},function(r,o,t){"use strict";var i,s,a,c=t(28),l=t(2),u=t(7),f=t(21),p=t(23),d=t(9),h=(t(3),t(14)),w=t(38),T=t(40),P=(t(58).set,t(60)),x=t(30).set,b=t(48)(),k="Promise",S=l.TypeError,_=l.process,g=l[k],_=l.process,I=f(_)=="process",F=function(){},j=!!(function(){try{var y=g.resolve(1),v=(y.constructor={})[t(1)("species")]=function(R){R(F,F)};return(I||typeof PromiseRejectionEvent=="function")&&y.then(F)instanceof v}catch{}})(),de=function(y,v){return y===v||y===g&&v===a},me=function(y){var v;return!(!d(y)||typeof(v=y.then)!="function")&&v},ee=function(y){return de(g,y)?new ke(y):new s(y)},ke=s=function(y){var v,R;this.promise=new y(function(L,Y){if(v!==void 0||R!==void 0)throw S("Bad Promise constructor");v=L,R=Y}),this.resolve=h(v),this.reject=h(R)},gt=function(y){try{y()}catch(v){return{error:v}}},et=function(y,v){if(!y._n){y._n=!0;var R=y._c;b(function(){for(var L=y._v,Y=y._s==1,tt=0,yt=function(De){var ve,An,Gt=Y?De.ok:De.fail,Wt=De.resolve,wt=De.reject,kn=De.domain;try{Gt?(Y||(y._h==2&&Ne(y),y._h=1),Gt===!0?ve=L:(kn&&kn.enter(),ve=Gt(L),kn&&kn.exit()),ve===De.promise?wt(S("Promise-chain cycle")):(An=me(ve))?An.call(ve,Wt,wt):Wt(ve)):wt(L)}catch(Ks){wt(Ks)}};R.length>tt;)yt(R[tt++]);y._c=[],y._n=!1,v&&!y._h&&jt(y)})}},jt=function(y){x.call(l,function(){var v,R,L,Y=y._v;if(te(y)&&(v=gt(function(){I?_.emit("unhandledRejection",Y,y):(R=l.onunhandledrejection)?R({promise:y,reason:Y}):(L=l.console)&&L.error&&L.error("Unhandled promise rejection",Y)}),y._h=I||te(y)?2:1),y._a=void 0,v)throw v.error})},te=function(y){if(y._h==1)return!1;for(var v,R=y._a||y._c,L=0;R.length>L;)if(v=R[L++],v.fail||!te(v.promise))return!1;return!0},Ne=function(y){x.call(l,function(){var v;I?_.emit("rejectionHandled",y):(v=l.onrejectionhandled)&&v({promise:y,reason:y._v})})},se=function(y){var v=this;v._d||(v._d=!0,v=v._w||v,v._v=y,v._s=2,v._a||(v._a=v._c.slice()),et(v,!0))},Kt=function(y){var v,R=this;if(!R._d){R._d=!0,R=R._w||R;try{if(R===y)throw S("Promise can't be resolved itself");(v=me(y))?b(function(){var L={_w:R,_d:!1};try{v.call(y,u(Kt,L,1),u(se,L,1))}catch(Y){se.call(L,Y)}}):(R._v=y,R._s=1,et(R,!1))}catch(L){se.call({_w:R,_d:!1},L)}}};j||(g=function(y){w(this,g,k,"_h"),h(y),i.call(this);try{y(u(Kt,this,1),u(se,this,1))}catch(v){se.call(this,v)}},i=function(y){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=t(56)(g.prototype,{then:function(y,v){var R=ee(P(this,g));return R.ok=typeof y!="function"||y,R.fail=typeof v=="function"&&v,R.domain=I?_.domain:void 0,this._c.push(R),this._a&&this._a.push(R),this._s&&et(this,!1),R.promise},catch:function(y){return this.then(void 0,y)}}),ke=function(){var y=new i;this.promise=y,this.resolve=u(Kt,y,1),this.reject=u(se,y,1)}),p(p.G+p.W+p.F*!j,{Promise:g}),t(18)(g,k),t(59)(k),a=t(6)[k],p(p.S+p.F*!j,k,{reject:function(y){var v=ee(this),R=v.reject;return R(y),v.promise}}),p(p.S+p.F*(c||!j),k,{resolve:function(y){if(y instanceof g&&de(y.constructor,this))return y;var v=ee(this),R=v.resolve;return R(y),v.promise}}),p(p.S+p.F*!(j&&t(46)(function(y){g.all(y).catch(F)})),k,{all:function(y){var v=this,R=ee(v),L=R.resolve,Y=R.reject,tt=gt(function(){var yt=[],De=0,ve=1;T(y,!1,function(An){var Gt=De++,Wt=!1;yt.push(void 0),ve++,v.resolve(An).then(function(wt){Wt||(Wt=!0,yt[Gt]=wt,--ve||L(yt))},Y)}),--ve||L(yt)});return tt&&Y(tt.error),R.promise},race:function(y){var v=this,R=ee(v),L=R.reject,Y=gt(function(){T(y,!1,function(tt){v.resolve(tt).then(R.resolve,L)})});return Y&&L(Y.error),R.promise}})},function(r,o,t){"use strict";var i=t(61)(!0);t(27)(String,"String",function(s){this._t=String(s),this._i=0},function(){var s,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(s=i(a,c),this._i+=s.length,{value:s,done:!1})})},function(r,o,t){t(65);for(var i=t(2),s=t(5),a=t(10),c=t(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=i[f],d=p&&p.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(r,o){r.exports=require("child_process")},function(r,o){r.exports=require("crypto")}])})});var Zi={};Qs(Zi,{initTray:()=>qr,killTray:()=>wn,openBrowser:()=>vn,showTrayNotification:()=>Jr,updateTrayTooltip:()=>sr});function Gi(e){for(let n of e)try{if(Nt.default.existsSync(n))return n}catch{}return null}function yc(){if(process.platform==="win32"){for(let e of Ji)try{if(Nt.default.existsSync(e))return Nt.default.readFileSync(e).toString("base64")}catch{}return Ki}return Ki}function wc(){let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function Qi(){let{port:e,tunnelUrl:n,running:r}=Dt,o=r?n?"Tunnel ON":"Local only":"Idle",t=`http://localhost:${e}`;return`9Remote \u2022 ${o}
|
|
5
5
|
Local: ${t}
|
|
6
|
-
Right-click to open / quit`}function
|
|
7
|
-
`,"utf8")}catch{}};return ji.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?r?.():l.index===1&&(n?.(),gn(),setTimeout(()=>process.exit(0),500))}catch{}}),i.on("error",()=>{}),i.stderr.on("data",()=>{}),["Open Web UI","Shutdown"].forEach((c,l)=>s({action:"add-item",index:l,title:c,enabled:!0})),{_isWin:!0,_setTooltip(c){s({action:"set-tooltip",text:c})},sendAction(){},kill(){try{s({action:"kill"})}catch{}setTimeout(()=>{try{i&&!i.killed&&i.kill()}catch{}},300)}}}async function Vr({port:e,onQuit:n,onOpenUI:r}){if(!hc())return null;if(process.platform==="win32")return Nt={port:e,tunnelUrl:"",running:!0},z=yc({port:e,onQuit:n,onOpenUI:r}),z;try{let o=gc();if(!o)return null;let i={darwin:"tray_darwin_release",win32:"tray_windows_release.exe",linux:"tray_linux_release"}[process.platform];if(!i)return null;let s=Re.default.join(Wi,"systray2","traybin",i);if(!Mt.default.existsSync(s))return null;if(process.platform!=="win32")try{Mt.default.chmodSync(s,493)}catch{}return Nt={port:e,tunnelUrl:"",running:!0},z=new o({menu:qi(),debug:!1,copyDir:!0}),z.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(n?.(),gn(),setTimeout(()=>process.exit(0),500))}),typeof z.ready=="function"?z.ready().catch(()=>{}):(z.onReady(()=>{}),z.onError(()=>{})),z}catch{return null}}function or({tunnelUrl:e,running:n}={}){if(e!==void 0&&(Nt.tunnelUrl=e),n!==void 0&&(Nt.running=n),!!z){if(z._isWin){z._setTooltip?.(Yi());return}try{z.sendAction({type:"update-menu",menu:qi(),seq_id:-1})}catch{}}}function gn(){let e=z;if(z=null,e)try{e.kill(!0)}catch{}}function Yr({title:e="9Remote",message:n}){let r=process.platform;if(n){if(r==="win32"){let o=c=>String(c).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""),t=c=>String(c).replace(/'/g,"''"),i="9Remote",s=`<toast><visual><binding template="ToastText02"><text id="1">${o(e)}</text><text id="2">${o(n)}</text></binding></visual></toast>`,a=["try {","[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType=WindowsRuntime] > $null;","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType=WindowsRuntime] > $null;","$xml = New-Object Windows.Data.Xml.Dom.XmlDocument;",`$xml.LoadXml('${t(s)}');`,"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml);",`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${t(i)}').Show($toast);`,"} catch {","Add-Type -AssemblyName System.Windows.Forms;","$n = New-Object System.Windows.Forms.NotifyIcon;","$n.Icon = [System.Drawing.SystemIcons]::Information;",`$n.BalloonTipTitle = '${t(e)}';`,`$n.BalloonTipText = '${t(n)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,$e.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),t=`display notification "${o(n)}" with title "${o(e)}"`;(0,$e.spawn)("osascript",["-e",t],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,$e.spawn)("notify-send",[e,n],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function yn(e){let n=process.platform;if(n==="win32"){try{(0,$e.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,$e.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(n==="darwin"){try{(0,$e.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let r=[["setsid",["--fork","xdg-open",e]],["setsid",["xdg-open",e]],["xdg-open",[e]],["gio",["open",e]],["sensible-browser",[e]],["x-www-browser",[e]]];for(let[o,t]of r)try{(0,$e.spawn)(o,t,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var $e,ji,Mt,Re,Ki,Gi,Wi,z,Nt,rr,Bi,Vi,dc,Dt=Vs(()=>{$e=require("child_process"),ji=A(require("readline"),1),Mt=A(require("fs"),1),Re=A(require("path"),1),Ki=A(require("os"),1),Gi=require("url"),Wi=(0,Re.join)(Ki.default.homedir(),".9remote","runtime","node_modules"),z=null,Nt={port:0,tunnelUrl:"",running:!1},rr=Re.default.dirname((0,Gi.fileURLToPath)(__importMetaUrl)),Bi="iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAFw0lEQVR4nOWbaWwUVQDHf2+2tXRbCqmoKGgAuRIJoBwKkSAoDVKamDYLxUYUBSJHNCD30RhAbVWQqKCgXFGodKUfqGLljERsRaNQQoKoCKGFRhBp6XZ7sPv8MF0o7NTO7hzb4/dt5/9m3v/9d/fNO2YEOpEZiQnUeZMRYjQwAOgGdASi9V7DIuqAq8BZBMeQ8iDeuK/F7svX9JwsmiogJ8b0RjgWIkkHnAbN2kUVkIPDly121Pz+fwUbDUC6iEWJXQniVSDKbIc2UQdyLbHeTLGVaq0CmgHIZ2N64XPkAf0stWcfRUSTKj6vuni7EBSATHc+jORb4C5brNmFpASHSBY5nuKGh28JoP6bP0Jra3wASQlSDBFuT1ngkHJDe4F2+BxuWmvjAQRdccivpIvYwKEbAeCNXYV6e2vdSAahOBcFPgqov9XhOEnL7e1DpRK/6CXcnjL1FyAcC2k7jQeIR5GZAEJmJCZwvfoiLWeQYxYevM57Feq8ybS9xgPE4fSMU+rH9m0TKUZHEUrPH9cBnp4F9/SA4/vg+53WmbOH/lFAd11FHVGwvAC69Vc/j5gEPQfD1vnW2bMaSQ8FSNBVuO/wm40PMHYmpC7SLt8SEHRQgDsMXWTCchgz1RxD9hOjNF2mnlM/wNlibW3KGngs1SRP9qI/AN91eDsNLp3TuIoDZm+CAU+ZaM0e9AcAcOUCvJEC5X8Ha1F3wNwc6P2oSdbsIbQAAMr+hOw08FYGazFOmO+GLn1MsGYPoQcAcOYXeNcFdTXBWvs7YWk+dHrAoDV7CC8AgJOH4f3nwe8L1hK7wLJ8SGj+SwvhBwDwUz5snqOtde4JC76EdvGGqrAaYwEA7N8EuSu1tZ6DYd5OiI4xXI1VGA8AIC8L9nygrfV7AmZsAGFOVWZjnqvPFsN327W14S6Ystq0qszEvACkhI2z4NhebT1perOcN5j7u/TVwXsZ8Fuhtj5huTqdbkaY/8esqVKHzOdOaOuTs2BYmunVhos1PZOnXB0tXj4frAkFZn4SPLWOENZ1zVdK4c0UqLgcrEXHwJMvWlZ1KDTPe5ONWBdAYhdYkg8JnYK1uho4sNmyqkPBmgDaJ8KS3dDp/mBN+mH9tMYXV2zG/ABinDAvF7r21da3LYTCXaZXGy7mBuCIhjnboc8wbT13BRSsN7VKo5gXgBAwfR0MTNLW926EvGzTqjML8wJ4LgtGZmhrR3Jhy2umVWUm5gSQthjGzdbWThyCj19WO79miPEAxkwF1zJt7Y+fYXW69tJZM8FYAENS1D0BLUpOQdYzUK2xeNqMCD+Ah0bCK9vUPYHbuVKqNr7yXwPW7CG8AB4cpN7rtZa6rv0Dq8ZrT4SaIaEHEFjsjNVY7KypgndccOG0CdbsIbTnghLvU5e7O9wdrF2vhTWT4PSPobt4fCIMSIJoA/u0UkLpKfhmnTod14n+ABxRsGCX9oaH3wcfvgTH9+u+3A1SF6krRWYxOAWWjlD3MnWg/y+g9XxAgC1zoShP96VuYeyM8M5rjG79Va86UYBaQxXmroR9nxq6RASpUYAKXUW1ng8oWK/uCRih4CNj59/O2WLVqx4k5UJOdB4Fhug6waqHpCLXCRYJme7ciGRa+DW3aDYoSHkw0i4ihzwgpIt4FGcZEBdpOzbjwV/VWRFuKoEvIu3GdgQ7hJtKdRzg8GWjvn7WVqhF8WdB/UBIfbVMro2sJzuRa8SO6jPQcCQY680EiiJlyTYEhVR4X7/5sQHSFdcZRR4FNBb0WwUX8Muhwu0tDRy4ZS4g3J4yFDEeSYn93iznPH4xtmHjQWMyJHI8xUjlERCH7fNmMYJC/GKocHuC9uw1Z4PCXXmJCk8SsALwWO3PQmoRvEV51aiG7wo2pOmXp9V+IROYTMsZLHmA7Tj82YHevjGaDCCAdBGPIzYZKUYBA5F0R9ARo4/bG6cWyVUEfyH4Fb88hPTuqR/gNcl/yU6WmseVCn8AAAAASUVORK5CYII=",Vi=[Re.default.join(rr,"assets","trayIcon.ico"),Re.default.join(rr,"..","assets","trayIcon.ico")],dc=[Re.default.join(rr,"assets","tray.ps1"),Re.default.join(rr,"..","assets","tray.ps1")]});var Xr=ce((Pu,ns)=>{ns.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var is=ce((Iu,os)=>{var Sc=Xr();function rs(e){this.mode=Sc.MODE_8BIT_BYTE,this.data=e}rs.prototype={getLength:function(){return this.data.length},write:function(e){for(var n=0;n<this.data.length;n++)e.put(this.data.charCodeAt(n),8)}};os.exports=rs});var Zr=ce((Ou,ss)=>{var we={glog:function(e){if(e<1)throw new Error("glog("+e+")");return we.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return we.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(H=0;H<8;H++)we.EXP_TABLE[H]=1<<H;var H;for(H=8;H<256;H++)we.EXP_TABLE[H]=we.EXP_TABLE[H-4]^we.EXP_TABLE[H-5]^we.EXP_TABLE[H-6]^we.EXP_TABLE[H-8];var H;for(H=0;H<255;H++)we.LOG_TABLE[we.EXP_TABLE[H]]=H;var H;ss.exports=we});var zr=ce((Cu,as)=>{var mt=Zr();function sr(e,n){if(e.length===void 0)throw new Error(e.length+"/"+n);for(var r=0;r<e.length&&e[r]===0;)r++;this.num=new Array(e.length-r+n);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}sr.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var n=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)n[r+o]^=mt.gexp(mt.glog(this.get(r))+mt.glog(e.get(o)));return new sr(n,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var n=mt.glog(this.get(0))-mt.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(var t=0;t<e.getLength();t++)r[t]^=mt.gexp(mt.glog(e.get(t))+n);return new sr(r,0).mod(e)}};as.exports=sr});var ls=ce(($u,cs)=>{cs.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var ps=ce((Lu,fs)=>{var pe=Xr(),us=zr(),Ec=Zr(),Qe=ls(),V={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var n=e<<10;V.getBCHDigit(n)-V.getBCHDigit(V.G15)>=0;)n^=V.G15<<V.getBCHDigit(n)-V.getBCHDigit(V.G15);return(e<<10|n)^V.G15_MASK},getBCHTypeNumber:function(e){for(var n=e<<12;V.getBCHDigit(n)-V.getBCHDigit(V.G18)>=0;)n^=V.G18<<V.getBCHDigit(n)-V.getBCHDigit(V.G18);return e<<12|n},getBCHDigit:function(e){for(var n=0;e!==0;)n++,e>>>=1;return n},getPatternPosition:function(e){return V.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,n,r){switch(e){case Qe.PATTERN000:return(n+r)%2===0;case Qe.PATTERN001:return n%2===0;case Qe.PATTERN010:return r%3===0;case Qe.PATTERN011:return(n+r)%3===0;case Qe.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case Qe.PATTERN101:return n*r%2+n*r%3===0;case Qe.PATTERN110:return(n*r%2+n*r%3)%2===0;case Qe.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var n=new us([1],0),r=0;r<e;r++)n=n.multiply(new us([1,Ec.gexp(r)],0));return n},getLengthInBits:function(e,n){if(1<=n&&n<10)switch(e){case pe.MODE_NUMBER:return 10;case pe.MODE_ALPHA_NUM:return 9;case pe.MODE_8BIT_BYTE:return 8;case pe.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(n<27)switch(e){case pe.MODE_NUMBER:return 12;case pe.MODE_ALPHA_NUM:return 11;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(n<41)switch(e){case pe.MODE_NUMBER:return 14;case pe.MODE_ALPHA_NUM:return 13;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+n)},getLostPoint:function(e){var n=e.getModuleCount(),r=0,o=0,t=0;for(o=0;o<n;o++)for(t=0;t<n;t++){for(var i=0,s=e.isDark(o,t),a=-1;a<=1;a++)if(!(o+a<0||n<=o+a))for(var c=-1;c<=1;c++)t+c<0||n<=t+c||a===0&&c===0||s===e.isDark(o+a,t+c)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<n-1;o++)for(t=0;t<n-1;t++){var l=0;e.isDark(o,t)&&l++,e.isDark(o+1,t)&&l++,e.isDark(o,t+1)&&l++,e.isDark(o+1,t+1)&&l++,(l===0||l===4)&&(r+=3)}for(o=0;o<n;o++)for(t=0;t<n-6;t++)e.isDark(o,t)&&!e.isDark(o,t+1)&&e.isDark(o,t+2)&&e.isDark(o,t+3)&&e.isDark(o,t+4)&&!e.isDark(o,t+5)&&e.isDark(o,t+6)&&(r+=40);for(t=0;t<n;t++)for(o=0;o<n-6;o++)e.isDark(o,t)&&!e.isDark(o+1,t)&&e.isDark(o+2,t)&&e.isDark(o+3,t)&&e.isDark(o+4,t)&&!e.isDark(o+5,t)&&e.isDark(o+6,t)&&(r+=40);var u=0;for(t=0;t<n;t++)for(o=0;o<n;o++)e.isDark(o,t)&&u++;var f=Math.abs(100*u/n/n-50)/5;return r+=f*10,r}};fs.exports=V});var eo=ce((Mu,ds)=>{ds.exports={L:1,M:0,Q:3,H:2}});var hs=ce((Nu,ms)=>{var ar=eo();function be(e,n){this.totalCount=e,this.dataCount=n}be.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];be.getRSBlocks=function(e,n){var r=be.getRsBlockTable(e,n);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+n);for(var o=r.length/3,t=[],i=0;i<o;i++)for(var s=r[i*3+0],a=r[i*3+1],c=r[i*3+2],l=0;l<s;l++)t.push(new be(a,c));return t};be.getRsBlockTable=function(e,n){switch(n){case ar.L:return be.RS_BLOCK_TABLE[(e-1)*4+0];case ar.M:return be.RS_BLOCK_TABLE[(e-1)*4+1];case ar.Q:return be.RS_BLOCK_TABLE[(e-1)*4+2];case ar.H:return be.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};ms.exports=be});var ws=ce((Du,ys)=>{function gs(){this.buffer=[],this.length=0}gs.prototype={get:function(e){var n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)==1},put:function(e,n){for(var r=0;r<n;r++)this.putBit((e>>>n-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}};ys.exports=gs});var Ts=ce((Fu,Es)=>{var Tc=is(),Xe=ps(),xc=zr(),vs=hs(),Ss=ws();function Ae(e,n){this.typeNumber=e,this.errorCorrectLevel=n,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}Ae.prototype={addData:function(e){var n=new Tc(e);this.dataList.push(n),this.dataCache=null},isDark:function(e,n){if(e<0||this.moduleCount<=e||n<0||this.moduleCount<=n)throw new Error(e+","+n);return this.modules[e][n]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var n=vs.getRSBlocks(e,this.errorCorrectLevel),r=new Ss,o=0,t=0;t<n.length;t++)o+=n[t].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];r.put(s.mode,4),r.put(s.getLength(),Xe.getLengthInBits(s.mode,e)),s.write(r)}if(r.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,n){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[r][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,n),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=Ae.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,n)},setupPositionProbePattern:function(e,n){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)n+o<=-1||this.moduleCount<=n+o||(0<=r&&r<=6&&(o===0||o===6)||0<=o&&o<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=o&&o<=4?this.modules[e+r][n+o]=!0:this.modules[e+r][n+o]=!1)},getBestMaskPattern:function(){for(var e=0,n=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=Xe.getLostPoint(this);(r===0||e>o)&&(e=o,n=r)}return n},createMovieClip:function(e,n,r){var o=e.createEmptyMovieClip(n,r),t=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*t,a=0;a<this.modules[i].length;a++){var c=a*t,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+t,s),o.lineTo(c+t,s+t),o.lineTo(c,s+t),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)this.modules[e][6]===null&&(this.modules[e][6]=e%2===0);for(var n=8;n<this.moduleCount-8;n++)this.modules[6][n]===null&&(this.modules[6][n]=n%2===0)},setupPositionAdjustPattern:function(){for(var e=Xe.getPatternPosition(this.typeNumber),n=0;n<e.length;n++)for(var r=0;r<e.length;r++){var o=e[n],t=e[r];if(this.modules[o][t]===null)for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)Math.abs(i)===2||Math.abs(s)===2||i===0&&s===0?this.modules[o+i][t+s]=!0:this.modules[o+i][t+s]=!1}},setupTypeNumber:function(e){for(var n=Xe.getBCHTypeNumber(this.typeNumber),r,o=0;o<18;o++)r=!e&&(n>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r;for(var t=0;t<18;t++)r=!e&&(n>>t&1)===1,this.modules[t%3+this.moduleCount-8-3][Math.floor(t/3)]=r},setupTypeInfo:function(e,n){for(var r=this.errorCorrectLevel<<3|n,o=Xe.getBCHTypeInfo(r),t,i=0;i<15;i++)t=!e&&(o>>i&1)===1,i<6?this.modules[i][8]=t:i<8?this.modules[i+1][8]=t:this.modules[this.moduleCount-15+i][8]=t;for(var s=0;s<15;s++)t=!e&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=t:s<9?this.modules[8][15-s-1+1]=t:this.modules[8][15-s-1]=t;this.modules[this.moduleCount-8][8]=!e},mapData:function(e,n){for(var r=-1,o=this.moduleCount-1,t=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(s===6&&s--;;){for(var a=0;a<2;a++)if(this.modules[o][s-a]===null){var c=!1;i<e.length&&(c=(e[i]>>>t&1)===1);var l=Xe.getMask(n,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,t--,t===-1&&(i++,t=7)}if(o+=r,o<0||this.moduleCount<=o){o-=r,r=-r;break}}}};Ae.PAD0=236;Ae.PAD1=17;Ae.createData=function(e,n,r){for(var o=vs.getRSBlocks(e,n),t=new Ss,i=0;i<r.length;i++){var s=r[i];t.put(s.mode,4),t.put(s.getLength(),Xe.getLengthInBits(s.mode,e)),s.write(t)}for(var a=0,c=0;c<o.length;c++)a+=o[c].dataCount;if(t.getLengthInBits()>a*8)throw new Error("code length overflow. ("+t.getLengthInBits()+">"+a*8+")");for(t.getLengthInBits()+4<=a*8&&t.put(0,4);t.getLengthInBits()%8!==0;)t.putBit(!1);for(;!(t.getLengthInBits()>=a*8||(t.put(Ae.PAD0,8),t.getLengthInBits()>=a*8));)t.put(Ae.PAD1,8);return Ae.createBytes(t,o)};Ae.createBytes=function(e,n){for(var r=0,o=0,t=0,i=new Array(n.length),s=new Array(n.length),a=0;a<n.length;a++){var c=n[a].dataCount,l=n[a].totalCount-c;o=Math.max(o,c),t=Math.max(t,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&e.buffer[u+r];r+=c;var f=Xe.getErrorCorrectPolynomial(l),p=new xc(i[a],f.getLength()-1),d=p.mod(f);s[a]=new Array(f.getLength()-1);for(var h=0;h<s[a].length;h++){var v=h+d.getLength()-s[a].length;s[a][h]=v>=0?d.get(v):0}}for(var T=0,P=0;P<n.length;P++)T+=n[P].totalCount;for(var x=new Array(T),b=0,k=0;k<o;k++)for(var S=0;S<n.length;S++)k<i[S].length&&(x[b++]=i[S][k]);for(var g=0;g<t;g++)for(var _=0;_<n.length;_++)g<s[_].length&&(x[b++]=s[_][g]);return x};Es.exports=Ae});var bs=ce((Uu,Rs)=>{var Rc=Ts(),xs=eo(),bc="\x1B[40m \x1B[0m",cr="\x1B[47m \x1B[0m",Ac=function(e){return e?bc:cr},to=function(e){return{times:function(n){return new Array(n).join(e)}}},kc=function(e,n){for(var r=new Array(e),o=0;o<e;o++)r[o]=n;return r};Rs.exports={error:xs.L,generate:function(e,n,r){typeof n=="function"&&(r=n,n={});var o=new Rc(-1,this.error);o.addData(e),o.make();var t="";if(n&&n.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(kc(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=to(u.BLACK_WHITE).times(a+3),p=to(u.WHITE_BLACK).times(a+3);t+=f+`
|
|
6
|
+
Right-click to open / quit`}function Xi(){let{port:e,tunnelUrl:n}=Dt,r=process.platform==="win32",o=n?`9Remote (Port ${e}) \u2022 Tunnel ON`:`9Remote (Port ${e}) \u2022 Local only`;return{icon:yc(),title:r?`9Remote - Port ${e}`:"",tooltip:Qi(),items:[{title:o,tooltip:n||`http://localhost:${e}`,checked:!1,enabled:!1},{title:"Open Web UI",tooltip:`Open http://localhost:${e} in your browser`,checked:!1,enabled:!0},{title:"Shutdown",tooltip:"Stop 9Remote server, tunnel and quit",checked:!1,enabled:!0}]}}function vc(){try{let e=require(Re.default.join(qi,"systray2"));return e.default?.default||e.default||e}catch{return null}}function Sc({port:e,onQuit:n,onOpenUI:r}){let o=Gi(Ji),t=Gi(gc);if(!o||!t)return null;let i;try{i=(0,Ce.spawn)("powershell.exe",["-NoProfile","-ExecutionPolicy","Bypass","-WindowStyle","Hidden","-InputFormat","Text","-OutputFormat","Text","-File",t,"-IconPath",o,"-Tooltip",`9Remote - Port ${e}`],{windowsHide:!0,stdio:["pipe","pipe","pipe"]})}catch{return null}let s=c=>{try{i.stdin.writable&&i.stdin.write(`${JSON.stringify(c)}
|
|
7
|
+
`,"utf8")}catch{}};return Wi.default.createInterface({input:i.stdout}).on("line",c=>{try{let l=JSON.parse(c);if(l.type!=="click")return;l.index===0?r?.():l.index===1&&(n?.(),wn(),setTimeout(()=>process.exit(0),500))}catch{}}),i.on("error",()=>{}),i.stderr.on("data",()=>{}),["Open Web UI","Shutdown"].forEach((c,l)=>s({action:"add-item",index:l,title:c,enabled:!0})),{_isWin:!0,_setTooltip(c){s({action:"set-tooltip",text:c})},sendAction(){},kill(){try{s({action:"kill"})}catch{}setTimeout(()=>{try{i&&!i.killed&&i.kill()}catch{}},300)}}}async function qr({port:e,onQuit:n,onOpenUI:r}){if(!wc())return null;if(process.platform==="win32")return Dt={port:e,tunnelUrl:"",running:!0},z=Sc({port:e,onQuit:n,onOpenUI:r}),z;try{let o=vc();if(!o)return null;let i={darwin:"tray_darwin_release",win32:"tray_windows_release.exe",linux:"tray_linux_release"}[process.platform];if(!i)return null;let s=Re.default.join(qi,"systray2","traybin",i);if(!Nt.default.existsSync(s))return null;if(process.platform!=="win32")try{Nt.default.chmodSync(s,493)}catch{}return Dt={port:e,tunnelUrl:"",running:!0},z=new o({menu:Xi(),debug:!1,copyDir:!0}),z.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(n?.(),wn(),setTimeout(()=>process.exit(0),500))}),typeof z.ready=="function"?z.ready().catch(()=>{}):(z.onReady(()=>{}),z.onError(()=>{})),z}catch{return null}}function sr({tunnelUrl:e,running:n}={}){if(e!==void 0&&(Dt.tunnelUrl=e),n!==void 0&&(Dt.running=n),!!z){if(z._isWin){z._setTooltip?.(Qi());return}try{z.sendAction({type:"update-menu",menu:Xi(),seq_id:-1})}catch{}}}function wn(){let e=z;if(z=null,e)try{e.kill(!0)}catch{}}function Jr({title:e="9Remote",message:n}){let r=process.platform;if(n){if(r==="win32"){let o=c=>String(c).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""),t=c=>String(c).replace(/'/g,"''"),i="9Remote",s=`<toast><visual><binding template="ToastText02"><text id="1">${o(e)}</text><text id="2">${o(n)}</text></binding></visual></toast>`,a=["try {","[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType=WindowsRuntime] > $null;","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType=WindowsRuntime] > $null;","$xml = New-Object Windows.Data.Xml.Dom.XmlDocument;",`$xml.LoadXml('${t(s)}');`,"$toast = [Windows.UI.Notifications.ToastNotification]::new($xml);",`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${t(i)}').Show($toast);`,"} catch {","Add-Type -AssemblyName System.Windows.Forms;","$n = New-Object System.Windows.Forms.NotifyIcon;","$n.Icon = [System.Drawing.SystemIcons]::Information;",`$n.BalloonTipTitle = '${t(e)}';`,`$n.BalloonTipText = '${t(n)}';`,"$n.Visible = $true;","$n.ShowBalloonTip(5000);","Start-Sleep -Seconds 6;","$n.Dispose();","}"].join(" ");try{(0,Ce.spawn)("powershell.exe",["-NoProfile","-WindowStyle","Hidden","-Command",a],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(r==="darwin"){try{let o=s=>String(s).replace(/"/g,'\\"'),t=`display notification "${o(n)}" with title "${o(e)}"`;(0,Ce.spawn)("osascript",["-e",t],{detached:!0,stdio:"ignore"}).unref()}catch{}return}try{(0,Ce.spawn)("notify-send",[e,n],{detached:!0,stdio:"ignore"}).unref()}catch{}}}function vn(e){let n=process.platform;if(n==="win32"){try{(0,Ce.spawn)("rundll32.exe",["url.dll,FileProtocolHandler",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();return}catch{}try{(0,Ce.spawn)("cmd.exe",["/d","/s","/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}return}if(n==="darwin"){try{(0,Ce.spawn)("open",[e],{detached:!0,stdio:"ignore"}).unref()}catch{}return}let r=[["setsid",["--fork","xdg-open",e]],["setsid",["xdg-open",e]],["xdg-open",[e]],["gio",["open",e]],["sensible-browser",[e]],["x-www-browser",[e]]];for(let[o,t]of r)try{(0,Ce.spawn)(o,t,{detached:!0,stdio:"ignore",env:{...process.env}}).unref();return}catch{}}var Ce,Wi,Nt,Re,Vi,Yi,qi,z,Dt,ir,Ki,Ji,gc,Ft=Js(()=>{Ce=require("child_process"),Wi=A(require("readline"),1),Nt=A(require("fs"),1),Re=A(require("path"),1),Vi=A(require("os"),1),Yi=require("url"),qi=(0,Re.join)(Vi.default.homedir(),".9remote","runtime","node_modules"),z=null,Dt={port:0,tunnelUrl:"",running:!1},ir=Re.default.dirname((0,Yi.fileURLToPath)(__importMetaUrl)),Ki="iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAFw0lEQVR4nOWbaWwUVQDHf2+2tXRbCqmoKGgAuRIJoBwKkSAoDVKamDYLxUYUBSJHNCD30RhAbVWQqKCgXFGodKUfqGLljERsRaNQQoKoCKGFRhBp6XZ7sPv8MF0o7NTO7hzb4/dt5/9m3v/9d/fNO2YEOpEZiQnUeZMRYjQwAOgGdASi9V7DIuqAq8BZBMeQ8iDeuK/F7svX9JwsmiogJ8b0RjgWIkkHnAbN2kUVkIPDly121Pz+fwUbDUC6iEWJXQniVSDKbIc2UQdyLbHeTLGVaq0CmgHIZ2N64XPkAf0stWcfRUSTKj6vuni7EBSATHc+jORb4C5brNmFpASHSBY5nuKGh28JoP6bP0Jra3wASQlSDBFuT1ngkHJDe4F2+BxuWmvjAQRdccivpIvYwKEbAeCNXYV6e2vdSAahOBcFPgqov9XhOEnL7e1DpRK/6CXcnjL1FyAcC2k7jQeIR5GZAEJmJCZwvfoiLWeQYxYevM57Feq8ybS9xgPE4fSMU+rH9m0TKUZHEUrPH9cBnp4F9/SA4/vg+53WmbOH/lFAd11FHVGwvAC69Vc/j5gEPQfD1vnW2bMaSQ8FSNBVuO/wm40PMHYmpC7SLt8SEHRQgDsMXWTCchgz1RxD9hOjNF2mnlM/wNlibW3KGngs1SRP9qI/AN91eDsNLp3TuIoDZm+CAU+ZaM0e9AcAcOUCvJEC5X8Ha1F3wNwc6P2oSdbsIbQAAMr+hOw08FYGazFOmO+GLn1MsGYPoQcAcOYXeNcFdTXBWvs7YWk+dHrAoDV7CC8AgJOH4f3nwe8L1hK7wLJ8SGj+SwvhBwDwUz5snqOtde4JC76EdvGGqrAaYwEA7N8EuSu1tZ6DYd5OiI4xXI1VGA8AIC8L9nygrfV7AmZsAGFOVWZjnqvPFsN327W14S6Ystq0qszEvACkhI2z4NhebT1perOcN5j7u/TVwXsZ8Fuhtj5huTqdbkaY/8esqVKHzOdOaOuTs2BYmunVhos1PZOnXB0tXj4frAkFZn4SPLWOENZ1zVdK4c0UqLgcrEXHwJMvWlZ1KDTPe5ONWBdAYhdYkg8JnYK1uho4sNmyqkPBmgDaJ8KS3dDp/mBN+mH9tMYXV2zG/ABinDAvF7r21da3LYTCXaZXGy7mBuCIhjnboc8wbT13BRSsN7VKo5gXgBAwfR0MTNLW926EvGzTqjML8wJ4LgtGZmhrR3Jhy2umVWUm5gSQthjGzdbWThyCj19WO79miPEAxkwF1zJt7Y+fYXW69tJZM8FYAENS1D0BLUpOQdYzUK2xeNqMCD+Ah0bCK9vUPYHbuVKqNr7yXwPW7CG8AB4cpN7rtZa6rv0Dq8ZrT4SaIaEHEFjsjNVY7KypgndccOG0CdbsIbTnghLvU5e7O9wdrF2vhTWT4PSPobt4fCIMSIJoA/u0UkLpKfhmnTod14n+ABxRsGCX9oaH3wcfvgTH9+u+3A1SF6krRWYxOAWWjlD3MnWg/y+g9XxAgC1zoShP96VuYeyM8M5rjG79Va86UYBaQxXmroR9nxq6RASpUYAKXUW1ng8oWK/uCRih4CNj59/O2WLVqx4k5UJOdB4Fhug6waqHpCLXCRYJme7ciGRa+DW3aDYoSHkw0i4ihzwgpIt4FGcZEBdpOzbjwV/VWRFuKoEvIu3GdgQ7hJtKdRzg8GWjvn7WVqhF8WdB/UBIfbVMro2sJzuRa8SO6jPQcCQY680EiiJlyTYEhVR4X7/5sQHSFdcZRR4FNBb0WwUX8Muhwu0tDRy4ZS4g3J4yFDEeSYn93iznPH4xtmHjQWMyJHI8xUjlERCH7fNmMYJC/GKocHuC9uw1Z4PCXXmJCk8SsALwWO3PQmoRvEV51aiG7wo2pOmXp9V+IROYTMsZLHmA7Tj82YHevjGaDCCAdBGPIzYZKUYBA5F0R9ARo4/bG6cWyVUEfyH4Fb88hPTuqR/gNcl/yU6WmseVCn8AAAAASUVORK5CYII=",Ji=[Re.default.join(ir,"assets","trayIcon.ico"),Re.default.join(ir,"..","assets","trayIcon.ico")],gc=[Re.default.join(ir,"assets","tray.ps1"),Re.default.join(ir,"..","assets","tray.ps1")]});var zr=ce((Lu,is)=>{is.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var cs=ce((Mu,as)=>{var xc=zr();function ss(e){this.mode=xc.MODE_8BIT_BYTE,this.data=e}ss.prototype={getLength:function(){return this.data.length},write:function(e){for(var n=0;n<this.data.length;n++)e.put(this.data.charCodeAt(n),8)}};as.exports=ss});var eo=ce((Nu,ls)=>{var we={glog:function(e){if(e<1)throw new Error("glog("+e+")");return we.LOG_TABLE[e]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return we.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(H=0;H<8;H++)we.EXP_TABLE[H]=1<<H;var H;for(H=8;H<256;H++)we.EXP_TABLE[H]=we.EXP_TABLE[H-4]^we.EXP_TABLE[H-5]^we.EXP_TABLE[H-6]^we.EXP_TABLE[H-8];var H;for(H=0;H<255;H++)we.LOG_TABLE[we.EXP_TABLE[H]]=H;var H;ls.exports=we});var to=ce((Du,us)=>{var mt=eo();function cr(e,n){if(e.length===void 0)throw new Error(e.length+"/"+n);for(var r=0;r<e.length&&e[r]===0;)r++;this.num=new Array(e.length-r+n);for(var o=0;o<e.length-r;o++)this.num[o]=e[o+r]}cr.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var n=new Array(this.getLength()+e.getLength()-1),r=0;r<this.getLength();r++)for(var o=0;o<e.getLength();o++)n[r+o]^=mt.gexp(mt.glog(this.get(r))+mt.glog(e.get(o)));return new cr(n,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var n=mt.glog(this.get(0))-mt.glog(e.get(0)),r=new Array(this.getLength()),o=0;o<this.getLength();o++)r[o]=this.get(o);for(var t=0;t<e.getLength();t++)r[t]^=mt.gexp(mt.glog(e.get(t))+n);return new cr(r,0).mod(e)}};us.exports=cr});var ps=ce((Fu,fs)=>{fs.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var hs=ce((Uu,ms)=>{var pe=zr(),ds=to(),Rc=eo(),Qe=ps(),V={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(e){for(var n=e<<10;V.getBCHDigit(n)-V.getBCHDigit(V.G15)>=0;)n^=V.G15<<V.getBCHDigit(n)-V.getBCHDigit(V.G15);return(e<<10|n)^V.G15_MASK},getBCHTypeNumber:function(e){for(var n=e<<12;V.getBCHDigit(n)-V.getBCHDigit(V.G18)>=0;)n^=V.G18<<V.getBCHDigit(n)-V.getBCHDigit(V.G18);return e<<12|n},getBCHDigit:function(e){for(var n=0;e!==0;)n++,e>>>=1;return n},getPatternPosition:function(e){return V.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,n,r){switch(e){case Qe.PATTERN000:return(n+r)%2===0;case Qe.PATTERN001:return n%2===0;case Qe.PATTERN010:return r%3===0;case Qe.PATTERN011:return(n+r)%3===0;case Qe.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case Qe.PATTERN101:return n*r%2+n*r%3===0;case Qe.PATTERN110:return(n*r%2+n*r%3)%2===0;case Qe.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var n=new ds([1],0),r=0;r<e;r++)n=n.multiply(new ds([1,Rc.gexp(r)],0));return n},getLengthInBits:function(e,n){if(1<=n&&n<10)switch(e){case pe.MODE_NUMBER:return 10;case pe.MODE_ALPHA_NUM:return 9;case pe.MODE_8BIT_BYTE:return 8;case pe.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(n<27)switch(e){case pe.MODE_NUMBER:return 12;case pe.MODE_ALPHA_NUM:return 11;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else if(n<41)switch(e){case pe.MODE_NUMBER:return 14;case pe.MODE_ALPHA_NUM:return 13;case pe.MODE_8BIT_BYTE:return 16;case pe.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}else throw new Error("type:"+n)},getLostPoint:function(e){var n=e.getModuleCount(),r=0,o=0,t=0;for(o=0;o<n;o++)for(t=0;t<n;t++){for(var i=0,s=e.isDark(o,t),a=-1;a<=1;a++)if(!(o+a<0||n<=o+a))for(var c=-1;c<=1;c++)t+c<0||n<=t+c||a===0&&c===0||s===e.isDark(o+a,t+c)&&i++;i>5&&(r+=3+i-5)}for(o=0;o<n-1;o++)for(t=0;t<n-1;t++){var l=0;e.isDark(o,t)&&l++,e.isDark(o+1,t)&&l++,e.isDark(o,t+1)&&l++,e.isDark(o+1,t+1)&&l++,(l===0||l===4)&&(r+=3)}for(o=0;o<n;o++)for(t=0;t<n-6;t++)e.isDark(o,t)&&!e.isDark(o,t+1)&&e.isDark(o,t+2)&&e.isDark(o,t+3)&&e.isDark(o,t+4)&&!e.isDark(o,t+5)&&e.isDark(o,t+6)&&(r+=40);for(t=0;t<n;t++)for(o=0;o<n-6;o++)e.isDark(o,t)&&!e.isDark(o+1,t)&&e.isDark(o+2,t)&&e.isDark(o+3,t)&&e.isDark(o+4,t)&&!e.isDark(o+5,t)&&e.isDark(o+6,t)&&(r+=40);var u=0;for(t=0;t<n;t++)for(o=0;o<n;o++)e.isDark(o,t)&&u++;var f=Math.abs(100*u/n/n-50)/5;return r+=f*10,r}};ms.exports=V});var no=ce((Bu,gs)=>{gs.exports={L:1,M:0,Q:3,H:2}});var ws=ce((Hu,ys)=>{var lr=no();function be(e,n){this.totalCount=e,this.dataCount=n}be.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];be.getRSBlocks=function(e,n){var r=be.getRsBlockTable(e,n);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+e+"/errorCorrectLevel:"+n);for(var o=r.length/3,t=[],i=0;i<o;i++)for(var s=r[i*3+0],a=r[i*3+1],c=r[i*3+2],l=0;l<s;l++)t.push(new be(a,c));return t};be.getRsBlockTable=function(e,n){switch(n){case lr.L:return be.RS_BLOCK_TABLE[(e-1)*4+0];case lr.M:return be.RS_BLOCK_TABLE[(e-1)*4+1];case lr.Q:return be.RS_BLOCK_TABLE[(e-1)*4+2];case lr.H:return be.RS_BLOCK_TABLE[(e-1)*4+3];default:return}};ys.exports=be});var Es=ce((ju,Ss)=>{function vs(){this.buffer=[],this.length=0}vs.prototype={get:function(e){var n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)==1},put:function(e,n){for(var r=0;r<n;r++)this.putBit((e>>>n-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}};Ss.exports=vs});var bs=ce((Ku,Rs)=>{var bc=cs(),Xe=hs(),Ac=to(),Ts=ws(),xs=Es();function Ae(e,n){this.typeNumber=e,this.errorCorrectLevel=n,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}Ae.prototype={addData:function(e){var n=new bc(e);this.dataList.push(n),this.dataCache=null},isDark:function(e,n){if(e<0||this.moduleCount<=e||n<0||this.moduleCount<=n)throw new Error(e+","+n);return this.modules[e][n]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var e=1;for(e=1;e<40;e++){for(var n=Ts.getRSBlocks(e,this.errorCorrectLevel),r=new xs,o=0,t=0;t<n.length;t++)o+=n[t].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];r.put(s.mode,4),r.put(s.getLength(),Xe.getLengthInBits(s.mode,e)),s.write(r)}if(r.getLengthInBits()<=o*8)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,n){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[r][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(e,n),this.typeNumber>=7&&this.setupTypeNumber(e),this.dataCache===null&&(this.dataCache=Ae.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,n)},setupPositionProbePattern:function(e,n){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var o=-1;o<=7;o++)n+o<=-1||this.moduleCount<=n+o||(0<=r&&r<=6&&(o===0||o===6)||0<=o&&o<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=o&&o<=4?this.modules[e+r][n+o]=!0:this.modules[e+r][n+o]=!1)},getBestMaskPattern:function(){for(var e=0,n=0,r=0;r<8;r++){this.makeImpl(!0,r);var o=Xe.getLostPoint(this);(r===0||e>o)&&(e=o,n=r)}return n},createMovieClip:function(e,n,r){var o=e.createEmptyMovieClip(n,r),t=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*t,a=0;a<this.modules[i].length;a++){var c=a*t,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+t,s),o.lineTo(c+t,s+t),o.lineTo(c,s+t),o.endFill())}return o},setupTimingPattern:function(){for(var e=8;e<this.moduleCount-8;e++)this.modules[e][6]===null&&(this.modules[e][6]=e%2===0);for(var n=8;n<this.moduleCount-8;n++)this.modules[6][n]===null&&(this.modules[6][n]=n%2===0)},setupPositionAdjustPattern:function(){for(var e=Xe.getPatternPosition(this.typeNumber),n=0;n<e.length;n++)for(var r=0;r<e.length;r++){var o=e[n],t=e[r];if(this.modules[o][t]===null)for(var i=-2;i<=2;i++)for(var s=-2;s<=2;s++)Math.abs(i)===2||Math.abs(s)===2||i===0&&s===0?this.modules[o+i][t+s]=!0:this.modules[o+i][t+s]=!1}},setupTypeNumber:function(e){for(var n=Xe.getBCHTypeNumber(this.typeNumber),r,o=0;o<18;o++)r=!e&&(n>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r;for(var t=0;t<18;t++)r=!e&&(n>>t&1)===1,this.modules[t%3+this.moduleCount-8-3][Math.floor(t/3)]=r},setupTypeInfo:function(e,n){for(var r=this.errorCorrectLevel<<3|n,o=Xe.getBCHTypeInfo(r),t,i=0;i<15;i++)t=!e&&(o>>i&1)===1,i<6?this.modules[i][8]=t:i<8?this.modules[i+1][8]=t:this.modules[this.moduleCount-15+i][8]=t;for(var s=0;s<15;s++)t=!e&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=t:s<9?this.modules[8][15-s-1+1]=t:this.modules[8][15-s-1]=t;this.modules[this.moduleCount-8][8]=!e},mapData:function(e,n){for(var r=-1,o=this.moduleCount-1,t=7,i=0,s=this.moduleCount-1;s>0;s-=2)for(s===6&&s--;;){for(var a=0;a<2;a++)if(this.modules[o][s-a]===null){var c=!1;i<e.length&&(c=(e[i]>>>t&1)===1);var l=Xe.getMask(n,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,t--,t===-1&&(i++,t=7)}if(o+=r,o<0||this.moduleCount<=o){o-=r,r=-r;break}}}};Ae.PAD0=236;Ae.PAD1=17;Ae.createData=function(e,n,r){for(var o=Ts.getRSBlocks(e,n),t=new xs,i=0;i<r.length;i++){var s=r[i];t.put(s.mode,4),t.put(s.getLength(),Xe.getLengthInBits(s.mode,e)),s.write(t)}for(var a=0,c=0;c<o.length;c++)a+=o[c].dataCount;if(t.getLengthInBits()>a*8)throw new Error("code length overflow. ("+t.getLengthInBits()+">"+a*8+")");for(t.getLengthInBits()+4<=a*8&&t.put(0,4);t.getLengthInBits()%8!==0;)t.putBit(!1);for(;!(t.getLengthInBits()>=a*8||(t.put(Ae.PAD0,8),t.getLengthInBits()>=a*8));)t.put(Ae.PAD1,8);return Ae.createBytes(t,o)};Ae.createBytes=function(e,n){for(var r=0,o=0,t=0,i=new Array(n.length),s=new Array(n.length),a=0;a<n.length;a++){var c=n[a].dataCount,l=n[a].totalCount-c;o=Math.max(o,c),t=Math.max(t,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&e.buffer[u+r];r+=c;var f=Xe.getErrorCorrectPolynomial(l),p=new Ac(i[a],f.getLength()-1),d=p.mod(f);s[a]=new Array(f.getLength()-1);for(var h=0;h<s[a].length;h++){var w=h+d.getLength()-s[a].length;s[a][h]=w>=0?d.get(w):0}}for(var T=0,P=0;P<n.length;P++)T+=n[P].totalCount;for(var x=new Array(T),b=0,k=0;k<o;k++)for(var S=0;S<n.length;S++)k<i[S].length&&(x[b++]=i[S][k]);for(var g=0;g<t;g++)for(var _=0;_<n.length;_++)g<s[_].length&&(x[b++]=s[_][g]);return x};Rs.exports=Ae});var _s=ce((Gu,ks)=>{var kc=bs(),As=no(),_c="\x1B[40m \x1B[0m",ur="\x1B[47m \x1B[0m",Pc=function(e){return e?_c:ur},ro=function(e){return{times:function(n){return new Array(n).join(e)}}},Oc=function(e,n){for(var r=new Array(e),o=0;o<e;o++)r[o]=n;return r};ks.exports={error:As.L,generate:function(e,n,r){typeof n=="function"&&(r=n,n={});var o=new kc(-1,this.error);o.addData(e),o.make();var t="";if(n&&n.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(Oc(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=ro(u.BLACK_WHITE).times(a+3),p=ro(u.WHITE_BLACK).times(a+3);t+=f+`
|
|
8
8
|
`;for(var d=0;d<a;d+=2){t+=u.WHITE_ALL;for(var h=0;h<a;h++)c[d][h]===s&&c[d+1][h]===s?t+=u.WHITE_ALL:c[d][h]===s&&c[d+1][h]===i?t+=u.WHITE_BLACK:c[d][h]===i&&c[d+1][h]===s?t+=u.BLACK_WHITE:t+=u.BLACK_ALL;t+=u.WHITE_ALL+`
|
|
9
|
-
`}l||(t+=p)}else{var
|
|
10
|
-
`,o.modules.forEach(function(T){t+=
|
|
11
|
-
`}),t+=
|
|
12
|
-
`)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of
|
|
13
|
-
`)}catch{}}function
|
|
14
|
-
=== SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),
|
|
15
|
-
`).filter(Boolean).slice(-e)}catch{return[]}}function q(e){return{info:(...n)=>
|
|
9
|
+
`}l||(t+=p)}else{var w=ro(ur).times(o.getModuleCount()+3);t+=w+`
|
|
10
|
+
`,o.modules.forEach(function(T){t+=ur,t+=T.map(Pc).join(""),t+=ur+`
|
|
11
|
+
`}),t+=w}r?r(t):console.log(t)},setErrorLevel:function(e){this.error=As[e]||this.error}}});var Pn=require("fs"),Yt=require("path"),go=require("url"),yo=A(require("os"),1);var _n=A(require("dns"),1),_e=A(require("path"),1),lo=A(require("os"),1),ne="9remote",mr=process.env.NREMOTE_REGISTRY||`https://registry.npmjs.org/${ne}/latest`,Pe=`${ne}@latest`,Fe=_e.default.join(lo.default.homedir(),".9remote"),re={ROOT:Fe,LOGS:_e.default.join(Fe,"logs"),STATE:_e.default.join(Fe,"state"),CONFIG:_e.default.join(Fe,"config"),BIN:_e.default.join(Fe,"bin"),PIDS:_e.default.join(Fe,"pids"),BUFFERS:_e.default.join(Fe,"buffers"),DAEMON:_e.default.join(Fe,"daemon")},uo=new _n.default.promises.Resolver;uo.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);var dr=_n.default.lookup,Zs=/^(\d{1,3}\.){3}\d{1,3}$|^::1$|^[0-9a-f:]+$/i;_n.default.lookup=(e,n,r)=>{if(typeof n=="function"&&(r=n,n={}),e==="localhost"||Zs.test(e))return dr(e,n,r);uo.resolve4(e).then(o=>{if(!o?.length)return dr(e,n,r);n.all?r(null,o.map(t=>({address:t,family:4}))):r(null,o[0],4)}).catch(()=>dr(e,n,r))};var O=2208,co=5173;var Xc=[`http://localhost:${O}`,`http://127.0.0.1:${O}`,`http://localhost:${co}`,`http://127.0.0.1:${co}`],Vt={fileName:"agent.log",rotatedName:"agent.log.1",maxBytes:2*1024*1024,cleanupAfterDays:7},fo=60,$={STOPPED:0,PREPARING:1,CONNECTING:2,TUNNELING:3,VERIFYING:4,READY:5},po={showTunnelUrlInMenu:!1};var mo={CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN:"1"};var ho={checkIntervalMs:3e4,requestTimeoutMs:5e3},le={server:{strategy:"exp",baseMs:1e3,maxMs:6e4},tunnelRestart:{strategy:"exp",baseMs:2e3,maxMs:3e5},tunnelSpawn:{strategy:"linear",baseMs:5e3,maxMs:6e4},internet:{strategy:"linear",baseMs:3e3,maxMs:6e4},sse:{strategy:"linear",baseMs:2e3,maxMs:2e3},urlSync:{strategy:"linear",baseMs:5e3,maxMs:6e4}},zs={Accept:"application/json, text/plain, */*","Accept-Language":"en-US,en;q=0.9","Cache-Control":"no-cache",Pragma:"no-cache","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"};function G(e,n={}){return fetch(e,{...n,headers:{...zs,...n.headers}})}var ea=(0,Yt.dirname)((0,go.fileURLToPath)(__importMetaUrl)),ta=[(0,Yt.join)(yo.default.homedir(),".9remote",".env"),(0,Yt.join)(ea,"..",".env")];function na(e){for(let n of e.split(`
|
|
12
|
+
`)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?$/);o&&!process.env[o[1]]&&(process.env[o[1]]=o[2])}}for(let e of ta)if((0,Pn.existsSync)(e))try{na((0,Pn.readFileSync)(e,"utf8"))}catch{}for(let[e,n]of Object.entries(mo))process.env[e]||(process.env[e]=n);var vr=A(require("path"),1),Ro=A(require("fs"),1),bo=require("url");var vo=A(wo(),1),gr=A(require("crypto"),1),{machineIdSync:ra}=vo.default;async function vt(e=null){let n=e||process.env.MACHINE_ID_SALT||"9remote-salt";try{let r=ra();return gr.default.createHash("sha256").update(r+n).digest("hex").substring(0,16)}catch(r){return console.error("Error getting machine ID:",r),gr.default.randomUUID().replace(/-/g,"").substring(0,16)}}var So=A(require("crypto"),1),oa=process.env.API_KEY_SECRET||"9remote-api-key-secret";function ia(){let e="abcdefghijklmnopqrstuvwxyz0123456789",n="";for(let r=0;r<4;r++)n+=e.charAt(Math.floor(Math.random()*e.length));return n}function sa(e,n){return So.default.createHmac("sha256",oa).update(e+n).digest("hex").slice(0,6)}function St(e){let n=e.slice(0,8),r=ia(),o=sa(n,r);return{key:`sk-${n}-${r}-${o}`,keyId:r}}function On(e){return!e||e.length<8?"sk-***":`${e.slice(0,3)}***${e.slice(-4)}`}var ae=A(require("fs"),1),Jt=A(require("path"),1);var rl=re.STATE,yr=Jt.default.join(re.STATE,"state.json"),wr=Jt.default.join(re.ROOT,"keys.json"),In=Jt.default.join(re.STATE,"cmd.json"),ol=Jt.default.join(re.STATE,"settings.json");function $n(){for(let e of[re.ROOT,re.STATE])ae.default.existsSync(e)||ae.default.mkdirSync(e,{recursive:!0})}function Cn(e){try{$n(),ae.default.writeFileSync(yr,JSON.stringify(e,null,2),{mode:384})}catch(n){console.error("Error saving state:",n)}}function Eo(){try{ae.default.existsSync(yr)&&ae.default.unlinkSync(yr)}catch{}}function Ln(){try{return $n(),ae.default.existsSync(wr)?JSON.parse(ae.default.readFileSync(wr,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function Et(e){try{$n(),ae.default.writeFileSync(In,JSON.stringify({cmd:e,ts:Date.now()}))}catch{}}function To(){try{if(!ae.default.existsSync(In))return null;let e=JSON.parse(ae.default.readFileSync(In,"utf8"));return ae.default.unlinkSync(In),e.cmd}catch{return null}}function nt(e,n,r="Default"){try{$n();let o={machineId:e,key:n,name:r,createdAt:new Date().toISOString()};return ae.default.writeFileSync(wr,JSON.stringify(o,null,2),{mode:384}),o}catch(o){return console.error("Error saving key:",o),null}}function xo(){return process.env.CODESPACES==="true"}var aa=vr.default.dirname((0,bo.fileURLToPath)(__importMetaUrl));async function Ue(){let e=await vt();if(xo()&&process.env.NREMOTE_API_KEY)return nt(e,process.env.NREMOTE_API_KEY,"Codespace");let n=Ln();if(!n.key){let{key:r}=St(e);n=nt(e,r,"Default")}return n}function Se(){return"2.1.2"}var Ee=A(require("fs"),1),Er=A(require("path"),1);var Mn=re.LOGS,Xt=Er.default.join(Mn,Vt.fileName),Nn=Er.default.join(Mn,Vt.rotatedName),Ao=!1,ko=null;function ca(){Ee.default.existsSync(Mn)||Ee.default.mkdirSync(Mn,{recursive:!0})}function la(){try{if(Ee.default.statSync(Xt).size<Vt.maxBytes)return;try{Ee.default.rmSync(Nn,{force:!0})}catch{}Ee.default.renameSync(Xt,Nn)}catch{}}function ua(){try{let e=Ee.default.statSync(Nn);Date.now()-e.mtimeMs>Vt.cleanupAfterDays*864e5&&Ee.default.rmSync(Nn,{force:!0})}catch{}}function Tr(e){try{la(),Ee.default.appendFileSync(Xt,e+`
|
|
13
|
+
`)}catch{}}function Sr(e){return e.map(n=>{if(n instanceof Error)return n.stack||n.message;if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}).join(" ")}function _o(){let e=new Date,n=(r,o=2)=>String(r).padStart(o,"0");return`${n(e.getHours())}:${n(e.getMinutes())}:${n(e.getSeconds())}.${n(e.getMilliseconds(),3)}`}var fa=/\x1b\[[0-9;]*m/g,pa=/https?:\/\/[^\s]+/g;function da(e){return String(e).replace(fa,"").replace(pa,"").replace(/\s+$/g,"")}function Qt(e,n,r){let o=da(r);if(!o)return;let t=n==="info"?e:`${e}:${n}`,i=`${_o()} [${t}] ${o}`;if(Tr(i),ko)try{ko(i)}catch{}}function ma(){process.on("uncaughtException",e=>Qt("crash","error",`uncaughtException: ${e?.stack||e?.message||e}`)),process.on("unhandledRejection",e=>{let n=e instanceof Error?e.stack||e.message:String(e);Qt("crash","error",`unhandledRejection: ${n}`)}),process.on("exit",e=>Tr(`${_o()} [exit] code=${e} pid=${process.pid}`))}function Po(){Ao||(Ao=!0,ca(),ua(),Tr(`
|
|
14
|
+
=== SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),ma())}function Oo(e=60){try{return Ee.default.readFileSync(Xt,"utf8").split(`
|
|
15
|
+
`).filter(Boolean).slice(-e)}catch{return[]}}function q(e){return{info:(...n)=>Qt(e,"info",Sr(n)),warn:(...n)=>Qt(e,"warn",Sr(n)),error:(...n)=>Qt(e,"error",Sr(n))}}var Zt=Xt;var Io=(e=0)=>n=>`\x1B[${n+e}m`,$o=(e=0)=>n=>`\x1B[${38+e};5;${n}m`,Co=(e=0)=>(n,r,o)=>`\x1B[${38+e};2;${n};${r};${o}m`,M={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ml=Object.keys(M.modifier),ha=Object.keys(M.color),ga=Object.keys(M.bgColor),hl=[...ha,...ga];function ya(){let e=new Map;for(let[n,r]of Object.entries(M)){for(let[o,t]of Object.entries(r))M[o]={open:`\x1B[${t[0]}m`,close:`\x1B[${t[1]}m`},r[o]=M[o],e.set(t[0],t[1]);Object.defineProperty(M,n,{value:r,enumerable:!1})}return Object.defineProperty(M,"codes",{value:e,enumerable:!1}),M.color.close="\x1B[39m",M.bgColor.close="\x1B[49m",M.color.ansi=Io(),M.color.ansi256=$o(),M.color.ansi16m=Co(),M.bgColor.ansi=Io(10),M.bgColor.ansi256=$o(10),M.bgColor.ansi16m=Co(10),Object.defineProperties(M,{rgbToAnsi256:{value(n,r,o){return n===r&&r===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(n){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(i=>i+i).join(""));let t=Number.parseInt(o,16);return[t>>16&255,t>>8&255,t&255]},enumerable:!1},hexToAnsi256:{value:n=>M.rgbToAnsi256(...M.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,o,t;if(n>=232)r=((n-232)*10+8)/255,o=r,t=r;else{n-=16;let a=n%36;r=Math.floor(n/36)/5,o=Math.floor(a/6)/5,t=a%6/5}let i=Math.max(r,o,t)*2;if(i===0)return 30;let s=30+(Math.round(t)<<2|Math.round(o)<<1|Math.round(r));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(n,r,o)=>M.ansi256ToAnsi(M.rgbToAnsi256(n,r,o)),enumerable:!1},hexToAnsi:{value:n=>M.ansi256ToAnsi(M.hexToAnsi256(n)),enumerable:!1}}),M}var wa=ya(),he=wa;var Fn=A(require("node:process"),1),Mo=A(require("node:os"),1),xr=A(require("node:tty"),1);function ue(e,n=globalThis.Deno?globalThis.Deno.args:Fn.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",o=n.indexOf(r+e),t=n.indexOf("--");return o!==-1&&(t===-1||o<t)}var{env:N}=Fn.default,Dn;ue("no-color")||ue("no-colors")||ue("color=false")||ue("color=never")?Dn=0:(ue("color")||ue("colors")||ue("color=true")||ue("color=always"))&&(Dn=1);function va(){if("FORCE_COLOR"in N)return N.FORCE_COLOR==="true"?1:N.FORCE_COLOR==="false"?0:N.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(N.FORCE_COLOR,10),3)}function Sa(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Ea(e,{streamIsTTY:n,sniffFlags:r=!0}={}){let o=va();o!==void 0&&(Dn=o);let t=r?Dn:o;if(t===0)return 0;if(r){if(ue("color=16m")||ue("color=full")||ue("color=truecolor"))return 3;if(ue("color=256"))return 2}if("TF_BUILD"in N&&"AGENT_NAME"in N)return 1;if(e&&!n&&t===void 0)return 0;let i=t||0;if(N.TERM==="dumb")return i;if(Fn.default.platform==="win32"){let s=Mo.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in N)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in N)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in N)||N.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in N)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(N.TEAMCITY_VERSION)?1:0;if(N.COLORTERM==="truecolor"||N.TERM==="xterm-kitty"||N.TERM==="xterm-ghostty"||N.TERM==="wezterm")return 3;if("TERM_PROGRAM"in N){let s=Number.parseInt((N.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(N.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(N.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(N.TERM)||"COLORTERM"in N?1:i}function Lo(e,n={}){let r=Ea(e,{streamIsTTY:e&&e.isTTY,...n});return Sa(r)}var Ta={stdout:Lo({isTTY:xr.default.isatty(1)}),stderr:Lo({isTTY:xr.default.isatty(2)})},No=Ta;function Do(e,n,r){let o=e.indexOf(n);if(o===-1)return e;let t=n.length,i=0,s="";do s+=e.slice(i,o)+n+r,i=o+t,o=e.indexOf(n,i);while(o!==-1);return s+=e.slice(i),s}function Fo(e,n,r,o){let t=0,i="";do{let s=e[o-1]==="\r";i+=e.slice(t,s?o-1:o)+n+(s?`\r
|
|
16
16
|
`:`
|
|
17
17
|
`)+r,t=o+1,o=e.indexOf(`
|
|
18
|
-
`,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:
|
|
19
|
-
`);return i!==-1&&(n=
|
|
20
|
-
`),(0,it.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,it.spawn)(n,[r,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function
|
|
18
|
+
`,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:Uo,stderr:Bo}=No,Rr=Symbol("GENERATOR"),Tt=Symbol("STYLER"),zt=Symbol("IS_EMPTY"),Ho=["ansi","ansi","ansi256","ansi16m"],xt=Object.create(null),xa=(e,n={})=>{if(n.level&&!(Number.isInteger(n.level)&&n.level>=0&&n.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=Uo?Uo.level:0;e.level=n.level===void 0?r:n.level};var Ra=e=>{let n=(...r)=>r.join(" ");return xa(n,e),Object.setPrototypeOf(n,en.prototype),n};function en(e){return Ra(e)}Object.setPrototypeOf(en.prototype,Function.prototype);for(let[e,n]of Object.entries(he))xt[e]={get(){let r=Un(this,Ar(n.open,n.close,this[Tt]),this[zt]);return Object.defineProperty(this,e,{value:r}),r}};xt.visible={get(){let e=Un(this,this[Tt],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var br=(e,n,r,...o)=>e==="rgb"?n==="ansi16m"?he[r].ansi16m(...o):n==="ansi256"?he[r].ansi256(he.rgbToAnsi256(...o)):he[r].ansi(he.rgbToAnsi(...o)):e==="hex"?br("rgb",n,r,...he.hexToRgb(...o)):he[r][e](...o),ba=["rgb","hex","ansi256"];for(let e of ba){xt[e]={get(){let{level:r}=this;return function(...o){let t=Ar(br(e,Ho[r],"color",...o),he.color.close,this[Tt]);return Un(this,t,this[zt])}}};let n="bg"+e[0].toUpperCase()+e.slice(1);xt[n]={get(){let{level:r}=this;return function(...o){let t=Ar(br(e,Ho[r],"bgColor",...o),he.bgColor.close,this[Tt]);return Un(this,t,this[zt])}}}}var Aa=Object.defineProperties(()=>{},{...xt,level:{enumerable:!0,get(){return this[Rr].level},set(e){this[Rr].level=e}}}),Ar=(e,n,r)=>{let o,t;return r===void 0?(o=e,t=n):(o=r.openAll+e,t=n+r.closeAll),{open:e,close:n,openAll:o,closeAll:t,parent:r}},Un=(e,n,r)=>{let o=(...t)=>ka(o,t.length===1?""+t[0]:t.join(" "));return Object.setPrototypeOf(o,Aa),o[Rr]=e,o[Tt]=n,o[zt]=r,o},ka=(e,n)=>{if(e.level<=0||!n)return e[zt]?"":n;let r=e[Tt];if(r===void 0)return n;let{openAll:o,closeAll:t}=r;if(n.includes("\x1B"))for(;r!==void 0;)n=Do(n,r.close,r.open),r=r.parent;let i=n.indexOf(`
|
|
19
|
+
`);return i!==-1&&(n=Fo(n,t,o,i)),o+n+t};Object.defineProperties(en.prototype,xt);var _a=en(),Tl=en({level:Bo?Bo.level:0});var m=_a;var Q=require("fs"),ri=require("url"),nn=require("child_process"),Ie=A(require("path"),1),At=A(require("os"),1);var Rt=A(require("fs"),1),kr=A(require("path"),1),jo=A(require("os"),1),Ko=require("child_process"),Bn=kr.default.join(jo.default.homedir(),".9remote","pids");function Pa(){try{Rt.default.existsSync(Bn)||Rt.default.mkdirSync(Bn,{recursive:!0})}catch{}}function _r(e){return kr.default.join(Bn,`${e}.pid`)}function Be(e,n){if(n)try{Pa(),Rt.default.writeFileSync(_r(e),String(n))}catch{}}function Hn(e){try{let n=Rt.default.readFileSync(_r(e),"utf8").trim(),r=parseInt(n,10);return Number.isFinite(r)&&r>0?r:null}catch{return null}}function He(e){try{Rt.default.unlinkSync(_r(e))}catch{}}function Go(e){if(!e)return!1;try{return process.kill(e,0),!0}catch{return!1}}function Oa(e){let n=Hn(e);if(He(e),!n)return!1;try{process.platform==="win32"?(0,Ko.execSync)(`taskkill /F /T /PID ${n}`,{stdio:"ignore",windowsHide:!0}):process.kill(n,"SIGKILL")}catch{}return!0}var Ia=["cloudflared","agent"];function Wo(){for(let e of Ia)Oa(e)}function Vo(){return Bn}var it=require("child_process"),C=require("fs"),rt=require("path"),Or=A(require("os"),1),ot=A(require("path"),1),qo=require("url");var Kn=(0,rt.join)(re.LOGS,"autostart.log"),jn="cc.9remote.agent",Gn="9Remote",Wn=["--tray","--skip-update","--start"],tn=Or.default.homedir(),Yo=ot.default.dirname((0,qo.fileURLToPath)(__importMetaUrl)),J={darwin:(0,rt.join)(tn,"Library","LaunchAgents",`${jn}.plist`),linux:(0,rt.join)(tn,".config","autostart",`${jn}.desktop`),linuxSystemd:(0,rt.join)(tn,".config","systemd","user",`${jn}.service`),win:(0,rt.join)(process.env.APPDATA||"","Microsoft","Windows","Start Menu","Programs","Startup",`${Gn}.vbs`)};function st(){for(let e=Yo,n=null;e!==n;n=e,e=ot.default.dirname(e)){let r=ot.default.join(e,"package.json");if((0,C.existsSync)(r)){try{let o=JSON.parse((0,C.readFileSync)(r,"utf8"));if(o.name!==ne)continue;let t=typeof o.bin=="string"?o.bin:o.bin?.[ne];if(t){let i=ot.default.resolve(e,t);if((0,C.existsSync)(i))return i}}catch{}break}}return process.argv[1]||ot.default.resolve(Yo,"..","index.js")}function je(){return process.execPath}function Jo(e){let n=je(),r=st();if(process.platform==="win32"){let t=e.join(" "),i=(0,rt.join)(Or.default.tmpdir(),`${ne}-launch.vbs`);return(0,C.writeFileSync)(i,`CreateObject("WScript.Shell").Run """${n}"" ""${r}"" ${t}", 0, False
|
|
20
|
+
`),(0,it.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,it.spawn)(n,[r,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function Qo(){let e=ot.default.dirname(je()),n=["/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin","/opt/homebrew/bin"];return n.includes(e)||n.unshift(e),n.join(":")}function Pr(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $a(e,n){let r=[e,n,...Wn].map(o=>` <string>${Pr(o)}</string>`).join(`
|
|
21
21
|
`);return`<?xml version="1.0" encoding="UTF-8"?>
|
|
22
22
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
23
23
|
<plist version="1.0">
|
|
24
24
|
<dict>
|
|
25
25
|
<key>Label</key>
|
|
26
|
-
<string>${
|
|
26
|
+
<string>${jn}</string>
|
|
27
27
|
<key>ProgramArguments</key>
|
|
28
28
|
<array>
|
|
29
29
|
${r}
|
|
@@ -35,27 +35,27 @@ ${r}
|
|
|
35
35
|
<key>EnvironmentVariables</key>
|
|
36
36
|
<dict>
|
|
37
37
|
<key>PATH</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${Pr(Qo())}</string>
|
|
39
39
|
<key>HOME</key>
|
|
40
|
-
<string>${
|
|
40
|
+
<string>${Pr(tn)}</string>
|
|
41
41
|
</dict>
|
|
42
42
|
<key>StandardOutPath</key>
|
|
43
|
-
<string>${
|
|
43
|
+
<string>${Kn}</string>
|
|
44
44
|
<key>StandardErrorPath</key>
|
|
45
|
-
<string>${
|
|
45
|
+
<string>${Kn}</string>
|
|
46
46
|
</dict>
|
|
47
47
|
</plist>
|
|
48
|
-
`}function
|
|
48
|
+
`}function Ca(){return(0,C.existsSync)(J.darwin)}function La(){let e=Wn.join(" ");return`Set WshShell = CreateObject("WScript.Shell")
|
|
49
49
|
WshShell.Run """${je()}"" ""${st()}"" ${e}", 0, False
|
|
50
|
-
`}function
|
|
50
|
+
`}function Ma(){try{(0,it.execFileSync)("reg",["DELETE","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","/V",Gn,"/F"],{windowsHide:!0,stdio:"ignore"})}catch{}}function Na(){return(0,C.existsSync)(J.win)}function Da(){let e=`${je()} ${st()} ${Wn.join(" ")}`;return`[Desktop Entry]
|
|
51
51
|
Type=Application
|
|
52
|
-
Name=${
|
|
52
|
+
Name=${Gn}
|
|
53
53
|
Exec=${e}
|
|
54
54
|
X-GNOME-Autostart-enabled=true
|
|
55
55
|
NoDisplay=false
|
|
56
56
|
Terminal=false
|
|
57
|
-
`}function
|
|
58
|
-
Description=${
|
|
57
|
+
`}function Fa(){let e=Wn.map(n=>`'${n}'`).join(" ");return`[Unit]
|
|
58
|
+
Description=${Gn} Agent
|
|
59
59
|
After=network-online.target
|
|
60
60
|
Wants=network-online.target
|
|
61
61
|
|
|
@@ -64,14 +64,14 @@ Type=simple
|
|
|
64
64
|
ExecStart=${je()} ${st()} ${e}
|
|
65
65
|
Restart=always
|
|
66
66
|
RestartSec=10
|
|
67
|
-
Environment=PATH=${
|
|
68
|
-
Environment=HOME=${
|
|
69
|
-
StandardOutput=append:${
|
|
70
|
-
StandardError=append:${
|
|
67
|
+
Environment=PATH=${Qo()}
|
|
68
|
+
Environment=HOME=${tn}
|
|
69
|
+
StandardOutput=append:${Kn}
|
|
70
|
+
StandardError=append:${Kn}
|
|
71
71
|
|
|
72
72
|
[Install]
|
|
73
73
|
WantedBy=default.target
|
|
74
|
-
`}function
|
|
74
|
+
`}function Ua(e){try{return(0,it.execFileSync)("systemctl",["--user",...e],{stdio:"ignore"}),!0}catch{return!1}}function Ba(){return(0,C.existsSync)(J.linux)||(0,C.existsSync)(J.linuxSystemd)}async function Ha(){try{if(process.platform==="darwin")return Ca();if(process.platform==="win32")return await Na();if(process.platform==="linux")return Ba()}catch{}return!1}async function Xo(){try{if(process.platform==="win32"&&Ma(),!await Ha())return!1;if(process.platform==="darwin"){let e=$a(je(),st());return((0,C.existsSync)(J.darwin)?(0,C.readFileSync)(J.darwin,"utf8"):"")===e?!1:((0,C.writeFileSync)(J.darwin,e),!0)}if(process.platform==="win32"){let e=La();return((0,C.existsSync)(J.win)?(0,C.readFileSync)(J.win,"utf8"):"")===e?!1:((0,C.writeFileSync)(J.win,e),!0)}if(process.platform==="linux"){if((0,C.existsSync)(J.linuxSystemd)){let e=Fa();return(0,C.readFileSync)(J.linuxSystemd,"utf8")===e?!1:((0,C.writeFileSync)(J.linuxSystemd,e),Ua(["daemon-reload"]),!0)}if((0,C.existsSync)(J.linux)){let e=Da();return(0,C.readFileSync)(J.linux,"utf8")===e?!1:((0,C.writeFileSync)(J.linux,e),!0)}}}catch{}return!1}var D="https://9remote.cc",Zo=3e4,zo=500,Ir=300,ge={cmdMs:1e3,pendingApprovalMs:3e3,statsMs:5e3,serverReadyIntervalMs:200,serverReadyTimeoutMs:5e3,bgServerReadyTimeoutMs:15e3,bgServerReadyIntervalMs:300},Ke={intervalMs:2e3,timeoutMs:18e4,fetchTimeoutMs:5e3,dnsTimeoutMs:2e3,maxLogEntries:80,postReadyHoldMs:2e3},oe={killCloudflaredMs:500,killCloudflaredTuiMs:300,serverBootMs:2e3,trayReadyMs:1e3,postReadyHoldMs:2e3,bgSpawnFlushMs:400},Oe={maxLogLines:200,headerWidth:44},bt={checkIntervalMs:36e5,connectCheckDebounceMs:9e5,maxRetry:3,retryDelayMs:3e3,verifyTimeoutMs:15e3,lockTtlMs:3e5,lockFile:"update.lock"},ei=5e3,ti=2,ni=3e4,fe={orange:m.rgb(230,138,110),orangeDim:m.rgb(200,120,95)};var ja=Ie.default.dirname((0,ri.fileURLToPath)(__importMetaUrl)),oi=3e3;var Yn=2208,$r=Ie.default.join(At.default.homedir(),".9remote","cloudflared.pid");function Ka(){try{Wo()}catch{}try{if((0,Q.existsSync)($r)){let e=parseInt((0,Q.readFileSync)($r,"utf8"));if(Number.isFinite(e))try{process.kill(e)}catch{}try{(0,Q.unlinkSync)($r)}catch{}}}catch{}try{process.platform==="win32"?(0,nn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${Yn}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,nn.execSync)(`lsof -ti:${Yn} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}if(process.platform==="win32"){let e=Date.now()+1500;for(;Date.now()<e;);}}function ii(){return"2.1.2"}function si(e,n){let r=e.split(".").map(Number),o=n.split(".").map(Number);for(let t=0;t<3;t++){if(o[t]>r[t])return!0;if(o[t]<r[t])return!1}return!1}function Ga(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,Q.existsSync)("/.dockerenv")?"Docker":null}function qn(){Ka()}async function ai(){try{let e=ii();if(!e)return null;let n=await G(mr,{signal:AbortSignal.timeout(oi)});if(!n.ok)return null;let{version:r}=await n.json();return r&&si(e,r)?{current:e,latest:r}:null}catch{return null}}var Vn=Ie.default.join(re.STATE,bt.lockFile);function Wa(){try{if((0,Q.existsSync)(Vn)){let{pid:e,ts:n}=JSON.parse((0,Q.readFileSync)(Vn,"utf8")),r=Date.now()-n<bt.lockTtlMs,o=!1;try{process.kill(e,0),o=!0}catch{}if(r&&o)return!1}}catch{}try{(0,Q.writeFileSync)(Vn,JSON.stringify({pid:process.pid,ts:Date.now()}))}catch{}return!0}async function Va(){try{let e=await G(mr,{signal:AbortSignal.timeout(oi)});if(!e.ok)return null;let{version:n}=await e.json();return n||null}catch{return null}}function Ya(){try{if(process.env.NREMOTE_REGISTRY)return`--registry ${new URL(process.env.NREMOTE_REGISTRY).origin}`}catch{}return""}function qa({currentVersion:e,latest:n,agentPid:r}){let o=Vo(),t=Ya(),i=je(),s=st(),a=Vn,c=`--prefer-online --no-audit --no-fund ${t}`.trim();if(process.platform==="win32"){let f=Ie.default.join(At.default.tmpdir(),`${ne}-restart.vbs`),p=`@echo off
|
|
75
75
|
setlocal EnableDelayedExpansion
|
|
76
76
|
set "NODE=${i}"
|
|
77
77
|
set "CLI=${s}"
|
|
@@ -89,7 +89,7 @@ for %%N in (cloudflared agent) do (
|
|
|
89
89
|
del /f /q "${o}\\%%N.pid" >nul 2>&1
|
|
90
90
|
)
|
|
91
91
|
)
|
|
92
|
-
for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${
|
|
92
|
+
for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${Yn}') do taskkill /F /PID %%a >nul 2>&1
|
|
93
93
|
timeout /t 3 /nobreak >nul
|
|
94
94
|
|
|
95
95
|
set ATTEMPT=0
|
|
@@ -123,8 +123,8 @@ del /f /q "${a}" >nul 2>&1
|
|
|
123
123
|
|
|
124
124
|
wscript "${f}"
|
|
125
125
|
exit /b 0
|
|
126
|
-
`,d=
|
|
127
|
-
`);let h=
|
|
126
|
+
`,d=Ie.default.join(At.default.tmpdir(),`${ne}-update.bat`);(0,Q.writeFileSync)(d,p),(0,Q.writeFileSync)(f,'CreateObject("WScript.Shell").Run """%NODE%"" ""%CLI%"" --tray --skip-update --start", 0, False'.replace("%NODE%",i).replace("%CLI%",s)+`
|
|
127
|
+
`);let h=Ie.default.join(At.default.tmpdir(),`${ne}-update.vbs`);return(0,Q.writeFileSync)(h,`CreateObject("WScript.Shell").Run "cmd /c ""${d}""", 0, False
|
|
128
128
|
`),{shellCmd:["wscript.exe",[h]],windowsVerbatim:!1}}let l=`#!/bin/bash
|
|
129
129
|
# Wait for agent to exit so it releases the cli.cjs file lock
|
|
130
130
|
while kill -0 ${r} 2>/dev/null; do sleep 1; done
|
|
@@ -138,7 +138,7 @@ for name in cloudflared agent; do
|
|
|
138
138
|
rm -f "$f"
|
|
139
139
|
fi
|
|
140
140
|
done
|
|
141
|
-
lsof -ti:${
|
|
141
|
+
lsof -ti:${Yn} | xargs kill -9 2>/dev/null || true
|
|
142
142
|
sleep 2
|
|
143
143
|
|
|
144
144
|
attempt=0
|
|
@@ -162,17 +162,17 @@ fi
|
|
|
162
162
|
|
|
163
163
|
rm -f "${a}"
|
|
164
164
|
"${i}" "${s}" --tray --skip-update --start
|
|
165
|
-
`,u=
|
|
166
|
-
`)}function _t(e,n=null){console.log(
|
|
165
|
+
`,u=Ie.default.join(At.default.tmpdir(),`${ne}-update.sh`);return(0,Q.writeFileSync)(u,l,{mode:493}),{shellCmd:["sh",[u]],windowsVerbatim:!1}}async function ci(){let e=ii();if(!e||Ga())return!1;let n=await Va();if(!n||!si(e,n)||!Wa())return!1;let{shellCmd:r,windowsVerbatim:o}=qa({currentVersion:e,latest:n,agentPid:process.pid});return(0,nn.spawn)(r[0],r[1],{detached:!0,stdio:"ignore",windowsHide:!0,windowsVerbatimArguments:o}).unref(),setTimeout(()=>process.exit(0),500),!0}var Ti=A(require("os"),1);var Zn=A(require("readline"),1),fi=A(require("http"),1);var Cr=require("child_process"),Ja={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function Jn(e){let n=Ja[e];n&&process.platform==="darwin"&&(0,Cr.exec)(`open "${n}"`,()=>{})}function ye({strategy:e,baseMs:n,maxMs:r},o){let t=Math.max(1,o),i=e==="exp"?n*Math.pow(2,t-1):n*t;return Math.min(i,r)}async function li({config:e,task:n,label:r="task",log:o=()=>{},ctx:t={}}){let i=0;for(;!t.cancelled;){i++;try{if(await n(i))return!0}catch(a){o(`\u274C ${r} attempt ${i} error: ${a?.message||a}`)}if(t.cancelled)return!1;let s=ye(e,i);o(`\u{1F504} ${r} retry in ${s}ms (attempt ${i})`),await new Promise(a=>setTimeout(a,s))}return!1}var E={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",orange:"\x1B[38;2;230;138;110m",green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",white:"\x1B[37m"},pi=()=>Math.min(44,process.stdout.columns||44);function Mr(e,n=null){let o=pi()-2,t=(a="")=>{let c=a.replace(/\x1b\[[0-9;]*m/g,""),l=Math.max(0,o-c.length);return E.orange+"\u2551"+E.reset+a+" ".repeat(l)+E.orange+"\u2551"+E.reset},i=(a,c=l=>l)=>{let l=a.replace(/\x1b\[[0-9;]*m/g,""),u=Math.floor((o-l.length)/2),f=o-l.length-u;return E.orange+"\u2551"+E.reset+" ".repeat(u)+c(a)+" ".repeat(f)+E.orange+"\u2551"+E.reset},s=["",E.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+E.reset,t(),i(`\u{1F680} 9Remote v${e}`,a=>E.bold+E.orange+a+E.reset),i("Remote terminal access from anywhere",a=>E.dim+a+E.reset),t()];return n&&(s.push(i(`\u2B06 New version v${n} available!`,a=>E.yellow+E.bold+a+E.reset)),s.push(i(`Run: npm i -g ${Pe}`,a=>E.dim+a+E.reset)),s.push(t())),s.push(E.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+E.reset),s.push(""),s.join(`
|
|
166
|
+
`)}function _t(e,n=null){console.log(Mr(e,n))}var ui=["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"],Lr=[{label:"Preparing",desc:"Checking dependencies"},{label:"Connecting",desc:"Creating session"},{label:"Starting tunnel",desc:"Spawning tunnel"},{label:"Verifying tunnel",desc:"Health check"},{label:"Ready",desc:"Tunnel is live"}],Qa=process.platform==="win32",Xa=Qa?120:80;process.on("exit",()=>process.stdout.write("\x1B[?25h"));var di=(e,n)=>{process.stdout.write("\x1B[?25h"),process.listenerCount(e)<=1&&process.exit(n)};process.on("SIGINT",()=>di("SIGINT",130));process.on("SIGTERM",()=>di("SIGTERM",143));var $e=0,at=null,Qn=0,Te=-1,rn=null,kt=null,Xn=!1;function mi(){let e=[],n=Te===Lr.length-1;return Lr.forEach((r,o)=>{let t=o===Te&&rn?rn:r.desc;if(o<Te||n&&o===Te)e.push(` ${E.green}\u2713${E.reset} ${E.dim}${r.label}${E.reset}`),kt&&o===kt.afterIdx&&e.push(` ${E.green}\u2713${E.reset} ${E.cyan}${kt.text}${E.reset}`);else if(o===Te){let i=ui[Qn%ui.length];e.push(` ${E.orange}${i}${E.reset} ${E.bold}${r.label}${E.reset} ${E.dim}${t}${E.reset}`)}else e.push(` ${E.dim}\u25CB ${r.label}${E.reset}`)}),e}function hi(){let e=mi();$e>0&&process.stdout.write(`\x1B[${$e}A\x1B[0J`),process.stdout.write(e.join(`
|
|
167
167
|
`)+`
|
|
168
|
-
`)
|
|
168
|
+
`),$e=e.length}function gi(){if($e===0||Te<0)return;let e=mi();if(e.length!==$e){hi();return}let n=Te+(kt&&kt.afterIdx<Te?1:0),r=$e-n;process.stdout.write(`\x1B[${r}A\r\x1B[2K${e[n]}\x1B[${r}B\r`)}function Za(){Xn||(process.stdout.write("\x1B[?25l"),Xn=!0)}function yi(){Xn&&(process.stdout.write("\x1B[?25h"),Xn=!1)}function wi(e,n=!1,r=null){at&&(clearInterval(at),at=null),Te=e,rn=r,Qn=0,n||($e=0),hi(),e<Lr.length-1?(Za(),at=setInterval(()=>{Qn++,gi()},Xa)):yi()}function Pt(e){rn=e,$e>0&&gi()}function vi(){at&&(clearInterval(at),at=null),yi(),$e=0,Te=-1,rn=null,kt=null,Qn=0}function xe(e,n,r=0,o="",t=null,i=null){return new Promise(s=>{let a=r,c=!0,l=!0,u=process.platform==="win32",f=()=>{if(!c)return;process.stdout.write(l?"\x1B[2J\x1B[H":"\x1B[H"),l=!1;let w=typeof o=="function"?o():o;if(w)for(let T of w.split(`
|
|
169
169
|
`))process.stdout.write(T+`\x1B[K
|
|
170
170
|
`);e&&process.stdout.write(`${E.dim}${e}${E.reset}\x1B[K
|
|
171
171
|
\x1B[K
|
|
172
172
|
`),n.forEach((T,P)=>{let x=P===a?u?">":"\u2605":u?" ":"\u2606",b=P===a?` \x1B[7m${E.bold}${x} ${T.label}${E.reset}`:` ${x} ${T.label}`;process.stdout.write(b+`\x1B[K
|
|
173
|
-
`)}),process.stdout.write("\x1B[J")},p=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",d),process.stdin.pause()}},d=(
|
|
173
|
+
`)}),process.stdout.write("\x1B[J")},p=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",d),process.stdin.pause()}},d=(w,T)=>{!c||!T||(T.name==="up"?(a=(a-1+n.length)%n.length,f()):T.name==="down"?(a=(a+1)%n.length,f()):T.name==="return"?(p(),s(a)):T.name==="escape"?(p(),s(-1)):T.ctrl&&T.name==="c"&&(p(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),Zn.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{s(-1);return}process.stdin.on("keypress",d),process.stdin.resume(),f(),t&&t(f,()=>{c&&(p(),s(-2))})})}function Nr(e){return new Promise(n=>{if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}if(process.stdin.pause(),process.stdout.write(`${e} (y/N): `),Zn.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let r=(o,t)=>{if(!t)return;if(process.stdin.removeListener("keypress",r),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),t.ctrl&&t.name==="c"&&(process.stdout.write(`
|
|
174
174
|
`),process.exit(0));let i=(t.name||"").toLowerCase()==="y";process.stdout.write((i?"y":"n")+`
|
|
175
|
-
`),n(i)};process.stdin.on("keypress",r)})}function
|
|
175
|
+
`),n(i)};process.stdin.on("keypress",r)})}function Si(e,n){return new Promise(r=>{let o=e?e.slice(0,8):"unknown",t=pi(),i=process.stdin.listeners("keypress").slice();if(process.stdin.removeAllListeners("keypress"),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause();let s=`${E.orange}${"\u2550".repeat(t)}${E.reset}`;if(process.stdout.write(`\x1B[2J\x1B[H
|
|
176
176
|
${s}
|
|
177
177
|
${E.orange}${E.bold} \u{1F514} New Device Connection${E.reset}
|
|
178
178
|
${s}
|
|
@@ -180,49 +180,49 @@ ${s}
|
|
|
180
180
|
IP: ${E.cyan}${n}${E.reset}
|
|
181
181
|
${s}
|
|
182
182
|
|
|
183
|
-
Allow this device? ${E.dim}(y/n)${E.reset} `),
|
|
183
|
+
Allow this device? ${E.dim}(y/n)${E.reset} `),Zn.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume();let a=()=>{for(let l of i)process.stdin.on("keypress",l);if(i.length>0){if(process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{}process.stdin.resume()}},c=(l,u)=>{if(!u)return;let f=(u.name||"").toLowerCase(),p=f==="y"||u.name==="return",d=f==="n"||u.name==="escape",h=u.ctrl&&u.name==="c";if(!p&&!d&&!h)return;try{if(process.stdin.removeListener("keypress",c),process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause()}catch{}h&&process.exit(0);let w=p,T=w?`${E.green}y${E.reset}
|
|
184
184
|
|
|
185
185
|
${E.green}\u2713 Device approved${E.reset}
|
|
186
186
|
`:`${E.red}n${E.reset}
|
|
187
187
|
|
|
188
188
|
${E.red}\u2717 Device rejected${E.reset}
|
|
189
|
-
`;process.stdout.write(T),setTimeout(()=>{try{a()}catch{}r(
|
|
190
|
-
`);
|
|
191
|
-
`).find(c=>c.includes(r));if(!t){X.warn(`\u26A0\uFE0F No sha256 entry for ${r}, skipping verify`);return}let i=t.trim().split(/\s+/)[0],{createHash:s}=await import("crypto"),a=s("sha256").update(B.default.readFileSync(n)).digest("hex");if(a!==i)throw new Error(`Integrity check failed: SHA256 mismatch (expected ${i}, got ${a})`);X.info("\u2713 cloudflared SHA256 verified")}function
|
|
192
|
-
`,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{B.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,ut.spawn)(o,["tunnel","--url",`http://localhost:${e}`,"--config",i,"--no-autoupdate","--protocol","http2"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return Be("cloudflared",c.pid),lt=!1,new Promise((l,u)=>{let f=!1,p=null,d="",h=setTimeout(()=>{f||(f=!0,a(),u(new Error("Quick tunnel timed out after 90s")))},9e4),
|
|
193
|
-
`).slice(-5).join(" | ");u(new Error(`cloudflared exited (code=${T}, signal=${P}) output: ${x||"(empty)"}`)),lt||
|
|
194
|
-
`).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(n))
|
|
195
|
-
${n}`)),
|
|
196
|
-
`+r.trim())})})}async function
|
|
189
|
+
`;process.stdout.write(T),setTimeout(()=>{try{a()}catch{}r(w)},500)};process.stdin.on("keypress",c)})}function Ei(e,n){let r=null,o=!1,t=null,i=45e3,s=()=>{t&&clearTimeout(t),t=setTimeout(()=>{try{r?.destroy()}catch{}},i)},a=async()=>{if(o)return;let c=await Ot();r=fi.default.get(`http://${c}:${e}/api/ui/events`,l=>{let u="";s(),l.on("data",f=>{s(),u+=f.toString();let p=u.split(`
|
|
190
|
+
`);u=p.pop();let d="";for(let h of p)if(h.startsWith("data: "))d=h.slice(6);else if(h===""&&d){try{let w=JSON.parse(d);n(w.type,w)}catch{}d=""}}),l.on("end",()=>{t&&clearTimeout(t),o||setTimeout(a,ye(le.sse,1))})}),r.on("error",()=>{t&&clearTimeout(t),o||setTimeout(a,ye(le.sse,1))})};return a(),()=>{o=!0,t&&clearTimeout(t),r?.destroy()}}var Dr=!1;function xi(e){Dr=e}var on=null;async function Ot(){if(on)return on;let e=o=>fetch(`http://${o}:${O}/api/health`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?o:Promise.reject()),r=(await Promise.allSettled(["localhost","127.0.0.1"].map(e))).map((o,t)=>o.status==="fulfilled"?["localhost","127.0.0.1"][t]:null);return on=r.find(o=>o==="localhost")||r.find(Boolean)||null,on||"127.0.0.1"}function Ri(){on=null}async function Z(e,n){let r=await Ot();try{return await fetch(`http://${r}:${O}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{return Ri(),null}}async function W(e){let n=await Ot();try{let r=await fetch(`http://${n}:${O}${e}`);return r.ok?await r.json():null}catch{return Ri(),null}}async function U(e){await Z("/api/ui/state",e)}async function K(e,n={}){Dr&&wi(e-1,e>$.PREPARING),await U({step:e,stepDesc:"",...n})}function zn({phase:e,percent:n}){let r=e==="download"?`Downloading tunnel binary ${n??0}%`:"Extracting tunnel binary";Dr&&Pt(r),U({stepDesc:r})}async function ie(){return!!await W("/api/health")}async function Fr(){let[e,n,r,o]=await Promise.all([W("/api/ui/state"),W("/api/device/auto-approve"),W("/api/autostart"),W("/api/sleep-inhibit")]);return{desktopEnabled:!!e?.desktopEnabled,remoteAvailable:!!e?.remoteAvailable,autoApprove:!!n?.enabled,autoStart:!!r?.enabled,sleepInhibitMode:o?.mode||"never",sleepInhibitActive:!!o?.active,sleepInhibitPresets:Array.isArray(o?.presets)?o.presets:[]}}function bi(){let e=Ti.default.networkInterfaces();for(let n of Object.values(e))for(let r of n)if(r.family==="IPv4"&&!r.internal)return r.address;return null}var Sn=require("child_process"),En=A(require("path"),1),Qr=A(require("fs"),1),ts=require("url");var B=A(require("fs"),1),We=A(require("path"),1),Yr=A(require("https"),1),Ve=A(require("os"),1),Ni=A(require("net"),1),ut=require("child_process");var Ai=A(require("dns"),1),ki=require("child_process");var za=2e3,ec=5e3,_i=new Ai.default.promises.Resolver;_i.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);function It(){process.platform==="win32"&&(0,ki.execFile)("ipconfig",["/flushdns"],{windowsHide:!0},()=>{})}async function Ur(e,n=za){let r=Date.now();try{return{ok:!0,addrs:await Promise.race([_i.resolve4(e),new Promise((t,i)=>setTimeout(()=>i(Object.assign(new Error("DNS timeout"),{code:"ETIMEOUT"})),n))]),elapsedMs:Date.now()-r}}catch(o){return{ok:!1,code:o.code||o.message,elapsedMs:Date.now()-r}}}async function er(e,{flushDns:n=!1}={}){let r=Date.now(),o=null;try{o=new URL(e).hostname}catch{}if(n&&It(),o){let t=await Ur(o);if(!t.ok)return It(),{ok:!1,dnsCode:t.code,elapsedMs:Date.now()-r}}try{let t=await G(`${e}/api/health`,{signal:AbortSignal.timeout(ec)});return{ok:t.ok,httpStatus:t.status,elapsedMs:Date.now()-r}}catch(t){return{ok:!1,dnsCode:t.cause?.code||t.code||t.message,elapsedMs:Date.now()-r}}}var tc=q("tunnel"),sn=null,an=null,$t=null,ct=null,Ge=0,Br=!1;async function Hr(e){try{let n=await Ot();await fetch(`http://${n}:${O}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch{}}async function Pi(){if(!an||Br)return;let e=await er(an),n=e.ok?"healthy":"unreachable";if(n===$t){ct=null,Ge=0;return}if(n!==ct){ct=n,Ge=1;return}Ge++,!(Ge<ti)&&(tc.info(`\u{1FA7A} ${$t??"init"} \u2192 ${n}${e.ok?"":` (http=${e.httpStatus??"-"} dns=${e.dnsCode??"-"})`}`),$t=n,ct=null,Ge=0,await Hr({tunnelHealth:{status:n,checkedAt:Date.now()}}))}function Oi(e){if(!e)return ln();e!==an&&(an=e,$t=null,ct=null,Ge=0,It(),sn||(sn=setInterval(Pi,ho.checkIntervalMs)),Pi())}var Ii=Oi,Ct=Oi;function $i(){Br=!0}function Ci(){Br=!1}function cn(e){$t=e,ct=null,Ge=0,Hr({tunnelHealth:{status:e,checkedAt:Date.now()}})}function ln(){sn&&(clearInterval(sn),sn=null),an=null,$t=null,ct=null,Ge=0,Hr({tunnelHealth:{status:"unknown",checkedAt:null}})}var X=q("tunnel"),pn={networkCheckIntervalMs:5e3,networkRestoreDelayMs:2500,internetCheckTimeoutMs:3e3,internetCheckHost:"1.1.1.1",internetCheckPort:443},dn=null,tr=null,nr=null,mn=null,Mt=!1,un=0,Wr=!1,hn=null,rr=0,jr=0,Kr=!1,nc=3e4,rc=5e3,fn=We.default.join(Ve.default.homedir(),".9remote","bin"),Li="cloudflared",gn=Ve.default.platform()==="win32",oc=gn?`${Li}.exe`:Li,Lt=We.default.join(fn,oc),Gr=We.default.join(Ve.default.homedir(),".9remote","cloudflared.pid"),lt=!1,ic="2026.6.1",Di=`https://github.com/cloudflare/cloudflared/releases/download/${ic}`;function Fi(){return new Promise(e=>{let n=new Ni.default.Socket,r=!1,o=t=>{if(!r){r=!0;try{n.destroy()}catch{}e(t)}};n.setTimeout(pn.internetCheckTimeoutMs),n.once("connect",()=>o(!0)),n.once("timeout",()=>o(!1)),n.once("error",()=>o(!1));try{n.connect(pn.internetCheckPort,pn.internetCheckHost)}catch{o(!1)}})}async function sc(){Wr=!0;try{let e=0;for(;;){if(e++,await Fi())return;await new Promise(n=>setTimeout(n,ye(le.internet,e)))}}finally{Wr=!1}}async function or(e,n){if(!mn){X.warn("\u26A0\uFE0F No restartCallback registered \u2014 skip");return}if(Mt){X.info(`\u23ED restart already in flight, skip (${n})`);return}if(Date.now()-jr<rc){X.info(`\u23ED restart debounced, skip (${n})`);return}jr=Date.now(),Mt=!0;try{await sc();let r=ye(le.tunnelRestart,un+1);await new Promise(o=>setTimeout(o,r)),await mn(e),un=0,jr=0}catch(r){un++,X.error(`\u274C restart failed (#${un}): ${r?.message||r}`),setImmediate(()=>{Mt=!1,or(e,"retry after fail")});return}finally{Mt=!1}}var ac={darwin:{x64:"cloudflared-darwin-amd64.tgz",arm64:"cloudflared-darwin-arm64.tgz"},win32:{x64:"cloudflared-windows-amd64.exe"},linux:{x64:"cloudflared-linux-amd64",arm64:"cloudflared-linux-arm64"}};function cc(){let e=Ve.default.platform(),n=Ve.default.arch(),r=ac[e];if(!r)throw new Error(`Unsupported platform: ${e}`);let o=r[n];if(!o)throw new Error(`Unsupported architecture: ${n} for platform ${e}`);return`${Di}/${o}`}var lc=150;async function Ui(e,n,r){return new Promise((o,t)=>{let i=B.default.createWriteStream(n);Yr.default.get(e,s=>{if([301,302].includes(s.statusCode)){i.close(),B.default.unlinkSync(n),Ui(s.headers.location,n,r).then(o).catch(t);return}if(s.statusCode!==200){i.close(),B.default.unlinkSync(n),t(new Error(`Download failed with status ${s.statusCode}`));return}let a=parseInt(s.headers["content-length"]||"0",10),c=0,l=0,u=-1;s.on("data",f=>{if(c+=f.length,!r||!a)return;let p=Date.now(),d=Math.min(100,Math.floor(c/a*100));d!==u&&p-l>=lc&&(l=p,u=d,r(d))}),s.pipe(i),i.on("finish",()=>{r&&a&&r(100),i.close(()=>o(n))}),i.on("error",f=>{i.close(),B.default.unlinkSync(n),t(f)})}).on("error",s=>{i.close(),B.default.existsSync(n)&&B.default.unlinkSync(n),t(s)})})}async function yn(e){if(B.default.existsSync(fn)||B.default.mkdirSync(fn,{recursive:!0}),B.default.existsSync(Lt))return gn||B.default.chmodSync(Lt,"755"),Lt;let n=cc(),r=n.endsWith(".tgz"),o=r?We.default.join(fn,"cloudflared.tgz"):Lt;try{return e?.({phase:"download",percent:0}),await Ui(n,o,t=>{e?.({phase:"download",percent:t})}),await uc(n,o),r&&(e?.({phase:"extract"}),(0,ut.execSync)(`tar -xzf "${o}" -C "${fn}"`,{stdio:"pipe",windowsHide:!0}),B.default.unlinkSync(o)),gn||B.default.chmodSync(Lt,"755"),Lt}catch(t){try{B.default.existsSync(o)&&B.default.unlinkSync(o)}catch{}throw console.error("\u274C Failed to download cloudflared:",t.message),t}}function Bi(e){return new Promise((n,r)=>{Yr.default.get(e,o=>{if([301,302].includes(o.statusCode))return Bi(o.headers.location).then(n).catch(r);if(o.statusCode!==200)return r(new Error(`HTTP ${o.statusCode}`));let t="";o.on("data",i=>t+=i),o.on("end",()=>n(t))}).on("error",r)})}async function uc(e,n){let r=We.default.basename(e),o;try{o=await Bi(`${Di}/sha256sum.txt`)}catch(c){X.warn(`\u26A0\uFE0F sha256 manifest unavailable (${c.message}), skipping verify`);return}let t=o.split(`
|
|
191
|
+
`).find(c=>c.includes(r));if(!t){X.warn(`\u26A0\uFE0F No sha256 entry for ${r}, skipping verify`);return}let i=t.trim().split(/\s+/)[0],{createHash:s}=await import("crypto"),a=s("sha256").update(B.default.readFileSync(n)).digest("hex");if(a!==i)throw new Error(`Integrity check failed: SHA256 mismatch (expected ${i}, got ${a})`);X.info("\u2713 cloudflared SHA256 verified")}function fc(e){let n=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,r=[];for(let o of e.matchAll(n))o[1]!=="api"&&r.push(`https://${o[1]}.trycloudflare.com`);return r.length?r[r.length-1]:null}async function Hi(e,n=null,r=null){let o=await yn();r&&(mn=r),nr=e;let t=B.default.mkdtempSync(We.default.join(Ve.default.tmpdir(),"9remote-quick-")),i=We.default.join(t,"config.yml");B.default.writeFileSync(i,`# quick-tunnel
|
|
192
|
+
`,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{B.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,ut.spawn)(o,["tunnel","--url",`http://localhost:${e}`,"--config",i,"--no-autoupdate","--protocol","http2"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return Be("cloudflared",c.pid),lt=!1,new Promise((l,u)=>{let f=!1,p=null,d="",h=setTimeout(()=>{f||(f=!0,a(),u(new Error("Quick tunnel timed out after 90s")))},9e4),w=T=>{let P=T.toString();d+=P,d.length>4096&&(d=d.slice(-4096));let x=fc(P);if(x){if(!f){f=!0,p=x,hn=x,rr=Date.now(),clearTimeout(h),a(),mc(),X.info(`\u2705 tunnel ready: ${x}`),l({child:c,tunnelUrl:x});return}x!==p&&(X.info(`\u{1F504} URL rotated: ${x}`),p=x,hn=x,rr=Date.now(),n?.(x))}};c.stdout.on("data",w),c.stderr.on("data",w),c.on("error",T=>{f||(f=!0,clearTimeout(h),a(),u(T))}),c.on("exit",(T,P)=>{if(a(),X.info(`\u{1F4A5} cloudflared exit pid=${c.pid} code=${T} signal=${P} intentional=${lt}`),lt||cn("unreachable"),!f){f=!0,clearTimeout(h);let x=d.trim().split(`
|
|
193
|
+
`).slice(-5).join(" | ");u(new Error(`cloudflared exited (code=${T}, signal=${P}) output: ${x||"(empty)"}`)),lt||or(e,`initial spawn failed (code ${T})`);return}lt||or(e,`quick tunnel exit code ${T}`)})})}function Vr(e){if(gn)try{(0,ut.execSync)(`taskkill /PID ${e} /T /F`,{windowsHide:!0,stdio:"ignore"})}catch{}else try{process.kill(e,"SIGKILL")}catch{}}function pc(e){try{let n=[];if(gn){let r=`Get-NetTCPConnection -LocalPort ${e} -State Established -ErrorAction SilentlyContinue | Where-Object { (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).Name -eq 'cloudflared' } | Select-Object -ExpandProperty OwningProcess -Unique`;n=(0,ut.execSync)(`powershell -NoProfile -Command "${r}"`,{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).map(t=>+t.trim()).filter(Boolean)}else n=(0,ut.execSync)(`lsof -nP -iTCP:${e} -sTCP:ESTABLISHED 2>/dev/null | awk '/cloudflar/ {print $2}' | sort -u`,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
194
|
+
`).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(n))Vr(r),X.info(`\u2705 killed orphan cloudflared pid=${r}`)}catch{}}function ft(){if(!Kr){Kr=!0;try{try{if(B.default.existsSync(Gr)){let n=parseInt(B.default.readFileSync(Gr,"utf8"));Number.isFinite(n)&&(lt=!0,Vr(n)),B.default.unlinkSync(Gr)}}catch{}let e=Hn("cloudflared");lt=!0,e&&(Vr(e),X.info("\u2705 Cloudflared killed"),He("cloudflared")),pc(O)}finally{setTimeout(()=>{Kr=!1},2e3)}}}function ji(){un=0,Mt=!1,mn=null,nr=null,hn=null,hc()}var dc=/^(utun|awdl|llw|anpi|bridge|gif|stf|ipsec|ap|tun|tap|vmnet|veth|docker)/i;function Mi(){let e=Ve.default.networkInterfaces(),n=[];for(let[r,o]of Object.entries(e))if(o&&!dc.test(r))for(let t of o)!t.internal&&t.family==="IPv4"&&n.push(`${r}:${t.address}`);return n.sort().join("|")}function mc(){dn||(tr=Mi(),dn=setInterval(async()=>{if(Wr||Mt||!mn||nr==null)return;let e=Mi(),n=e!==tr;tr=e;let r=Hn("cloudflared"),o=!r||!Go(r);if(!(!n&&!o)){if(n&&!o&&rr&&Date.now()-rr<nc){X.info("\u23F8 Network change in cooldown, skip");return}if(n&&X.info("\u{1F504} Network change detected"),o&&X.info("\u{1F50D} Liveness watchdog: cloudflared not alive"),cn("unreachable"),await new Promise(t=>setTimeout(t,pn.networkRestoreDelayMs)),!!await Fi()){if(n&&!o&&hn){let t=!1;for(let i=0;i<2;i++){if((await er(hn)).ok){t=!0;break}i===0&&await new Promise(a=>setTimeout(a,2e3))}if(t){X.info("\u2705 Tunnel survived network change, skip restart");return}}n&&!o&&ft(),or(nr,n?"network change":"liveness watchdog")}}},pn.networkCheckIntervalMs))}function hc(){dn&&(clearInterval(dn),dn=null),tr=null}Ft();var Le=q("server"),ns=En.default.dirname((0,ts.fileURLToPath)(__importMetaUrl)),Ec=En.default.resolve(ns,"./server.cjs"),zi=En.default.resolve(ns,"../../index.js");function ar(e){try{process.platform==="win32"?(0,Sn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${e}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,Sn.execSync)(`lsof -ti:${e} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function Ye(e,n,r){let o=null,t=!1,i=!0,s=0,a=null,c=()=>{i&&(ar(O),i=!1);let l=process.env.NODE_ENV==="development"&&Qr.default.existsSync(zi),u=l?zi:Ec;Qr.default.existsSync(u)||(Le.error(`\u274C Server not found: ${u}`),process.exit(1));let f={...process.env,PORT:String(O)};l||delete f.NODE_ENV,o=(0,Sn.spawn)("node",[u],{cwd:En.default.dirname(u),stdio:["ignore","inherit","inherit"],detached:!1,windowsHide:!0,env:f}),a&&clearTimeout(a),a=setTimeout(()=>{s=0},Zo),o.on("exit",(p,d)=>{if(a&&(clearTimeout(a),a=null),t)return;Le.error(`\u{1F4A5} Server exited unexpectedly (code: ${p}, signal: ${d})`),s++;let h=ye(le.server,s);Le.warn(`\u{1F504} Restarting server in ${h}ms (fail#${s})`),n&&(Le.info("\u2705 Restarting tunnel connection..."),n()),setTimeout(()=>{c(),r?.()},h)}),o.on("error",p=>{Le.error(`\u274C Server error: ${p.message}`)}),e?.(o)};return c(),{getProcess:()=>o,shutdown:()=>{if(t=!0,!!o){try{o.kill("SIGTERM")}catch{}setTimeout(()=>{try{o&&o.kill("SIGKILL")}catch{}},2e3)}}}}function pt({serverManager:e,tunnelProcess:n,exit:r=!0,code:o=0}={}){try{ln()}catch{}try{e?.shutdown?.()}catch{}try{n?.kill?.()}catch{}try{ft()}catch{}try{wn()}catch{}try{ar(O)}catch{}try{ji()}catch{}try{Eo()}catch{}try{He("agent")}catch{}try{He("cloudflared")}catch{}r&&setTimeout(()=>process.exit(o),zo)}var es=!1;function qe(e,n){if(es)return;es=!0;let r=!1,o=t=>{r||(r=!0,Le.info(`\u{1F6D1} Stopping 9Remote (${t})...`),pt({serverManager:e,tunnelProcess:n}),Le.info("\u2705 Server stopped"))};if(process.on("SIGINT",()=>o("SIGINT")),process.on("SIGTERM",()=>o("SIGTERM")),process.on("SIGHUP",()=>o("SIGHUP")),process.platform==="win32"){process.on("SIGBREAK",()=>o("SIGBREAK"));try{import("readline").then(({createInterface:t})=>{t({input:process.stdin,output:process.stdout}).on("SIGINT",()=>o("SIGINT")),process.stdin.isTTY&&process.stdin.unref?.()}).catch(()=>{})}catch{}}process.on("uncaughtException",t=>{Le.error(`Uncaught exception: ${t?.stack||t?.message||t}`),o("uncaughtException"),setTimeout(()=>process.exit(1),Ir)}),process.on("unhandledRejection",t=>{Le.error(`Unhandled rejection: ${t?.stack||t?.message||t}`),o("unhandledRejection"),setTimeout(()=>process.exit(1),Ir)})}Ft();var Xr=q("tunnel");async function dt(e,n,r){let o=0;for(;;){o++;try{return await Hi(e,n,r)}catch(t){let i=ye(le.tunnelSpawn,o);Xr.warn(`\u26A0\uFE0F spawn attempt ${o} failed: ${t?.message||t} \u2014 retry in ${i}ms`),await new Promise(s=>setTimeout(s,i))}}}function Ut({onUrlUpdate:e,setTunnel:n}){return async r=>{try{let o=await dt(r,e);n(o.child),await e(o.tunnelUrl),Xr.info(`\u2705 Tunnel restarted: ${o.tunnelUrl}`)}catch(o){Xr.error(`\u274C Tunnel restart failed: ${o?.message||o}`)}}}async function Je(e,n={}){let r=n.intervalMs??Ke.intervalMs,o=n.timeoutMs??Ke.timeoutMs,t=`${e}/api/health`,i=(()=>{try{return new URL(e).hostname}catch{return null}})(),s=Date.now(),a=0,c=[];await U({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:[]}});let l=u=>{c.push(u);let f=c.length>Ke.maxLogEntries?c.slice(-Ke.maxLogEntries):c;U({healthCheck:{running:!0,timeoutMs:o,startedAt:s,logs:f}})};for(;Date.now()-s<o;){if(a++,It(),i){let f=await Ur(i,Ke.dnsTimeoutMs);if(!f.ok){let p=f.code==="ENOTFOUND"||f.code==="ETIMEOUT"||f.code==="ESERVFAIL",d=p?"connecting...":f.code;Pt(`#${a} \u2192 ${d}`),l({attempt:a,status:d,elapsedMs:f.elapsedMs,ok:!1,waiting:p,time:Date.now()}),await new Promise(h=>setTimeout(h,r));continue}}let u=Date.now();try{let f=await G(t,{signal:AbortSignal.timeout(Ke.fetchTimeoutMs)}),p=Date.now()-u;if(Pt(`#${a} \u2192 ${f.status}`),l({attempt:a,status:String(f.status),elapsedMs:p,ok:f.ok,time:Date.now()}),f.ok)return await U({healthCheck:{running:!1,timeoutMs:0,startedAt:null,logs:[]}}),await new Promise(d=>setTimeout(d,Ke.postReadyHoldMs)),!0}catch(f){let p=Date.now()-u,d=f.cause?.code||f.code||f.message,h=d==="ENOTFOUND",w=h?"connecting...":d;Pt(`#${a} \u2192 ${w}`),l({attempt:a,status:w,elapsedMs:p,ok:!1,waiting:h,time:Date.now()})}await new Promise(f=>setTimeout(f,r))}return await U({healthCheck:{running:!1,timeoutMs:o,startedAt:s,logs:c}}),!1}var xn=q("tunnel"),Zr=null,rs=null,os=0;async function Me(e,n){if(n&&n===rs&&Date.now()-os<ei){xn.info(`\u23ED urlSync debounced (same URL): ${n}`);return}Zr&&(Zr.cancelled=!0);let r={cancelled:!1};Zr=r;let o=bi();li({config:le.urlSync,label:`urlSync ${n}`,log:t=>xn.warn(t),ctx:r,task:async()=>{let t=await G(`${D}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e,tunnelUrl:n,localIp:o?`${o}:${O}`:null})});if(r.cancelled)return!0;if(t.ok)return rs=n,os=Date.now(),xn.info("\u2705 urlSync ok"),Tc(n),!0;let i=await t.text().catch(()=>"");return xn.warn(`\u26A0\uFE0F urlSync HTTP ${t.status}: ${i.slice(0,200)}`),!1}}),n&&Ii(n)}var Tn=null;async function Tc(e){if(Tn?.url===e)return;let n={url:e};Tn=n,$i();try{let r=await Je(e,{timeoutMs:ni});if(Tn!==n)return;r&&(cn("healthy"),xn.info("\u2705 fast probe healthy"))}catch{}finally{Tn===n&&(Tn=null),Ci()}}var oo=A(_s(),1);var Ic=30;async function Bt(e,n){try{let r=await G(`${n}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e,expiryMinutes:Ic})});if(!r.ok){let o=await r.json();throw new Error(o.error||"Failed to create temp key")}return await r.json()}catch(r){return console.error("Error creating temp key:",r),null}}function $c(e,n="\u{1F4F1} Scan QR to connect:"){console.log(fe.orange(`
|
|
195
|
+
${n}`)),oo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{console.log(r.trim())})}function Cc(e){return new Promise(n=>{oo.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{n(fe.orangeDim("\u{1F4F1} Scan QR to connect:")+`
|
|
196
|
+
`+r.trim())})})}async function fr(e,n){let r=await Bt(e,D);if(!r){console.log(m.red("\u274C Failed to create temp key"));return}let o=`${D}/login?k=${r.tempKey}`,t=Math.min(Oe.headerWidth,process.stdout.columns||55);await K($.READY,{tunnelUrl:n,oneTimeKey:r.tempKey,oneTimeKeyExpiresAt:r.expiresAt,permanentKey:e,qrUrl:o,workerUrl:D}),$c(o),console.log(m.gray(`
|
|
197
197
|
QR will expire in 30 minutes (one-time use)
|
|
198
|
-
`)),console.log(fe.orange("\u2550".repeat(t))),console.log(m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),console.log(m.white("One-Time Key".padEnd(14))+fe.orange.bold(r.tempKey)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(fe.orange("\u2550".repeat(t)))}async function
|
|
198
|
+
`)),console.log(fe.orange("\u2550".repeat(t))),console.log(m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),console.log(m.white("One-Time Key".padEnd(14))+fe.orange.bold(r.tempKey)),console.log(m.white("Key".padEnd(14))+m.gray(e)),console.log(fe.orange("\u2550".repeat(t)))}async function Rn(e,n,r,o=""){let t=Math.min(Oe.headerWidth,process.stdout.columns||Oe.headerWidth),i=[];return e&&r?(i.push(await Cc(r)),i.push(m.gray(`
|
|
199
199
|
QR expires in 30 minutes (one-time use)
|
|
200
200
|
`))):i.push(m.gray(`
|
|
201
201
|
(One-time key used \u2014 generate a new one from menu)
|
|
202
|
-
`)),i.push(fe.orange("\u2550".repeat(t)),m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),
|
|
203
|
-
`)}var ht=q("cmd");function Ze(e,n,r){let o=!1;setInterval(async()=>{if(o)return;let t=
|
|
204
|
-
\u{1F310} UI ready at ${i}`));let s=null;await U({permanentKey:e.key,step
|
|
202
|
+
`)),i.push(fe.orange("\u2550".repeat(t)),m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),po.showTunnelUrlInMenu&&i.push(m.white("Tunnel".padEnd(14))+(o?m.cyan(o):m.gray("\u2014"))),i.push(m.white("One-Time Key".padEnd(14))+(e?fe.orange.bold(e)+m.dim(" (expires in 30m)"):m.gray("\u2014")),m.white("Key".padEnd(14))+m.dim(n),fe.orange("\u2550".repeat(t))),i.join(`
|
|
203
|
+
`)}var ht=q("cmd");function Ze(e,n,r){let o=!1;setInterval(async()=>{if(o)return;let t=To();if(t){o=!0;try{if(t==="stop-tunnel")await Ps(e,n);else if(t==="restart-tunnel")await Ps(e,n),await Os(e,n,r);else if(t==="start-tunnel"){if(await Os(e,n,r)==="alreadyRunning"){o=!1;return}}else t==="regenerate-key"?await Lc():t==="shutdown"?Mc(e,n):t==="update"&&await ci()}finally{o=!1}}},ge.cmdMs)}async function Ps(e,n){ln();let r=e();r&&(r.kill(),n(null),ht.info("\u{1F6D1} Tunnel stopped")),await K($.STOPPED,{tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null}),sr({tunnelUrl:"",running:!0})}async function Os(e,n,r){let o=e();if(o)if(o.killed||o.exitCode!=null)n(null);else{let t=await W("/api/ui/state");return await K($.READY,{tunnelUrl:t?.tunnelUrl||""}),"alreadyRunning"}ht.info("\u{1F680} Starting tunnel...");try{await K($.PREPARING),await yn(zn),await K($.CONNECTING);let t=await G(`${D}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r})});if(!t.ok)throw new Error(`Session create failed: ${t.status}`);await K($.TUNNELING);let i=async c=>{await Me(r,c),await U({tunnelUrl:c}),Ct(c)},s=await dt(O,i,Ut({onUrlUpdate:i,setTunnel:c=>n(c)}));n(s.child),await K($.VERIFYING),await Je(s.tunnelUrl)||ht.warn("\u26A0\uFE0F Tunnel health check timed out, proceeding anyway..."),await Me(r,s.tunnelUrl),sr({tunnelUrl:s.tunnelUrl,running:!0}),await new Promise(c=>setTimeout(c,oe.postReadyHoldMs)),await fr(r,s.tunnelUrl)}catch(t){ht.error(`\u274C Failed to start tunnel: ${t.message}`),await K($.STOPPED)}}async function Lc(){let e=await vt(),{key:n}=St(e),r=Ln();nt(e,n,r?.name||"Default"),await U({permanentKey:n}),ht.info(`\u2705 Key regenerated: ${On(n)}`)}function Mc(e,n){ht.info("\u{1F6D1} Shutting down 9Remote completely...");let r=e();n(null),pt({tunnelProcess:r}),ht.info("\u2705 9Remote stopped")}async function Is(){Be("agent",process.pid),_t(Se());let e=await Ue(),n=process.argv.find(a=>a.startsWith("--theme=")),r=n?n.split("=")[1]:null,o=await ie(),t=o?{getProcess:()=>null,shutdown:()=>{}}:Ye(null,null);o||await new Promise(a=>setTimeout(a,oe.serverBootMs));let i=`http://localhost:${O}`;console.log(m.green(`
|
|
204
|
+
\u{1F310} UI ready at ${i}`));let s=null;await U({permanentKey:e.key,step:$.STOPPED,theme:r}),qe(t,null),Ze(()=>s,a=>{s=a},e.key),process.argv.includes("--start")&&Et("start-tunnel"),await new Promise(()=>{})}Ft();async function $s(){Be("agent",process.pid),Xo().catch(()=>{});let e=await Ue(),n=process.argv.find(l=>l.startsWith("--theme=")),r=n?n.split("=")[1]:null,o=await ie(),t=o?{getProcess:()=>null,shutdown:()=>{}}:Ye(null,null);o||await new Promise(l=>setTimeout(l,oe.serverBootMs));let i=`http://localhost:${O}`,s=null;await U({permanentKey:e.key,step:$.STOPPED,theme:r});let a=()=>{let l=s;s=null,pt({serverManager:t,tunnelProcess:l,exit:!1})};qe(t,null),Ze(()=>s,l=>{s=l},e.key);try{He("cloudflared")}catch{}process.argv.includes("--start")&&Et("start-tunnel"),await qr({port:O,onQuit:a,onOpenUI:()=>vn(i)})&&Jr({title:"9Remote is running",message:`Open ${i} or use the tray icon to manage.`}),await new Promise(()=>{})}var ze=q("mode");async function Nc(e){ze.info("\u{1F680} Starting server..."),await K($.PREPARING);try{ft(),await new Promise(s=>setTimeout(s,oe.killCloudflaredMs))}catch{}try{let s=await G(`${D}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e})});if(!s.ok)return ze.error(`\u274C Session create failed: ${s.status}`),null}catch(s){return ze.error(`\u274C Session create failed: ${s.message}`),null}let n=await ie(),r=n?{getProcess:()=>null,shutdown:()=>{}}:Ye(null,null);n||await new Promise(s=>setTimeout(s,oe.serverBootMs)),ze.info("\u2705 Starting tunnel..."),await K($.CONNECTING);let o={current:null},t,i=async s=>{ze.info(`\u{1F504} Tunnel URL rotated: ${s}`),await Me(e,s),U({tunnelUrl:s}),Ct(s)};try{let s=await dt(O,i,Ut({onUrlUpdate:i,setTunnel:a=>{o.current=a}}));o.current=s.child,t=s.tunnelUrl}catch(s){return ze.error(`\u274C Failed to start tunnel: ${s.message}`),r.shutdown(),null}return await Je(t)||ze.warn("\u26A0\uFE0F Tunnel health check timed out, proceeding anyway..."),await Me(e,t),Cn({apiKey:e,tunnelUrl:t,serverPid:r.getProcess()?.pid,tunnelPid:o.current?.pid}),{serverManager:r,tunnelRef:o,tunnelUrl:t}}async function Cs(){_t(Se());let e=await Ue();ze.info(`Using key: ${On(e.key)} (${e.name})`);let n=await Nc(e.key);n||process.exit(1);let{serverManager:r,tunnelRef:o,tunnelUrl:t}=n;await fr(e.key,t),qe(r,o.current),Ze(()=>o.current,s=>{o.current=s},e.key);let i=Date.now();setInterval(()=>{let s=Math.floor((Date.now()-i)/1e3),a=Math.floor(s/3600),c=Math.floor(s%3600/60),l=s%60;U({uptime:`${a}:${String(c).padStart(2,"0")}:${String(l).padStart(2,"0")}`})},ge.statsMs),await new Promise(()=>{})}var Ls=A(require("path"),1),Ms=A(require("fs"),1);Ft();async function Ns(){let e=`http://localhost:${O}`;await ie()&&(ar(O),await new Promise(c=>setTimeout(c,500)));let n=["--tray"],r=process.argv.find(c=>c.startsWith("--theme="));r&&n.push(r);let o=Zt;try{Ms.default.mkdirSync(Ls.default.dirname(o),{recursive:!0})}catch{}let t=null;try{t=Jo(n),t&&Be("agent",t)}catch(c){console.log(m.red(`
|
|
205
205
|
\u274C Failed to launch background: ${c.message}`)),process.exit(1)}let i=Date.now()+ge.bgServerReadyTimeoutMs,s=!1;for(;Date.now()<i;){if(await ie()){s=!0;break}await new Promise(c=>setTimeout(c,ge.bgServerReadyIntervalMs))}s||(console.log(m.red(`
|
|
206
206
|
\u274C Background server failed to start.`)),console.log(m.gray(` Check log: ${o}
|
|
207
|
-
`)),process.exit(1)),Et("start-tunnel"),
|
|
207
|
+
`)),process.exit(1)),Et("start-tunnel"),vn(e);let a=t?` (PID: ${t})`:"";console.log(m.green(`
|
|
208
208
|
\u{1F310} 9Remote running at ${e}${a}`)),console.log(m.gray(`\u{1F4A1} Log: ${o}
|
|
209
|
-
`)),await new Promise(c=>setTimeout(c,oe.bgSpawnFlushMs)),process.exit(0)}var
|
|
209
|
+
`)),await new Promise(c=>setTimeout(c,oe.bgSpawnFlushMs)),process.exit(0)}var Ds=A(require("readline"),1);var io=q("mode"),Ht=null;async function Fs(){console.clear(),vi(),xi(!0),await K($.PREPARING);let e=await Ue(),n=null,r={getProcess:()=>null,shutdown:()=>{}};if(!await ie()){r=Ye(null,null,()=>{if(process.stdin.isTTY){try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.setRawMode(!0),process.stdin.resume()}catch{}}try{Ds.default.emitKeypressEvents(process.stdin)}catch{}n?.()});let S=Date.now()+ge.serverReadyTimeoutMs;for(;Date.now()<S&&!await ie();)await new Promise(g=>setTimeout(g,ge.serverReadyIntervalMs))}try{ft(),await new Promise(S=>setTimeout(S,oe.killCloudflaredTuiMs))}catch{}await yn(zn),await K($.CONNECTING);try{let S=await G(`${D}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e.key})});if(!S.ok)throw new Error(`Session create failed: ${S.status}`)}catch(S){io.error(`\u274C Failed to connect: ${S.message}`),process.exit(1)}await K($.TUNNELING);let t,i,s={current:null},a=async S=>{await Me(e.key,S),await U({tunnelUrl:S}),Ct(S)};try{let S=await dt(O,a,Ut({onUrlUpdate:a,setTunnel:g=>{s.current=g}}));t=S.child,i=S.tunnelUrl,s.current=t}catch(S){io.error(`\u274C Tunnel failed: ${S.message}`),process.exit(1)}await K($.VERIFYING),await Je(i)||io.warn("\u26A0\uFE0F Tunnel health check timed out, proceeding anyway..."),await Me(e.key,i),Cn({apiKey:e.key,tunnelUrl:i,tunnelPid:t.pid});let c=await Bt(e.key,D),l=c?`${D}/login?k=${c.tempKey}`:`${D}/login`;await K($.READY,{tunnelUrl:i,oneTimeKey:c?.tempKey||"",oneTimeKeyExpiresAt:c?.expiresAt||null,permanentKey:e.key,qrUrl:l,workerUrl:D}),await new Promise(S=>setTimeout(S,oe.trayReadyMs));let u=c?.tempKey||"",f=l,p=i,d=await Rn(u,e.key,f,p),h=[],w=!1,T=()=>{w||n?.()},P=async(S,g,_)=>{if(!w){w=!0;try{let I=await Si(g,_);await Z(`/api/device/${I?"approve":"reject"}`,{socketId:S})}catch{}finally{w=!1,n?.()}}},x=Ei(O,async(S,g)=>{if(S==="log"&&g.message)h.push(g.message),h.length>Oe.maxLogLines&&h.shift();else if(S==="state"){let _=g.permanentKey||e.key,I=g.oneTimeKey!==void 0?g.oneTimeKey:u,F=g.qrUrl!==void 0?g.qrUrl:f,j=g.tunnelUrl!==void 0?g.tunnelUrl:p;(I!==u||_!==e.key||j!==p)&&(u=I,f=F,p=j,g.permanentKey&&(e={...e,key:g.permanentKey}),d=await Rn(u,e.key,f,p),T())}else S==="permissions"||S==="autostart"||S==="sleepInhibit"?(w||Ht?.(),T()):S==="deviceApproval"&&g.action==="pending"&&await P(g.socketId,g.deviceId,g.ip)}),b=setInterval(async()=>{if(w)return;let g=(await W("/api/device/pending"))?.pending?.[0];g&&await P(g.socketId,g.deviceId,g.ip)},ge.pendingApprovalMs);qe({getProcess:r.getProcess,shutdown:()=>{r.shutdown(),x(),clearInterval(b)}},t),Ze(()=>s.current,S=>{s.current=S},e.key),await Dc(e,i,()=>d,S=>{d=S},S=>{n=S},()=>{try{x()}catch{}try{clearInterval(b)}catch{}pt({serverManager:r,tunnelProcess:t,exit:!1})},h)}async function Dc(e,n,r,o,t,i,s){for(;;){let{desktopEnabled:a,remoteAvailable:c,autoApprove:l}=await Fr(),u=[{label:"Open Web UI",action:"webui"},{label:"Keys \u25B6",action:"keys"}];c&&u.push({label:`Remote Desktop: ${a?m.green("ON"):m.gray("OFF")} \u25B6`,action:"desktop"}),u.push({label:`Manage Devices \u25B6 ${m.dim("(Auto-approve:")} ${l?m.green("ON"):m.gray("OFF")}${m.dim(")")}`,action:"devices"},{label:"Settings \u25B6",action:"settings"},{label:"View Logs",action:"logs"},{label:m.gray("Exit"),action:"exit"});let f=null;t(()=>f?.());let p=await xe("",u,0,r,h=>{f=h},i),d=p>=0?u[p].action:"exit";if(d==="webui"){let h=`http://localhost:${O}`,{openBrowser:w}=await Promise.resolve().then(()=>(Ft(),Zi));w(h),console.log(m.green(`
|
|
210
210
|
\u{1F310} Opening ${h}
|
|
211
|
-
`))}else if(d==="keys")await
|
|
211
|
+
`))}else if(d==="keys")await Fc(e,n,o,r);else if(d==="desktop")await Hc();else if(d==="devices")await jc();else if(d==="settings")await Bc();else if(d==="logs")await Kc();else{try{i?.()}catch{}console.log(m.gray(`
|
|
212
212
|
Goodbye!
|
|
213
|
-
`)),process.exit(0)}}}async function
|
|
213
|
+
`)),process.exit(0)}}}async function Fc(e,n,r,o){let t=[{label:"New One-Time Key",action:"otk"},{label:"Regenerate Permanent Key",action:"regen"},{label:m.gray("\u2190 Back"),action:"back"}],i=await xe("Keys",t,0,o),s=i>=0?t[i].action:"back";if(s==="otk"){let a=await Bt(e.key,D);if(a){let c=`${D}/login?k=${a.tempKey}`;r(await Rn(a.tempKey,e.key,c,n)),await U({oneTimeKey:a.tempKey,oneTimeKeyExpiresAt:a.expiresAt,qrUrl:c})}}else if(s==="regen"&&await Nr(m.yellow("\u26A0\uFE0F Replace current key and disconnect all sessions? Continue?"))){let c=await vt(),{key:l}=St(c),u=nt(c,l,e.name||"Default");Object.assign(e,u),await U({permanentKey:e.key});let f=await Bt(e.key,D);if(f){let p=`${D}/login?k=${f.tempKey}`;r(await Rn(f.tempKey,e.key,p,n)),await U({oneTimeKey:f.tempKey,oneTimeKeyExpiresAt:f.expiresAt,qrUrl:p})}}}var Us={"30m":"Off after 30 min idle","1h":"Off after 1 hour idle","2h":"Off after 2 hours idle","4h":"Off after 4 hours idle","24h":"Off after 24 hours idle",never:"Never off"};async function Uc(e,n){let r=n.map(s=>({label:Us[s]||s,action:s}));r.push({label:m.gray("\u2190 Back"),action:"back"});let o=Math.max(0,n.indexOf(e)),t=await xe("Prevent sleep",r,o),i=t>=0?r[t].action:"back";i!=="back"&&await Z("/api/sleep-inhibit",{mode:i})}async function Bc(){for(;;){let e=!1,n="never",r=[],o=()=>[{label:`Launch on system startup: ${e?m.green("ON"):m.gray("OFF")}`,action:"autostart"},{label:`Prevent sleep: ${m.green(Us[n]||n)} \u25B6`,action:"sleep"},{label:m.gray("\u2190 Back"),action:"back"}],t=o(),i=null,s=async()=>{let l=await Fr();e=!!l.autoStart,n=l.sleepInhibitMode||"never",r=l.sleepInhibitPresets||[],t=o(),i?.()};await s(),Ht=s;let a=await xe("Settings",t,0,"",l=>{i=l});Ht=null;let c=a>=0?t[a].action:"back";if(c==="autostart")await Z("/api/autostart",{enabled:!e});else if(c==="sleep")await Uc(n,r);else return}}async function Hc(){for(;;){let e=!1,n={screenRecording:!1,accessibility:!1},r=()=>({toggle:`Toggle: ${e?m.green("ON \u2192 turn OFF"):m.gray("OFF \u2192 turn ON")}`,sr:`Screen Recording ${n.screenRecording?m.green("\u2713"):m.red("\u2717 (click to grant)")}`,ax:`Mouse & Keyboard control ${n.accessibility?m.green("\u2713"):m.red("\u2717 (click to grant)")}`}),o=[{label:""},{label:""},{label:""},{label:m.gray("\u2190 Back")}],t=null,i=async()=>{let a=await W("/api/ui/state")||{};e=!!a.desktopEnabled,n={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility};let c=r();o[0].label=c.toggle,o[1].label=c.sr,o[2].label=c.ax,t?.()};await i(),Ht=i;let s=await xe("Remote Desktop",o,0,"",a=>{t=a});if(Ht=null,s===0)await Z("/api/desktop/toggle",{enabled:!e});else if(s===1&&!n.screenRecording)await Z("/api/permissions/request",{type:"screenRecording"})||Jn("screenRecording");else if(s===2&&!n.accessibility)await Z("/api/permissions/request",{type:"accessibility"})||Jn("accessibility");else if(s===3||s===-1)return}}async function jc(){for(;;){let[e,n]=await Promise.all([W("/api/device/approved"),W("/api/device/auto-approve")]),r=e?.devices||[],o=!!n?.enabled,t=[{label:`Auto-approve new devices: ${o?m.green("ON"):m.gray("OFF")}`,action:"toggle"},...r.map(a=>{let c=a.deviceId.slice(0,8),l=a.approvedAt?new Date(a.approvedAt).toLocaleString():"unknown";return{label:`${c}... ${m.dim(l)}`,action:"remove",deviceId:a.deviceId}}),{label:m.gray("\u2190 Back"),action:"back"}],i=await xe(`Approved Devices (${r.length})`,t,0);if(i===-1)return;let s=t[i];if(s.action==="back")return;if(s.action==="toggle"){await Z("/api/device/auto-approve",{enabled:!o});continue}s.action==="remove"&&await Nr(m.yellow(`Remove device ${s.deviceId.slice(0,8)}...?`))&&await Z("/api/device/remove",{deviceId:s.deviceId})}}async function Kc(){let e=Oo(fo),n=e.length?e.join(`
|
|
214
214
|
`):m.gray(" No logs yet"),r=`
|
|
215
|
-
${m.dim("Log file:")} ${m.cyan(
|
|
216
|
-
${m.dim(`Tail: tail -f ${
|
|
215
|
+
${m.dim("Log file:")} ${m.cyan(Zt)}
|
|
216
|
+
${m.dim(`Tail: tail -f ${Zt}`)}`;await xe("Logs",[{label:m.gray("\u2190 Back")}],0,n+r)}async function Bs(){let e=Se(),n=await ai(),r=Mr(e,n?.latest??null),o=[];n?.latest&&o.push({label:m.yellow(`Update to v${n.latest}`),action:"update"}),o.push({label:"Open Web UI (background)",action:"ui"},{label:"Terminal UI",action:"tui"},{label:m.gray("Exit"),action:"exit"});let t=await xe("",o,0,r),i=t>=0?o[t].action:"exit";if(i==="update"){let s=Math.min(Oe.headerWidth,process.stdout.columns||Oe.headerWidth);qn(),console.log(fe.orange(`
|
|
217
217
|
`+"\u2550".repeat(s))),console.log(m.gray(` \u2713 Stopped running instances
|
|
218
218
|
`)),console.log(m.yellow(` \u2B06 Run this command to update:
|
|
219
219
|
`)),console.log(m.white.bold(` npm i -g ${Pe}
|
|
220
220
|
`)),console.log(fe.orange("\u2550".repeat(s))+`
|
|
221
|
-
`),process.exit(0)}else i==="ui"?await
|
|
221
|
+
`),process.exit(0)}else i==="ui"?await Ns():i==="tui"?await Fs():process.exit(0)}var Hs=[["9remote","Interactive menu (TUI). Falls back to help with no TTY."],["9remote start","Run server + tunnel in foreground (headless)."],["9remote key","Show permanent key + connect URL."],["9remote key --new","Regenerate the permanent key."],["9remote otk","Create a fresh one-time connect key + URL."],["9remote devices","List approved devices."],["9remote auto-approve <on|off>","Toggle device auto-approve."],["9remote approve <socketId>","Approve a pending device."],["9remote help","Show this help."]];function so(){_t(Se()),console.log(m.white.bold(`
|
|
222
222
|
Usage:
|
|
223
|
-
`));let e=Math.max(...
|
|
223
|
+
`));let e=Math.max(...Hs.map(([n])=>n.length))+2;for(let[n,r]of Hs)console.log(" "+m.cyan(n.padEnd(e))+m.gray(r));console.log()}async function bn(){return await ie()?!0:(console.log(m.red(`
|
|
224
224
|
\u2717 Server not running. Start it first: `)+m.cyan("9remote start")+`
|
|
225
|
-
`),!1)}async function
|
|
225
|
+
`),!1)}async function Gc(e){if(!await bn())return;if(e){let r=await Z("/api/key/regenerate"),o=r&&r.ok?await r.json():null;if(!o?.permanentKey){console.log(m.red(`
|
|
226
226
|
\u2717 Regenerate failed
|
|
227
227
|
`));return}console.log(m.green(`
|
|
228
228
|
\u2713 New key: `)+m.white.bold(o.permanentKey)+`
|
|
@@ -230,17 +230,17 @@ Usage:
|
|
|
230
230
|
\u2717 No key yet. Run: `)+m.cyan("9remote start")+`
|
|
231
231
|
`);return}console.log(m.white(`
|
|
232
232
|
Key`.padEnd(14))+m.white.bold(n.permanentKey)),n.qrUrl&&console.log(m.white("Connect URL".padEnd(14))+m.cyan(n.qrUrl)),console.log(m.white("App URL".padEnd(14))+m.gray(`${D}/login`)+`
|
|
233
|
-
`)}async function
|
|
233
|
+
`)}async function Wc(){if(!await bn())return;let e=await Z("/api/key/one-time"),n=e&&e.ok?await e.json():null;if(!n?.qrUrl){console.log(m.red(`
|
|
234
234
|
\u2717 Failed to create one-time key
|
|
235
235
|
`));return}console.log(m.green(`
|
|
236
236
|
\u2713 One-time key (30 min): `)+m.white.bold(n.oneTimeKey)),console.log(m.white("Connect URL ")+m.cyan(n.qrUrl)+`
|
|
237
|
-
`)}async function
|
|
237
|
+
`)}async function Vc(){if(!await bn())return;let n=(await W("/api/device/approved")||{}).devices||[],r=await W("/api/device/auto-approve")||{};if(console.log(m.white(`
|
|
238
238
|
Auto-approve: `)+(r.enabled?m.green("ON"):m.gray("OFF"))),!n.length){console.log(m.gray(`No approved devices
|
|
239
|
-
`));return}console.log(m.white(`Approved devices (${n.length}):`));for(let o of n)console.log(" "+m.cyan(o.deviceId));console.log()}async function
|
|
239
|
+
`));return}console.log(m.white(`Approved devices (${n.length}):`));for(let o of n)console.log(" "+m.cyan(o.deviceId));console.log()}async function Yc(e){if(!await bn())return;let n=e==="on";if(e!=="on"&&e!=="off"){console.log(m.red(`
|
|
240
240
|
\u2717 Usage: 9remote auto-approve <on|off>
|
|
241
241
|
`));return}let r=await Z("/api/device/auto-approve",{enabled:n}),o=r&&r.ok?await r.json():null;console.log(m.green(`
|
|
242
242
|
\u2713 Auto-approve: `)+(o?.enabled?m.green("ON"):m.gray("OFF"))+`
|
|
243
|
-
`)}async function
|
|
243
|
+
`)}async function qc(e){if(!await bn())return;if(!e){let t=(await W("/api/device/pending")||{}).pending||[];if(!t.length){console.log(m.gray(`
|
|
244
244
|
No pending devices
|
|
245
245
|
`));return}console.log(m.white(`
|
|
246
246
|
Pending devices (${t.length}):`));for(let i of t)console.log(" "+m.cyan(i.socketId)+m.gray(` ${i.deviceId?.slice(0,8)||""} ${i.ip||""}`));console.log(m.gray(`
|
|
@@ -249,5 +249,5 @@ Approve with: `)+m.cyan("9remote approve <socketId>")+`
|
|
|
249
249
|
\u2713 Approved
|
|
250
250
|
`):m.red(`
|
|
251
251
|
\u2717 Approve failed (invalid socketId?)
|
|
252
|
-
`))}async function
|
|
253
|
-
`),process.exit(0));
|
|
252
|
+
`))}async function js(e){let n=e[2],r=e.slice(3);switch(n){case"help":case"-h":case"--help":return so(),!0;case"key":return await Gc(r.includes("--new")),!0;case"otk":return await Wc(),!0;case"devices":return await Vc(),!0;case"auto-approve":return await Yc(r[0]),!0;case"approve":return await qc(r[0]),!0;default:return!1}}var ao=process.argv[2];(ao==="version"||ao==="--version"||ao==="-v")&&(process.stdout.write(Se()+`
|
|
253
|
+
`),process.exit(0));Po();async function Jc(){let e=process.argv[2];if(await js(process.argv))return;process.argv.includes("--tray")||process.argv.includes("--auto")||process.argv.includes("--start")||qn(),e==="ui"?await Is():e==="start"||process.argv.includes("--auto")?await Cs():process.argv.includes("--tray")||process.argv.includes("--start")?await $s():process.stdin.isTTY?await Bs():so()}Jc().catch(console.error);
|