9remote 0.1.62 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/cli/index.js +6 -4
- package/dist/cli.cjs +28 -74
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 9remote
|
|
4
|
+
|
|
5
|
+
**Your Mac/Linux terminal in your pocket — anywhere, instantly**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/9remote)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://www.npmjs.com/package/9remote)
|
|
10
|
+
|
|
11
|
+
[🌐 Web App](https://9remote.cc) • [📖 Docs](https://docs.9remote.cc) • [🚀 Get Started](#-quick-start)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Why 9remote?
|
|
18
|
+
|
|
19
|
+
- ❌ **SSH is a hassle** — need to open firewall, configure port forwarding, manage keys
|
|
20
|
+
- ❌ **VPN is overkill** — too complex to set up just to check a terminal
|
|
21
|
+
- ❌ **ngrok / tunnels expire** — lose connection, have to restart everything
|
|
22
|
+
|
|
23
|
+
**9remote solves it:**
|
|
24
|
+
- ✅ **One command** — `npx 9remote`, scan QR, done
|
|
25
|
+
- ✅ **Auto tunnel** — Cloudflare tunnel starts automatically, no port forwarding
|
|
26
|
+
- ✅ **Works on phone** — full terminal from your browser, under 50ms latency
|
|
27
|
+
- ✅ **Remote Desktop** — view and control your screen, mouse & keyboard
|
|
28
|
+
- ✅ **Persistent sessions** — PTY daemon survives server restarts
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ⚡ Quick Start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx 9remote
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Scan the QR code on your phone → you're in.
|
|
39
|
+
|
|
40
|
+
Or install globally:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install -g 9remote
|
|
44
|
+
9remote
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
> **Ready in 30 seconds. No config needed.**
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## ✨ Features
|
|
52
|
+
|
|
53
|
+
- 🖥️ **Remote Terminal** — Full PTY shell, always on, persistent across reconnects
|
|
54
|
+
- 🖱️ **Remote Desktop** — Live screen streaming via WebRTC + mouse/keyboard control
|
|
55
|
+
- 📁 **File Explorer** — Browse, upload, download files from your browser
|
|
56
|
+
- 📱 **QR Login** — One-time key (30 min) for quick mobile access
|
|
57
|
+
- 🔒 **E2E Secure** — All traffic through Cloudflare tunnel, no open ports
|
|
58
|
+
- 🔄 **Auto Restart** — Server + tunnel auto-recover on crash
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 📖 CLI Commands
|
|
63
|
+
|
|
64
|
+
| Command | Description |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `9remote` | TUI mode — interactive menu with QR |
|
|
67
|
+
| `9remote ui` | Web UI mode — open browser dashboard |
|
|
68
|
+
| `9remote start` | Auto start server + tunnel (headless) |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
<details>
|
|
73
|
+
<summary><b>🔧 How it works</b></summary>
|
|
74
|
+
|
|
75
|
+
1. **Start** — `9remote` spawns a local server on port `2208`
|
|
76
|
+
2. **Tunnel** — A Cloudflare Quick Tunnel is created automatically (no account needed)
|
|
77
|
+
3. **QR** — A one-time login link is generated and shown as QR code
|
|
78
|
+
4. **Connect** — Scan from your phone → authenticated session via [9remote.cc](https://9remote.cc)
|
|
79
|
+
5. **Transport** — Terminal uses WebSocket; Remote Desktop uses WebRTC DataChannel for low latency
|
|
80
|
+
|
|
81
|
+
</details>
|
|
82
|
+
|
|
83
|
+
<details>
|
|
84
|
+
<summary><b>📡 Remote Desktop</b></summary>
|
|
85
|
+
|
|
86
|
+
- Screen streaming via WebRTC (adaptive: 60ms active / 400ms idle)
|
|
87
|
+
- Tile-based diff rendering — only changed regions are sent
|
|
88
|
+
- Mouse & keyboard control via `robotjs`
|
|
89
|
+
- Requires macOS permissions: **Screen Recording** + **Accessibility**
|
|
90
|
+
|
|
91
|
+
Enable from TUI menu: `Remote Desktop → Toggle ON`
|
|
92
|
+
|
|
93
|
+
</details>
|
|
94
|
+
|
|
95
|
+
<details>
|
|
96
|
+
<summary><b>🔑 Keys & Security</b></summary>
|
|
97
|
+
|
|
98
|
+
- **Permanent Key** — stored locally, tied to your machine ID
|
|
99
|
+
- **One-Time Key** — 30-minute temporary key for quick phone access
|
|
100
|
+
- Keys are never stored on our servers after session ends
|
|
101
|
+
- Regenerate your key anytime from the TUI menu
|
|
102
|
+
|
|
103
|
+
</details>
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 🛠️ Built With
|
|
108
|
+
|
|
109
|
+
- [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) — Zero-config secure tunnel
|
|
110
|
+
- [node-datachannel](https://github.com/murat-dogan/node-datachannel) — WebRTC for low-latency desktop streaming
|
|
111
|
+
- [node-pty](https://github.com/microsoft/node-pty) — Persistent PTY terminal sessions
|
|
112
|
+
- [Socket.IO](https://socket.io/) — Real-time terminal + signaling
|
|
113
|
+
- [Preact](https://preactjs.com/) — Lightweight Web UI
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 📝 License
|
|
118
|
+
|
|
119
|
+
MIT © [9remote](https://github.com/decolua/9remote)
|
package/cli/index.js
CHANGED
|
@@ -709,7 +709,9 @@ async function autoStartDev() {
|
|
|
709
709
|
|
|
710
710
|
await showConnectionInfo(keyData.key, tunnelUrl);
|
|
711
711
|
setupExitHandler(serverManager, tunnelProcess, keyData.key);
|
|
712
|
-
|
|
712
|
+
|
|
713
|
+
let activeTunnel = tunnelProcess;
|
|
714
|
+
setupCmdPoller(() => activeTunnel, (t) => { activeTunnel = t; }, keyData.key);
|
|
713
715
|
|
|
714
716
|
// Push stats to UI every 5s
|
|
715
717
|
const startTime = Date.now();
|
|
@@ -857,9 +859,9 @@ async function startUiMode() {
|
|
|
857
859
|
|
|
858
860
|
// Start app
|
|
859
861
|
async function start() {
|
|
860
|
-
//
|
|
861
|
-
const hasUpdate = await checkAndUpdate(skipUpdate);
|
|
862
|
-
if (hasUpdate) return;
|
|
862
|
+
// Disable auto-update - TUI already shows update notification
|
|
863
|
+
// const hasUpdate = await checkAndUpdate(skipUpdate);
|
|
864
|
+
// if (hasUpdate) return;
|
|
863
865
|
|
|
864
866
|
const command = process.argv[2];
|
|
865
867
|
|
package/dist/cli.cjs
CHANGED
|
@@ -1,83 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const __importMetaUrl = require('url').pathToFileURL(__filename).href;
|
|
3
|
-
var Zn=Object.create;var Dt=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var V=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports);var or=(r,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of tr(n))!rr.call(r,e)&&e!==t&&Dt(r,e,{get:()=>n[e],enumerable:!(o=er(n,e))||o.enumerable});return r};var M=(r,n,t)=>(t=r!=null?Zn(nr(r)):{},or(n||!r||!r.__esModule?Dt(t,"default",{value:r,enumerable:!0}):t,r));var dt=V((wo,qt)=>{qt.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var Zt=V((To,zt)=>{var wr=dt();function Xt(r){this.mode=wr.MODE_8BIT_BYTE,this.data=r}Xt.prototype={getLength:function(){return this.data.length},write:function(r){for(var n=0;n<this.data.length;n++)r.put(this.data.charCodeAt(n),8)}};zt.exports=Xt});var mt=V((Eo,en)=>{var ee={glog:function(r){if(r<1)throw new Error("glog("+r+")");return ee.LOG_TABLE[r]},gexp:function(r){for(;r<0;)r+=255;for(;r>=256;)r-=255;return ee.EXP_TABLE[r]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for($=0;$<8;$++)ee.EXP_TABLE[$]=1<<$;var $;for($=8;$<256;$++)ee.EXP_TABLE[$]=ee.EXP_TABLE[$-4]^ee.EXP_TABLE[$-5]^ee.EXP_TABLE[$-6]^ee.EXP_TABLE[$-8];var $;for($=0;$<255;$++)ee.LOG_TABLE[ee.EXP_TABLE[$]]=$;var $;en.exports=ee});var gt=V((bo,tn)=>{var pe=mt();function Ye(r,n){if(r.length===void 0)throw new Error(r.length+"/"+n);for(var t=0;t<r.length&&r[t]===0;)t++;this.num=new Array(r.length-t+n);for(var o=0;o<r.length-t;o++)this.num[o]=r[o+t]}Ye.prototype={get:function(r){return this.num[r]},getLength:function(){return this.num.length},multiply:function(r){for(var n=new Array(this.getLength()+r.getLength()-1),t=0;t<this.getLength();t++)for(var o=0;o<r.getLength();o++)n[t+o]^=pe.gexp(pe.glog(this.get(t))+pe.glog(r.get(o)));return new Ye(n,0)},mod:function(r){if(this.getLength()-r.getLength()<0)return this;for(var n=pe.glog(this.get(0))-pe.glog(r.get(0)),t=new Array(this.getLength()),o=0;o<this.getLength();o++)t[o]=this.get(o);for(var e=0;e<r.getLength();e++)t[e]^=pe.gexp(pe.glog(r.get(e))+n);return new Ye(t,0).mod(r)}};tn.exports=Ye});var rn=V((_o,nn)=>{nn.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var an=V((xo,sn)=>{var q=dt(),on=gt(),Tr=mt(),ce=rn(),j={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(r){for(var n=r<<10;j.getBCHDigit(n)-j.getBCHDigit(j.G15)>=0;)n^=j.G15<<j.getBCHDigit(n)-j.getBCHDigit(j.G15);return(r<<10|n)^j.G15_MASK},getBCHTypeNumber:function(r){for(var n=r<<12;j.getBCHDigit(n)-j.getBCHDigit(j.G18)>=0;)n^=j.G18<<j.getBCHDigit(n)-j.getBCHDigit(j.G18);return r<<12|n},getBCHDigit:function(r){for(var n=0;r!==0;)n++,r>>>=1;return n},getPatternPosition:function(r){return j.PATTERN_POSITION_TABLE[r-1]},getMask:function(r,n,t){switch(r){case ce.PATTERN000:return(n+t)%2===0;case ce.PATTERN001:return n%2===0;case ce.PATTERN010:return t%3===0;case ce.PATTERN011:return(n+t)%3===0;case ce.PATTERN100:return(Math.floor(n/2)+Math.floor(t/3))%2===0;case ce.PATTERN101:return n*t%2+n*t%3===0;case ce.PATTERN110:return(n*t%2+n*t%3)%2===0;case ce.PATTERN111:return(n*t%3+(n+t)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}},getErrorCorrectPolynomial:function(r){for(var n=new on([1],0),t=0;t<r;t++)n=n.multiply(new on([1,Tr.gexp(t)],0));return n},getLengthInBits:function(r,n){if(1<=n&&n<10)switch(r){case q.MODE_NUMBER:return 10;case q.MODE_ALPHA_NUM:return 9;case q.MODE_8BIT_BYTE:return 8;case q.MODE_KANJI:return 8;default:throw new Error("mode:"+r)}else if(n<27)switch(r){case q.MODE_NUMBER:return 12;case q.MODE_ALPHA_NUM:return 11;case q.MODE_8BIT_BYTE:return 16;case q.MODE_KANJI:return 10;default:throw new Error("mode:"+r)}else if(n<41)switch(r){case q.MODE_NUMBER:return 14;case q.MODE_ALPHA_NUM:return 13;case q.MODE_8BIT_BYTE:return 16;case q.MODE_KANJI:return 12;default:throw new Error("mode:"+r)}else throw new Error("type:"+n)},getLostPoint:function(r){var n=r.getModuleCount(),t=0,o=0,e=0;for(o=0;o<n;o++)for(e=0;e<n;e++){for(var i=0,s=r.isDark(o,e),a=-1;a<=1;a++)if(!(o+a<0||n<=o+a))for(var c=-1;c<=1;c++)e+c<0||n<=e+c||a===0&&c===0||s===r.isDark(o+a,e+c)&&i++;i>5&&(t+=3+i-5)}for(o=0;o<n-1;o++)for(e=0;e<n-1;e++){var l=0;r.isDark(o,e)&&l++,r.isDark(o+1,e)&&l++,r.isDark(o,e+1)&&l++,r.isDark(o+1,e+1)&&l++,(l===0||l===4)&&(t+=3)}for(o=0;o<n;o++)for(e=0;e<n-6;e++)r.isDark(o,e)&&!r.isDark(o,e+1)&&r.isDark(o,e+2)&&r.isDark(o,e+3)&&r.isDark(o,e+4)&&!r.isDark(o,e+5)&&r.isDark(o,e+6)&&(t+=40);for(e=0;e<n;e++)for(o=0;o<n-6;o++)r.isDark(o,e)&&!r.isDark(o+1,e)&&r.isDark(o+2,e)&&r.isDark(o+3,e)&&r.isDark(o+4,e)&&!r.isDark(o+5,e)&&r.isDark(o+6,e)&&(t+=40);var u=0;for(e=0;e<n;e++)for(o=0;o<n;o++)r.isDark(o,e)&&u++;var f=Math.abs(100*u/n/n-50)/5;return t+=f*10,t}};sn.exports=j});var yt=V((So,cn)=>{cn.exports={L:1,M:0,Q:3,H:2}});var un=V((ko,ln)=>{var Ve=yt();function re(r,n){this.totalCount=r,this.dataCount=n}re.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]];re.getRSBlocks=function(r,n){var t=re.getRsBlockTable(r,n);if(t===void 0)throw new Error("bad rs block @ typeNumber:"+r+"/errorCorrectLevel:"+n);for(var o=t.length/3,e=[],i=0;i<o;i++)for(var s=t[i*3+0],a=t[i*3+1],c=t[i*3+2],l=0;l<s;l++)e.push(new re(a,c));return e};re.getRsBlockTable=function(r,n){switch(n){case Ve.L:return re.RS_BLOCK_TABLE[(r-1)*4+0];case Ve.M:return re.RS_BLOCK_TABLE[(r-1)*4+1];case Ve.Q:return re.RS_BLOCK_TABLE[(r-1)*4+2];case Ve.H:return re.RS_BLOCK_TABLE[(r-1)*4+3];default:return}};ln.exports=re});var hn=V((Ro,pn)=>{function fn(){this.buffer=[],this.length=0}fn.prototype={get:function(r){var n=Math.floor(r/8);return(this.buffer[n]>>>7-r%8&1)==1},put:function(r,n){for(var t=0;t<n;t++)this.putBit((r>>>n-t-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(r){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),r&&(this.buffer[n]|=128>>>this.length%8),this.length++}};pn.exports=fn});var yn=V((Ao,gn)=>{var Er=Zt(),le=an(),br=gt(),dn=un(),mn=hn();function oe(r,n){this.typeNumber=r,this.errorCorrectLevel=n,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}oe.prototype={addData:function(r){var n=new Er(r);this.dataList.push(n),this.dataCache=null},isDark:function(r,n){if(r<0||this.moduleCount<=r||n<0||this.moduleCount<=n)throw new Error(r+","+n);return this.modules[r][n]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var r=1;for(r=1;r<40;r++){for(var n=dn.getRSBlocks(r,this.errorCorrectLevel),t=new mn,o=0,e=0;e<n.length;e++)o+=n[e].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];t.put(s.mode,4),t.put(s.getLength(),le.getLengthInBits(s.mode,r)),s.write(t)}if(t.getLengthInBits()<=o*8)break}this.typeNumber=r}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(r,n){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var t=0;t<this.moduleCount;t++){this.modules[t]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[t][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(r,n),this.typeNumber>=7&&this.setupTypeNumber(r),this.dataCache===null&&(this.dataCache=oe.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,n)},setupPositionProbePattern:function(r,n){for(var t=-1;t<=7;t++)if(!(r+t<=-1||this.moduleCount<=r+t))for(var o=-1;o<=7;o++)n+o<=-1||this.moduleCount<=n+o||(0<=t&&t<=6&&(o===0||o===6)||0<=o&&o<=6&&(t===0||t===6)||2<=t&&t<=4&&2<=o&&o<=4?this.modules[r+t][n+o]=!0:this.modules[r+t][n+o]=!1)},getBestMaskPattern:function(){for(var r=0,n=0,t=0;t<8;t++){this.makeImpl(!0,t);var o=le.getLostPoint(this);(t===0||r>o)&&(r=o,n=t)}return n},createMovieClip:function(r,n,t){var o=r.createEmptyMovieClip(n,t),e=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*e,a=0;a<this.modules[i].length;a++){var c=a*e,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+e,s),o.lineTo(c+e,s+e),o.lineTo(c,s+e),o.endFill())}return o},setupTimingPattern:function(){for(var r=8;r<this.moduleCount-8;r++)this.modules[r][6]===null&&(this.modules[r][6]=r%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 r=le.getPatternPosition(this.typeNumber),n=0;n<r.length;n++)for(var t=0;t<r.length;t++){var o=r[n],e=r[t];if(this.modules[o][e]===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][e+s]=!0:this.modules[o+i][e+s]=!1}},setupTypeNumber:function(r){for(var n=le.getBCHTypeNumber(this.typeNumber),t,o=0;o<18;o++)t=!r&&(n>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=t;for(var e=0;e<18;e++)t=!r&&(n>>e&1)===1,this.modules[e%3+this.moduleCount-8-3][Math.floor(e/3)]=t},setupTypeInfo:function(r,n){for(var t=this.errorCorrectLevel<<3|n,o=le.getBCHTypeInfo(t),e,i=0;i<15;i++)e=!r&&(o>>i&1)===1,i<6?this.modules[i][8]=e:i<8?this.modules[i+1][8]=e:this.modules[this.moduleCount-15+i][8]=e;for(var s=0;s<15;s++)e=!r&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=e:s<9?this.modules[8][15-s-1+1]=e:this.modules[8][15-s-1]=e;this.modules[this.moduleCount-8][8]=!r},mapData:function(r,n){for(var t=-1,o=this.moduleCount-1,e=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<r.length&&(c=(r[i]>>>e&1)===1);var l=le.getMask(n,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,e--,e===-1&&(i++,e=7)}if(o+=t,o<0||this.moduleCount<=o){o-=t,t=-t;break}}}};oe.PAD0=236;oe.PAD1=17;oe.createData=function(r,n,t){for(var o=dn.getRSBlocks(r,n),e=new mn,i=0;i<t.length;i++){var s=t[i];e.put(s.mode,4),e.put(s.getLength(),le.getLengthInBits(s.mode,r)),s.write(e)}for(var a=0,c=0;c<o.length;c++)a+=o[c].dataCount;if(e.getLengthInBits()>a*8)throw new Error("code length overflow. ("+e.getLengthInBits()+">"+a*8+")");for(e.getLengthInBits()+4<=a*8&&e.put(0,4);e.getLengthInBits()%8!==0;)e.putBit(!1);for(;!(e.getLengthInBits()>=a*8||(e.put(oe.PAD0,8),e.getLengthInBits()>=a*8));)e.put(oe.PAD1,8);return oe.createBytes(e,o)};oe.createBytes=function(r,n){for(var t=0,o=0,e=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),e=Math.max(e,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&r.buffer[u+t];t+=c;var f=le.getErrorCorrectPolynomial(l),h=new br(i[a],f.getLength()-1),d=h.mod(f);s[a]=new Array(f.getLength()-1);for(var p=0;p<s[a].length;p++){var g=p+d.getLength()-s[a].length;s[a][p]=g>=0?d.get(g):0}}for(var T=0,k=0;k<n.length;k++)T+=n[k].totalCount;for(var _=new Array(T),x=0,b=0;b<o;b++)for(var A=0;A<n.length;A++)b<i[A].length&&(_[x++]=i[A][b]);for(var w=0;w<e;w++)for(var R=0;R<n.length;R++)w<s[R].length&&(_[x++]=s[R][w]);return _};gn.exports=oe});var Tn=V((Oo,wn)=>{var _r=yn(),vn=yt(),xr="\x1B[40m \x1B[0m",Je="\x1B[47m \x1B[0m",Sr=function(r){return r?xr:Je},vt=function(r){return{times:function(n){return new Array(n).join(r)}}},kr=function(r,n){for(var t=new Array(r),o=0;o<r;o++)t[o]=n;return t};wn.exports={error:vn.L,generate:function(r,n,t){typeof n=="function"&&(t=n,n={});var o=new _r(-1,this.error);o.addData(r),o.make();var e="";if(n&&n.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(kr(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=vt(u.BLACK_WHITE).times(a+3),h=vt(u.WHITE_BLACK).times(a+3);e+=f+`
|
|
3
|
+
var Qn=Object.create;var Nt=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Vn=Object.getOwnPropertyNames;var Jn=Object.getPrototypeOf,qn=Object.prototype.hasOwnProperty;var Y=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports);var Xn=(n,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of Vn(r))!qn.call(n,e)&&e!==t&&Nt(n,e,{get:()=>r[e],enumerable:!(o=Yn(r,e))||o.enumerable});return n};var L=(n,r,t)=>(t=n!=null?Qn(Jn(n)):{},Xn(r||!n||!n.__esModule?Nt(t,"default",{value:n,enumerable:!0}):t,n));var pt=Y((po,Vt)=>{Vt.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var Xt=Y((ho,qt)=>{var pr=pt();function Jt(n){this.mode=pr.MODE_8BIT_BYTE,this.data=n}Jt.prototype={getLength:function(){return this.data.length},write:function(n){for(var r=0;r<this.data.length;r++)n.put(this.data.charCodeAt(r),8)}};qt.exports=Jt});var ht=Y((mo,zt)=>{var Z={glog:function(n){if(n<1)throw new Error("glog("+n+")");return Z.LOG_TABLE[n]},gexp:function(n){for(;n<0;)n+=255;for(;n>=256;)n-=255;return Z.EXP_TABLE[n]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for($=0;$<8;$++)Z.EXP_TABLE[$]=1<<$;var $;for($=8;$<256;$++)Z.EXP_TABLE[$]=Z.EXP_TABLE[$-4]^Z.EXP_TABLE[$-5]^Z.EXP_TABLE[$-6]^Z.EXP_TABLE[$-8];var $;for($=0;$<255;$++)Z.LOG_TABLE[Z.EXP_TABLE[$]]=$;var $;zt.exports=Z});var dt=Y((go,Zt)=>{var fe=ht();function He(n,r){if(n.length===void 0)throw new Error(n.length+"/"+r);for(var t=0;t<n.length&&n[t]===0;)t++;this.num=new Array(n.length-t+r);for(var o=0;o<n.length-t;o++)this.num[o]=n[o+t]}He.prototype={get:function(n){return this.num[n]},getLength:function(){return this.num.length},multiply:function(n){for(var r=new Array(this.getLength()+n.getLength()-1),t=0;t<this.getLength();t++)for(var o=0;o<n.getLength();o++)r[t+o]^=fe.gexp(fe.glog(this.get(t))+fe.glog(n.get(o)));return new He(r,0)},mod:function(n){if(this.getLength()-n.getLength()<0)return this;for(var r=fe.glog(this.get(0))-fe.glog(n.get(0)),t=new Array(this.getLength()),o=0;o<this.getLength();o++)t[o]=this.get(o);for(var e=0;e<n.getLength();e++)t[e]^=fe.gexp(fe.glog(n.get(e))+r);return new He(t,0).mod(n)}};Zt.exports=He});var tn=Y((yo,en)=>{en.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var on=Y((vo,rn)=>{var J=pt(),nn=dt(),hr=ht(),ae=tn(),j={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(n){for(var r=n<<10;j.getBCHDigit(r)-j.getBCHDigit(j.G15)>=0;)r^=j.G15<<j.getBCHDigit(r)-j.getBCHDigit(j.G15);return(n<<10|r)^j.G15_MASK},getBCHTypeNumber:function(n){for(var r=n<<12;j.getBCHDigit(r)-j.getBCHDigit(j.G18)>=0;)r^=j.G18<<j.getBCHDigit(r)-j.getBCHDigit(j.G18);return n<<12|r},getBCHDigit:function(n){for(var r=0;n!==0;)r++,n>>>=1;return r},getPatternPosition:function(n){return j.PATTERN_POSITION_TABLE[n-1]},getMask:function(n,r,t){switch(n){case ae.PATTERN000:return(r+t)%2===0;case ae.PATTERN001:return r%2===0;case ae.PATTERN010:return t%3===0;case ae.PATTERN011:return(r+t)%3===0;case ae.PATTERN100:return(Math.floor(r/2)+Math.floor(t/3))%2===0;case ae.PATTERN101:return r*t%2+r*t%3===0;case ae.PATTERN110:return(r*t%2+r*t%3)%2===0;case ae.PATTERN111:return(r*t%3+(r+t)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}},getErrorCorrectPolynomial:function(n){for(var r=new nn([1],0),t=0;t<n;t++)r=r.multiply(new nn([1,hr.gexp(t)],0));return r},getLengthInBits:function(n,r){if(1<=r&&r<10)switch(n){case J.MODE_NUMBER:return 10;case J.MODE_ALPHA_NUM:return 9;case J.MODE_8BIT_BYTE:return 8;case J.MODE_KANJI:return 8;default:throw new Error("mode:"+n)}else if(r<27)switch(n){case J.MODE_NUMBER:return 12;case J.MODE_ALPHA_NUM:return 11;case J.MODE_8BIT_BYTE:return 16;case J.MODE_KANJI:return 10;default:throw new Error("mode:"+n)}else if(r<41)switch(n){case J.MODE_NUMBER:return 14;case J.MODE_ALPHA_NUM:return 13;case J.MODE_8BIT_BYTE:return 16;case J.MODE_KANJI:return 12;default:throw new Error("mode:"+n)}else throw new Error("type:"+r)},getLostPoint:function(n){var r=n.getModuleCount(),t=0,o=0,e=0;for(o=0;o<r;o++)for(e=0;e<r;e++){for(var i=0,s=n.isDark(o,e),a=-1;a<=1;a++)if(!(o+a<0||r<=o+a))for(var c=-1;c<=1;c++)e+c<0||r<=e+c||a===0&&c===0||s===n.isDark(o+a,e+c)&&i++;i>5&&(t+=3+i-5)}for(o=0;o<r-1;o++)for(e=0;e<r-1;e++){var l=0;n.isDark(o,e)&&l++,n.isDark(o+1,e)&&l++,n.isDark(o,e+1)&&l++,n.isDark(o+1,e+1)&&l++,(l===0||l===4)&&(t+=3)}for(o=0;o<r;o++)for(e=0;e<r-6;e++)n.isDark(o,e)&&!n.isDark(o,e+1)&&n.isDark(o,e+2)&&n.isDark(o,e+3)&&n.isDark(o,e+4)&&!n.isDark(o,e+5)&&n.isDark(o,e+6)&&(t+=40);for(e=0;e<r;e++)for(o=0;o<r-6;o++)n.isDark(o,e)&&!n.isDark(o+1,e)&&n.isDark(o+2,e)&&n.isDark(o+3,e)&&n.isDark(o+4,e)&&!n.isDark(o+5,e)&&n.isDark(o+6,e)&&(t+=40);var u=0;for(e=0;e<r;e++)for(o=0;o<r;o++)n.isDark(o,e)&&u++;var f=Math.abs(100*u/r/r-50)/5;return t+=f*10,t}};rn.exports=j});var mt=Y((wo,sn)=>{sn.exports={L:1,M:0,Q:3,H:2}});var cn=Y((To,an)=>{var We=mt();function ne(n,r){this.totalCount=n,this.dataCount=r}ne.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]];ne.getRSBlocks=function(n,r){var t=ne.getRsBlockTable(n,r);if(t===void 0)throw new Error("bad rs block @ typeNumber:"+n+"/errorCorrectLevel:"+r);for(var o=t.length/3,e=[],i=0;i<o;i++)for(var s=t[i*3+0],a=t[i*3+1],c=t[i*3+2],l=0;l<s;l++)e.push(new ne(a,c));return e};ne.getRsBlockTable=function(n,r){switch(r){case We.L:return ne.RS_BLOCK_TABLE[(n-1)*4+0];case We.M:return ne.RS_BLOCK_TABLE[(n-1)*4+1];case We.Q:return ne.RS_BLOCK_TABLE[(n-1)*4+2];case We.H:return ne.RS_BLOCK_TABLE[(n-1)*4+3];default:return}};an.exports=ne});var fn=Y((Eo,un)=>{function ln(){this.buffer=[],this.length=0}ln.prototype={get:function(n){var r=Math.floor(n/8);return(this.buffer[r]>>>7-n%8&1)==1},put:function(n,r){for(var t=0;t<r;t++)this.putBit((n>>>r-t-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(n){var r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),n&&(this.buffer[r]|=128>>>this.length%8),this.length++}};un.exports=ln});var mn=Y((bo,dn)=>{var dr=Xt(),ce=on(),mr=dt(),pn=cn(),hn=fn();function re(n,r){this.typeNumber=n,this.errorCorrectLevel=r,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}re.prototype={addData:function(n){var r=new dr(n);this.dataList.push(r),this.dataCache=null},isDark:function(n,r){if(n<0||this.moduleCount<=n||r<0||this.moduleCount<=r)throw new Error(n+","+r);return this.modules[n][r]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var n=1;for(n=1;n<40;n++){for(var r=pn.getRSBlocks(n,this.errorCorrectLevel),t=new hn,o=0,e=0;e<r.length;e++)o+=r[e].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];t.put(s.mode,4),t.put(s.getLength(),ce.getLengthInBits(s.mode,n)),s.write(t)}if(t.getLengthInBits()<=o*8)break}this.typeNumber=n}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(n,r){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var t=0;t<this.moduleCount;t++){this.modules[t]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[t][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(n,r),this.typeNumber>=7&&this.setupTypeNumber(n),this.dataCache===null&&(this.dataCache=re.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,r)},setupPositionProbePattern:function(n,r){for(var t=-1;t<=7;t++)if(!(n+t<=-1||this.moduleCount<=n+t))for(var o=-1;o<=7;o++)r+o<=-1||this.moduleCount<=r+o||(0<=t&&t<=6&&(o===0||o===6)||0<=o&&o<=6&&(t===0||t===6)||2<=t&&t<=4&&2<=o&&o<=4?this.modules[n+t][r+o]=!0:this.modules[n+t][r+o]=!1)},getBestMaskPattern:function(){for(var n=0,r=0,t=0;t<8;t++){this.makeImpl(!0,t);var o=ce.getLostPoint(this);(t===0||n>o)&&(n=o,r=t)}return r},createMovieClip:function(n,r,t){var o=n.createEmptyMovieClip(r,t),e=1;this.make();for(var i=0;i<this.modules.length;i++)for(var s=i*e,a=0;a<this.modules[i].length;a++){var c=a*e,l=this.modules[i][a];l&&(o.beginFill(0,100),o.moveTo(c,s),o.lineTo(c+e,s),o.lineTo(c+e,s+e),o.lineTo(c,s+e),o.endFill())}return o},setupTimingPattern:function(){for(var n=8;n<this.moduleCount-8;n++)this.modules[n][6]===null&&(this.modules[n][6]=n%2===0);for(var r=8;r<this.moduleCount-8;r++)this.modules[6][r]===null&&(this.modules[6][r]=r%2===0)},setupPositionAdjustPattern:function(){for(var n=ce.getPatternPosition(this.typeNumber),r=0;r<n.length;r++)for(var t=0;t<n.length;t++){var o=n[r],e=n[t];if(this.modules[o][e]===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][e+s]=!0:this.modules[o+i][e+s]=!1}},setupTypeNumber:function(n){for(var r=ce.getBCHTypeNumber(this.typeNumber),t,o=0;o<18;o++)t=!n&&(r>>o&1)===1,this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=t;for(var e=0;e<18;e++)t=!n&&(r>>e&1)===1,this.modules[e%3+this.moduleCount-8-3][Math.floor(e/3)]=t},setupTypeInfo:function(n,r){for(var t=this.errorCorrectLevel<<3|r,o=ce.getBCHTypeInfo(t),e,i=0;i<15;i++)e=!n&&(o>>i&1)===1,i<6?this.modules[i][8]=e:i<8?this.modules[i+1][8]=e:this.modules[this.moduleCount-15+i][8]=e;for(var s=0;s<15;s++)e=!n&&(o>>s&1)===1,s<8?this.modules[8][this.moduleCount-s-1]=e:s<9?this.modules[8][15-s-1+1]=e:this.modules[8][15-s-1]=e;this.modules[this.moduleCount-8][8]=!n},mapData:function(n,r){for(var t=-1,o=this.moduleCount-1,e=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<n.length&&(c=(n[i]>>>e&1)===1);var l=ce.getMask(r,o,s-a);l&&(c=!c),this.modules[o][s-a]=c,e--,e===-1&&(i++,e=7)}if(o+=t,o<0||this.moduleCount<=o){o-=t,t=-t;break}}}};re.PAD0=236;re.PAD1=17;re.createData=function(n,r,t){for(var o=pn.getRSBlocks(n,r),e=new hn,i=0;i<t.length;i++){var s=t[i];e.put(s.mode,4),e.put(s.getLength(),ce.getLengthInBits(s.mode,n)),s.write(e)}for(var a=0,c=0;c<o.length;c++)a+=o[c].dataCount;if(e.getLengthInBits()>a*8)throw new Error("code length overflow. ("+e.getLengthInBits()+">"+a*8+")");for(e.getLengthInBits()+4<=a*8&&e.put(0,4);e.getLengthInBits()%8!==0;)e.putBit(!1);for(;!(e.getLengthInBits()>=a*8||(e.put(re.PAD0,8),e.getLengthInBits()>=a*8));)e.put(re.PAD1,8);return re.createBytes(e,o)};re.createBytes=function(n,r){for(var t=0,o=0,e=0,i=new Array(r.length),s=new Array(r.length),a=0;a<r.length;a++){var c=r[a].dataCount,l=r[a].totalCount-c;o=Math.max(o,c),e=Math.max(e,l),i[a]=new Array(c);for(var u=0;u<i[a].length;u++)i[a][u]=255&n.buffer[u+t];t+=c;var f=ce.getErrorCorrectPolynomial(l),h=new mr(i[a],f.getLength()-1),d=h.mod(f);s[a]=new Array(f.getLength()-1);for(var p=0;p<s[a].length;p++){var y=p+d.getLength()-s[a].length;s[a][p]=y>=0?d.get(y):0}}for(var E=0,I=0;I<r.length;I++)E+=r[I].totalCount;for(var x=new Array(E),b=0,S=0;S<o;S++)for(var R=0;R<r.length;R++)S<i[R].length&&(x[b++]=i[R][S]);for(var v=0;v<e;v++)for(var k=0;k<r.length;k++)v<s[k].length&&(x[b++]=s[k][v]);return x};dn.exports=re});var vn=Y((_o,yn)=>{var gr=mn(),gn=mt(),yr="\x1B[40m \x1B[0m",Qe="\x1B[47m \x1B[0m",vr=function(n){return n?yr:Qe},gt=function(n){return{times:function(r){return new Array(r).join(n)}}},wr=function(n,r){for(var t=new Array(n),o=0;o<n;o++)t[o]=r;return t};yn.exports={error:gn.L,generate:function(n,r,t){typeof r=="function"&&(t=r,r={});var o=new gr(-1,this.error);o.addData(n),o.make();var e="";if(r&&r.small){var i=!0,s=!1,a=o.getModuleCount(),c=o.modules.slice(),l=a%2===1;l&&c.push(wr(a,s));var u={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},f=gt(u.BLACK_WHITE).times(a+3),h=gt(u.WHITE_BLACK).times(a+3);e+=f+`
|
|
4
4
|
`;for(var d=0;d<a;d+=2){e+=u.WHITE_ALL;for(var p=0;p<a;p++)c[d][p]===s&&c[d+1][p]===s?e+=u.WHITE_ALL:c[d][p]===s&&c[d+1][p]===i?e+=u.WHITE_BLACK:c[d][p]===i&&c[d+1][p]===s?e+=u.BLACK_WHITE:e+=u.BLACK_ALL;e+=u.WHITE_ALL+`
|
|
5
|
-
`}l||(e+=h)}else{var
|
|
6
|
-
`,o.modules.forEach(function(
|
|
7
|
-
`}),e+=
|
|
8
|
-
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return x.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return x.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(x){var b=c((0,d.execSync)(_[T]).toString());return x?b:a(b)}function u(x){return new h.default(function(b,A){return(0,d.exec)(_[T],{},function(w,R,O){if(w)return A(new Error("Error while obtaining machine id: "+w.stack));var L=c(R.toString());return b(x?L:a(L))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=e(35),h=i(f);o.machineIdSync=l,o.machineId=u;var d=e(70),p=e(71),g=process,T=g.platform,k={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},_={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:k[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(t,o,e){t.exports={default:e(36),__esModule:!0}},function(t,o,e){e(66),e(68),e(69),e(67),t.exports=e(6).Promise},function(t,o){t.exports=function(){}},function(t,o){t.exports=function(e,i,s,a){if(!(e instanceof i)||a!==void 0&&a in e)throw TypeError(s+": incorrect invocation!");return e}},function(t,o,e){var i=e(13),s=e(31),a=e(62);t.exports=function(c){return function(l,u,f){var h,d=i(l),p=s(d.length),g=a(f,p);if(c&&u!=u){for(;p>g;)if(h=d[g++],h!=h)return!0}else for(;p>g;g++)if((c||g in d)&&d[g]===u)return c||g||0;return!c&&-1}}},function(t,d,e){var i=e(7),s=e(44),a=e(43),c=e(3),l=e(31),u=e(64),f={},h={},d=t.exports=function(p,g,T,k,_){var x,b,A,w,R=_?function(){return p}:u(p),O=i(T,k,g?2:1),L=0;if(typeof R!="function")throw TypeError(p+" is not iterable!");if(a(R)){for(x=l(p.length);x>L;L++)if(w=g?O(c(b=p[L])[0],b[1]):O(p[L]),w===f||w===h)return w}else for(A=R.call(p);!(b=A.next()).done;)if(w=s(A,O,b.value,g),w===f||w===h)return w};d.BREAK=f,d.RETURN=h},function(t,o){t.exports=function(e,i,s){var a=s===void 0;switch(i.length){case 0:return a?e():e.call(s);case 1:return a?e(i[0]):e.call(s,i[0]);case 2:return a?e(i[0],i[1]):e.call(s,i[0],i[1]);case 3:return a?e(i[0],i[1],i[2]):e.call(s,i[0],i[1],i[2]);case 4:return a?e(i[0],i[1],i[2],i[3]):e.call(s,i[0],i[1],i[2],i[3])}return e.apply(s,i)}},function(t,o,e){var i=e(11);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(t,o,e){var i=e(10),s=e(1)("iterator"),a=Array.prototype;t.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(t,o,e){var i=e(3);t.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(t,o,e){"use strict";var i=e(49),s=e(17),a=e(18),c={};e(5)(c,e(1)("iterator"),function(){return this}),t.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(t,o,e){var i=e(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}t.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],h=f[i]();h.next=function(){return{done:u=!0}},f[i]=function(){return h},c(f)}catch{}return u}},function(t,o){t.exports=function(e,i){return{value:i,done:!!e}}},function(t,o,e){var i=e(2),s=e(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=e(11)(c)=="process";t.exports=function(){var f,h,d,p=function(){var _,x;for(u&&(_=c.domain)&&_.exit();f;){x=f.fn,f=f.next;try{x()}catch(b){throw f?d():h=void 0,b}}h=void 0,_&&_.enter()};if(u)d=function(){c.nextTick(p)};else if(a){var g=!0,T=document.createTextNode("");new a(p).observe(T,{characterData:!0}),d=function(){T.data=g=!g}}else if(l&&l.resolve){var k=l.resolve();d=function(){k.then(p)}}else d=function(){s.call(i,p)};return function(_){var x={fn:_,next:void 0};h&&(h.next=x),f||(f=x,d()),h=x}}},function(t,o,e){var i=e(3),s=e(50),a=e(22),c=e(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var h,d=e(16)("iframe"),p=a.length,g=">";for(d.style.display="none",e(25).appendChild(d),d.src="javascript:",h=d.contentWindow.document,h.open(),h.write("<script>document.F=Object</script"+g),h.close(),f=h.F;p--;)delete f[u][a[p]];return f()};t.exports=Object.create||function(h,d){var p;return h!==null?(l[u]=i(h),p=new l,l[u]=null,p[c]=h):p=f(),d===void 0?p:s(p,d)}},function(t,o,e){var i=e(12),s=e(3),a=e(54);t.exports=e(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),h=f.length,d=0;h>d;)i.f(c,u=f[d++],l[u]);return c}},function(t,o,e){var i=e(55),s=e(17),a=e(13),c=e(32),l=e(8),u=e(26),f=Object.getOwnPropertyDescriptor;o.f=e(4)?f:function(h,d){if(h=a(h),d=c(d,!0),u)try{return f(h,d)}catch{}if(l(h,d))return s(!i.f.call(h,d),h[d])}},function(t,o,e){var i=e(8),s=e(63),a=e(19)("IE_PROTO"),c=Object.prototype;t.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(t,o,e){var i=e(8),s=e(13),a=e(39)(!1),c=e(19)("IE_PROTO");t.exports=function(l,u){var f,h=s(l),d=0,p=[];for(f in h)f!=c&&i(h,f)&&p.push(f);for(;u.length>d;)i(h,f=u[d++])&&(~a(p,f)||p.push(f));return p}},function(t,o,e){var i=e(53),s=e(22);t.exports=Object.keys||function(a){return i(a,s)}},function(t,o){o.f={}.propertyIsEnumerable},function(t,o,e){var i=e(5);t.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(t,o,e){t.exports=e(5)},function(t,o,e){var i=e(9),s=e(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=e(7)(Function.call,e(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,h){return a(f,h),l?f.__proto__=h:u(f,h),f}})({},!1):void 0),check:a}},function(t,o,e){"use strict";var i=e(2),s=e(6),a=e(12),c=e(4),l=e(1)("species");t.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(t,o,e){var i=e(3),s=e(14),a=e(1)("species");t.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(t,o,e){var i=e(20),s=e(15);t.exports=function(a){return function(c,l){var u,f,h=String(s(c)),d=i(l),p=h.length;return d<0||d>=p?a?"":void 0:(u=h.charCodeAt(d),u<55296||u>56319||d+1===p||(f=h.charCodeAt(d+1))<56320||f>57343?a?h.charAt(d):u:a?h.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(t,o,e){var i=e(20),s=Math.max,a=Math.min;t.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(t,o,e){var i=e(15);t.exports=function(s){return Object(i(s))}},function(t,o,e){var i=e(21),s=e(1)("iterator"),a=e(10);t.exports=e(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(t,o,e){"use strict";var i=e(37),s=e(47),a=e(10),c=e(13);t.exports=e(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(t,o){},function(t,o,e){"use strict";var i,s,a,c=e(28),l=e(2),u=e(7),f=e(21),h=e(23),d=e(9),p=(e(3),e(14)),g=e(38),T=e(40),k=(e(58).set,e(60)),_=e(30).set,x=e(48)(),b="Promise",A=l.TypeError,R=l.process,w=l[b],R=l.process,O=f(R)=="process",L=function(){},F=!!(function(){try{var m=w.resolve(1),y=(m.constructor={})[e(1)("species")]=function(E){E(L,L)};return(O||typeof PromiseRejectionEvent=="function")&&m.then(L)instanceof y}catch{}})(),X=function(m,y){return m===y||m===w&&y===a},z=function(m){var y;return!(!d(m)||typeof(y=m.then)!="function")&&y},G=function(m){return X(w,m)?new ie(m):new s(m)},ie=s=function(m){var y,E;this.promise=new m(function(P,K){if(y!==void 0||E!==void 0)throw A("Bad Promise constructor");y=P,E=K}),this.resolve=p(y),this.reject=p(E)},ye=function(m){try{m()}catch(y){return{error:y}}},ue=function(m,y){if(!m._n){m._n=!0;var E=m._c;x(function(){for(var P=m._v,K=m._s==1,fe=0,ve=function(ae){var ne,Ke,Pe=K?ae.ok:ae.fail,Ce=ae.resolve,we=ae.reject,Ge=ae.domain;try{Pe?(K||(m._h==2&&se(m),m._h=1),Pe===!0?ne=P:(Ge&&Ge.enter(),ne=Pe(P),Ge&&Ge.exit()),ne===ae.promise?we(A("Promise-chain cycle")):(Ke=z(ne))?Ke.call(ne,Ce,we):Ce(ne)):we(P)}catch(zn){we(zn)}};E.length>fe;)ve(E[fe++]);m._c=[],m._n=!1,y&&!m._h&&Ae(m)})}},Ae=function(m){_.call(l,function(){var y,E,P,K=m._v;if(H(m)&&(y=ye(function(){O?R.emit("unhandledRejection",K,m):(E=l.onunhandledrejection)?E({promise:m,reason:K}):(P=l.console)&&P.error&&P.error("Unhandled promise rejection",K)}),m._h=O||H(m)?2:1),m._a=void 0,y)throw y.error})},H=function(m){if(m._h==1)return!1;for(var y,E=m._a||m._c,P=0;E.length>P;)if(y=E[P++],y.fail||!H(y.promise))return!1;return!0},se=function(m){_.call(l,function(){var y;O?R.emit("rejectionHandled",m):(y=l.onrejectionhandled)&&y({promise:m,reason:m._v})})},W=function(m){var y=this;y._d||(y._d=!0,y=y._w||y,y._v=m,y._s=2,y._a||(y._a=y._c.slice()),ue(y,!0))},Oe=function(m){var y,E=this;if(!E._d){E._d=!0,E=E._w||E;try{if(E===m)throw A("Promise can't be resolved itself");(y=z(m))?x(function(){var P={_w:E,_d:!1};try{y.call(m,u(Oe,P,1),u(W,P,1))}catch(K){W.call(P,K)}}):(E._v=m,E._s=1,ue(E,!1))}catch(P){W.call({_w:E,_d:!1},P)}}};F||(w=function(m){g(this,w,b,"_h"),p(m),i.call(this);try{m(u(Oe,this,1),u(W,this,1))}catch(y){W.call(this,y)}},i=function(m){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=e(56)(w.prototype,{then:function(m,y){var E=G(k(this,w));return E.ok=typeof m!="function"||m,E.fail=typeof y=="function"&&y,E.domain=O?R.domain:void 0,this._c.push(E),this._a&&this._a.push(E),this._s&&ue(this,!1),E.promise},catch:function(m){return this.then(void 0,m)}}),ie=function(){var m=new i;this.promise=m,this.resolve=u(Oe,m,1),this.reject=u(W,m,1)}),h(h.G+h.W+h.F*!F,{Promise:w}),e(18)(w,b),e(59)(b),a=e(6)[b],h(h.S+h.F*!F,b,{reject:function(m){var y=G(this),E=y.reject;return E(m),y.promise}}),h(h.S+h.F*(c||!F),b,{resolve:function(m){if(m instanceof w&&X(m.constructor,this))return m;var y=G(this),E=y.resolve;return E(m),y.promise}}),h(h.S+h.F*!(F&&e(46)(function(m){w.all(m).catch(L)})),b,{all:function(m){var y=this,E=G(y),P=E.resolve,K=E.reject,fe=ye(function(){var ve=[],ae=0,ne=1;T(m,!1,function(Ke){var Pe=ae++,Ce=!1;ve.push(void 0),ne++,y.resolve(Ke).then(function(we){Ce||(Ce=!0,ve[Pe]=we,--ne||P(ve))},K)}),--ne||P(ve)});return fe&&K(fe.error),E.promise},race:function(m){var y=this,E=G(y),P=E.reject,K=ye(function(){T(m,!1,function(fe){y.resolve(fe).then(E.resolve,P)})});return K&&P(K.error),E.promise}})},function(t,o,e){"use strict";var i=e(61)(!0);e(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(t,o,e){e(65);for(var i=e(2),s=e(5),a=e(10),c=e(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],h=i[f],d=h&&h.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(t,o){t.exports=require("child_process")},function(t,o){t.exports=require("crypto")}])})});var jt=(r=0)=>n=>`\x1B[${n+r}m`,Ut=(r=0)=>n=>`\x1B[${38+r};5;${n}m`,Ft=(r=0)=>(n,t,o)=>`\x1B[${38+r};2;${n};${t};${o}m`,C={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]}},co=Object.keys(C.modifier),ir=Object.keys(C.color),sr=Object.keys(C.bgColor),lo=[...ir,...sr];function ar(){let r=new Map;for(let[n,t]of Object.entries(C)){for(let[o,e]of Object.entries(t))C[o]={open:`\x1B[${e[0]}m`,close:`\x1B[${e[1]}m`},t[o]=C[o],r.set(e[0],e[1]);Object.defineProperty(C,n,{value:t,enumerable:!1})}return Object.defineProperty(C,"codes",{value:r,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=jt(),C.color.ansi256=Ut(),C.color.ansi16m=Ft(),C.bgColor.ansi=jt(10),C.bgColor.ansi256=Ut(10),C.bgColor.ansi16m=Ft(10),Object.defineProperties(C,{rgbToAnsi256:{value(n,t,o){return n===t&&t===o?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(n){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!t)return[0,0,0];let[o]=t;o.length===3&&(o=[...o].map(i=>i+i).join(""));let e=Number.parseInt(o,16);return[e>>16&255,e>>8&255,e&255]},enumerable:!1},hexToAnsi256:{value:n=>C.rgbToAnsi256(...C.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let t,o,e;if(n>=232)t=((n-232)*10+8)/255,o=t,e=t;else{n-=16;let a=n%36;t=Math.floor(n/36)/5,o=Math.floor(a/6)/5,e=a%6/5}let i=Math.max(t,o,e)*2;if(i===0)return 30;let s=30+(Math.round(e)<<2|Math.round(o)<<1|Math.round(t));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(n,t,o)=>C.ansi256ToAnsi(C.rgbToAnsi256(n,t,o)),enumerable:!1},hexToAnsi:{value:n=>C.ansi256ToAnsi(C.hexToAnsi256(n)),enumerable:!1}}),C}var cr=ar(),Z=cr;var We=M(require("node:process"),1),Gt=M(require("node:os"),1),ut=M(require("node:tty"),1);function J(r,n=globalThis.Deno?globalThis.Deno.args:We.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",o=n.indexOf(t+r),e=n.indexOf("--");return o!==-1&&(e===-1||o<e)}var{env:I}=We.default,He;J("no-color")||J("no-colors")||J("color=false")||J("color=never")?He=0:(J("color")||J("colors")||J("color=true")||J("color=always"))&&(He=1);function lr(){if("FORCE_COLOR"in I)return I.FORCE_COLOR==="true"?1:I.FORCE_COLOR==="false"?0:I.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(I.FORCE_COLOR,10),3)}function ur(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function fr(r,{streamIsTTY:n,sniffFlags:t=!0}={}){let o=lr();o!==void 0&&(He=o);let e=t?He:o;if(e===0)return 0;if(t){if(J("color=16m")||J("color=full")||J("color=truecolor"))return 3;if(J("color=256"))return 2}if("TF_BUILD"in I&&"AGENT_NAME"in I)return 1;if(r&&!n&&e===void 0)return 0;let i=e||0;if(I.TERM==="dumb")return i;if(We.default.platform==="win32"){let s=Gt.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in I)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in I)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in I)||I.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in I)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(I.TEAMCITY_VERSION)?1:0;if(I.COLORTERM==="truecolor"||I.TERM==="xterm-kitty"||I.TERM==="xterm-ghostty"||I.TERM==="wezterm")return 3;if("TERM_PROGRAM"in I){let s=Number.parseInt((I.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(I.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(I.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(I.TERM)||"COLORTERM"in I?1:i}function Kt(r,n={}){let t=fr(r,{streamIsTTY:r&&r.isTTY,...n});return ur(t)}var pr={stdout:Kt({isTTY:ut.default.isatty(1)}),stderr:Kt({isTTY:ut.default.isatty(2)})},Ht=pr;function Wt(r,n,t){let o=r.indexOf(n);if(o===-1)return r;let e=n.length,i=0,s="";do s+=r.slice(i,o)+n+t,i=o+e,o=r.indexOf(n,i);while(o!==-1);return s+=r.slice(i),s}function Qt(r,n,t,o){let e=0,i="";do{let s=r[o-1]==="\r";i+=r.slice(e,s?o-1:o)+n+(s?`\r
|
|
5
|
+
`}l||(e+=h)}else{var y=gt(Qe).times(o.getModuleCount()+3);e+=y+`
|
|
6
|
+
`,o.modules.forEach(function(E){e+=Qe,e+=E.map(vr).join(""),e+=Qe+`
|
|
7
|
+
`}),e+=y}t?t(e):console.log(e)},setErrorLevel:function(n){this.error=gn[n]||this.error}}});var wn=Y((Ie,yt)=>{(function(n,r){typeof Ie=="object"&&typeof yt=="object"?yt.exports=r(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],r):typeof Ie=="object"?Ie["electron-machine-id"]=r(require("child_process"),require("crypto")):n["electron-machine-id"]=r(n.child_process,n.crypto)})(Ie,function(n,r){return(function(t){function o(i){if(e[i])return e[i].exports;var s=e[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}var e={};return o.m=t,o.c=e,o.p="",o(0)})([function(t,o,e){t.exports=e(34)},function(t,o,e){var i=e(29)("wks"),s=e(33),a=e(2).Symbol,c=typeof a=="function",l=t.exports=function(u){return i[u]||(i[u]=c&&a[u]||(c?a:s)("Symbol."+u))};l.store=i},function(t,o){var e=t.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=e)},function(t,o,e){var i=e(9);t.exports=function(s){if(!i(s))throw TypeError(s+" is not an object!");return s}},function(t,o,e){t.exports=!e(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(t,o,e){var i=e(12),s=e(17);t.exports=e(4)?function(a,c,l){return i.f(a,c,s(1,l))}:function(a,c,l){return a[c]=l,a}},function(t,o){var e=t.exports={version:"2.4.0"};typeof __e=="number"&&(__e=e)},function(t,o,e){var i=e(14);t.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(t,o){var e={}.hasOwnProperty;t.exports=function(i,s){return e.call(i,s)}},function(t,o){t.exports=function(e){return typeof e=="object"?e!==null:typeof e=="function"}},function(t,o){t.exports={}},function(t,o){var e={}.toString;t.exports=function(i){return e.call(i).slice(8,-1)}},function(t,o,e){var i=e(3),s=e(26),a=e(32),c=Object.defineProperty;o.f=e(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(t,o,e){var i=e(42),s=e(15);t.exports=function(a){return i(s(a))}},function(t,o){t.exports=function(e){if(typeof e!="function")throw TypeError(e+" is not a function!");return e}},function(t,o){t.exports=function(e){if(e==null)throw TypeError("Can't call method on "+e);return e}},function(t,o,e){var i=e(9),s=e(2).document,a=i(s)&&i(s.createElement);t.exports=function(c){return a?s.createElement(c):{}}},function(t,o){t.exports=function(e,i){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:i}}},function(t,o,e){var i=e(12).f,s=e(8),a=e(1)("toStringTag");t.exports=function(c,l,u){c&&!s(c=u?c:c.prototype,a)&&i(c,a,{configurable:!0,value:l})}},function(t,o,e){var i=e(29)("keys"),s=e(33);t.exports=function(a){return i[a]||(i[a]=s(a))}},function(t,o){var e=Math.ceil,i=Math.floor;t.exports=function(s){return isNaN(s=+s)?0:(s>0?i:e)(s)}},function(t,o,e){var i=e(11),s=e(1)("toStringTag"),a=i((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};t.exports=function(l){var u,f,h;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),s))=="string"?f:a?i(u):(h=i(u))=="Object"&&typeof u.callee=="function"?"Arguments":h}},function(t,o){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,o,e){var i=e(2),s=e(6),a=e(7),c=e(5),l="prototype",u=function(f,h,d){var p,y,E,I=f&u.F,x=f&u.G,b=f&u.S,S=f&u.P,R=f&u.B,v=f&u.W,k=x?s:s[h]||(s[h]={}),A=k[l],M=x?i:b?i[h]:(i[h]||{})[l];x&&(d=h);for(p in d)y=!I&&M&&M[p]!==void 0,y&&p in k||(E=y?M[p]:d[p],k[p]=x&&typeof M[p]!="function"?d[p]:R&&y?a(E,i):v&&M[p]==E?(function(F){var q=function(X,G,oe){if(this instanceof F){switch(arguments.length){case 0:return new F;case 1:return new F(X);case 2:return new F(X,G)}return new F(X,G,oe)}return F.apply(this,arguments)};return q[l]=F[l],q})(E):S&&typeof E=="function"?a(Function.call,E):E,S&&((k.virtual||(k.virtual={}))[p]=E,f&u.R&&A&&!A[p]&&c(A,p,E)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,o){t.exports=function(e){try{return!!e()}catch{return!0}}},function(t,o,e){t.exports=e(2).document&&document.documentElement},function(t,o,e){t.exports=!e(4)&&!e(24)(function(){return Object.defineProperty(e(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,o,e){"use strict";var i=e(28),s=e(23),a=e(57),c=e(5),l=e(8),u=e(10),f=e(45),h=e(18),d=e(52),p=e(1)("iterator"),y=!([].keys&&"next"in[].keys()),E="@@iterator",I="keys",x="values",b=function(){return this};t.exports=function(S,R,v,k,A,M,F){f(v,R,k);var q,X,G,oe=function(g){if(!y&&g in H)return H[g];switch(g){case I:return function(){return new v(this,g)};case x:return function(){return new v(this,g)}}return function(){return new v(this,g)}},me=R+" Iterator",le=A==x,ke=!1,H=S.prototype,ie=H[p]||H[E]||A&&H[A],W=ie||oe(A),Re=A?le?oe("entries"):W:void 0,m=R=="Array"&&H.entries||ie;if(m&&(G=d(m.call(new S)),G!==Object.prototype&&(h(G,me,!0),i||l(G,p)||c(G,p,b))),le&&ie&&ie.name!==x&&(ke=!0,W=function(){return ie.call(this)}),i&&!F||!y&&!ke&&H[p]||c(H,p,W),u[R]=W,u[me]=b,A)if(q={values:le?W:oe(x),keys:M?W:oe(I),entries:Re},F)for(X in q)X in H||a(H,X,q[X]);else s(s.P+s.F*(y||ke),R,q);return q}},function(t,o){t.exports=!0},function(t,o,e){var i=e(2),s="__core-js_shared__",a=i[s]||(i[s]={});t.exports=function(c){return a[c]||(a[c]={})}},function(t,o,e){var i,s,a,c=e(7),l=e(41),u=e(25),f=e(16),h=e(2),d=h.process,p=h.setImmediate,y=h.clearImmediate,E=h.MessageChannel,I=0,x={},b="onreadystatechange",S=function(){var v=+this;if(x.hasOwnProperty(v)){var k=x[v];delete x[v],k()}},R=function(v){S.call(v.data)};p&&y||(p=function(v){for(var k=[],A=1;arguments.length>A;)k.push(arguments[A++]);return x[++I]=function(){l(typeof v=="function"?v:Function(v),k)},i(I),I},y=function(v){delete x[v]},e(11)(d)=="process"?i=function(v){d.nextTick(c(S,v,1))}:E?(s=new E,a=s.port2,s.port1.onmessage=R,i=c(a.postMessage,a,1)):h.addEventListener&&typeof postMessage=="function"&&!h.importScripts?(i=function(v){h.postMessage(v+"","*")},h.addEventListener("message",R,!1)):i=b in f("script")?function(v){u.appendChild(f("script"))[b]=function(){u.removeChild(this),S.call(v)}}:function(v){setTimeout(c(S,v,1),0)}),t.exports={set:p,clear:y}},function(t,o,e){var i=e(20),s=Math.min;t.exports=function(a){return a>0?s(i(a),9007199254740991):0}},function(t,o,e){var i=e(9);t.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(t,o){var e=0,i=Math.random();t.exports=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++e+i).toString(36))}},function(t,o,e){"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,p.createHash)("sha256").update(b).digest("hex")}function c(b){switch(E){case"darwin":return b.split("IOPlatformUUID")[1].split(`
|
|
8
|
+
`)[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 S=c((0,d.execSync)(x[E]).toString());return b?S:a(S)}function u(b){return new h.default(function(S,R){return(0,d.exec)(x[E],{},function(v,k,A){if(v)return R(new Error("Error while obtaining machine id: "+v.stack));var M=c(k.toString());return S(b?M:a(M))})})}Object.defineProperty(o,"__esModule",{value:!0});var f=e(35),h=i(f);o.machineIdSync=l,o.machineId=u;var d=e(70),p=e(71),y=process,E=y.platform,I={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},x={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:I[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(t,o,e){t.exports={default:e(36),__esModule:!0}},function(t,o,e){e(66),e(68),e(69),e(67),t.exports=e(6).Promise},function(t,o){t.exports=function(){}},function(t,o){t.exports=function(e,i,s,a){if(!(e instanceof i)||a!==void 0&&a in e)throw TypeError(s+": incorrect invocation!");return e}},function(t,o,e){var i=e(13),s=e(31),a=e(62);t.exports=function(c){return function(l,u,f){var h,d=i(l),p=s(d.length),y=a(f,p);if(c&&u!=u){for(;p>y;)if(h=d[y++],h!=h)return!0}else for(;p>y;y++)if((c||y in d)&&d[y]===u)return c||y||0;return!c&&-1}}},function(t,d,e){var i=e(7),s=e(44),a=e(43),c=e(3),l=e(31),u=e(64),f={},h={},d=t.exports=function(p,y,E,I,x){var b,S,R,v,k=x?function(){return p}:u(p),A=i(E,I,y?2:1),M=0;if(typeof k!="function")throw TypeError(p+" is not iterable!");if(a(k)){for(b=l(p.length);b>M;M++)if(v=y?A(c(S=p[M])[0],S[1]):A(p[M]),v===f||v===h)return v}else for(R=k.call(p);!(S=R.next()).done;)if(v=s(R,A,S.value,y),v===f||v===h)return v};d.BREAK=f,d.RETURN=h},function(t,o){t.exports=function(e,i,s){var a=s===void 0;switch(i.length){case 0:return a?e():e.call(s);case 1:return a?e(i[0]):e.call(s,i[0]);case 2:return a?e(i[0],i[1]):e.call(s,i[0],i[1]);case 3:return a?e(i[0],i[1],i[2]):e.call(s,i[0],i[1],i[2]);case 4:return a?e(i[0],i[1],i[2],i[3]):e.call(s,i[0],i[1],i[2],i[3])}return e.apply(s,i)}},function(t,o,e){var i=e(11);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(s){return i(s)=="String"?s.split(""):Object(s)}},function(t,o,e){var i=e(10),s=e(1)("iterator"),a=Array.prototype;t.exports=function(c){return c!==void 0&&(i.Array===c||a[s]===c)}},function(t,o,e){var i=e(3);t.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(t,o,e){"use strict";var i=e(49),s=e(17),a=e(18),c={};e(5)(c,e(1)("iterator"),function(){return this}),t.exports=function(l,u,f){l.prototype=i(c,{next:s(1,f)}),a(l,u+" Iterator")}},function(t,o,e){var i=e(1)("iterator"),s=!1;try{var a=[7][i]();a.return=function(){s=!0},Array.from(a,function(){throw 2})}catch{}t.exports=function(c,l){if(!l&&!s)return!1;var u=!1;try{var f=[7],h=f[i]();h.next=function(){return{done:u=!0}},f[i]=function(){return h},c(f)}catch{}return u}},function(t,o){t.exports=function(e,i){return{value:i,done:!!e}}},function(t,o,e){var i=e(2),s=e(30).set,a=i.MutationObserver||i.WebKitMutationObserver,c=i.process,l=i.Promise,u=e(11)(c)=="process";t.exports=function(){var f,h,d,p=function(){var x,b;for(u&&(x=c.domain)&&x.exit();f;){b=f.fn,f=f.next;try{b()}catch(S){throw f?d():h=void 0,S}}h=void 0,x&&x.enter()};if(u)d=function(){c.nextTick(p)};else if(a){var y=!0,E=document.createTextNode("");new a(p).observe(E,{characterData:!0}),d=function(){E.data=y=!y}}else if(l&&l.resolve){var I=l.resolve();d=function(){I.then(p)}}else d=function(){s.call(i,p)};return function(x){var b={fn:x,next:void 0};h&&(h.next=b),f||(f=b,d()),h=b}}},function(t,o,e){var i=e(3),s=e(50),a=e(22),c=e(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var h,d=e(16)("iframe"),p=a.length,y=">";for(d.style.display="none",e(25).appendChild(d),d.src="javascript:",h=d.contentWindow.document,h.open(),h.write("<script>document.F=Object</script"+y),h.close(),f=h.F;p--;)delete f[u][a[p]];return f()};t.exports=Object.create||function(h,d){var p;return h!==null?(l[u]=i(h),p=new l,l[u]=null,p[c]=h):p=f(),d===void 0?p:s(p,d)}},function(t,o,e){var i=e(12),s=e(3),a=e(54);t.exports=e(4)?Object.defineProperties:function(c,l){s(c);for(var u,f=a(l),h=f.length,d=0;h>d;)i.f(c,u=f[d++],l[u]);return c}},function(t,o,e){var i=e(55),s=e(17),a=e(13),c=e(32),l=e(8),u=e(26),f=Object.getOwnPropertyDescriptor;o.f=e(4)?f:function(h,d){if(h=a(h),d=c(d,!0),u)try{return f(h,d)}catch{}if(l(h,d))return s(!i.f.call(h,d),h[d])}},function(t,o,e){var i=e(8),s=e(63),a=e(19)("IE_PROTO"),c=Object.prototype;t.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(t,o,e){var i=e(8),s=e(13),a=e(39)(!1),c=e(19)("IE_PROTO");t.exports=function(l,u){var f,h=s(l),d=0,p=[];for(f in h)f!=c&&i(h,f)&&p.push(f);for(;u.length>d;)i(h,f=u[d++])&&(~a(p,f)||p.push(f));return p}},function(t,o,e){var i=e(53),s=e(22);t.exports=Object.keys||function(a){return i(a,s)}},function(t,o){o.f={}.propertyIsEnumerable},function(t,o,e){var i=e(5);t.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(t,o,e){t.exports=e(5)},function(t,o,e){var i=e(9),s=e(3),a=function(c,l){if(s(c),!i(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=e(7)(Function.call,e(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,h){return a(f,h),l?f.__proto__=h:u(f,h),f}})({},!1):void 0),check:a}},function(t,o,e){"use strict";var i=e(2),s=e(6),a=e(12),c=e(4),l=e(1)("species");t.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(t,o,e){var i=e(3),s=e(14),a=e(1)("species");t.exports=function(c,l){var u,f=i(c).constructor;return f===void 0||(u=i(f)[a])==null?l:s(u)}},function(t,o,e){var i=e(20),s=e(15);t.exports=function(a){return function(c,l){var u,f,h=String(s(c)),d=i(l),p=h.length;return d<0||d>=p?a?"":void 0:(u=h.charCodeAt(d),u<55296||u>56319||d+1===p||(f=h.charCodeAt(d+1))<56320||f>57343?a?h.charAt(d):u:a?h.slice(d,d+2):(u-55296<<10)+(f-56320)+65536)}}},function(t,o,e){var i=e(20),s=Math.max,a=Math.min;t.exports=function(c,l){return c=i(c),c<0?s(c+l,0):a(c,l)}},function(t,o,e){var i=e(15);t.exports=function(s){return Object(i(s))}},function(t,o,e){var i=e(21),s=e(1)("iterator"),a=e(10);t.exports=e(6).getIteratorMethod=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[i(c)]}},function(t,o,e){"use strict";var i=e(37),s=e(47),a=e(10),c=e(13);t.exports=e(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(t,o){},function(t,o,e){"use strict";var i,s,a,c=e(28),l=e(2),u=e(7),f=e(21),h=e(23),d=e(9),p=(e(3),e(14)),y=e(38),E=e(40),I=(e(58).set,e(60)),x=e(30).set,b=e(48)(),S="Promise",R=l.TypeError,k=l.process,v=l[S],k=l.process,A=f(k)=="process",M=function(){},F=!!(function(){try{var m=v.resolve(1),g=(m.constructor={})[e(1)("species")]=function(T){T(M,M)};return(A||typeof PromiseRejectionEvent=="function")&&m.then(M)instanceof g}catch{}})(),q=function(m,g){return m===g||m===v&&g===a},X=function(m){var g;return!(!d(m)||typeof(g=m.then)!="function")&&g},G=function(m){return q(v,m)?new oe(m):new s(m)},oe=s=function(m){var g,T;this.promise=new m(function(O,K){if(g!==void 0||T!==void 0)throw R("Bad Promise constructor");g=O,T=K}),this.resolve=p(g),this.reject=p(T)},me=function(m){try{m()}catch(g){return{error:g}}},le=function(m,g){if(!m._n){m._n=!0;var T=m._c;b(function(){for(var O=m._v,K=m._s==1,ue=0,ge=function(se){var te,je,Ae=K?se.ok:se.fail,Oe=se.resolve,ye=se.reject,Ue=se.domain;try{Ae?(K||(m._h==2&&ie(m),m._h=1),Ae===!0?te=O:(Ue&&Ue.enter(),te=Ae(O),Ue&&Ue.exit()),te===se.promise?ye(R("Promise-chain cycle")):(je=X(te))?je.call(te,Oe,ye):Oe(te)):ye(O)}catch(Wn){ye(Wn)}};T.length>ue;)ge(T[ue++]);m._c=[],m._n=!1,g&&!m._h&&ke(m)})}},ke=function(m){x.call(l,function(){var g,T,O,K=m._v;if(H(m)&&(g=me(function(){A?k.emit("unhandledRejection",K,m):(T=l.onunhandledrejection)?T({promise:m,reason:K}):(O=l.console)&&O.error&&O.error("Unhandled promise rejection",K)}),m._h=A||H(m)?2:1),m._a=void 0,g)throw g.error})},H=function(m){if(m._h==1)return!1;for(var g,T=m._a||m._c,O=0;T.length>O;)if(g=T[O++],g.fail||!H(g.promise))return!1;return!0},ie=function(m){x.call(l,function(){var g;A?k.emit("rejectionHandled",m):(g=l.onrejectionhandled)&&g({promise:m,reason:m._v})})},W=function(m){var g=this;g._d||(g._d=!0,g=g._w||g,g._v=m,g._s=2,g._a||(g._a=g._c.slice()),le(g,!0))},Re=function(m){var g,T=this;if(!T._d){T._d=!0,T=T._w||T;try{if(T===m)throw R("Promise can't be resolved itself");(g=X(m))?b(function(){var O={_w:T,_d:!1};try{g.call(m,u(Re,O,1),u(W,O,1))}catch(K){W.call(O,K)}}):(T._v=m,T._s=1,le(T,!1))}catch(O){W.call({_w:T,_d:!1},O)}}};F||(v=function(m){y(this,v,S,"_h"),p(m),i.call(this);try{m(u(Re,this,1),u(W,this,1))}catch(g){W.call(this,g)}},i=function(m){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=e(56)(v.prototype,{then:function(m,g){var T=G(I(this,v));return T.ok=typeof m!="function"||m,T.fail=typeof g=="function"&&g,T.domain=A?k.domain:void 0,this._c.push(T),this._a&&this._a.push(T),this._s&&le(this,!1),T.promise},catch:function(m){return this.then(void 0,m)}}),oe=function(){var m=new i;this.promise=m,this.resolve=u(Re,m,1),this.reject=u(W,m,1)}),h(h.G+h.W+h.F*!F,{Promise:v}),e(18)(v,S),e(59)(S),a=e(6)[S],h(h.S+h.F*!F,S,{reject:function(m){var g=G(this),T=g.reject;return T(m),g.promise}}),h(h.S+h.F*(c||!F),S,{resolve:function(m){if(m instanceof v&&q(m.constructor,this))return m;var g=G(this),T=g.resolve;return T(m),g.promise}}),h(h.S+h.F*!(F&&e(46)(function(m){v.all(m).catch(M)})),S,{all:function(m){var g=this,T=G(g),O=T.resolve,K=T.reject,ue=me(function(){var ge=[],se=0,te=1;E(m,!1,function(je){var Ae=se++,Oe=!1;ge.push(void 0),te++,g.resolve(je).then(function(ye){Oe||(Oe=!0,ge[Ae]=ye,--te||O(ge))},K)}),--te||O(ge)});return ue&&K(ue.error),T.promise},race:function(m){var g=this,T=G(g),O=T.reject,K=me(function(){E(m,!1,function(ue){g.resolve(ue).then(T.resolve,O)})});return K&&O(K.error),T.promise}})},function(t,o,e){"use strict";var i=e(61)(!0);e(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(t,o,e){e(65);for(var i=e(2),s=e(5),a=e(10),c=e(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],h=i[f],d=h&&h.prototype;d&&!d[c]&&s(d,c,f),a[f]=a.Array}},function(t,o){t.exports=require("child_process")},function(t,o){t.exports=require("crypto")}])})});var Bt=(n=0)=>r=>`\x1B[${r+n}m`,Dt=(n=0)=>r=>`\x1B[${38+n};5;${r}m`,jt=(n=0)=>(r,t,o)=>`\x1B[${38+n};2;${r};${t};${o}m`,P={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]}},no=Object.keys(P.modifier),zn=Object.keys(P.color),Zn=Object.keys(P.bgColor),ro=[...zn,...Zn];function er(){let n=new Map;for(let[r,t]of Object.entries(P)){for(let[o,e]of Object.entries(t))P[o]={open:`\x1B[${e[0]}m`,close:`\x1B[${e[1]}m`},t[o]=P[o],n.set(e[0],e[1]);Object.defineProperty(P,r,{value:t,enumerable:!1})}return Object.defineProperty(P,"codes",{value:n,enumerable:!1}),P.color.close="\x1B[39m",P.bgColor.close="\x1B[49m",P.color.ansi=Bt(),P.color.ansi256=Dt(),P.color.ansi16m=jt(),P.bgColor.ansi=Bt(10),P.bgColor.ansi256=Dt(10),P.bgColor.ansi16m=jt(10),Object.defineProperties(P,{rgbToAnsi256:{value(r,t,o){return r===t&&t===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(t/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(r){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!t)return[0,0,0];let[o]=t;o.length===3&&(o=[...o].map(i=>i+i).join(""));let e=Number.parseInt(o,16);return[e>>16&255,e>>8&255,e&255]},enumerable:!1},hexToAnsi256:{value:r=>P.rgbToAnsi256(...P.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let t,o,e;if(r>=232)t=((r-232)*10+8)/255,o=t,e=t;else{r-=16;let a=r%36;t=Math.floor(r/36)/5,o=Math.floor(a/6)/5,e=a%6/5}let i=Math.max(t,o,e)*2;if(i===0)return 30;let s=30+(Math.round(e)<<2|Math.round(o)<<1|Math.round(t));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(r,t,o)=>P.ansi256ToAnsi(P.rgbToAnsi256(r,t,o)),enumerable:!1},hexToAnsi:{value:r=>P.ansi256ToAnsi(P.hexToAnsi256(r)),enumerable:!1}}),P}var tr=er(),z=tr;var Ke=L(require("node:process"),1),Ft=L(require("node:os"),1),ct=L(require("node:tty"),1);function V(n,r=globalThis.Deno?globalThis.Deno.args:Ke.default.argv){let t=n.startsWith("-")?"":n.length===1?"-":"--",o=r.indexOf(t+n),e=r.indexOf("--");return o!==-1&&(e===-1||o<e)}var{env:C}=Ke.default,Fe;V("no-color")||V("no-colors")||V("color=false")||V("color=never")?Fe=0:(V("color")||V("colors")||V("color=true")||V("color=always"))&&(Fe=1);function nr(){if("FORCE_COLOR"in C)return C.FORCE_COLOR==="true"?1:C.FORCE_COLOR==="false"?0:C.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(C.FORCE_COLOR,10),3)}function rr(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function or(n,{streamIsTTY:r,sniffFlags:t=!0}={}){let o=nr();o!==void 0&&(Fe=o);let e=t?Fe:o;if(e===0)return 0;if(t){if(V("color=16m")||V("color=full")||V("color=truecolor"))return 3;if(V("color=256"))return 2}if("TF_BUILD"in C&&"AGENT_NAME"in C)return 1;if(n&&!r&&e===void 0)return 0;let i=e||0;if(C.TERM==="dumb")return i;if(Ke.default.platform==="win32"){let s=Ft.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in C)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in C)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in C)||C.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in C)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(C.TEAMCITY_VERSION)?1:0;if(C.COLORTERM==="truecolor"||C.TERM==="xterm-kitty"||C.TERM==="xterm-ghostty"||C.TERM==="wezterm")return 3;if("TERM_PROGRAM"in C){let s=Number.parseInt((C.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(C.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(C.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(C.TERM)||"COLORTERM"in C?1:i}function Ut(n,r={}){let t=or(n,{streamIsTTY:n&&n.isTTY,...r});return rr(t)}var ir={stdout:Ut({isTTY:ct.default.isatty(1)}),stderr:Ut({isTTY:ct.default.isatty(2)})},Kt=ir;function Gt(n,r,t){let o=n.indexOf(r);if(o===-1)return n;let e=r.length,i=0,s="";do s+=n.slice(i,o)+r+t,i=o+e,o=n.indexOf(r,i);while(o!==-1);return s+=n.slice(i),s}function Ht(n,r,t,o){let e=0,i="";do{let s=n[o-1]==="\r";i+=n.slice(e,s?o-1:o)+r+(s?`\r
|
|
9
9
|
`:`
|
|
10
|
-
`)+t,e=o+1,o=
|
|
11
|
-
`,e)}while(o!==-1);return i+=
|
|
12
|
-
`);return i!==-1&&(
|
|
13
|
-
|
|
14
|
-
`)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
call npm cache clean --force >nul 2>&1
|
|
21
|
-
call npm install -g ${Y}@latest --prefer-online
|
|
22
|
-
|
|
23
|
-
if %ERRORLEVEL% EQU 0 (
|
|
24
|
-
echo \u2705 Update completed successfully
|
|
25
|
-
echo \u{1F680} Restarting with new version...
|
|
26
|
-
${Y} ${g} --skip-update
|
|
27
|
-
) else (
|
|
28
|
-
echo \u274C Update failed
|
|
29
|
-
echo \u{1F4A1} Try manually: npm install -g ${Y}
|
|
30
|
-
echo \u{1F504} Starting with current version...
|
|
31
|
-
${Y} ${g} --skip-update
|
|
32
|
-
)
|
|
33
|
-
`;k=je.default.join(xt.default.tmpdir(),`${Y}-update.bat`),(0,he.writeFileSync)(k,b),_=["cmd.exe",["/c",k]]}else{let b=`#!/bin/bash
|
|
34
|
-
echo "\u{1F4E5} Downloading update..."
|
|
35
|
-
echo "\u23F3 Waiting for process to exit..."
|
|
36
|
-
sleep 1
|
|
37
|
-
|
|
38
|
-
pkill -f "${Y}" 2>/dev/null || true
|
|
39
|
-
sleep 1
|
|
40
|
-
|
|
41
|
-
echo "\u{1F504} Installing new version..."
|
|
42
|
-
npm cache clean --force 2>/dev/null
|
|
43
|
-
|
|
44
|
-
# Try to install with full output for debugging
|
|
45
|
-
npm install -g ${Y}@latest --prefer-online 2>&1
|
|
46
|
-
EXIT_CODE=$?
|
|
47
|
-
|
|
48
|
-
if [ $EXIT_CODE -eq 0 ]; then
|
|
49
|
-
echo "\u2705 Update completed successfully"
|
|
50
|
-
echo "\u{1F680} Restarting with new version..."
|
|
51
|
-
${Y} ${g} --skip-update
|
|
52
|
-
else
|
|
53
|
-
echo "\u274C Update failed (exit code: $EXIT_CODE)"
|
|
54
|
-
echo "\u{1F4A1} Update manually: npm install -g ${Y}@latest"
|
|
55
|
-
echo "\u{1F504} Starting with current version..."
|
|
56
|
-
${Y} ${g} --skip-update
|
|
57
|
-
fi
|
|
58
|
-
`;k=je.default.join(xt.default.tmpdir(),`${Y}-update.sh`),(0,he.writeFileSync)(k,b,{mode:493}),_=["sh",[k]]}(0,On.spawn)(_[0],_[1],{detached:!0,stdio:"inherit"}).unref(),process.exit(0)}).catch(()=>{clearTimeout(u),l(!1)})})}var N=M(require("fs"),1),de=M(require("path"),1),Bn=M(require("https"),1),me=M(require("os"),1),Ze=require("child_process"),St=null,Lr=null,$r=null,Ue=de.default.join(me.default.homedir(),".9remote","bin"),Nn="cloudflared",kt=me.default.platform()==="win32",Nr=kt?`${Nn}.exe`:Nn,Se=de.default.join(Ue,Nr),ze=de.default.join(me.default.homedir(),".9remote","cloudflared.pid"),Rt=!1,Br=5,Dr=6e4,Fe=[],At=null,jr="https://github.com/cloudflare/cloudflared/releases/latest/download",Ur={darwin:{x64:"cloudflared-darwin-amd64.tgz",arm64:"cloudflared-darwin-amd64.tgz"},win32:{x64:"cloudflared-windows-amd64.exe"},linux:{x64:"cloudflared-linux-amd64",arm64:"cloudflared-linux-arm64"}};function Fr(){let r=me.default.platform(),n=me.default.arch(),t=Ur[r];if(!t)throw new Error(`Unsupported platform: ${r}`);let o=t[n];if(!o)throw new Error(`Unsupported architecture: ${n} for platform ${r}`);return`${jr}/${o}`}async function Dn(r,n){return new Promise((t,o)=>{let e=N.default.createWriteStream(n);Bn.default.get(r,i=>{if([301,302].includes(i.statusCode)){e.close(),N.default.unlinkSync(n),Dn(i.headers.location,n).then(t).catch(o);return}if(i.statusCode!==200){e.close(),N.default.unlinkSync(n),o(new Error(`Download failed with status ${i.statusCode}`));return}i.pipe(e),e.on("finish",()=>{e.close(()=>t(n))}),e.on("error",s=>{e.close(),N.default.unlinkSync(n),o(s)})}).on("error",i=>{e.close(),N.default.existsSync(n)&&N.default.unlinkSync(n),o(i)})})}async function et(){if(N.default.existsSync(Ue)||N.default.mkdirSync(Ue,{recursive:!0}),N.default.existsSync(Se))return kt||N.default.chmodSync(Se,"755"),Se;console.log("\u{1F4E5} Downloading tunnel binary...");let r=Fr(),n=r.endsWith(".tgz"),t=n?de.default.join(Ue,"cloudflared.tgz"):Se;try{return await Dn(r,t),n&&(console.log("\u2705 Extracting..."),(0,Ze.execSync)(`tar -xzf "${t}" -C "${Ue}"`,{stdio:"pipe"}),N.default.unlinkSync(t)),kt||N.default.chmodSync(Se,"755"),console.log("\u2705 cloudflared ready"),Se}catch(o){throw console.error("\u274C Failed to download cloudflared:",o.message),o}}function Kr(r){let n=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,t=[];for(let o of r.matchAll(n))o[1]!=="api"&&t.push(`https://${o[1]}.trycloudflare.com`);return t.length?t[t.length-1]:null}async function tt(r,n=null){let t=await et(),o=N.default.mkdtempSync(de.default.join(me.default.tmpdir(),"9remote-quick-")),e=de.default.join(o,"config.yml");N.default.writeFileSync(e,`# quick-tunnel
|
|
59
|
-
`,"utf8");let i=!1,s=()=>{if(!i){i=!0;try{N.default.rmSync(o,{recursive:!0,force:!0})}catch{}}},a=(0,Ze.spawn)(t,["tunnel","--url",`http://localhost:${r}`,"--config",e,"--no-autoupdate"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return N.default.writeFileSync(ze,a.pid.toString()),Rt=!1,new Promise((c,l)=>{let u=!1,f=null,h=setTimeout(()=>{u||(u=!0,s(),l(new Error("Quick tunnel timed out after 90s")))},9e4),d=p=>{let g=p.toString(),T=Kr(g);if(T){if(!u){u=!0,f=T,clearTimeout(h),s(),c({child:a,tunnelUrl:T});return}T!==f&&(f=T,n?.(T))}};a.stdout.on("data",d),a.stderr.on("data",d),a.on("error",p=>{u||(u=!0,clearTimeout(h),s(),l(p))}),a.on("exit",p=>{if(s(),!u){u=!0,clearTimeout(h),l(new Error(`cloudflared exited with code ${p}`));return}if(!Rt&&At){let g=Date.now();Fe.push(g),Fe=Fe.filter(T=>T>g-Dr),Fe.length<=Br&&setTimeout(()=>At(r),2e3)}})})}function Ot(){try{if(N.default.existsSync(ze)){Rt=!0;let r=parseInt(N.default.readFileSync(ze,"utf8"));process.kill(r),N.default.unlinkSync(ze),console.log("\u2705 Cloudflared killed")}}catch{}}function jn(){Fe=[],At=null,$r=null,Gr()}function Gr(){St&&(clearInterval(St),St=null),Lr=null}var Pt=M(require("readline"),1),Fn=M(require("http"),1);var Un=require("child_process"),Hr={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function nt(r){let n=Hr[r];n&&process.platform==="darwin"&&(0,Un.exec)(`open "${n}"`,()=>{})}var S={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"},Wr=()=>Math.min(44,process.stdout.columns||44);function ot(r,n=null){let o=Wr()-2,e=(s="")=>{let a=s.replace(/\x1b\[[0-9;]*m/g,""),c=Math.max(0,o-a.length);return S.orange+"\u2551"+S.reset+s+" ".repeat(c)+S.orange+"\u2551"+S.reset},i=(s,a=c=>c)=>{let c=s.replace(/\x1b\[[0-9;]*m/g,""),l=Math.floor((o-c.length)/2),u=o-c.length-l;return S.orange+"\u2551"+S.reset+" ".repeat(l)+a(s)+" ".repeat(u)+S.orange+"\u2551"+S.reset};if(console.log(""),console.log(S.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+S.reset),console.log(e()),console.log(i(`\u{1F680} 9Remote v${r}`,s=>S.bold+S.orange+s+S.reset)),console.log(i("Remote terminal access from anywhere",s=>S.dim+s+S.reset)),console.log(e()),n){let s=`\u2B06 New version v${n} available!`;console.log(i(s,c=>S.yellow+S.bold+c+S.reset)),console.log(i("Run: npm i -g 9remote@latest",c=>S.dim+c+S.reset)),console.log(e())}console.log(S.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+S.reset),console.log("")}var Qr=[{label:"Preparing",desc:"Checking dependencies"},{label:"Connecting",desc:"Creating session"},{label:"Starting tunnel",desc:"Spawning cloudflared"},{label:"Ready",desc:"Tunnel is live"}],rt=0;function it(r,n=!1){n&&rt>0&&process.stdout.write(`\x1B[${rt}A\x1B[0J`);let t=[];Qr.forEach((o,e)=>{e<r?t.push(` ${S.green}\u2713${S.reset} ${S.dim}${o.label}${S.reset}`):e===r?t.push(` ${S.orange}\u25CF${S.reset} ${S.bold}${o.label}${S.reset} ${S.dim}${o.desc}${S.reset}`):t.push(` ${S.dim}\u25CB ${o.label}${S.reset}`)}),t.forEach(o=>console.log(o)),rt=t.length}function Kn(){rt=0}function Ct(r,n,t=0,o="",e=null,i=null){return new Promise(s=>{let a=t,c=!0,l=process.platform==="win32",u=()=>{if(!c)return;process.stdout.write("\x1B[2J\x1B[H");let d=typeof o=="function"?o():o;d&&process.stdout.write(d+`
|
|
60
|
-
`),process.stdout.write(`${S.dim}${r}${S.reset}
|
|
61
|
-
|
|
62
|
-
`),n.forEach((p,g)=>{let T=g===a?l?">":"\u2605":l?" ":"\u2606";console.log(g===a?` \x1B[7m${S.bold}${T} ${p.label}${S.reset}`:` ${T} ${p.label}`)})},f=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",h),process.stdin.pause()}},h=(d,p)=>{!c||!p||(p.name==="up"?(a=(a-1+n.length)%n.length,u()):p.name==="down"?(a=(a+1)%n.length,u()):p.name==="return"?(f(),s(a)):p.name==="escape"?(f(),s(-1)):p.ctrl&&p.name==="c"&&(f(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),Pt.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{s(-1);return}process.stdin.on("keypress",h),process.stdin.resume(),u(),e&&e(u)})}function Gn(r){return new Promise(n=>{if(process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeAllListeners("keypress");let t=Pt.default.createInterface({input:process.stdin,output:process.stdout});t.question(`${r} (y/N): `,o=>{t.close(),n(o.trim().toLowerCase()==="y")})})}function Hn(r,n){let t=null,o=!1,e=()=>{o||(t=Fn.default.get(`http://localhost:${r}/api/ui/events`,i=>{let s="";i.on("data",a=>{s+=a.toString();let c=s.split(`
|
|
63
|
-
`);s=c.pop();let l="";for(let u of c)if(u.startsWith("data: "))l=u.slice(6);else if(u===""&&l){try{let f=JSON.parse(l);n(f.type,f)}catch{}l=""}}),i.on("end",()=>{o||setTimeout(e,2e3)})}),t.on("error",()=>{o||setTimeout(e,2e3)}))};return e(),()=>{o=!0,t?.destroy()}}var Yr=process.argv.includes("--skip-update"),ct=ge.default.dirname((0,Vn.fileURLToPath)(__importMetaUrl)),Xo=ge.default.resolve(ct,"../.."),Vr=ge.default.resolve(ct,"../dist/server.cjs"),Wn=ge.default.resolve(ct,"../index.js"),U="https://9remote.cc",B=2208,It=10,Qn=6e4,te=v.rgb(230,138,110),qn=v.rgb(200,120,95);function Lt(){return"0.1.62"}function Jr(r,n="\u{1F4F1} Scan QR to connect:"){console.log(te(`
|
|
64
|
-
${n}`)),Mt.default.generate(r,{small:!0,type:"terminal",margin:0},t=>{console.log(t.trim())})}function qr(r){return new Promise(n=>{Mt.default.generate(r,{small:!0,type:"terminal",margin:0},t=>{n(qn("\u{1F4F1} Scan QR to connect:")+`
|
|
65
|
-
`+t.trim())})})}async function Xn(r,n){let t=await De(r,U);if(!t){console.log(v.red("\u274C Failed to create temp key"));return}let o=`${U}/login?k=${t.tempKey}`,e=Math.min(44,process.stdout.columns||55);D({step:4,tunnelUrl:n,oneTimeKey:t.tempKey,oneTimeKeyExpiresAt:t.expiresAt,permanentKey:r,qrUrl:o,workerUrl:U}),Jr(o),console.log(v.gray(`
|
|
10
|
+
`)+t,e=o+1,o=n.indexOf(`
|
|
11
|
+
`,e)}while(o!==-1);return i+=n.slice(e),i}var{stdout:Wt,stderr:Qt}=Kt,lt=Symbol("GENERATOR"),ve=Symbol("STYLER"),Pe=Symbol("IS_EMPTY"),Yt=["ansi","ansi","ansi256","ansi16m"],we=Object.create(null),sr=(n,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Wt?Wt.level:0;n.level=r.level===void 0?t:r.level};var ar=n=>{let r=(...t)=>t.join(" ");return sr(r,n),Object.setPrototypeOf(r,Ce.prototype),r};function Ce(n){return ar(n)}Object.setPrototypeOf(Ce.prototype,Function.prototype);for(let[n,r]of Object.entries(z))we[n]={get(){let t=Ge(this,ft(r.open,r.close,this[ve]),this[Pe]);return Object.defineProperty(this,n,{value:t}),t}};we.visible={get(){let n=Ge(this,this[ve],!0);return Object.defineProperty(this,"visible",{value:n}),n}};var ut=(n,r,t,...o)=>n==="rgb"?r==="ansi16m"?z[t].ansi16m(...o):r==="ansi256"?z[t].ansi256(z.rgbToAnsi256(...o)):z[t].ansi(z.rgbToAnsi(...o)):n==="hex"?ut("rgb",r,t,...z.hexToRgb(...o)):z[t][n](...o),cr=["rgb","hex","ansi256"];for(let n of cr){we[n]={get(){let{level:t}=this;return function(...o){let e=ft(ut(n,Yt[t],"color",...o),z.color.close,this[ve]);return Ge(this,e,this[Pe])}}};let r="bg"+n[0].toUpperCase()+n.slice(1);we[r]={get(){let{level:t}=this;return function(...o){let e=ft(ut(n,Yt[t],"bgColor",...o),z.bgColor.close,this[ve]);return Ge(this,e,this[Pe])}}}}var lr=Object.defineProperties(()=>{},{...we,level:{enumerable:!0,get(){return this[lt].level},set(n){this[lt].level=n}}}),ft=(n,r,t)=>{let o,e;return t===void 0?(o=n,e=r):(o=t.openAll+n,e=r+t.closeAll),{open:n,close:r,openAll:o,closeAll:e,parent:t}},Ge=(n,r,t)=>{let o=(...e)=>ur(o,e.length===1?""+e[0]:e.join(" "));return Object.setPrototypeOf(o,lr),o[lt]=n,o[ve]=r,o[Pe]=t,o},ur=(n,r)=>{if(n.level<=0||!r)return n[Pe]?"":r;let t=n[ve];if(t===void 0)return r;let{openAll:o,closeAll:e}=t;if(r.includes("\x1B"))for(;t!==void 0;)r=Gt(r,t.close,t.open),t=t.parent;let i=r.indexOf(`
|
|
12
|
+
`);return i!==-1&&(r=Ht(r,e,o,i)),o+r+e};Object.defineProperties(Ce.prototype,we);var fr=Ce(),uo=Ce({level:Qt?Qt.level:0});var w=fr;var Ct=L(vn(),1),xe=require("child_process"),de=L(require("path"),1),Un=require("url"),ot=L(require("fs"),1),Fn=L(require("os"),1);var Tn=L(wn(),1),vt=L(require("crypto"),1),{machineIdSync:Tr}=Tn.default;async function Te(n=null){let r=n||process.env.MACHINE_ID_SALT||"9remote-salt";try{let t=Tr();return vt.default.createHash("sha256").update(t+r).digest("hex").substring(0,16)}catch(t){return console.error("Error getting machine ID:",t),vt.default.randomUUID().replace(/-/g,"").substring(0,16)}}var En=L(require("crypto"),1),Er=process.env.API_KEY_SECRET||"9remote-api-key-secret";function br(){let n="abcdefghijklmnopqrstuvwxyz0123456789",r="";for(let t=0;t<4;t++)r+=n.charAt(Math.floor(Math.random()*n.length));return r}function _r(n,r){return En.default.createHmac("sha256",Er).update(n+r).digest("hex").slice(0,6)}function Ee(n){let r=n.slice(0,8),t=br(),o=_r(r,t);return{key:`sk-${r}-${t}-${o}`,keyId:t}}var Q=L(require("fs"),1),Le=L(require("path"),1),bn=L(require("os"),1),Me=Le.default.join(bn.default.homedir(),".9remote"),wt=Le.default.join(Me,"state.json"),Tt=Le.default.join(Me,"keys.json"),Ye=Le.default.join(Me,"cmd.json");function Ve(){Q.default.existsSync(Me)||Q.default.mkdirSync(Me,{recursive:!0})}function Et(n){try{Ve(),Q.default.writeFileSync(wt,JSON.stringify(n,null,2))}catch(r){console.error("Error saving state:",r)}}function _n(){try{Q.default.existsSync(wt)&&Q.default.unlinkSync(wt)}catch{}}function $e(){try{return Ve(),Q.default.existsSync(Tt)?JSON.parse(Q.default.readFileSync(Tt,"utf8")):{machineId:null,key:null,name:"Default",createdAt:null}}catch{return{machineId:null,key:null,name:"Default",createdAt:null}}}function xn(n){try{Ve(),Q.default.writeFileSync(Ye,JSON.stringify({cmd:n,ts:Date.now()}))}catch{}}function Sn(){try{if(!Q.default.existsSync(Ye))return null;let n=JSON.parse(Q.default.readFileSync(Ye,"utf8"));return Q.default.unlinkSync(Ye),n.cmd}catch{return null}}function be(n,r,t="Default"){try{Ve();let o={machineId:n,key:r,name:t,createdAt:new Date().toISOString()};return Q.default.writeFileSync(Tt,JSON.stringify(o,null,2)),o}catch(o){return console.error("Error saving key:",o),null}}async function Ne(n,r){try{let t=await fetch(`${r}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n,expiryMinutes:30})});if(!t.ok){let o=await t.json();throw new Error(o.error||"Failed to create temp key")}return await t.json()}catch(t){return console.error("Error creating temp key:",t),null}}var Je=require("fs"),kn=require("url");var bt=L(require("path"),1);var xr=bt.default.dirname((0,kn.fileURLToPath)(__importMetaUrl)),Sr="9remote",kr=`https://registry.npmjs.org/${Sr}/latest`,Rr=3e3;function Ar(){return"0.1.64"}function Or(n,r){let t=n.split(".").map(Number),o=r.split(".").map(Number);for(let e=0;e<3;e++){if(o[e]>t[e])return!0;if(o[e]<t[e])return!1}return!1}async function Rn(){try{let n=Ar();if(!n)return null;let r=await fetch(kr,{signal:AbortSignal.timeout(Rr)});if(!r.ok)return null;let{version:t}=await r.json();return t&&Or(n,t)?{current:n,latest:t}:null}catch{return null}}var N=L(require("fs"),1),pe=L(require("path"),1),On=L(require("https"),1),he=L(require("os"),1),Xe=require("child_process"),_t=null,Pr=null,Cr=null,Be=pe.default.join(he.default.homedir(),".9remote","bin"),An="cloudflared",xt=he.default.platform()==="win32",Ir=xt?`${An}.exe`:An,_e=pe.default.join(Be,Ir),qe=pe.default.join(he.default.homedir(),".9remote","cloudflared.pid"),St=!1,Mr=5,Lr=6e4,De=[],kt=null,$r="https://github.com/cloudflare/cloudflared/releases/latest/download",Nr={darwin:{x64:"cloudflared-darwin-amd64.tgz",arm64:"cloudflared-darwin-amd64.tgz"},win32:{x64:"cloudflared-windows-amd64.exe"},linux:{x64:"cloudflared-linux-amd64",arm64:"cloudflared-linux-arm64"}};function Br(){let n=he.default.platform(),r=he.default.arch(),t=Nr[n];if(!t)throw new Error(`Unsupported platform: ${n}`);let o=t[r];if(!o)throw new Error(`Unsupported architecture: ${r} for platform ${n}`);return`${$r}/${o}`}async function Pn(n,r){return new Promise((t,o)=>{let e=N.default.createWriteStream(r);On.default.get(n,i=>{if([301,302].includes(i.statusCode)){e.close(),N.default.unlinkSync(r),Pn(i.headers.location,r).then(t).catch(o);return}if(i.statusCode!==200){e.close(),N.default.unlinkSync(r),o(new Error(`Download failed with status ${i.statusCode}`));return}i.pipe(e),e.on("finish",()=>{e.close(()=>t(r))}),e.on("error",s=>{e.close(),N.default.unlinkSync(r),o(s)})}).on("error",i=>{e.close(),N.default.existsSync(r)&&N.default.unlinkSync(r),o(i)})})}async function ze(){if(N.default.existsSync(Be)||N.default.mkdirSync(Be,{recursive:!0}),N.default.existsSync(_e))return xt||N.default.chmodSync(_e,"755"),_e;console.log("\u{1F4E5} Downloading tunnel binary...");let n=Br(),r=n.endsWith(".tgz"),t=r?pe.default.join(Be,"cloudflared.tgz"):_e;try{return await Pn(n,t),r&&(console.log("\u2705 Extracting..."),(0,Xe.execSync)(`tar -xzf "${t}" -C "${Be}"`,{stdio:"pipe"}),N.default.unlinkSync(t)),xt||N.default.chmodSync(_e,"755"),console.log("\u2705 cloudflared ready"),_e}catch(o){throw console.error("\u274C Failed to download cloudflared:",o.message),o}}function Dr(n){let r=/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/gi,t=[];for(let o of n.matchAll(r))o[1]!=="api"&&t.push(`https://${o[1]}.trycloudflare.com`);return t.length?t[t.length-1]:null}async function Ze(n,r=null){let t=await ze(),o=N.default.mkdtempSync(pe.default.join(he.default.tmpdir(),"9remote-quick-")),e=pe.default.join(o,"config.yml");N.default.writeFileSync(e,`# quick-tunnel
|
|
13
|
+
`,"utf8");let i=!1,s=()=>{if(!i){i=!0;try{N.default.rmSync(o,{recursive:!0,force:!0})}catch{}}},a=(0,Xe.spawn)(t,["tunnel","--url",`http://localhost:${n}`,"--config",e,"--no-autoupdate"],{detached:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return N.default.writeFileSync(qe,a.pid.toString()),St=!1,new Promise((c,l)=>{let u=!1,f=null,h=setTimeout(()=>{u||(u=!0,s(),l(new Error("Quick tunnel timed out after 90s")))},9e4),d=p=>{let y=p.toString(),E=Dr(y);if(E){if(!u){u=!0,f=E,clearTimeout(h),s(),c({child:a,tunnelUrl:E});return}E!==f&&(f=E,r?.(E))}};a.stdout.on("data",d),a.stderr.on("data",d),a.on("error",p=>{u||(u=!0,clearTimeout(h),s(),l(p))}),a.on("exit",p=>{if(s(),!u){u=!0,clearTimeout(h),l(new Error(`cloudflared exited with code ${p}`));return}if(!St&&kt){let y=Date.now();De.push(y),De=De.filter(E=>E>y-Lr),De.length<=Mr&&setTimeout(()=>kt(n),2e3)}})})}function Rt(){try{if(N.default.existsSync(qe)){St=!0;let n=parseInt(N.default.readFileSync(qe,"utf8"));process.kill(n),N.default.unlinkSync(qe),console.log("\u2705 Cloudflared killed")}}catch{}}function Cn(){De=[],kt=null,Cr=null,jr()}function jr(){_t&&(clearInterval(_t),_t=null),Pr=null}var At=L(require("readline"),1),Mn=L(require("http"),1);var In=require("child_process"),Ur={screenRecording:"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",accessibility:"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"};function et(n){let r=Ur[n];r&&process.platform==="darwin"&&(0,In.exec)(`open "${r}"`,()=>{})}var _={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"},Fr=()=>Math.min(44,process.stdout.columns||44);function nt(n,r=null){let o=Fr()-2,e=(s="")=>{let a=s.replace(/\x1b\[[0-9;]*m/g,""),c=Math.max(0,o-a.length);return _.orange+"\u2551"+_.reset+s+" ".repeat(c)+_.orange+"\u2551"+_.reset},i=(s,a=c=>c)=>{let c=s.replace(/\x1b\[[0-9;]*m/g,""),l=Math.floor((o-c.length)/2),u=o-c.length-l;return _.orange+"\u2551"+_.reset+" ".repeat(l)+a(s)+" ".repeat(u)+_.orange+"\u2551"+_.reset};if(console.log(""),console.log(_.orange+"\u2554"+"\u2550".repeat(o)+"\u2557"+_.reset),console.log(e()),console.log(i(`\u{1F680} 9Remote v${n}`,s=>_.bold+_.orange+s+_.reset)),console.log(i("Remote terminal access from anywhere",s=>_.dim+s+_.reset)),console.log(e()),r){let s=`\u2B06 New version v${r} available!`;console.log(i(s,c=>_.yellow+_.bold+c+_.reset)),console.log(i("Run: npm i -g 9remote@latest",c=>_.dim+c+_.reset)),console.log(e())}console.log(_.orange+"\u255A"+"\u2550".repeat(o)+"\u255D"+_.reset),console.log("")}var Kr=[{label:"Preparing",desc:"Checking dependencies"},{label:"Connecting",desc:"Creating session"},{label:"Starting tunnel",desc:"Spawning cloudflared"},{label:"Ready",desc:"Tunnel is live"}],tt=0;function rt(n,r=!1){r&&tt>0&&process.stdout.write(`\x1B[${tt}A\x1B[0J`);let t=[];Kr.forEach((o,e)=>{e<n?t.push(` ${_.green}\u2713${_.reset} ${_.dim}${o.label}${_.reset}`):e===n?t.push(` ${_.orange}\u25CF${_.reset} ${_.bold}${o.label}${_.reset} ${_.dim}${o.desc}${_.reset}`):t.push(` ${_.dim}\u25CB ${o.label}${_.reset}`)}),t.forEach(o=>console.log(o)),tt=t.length}function Ln(){tt=0}function Ot(n,r,t=0,o="",e=null,i=null){return new Promise(s=>{let a=t,c=!0,l=process.platform==="win32",u=()=>{if(!c)return;process.stdout.write("\x1B[2J\x1B[H");let d=typeof o=="function"?o():o;d&&process.stdout.write(d+`
|
|
14
|
+
`),process.stdout.write(`${_.dim}${n}${_.reset}
|
|
15
|
+
|
|
16
|
+
`),r.forEach((p,y)=>{let E=y===a?l?">":"\u2605":l?" ":"\u2606";console.log(y===a?` \x1B[7m${_.bold}${E} ${p.label}${_.reset}`:` ${E} ${p.label}`)})},f=()=>{if(c){if(c=!1,process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeListener("keypress",h),process.stdin.pause()}},h=(d,p)=>{!c||!p||(p.name==="up"?(a=(a-1+r.length)%r.length,u()):p.name==="down"?(a=(a+1)%r.length,u()):p.name==="return"?(f(),s(a)):p.name==="escape"?(f(),s(-1)):p.ctrl&&p.name==="c"&&(f(),i&&i(),process.exit(0)))};if(process.stdin.removeAllListeners("keypress"),At.default.emitKeypressEvents(process.stdin),process.stdin.isTTY)try{process.stdin.setRawMode(!0)}catch{s(-1);return}process.stdin.on("keypress",h),process.stdin.resume(),u(),e&&e(u)})}function $n(n){return new Promise(r=>{if(process.stdin.isTTY)try{process.stdin.setRawMode(!1)}catch{}process.stdin.removeAllListeners("keypress");let t=At.default.createInterface({input:process.stdin,output:process.stdout});t.question(`${n} (y/N): `,o=>{t.close(),r(o.trim().toLowerCase()==="y")})})}function Nn(n,r){let t=null,o=!1,e=()=>{o||(t=Mn.default.get(`http://localhost:${n}/api/ui/events`,i=>{let s="";i.on("data",a=>{s+=a.toString();let c=s.split(`
|
|
17
|
+
`);s=c.pop();let l="";for(let u of c)if(u.startsWith("data: "))l=u.slice(6);else if(u===""&&l){try{let f=JSON.parse(l);r(f.type,f)}catch{}l=""}}),i.on("end",()=>{o||setTimeout(e,2e3)})}),t.on("error",()=>{o||setTimeout(e,2e3)}))};return e(),()=>{o=!0,t?.destroy()}}var Wo=process.argv.includes("--skip-update"),st=de.default.dirname((0,Un.fileURLToPath)(__importMetaUrl)),Qo=de.default.resolve(st,"../.."),Gr=de.default.resolve(st,"../dist/server.cjs"),Bn=de.default.resolve(st,"../index.js"),U="https://9remote.cc",B=2208,Pt=10,Dn=6e4,ee=w.rgb(230,138,110),Kn=w.rgb(200,120,95);function It(){return"0.1.64"}function Hr(n,r="\u{1F4F1} Scan QR to connect:"){console.log(ee(`
|
|
18
|
+
${r}`)),Ct.default.generate(n,{small:!0,type:"terminal",margin:0},t=>{console.log(t.trim())})}function Wr(n){return new Promise(r=>{Ct.default.generate(n,{small:!0,type:"terminal",margin:0},t=>{r(Kn("\u{1F4F1} Scan QR to connect:")+`
|
|
19
|
+
`+t.trim())})})}async function Gn(n,r){let t=await Ne(n,U);if(!t){console.log(w.red("\u274C Failed to create temp key"));return}let o=`${U}/login?k=${t.tempKey}`,e=Math.min(44,process.stdout.columns||55);D({step:4,tunnelUrl:r,oneTimeKey:t.tempKey,oneTimeKeyExpiresAt:t.expiresAt,permanentKey:n,qrUrl:o,workerUrl:U}),Hr(o),console.log(w.gray(`
|
|
66
20
|
QR will expire in 30 minutes (one-time use)
|
|
67
|
-
`)),console.log(
|
|
21
|
+
`)),console.log(ee("\u2550".repeat(e)));let i="App URL",s=`${U}/login`;console.log(w.white(i.padEnd(14))+w.gray(s));let a="One-Time Key",c=t.tempKey;console.log(w.white(a.padEnd(14))+ee.bold(c));let l="Key",u=n;console.log(w.white(l.padEnd(14))+w.gray(u)),console.log(ee("\u2550".repeat(e)))}async function it(n,r,t){let o=Math.min(44,process.stdout.columns||44),e=[];if(n&&t){let i=await Wr(t);e.push(i),e.push(w.gray(`
|
|
68
22
|
QR expires in 30 minutes (one-time use)
|
|
69
|
-
`))}else e.push(
|
|
23
|
+
`))}else e.push(w.gray(`
|
|
70
24
|
(One-time key used \u2014 generate a new one from menu)
|
|
71
|
-
`));return e.push(
|
|
72
|
-
`)}function
|
|
73
|
-
\u{1F4A5} Server crashed (code: ${u}, signal: ${f})`));let h=Date.now();for(t.push(h);t.length>0&&t[0]<h-
|
|
74
|
-
|
|
75
|
-
\u{1F6D1} Stopping server...`)),
|
|
76
|
-
\u{1F680} Starting server...`)),D({step:1});try{
|
|
77
|
-
\u274C Failed to connect: ${p.message}`)),process.exit(1)}
|
|
78
|
-
\u274C Tunnel failed: ${p.message}`)),process.exit(1)}await
|
|
25
|
+
`));return e.push(ee("\u2550".repeat(o)),w.white("App URL".padEnd(14))+w.gray(`${U}/login`),w.white("One-Time Key".padEnd(14))+(n?ee.bold(n)+w.dim(" (expires in 30m)"):w.gray("\u2014")),w.white("Key".padEnd(14))+w.dim(r),ee("\u2550".repeat(o))),e.join(`
|
|
26
|
+
`)}function at(n){try{process.platform==="win32"?(0,xe.execSync)(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${n}') do taskkill /F /PID %a`,{stdio:"ignore"}):(0,xe.execSync)(`lsof -ti:${n} | xargs kill -9 2>/dev/null || true`,{stdio:"ignore"})}catch{}}function Mt(n,r){let t=[],o=null,e=!1,i=!0,s=()=>{i&&(at(B),i=!1);let a=process.env.NODE_ENV==="development"&&ot.default.existsSync(Bn),c=a?Bn:Gr;ot.default.existsSync(c)||(console.error(`\u274C Server not found: ${c}`),process.exit(1));let l={...process.env,PORT:String(B)};a||delete l.NODE_ENV,o=(0,xe.spawn)("node",[c],{cwd:de.default.dirname(c),stdio:["ignore","inherit","inherit"],detached:!1,env:l}),o.on("exit",(u,f)=>{if(!e&&(u!==0||f)){console.log(w.red(`
|
|
27
|
+
\u{1F4A5} Server crashed (code: ${u}, signal: ${f})`));let h=Date.now();for(t.push(h);t.length>0&&t[0]<h-Dn;)t.shift();t.length>Pt&&(console.log(w.red(`\u274C Too many restarts (${Pt} in ${Dn/1e3}s). Giving up.`)),process.exit(1)),console.log(w.yellow(`\u{1F504} Restarting server... (attempt ${t.length}/${Pt})`)),console.log(Kn("\u26A0\uFE0F [DEBUG] NOTE: Tunnel connection may be stale - will restart tunnel")),r&&(console.log(w.yellow("\u2705 Restarting tunnel connection...")),r()),setTimeout(()=>{s()},1e3)}}),o.on("error",u=>{console.log(w.red(`\u274C Server error: ${u.message}`))}),n&&n(o)};return s(),{getProcess:()=>o,shutdown:()=>{e=!0,o&&o.kill()}}}var jn=!1;function Lt(n,r,t){jn||(jn=!0,process.on("SIGINT",async()=>{console.log(w.yellow(`
|
|
28
|
+
|
|
29
|
+
\u{1F6D1} Stopping server...`)),n.shutdown(),r&&r.kill(),at(B),Cn(),_n(),console.log(w.green("\u2705 Server stopped")),process.exit(0)}))}function Qr(){let n=Fn.default.networkInterfaces();for(let r of Object.values(n))for(let t of r)if(t.family==="IPv4"&&!t.internal)return t.address;return null}async function D(n){try{await fetch(`http://localhost:${B}/api/ui/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}async function Se(n,r){let t=Qr();try{await fetch(`${U}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n,tunnelUrl:r,localIp:t?`${t}:${B}`:null})})}catch{}}async function Yr(n){console.log(ee(`
|
|
30
|
+
\u{1F680} Starting server...`)),D({step:1});try{Rt(),await new Promise(i=>setTimeout(i,500))}catch{}try{let i=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n})});if(!i.ok){let s=await i.text();return console.log(w.red(`\u274C Failed to create session: ${i.status} ${s.substring(0,200)}`)),null}}catch(i){return console.log(w.red(`\u274C Failed to create session: ${i.message}`)),null}let r=await $t(),t=r?{getProcess:()=>null,shutdown:()=>{}}:Mt(null,null);r||await new Promise(i=>setTimeout(i,2e3)),console.log(ee("\u2705 Starting tunnel...")),D({step:2});let o,e;try{let i=await Ze(B,async s=>{console.log(ee(`\u{1F504} Tunnel URL rotated: ${s}`)),await Se(n,s),D({tunnelUrl:s})});o=i.child,e=i.tunnelUrl}catch(i){return console.log(w.red(`\u274C Failed to start tunnel: ${i.message}`)),t.shutdown(),null}return await Se(n,e),Et({apiKey:n,tunnelUrl:e,serverPid:t.getProcess()?.pid,tunnelPid:o.pid}),{serverManager:t,tunnelProcess:o,tunnelUrl:e}}async function Vr(){console.clear();let n=await Te(),r=$e();if(!r.key){let{key:p}=Ee(n);r=be(n,p,"Default")}let t={getProcess:()=>null,shutdown:()=>{}},[o]=await Promise.all([Rn(),(async()=>{await $t()||(t=Mt(null,null),await new Promise(y=>setTimeout(y,2e3)))})()]),e=It();nt(e,o?.latest??null),Ln(),rt(0);try{Rt(),await new Promise(p=>setTimeout(p,300))}catch{}await ze(),rt(1,!0);try{let p=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:r.key})});if(!p.ok)throw new Error(`Session create failed: ${p.status}`)}catch(p){console.log(w.red(`
|
|
31
|
+
\u274C Failed to connect: ${p.message}`)),process.exit(1)}rt(2,!0);let i,s;try{let p=await Ze(B,async y=>{await Se(r.key,y),await D({tunnelUrl:y})});i=p.child,s=p.tunnelUrl}catch(p){console.log(w.red(`
|
|
32
|
+
\u274C Tunnel failed: ${p.message}`)),process.exit(1)}await Se(r.key,s),Et({apiKey:r.key,tunnelUrl:s,tunnelPid:i.pid});let a=await Ne(r.key,U),c=a?`${U}/login?k=${a.tempKey}`:`${U}/login`;await D({step:4,tunnelUrl:s,oneTimeKey:a?.tempKey||"",oneTimeKeyExpiresAt:a?.expiresAt||null,permanentKey:r.key,qrUrl:c,workerUrl:U});let l=a?.tempKey||"",u=c,f=await it(l,r.key,u),h=null,d=Nn(B,async(p,y)=>{if(p==="state"){let E=y.permanentKey||r.key,I=y.oneTimeKey!==void 0?y.oneTimeKey:l,x=y.qrUrl!==void 0?y.qrUrl:u;(I!==l||E!==r.key)&&(l=I,u=x,y.permanentKey&&(r={...r,key:y.permanentKey}),f=await it(l,r.key,u),h?.())}else p==="permissions"&&h?.()});Lt({getProcess:t.getProcess,shutdown:()=>{t.shutdown(),d()}},i,r.key),await qr(r,s,()=>f,p=>{f=p},p=>{h=p},()=>{t.shutdown(),at(B),d()})}async function Jr(){try{let n=await fetch(`http://localhost:${B}/api/ui/state`);if(n.ok)return!!(await n.json()).desktopEnabled}catch{}return!1}async function qr(n,r,t=()=>"",o=()=>{},e=()=>{},i=null){for(;;){let a=`Remote Desktop: ${await Jr()?w.green("ON"):w.gray("OFF")} \u25B6`,c=[{label:"Open Web UI"},{label:"New One-Time Key"},{label:"Regenerate Permanent Key"},{label:a},{label:w.gray("Exit")}],l=null;e(()=>l?.());let u=await Ot("Select action",c,0,t,f=>{l=f},i);if(u===0){let f=`http://localhost:${B}`,h=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";(0,xe.spawn)(h,[f],{detached:!0,stdio:"ignore"}).unref(),console.log(w.green(`
|
|
79
33
|
\u{1F310} Opening ${f}
|
|
80
|
-
`))}else if(u===1){let f=await
|
|
34
|
+
`))}else if(u===1){let f=await Ne(n.key,U);if(f){let h=`${U}/login?k=${f.tempKey}`;o(await it(f.tempKey,n.key,h)),await D({oneTimeKey:f.tempKey,oneTimeKeyExpiresAt:f.expiresAt,qrUrl:h})}}else if(u===2){if(await $n(w.yellow("\u26A0\uFE0F Replace current key and disconnect all sessions? Continue?"))){let h=await Te(),{key:d}=Ee(h);n=be(h,d,n.name||"Default"),await D({permanentKey:n.key});let p=await Ne(n.key,U);if(p){let y=`${U}/login?k=${p.tempKey}`;o(await it(p.tempKey,n.key,y)),await D({oneTimeKey:p.tempKey,oneTimeKeyExpiresAt:p.expiresAt,qrUrl:y})}}}else u===3?await Xr():(at(B),console.log(w.gray(`
|
|
81
35
|
Goodbye!
|
|
82
|
-
`)),process.exit(0))}}async function
|
|
83
|
-
\u{1F310} UI ready at http://localhost:${B}`));let s=null,a=()=>s,c=l=>{s=l};await D({permanentKey:
|
|
36
|
+
`)),process.exit(0))}}async function Xr(){for(;;){let n=!1,r={screenRecording:!1,accessibility:!1};try{let s=await fetch(`http://localhost:${B}/api/ui/state`);if(s.ok){let a=await s.json();n=!!a.desktopEnabled,r={screenRecording:!!a.screenRecording,accessibility:!!a.accessibility}}}catch{}let t=`Toggle: ${n?w.green("ON \u2192 turn OFF"):w.gray("OFF \u2192 turn ON")}`,o=`Screen Recording ${r.screenRecording?w.green("\u2713"):w.red("\u2717 (click to grant)")}`,e=`Mouse & Keyboard control ${r.accessibility?w.green("\u2713"):w.red("\u2717 (click to grant)")}`,i=await Ot("Remote Desktop",[{label:t},{label:o},{label:e},{label:w.gray("\u2190 Back")}],0);if(i===0)try{await fetch(`http://localhost:${B}/api/desktop/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!n})})}catch{}else if(i===1&&!r.screenRecording)try{await fetch(`http://localhost:${B}/api/permissions/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"screenRecording"})})}catch{et("screenRecording")}else if(i===2&&!r.accessibility)try{await fetch(`http://localhost:${B}/api/permissions/request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"accessibility"})})}catch{et("accessibility")}else if(i===3||i===-1)return}}async function zr(){nt(It());let n=await Te(),r=$e();if(!r.key){console.log(w.yellow("\u26A0\uFE0F No key found. Creating default key..."));let{key:c}=Ee(n);r=be(n,c,"Default"),console.log(w.green("\u2705 Default key created!"))}console.log(w.gray(`Using key: ${r.key.slice(0,20)}... (${r.name})`));let t=await Yr(r.key);t||process.exit(1);let{serverManager:o,tunnelProcess:e,tunnelUrl:i}=t;await Gn(r.key,i),Lt(o,e,r.key);let s=e;Hn(()=>s,c=>{s=c},r.key);let a=Date.now();setInterval(()=>{let c=Math.floor((Date.now()-a)/1e3),l=Math.floor(c/3600),u=Math.floor(c%3600/60),f=c%60;D({uptime:`${l}:${String(u).padStart(2,"0")}:${String(f).padStart(2,"0")}`})},5e3),await new Promise(()=>{})}function Hn(n,r,t){let o=!1;setInterval(async()=>{if(o)return;let e=Sn();if(e){o=!0;try{if(e==="stop-tunnel"){let i=n();i&&(i.kill(),r(null),console.log(w.yellow("\u{1F6D1} Tunnel stopped"))),await D({step:0,tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null})}if(e==="start-tunnel"){if(n()){o=!1;return}console.log(ee("\u{1F680} Starting tunnel..."));try{await D({step:1}),await ze(),await D({step:2});let i=await fetch(`${U}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t})});if(!i.ok)throw new Error(`Session create failed: ${i.status}`);await D({step:3});let s=await Ze(B,async a=>{await Se(t,a),await D({tunnelUrl:a})});r(s.child),await Se(t,s.tunnelUrl),await Gn(t,s.tunnelUrl)}catch(i){console.log(w.red(`\u274C Failed to start tunnel: ${i.message}`)),await D({step:0})}}if(e==="regenerate-key"){let i=await Te(),{key:s}=Ee(i),a=$e();be(i,s,a?.name||"Default"),await D({permanentKey:s}),console.log(w.green(`\u2705 Key regenerated: ${s}`))}}finally{o=!1}}},1e3)}async function $t(){try{return(await fetch(`http://localhost:${B}/api/health`)).ok}catch{return!1}}async function Zr(){nt(It());let n=await Te(),r=$e();if(!r.key){let{key:l}=Ee(n);r=be(n,l,"Default")}let t=process.argv.find(l=>l.startsWith("--theme=")),o=t?t.split("=")[1]:null,e=await $t(),i=e?{getProcess:()=>null,shutdown:()=>{}}:Mt(null,null);e||await new Promise(l=>setTimeout(l,2e3)),console.log(w.green(`
|
|
37
|
+
\u{1F310} UI ready at http://localhost:${B}`));let s=null,a=()=>s,c=l=>{s=l};await D({permanentKey:r.key,step:0,theme:o}),Lt(i,null,r.key),Hn(a,c,r.key),process.argv.includes("--start")&&xn("start-tunnel"),await new Promise(()=>{})}async function eo(){let n=process.argv[2];n==="ui"?await Zr():n==="start"||process.argv.includes("--auto")?await zr():await Vr()}eo().catch(console.error);
|