9remote 2.1.2 → 2.1.5
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 +68 -68
- package/dist/ptyDaemon.cjs +6 -6
- package/dist/server.cjs +71 -71
- package/dist/ui/assets/{index-5Az69C6y.js → index-x-cLAYQY.js} +3556 -3552
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
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,_,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}
|
|
3
|
+
var Ws=Object.create;var pr=Object.defineProperty;var Vs=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var qs=Object.getPrototypeOf,Js=Object.prototype.hasOwnProperty;var Qs=(e,n)=>()=>(e&&(n=e(e=0)),n);var ce=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Xs=(e,n)=>{for(var r in n)pr(e,r,{get:n[r],enumerable:!0})},Zs=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Ys(n))!Js.call(e,t)&&t!==r&&pr(e,t,{get:()=>n[t],enumerable:!(o=Vs(n,t))||o.enumerable});return e};var A=(e,n,r)=>(r=e!=null?Ws(qs(e)):{},Zs(n||!e||!e.__esModule?pr(r,"default",{value:e,enumerable:!0}):r,e));var vo=ce((Jt,hr)=>{(function(e,n){typeof Jt=="object"&&typeof hr=="object"?hr.exports=n(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],n):typeof Jt=="object"?Jt["electron-machine-id"]=n(require("child_process"),require("crypto")):e["electron-machine-id"]=n(e.child_process,e.crypto)})(Jt,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",tt=I==x,Kt=!1,te=k.prototype,Ne=te[h]||te[T]||I&&te[I],se=Ne||ke(I),Gt=I?tt?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))),tt&&Ne&&Ne.name!==x&&(Kt=!0,se=function(){return Ne.call(this)}),i&&!j||!w&&!Kt&&te[h]||c(te,h,se),u[S]=se,u[gt]=b,I)if(de={values:tt?se:ke(x),keys:F?se:ke(P),entries:Gt},j)for(me in de)me in te||a(te,me,de[me]);else s(s.P+s.F*(w||Kt),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,q){if(v!==void 0||R!==void 0)throw S("Bad Promise constructor");v=L,R=q}),this.resolve=h(v),this.reject=h(R)},gt=function(y){try{y()}catch(v){return{error:v}}},tt=function(y,v){if(!y._n){y._n=!0;var R=y._c;b(function(){for(var L=y._v,q=y._s==1,nt=0,yt=function(De){var ve,_n,Wt=q?De.ok:De.fail,Vt=De.resolve,wt=De.reject,Pn=De.domain;try{Wt?(q||(y._h==2&&Ne(y),y._h=1),Wt===!0?ve=L:(Pn&&Pn.enter(),ve=Wt(L),Pn&&Pn.exit()),ve===De.promise?wt(S("Promise-chain cycle")):(_n=me(ve))?_n.call(ve,Vt,wt):Vt(ve)):wt(L)}catch(Gs){wt(Gs)}};R.length>nt;)yt(R[nt++]);y._c=[],y._n=!1,v&&!y._h&&Kt(y)})}},Kt=function(y){x.call(l,function(){var v,R,L,q=y._v;if(te(y)&&(v=gt(function(){I?_.emit("unhandledRejection",q,y):(R=l.onunhandledrejection)?R({promise:y,reason:q}):(L=l.console)&&L.error&&L.error("Unhandled promise rejection",q)}),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()),tt(v,!0))},Gt=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(Gt,L,1),u(se,L,1))}catch(q){se.call(L,q)}}):(R._v=y,R._s=1,tt(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(Gt,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&&tt(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(Gt,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,q=R.reject,nt=gt(function(){var yt=[],De=0,ve=1;T(y,!1,function(_n){var Wt=De++,Vt=!1;yt.push(void 0),ve++,v.resolve(_n).then(function(wt){Vt||(Vt=!0,yt[Wt]=wt,--ve||L(yt))},q)}),--ve||L(yt)});return nt&&q(nt.error),R.promise},race:function(y){var v=this,R=ee(v),L=R.reject,q=gt(function(){T(y,!1,function(nt){v.resolve(nt).then(R.resolve,L)})});return q&&L(q.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={};Xs(zi,{initTray:()=>Jr,killTray:()=>Sn,openBrowser:()=>En,showTrayNotification:()=>Qr,updateTrayTooltip:()=>sr});function Wi(e){for(let n of e)try{if(Dt.default.existsSync(n))return n}catch{}return null}function vc(){if(process.platform==="win32"){for(let e of Qi)try{if(Dt.default.existsSync(e))return Dt.default.readFileSync(e).toString("base64")}catch{}return Gi}return Gi}function Sc(){let e=process.platform;return!(!["darwin","win32","linux"].includes(e)||e==="linux"&&!process.env.DISPLAY)}function Xi(){let{port:e,tunnelUrl:n,running:r}=Ft,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 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+`
|
|
6
|
+
Right-click to open / quit`}function Zi(){let{port:e,tunnelUrl:n}=Ft,r=process.platform==="win32",o=n?`9Remote (Port ${e}) \u2022 Tunnel ON`:`9Remote (Port ${e}) \u2022 Local only`;return{icon:vc(),title:r?`9Remote - Port ${e}`:"",tooltip:Xi(),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 Ec(){try{let e=require(Re.default.join(Ji,"systray2"));return e.default?.default||e.default||e}catch{return null}}function Tc({port:e,onQuit:n,onOpenUI:r}){let o=Wi(Qi),t=Wi(wc);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 Vi.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?.(),Sn(),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 Jr({port:e,onQuit:n,onOpenUI:r}){if(!Sc())return null;if(process.platform==="win32")return Ft={port:e,tunnelUrl:"",running:!0},z=Tc({port:e,onQuit:n,onOpenUI:r}),z;try{let o=Ec();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(Ji,"systray2","traybin",i);if(!Dt.default.existsSync(s))return null;if(process.platform!=="win32")try{Dt.default.chmodSync(s,493)}catch{}return Ft={port:e,tunnelUrl:"",running:!0},z=new o({menu:Zi(),debug:!1,copyDir:!0}),z.onClick(a=>{let c=a.item?.title||a.item;c==="Open Web UI"?r?.():c==="Shutdown"&&(n?.(),Sn(),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&&(Ft.tunnelUrl=e),n!==void 0&&(Ft.running=n),!!z){if(z._isWin){z._setTooltip?.(Xi());return}try{z.sendAction({type:"update-menu",menu:Zi(),seq_id:-1})}catch{}}}function Sn(){let e=z;if(z=null,e)try{e.kill(!0)}catch{}}function Qr({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 En(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,Vi,Dt,Re,Yi,qi,Ji,z,Ft,ir,Gi,Qi,wc,Ut=Qs(()=>{Ce=require("child_process"),Vi=A(require("readline"),1),Dt=A(require("fs"),1),Re=A(require("path"),1),Yi=A(require("os"),1),qi=require("url"),Ji=(0,Re.join)(Yi.default.homedir(),".9remote","runtime","node_modules"),z=null,Ft={port:0,tunnelUrl:"",running:!1},ir=Re.default.dirname((0,qi.fileURLToPath)(__importMetaUrl)),Gi="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=",Qi=[Re.default.join(ir,"assets","trayIcon.ico"),Re.default.join(ir,"..","assets","trayIcon.ico")],wc=[Re.default.join(ir,"assets","tray.ps1"),Re.default.join(ir,"..","assets","tray.ps1")]});var eo=ce((Nu,ss)=>{ss.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var ls=ce((Du,cs)=>{var bc=eo();function as(e){this.mode=bc.MODE_8BIT_BYTE,this.data=e}as.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)}};cs.exports=as});var to=ce((Fu,us)=>{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;us.exports=we});var no=ce((Uu,fs)=>{var mt=to();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)}};fs.exports=cr});var ds=ce((Bu,ps)=>{ps.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var gs=ce((Hu,hs)=>{var pe=eo(),ms=no(),Ac=to(),Xe=ds(),Y={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;Y.getBCHDigit(n)-Y.getBCHDigit(Y.G15)>=0;)n^=Y.G15<<Y.getBCHDigit(n)-Y.getBCHDigit(Y.G15);return(e<<10|n)^Y.G15_MASK},getBCHTypeNumber:function(e){for(var n=e<<12;Y.getBCHDigit(n)-Y.getBCHDigit(Y.G18)>=0;)n^=Y.G18<<Y.getBCHDigit(n)-Y.getBCHDigit(Y.G18);return e<<12|n},getBCHDigit:function(e){for(var n=0;e!==0;)n++,e>>>=1;return n},getPatternPosition:function(e){return Y.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,n,r){switch(e){case Xe.PATTERN000:return(n+r)%2===0;case Xe.PATTERN001:return n%2===0;case Xe.PATTERN010:return r%3===0;case Xe.PATTERN011:return(n+r)%3===0;case Xe.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case Xe.PATTERN101:return n*r%2+n*r%3===0;case Xe.PATTERN110:return(n*r%2+n*r%3)%2===0;case Xe.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var n=new ms([1],0),r=0;r<e;r++)n=n.multiply(new ms([1,Ac.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}};hs.exports=Y});var ro=ce((ju,ys)=>{ys.exports={L:1,M:0,Q:3,H:2}});var vs=ce((Ku,ws)=>{var lr=ro();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}};ws.exports=be});var Ts=ce((Gu,Es)=>{function Ss(){this.buffer=[],this.length=0}Ss.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++}};Es.exports=Ss});var As=ce((Wu,bs)=>{var kc=ls(),Ze=gs(),_c=no(),xs=vs(),Rs=Ts();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 kc(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=xs.getRSBlocks(e,this.errorCorrectLevel),r=new Rs,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(),Ze.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=Ze.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=Ze.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=Ze.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=Ze.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=Ze.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=xs.getRSBlocks(e,n),t=new Rs,i=0;i<r.length;i++){var s=r[i];t.put(s.mode,4),t.put(s.getLength(),Ze.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=Ze.getErrorCorrectPolynomial(l),p=new _c(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};bs.exports=Ae});var Ps=ce((Vu,_s)=>{var Pc=As(),ks=ro(),Oc="\x1B[40m \x1B[0m",ur="\x1B[47m \x1B[0m",Ic=function(e){return e?Oc:ur},oo=function(e){return{times:function(n){return new Array(n).join(e)}}},$c=function(e,n){for(var r=new Array(e),o=0;o<e;o++)r[o]=n;return r};_s.exports={error:ks.L,generate:function(e,n,r){typeof n=="function"&&(r=n,n={});var o=new Pc(-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($c(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=oo(u.BLACK_WHITE).times(a+3),p=oo(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 w=
|
|
10
|
-
`,o.modules.forEach(function(T){t+=ur,t+=T.map(
|
|
11
|
-
`}),t+=w}r?r(t):console.log(t)},setErrorLevel:function(e){this.error=
|
|
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 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
|
|
14
|
-
=== SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),
|
|
15
|
-
`).filter(Boolean).slice(-e)}catch{return[]}}function
|
|
9
|
+
`}l||(t+=p)}else{var w=oo(ur).times(o.getModuleCount()+3);t+=w+`
|
|
10
|
+
`,o.modules.forEach(function(T){t+=ur,t+=T.map(Ic).join(""),t+=ur+`
|
|
11
|
+
`}),t+=w}r?r(t):console.log(t)},setErrorLevel:function(e){this.error=ks[e]||this.error}}});var In=require("fs"),qt=require("path"),yo=require("url"),wo=A(require("os"),1);var On=A(require("dns"),1),_e=A(require("path"),1),uo=A(require("os"),1),ne="9remote",mr=process.env.NREMOTE_REGISTRY||`https://registry.npmjs.org/${ne}/latest`,Pe=`${ne}@latest`,Fe=_e.default.join(uo.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")},fo=new On.default.promises.Resolver;fo.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);var dr=On.default.lookup,zs=/^(\d{1,3}\.){3}\d{1,3}$|^::1$|^[0-9a-f:]+$/i;On.default.lookup=(e,n,r)=>{if(typeof n=="function"&&(r=n,n={}),e==="localhost"||zs.test(e))return dr(e,n,r);fo.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,lo=5173;var zc=[`http://localhost:${O}`,`http://127.0.0.1:${O}`,`http://localhost:${lo}`,`http://127.0.0.1:${lo}`],Yt={fileName:"agent.log",rotatedName:"agent.log.1",maxBytes:2*1024*1024,cleanupAfterDays:7},po=60,$={STOPPED:0,PREPARING:1,CONNECTING:2,TUNNELING:3,VERIFYING:4,READY:5},mo={showTunnelUrlInMenu:!1};var ho={CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN:"1"};var go={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}},ea={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:{...ea,...n.headers}})}var ta=(0,qt.dirname)((0,yo.fileURLToPath)(__importMetaUrl)),na=[(0,qt.join)(wo.default.homedir(),".9remote",".env"),(0,qt.join)(ta,"..",".env")];function ra(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 na)if((0,In.existsSync)(e))try{ra((0,In.readFileSync)(e,"utf8"))}catch{}for(let[e,n]of Object.entries(ho))process.env[e]||(process.env[e]=n);var vr=A(require("path"),1),bo=A(require("fs"),1),Ao=require("url");var So=A(vo(),1),gr=A(require("crypto"),1),{machineIdSync:oa}=So.default;async function vt(e=null){let n=e||process.env.MACHINE_ID_SALT||"9remote-salt";try{let r=oa();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 Eo=A(require("crypto"),1),ia=process.env.API_KEY_SECRET||"9remote-api-key-secret";function sa(){let e="abcdefghijklmnopqrstuvwxyz0123456789",n="";for(let r=0;r<4;r++)n+=e.charAt(Math.floor(Math.random()*e.length));return n}function aa(e,n){return Eo.default.createHmac("sha256",ia).update(e+n).digest("hex").slice(0,6)}function St(e){let n=e.slice(0,8),r=sa(),o=aa(n,r);return{key:`sk-${n}-${r}-${o}`,keyId:r}}function $n(e){return!e||e.length<8?"sk-***":`${e.slice(0,3)}***${e.slice(-4)}`}var ae=A(require("fs"),1),Qt=A(require("path"),1);var il=re.STATE,yr=Qt.default.join(re.STATE,"state.json"),wr=Qt.default.join(re.ROOT,"keys.json"),Cn=Qt.default.join(re.STATE,"cmd.json"),sl=Qt.default.join(re.STATE,"settings.json");function Ln(){for(let e of[re.ROOT,re.STATE])ae.default.existsSync(e)||ae.default.mkdirSync(e,{recursive:!0})}function Mn(e){try{Ln(),ae.default.writeFileSync(yr,JSON.stringify(e,null,2),{mode:384})}catch(n){console.error("Error saving state:",n)}}function To(){try{ae.default.existsSync(yr)&&ae.default.unlinkSync(yr)}catch{}}function Nn(){try{return Ln(),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{Ln(),ae.default.writeFileSync(Cn,JSON.stringify({cmd:e,ts:Date.now()}))}catch{}}function xo(){try{if(!ae.default.existsSync(Cn))return null;let e=JSON.parse(ae.default.readFileSync(Cn,"utf8"));return ae.default.unlinkSync(Cn),e.cmd}catch{return null}}function rt(e,n,r="Default"){try{Ln();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 Ro(){return process.env.CODESPACES==="true"}var ca=vr.default.dirname((0,Ao.fileURLToPath)(__importMetaUrl));async function Ue(){let e=await vt();if(Ro()&&process.env.NREMOTE_API_KEY)return rt(e,process.env.NREMOTE_API_KEY,"Codespace");let n=Nn();if(!n.key){let{key:r}=St(e);n=rt(e,r,"Default")}return n}function Se(){return"2.1.5"}var Ee=A(require("fs"),1),Er=A(require("path"),1);var Dn=re.LOGS,Zt=Er.default.join(Dn,Yt.fileName),Fn=Er.default.join(Dn,Yt.rotatedName),ko=!1,_o=null;function la(){Ee.default.existsSync(Dn)||Ee.default.mkdirSync(Dn,{recursive:!0})}function ua(){try{if(Ee.default.statSync(Zt).size<Yt.maxBytes)return;try{Ee.default.rmSync(Fn,{force:!0})}catch{}Ee.default.renameSync(Zt,Fn)}catch{}}function fa(){try{let e=Ee.default.statSync(Fn);Date.now()-e.mtimeMs>Yt.cleanupAfterDays*864e5&&Ee.default.rmSync(Fn,{force:!0})}catch{}}function Tr(e){try{ua(),Ee.default.appendFileSync(Zt,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 Po(){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 pa=/\x1b\[[0-9;]*m/g,da=/https?:\/\/[^\s]+/g;function ma(e){return String(e).replace(pa,"").replace(da,"").replace(/\s+$/g,"")}function Xt(e,n,r){let o=ma(r);if(!o)return;let t=n==="info"?e:`${e}:${n}`,i=`${Po()} [${t}] ${o}`;if(Tr(i),_o)try{_o(i)}catch{}}function ha(){process.on("uncaughtException",e=>Xt("crash","error",`uncaughtException: ${e?.stack||e?.message||e}`)),process.on("unhandledRejection",e=>{let n=e instanceof Error?e.stack||e.message:String(e);Xt("crash","error",`unhandledRejection: ${n}`)}),process.on("exit",e=>Tr(`${Po()} [exit] code=${e} pid=${process.pid}`))}function Oo(){ko||(ko=!0,la(),fa(),Tr(`
|
|
14
|
+
=== SESSION ${new Date().toISOString()} pid=${process.pid} argv=${process.argv.slice(2).join(" ")} ===`),ha())}function Io(e=60){try{return Ee.default.readFileSync(Zt,"utf8").split(`
|
|
15
|
+
`).filter(Boolean).slice(-e)}catch{return[]}}function J(e){return{info:(...n)=>Xt(e,"info",Sr(n)),warn:(...n)=>Xt(e,"warn",Sr(n)),error:(...n)=>Xt(e,"error",Sr(n))}}var zt=Zt;var $o=(e=0)=>n=>`\x1B[${n+e}m`,Co=(e=0)=>n=>`\x1B[${38+e};5;${n}m`,Lo=(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]}},gl=Object.keys(M.modifier),ga=Object.keys(M.color),ya=Object.keys(M.bgColor),yl=[...ga,...ya];function wa(){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=$o(),M.color.ansi256=Co(),M.color.ansi16m=Lo(),M.bgColor.ansi=$o(10),M.bgColor.ansi256=Co(10),M.bgColor.ansi16m=Lo(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 va=wa(),he=va;var Bn=A(require("node:process"),1),No=A(require("node:os"),1),xr=A(require("node:tty"),1);function ue(e,n=globalThis.Deno?globalThis.Deno.args:Bn.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}=Bn.default,Un;ue("no-color")||ue("no-colors")||ue("color=false")||ue("color=never")?Un=0:(ue("color")||ue("colors")||ue("color=true")||ue("color=always"))&&(Un=1);function Sa(){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 Ea(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Ta(e,{streamIsTTY:n,sniffFlags:r=!0}={}){let o=Sa();o!==void 0&&(Un=o);let t=r?Un: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(Bn.default.platform==="win32"){let s=No.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 Mo(e,n={}){let r=Ta(e,{streamIsTTY:e&&e.isTTY,...n});return Ea(r)}var xa={stdout:Mo({isTTY:xr.default.isatty(1)}),stderr:Mo({isTTY:xr.default.isatty(2)})},Do=xa;function Fo(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 Uo(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,
|
|
18
|
+
`,t)}while(o!==-1);return i+=e.slice(t),i}var{stdout:Bo,stderr:Ho}=Do,Rr=Symbol("GENERATOR"),Tt=Symbol("STYLER"),en=Symbol("IS_EMPTY"),jo=["ansi","ansi","ansi256","ansi16m"],xt=Object.create(null),Ra=(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=Bo?Bo.level:0;e.level=n.level===void 0?r:n.level};var ba=e=>{let n=(...r)=>r.join(" ");return Ra(n,e),Object.setPrototypeOf(n,tn.prototype),n};function tn(e){return ba(e)}Object.setPrototypeOf(tn.prototype,Function.prototype);for(let[e,n]of Object.entries(he))xt[e]={get(){let r=Hn(this,Ar(n.open,n.close,this[Tt]),this[en]);return Object.defineProperty(this,e,{value:r}),r}};xt.visible={get(){let e=Hn(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),Aa=["rgb","hex","ansi256"];for(let e of Aa){xt[e]={get(){let{level:r}=this;return function(...o){let t=Ar(br(e,jo[r],"color",...o),he.color.close,this[Tt]);return Hn(this,t,this[en])}}};let n="bg"+e[0].toUpperCase()+e.slice(1);xt[n]={get(){let{level:r}=this;return function(...o){let t=Ar(br(e,jo[r],"bgColor",...o),he.bgColor.close,this[Tt]);return Hn(this,t,this[en])}}}}var ka=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}},Hn=(e,n,r)=>{let o=(...t)=>_a(o,t.length===1?""+t[0]:t.join(" "));return Object.setPrototypeOf(o,ka),o[Rr]=e,o[Tt]=n,o[en]=r,o},_a=(e,n)=>{if(e.level<=0||!n)return e[en]?"":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=Fo(n,r.close,r.open),r=r.parent;let i=n.indexOf(`
|
|
19
|
+
`);return i!==-1&&(n=Uo(n,t,o,i)),o+n+t};Object.defineProperties(tn.prototype,xt);var Pa=tn(),Rl=tn({level:Ho?Ho.level:0});var m=Pa;var X=require("fs"),oi=require("url"),rn=require("child_process"),Ie=A(require("path"),1),At=A(require("os"),1);var Rt=A(require("fs"),1),kr=A(require("path"),1),Ko=A(require("os"),1),Go=require("child_process"),jn=kr.default.join(Ko.default.homedir(),".9remote","pids");function Oa(){try{Rt.default.existsSync(jn)||Rt.default.mkdirSync(jn,{recursive:!0})}catch{}}function _r(e){return kr.default.join(jn,`${e}.pid`)}function Be(e,n){if(n)try{Oa(),Rt.default.writeFileSync(_r(e),String(n))}catch{}}function Kn(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 Wo(e){if(!e)return!1;try{return process.kill(e,0),!0}catch{return!1}}function Ia(e){let n=Kn(e);if(He(e),!n)return!1;try{process.platform==="win32"?(0,Go.execSync)(`taskkill /F /T /PID ${n}`,{stdio:"ignore",windowsHide:!0}):process.kill(n,"SIGKILL")}catch{}return!0}var $a=["cloudflared","agent"];function Vo(){for(let e of $a)Ia(e)}function Yo(){return jn}var st=require("child_process"),C=require("fs"),ot=require("path"),Or=A(require("os"),1),it=A(require("path"),1),Jo=require("url");var Wn=(0,ot.join)(re.LOGS,"autostart.log"),Gn="cc.9remote.agent",Vn="9Remote",Yn=["--tray","--skip-update","--start"],nn=Or.default.homedir(),qo=it.default.dirname((0,Jo.fileURLToPath)(__importMetaUrl)),Q={darwin:(0,ot.join)(nn,"Library","LaunchAgents",`${Gn}.plist`),linux:(0,ot.join)(nn,".config","autostart",`${Gn}.desktop`),linuxSystemd:(0,ot.join)(nn,".config","systemd","user",`${Gn}.service`),win:(0,ot.join)(process.env.APPDATA||"","Microsoft","Windows","Start Menu","Programs","Startup",`${Vn}.vbs`)};function at(){for(let e=qo,n=null;e!==n;n=e,e=it.default.dirname(e)){let r=it.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=it.default.resolve(e,t);if((0,C.existsSync)(i))return i}}catch{}break}}return process.argv[1]||it.default.resolve(qo,"..","index.js")}function je(){return process.execPath}function Qo(e){let n=je(),r=at();if(process.platform==="win32"){let t=e.join(" "),i=(0,ot.join)(Or.default.tmpdir(),`${ne}-launch.vbs`);return(0,C.writeFileSync)(i,`CreateObject("WScript.Shell").Run """${n}"" ""${r}"" ${t}", 0, False
|
|
20
|
+
`),(0,st.execFile)("wscript.exe",[i],{windowsHide:!0}).unref?.(),null}let o=(0,st.spawn)(n,[r,...e],{detached:!0,stdio:"ignore"});return o.unref(),o.pid||null}function Xo(){let e=it.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 Ca(e,n){let r=[e,n,...Yn].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>${Gn}</string>
|
|
27
27
|
<key>ProgramArguments</key>
|
|
28
28
|
<array>
|
|
29
29
|
${r}
|
|
@@ -35,43 +35,43 @@ ${r}
|
|
|
35
35
|
<key>EnvironmentVariables</key>
|
|
36
36
|
<dict>
|
|
37
37
|
<key>PATH</key>
|
|
38
|
-
<string>${Pr(
|
|
38
|
+
<string>${Pr(Xo())}</string>
|
|
39
39
|
<key>HOME</key>
|
|
40
|
-
<string>${Pr(
|
|
40
|
+
<string>${Pr(nn)}</string>
|
|
41
41
|
</dict>
|
|
42
42
|
<key>StandardOutPath</key>
|
|
43
|
-
<string>${
|
|
43
|
+
<string>${Wn}</string>
|
|
44
44
|
<key>StandardErrorPath</key>
|
|
45
|
-
<string>${
|
|
45
|
+
<string>${Wn}</string>
|
|
46
46
|
</dict>
|
|
47
47
|
</plist>
|
|
48
|
-
`}function
|
|
49
|
-
WshShell.Run """${je()}"" ""${
|
|
50
|
-
`}function
|
|
48
|
+
`}function La(){return(0,C.existsSync)(Q.darwin)}function Ma(){let e=Yn.join(" ");return`Set WshShell = CreateObject("WScript.Shell")
|
|
49
|
+
WshShell.Run """${je()}"" ""${at()}"" ${e}", 0, False
|
|
50
|
+
`}function Na(){try{(0,st.execFileSync)("reg",["DELETE","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","/V",Vn,"/F"],{windowsHide:!0,stdio:"ignore"})}catch{}}function Da(){return(0,C.existsSync)(Q.win)}function Fa(){let e=`${je()} ${at()} ${Yn.join(" ")}`;return`[Desktop Entry]
|
|
51
51
|
Type=Application
|
|
52
|
-
Name=${
|
|
52
|
+
Name=${Vn}
|
|
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 Ua(){let e=Yn.map(n=>`'${n}'`).join(" ");return`[Unit]
|
|
58
|
+
Description=${Vn} Agent
|
|
59
59
|
After=network-online.target
|
|
60
60
|
Wants=network-online.target
|
|
61
61
|
|
|
62
62
|
[Service]
|
|
63
63
|
Type=simple
|
|
64
|
-
ExecStart=${je()} ${
|
|
64
|
+
ExecStart=${je()} ${at()} ${e}
|
|
65
65
|
Restart=always
|
|
66
66
|
RestartSec=10
|
|
67
|
-
Environment=PATH=${
|
|
68
|
-
Environment=HOME=${
|
|
69
|
-
StandardOutput=append:${
|
|
70
|
-
StandardError=append:${
|
|
67
|
+
Environment=PATH=${Xo()}
|
|
68
|
+
Environment=HOME=${nn}
|
|
69
|
+
StandardOutput=append:${Wn}
|
|
70
|
+
StandardError=append:${Wn}
|
|
71
71
|
|
|
72
72
|
[Install]
|
|
73
73
|
WantedBy=default.target
|
|
74
|
-
`}function
|
|
74
|
+
`}function Ba(e){try{return(0,st.execFileSync)("systemctl",["--user",...e],{stdio:"ignore"}),!0}catch{return!1}}function Ha(){return(0,C.existsSync)(Q.linux)||(0,C.existsSync)(Q.linuxSystemd)}async function ja(){try{if(process.platform==="darwin")return La();if(process.platform==="win32")return await Da();if(process.platform==="linux")return Ha()}catch{}return!1}async function Zo(){try{if(process.platform==="win32"&&Na(),!await ja())return!1;if(process.platform==="darwin"){let e=Ca(je(),at());return((0,C.existsSync)(Q.darwin)?(0,C.readFileSync)(Q.darwin,"utf8"):"")===e?!1:((0,C.writeFileSync)(Q.darwin,e),!0)}if(process.platform==="win32"){let e=Ma();return((0,C.existsSync)(Q.win)?(0,C.readFileSync)(Q.win,"utf8"):"")===e?!1:((0,C.writeFileSync)(Q.win,e),!0)}if(process.platform==="linux"){if((0,C.existsSync)(Q.linuxSystemd)){let e=Ua();return(0,C.readFileSync)(Q.linuxSystemd,"utf8")===e?!1:((0,C.writeFileSync)(Q.linuxSystemd,e),Ba(["daemon-reload"]),!0)}if((0,C.existsSync)(Q.linux)){let e=Fa();return(0,C.readFileSync)(Q.linux,"utf8")===e?!1:((0,C.writeFileSync)(Q.linux,e),!0)}}}catch{}return!1}var D="https://9remote.cc",zo=3e4,ei=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"},ti=5e3,ni=2,ri=3e4,fe={orange:m.rgb(230,138,110),orangeDim:m.rgb(200,120,95)};var Ka=Ie.default.dirname((0,oi.fileURLToPath)(__importMetaUrl)),ii=3e3;var Jn=2208,$r=Ie.default.join(At.default.homedir(),".9remote","cloudflared.pid");function Ga(){try{Vo()}catch{}try{if((0,X.existsSync)($r)){let e=parseInt((0,X.readFileSync)($r,"utf8"));if(Number.isFinite(e))try{process.kill(e)}catch{}try{(0,X.unlinkSync)($r)}catch{}}}catch{}try{process.platform==="win32"?(0,rn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${Jn}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,rn.execSync)(`lsof -ti:${Jn} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}if(process.platform==="win32"){let e=Date.now()+1500;for(;Date.now()<e;);}}function si(){return"2.1.5"}function ai(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 Wa(){return process.env.CODESPACES==="true"||process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN?"GitHub Codespaces":(0,X.existsSync)("/.dockerenv")?"Docker":null}function Qn(){Ga()}async function ci(){try{let e=si();if(!e)return null;let n=await G(mr,{signal:AbortSignal.timeout(ii)});if(!n.ok)return null;let{version:r}=await n.json();return r&&ai(e,r)?{current:e,latest:r}:null}catch{return null}}var qn=Ie.default.join(re.STATE,bt.lockFile);function Va(){try{if((0,X.existsSync)(qn)){let{pid:e,ts:n}=JSON.parse((0,X.readFileSync)(qn,"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,X.writeFileSync)(qn,JSON.stringify({pid:process.pid,ts:Date.now()}))}catch{}return!0}async function Ya(){try{let e=await G(mr,{signal:AbortSignal.timeout(ii)});if(!e.ok)return null;let{version:n}=await e.json();return n||null}catch{return null}}function qa(){try{if(process.env.NREMOTE_REGISTRY)return`--registry ${new URL(process.env.NREMOTE_REGISTRY).origin}`}catch{}return""}function Ja({currentVersion:e,latest:n,agentPid:r}){let o=Yo(),t=qa(),i=je(),s=at(),a=qn,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 :${Jn}') 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=Ie.default.join(At.default.tmpdir(),`${ne}-update.bat`);(0,
|
|
127
|
-
`);let h=Ie.default.join(At.default.tmpdir(),`${ne}-update.vbs`);return(0,
|
|
126
|
+
`,d=Ie.default.join(At.default.tmpdir(),`${ne}-update.bat`);(0,X.writeFileSync)(d,p),(0,X.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,X.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:${Jn} | 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=Ie.default.join(At.default.tmpdir(),`${ne}-update.sh`);return(0,
|
|
166
|
-
`)}function _t(e,n=null){console.log(Mr(e,n))}var
|
|
165
|
+
`,u=Ie.default.join(At.default.tmpdir(),`${ne}-update.sh`);return(0,X.writeFileSync)(u,l,{mode:493}),{shellCmd:["sh",[u]],windowsVerbatim:!1}}async function li(){let e=si();if(!e||Wa())return!1;let n=await Ya();if(!n||!ai(e,n)||!Va())return!1;let{shellCmd:r,windowsVerbatim:o}=Ja({currentVersion:e,latest:n,agentPid:process.pid});return(0,rn.spawn)(r[0],r[1],{detached:!0,stdio:"ignore",windowsHide:!0,windowsVerbatimArguments:o}).unref(),setTimeout(()=>process.exit(0),500),!0}var xi=A(require("os"),1);var er=A(require("readline"),1),pi=A(require("http"),1);var Cr=require("child_process"),Qa={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function Xn(e){let n=Qa[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 ui({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"},di=()=>Math.min(44,process.stdout.columns||44);function Mr(e,n=null){let o=di()-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 fi=["\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"}],Xa=process.platform==="win32",Za=Xa?120:80;process.on("exit",()=>process.stdout.write("\x1B[?25h"));var mi=(e,n)=>{process.stdout.write("\x1B[?25h"),process.listenerCount(e)<=1&&process.exit(n)};process.on("SIGINT",()=>mi("SIGINT",130));process.on("SIGTERM",()=>mi("SIGTERM",143));var $e=0,ct=null,Zn=0,Te=-1,on=null,kt=null,zn=!1;function hi(){let e=[],n=Te===Lr.length-1;return Lr.forEach((r,o)=>{let t=o===Te&&on?on: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=fi[Zn%fi.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 gi(){let e=hi();$e>0&&process.stdout.write(`\x1B[${$e}A\x1B[0J`),process.stdout.write(e.join(`
|
|
167
167
|
`)+`
|
|
168
|
-
`),$e=e.length}function
|
|
168
|
+
`),$e=e.length}function yi(){if($e===0||Te<0)return;let e=hi();if(e.length!==$e){gi();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(){zn||(process.stdout.write("\x1B[?25l"),zn=!0)}function wi(){zn&&(process.stdout.write("\x1B[?25h"),zn=!1)}function vi(e,n=!1,r=null){ct&&(clearInterval(ct),ct=null),Te=e,on=r,Zn=0,n||($e=0),gi(),e<Lr.length-1?(za(),ct=setInterval(()=>{Zn++,yi()},Za)):wi()}function Pt(e){on=e,$e>0&&yi()}function Si(){ct&&(clearInterval(ct),ct=null),wi(),$e=0,Te=-1,on=null,kt=null,Zn=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=(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"),
|
|
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"),er.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): `),er.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 Ei(e,n){return new Promise(r=>{let o=e?e.slice(0,8):"unknown",t=di(),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} `),er.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(w)},500)};process.stdin.on("keypress",c)})}function
|
|
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
|
|
191
|
-
`).find(c=>c.includes(r));if(!t){
|
|
192
|
-
`,"utf8");let s=!1,a=()=>{if(!s){s=!0;try{B.default.rmSync(t,{recursive:!0,force:!0})}catch{}}},c=(0,
|
|
193
|
-
`).slice(-5).join(" | ");u(new Error(`cloudflared exited (code=${T}, signal=${P}) output: ${x||"(empty)"}`)),
|
|
194
|
-
`).map(o=>+o.trim()).filter(Boolean);for(let r of new Set(n))
|
|
195
|
-
${n}`)),
|
|
196
|
-
`+r.trim())})})}async function fr(e,n){let r=await
|
|
189
|
+
`;process.stdout.write(T),setTimeout(()=>{try{a()}catch{}r(w)},500)};process.stdin.on("keypress",c)})}function Ti(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=pi.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 Ri(e){Dr=e}var sn=null;async function Ot(){if(sn)return sn;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 sn=r.find(o=>o==="localhost")||r.find(Boolean)||null,sn||"127.0.0.1"}function bi(){sn=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 bi(),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 bi(),null}}async function U(e){await Z("/api/ui/state",e)}async function K(e,n={}){Dr&&vi(e-1,e>$.PREPARING),await U({step:e,stepDesc:"",...n})}function tr({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 Ai(){let e=xi.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 Tn=require("child_process"),xn=A(require("path"),1),Xr=A(require("fs"),1),ns=require("url");var B=A(require("fs"),1),We=A(require("path"),1),qr=A(require("https"),1),Ve=A(require("os"),1),Di=A(require("net"),1),ft=require("child_process");var ki=A(require("dns"),1),_i=require("child_process");var ec=2e3,tc=5e3,Pi=new ki.default.promises.Resolver;Pi.setServers(["1.1.1.1","1.0.0.1","8.8.8.8"]);function It(){process.platform==="win32"&&(0,_i.execFile)("ipconfig",["/flushdns"],{windowsHide:!0},()=>{})}async function Ur(e,n=ec){let r=Date.now();try{return{ok:!0,addrs:await Promise.race([Pi.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 nr(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(tc)});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 nc=J("tunnel"),an=null,cn=null,$t=null,lt=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 Oi(){if(!cn||Br)return;let e=await nr(cn),n=e.ok?"healthy":"unreachable";if(n===$t){lt=null,Ge=0;return}if(n!==lt){lt=n,Ge=1;return}Ge++,!(Ge<ni)&&(nc.info(`\u{1FA7A} ${$t??"init"} \u2192 ${n}${e.ok?"":` (http=${e.httpStatus??"-"} dns=${e.dnsCode??"-"})`}`),$t=n,lt=null,Ge=0,await Hr({tunnelHealth:{status:n,checkedAt:Date.now()}}))}function Ii(e){if(!e)return ln();e!==cn&&(cn=e,$t=null,lt=null,Ge=0,It(),an||(an=setInterval(Oi,go.checkIntervalMs)),Oi())}var $i=Ii,Ct=Ii;function Ci(){Br=!0}function Li(){Br=!1}function Lt(e){$t=e,lt=null,Ge=0,Hr({tunnelHealth:{status:e,checkedAt:Date.now()}})}function ln(){an&&(clearInterval(an),an=null),cn=null,$t=null,lt=null,Ge=0,Hr({tunnelHealth:{status:"unknown",checkedAt:null}})}var V=J("tunnel"),pn={networkCheckIntervalMs:5e3,networkRestoreDelayMs:2500,internetCheckTimeoutMs:3e3,internetCheckHost:"1.1.1.1",internetCheckPort:443},rc=3e4,jr=0,dn=null,rr=null,mn=null,hn=null,Nt=!1,un=0,Vr=!1,gn=null,or=0,Kr=0,Gr=!1,oc=3e4,ic=5e3,fn=We.default.join(Ve.default.homedir(),".9remote","bin"),Mi="cloudflared",yn=Ve.default.platform()==="win32",sc=yn?`${Mi}.exe`:Mi,Mt=We.default.join(fn,sc),Wr=We.default.join(Ve.default.homedir(),".9remote","cloudflared.pid"),ut=!1,ac="2026.6.1",Fi=`https://github.com/cloudflare/cloudflared/releases/download/${ac}`;function Ui(){return new Promise(e=>{let n=new Di.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 cc(){Vr=!0;try{let e=0;for(;;){if(e++,await Ui())return;await new Promise(n=>setTimeout(n,ye(le.internet,e)))}}finally{Vr=!1}}async function wn(e,n){if(!hn){V.warn("\u26A0\uFE0F No restartCallback registered \u2014 skip");return}if(Nt){V.info(`\u23ED restart already in flight, skip (${n})`);return}if(Date.now()-Kr<ic){V.info(`\u23ED restart debounced, skip (${n})`);return}Kr=Date.now(),Nt=!0;try{await cc();let r=ye(le.tunnelRestart,un+1);await new Promise(o=>setTimeout(o,r)),await hn(e),un=0,Kr=0}catch(r){un++,V.error(`\u274C restart failed (#${un}): ${r?.message||r}`),setImmediate(()=>{Nt=!1,wn(e,"retry after fail")});return}finally{Nt=!1}}var lc={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 uc(){let e=Ve.default.platform(),n=Ve.default.arch(),r=lc[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`${Fi}/${o}`}var fc=150;async function Bi(e,n,r){return new Promise((o,t)=>{let i=B.default.createWriteStream(n);qr.default.get(e,s=>{if([301,302].includes(s.statusCode)){i.close(),B.default.unlinkSync(n),Bi(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>=fc&&(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 vn(e){if(B.default.existsSync(fn)||B.default.mkdirSync(fn,{recursive:!0}),B.default.existsSync(Mt))return yn||B.default.chmodSync(Mt,"755"),Mt;let n=uc(),r=n.endsWith(".tgz"),o=r?We.default.join(fn,"cloudflared.tgz"):Mt;try{return e?.({phase:"download",percent:0}),await Bi(n,o,t=>{e?.({phase:"download",percent:t})}),await pc(n,o),r&&(e?.({phase:"extract"}),(0,ft.execSync)(`tar -xzf "${o}" -C "${fn}"`,{stdio:"pipe",windowsHide:!0}),B.default.unlinkSync(o)),yn||B.default.chmodSync(Mt,"755"),Mt}catch(t){try{B.default.existsSync(o)&&B.default.unlinkSync(o)}catch{}throw console.error("\u274C Failed to download cloudflared:",t.message),t}}function Hi(e){return new Promise((n,r)=>{qr.default.get(e,o=>{if([301,302].includes(o.statusCode))return Hi(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 pc(e,n){let r=We.default.basename(e),o;try{o=await Hi(`${Fi}/sha256sum.txt`)}catch(c){V.warn(`\u26A0\uFE0F sha256 manifest unavailable (${c.message}), skipping verify`);return}let t=o.split(`
|
|
191
|
+
`).find(c=>c.includes(r));if(!t){V.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})`);V.info("\u2713 cloudflared SHA256 verified")}function dc(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 ji(e,n=null,r=null){let o=await vn();r&&(hn=r),mn=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,ft.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),ut=!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=dc(P);if(x){if(!f){f=!0,p=x,gn=x,or=Date.now(),clearTimeout(h),a(),gc(),V.info(`\u2705 tunnel ready: ${x}`),l({child:c,tunnelUrl:x});return}x!==p&&(V.info(`\u{1F504} URL rotated: ${x}`),p=x,gn=x,or=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(),V.info(`\u{1F4A5} cloudflared exit pid=${c.pid} code=${T} signal=${P} intentional=${ut}`),ut||Lt("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)"}`)),ut||wn(e,`initial spawn failed (code ${T})`);return}ut||wn(e,`quick tunnel exit code ${T}`)})})}function Yr(e){if(yn)try{(0,ft.execSync)(`taskkill /PID ${e} /T /F`,{windowsHide:!0,stdio:"ignore"})}catch{}else try{process.kill(e,"SIGKILL")}catch{}}function mc(e){try{let n=[];if(yn){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,ft.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,ft.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))Yr(r),V.info(`\u2705 killed orphan cloudflared pid=${r}`)}catch{}}function Ye(){if(!Gr){Gr=!0;try{try{if(B.default.existsSync(Wr)){let n=parseInt(B.default.readFileSync(Wr,"utf8"));Number.isFinite(n)&&(ut=!0,Yr(n)),B.default.unlinkSync(Wr)}}catch{}let e=Kn("cloudflared");ut=!0,e&&(Yr(e),V.info("\u2705 Cloudflared killed"),He("cloudflared")),mc(O)}finally{setTimeout(()=>{Gr=!1},2e3)}}}function Ki(){un=0,Nt=!1,hn=null,mn=null,gn=null,yc()}var hc=/^(utun|awdl|llw|anpi|bridge|gif|stf|ipsec|ap|tun|tap|vmnet|veth|docker)/i;function Ni(){let e=Ve.default.networkInterfaces(),n=[];for(let[r,o]of Object.entries(e))if(o&&!hc.test(r))for(let t of o)!t.internal&&t.family==="IPv4"&&n.push(`${r}:${t.address}`);return n.sort().join("|")}function gc(){dn||(rr=Ni(),jr=Date.now(),dn=setInterval(async()=>{let e=Date.now(),n=e-jr;if(jr=e,Vr||Nt||!hn||mn==null)return;if(n>rc){V.info(`\u{1F4A4} Sleep/wake detected (gap=${n}ms) \u2192 restart tunnel`),Lt("unreachable"),Ye(),wn(mn,"woke from sleep");return}let r=Ni(),o=r!==rr;rr=r;let t=Kn("cloudflared"),i=!t||!Wo(t);if(!(!o&&!i)){if(o&&!i&&or&&Date.now()-or<oc){V.info("\u23F8 Network change in cooldown, skip");return}if(o&&V.info("\u{1F504} Network change detected"),i&&V.info("\u{1F50D} Liveness watchdog: cloudflared not alive"),Lt("unreachable"),await new Promise(s=>setTimeout(s,pn.networkRestoreDelayMs)),!!await Ui()){if(o&&!i&&gn){let s=!1;for(let a=0;a<2;a++){if((await nr(gn)).ok){s=!0;break}a===0&&await new Promise(l=>setTimeout(l,2e3))}if(s){V.info("\u2705 Tunnel survived network change, skip restart");return}}o&&!i&&Ye(),wn(mn,o?"network change":"liveness watchdog")}}},pn.networkCheckIntervalMs))}function yc(){dn&&(clearInterval(dn),dn=null),rr=null}Ut();var Le=J("server"),rs=xn.default.dirname((0,ns.fileURLToPath)(__importMetaUrl)),xc=xn.default.resolve(rs,"./server.cjs"),es=xn.default.resolve(rs,"../../index.js");function ar(e){try{process.platform==="win32"?(0,Tn.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${e}') do taskkill /F /PID %a`,{stdio:"ignore",windowsHide:!0}):(0,Tn.execSync)(`lsof -ti:${e} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function qe(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"&&Xr.default.existsSync(es),u=l?es:xc;Xr.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,Tn.spawn)("node",[u],{cwd:xn.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{Ye()}catch{}try{Sn()}catch{}try{ar(O)}catch{}try{Ki()}catch{}try{To()}catch{}try{He("agent")}catch{}try{He("cloudflared")}catch{}r&&setTimeout(()=>process.exit(o),ei)}var ts=!1;function Je(e,n){if(ts)return;ts=!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)})}Ut();var Zr=J("tunnel");async function dt(e,n,r){let o=0;for(;;){o++;try{return await ji(e,n,r)}catch(t){let i=ye(le.tunnelSpawn,o);Zr.warn(`\u26A0\uFE0F spawn attempt ${o} failed: ${t?.message||t} \u2014 retry in ${i}ms`),await new Promise(s=>setTimeout(s,i))}}}function Bt({onUrlUpdate:e,setTunnel:n}){return async r=>{try{let o=await dt(r,e);n(o.child),await e(o.tunnelUrl),Zr.info(`\u2705 Tunnel restarted: ${o.tunnelUrl}`)}catch(o){Zr.error(`\u274C Tunnel restart failed: ${o?.message||o}`)}}}async function Qe(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 bn=J("tunnel"),zr=null,os=null,is=0;async function Me(e,n){if(n&&n===os&&Date.now()-is<ti){bn.info(`\u23ED urlSync debounced (same URL): ${n}`);return}zr&&(zr.cancelled=!0);let r={cancelled:!1};zr=r;let o=Ai();ui({config:le.urlSync,label:`urlSync ${n}`,log:t=>bn.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 os=n,is=Date.now(),bn.info("\u2705 urlSync ok"),Rc(n),!0;let i=await t.text().catch(()=>"");return bn.warn(`\u26A0\uFE0F urlSync HTTP ${t.status}: ${i.slice(0,200)}`),!1}}),n&&$i(n)}var Rn=null;async function Rc(e){if(Rn?.url===e)return;let n={url:e};Rn=n,Ci();try{let r=await Qe(e,{timeoutMs:ri});if(Rn!==n)return;r&&(Lt("healthy"),bn.info("\u2705 fast probe healthy"))}catch{}finally{Rn===n&&(Rn=null),Li()}}var io=A(Ps(),1);var Cc=30;async function Ht(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:Cc})});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 Lc(e,n="\u{1F4F1} Scan QR to connect:"){console.log(fe.orange(`
|
|
195
|
+
${n}`)),io.default.generate(e,{small:!0,type:"terminal",margin:0},r=>{console.log(r.trim())})}function Mc(e){return new Promise(n=>{io.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 Ht(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}),Lc(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 An(e,n,r,o=""){let t=Math.min(Oe.headerWidth,process.stdout.columns||Oe.headerWidth),i=[];return e&&r?(i.push(await Mc(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=
|
|
204
|
-
\u{1F310} UI ready at ${i}`));let s=null;await U({permanentKey:e.key,step:$.STOPPED,theme:r}),
|
|
202
|
+
`)),i.push(fe.orange("\u2550".repeat(t)),m.white("App URL".padEnd(14))+m.gray(`${D}/login`)),mo.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=J("cmd");function ze(e,n,r){let o=!1;setInterval(async()=>{if(o)return;let t=xo();if(t){o=!0;try{if(t==="stop-tunnel")await Os(e,n);else if(t==="restart-tunnel")await Os(e,n),await Is(e,n,r);else if(t==="start-tunnel"){if(await Is(e,n,r)==="alreadyRunning"){o=!1;return}}else t==="regenerate-key"?await Nc():t==="shutdown"?Dc(e,n):t==="update"&&await li()}finally{o=!1}}},ge.cmdMs)}async function Os(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 Is(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 vn(tr),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,Bt({onUrlUpdate:i,setTunnel:c=>n(c)}));n(s.child),await K($.VERIFYING),await Qe(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 Nc(){let e=await vt(),{key:n}=St(e),r=Nn();rt(e,n,r?.name||"Default"),await U({permanentKey:n}),ht.info(`\u2705 Key regenerated: ${$n(n)}`)}function Dc(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 $s(){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:()=>{}}:qe(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}),Je(t,null),ze(()=>s,a=>{s=a},e.key),process.argv.includes("--start")&&Et("start-tunnel"),await new Promise(()=>{})}Ut();async function Cs(){Be("agent",process.pid),Zo().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:()=>{}}:qe(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})};Je(t,null),ze(()=>s,l=>{s=l},e.key);try{He("cloudflared")}catch{}process.argv.includes("--start")&&Et("start-tunnel"),await Jr({port:O,onQuit:a,onOpenUI:()=>En(i)})&&Qr({title:"9Remote is running",message:`Open ${i} or use the tray icon to manage.`}),await new Promise(()=>{})}var et=J("mode");async function Fc(e){et.info("\u{1F680} Starting server..."),await K($.PREPARING);try{Ye(),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 et.error(`\u274C Session create failed: ${s.status}`),null}catch(s){return et.error(`\u274C Session create failed: ${s.message}`),null}let n=await ie(),r=n?{getProcess:()=>null,shutdown:()=>{}}:qe(null,null);n||await new Promise(s=>setTimeout(s,oe.serverBootMs)),et.info("\u2705 Starting tunnel..."),await K($.CONNECTING);let o={current:null},t,i=async s=>{et.info(`\u{1F504} Tunnel URL rotated: ${s}`),await Me(e,s),U({tunnelUrl:s}),Ct(s)};try{let s=await dt(O,i,Bt({onUrlUpdate:i,setTunnel:a=>{o.current=a}}));o.current=s.child,t=s.tunnelUrl}catch(s){return et.error(`\u274C Failed to start tunnel: ${s.message}`),r.shutdown(),null}return await Qe(t)||et.warn("\u26A0\uFE0F Tunnel health check timed out, proceeding anyway..."),await Me(e,t),Mn({apiKey:e,tunnelUrl:t,serverPid:r.getProcess()?.pid,tunnelPid:o.current?.pid}),{serverManager:r,tunnelRef:o,tunnelUrl:t}}async function Ls(){_t(Se());let e=await Ue();et.info(`Using key: ${$n(e.key)} (${e.name})`);let n=await Fc(e.key);n||process.exit(1);let{serverManager:r,tunnelRef:o,tunnelUrl:t}=n;await fr(e.key,t),Je(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 Ms=A(require("path"),1),Ns=A(require("fs"),1);Ut();async function Ds(){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{Ns.default.mkdirSync(Ms.default.dirname(o),{recursive:!0})}catch{}let t=null;try{t=Qo(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"),En(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 Fs=A(require("readline"),1);var so=J("mode"),jt=null;async function Us(){console.clear(),Si(),Ri(!0),await K($.PREPARING);let e=await Ue(),n=null,r={getProcess:()=>null,shutdown:()=>{}};if(!await ie()){r=qe(null,null,()=>{if(process.stdin.isTTY){try{process.stdin.setRawMode(!1)}catch{}try{process.stdin.setRawMode(!0),process.stdin.resume()}catch{}}try{Fs.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{Ye(),await new Promise(S=>setTimeout(S,oe.killCloudflaredTuiMs))}catch{}await vn(tr),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){so.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,Bt({onUrlUpdate:a,setTunnel:g=>{s.current=g}}));t=S.child,i=S.tunnelUrl,s.current=t}catch(S){so.error(`\u274C Tunnel failed: ${S.message}`),process.exit(1)}await K($.VERIFYING),await Qe(i)||so.warn("\u26A0\uFE0F Tunnel health check timed out, proceeding anyway..."),await Me(e.key,i),Mn({apiKey:e.key,tunnelUrl:i,tunnelPid:t.pid});let c=await Ht(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 An(u,e.key,f,p),h=[],w=!1,T=()=>{w||n?.()},P=async(S,g,_)=>{if(!w){w=!0;try{let I=await Ei(g,_);await Z(`/api/device/${I?"approve":"reject"}`,{socketId:S})}catch{}finally{w=!1,n?.()}}},x=Ti(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 An(u,e.key,f,p),T())}else S==="permissions"||S==="autostart"||S==="sleepInhibit"?(w||jt?.(),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);Je({getProcess:r.getProcess,shutdown:()=>{r.shutdown(),x(),clearInterval(b)}},t),ze(()=>s.current,S=>{s.current=S},e.key),await Uc(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 Uc(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(()=>(Ut(),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 Bc(e,n,o,r);else if(d==="desktop")await Kc();else if(d==="devices")await Gc();else if(d==="settings")await jc();else if(d==="logs")await Wc();else{try{i?.()}catch{}console.log(m.gray(`
|
|
212
212
|
Goodbye!
|
|
213
|
-
`)),process.exit(0)}}}async function
|
|
213
|
+
`)),process.exit(0)}}}async function Bc(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 Ht(e.key,D);if(a){let c=`${D}/login?k=${a.tempKey}`;r(await An(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=rt(c,l,e.name||"Default");Object.assign(e,u),await U({permanentKey:e.key});let f=await Ht(e.key,D);if(f){let p=`${D}/login?k=${f.tempKey}`;r(await An(f.tempKey,e.key,p,n)),await U({oneTimeKey:f.tempKey,oneTimeKeyExpiresAt:f.expiresAt,qrUrl:p})}}}var Bs={"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 Hc(e,n){let r=n.map(s=>({label:Bs[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 jc(){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(Bs[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(),jt=s;let a=await xe("Settings",t,0,"",l=>{i=l});jt=null;let c=a>=0?t[a].action:"back";if(c==="autostart")await Z("/api/autostart",{enabled:!e});else if(c==="sleep")await Hc(n,r);else return}}async function Kc(){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(),jt=i;let s=await xe("Remote Desktop",o,0,"",a=>{t=a});if(jt=null,s===0)await Z("/api/desktop/toggle",{enabled:!e});else if(s===1&&!n.screenRecording)await Z("/api/permissions/request",{type:"screenRecording"})||Xn("screenRecording");else if(s===2&&!n.accessibility)await Z("/api/permissions/request",{type:"accessibility"})||Xn("accessibility");else if(s===3||s===-1)return}}async function Gc(){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 Wc(){let e=Io(po),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 Hs(){let e=Se(),n=await ci(),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 Ds():i==="tui"?await Us():process.exit(0)}var js=[["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 ao(){_t(Se()),console.log(m.white.bold(`
|
|
222
222
|
Usage:
|
|
223
|
-
`));let e=Math.max(...
|
|
223
|
+
`));let e=Math.max(...js.map(([n])=>n.length))+2;for(let[n,r]of js)console.log(" "+m.cyan(n.padEnd(e))+m.gray(r));console.log()}async function kn(){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 Vc(e){if(!await kn())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 Yc(){if(!await kn())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 qc(){if(!await kn())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 Jc(e){if(!await kn())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 kn())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 Ks(e){let n=e[2],r=e.slice(3);switch(n){case"help":case"-h":case"--help":return ao(),!0;case"key":return await Vc(r.includes("--new")),!0;case"otk":return await Yc(),!0;case"devices":return await qc(),!0;case"auto-approve":return await Jc(r[0]),!0;case"approve":return await Qc(r[0]),!0;default:return!1}}var co=process.argv[2];(co==="version"||co==="--version"||co==="-v")&&(process.stdout.write(Se()+`
|
|
253
|
+
`),process.exit(0));Oo();async function Xc(){let e=process.argv[2];if(await Ks(process.argv))return;process.argv.includes("--tray")||process.argv.includes("--auto")||process.argv.includes("--start")||Qn(),e==="ui"?await $s():e==="start"||process.argv.includes("--auto")?await Ls():process.argv.includes("--tray")||process.argv.includes("--start")?await Cs():process.stdin.isTTY?await Hs():ao()}Xc().catch(console.error);
|