9remote 2.0.2 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/install.cjs +2 -0
- package/dist/ptyDaemon.cjs +1 -1
- package/dist/server.cjs +1 -1
- package/dist/ui/assets/{index-COWVKicT.css → index-BMHG73CL.css} +1 -1
- package/dist/ui/assets/index-Bg86Demx.js +8 -0
- package/dist/ui/index.html +2 -2
- package/package.json +4 -6
- package/cli/index.js +0 -1330
- package/cli/scripts/install.js +0 -19
- package/cli/utils/apiKey.js +0 -77
- package/cli/utils/assets/trayIcon.ico +0 -0
- package/cli/utils/cloudflared.js +0 -493
- package/cli/utils/machineId.js +0 -22
- package/cli/utils/permissions.js +0 -45
- package/cli/utils/pids.js +0 -114
- package/cli/utils/state.js +0 -115
- package/cli/utils/token.js +0 -32
- package/cli/utils/tray.js +0 -251
- package/cli/utils/tui.js +0 -445
- package/cli/utils/updateChecker.js +0 -358
- package/dist/ui/assets/index-BWfJSBGG.js +0 -8
- package/index.js +0 -275
- package/lib/constants.js +0 -64
- package/lib/deviceApproval.js +0 -152
- package/lib/router.js +0 -134
- package/lib/socketio.js +0 -240
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { readFileSync, writeFileSync, existsSync, unlinkSync } from "fs";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { spawn, execSync } from "child_process";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import os from "os";
|
|
7
|
-
import { browserFetch } from "../../lib/constants.js";
|
|
8
|
-
import { killAll as killAllPids, getPidsDir } from "./pids.js";
|
|
9
|
-
|
|
10
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const PACKAGE_NAME = "9remote";
|
|
12
|
-
const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
13
|
-
const UPDATE_CHECK_TIMEOUT = 3000;
|
|
14
|
-
const SAFETY_TIMEOUT = 8000;
|
|
15
|
-
const SERVER_PORT = 2208;
|
|
16
|
-
// Legacy path from pre-pids.js installs — clean up once so old instances
|
|
17
|
-
// can still be killed during upgrade from older versions.
|
|
18
|
-
const LEGACY_CLOUDFLARED_PID_FILE = path.join(os.homedir(), ".9remote", "cloudflared.pid");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Kill all 9remote-related child processes to release file locks before npm install.
|
|
22
|
-
*
|
|
23
|
-
* Critical on Windows: node.exe / tray helper / cloudflared.exe lock files inside
|
|
24
|
-
* node_modules\9remote\dist, so `npm i -g` fails with EBUSY when trying to rename
|
|
25
|
-
* the old dist folder.
|
|
26
|
-
*
|
|
27
|
-
* We kill ONLY by PID (from ~/.9remote/pids/) — never by image name (taskkill /IM)
|
|
28
|
-
* or by commandline match, because those would also kill unrelated apps on the
|
|
29
|
-
* machine that happen to use cloudflared.exe, tray_windows_release.exe, or node.exe.
|
|
30
|
-
*/
|
|
31
|
-
function cleanupBeforeUpdate() {
|
|
32
|
-
// 1. Kill tracked processes (cloudflared + agent tree) via pids.js.
|
|
33
|
-
// Agent kill with taskkill /F /T sweeps its server child + tray helper.
|
|
34
|
-
try { killAllPids(); } catch {}
|
|
35
|
-
|
|
36
|
-
// 2. Legacy: older versions stored cloudflared PID at a different path.
|
|
37
|
-
try {
|
|
38
|
-
if (existsSync(LEGACY_CLOUDFLARED_PID_FILE)) {
|
|
39
|
-
const pid = parseInt(readFileSync(LEGACY_CLOUDFLARED_PID_FILE, "utf8"));
|
|
40
|
-
if (Number.isFinite(pid)) { try { process.kill(pid); } catch {} }
|
|
41
|
-
try { unlinkSync(LEGACY_CLOUDFLARED_PID_FILE); } catch {}
|
|
42
|
-
}
|
|
43
|
-
} catch {}
|
|
44
|
-
|
|
45
|
-
// 3. Safety net for stale server on SERVER_PORT (e.g. crashed without clearing PID).
|
|
46
|
-
// Scoped to one specific port, so we only touch 9remote's own server.
|
|
47
|
-
try {
|
|
48
|
-
if (process.platform === "win32") {
|
|
49
|
-
execSync(`for /f "tokens=5" %a in ('netstat -aon ^| findstr :${SERVER_PORT}') do taskkill /F /PID %a`, { stdio: "ignore", windowsHide: true });
|
|
50
|
-
} else {
|
|
51
|
-
execSync(`lsof -ti:${SERVER_PORT} | xargs kill -9 2>/dev/null || true`, { stdio: "ignore" });
|
|
52
|
-
}
|
|
53
|
-
} catch {}
|
|
54
|
-
|
|
55
|
-
// 4. Give Windows a moment to release file handles before npm tries to rename.
|
|
56
|
-
if (process.platform === "win32") {
|
|
57
|
-
const end = Date.now() + 1500;
|
|
58
|
-
while (Date.now() < end) { /* spin-wait; Atomics.wait not worth importing */ }
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get current version
|
|
64
|
-
*/
|
|
65
|
-
function getCurrentVersion() {
|
|
66
|
-
// When bundled, version is injected at build time
|
|
67
|
-
if (typeof __CLI_VERSION__ !== "undefined") {
|
|
68
|
-
return __CLI_VERSION__;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Dev mode: read from package.json
|
|
72
|
-
try {
|
|
73
|
-
const packagePath = path.resolve(__dirname, "../package.json");
|
|
74
|
-
const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
75
|
-
return packageJson.version;
|
|
76
|
-
} catch {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Compare semver versions
|
|
83
|
-
* Returns true if latest > current
|
|
84
|
-
*/
|
|
85
|
-
export function isNewerVersion(current, latest) {
|
|
86
|
-
const currentParts = current.split(".").map(Number);
|
|
87
|
-
const latestParts = latest.split(".").map(Number);
|
|
88
|
-
|
|
89
|
-
for (let i = 0; i < 3; i++) {
|
|
90
|
-
if (latestParts[i] > currentParts[i]) return true;
|
|
91
|
-
if (latestParts[i] < currentParts[i]) return false;
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Check if running in restricted environment (Codespaces, Docker)
|
|
98
|
-
*/
|
|
99
|
-
function isRestrictedEnvironment() {
|
|
100
|
-
if (process.env.CODESPACES === "true" || process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN) {
|
|
101
|
-
return "GitHub Codespaces";
|
|
102
|
-
}
|
|
103
|
-
if (existsSync("/.dockerenv")) {
|
|
104
|
-
return "Docker";
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Check for npm updates (non-blocking, notification only)
|
|
111
|
-
*/
|
|
112
|
-
/**
|
|
113
|
-
* Kill running 9remote processes so user can safely run `npm i -g 9remote@latest`.
|
|
114
|
-
* Called when user chooses manual update from startup menu.
|
|
115
|
-
*/
|
|
116
|
-
export function stopRunningInstances() {
|
|
117
|
-
cleanupBeforeUpdate();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export async function checkForUpdates() {
|
|
121
|
-
try {
|
|
122
|
-
const currentVersion = getCurrentVersion();
|
|
123
|
-
if (!currentVersion) return;
|
|
124
|
-
|
|
125
|
-
const response = await browserFetch(NPM_REGISTRY_URL, {
|
|
126
|
-
signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT)
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
if (!response.ok) return;
|
|
130
|
-
|
|
131
|
-
const data = await response.json();
|
|
132
|
-
const latestVersion = data.version;
|
|
133
|
-
|
|
134
|
-
if (latestVersion && isNewerVersion(currentVersion, latestVersion)) {
|
|
135
|
-
console.log(
|
|
136
|
-
chalk.yellow(`\n⬆️ New version ${chalk.green(latestVersion)} available (current: ${currentVersion})`)
|
|
137
|
-
);
|
|
138
|
-
console.log(chalk.gray(` Run: npm i -g ${PACKAGE_NAME}\n`));
|
|
139
|
-
}
|
|
140
|
-
} catch {
|
|
141
|
-
// Silent fail - don't block CLI
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Check if a newer version exists — returns { current, latest } or null.
|
|
147
|
-
* Silent fail, no auto-update, no spinner.
|
|
148
|
-
*/
|
|
149
|
-
export async function checkLatestVersion() {
|
|
150
|
-
try {
|
|
151
|
-
const currentVersion = getCurrentVersion();
|
|
152
|
-
if (!currentVersion) return null;
|
|
153
|
-
const response = await browserFetch(NPM_REGISTRY_URL, {
|
|
154
|
-
signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT)
|
|
155
|
-
});
|
|
156
|
-
if (!response.ok) return null;
|
|
157
|
-
const { version: latestVersion } = await response.json();
|
|
158
|
-
if (latestVersion && isNewerVersion(currentVersion, latestVersion)) {
|
|
159
|
-
return { current: currentVersion, latest: latestVersion };
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
} catch {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Check and auto-update if new version available
|
|
169
|
-
* Returns true if update started (process will exit), false otherwise
|
|
170
|
-
*/
|
|
171
|
-
export async function checkAndUpdate(skipUpdate = false) {
|
|
172
|
-
if (skipUpdate) return false;
|
|
173
|
-
|
|
174
|
-
const currentVersion = getCurrentVersion();
|
|
175
|
-
if (!currentVersion) return false;
|
|
176
|
-
|
|
177
|
-
// Spinner frames
|
|
178
|
-
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
179
|
-
let frameIndex = 0;
|
|
180
|
-
let spinnerInterval = null;
|
|
181
|
-
|
|
182
|
-
const startSpinner = (text) => {
|
|
183
|
-
if (process.stdout.isTTY) {
|
|
184
|
-
process.stdout.write(`\r${frames[0]} ${text}`);
|
|
185
|
-
spinnerInterval = setInterval(() => {
|
|
186
|
-
process.stdout.write(`\r${frames[frameIndex++ % frames.length]} ${text}`);
|
|
187
|
-
}, 80);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const stopSpinner = () => {
|
|
192
|
-
if (spinnerInterval) {
|
|
193
|
-
clearInterval(spinnerInterval);
|
|
194
|
-
spinnerInterval = null;
|
|
195
|
-
}
|
|
196
|
-
if (process.stdout.isTTY) {
|
|
197
|
-
process.stdout.write("\r\x1b[K");
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
return new Promise((resolve) => {
|
|
202
|
-
let resolved = false;
|
|
203
|
-
|
|
204
|
-
const safeResolve = (value) => {
|
|
205
|
-
if (!resolved) {
|
|
206
|
-
resolved = true;
|
|
207
|
-
stopSpinner();
|
|
208
|
-
resolve(value);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// Safety timeout to prevent hanging
|
|
213
|
-
const safetyTimer = setTimeout(() => safeResolve(false), SAFETY_TIMEOUT);
|
|
214
|
-
|
|
215
|
-
startSpinner("Checking for updates...");
|
|
216
|
-
|
|
217
|
-
browserFetch(NPM_REGISTRY_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT) })
|
|
218
|
-
.then((res) => res.json())
|
|
219
|
-
.then((data) => {
|
|
220
|
-
if (resolved) return;
|
|
221
|
-
clearTimeout(safetyTimer);
|
|
222
|
-
|
|
223
|
-
const latestVersion = data.version;
|
|
224
|
-
if (!latestVersion || !isNewerVersion(currentVersion, latestVersion)) {
|
|
225
|
-
safeResolve(false);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
stopSpinner();
|
|
230
|
-
console.log(chalk.green(`✅ New version available: ${currentVersion} → ${latestVersion}`));
|
|
231
|
-
|
|
232
|
-
// Check restricted environment
|
|
233
|
-
const restrictedEnv = isRestrictedEnvironment();
|
|
234
|
-
if (restrictedEnv) {
|
|
235
|
-
console.log(chalk.yellow(` ⚠️ ${restrictedEnv} detected - manual update required`));
|
|
236
|
-
console.log(chalk.gray(` Run: npm install -g ${PACKAGE_NAME}@latest\n`));
|
|
237
|
-
safeResolve(false);
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
console.log(chalk.yellow("🔄 Auto-updating...\n"));
|
|
242
|
-
|
|
243
|
-
// Build update script
|
|
244
|
-
const args = process.argv.slice(2).filter((a) => a !== "--skip-update");
|
|
245
|
-
const argsStr = args.join(" ");
|
|
246
|
-
const platform = process.platform;
|
|
247
|
-
|
|
248
|
-
let scriptPath, shellCmd;
|
|
249
|
-
|
|
250
|
-
// The update script must kill our tracked processes by PID ONLY.
|
|
251
|
-
// Never use `taskkill /IM <image>` or `pkill -f <name>` — those match
|
|
252
|
-
// by binary name / commandline and would nuke unrelated apps on the
|
|
253
|
-
// machine (other cloudflared tunnels, other tray apps, any node.exe).
|
|
254
|
-
const pidsDir = getPidsDir();
|
|
255
|
-
|
|
256
|
-
if (platform === "win32") {
|
|
257
|
-
const script = `@echo off
|
|
258
|
-
echo 📥 Downloading update...
|
|
259
|
-
echo ⏳ Stopping 9remote processes...
|
|
260
|
-
|
|
261
|
-
REM Kill cloudflared first so it stops reconnecting, then kill the agent
|
|
262
|
-
REM tree (/T also terminates its server child + tray helper). PID-based so
|
|
263
|
-
REM we never touch unrelated node.exe / cloudflared.exe on this machine.
|
|
264
|
-
REM ptyDaemon is intentionally NOT killed — keep terminal sessions alive.
|
|
265
|
-
for %%N in (cloudflared agent) do (
|
|
266
|
-
if exist "${pidsDir}\\%%N.pid" (
|
|
267
|
-
for /f %%P in ('type "${pidsDir}\\%%N.pid"') do taskkill /F /T /PID %%P >nul 2>&1
|
|
268
|
-
del /f /q "${pidsDir}\\%%N.pid" >nul 2>&1
|
|
269
|
-
)
|
|
270
|
-
)
|
|
271
|
-
|
|
272
|
-
REM Safety net: kill anything still bound to our server port.
|
|
273
|
-
for /f "tokens=5" %%a in ('netstat -aon ^| findstr :${SERVER_PORT}') do taskkill /F /PID %%a >nul 2>&1
|
|
274
|
-
|
|
275
|
-
REM Let Windows flush file handles before npm renames node_modules\\9remote.
|
|
276
|
-
timeout /t 3 /nobreak >nul
|
|
277
|
-
|
|
278
|
-
echo 🔄 Installing new version...
|
|
279
|
-
call npm cache clean --force >nul 2>&1
|
|
280
|
-
call npm install -g ${PACKAGE_NAME}@latest --prefer-online
|
|
281
|
-
|
|
282
|
-
if %ERRORLEVEL% EQU 0 (
|
|
283
|
-
echo ✅ Update completed successfully
|
|
284
|
-
echo 🚀 Restarting with new version...
|
|
285
|
-
${PACKAGE_NAME} ${argsStr} --skip-update
|
|
286
|
-
) else (
|
|
287
|
-
echo ❌ Update failed
|
|
288
|
-
echo 💡 Try manually: npm install -g ${PACKAGE_NAME}
|
|
289
|
-
echo 🔄 Starting with current version...
|
|
290
|
-
${PACKAGE_NAME} ${argsStr} --skip-update
|
|
291
|
-
)
|
|
292
|
-
`;
|
|
293
|
-
scriptPath = path.join(os.tmpdir(), `${PACKAGE_NAME}-update.bat`);
|
|
294
|
-
writeFileSync(scriptPath, script);
|
|
295
|
-
shellCmd = ["cmd.exe", ["/c", scriptPath]];
|
|
296
|
-
} else {
|
|
297
|
-
const script = `#!/bin/bash
|
|
298
|
-
echo "📥 Downloading update..."
|
|
299
|
-
echo "⏳ Stopping 9remote processes..."
|
|
300
|
-
|
|
301
|
-
# Kill cloudflared first, then the agent (children die with the agent on
|
|
302
|
-
# POSIX once the parent process exits and systemd/init reaps them, or here
|
|
303
|
-
# because we SIGKILL them via kill -9). PID-based so unrelated apps are safe.
|
|
304
|
-
# ptyDaemon is intentionally NOT killed — keep terminal sessions alive.
|
|
305
|
-
for name in cloudflared agent; do
|
|
306
|
-
f="${pidsDir}/\${name}.pid"
|
|
307
|
-
if [ -f "$f" ]; then
|
|
308
|
-
pid=$(cat "$f" 2>/dev/null)
|
|
309
|
-
[ -n "$pid" ] && kill -9 "$pid" 2>/dev/null || true
|
|
310
|
-
rm -f "$f"
|
|
311
|
-
fi
|
|
312
|
-
done
|
|
313
|
-
|
|
314
|
-
# Safety net: kill anything still bound to our server port.
|
|
315
|
-
lsof -ti:${SERVER_PORT} | xargs kill -9 2>/dev/null || true
|
|
316
|
-
sleep 2
|
|
317
|
-
|
|
318
|
-
echo "🔄 Installing new version..."
|
|
319
|
-
npm cache clean --force 2>/dev/null
|
|
320
|
-
|
|
321
|
-
# Try to install with full output for debugging
|
|
322
|
-
npm install -g ${PACKAGE_NAME}@latest --prefer-online 2>&1
|
|
323
|
-
EXIT_CODE=$?
|
|
324
|
-
|
|
325
|
-
if [ $EXIT_CODE -eq 0 ]; then
|
|
326
|
-
echo "✅ Update completed successfully"
|
|
327
|
-
echo "🚀 Restarting with new version..."
|
|
328
|
-
${PACKAGE_NAME} ${argsStr} --skip-update
|
|
329
|
-
else
|
|
330
|
-
echo "❌ Update failed (exit code: $EXIT_CODE)"
|
|
331
|
-
echo "💡 Update manually: npm install -g ${PACKAGE_NAME}@latest"
|
|
332
|
-
echo "🔄 Starting with current version..."
|
|
333
|
-
${PACKAGE_NAME} ${argsStr} --skip-update
|
|
334
|
-
fi
|
|
335
|
-
`;
|
|
336
|
-
scriptPath = path.join(os.tmpdir(), `${PACKAGE_NAME}-update.sh`);
|
|
337
|
-
writeFileSync(scriptPath, script, { mode: 0o755 });
|
|
338
|
-
shellCmd = ["sh", [scriptPath]];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Cleanup child processes to release file locks before npm install
|
|
342
|
-
cleanupBeforeUpdate();
|
|
343
|
-
|
|
344
|
-
// Execute update script in background
|
|
345
|
-
const child = spawn(shellCmd[0], shellCmd[1], {
|
|
346
|
-
detached: true,
|
|
347
|
-
stdio: "inherit"
|
|
348
|
-
});
|
|
349
|
-
child.unref();
|
|
350
|
-
|
|
351
|
-
process.exit(0);
|
|
352
|
-
})
|
|
353
|
-
.catch(() => {
|
|
354
|
-
clearTimeout(safetyTimer);
|
|
355
|
-
safeResolve(false);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function o(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=o(n);fetch(n.href,r)}})();var Ce,D,tn,$,dt,nn,rn,Ee,_e,ue,on,ot,$e,et,be={},xe=[],bn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ke=Array.isArray;function G(e,t){for(var o in t)e[o]=t[o];return e}function it(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function xn(e,t,o){var i,n,r,s={};for(r in t)r=="key"?i=t[r]:r=="ref"?n=t[r]:s[r]=t[r];if(arguments.length>2&&(s.children=arguments.length>3?Ce.call(arguments,2):o),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)s[r]===void 0&&(s[r]=e.defaultProps[r]);return ge(e,s,i,n,null)}function ge(e,t,o,i,n){var r={type:e,props:t,key:o,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:n??++tn,__i:-1,__u:0};return n==null&&D.vnode!=null&&D.vnode(r),r}function ee(e){return e.children}function ye(e,t){this.props=e,this.context=t}function le(e,t){if(t==null)return e.__?le(e.__,e.__i+1):null;for(var o;t<e.__k.length;t++)if((o=e.__k[t])!=null&&o.__e!=null)return o.__e;return typeof e.type=="function"?le(e):null}function wn(e){if(e.__P&&e.__d){var t=e.__v,o=t.__e,i=[],n=[],r=G({},t);r.__v=t.__v+1,D.vnode&&D.vnode(r),st(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[o]:null,i,o??le(t),!!(32&t.__u),n),r.__v=t.__v,r.__.__k[r.__i]=r,cn(i,r,n),t.__e=t.__=null,r.__e!=o&&sn(r)}}function sn(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),sn(e)}function ft(e){(!e.__d&&(e.__d=!0)&&$.push(e)&&!we.__r++||dt!=D.debounceRendering)&&((dt=D.debounceRendering)||nn)(we)}function we(){try{for(var e,t=1;$.length;)$.length>t&&$.sort(rn),e=$.shift(),t=$.length,wn(e)}finally{$.length=we.__r=0}}function ln(e,t,o,i,n,r,s,l,a,d,m){var u,h,f,y,b,P,p,g=i&&i.__k||xe,x=t.length;for(a=Nn(o,t,g,a,x),u=0;u<x;u++)(f=o.__k[u])!=null&&(h=f.__i!=-1&&g[f.__i]||be,f.__i=u,P=st(e,f,h,n,r,s,l,a,d,m),y=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&<(h.ref,null,f),m.push(f.ref,f.__c||y,f)),b==null&&y!=null&&(b=y),(p=!!(4&f.__u))||h.__k===f.__k?(a=an(f,a,e,p),p&&h.__e&&(h.__e=null)):typeof f.type=="function"&&P!==void 0?a=P:y&&(a=y.nextSibling),f.__u&=-7);return o.__e=b,a}function Nn(e,t,o,i,n){var r,s,l,a,d,m=o.length,u=m,h=0;for(e.__k=new Array(n),r=0;r<n;r++)(s=t[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=e.__k[r]=ge(null,s,null,null,null):ke(s)?s=e.__k[r]=ge(ee,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[r]=ge(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[r]=s,a=r+h,s.__=e,s.__b=e.__b+1,l=null,(d=s.__i=Cn(s,o,a,u))!=-1&&(u--,(l=o[d])&&(l.__u|=2)),l==null||l.__v==null?(d==-1&&(n>m?h--:n<m&&h++),typeof s.type!="function"&&(s.__u|=4)):d!=a&&(d==a-1?h--:d==a+1?h++:(d>a?h--:h++,s.__u|=4))):e.__k[r]=null;if(u)for(r=0;r<m;r++)(l=o[r])!=null&&(2&l.__u)==0&&(l.__e==i&&(i=le(l)),dn(l,l));return i}function an(e,t,o,i){var n,r;if(typeof e.type=="function"){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=an(n[r],t,o,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=le(e)),o.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Cn(e,t,o,i){var n,r,s,l=e.key,a=e.type,d=t[o],m=d!=null&&(2&d.__u)==0;if(d===null&&l==null||m&&l==d.key&&a==d.type)return o;if(i>(m?1:0)){for(n=o-1,r=o+1;n>=0||r<t.length;)if((d=t[s=n>=0?n--:r++])!=null&&(2&d.__u)==0&&l==d.key&&a==d.type)return s}return-1}function ht(e,t,o){t[0]=="-"?e.setProperty(t,o??""):e[t]=o==null?"":typeof o!="number"||bn.test(t)?o:o+"px"}function he(e,t,o,i,n){var r,s;e:if(t=="style")if(typeof o=="string")e.style.cssText=o;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)o&&t in o||ht(e.style,t,"");if(o)for(t in o)i&&o[t]==i[t]||ht(e.style,t,o[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(on,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=o,o?i?o[ue]=i[ue]:(o[ue]=ot,e.addEventListener(t,r?et:$e,r)):e.removeEventListener(t,r?et:$e,r);else{if(n=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&o==1?"":o))}}function mt(e){return function(t){if(this.l){var o=this.l[t.type+e];if(t[_e]==null)t[_e]=ot++;else if(t[_e]<o[ue])return;return o(D.event?D.event(t):t)}}}function st(e,t,o,i,n,r,s,l,a,d){var m,u,h,f,y,b,P,p,g,x,N,M,v,w,C,_=t.type;if(t.constructor!==void 0)return null;128&o.__u&&(a=!!(32&o.__u),r=[l=t.__e=o.__e]),(m=D.__b)&&m(t);e:if(typeof _=="function")try{if(p=t.props,g=_.prototype&&_.prototype.render,x=(m=_.contextType)&&i[m.__c],N=m?x?x.props.value:m.__:i,o.__c?P=(u=t.__c=o.__c).__=u.__E:(g?t.__c=u=new _(p,N):(t.__c=u=new ye(p,N),u.constructor=_,u.render=Sn),x&&x.sub(u),u.state||(u.state={}),u.__n=i,h=u.__d=!0,u.__h=[],u._sb=[]),g&&u.__s==null&&(u.__s=u.state),g&&_.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=G({},u.__s)),G(u.__s,_.getDerivedStateFromProps(p,u.__s))),f=u.props,y=u.state,u.__v=t,h)g&&_.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),g&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(g&&_.getDerivedStateFromProps==null&&p!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(p,N),t.__v==o.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(p,u.__s,N)===!1){t.__v!=o.__v&&(u.props=p,u.state=u.__s,u.__d=!1),t.__e=o.__e,t.__k=o.__k,t.__k.some(function(k){k&&(k.__=t)}),xe.push.apply(u.__h,u._sb),u._sb=[],u.__h.length&&s.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(p,u.__s,N),g&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,y,b)})}if(u.context=N,u.props=p,u.__P=e,u.__e=!1,M=D.__r,v=0,g)u.state=u.__s,u.__d=!1,M&&M(t),m=u.render(u.props,u.state,u.context),xe.push.apply(u.__h,u._sb),u._sb=[];else do u.__d=!1,M&&M(t),m=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++v<25);u.state=u.__s,u.getChildContext!=null&&(i=G(G({},i),u.getChildContext())),g&&!h&&u.getSnapshotBeforeUpdate!=null&&(b=u.getSnapshotBeforeUpdate(f,y)),w=m!=null&&m.type===ee&&m.key==null?un(m.props.children):m,l=ln(e,ke(w)?w:[w],t,o,i,n,r,s,l,a,d),u.base=t.__e,t.__u&=-161,u.__h.length&&s.push(u),P&&(u.__E=u.__=null)}catch(k){if(t.__v=null,a||r!=null)if(k.then){for(t.__u|=a?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r[r.indexOf(l)]=null,t.__e=l}else{for(C=r.length;C--;)it(r[C]);tt(t)}else t.__e=o.__e,t.__k=o.__k,k.then||tt(t);D.__e(k,t,o)}else r==null&&t.__v==o.__v?(t.__k=o.__k,t.__e=o.__e):l=t.__e=kn(o.__e,t,o,i,n,r,s,a,d);return(m=D.diffed)&&m(t),128&t.__u?void 0:l}function tt(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(tt))}function cn(e,t,o){for(var i=0;i<o.length;i++)lt(o[i],o[++i],o[++i]);D.__c&&D.__c(t,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(r){r.call(n)})}catch(r){D.__e(r,n.__v)}})}function un(e){return typeof e!="object"||e==null||e.__b>0?e:ke(e)?e.map(un):G({},e)}function kn(e,t,o,i,n,r,s,l,a){var d,m,u,h,f,y,b,P=o.props||be,p=t.props,g=t.type;if(g=="svg"?n="http://www.w3.org/2000/svg":g=="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),r!=null){for(d=0;d<r.length;d++)if((f=r[d])&&"setAttribute"in f==!!g&&(g?f.localName==g:f.nodeType==3)){e=f,r[d]=null;break}}if(e==null){if(g==null)return document.createTextNode(p);e=document.createElementNS(n,g,p.is&&p),l&&(D.__m&&D.__m(t,r),l=!1),r=null}if(g==null)P===p||l&&e.data==p||(e.data=p);else{if(r=r&&Ce.call(e.childNodes),!l&&r!=null)for(P={},d=0;d<e.attributes.length;d++)P[(f=e.attributes[d]).name]=f.value;for(d in P)f=P[d],d=="dangerouslySetInnerHTML"?u=f:d=="children"||d in p||d=="value"&&"defaultValue"in p||d=="checked"&&"defaultChecked"in p||he(e,d,null,f,n);for(d in p)f=p[d],d=="children"?h=f:d=="dangerouslySetInnerHTML"?m=f:d=="value"?y=f:d=="checked"?b=f:l&&typeof f!="function"||P[d]===f||he(e,d,f,P[d],n);if(m)l||u&&(m.__html==u.__html||m.__html==e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(u&&(e.innerHTML=""),ln(t.type=="template"?e.content:e,ke(h)?h:[h],t,o,i,g=="foreignObject"?"http://www.w3.org/1999/xhtml":n,r,s,r?r[0]:o.__k&&le(o,0),l,a),r!=null)for(d=r.length;d--;)it(r[d]);l||(d="value",g=="progress"&&y==null?e.removeAttribute("value"):y!=null&&(y!==e[d]||g=="progress"&&!y||g=="option"&&y!=P[d])&&he(e,d,y,P[d],n),d="checked",b!=null&&b!=e[d]&&he(e,d,b,P[d],n))}return e}function lt(e,t,o){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(n){D.__e(n,o)}}function dn(e,t,o){var i,n;if(D.unmount&&D.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||lt(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(r){D.__e(r,t)}i.base=i.__P=null}if(i=e.__k)for(n=0;n<i.length;n++)i[n]&&dn(i[n],t,o||typeof e.type!="function");o||it(e.__e),e.__c=e.__=e.__e=void 0}function Sn(e,t,o){return this.constructor(e,o)}function En(e,t,o){var i,n,r,s;t==document&&(t=document.documentElement),D.__&&D.__(e,t),n=(i=!1)?null:t.__k,r=[],s=[],st(t,e=t.__k=xn(ee,null,[e]),n||be,be,t.namespaceURI,n?null:t.firstChild?Ce.call(t.childNodes):null,r,n?n.__e:t.firstChild,i,s),cn(r,e,s)}Ce=xe.slice,D={__e:function(e,t,o,i){for(var n,r,s;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&r.getDerivedStateFromError!=null&&(n.setState(r.getDerivedStateFromError(e)),s=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,i||{}),s=n.__d),s)return n.__E=n}catch(l){e=l}throw e}},tn=0,ye.prototype.setState=function(e,t){var o;o=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=G({},this.state),typeof e=="function"&&(e=e(G({},o),this.props)),e&&G(o,e),e!=null&&this.__v&&(t&&this._sb.push(t),ft(this))},ye.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ft(this))},ye.prototype.render=ee,$=[],nn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,rn=function(e,t){return e.__v.__b-t.__v.__b},we.__r=0,Ee=Math.random().toString(8),_e="__d"+Ee,ue="__a"+Ee,on=/(PointerCapture)$|Capture$/i,ot=0,$e=mt(!1),et=mt(!0);var Tn=0;function c(e,t,o,i,n,r){t||(t={});var s,l,a=t;if("ref"in a)for(l in a={},t)l=="ref"?s=t[l]:a[l]=t[l];var d={type:e,props:a,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Tn,__i:-1,__u:0,__source:n,__self:r};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)a[l]===void 0&&(a[l]=s[l]);return D.vnode&&D.vnode(d),d}var fe,q,Te,pt,Ne=0,fn=[],j=D,_t=j.__b,gt=j.__r,yt=j.diffed,vt=j.__c,bt=j.unmount,xt=j.__;function at(e,t){j.__h&&j.__h(q,e,Ne||t),Ne=0;var o=q.__H||(q.__H={__:[],__h:[]});return e>=o.__.length&&o.__.push({}),o.__[e]}function F(e){return Ne=1,An(mn,e)}function An(e,t,o){var i=at(fe++,2);if(i.t=e,!i.__c&&(i.__=[mn(void 0,t),function(l){var a=i.__N?i.__N[0]:i.__[0],d=i.t(a,l);a!==d&&(i.__N=[d,i.__[1]],i.__c.setState({}))}],i.__c=q,!q.__f)){var n=function(l,a,d){if(!i.__c.__H)return!0;var m=i.__c.__H.__.filter(function(h){return h.__c});if(m.every(function(h){return!h.__N}))return!r||r.call(this,l,a,d);var u=i.__c.props!==l;return m.some(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),r&&r.call(this,l,a,d)||u};q.__f=!0;var r=q.shouldComponentUpdate,s=q.componentWillUpdate;q.componentWillUpdate=function(l,a,d){if(this.__e){var m=r;r=void 0,n(l,a,d),r=m}s&&s.call(this,l,a,d)},q.shouldComponentUpdate=n}return i.__N||i.__}function se(e,t){var o=at(fe++,3);!j.__s&&hn(o.__H,t)&&(o.__=e,o.u=t,q.__H.__h.push(o))}function ct(e){return Ne=5,Rn(function(){return{current:e}},[])}function Rn(e,t){var o=at(fe++,7);return hn(o.__H,t)&&(o.__=e(),o.__H=t,o.__h=e),o.__}function In(){for(var e;e=fn.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ve),t.__h.some(nt),t.__h=[]}catch(o){t.__h=[],j.__e(o,e.__v)}}}j.__b=function(e){q=null,_t&&_t(e)},j.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),xt&&xt(e,t)},j.__r=function(e){gt&>(e),fe=0;var t=(q=e.__c).__H;t&&(Te===q?(t.__h=[],q.__h=[],t.__.some(function(o){o.__N&&(o.__=o.__N),o.u=o.__N=void 0})):(t.__h.some(ve),t.__h.some(nt),t.__h=[],fe=0)),Te=q},j.diffed=function(e){yt&&yt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fn.push(t)!==1&&pt===j.requestAnimationFrame||((pt=j.requestAnimationFrame)||Pn)(In)),t.__H.__.some(function(o){o.u&&(o.__H=o.u),o.u=void 0})),Te=q=null},j.__c=function(e,t){t.some(function(o){try{o.__h.some(ve),o.__h=o.__h.filter(function(i){return!i.__||nt(i)})}catch(i){t.some(function(n){n.__h&&(n.__h=[])}),t=[],j.__e(i,o.__v)}}),vt&&vt(e,t)},j.unmount=function(e){bt&&bt(e);var t,o=e.__c;o&&o.__H&&(o.__H.__.some(function(i){try{ve(i)}catch(n){t=n}}),o.__H=void 0,t&&j.__e(t,o.__v))};var wt=typeof requestAnimationFrame=="function";function Pn(e){var t,o=function(){clearTimeout(i),wt&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(o,35);wt&&(t=requestAnimationFrame(o))}function ve(e){var t=q,o=e.__c;typeof o=="function"&&(e.__c=void 0,o()),q=t}function nt(e){var t=q;e.__c=e.__(),q=t}function hn(e,t){return!e||e.length!==t.length||t.some(function(o,i){return o!==e[i]})}function mn(e,t){return typeof t=="function"?t(e):t}const Bn=[{icon:"download",label:"Preparing",desc:"Checking tunnel binary"},{icon:"cloud_sync",label:"Connecting",desc:"Creating session"},{icon:"lan",label:"Tunneling",desc:"Starting secure tunnel"},{icon:"verified",label:"Verifying",desc:"Health check"},{icon:"check_circle",label:"Ready",desc:"Connected"}],Mn=3;function Dn({currentStep:e,activeDesc:t="",healthCheck:o}){var r;const i=e-1,n=(r=o==null?void 0:o.logs)!=null&&r.length?o.logs[o.logs.length-1]:null;return c("div",{className:"glass-card p-5 flex flex-col gap-4",children:[c("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Setting up connection"}),c("div",{className:"flex flex-col gap-3",children:Bn.map((s,l)=>{const a=l<i,d=l===i,m=d&&l===Mn;let u=d&&t?t:s.desc,h="var(--text-muted)";if(m&&n){const f=/^\d{3}$/.test(String(n.status));u=`#${n.attempt} → ${n.status}`,h=n.ok||n.waiting?"#22c55e":f?"#eab308":"#ef4444"}return c("div",{className:"flex items-center gap-3",children:[c("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{background:a?"var(--brand-500)":d?"rgba(255,87,10,0.15)":"var(--glass-bg)",border:d?"1.5px solid var(--brand-500)":"1.5px solid transparent"},children:a?c("span",{className:"material-symbols-outlined text-white",style:{fontSize:16},children:"check"}):d?c("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(f=>c("span",{className:"w-1 h-1 rounded-full bg-orange-400 dot-bounce",style:{animationDelay:`${f*.18}s`}},f))}):c("span",{className:"material-symbols-outlined",style:{fontSize:16,color:"var(--text-muted)",opacity:.3},children:s.icon})}),c("div",{className:"flex-1 min-w-0",children:[c("p",{className:"text-sm font-medium",style:{color:a?"var(--text-muted)":d?"var(--text-main)":"var(--text-muted)",opacity:a||d?1:.4},children:s.label}),c("p",{className:"text-xs mt-0.5 truncate",style:{color:h,opacity:d?m&&n?.95:.7:.4,fontFamily:m&&n?"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace":void 0},children:u})]}),a&&c("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:"Done"}),d&&c("span",{className:"text-xs flex-shrink-0 px-2 py-0.5 rounded-full",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Running"})]},l)})})]})}function Ln(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ie={},Ae,Nt;function Un(){return Nt||(Nt=1,Ae=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Ae}var Re={},Z={},Ct;function te(){if(Ct)return Z;Ct=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Z.getSymbolSize=function(i){if(!i)throw new Error('"version" cannot be null or undefined');if(i<1||i>40)throw new Error('"version" should be in range from 1 to 40');return i*4+17},Z.getSymbolTotalCodewords=function(i){return t[i]},Z.getBCHDigit=function(o){let i=0;for(;o!==0;)i++,o>>>=1;return i},Z.setToSJISFunction=function(i){if(typeof i!="function")throw new Error('"toSJISFunc" is not a valid function.');e=i},Z.isKanjiModeEnabled=function(){return typeof e<"u"},Z.toSJIS=function(i){return e(i)},Z}var Ie={},kt;function ut(){return kt||(kt=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+o)}}e.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},e.from=function(i,n){if(e.isValid(i))return i;try{return t(i)}catch{return n}}})(Ie)),Ie}var Pe,St;function qn(){if(St)return Pe;St=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const o=Math.floor(t/8);return(this.buffer[o]>>>7-t%8&1)===1},put:function(t,o){for(let i=0;i<o;i++)this.putBit((t>>>o-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),t&&(this.buffer[o]|=128>>>this.length%8),this.length++}},Pe=e,Pe}var Be,Et;function Fn(){if(Et)return Be;Et=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,o,i,n){const r=t*this.size+o;this.data[r]=i,n&&(this.reservedBit[r]=!0)},e.prototype.get=function(t,o){return this.data[t*this.size+o]},e.prototype.xor=function(t,o,i){this.data[t*this.size+o]^=i},e.prototype.isReserved=function(t,o){return this.reservedBit[t*this.size+o]},Be=e,Be}var Me={},Tt;function jn(){return Tt||(Tt=1,(function(e){const t=te().getSymbolSize;e.getRowColCoords=function(i){if(i===1)return[];const n=Math.floor(i/7)+2,r=t(i),s=r===145?26:Math.ceil((r-13)/(2*n-2))*2,l=[r-7];for(let a=1;a<n-1;a++)l[a]=l[a-1]-s;return l.push(6),l.reverse()},e.getPositions=function(i){const n=[],r=e.getRowColCoords(i),s=r.length;for(let l=0;l<s;l++)for(let a=0;a<s;a++)l===0&&a===0||l===0&&a===s-1||l===s-1&&a===0||n.push([r[l],r[a]]);return n}})(Me)),Me}var De={},At;function On(){if(At)return De;At=1;const e=te().getSymbolSize,t=7;return De.getPositions=function(i){const n=e(i);return[[0,0],[n-t,0],[0,n-t]]},De}var Le={},Rt;function Hn(){return Rt||(Rt=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},e.from=function(n){return e.isValid(n)?parseInt(n,10):void 0},e.getPenaltyN1=function(n){const r=n.size;let s=0,l=0,a=0,d=null,m=null;for(let u=0;u<r;u++){l=a=0,d=m=null;for(let h=0;h<r;h++){let f=n.get(u,h);f===d?l++:(l>=5&&(s+=t.N1+(l-5)),d=f,l=1),f=n.get(h,u),f===m?a++:(a>=5&&(s+=t.N1+(a-5)),m=f,a=1)}l>=5&&(s+=t.N1+(l-5)),a>=5&&(s+=t.N1+(a-5))}return s},e.getPenaltyN2=function(n){const r=n.size;let s=0;for(let l=0;l<r-1;l++)for(let a=0;a<r-1;a++){const d=n.get(l,a)+n.get(l,a+1)+n.get(l+1,a)+n.get(l+1,a+1);(d===4||d===0)&&s++}return s*t.N2},e.getPenaltyN3=function(n){const r=n.size;let s=0,l=0,a=0;for(let d=0;d<r;d++){l=a=0;for(let m=0;m<r;m++)l=l<<1&2047|n.get(d,m),m>=10&&(l===1488||l===93)&&s++,a=a<<1&2047|n.get(m,d),m>=10&&(a===1488||a===93)&&s++}return s*t.N3},e.getPenaltyN4=function(n){let r=0;const s=n.data.length;for(let a=0;a<s;a++)r+=n.data[a];return Math.abs(Math.ceil(r*100/s/5)-10)*t.N4};function o(i,n,r){switch(i){case e.Patterns.PATTERN000:return(n+r)%2===0;case e.Patterns.PATTERN001:return n%2===0;case e.Patterns.PATTERN010:return r%3===0;case e.Patterns.PATTERN011:return(n+r)%3===0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2===0;case e.Patterns.PATTERN101:return n*r%2+n*r%3===0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2===0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}e.applyMask=function(n,r){const s=r.size;for(let l=0;l<s;l++)for(let a=0;a<s;a++)r.isReserved(a,l)||r.xor(a,l,o(n,a,l))},e.getBestMask=function(n,r){const s=Object.keys(e.Patterns).length;let l=0,a=1/0;for(let d=0;d<s;d++){r(d),e.applyMask(d,n);const m=e.getPenaltyN1(n)+e.getPenaltyN2(n)+e.getPenaltyN3(n)+e.getPenaltyN4(n);e.applyMask(d,n),m<a&&(a=m,l=d)}return l}})(Le)),Le}var me={},It;function pn(){if(It)return me;It=1;const e=ut(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return me.getBlocksCount=function(n,r){switch(r){case e.L:return t[(n-1)*4+0];case e.M:return t[(n-1)*4+1];case e.Q:return t[(n-1)*4+2];case e.H:return t[(n-1)*4+3];default:return}},me.getTotalCodewordsCount=function(n,r){switch(r){case e.L:return o[(n-1)*4+0];case e.M:return o[(n-1)*4+1];case e.Q:return o[(n-1)*4+2];case e.H:return o[(n-1)*4+3];default:return}},me}var Ue={},ce={},Pt;function zn(){if(Pt)return ce;Pt=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let i=1;for(let n=0;n<255;n++)e[n]=i,t[i]=n,i<<=1,i&256&&(i^=285);for(let n=255;n<512;n++)e[n]=e[n-255]})(),ce.log=function(i){if(i<1)throw new Error("log("+i+")");return t[i]},ce.exp=function(i){return e[i]},ce.mul=function(i,n){return i===0||n===0?0:e[t[i]+t[n]]},ce}var Bt;function Kn(){return Bt||(Bt=1,(function(e){const t=zn();e.mul=function(i,n){const r=new Uint8Array(i.length+n.length-1);for(let s=0;s<i.length;s++)for(let l=0;l<n.length;l++)r[s+l]^=t.mul(i[s],n[l]);return r},e.mod=function(i,n){let r=new Uint8Array(i);for(;r.length-n.length>=0;){const s=r[0];for(let a=0;a<n.length;a++)r[a]^=t.mul(n[a],s);let l=0;for(;l<r.length&&r[l]===0;)l++;r=r.slice(l)}return r},e.generateECPolynomial=function(i){let n=new Uint8Array([1]);for(let r=0;r<i;r++)n=e.mul(n,new Uint8Array([1,t.exp(r)]));return n}})(Ue)),Ue}var qe,Mt;function Vn(){if(Mt)return qe;Mt=1;const e=Kn();function t(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(i){this.degree=i,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(i){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(i.length+this.degree);n.set(i);const r=e.mod(n,this.genPoly),s=this.degree-r.length;if(s>0){const l=new Uint8Array(this.degree);return l.set(r,s),l}return r},qe=t,qe}var Fe={},je={},Oe={},Dt;function _n(){return Dt||(Dt=1,Oe.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Oe}var J={},Lt;function gn(){if(Lt)return J;Lt=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const i="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
|
|
2
|
-
]))+`;J.KANJI=new RegExp(o,"g"),J.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),J.BYTE=new RegExp(i,"g"),J.NUMERIC=new RegExp(e,"g"),J.ALPHANUMERIC=new RegExp(t,"g");const n=new RegExp("^"+o+"$"),r=new RegExp("^"+e+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return J.testKanji=function(a){return n.test(a)},J.testNumeric=function(a){return r.test(a)},J.testAlphanumeric=function(a){return s.test(a)},J}var Ut;function ne(){return Ut||(Ut=1,(function(e){const t=_n(),o=gn();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(r,s){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!t.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?r.ccBits[0]:s<27?r.ccBits[1]:r.ccBits[2]},e.getBestModeForData=function(r){return o.testNumeric(r)?e.NUMERIC:o.testAlphanumeric(r)?e.ALPHANUMERIC:o.testKanji(r)?e.KANJI:e.BYTE},e.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},e.isValid=function(r){return r&&r.bit&&r.ccBits};function i(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+n)}}e.from=function(r,s){if(e.isValid(r))return r;try{return i(r)}catch{return s}}})(je)),je}var qt;function Jn(){return qt||(qt=1,(function(e){const t=te(),o=pn(),i=ut(),n=ne(),r=_n(),s=7973,l=t.getBCHDigit(s);function a(h,f,y){for(let b=1;b<=40;b++)if(f<=e.getCapacity(b,y,h))return b}function d(h,f){return n.getCharCountIndicator(h,f)+4}function m(h,f){let y=0;return h.forEach(function(b){const P=d(b.mode,f);y+=P+b.getBitsLength()}),y}function u(h,f){for(let y=1;y<=40;y++)if(m(h,y)<=e.getCapacity(y,f,n.MIXED))return y}e.from=function(f,y){return r.isValid(f)?parseInt(f,10):y},e.getCapacity=function(f,y,b){if(!r.isValid(f))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=n.BYTE);const P=t.getSymbolTotalCodewords(f),p=o.getTotalCodewordsCount(f,y),g=(P-p)*8;if(b===n.MIXED)return g;const x=g-d(b,f);switch(b){case n.NUMERIC:return Math.floor(x/10*3);case n.ALPHANUMERIC:return Math.floor(x/11*2);case n.KANJI:return Math.floor(x/13);case n.BYTE:default:return Math.floor(x/8)}},e.getBestVersionForData=function(f,y){let b;const P=i.from(y,i.M);if(Array.isArray(f)){if(f.length>1)return u(f,P);if(f.length===0)return 1;b=f[0]}else b=f;return a(b.mode,b.getLength(),P)},e.getEncodedBits=function(f){if(!r.isValid(f)||f<7)throw new Error("Invalid QR Code version");let y=f<<12;for(;t.getBCHDigit(y)-l>=0;)y^=s<<t.getBCHDigit(y)-l;return f<<12|y}})(Fe)),Fe}var He={},Ft;function Yn(){if(Ft)return He;Ft=1;const e=te(),t=1335,o=21522,i=e.getBCHDigit(t);return He.getEncodedBits=function(r,s){const l=r.bit<<3|s;let a=l<<10;for(;e.getBCHDigit(a)-i>=0;)a^=t<<e.getBCHDigit(a)-i;return(l<<10|a)^o},He}var ze={},Ke,jt;function Gn(){if(jt)return Ke;jt=1;const e=ne();function t(o){this.mode=e.NUMERIC,this.data=o.toString()}return t.getBitsLength=function(i){return 10*Math.floor(i/3)+(i%3?i%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){let n,r,s;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),s=parseInt(r,10),i.put(s,10);const l=this.data.length-n;l>0&&(r=this.data.substr(n),s=parseInt(r,10),i.put(s,l*3+1))},Ke=t,Ke}var Ve,Ot;function Qn(){if(Ot)return Ve;Ot=1;const e=ne(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(i){this.mode=e.ALPHANUMERIC,this.data=i}return o.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(n){let r;for(r=0;r+2<=this.data.length;r+=2){let s=t.indexOf(this.data[r])*45;s+=t.indexOf(this.data[r+1]),n.put(s,11)}this.data.length%2&&n.put(t.indexOf(this.data[r]),6)},Ve=o,Ve}var Je,Ht;function Wn(){if(Ht)return Je;Ht=1;const e=ne();function t(o){this.mode=e.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return t.getBitsLength=function(i){return i*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(o){for(let i=0,n=this.data.length;i<n;i++)o.put(this.data[i],8)},Je=t,Je}var Ye,zt;function Xn(){if(zt)return Ye;zt=1;const e=ne(),t=te();function o(i){this.mode=e.KANJI,this.data=i}return o.getBitsLength=function(n){return n*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(i){let n;for(n=0;n<this.data.length;n++){let r=t.toSJIS(this.data[n]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
|
|
3
|
-
Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),i.put(r,13)}},Ye=o,Ye}var Ge={exports:{}},Kt;function Zn(){return Kt||(Kt=1,(function(e){var t={single_source_shortest_paths:function(o,i,n){var r={},s={};s[i]=0;var l=t.PriorityQueue.make();l.push(i,0);for(var a,d,m,u,h,f,y,b,P;!l.empty();){a=l.pop(),d=a.value,u=a.cost,h=o[d]||{};for(m in h)h.hasOwnProperty(m)&&(f=h[m],y=u+f,b=s[m],P=typeof s[m]>"u",(P||b>y)&&(s[m]=y,l.push(m,y),r[m]=d))}if(typeof n<"u"&&typeof s[n]>"u"){var p=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(p)}return r},extract_shortest_path_from_predecessor_list:function(o,i){for(var n=[],r=i;r;)n.push(r),o[r],r=o[r];return n.reverse(),n},find_path:function(o,i,n){var r=t.single_source_shortest_paths(o,i,n);return t.extract_shortest_path_from_predecessor_list(r,n)},PriorityQueue:{make:function(o){var i=t.PriorityQueue,n={},r;o=o||{};for(r in i)i.hasOwnProperty(r)&&(n[r]=i[r]);return n.queue=[],n.sorter=o.sorter||i.default_sorter,n},default_sorter:function(o,i){return o.cost-i.cost},push:function(o,i){var n={value:o,cost:i};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Ge)),Ge.exports}var Vt;function $n(){return Vt||(Vt=1,(function(e){const t=ne(),o=Gn(),i=Qn(),n=Wn(),r=Xn(),s=gn(),l=te(),a=Zn();function d(p){return unescape(encodeURIComponent(p)).length}function m(p,g,x){const N=[];let M;for(;(M=p.exec(x))!==null;)N.push({data:M[0],index:M.index,mode:g,length:M[0].length});return N}function u(p){const g=m(s.NUMERIC,t.NUMERIC,p),x=m(s.ALPHANUMERIC,t.ALPHANUMERIC,p);let N,M;return l.isKanjiModeEnabled()?(N=m(s.BYTE,t.BYTE,p),M=m(s.KANJI,t.KANJI,p)):(N=m(s.BYTE_KANJI,t.BYTE,p),M=[]),g.concat(x,N,M).sort(function(w,C){return w.index-C.index}).map(function(w){return{data:w.data,mode:w.mode,length:w.length}})}function h(p,g){switch(g){case t.NUMERIC:return o.getBitsLength(p);case t.ALPHANUMERIC:return i.getBitsLength(p);case t.KANJI:return r.getBitsLength(p);case t.BYTE:return n.getBitsLength(p)}}function f(p){return p.reduce(function(g,x){const N=g.length-1>=0?g[g.length-1]:null;return N&&N.mode===x.mode?(g[g.length-1].data+=x.data,g):(g.push(x),g)},[])}function y(p){const g=[];for(let x=0;x<p.length;x++){const N=p[x];switch(N.mode){case t.NUMERIC:g.push([N,{data:N.data,mode:t.ALPHANUMERIC,length:N.length},{data:N.data,mode:t.BYTE,length:N.length}]);break;case t.ALPHANUMERIC:g.push([N,{data:N.data,mode:t.BYTE,length:N.length}]);break;case t.KANJI:g.push([N,{data:N.data,mode:t.BYTE,length:d(N.data)}]);break;case t.BYTE:g.push([{data:N.data,mode:t.BYTE,length:d(N.data)}])}}return g}function b(p,g){const x={},N={start:{}};let M=["start"];for(let v=0;v<p.length;v++){const w=p[v],C=[];for(let _=0;_<w.length;_++){const k=w[_],T=""+v+_;C.push(T),x[T]={node:k,lastCount:0},N[T]={};for(let A=0;A<M.length;A++){const S=M[A];x[S]&&x[S].node.mode===k.mode?(N[S][T]=h(x[S].lastCount+k.length,k.mode)-h(x[S].lastCount,k.mode),x[S].lastCount+=k.length):(x[S]&&(x[S].lastCount=k.length),N[S][T]=h(k.length,k.mode)+4+t.getCharCountIndicator(k.mode,g))}}M=C}for(let v=0;v<M.length;v++)N[M[v]].end=0;return{map:N,table:x}}function P(p,g){let x;const N=t.getBestModeForData(p);if(x=t.from(g,N),x!==t.BYTE&&x.bit<N.bit)throw new Error('"'+p+'" cannot be encoded with mode '+t.toString(x)+`.
|
|
4
|
-
Suggested mode is: `+t.toString(N));switch(x===t.KANJI&&!l.isKanjiModeEnabled()&&(x=t.BYTE),x){case t.NUMERIC:return new o(p);case t.ALPHANUMERIC:return new i(p);case t.KANJI:return new r(p);case t.BYTE:return new n(p)}}e.fromArray=function(g){return g.reduce(function(x,N){return typeof N=="string"?x.push(P(N,null)):N.data&&x.push(P(N.data,N.mode)),x},[])},e.fromString=function(g,x){const N=u(g,l.isKanjiModeEnabled()),M=y(N),v=b(M,x),w=a.find_path(v.map,"start","end"),C=[];for(let _=1;_<w.length-1;_++)C.push(v.table[w[_]].node);return e.fromArray(f(C))},e.rawSplit=function(g){return e.fromArray(u(g,l.isKanjiModeEnabled()))}})(ze)),ze}var Jt;function er(){if(Jt)return Re;Jt=1;const e=te(),t=ut(),o=qn(),i=Fn(),n=jn(),r=On(),s=Hn(),l=pn(),a=Vn(),d=Jn(),m=Yn(),u=ne(),h=$n();function f(v,w){const C=v.size,_=r.getPositions(w);for(let k=0;k<_.length;k++){const T=_[k][0],A=_[k][1];for(let S=-1;S<=7;S++)if(!(T+S<=-1||C<=T+S))for(let R=-1;R<=7;R++)A+R<=-1||C<=A+R||(S>=0&&S<=6&&(R===0||R===6)||R>=0&&R<=6&&(S===0||S===6)||S>=2&&S<=4&&R>=2&&R<=4?v.set(T+S,A+R,!0,!0):v.set(T+S,A+R,!1,!0))}}function y(v){const w=v.size;for(let C=8;C<w-8;C++){const _=C%2===0;v.set(C,6,_,!0),v.set(6,C,_,!0)}}function b(v,w){const C=n.getPositions(w);for(let _=0;_<C.length;_++){const k=C[_][0],T=C[_][1];for(let A=-2;A<=2;A++)for(let S=-2;S<=2;S++)A===-2||A===2||S===-2||S===2||A===0&&S===0?v.set(k+A,T+S,!0,!0):v.set(k+A,T+S,!1,!0)}}function P(v,w){const C=v.size,_=d.getEncodedBits(w);let k,T,A;for(let S=0;S<18;S++)k=Math.floor(S/3),T=S%3+C-8-3,A=(_>>S&1)===1,v.set(k,T,A,!0),v.set(T,k,A,!0)}function p(v,w,C){const _=v.size,k=m.getEncodedBits(w,C);let T,A;for(T=0;T<15;T++)A=(k>>T&1)===1,T<6?v.set(T,8,A,!0):T<8?v.set(T+1,8,A,!0):v.set(_-15+T,8,A,!0),T<8?v.set(8,_-T-1,A,!0):T<9?v.set(8,15-T-1+1,A,!0):v.set(8,15-T-1,A,!0);v.set(_-8,8,1,!0)}function g(v,w){const C=v.size;let _=-1,k=C-1,T=7,A=0;for(let S=C-1;S>0;S-=2)for(S===6&&S--;;){for(let R=0;R<2;R++)if(!v.isReserved(k,S-R)){let O=!1;A<w.length&&(O=(w[A]>>>T&1)===1),v.set(k,S-R,O),T--,T===-1&&(A++,T=7)}if(k+=_,k<0||C<=k){k-=_,_=-_;break}}}function x(v,w,C){const _=new o;C.forEach(function(R){_.put(R.mode.bit,4),_.put(R.getLength(),u.getCharCountIndicator(R.mode,v)),R.write(_)});const k=e.getSymbolTotalCodewords(v),T=l.getTotalCodewordsCount(v,w),A=(k-T)*8;for(_.getLengthInBits()+4<=A&&_.put(0,4);_.getLengthInBits()%8!==0;)_.putBit(0);const S=(A-_.getLengthInBits())/8;for(let R=0;R<S;R++)_.put(R%2?17:236,8);return N(_,v,w)}function N(v,w,C){const _=e.getSymbolTotalCodewords(w),k=l.getTotalCodewordsCount(w,C),T=_-k,A=l.getBlocksCount(w,C),S=_%A,R=A-S,O=Math.floor(_/A),z=Math.floor(T/A),V=z+1,re=O-z,ae=new a(re);let Y=0;const Q=new Array(A),W=new Array(A);let I=0;const L=new Uint8Array(v.buffer);for(let X=0;X<A;X++){const oe=X<R?z:V;Q[X]=L.slice(Y,Y+oe),W[X]=ae.encode(Q[X]),Y+=oe,I=Math.max(I,oe)}const E=new Uint8Array(_);let B=0,H,U;for(H=0;H<I;H++)for(U=0;U<A;U++)H<Q[U].length&&(E[B++]=Q[U][H]);for(H=0;H<re;H++)for(U=0;U<A;U++)E[B++]=W[U][H];return E}function M(v,w,C,_){let k;if(Array.isArray(v))k=h.fromArray(v);else if(typeof v=="string"){let O=w;if(!O){const z=h.rawSplit(v);O=d.getBestVersionForData(z,C)}k=h.fromString(v,O||40)}else throw new Error("Invalid data");const T=d.getBestVersionForData(k,C);if(!T)throw new Error("The amount of data is too big to be stored in a QR Code");if(!w)w=T;else if(w<T)throw new Error(`
|
|
5
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
-
Minimum version required to store current data is: `+T+`.
|
|
7
|
-
`);const A=x(w,C,k),S=e.getSymbolSize(w),R=new i(S);return f(R,w),y(R),b(R,w),p(R,C,0),w>=7&&P(R,w),g(R,A),isNaN(_)&&(_=s.getBestMask(R,p.bind(null,R,C))),s.applyMask(_,R),p(R,C,_),{modules:R,version:w,errorCorrectionLevel:C,maskPattern:_,segments:k}}return Re.create=function(w,C){if(typeof w>"u"||w==="")throw new Error("No input text");let _=t.M,k,T;return typeof C<"u"&&(_=t.from(C.errorCorrectionLevel,t.M),k=d.from(C.version),T=s.from(C.maskPattern),C.toSJISFunc&&e.setToSJISFunction(C.toSJISFunc)),M(w,k,_,T)},Re}var Qe={},We={},Yt;function yn(){return Yt||(Yt=1,(function(e){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let i=o.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+o);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(r){return[r,r]}))),i.length===6&&i.push("F","F");const n=parseInt(i.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+i.slice(0,6).join("")}}e.getOptions=function(i){i||(i={}),i.color||(i.color={});const n=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,r=i.width&&i.width>=21?i.width:void 0,s=i.scale||4;return{width:r,scale:r?4:s,margin:n,color:{dark:t(i.color.dark||"#000000ff"),light:t(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},e.getScale=function(i,n){return n.width&&n.width>=i+n.margin*2?n.width/(i+n.margin*2):n.scale},e.getImageWidth=function(i,n){const r=e.getScale(i,n);return Math.floor((i+n.margin*2)*r)},e.qrToImageData=function(i,n,r){const s=n.modules.size,l=n.modules.data,a=e.getScale(s,r),d=Math.floor((s+r.margin*2)*a),m=r.margin*a,u=[r.color.light,r.color.dark];for(let h=0;h<d;h++)for(let f=0;f<d;f++){let y=(h*d+f)*4,b=r.color.light;if(h>=m&&f>=m&&h<d-m&&f<d-m){const P=Math.floor((h-m)/a),p=Math.floor((f-m)/a);b=u[l[P*s+p]?1:0]}i[y++]=b.r,i[y++]=b.g,i[y++]=b.b,i[y]=b.a}}})(We)),We}var Gt;function tr(){return Gt||(Gt=1,(function(e){const t=yn();function o(n,r,s){n.clearRect(0,0,r.width,r.height),r.style||(r.style={}),r.height=s,r.width=s,r.style.height=s+"px",r.style.width=s+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(r,s,l){let a=l,d=s;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),s||(d=i()),a=t.getOptions(a);const m=t.getImageWidth(r.modules.size,a),u=d.getContext("2d"),h=u.createImageData(m,m);return t.qrToImageData(h.data,r,a),o(u,d,m),u.putImageData(h,0,0),d},e.renderToDataURL=function(r,s,l){let a=l;typeof a>"u"&&(!s||!s.getContext)&&(a=s,s=void 0),a||(a={});const d=e.render(r,s,a),m=a.type||"image/png",u=a.rendererOpts||{};return d.toDataURL(m,u.quality)}})(Qe)),Qe}var Xe={},Qt;function nr(){if(Qt)return Xe;Qt=1;const e=yn();function t(n,r){const s=n.a/255,l=r+'="'+n.hex+'"';return s<1?l+" "+r+'-opacity="'+s.toFixed(2).slice(1)+'"':l}function o(n,r,s){let l=n+r;return typeof s<"u"&&(l+=" "+s),l}function i(n,r,s){let l="",a=0,d=!1,m=0;for(let u=0;u<n.length;u++){const h=Math.floor(u%r),f=Math.floor(u/r);!h&&!d&&(d=!0),n[u]?(m++,u>0&&h>0&&n[u-1]||(l+=d?o("M",h+s,.5+f+s):o("m",a,0),a=0,d=!1),h+1<r&&n[u+1]||(l+=o("h",m),m=0)):a++}return l}return Xe.render=function(r,s,l){const a=e.getOptions(s),d=r.modules.size,m=r.modules.data,u=d+a.margin*2,h=a.color.light.a?"<path "+t(a.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",f="<path "+t(a.color.dark,"stroke")+' d="'+i(m,d,a.margin)+'"/>',y='viewBox="0 0 '+u+" "+u+'"',P='<svg xmlns="http://www.w3.org/2000/svg" '+(a.width?'width="'+a.width+'" height="'+a.width+'" ':"")+y+' shape-rendering="crispEdges">'+h+f+`</svg>
|
|
8
|
-
`;return typeof l=="function"&&l(null,P),P},Xe}var Wt;function rr(){if(Wt)return ie;Wt=1;const e=Un(),t=er(),o=tr(),i=nr();function n(r,s,l,a,d){const m=[].slice.call(arguments,1),u=m.length,h=typeof m[u-1]=="function";if(!h&&!e())throw new Error("Callback required as last argument");if(h){if(u<2)throw new Error("Too few arguments provided");u===2?(d=l,l=s,s=a=void 0):u===3&&(s.getContext&&typeof d>"u"?(d=a,a=void 0):(d=a,a=l,l=s,s=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(l=s,s=a=void 0):u===2&&!s.getContext&&(a=l,l=s,s=void 0),new Promise(function(f,y){try{const b=t.create(l,a);f(r(b,s,a))}catch(b){y(b)}})}try{const f=t.create(l,a);d(null,r(f,s,a))}catch(f){d(f)}}return ie.create=t.create,ie.toCanvas=n.bind(null,o.render),ie.toDataURL=n.bind(null,o.renderToDataURL),ie.toString=n.bind(null,function(r,s,l){return i.render(r,l)}),ie}var or=rr();const ir=Ln(or);function de({message:e,confirmLabel:t="Confirm",confirmDanger:o=!1,onConfirm:i,onCancel:n}){return c("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},children:c("div",{className:"glass-card p-5 flex flex-col gap-4 w-72",children:[c("p",{className:"text-sm text-center",style:{color:"var(--text-main)"},children:e}),c("div",{className:"flex gap-2",children:[c("button",{onClick:n,className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:"Cancel"}),c("button",{onClick:i,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:o?"rgba(220,53,69,0.8)":"var(--brand-500)",color:"#fff"},children:t})]})]})})}const Xt="9remote.cc";function sr(e){if(e<=0)return"Expired";const t=Math.floor(e/1e3),o=Math.floor(t/60),i=t%60;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function pe({icon:e,onClick:t,title:o,danger:i}){return c("button",{onClick:t,title:o,className:"glass-btn w-7 h-7 flex items-center justify-center flex-shrink-0",style:i?{color:"rgba(255,100,100,0.7)"}:{color:"var(--text-muted)"},children:c("span",{className:"material-symbols-outlined",style:{fontSize:15},children:e})})}function Zt({qrUrl:e,oneTimeKey:t,oneTimeKeyExpiresAt:o,permanentKey:i,onGenerateOneTimeKey:n,onRegenerateKey:r}){const s=ct(null),[l,a]=F(null),[d,m]=F(null),[u,h]=F(null);se(()=>{!e||!s.current||ir.toCanvas(s.current,e,{width:160,margin:1,color:{dark:"#0f1923",light:"#ffffff"}}).catch(()=>{})},[e]),se(()=>{if(!o){a(null);return}const y=()=>a(o-Date.now());y();const b=setInterval(y,1e3);return()=>clearInterval(b)},[o]);const f=(y,b)=>{navigator.clipboard.writeText(y).catch(()=>{}),m(b),setTimeout(()=>m(null),2e3)};return c(ee,{children:[u==="oneTime"&&c(de,{message:"Generate a new one-time key? The current one will expire immediately.",confirmLabel:"Generate",onConfirm:()=>{h(null),n==null||n()},onCancel:()=>h(null)}),u==="regen"&&c(de,{message:"Regenerate permanent key? All existing sessions will be disconnected.",confirmLabel:"Regenerate",confirmDanger:!0,onConfirm:()=>{h(null),r==null||r()},onCancel:()=>h(null)}),c("div",{className:"glass-card p-5 flex flex-col items-center gap-4",children:[c("div",{className:"w-44 h-44 rounded-xl overflow-hidden bg-white p-2 flex items-center justify-center flex-shrink-0",children:e?c("canvas",{ref:s}):c("span",{className:"material-symbols-outlined text-gray-300 text-6xl",children:"qr_code_2"})}),c("div",{className:"flex flex-col items-center gap-1",children:[c("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Scan QR or open link to sign in"}),c("a",{href:`https://${Xt}/login`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 hover:underline transition-opacity",children:[c("span",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}),c("span",{className:"text-sm font-bold",style:{color:"var(--brand-500)"},children:[Xt,"/login"]}),c("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:14,color:"var(--brand-500)"},children:"open_in_new"})]})]}),c("div",{className:"w-full h-px",style:{background:"var(--border)"}}),c("div",{className:"w-full flex flex-col gap-1.5",children:[c("div",{className:"flex items-center justify-between px-0.5",children:[c("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"One-Time Key"}),c("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Single use · expires"})]}),c("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[c("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"timer"}),c("span",{className:"flex-1 font-mono font-bold tracking-[0.18em] text-base truncate",style:{color:t?"var(--brand-500)":"var(--border)"},children:t||"• • • • • •"}),l!==null&&c("span",{className:`text-xs font-mono flex-shrink-0 ${l<=0?"text-red-400":""}`,style:l>0?{color:"var(--text-muted)"}:{},children:sr(l)}),t&&c(pe,{icon:d==="oneTime"?"check":"content_copy",onClick:()=>f(t,"oneTime"),title:"Copy one-time key"}),c(pe,{icon:"refresh",onClick:()=>h("oneTime"),title:"New one-time key"})]})]}),c("div",{className:"w-full flex flex-col gap-1.5",children:[c("div",{className:"flex items-center justify-between px-0.5",children:[c("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Permanent Key"}),c("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Reusable · no expiry"})]}),c("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[c("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"key"}),c("span",{className:"flex-1 font-mono text-xs truncate",style:{color:"var(--text-muted)"},children:i||"— not set —"}),i&&c(pe,{icon:d==="permanent"?"check":"content_copy",onClick:()=>f(i,"permanent"),title:"Copy permanent key"}),c(pe,{icon:"autorenew",onClick:()=>h("regen"),title:"Regenerate permanent key",danger:!0})]})]})]})]})}const lr="https://docs.9remote.cc/",vn={screenRecording:{label:"Screen Recording",icon:"screenshot_monitor",desc:"Capture screen content"},accessibility:{label:"Accessibility",icon:"accessibility_new",desc:"Control mouse & keyboard"}};function ar({type:e,granted:t,onRequest:o}){const i=vn[e]||{label:e,desc:""};return c("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[c("span",{className:`material-symbols-outlined flex-shrink-0 ${t?"text-green-400":""}`,style:{fontSize:18,color:t?void 0:"var(--text-muted)"},children:t?"check_circle":"cancel"}),c("div",{className:"flex-1 min-w-0",children:[c("p",{className:"text-xs font-medium",style:{color:t?"var(--text-main)":"var(--text-muted)"},children:i.label}),c("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:i.desc})]}),!t&&c("button",{onClick:()=>o(e),title:"Click to grant permission",className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:"var(--border)",cursor:"pointer"},children:c("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]})}function cr({desktopEnabled:e,onDesktopToggle:t,permissions:o,onRequestPermission:i}){const n=Object.entries(vn),s=!n.every(([l])=>!!(o!=null&&o[l]))&&!e;return c("div",{className:"glass-card p-4 flex flex-col gap-3",children:[c("div",{className:"flex items-center gap-3",children:[c("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(255,87,10,0.15)"},children:c("span",{className:"material-symbols-outlined",style:{fontSize:20,color:"var(--brand-400)"},children:"terminal"})}),c("div",{className:"flex-1 min-w-0",children:[c("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"Remote Terminal"}),c("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Full shell access · always on"})]}),c("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-full",style:{background:"rgba(74,222,128,0.1)"},children:[c("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400"}),c("span",{className:"text-xs text-green-400 font-medium",children:"On"})]})]}),c("div",{className:"w-full h-px",style:{background:"var(--border)"}}),c("div",{className:"flex items-center gap-3",children:[c("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:e?"rgba(255,87,10,0.15)":"var(--glass-bg)"},children:c("span",{className:"material-symbols-outlined",style:{fontSize:20,color:e?"var(--brand-400)":"var(--text-muted)"},children:"desktop_windows"})}),c("div",{className:"flex-1 min-w-0",children:[c("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"Remote Desktop"}),c("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Control screen, mouse & keyboard"})]}),c("button",{onClick:s?void 0:t,disabled:s,title:s?"Grant all permissions below to enable":"",className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:e?"var(--brand-500)":"var(--border)",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},children:c("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:e?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),c("div",{className:"flex flex-col border-t pt-2",style:{borderColor:"var(--border)"},children:[c("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"System Permissions"}),n.map(([l])=>c(ar,{type:l,granted:(o==null?void 0:o[l])??!1,onRequest:i},l))]})]})}function ur({version:e}){return e?c("div",{className:"px-5 py-2 flex items-center gap-2 border-b",style:{background:"rgba(255,87,10,0.08)",borderColor:"rgba(255,87,10,0.2)"},children:[c("span",{className:"material-symbols-outlined text-sm flex-shrink-0",style:{color:"var(--brand-400)"},children:"system_update"}),c("span",{className:"text-xs flex-1",style:{color:"var(--brand-400)"},children:["Version ",e," available"]}),c("button",{onClick:()=>fetch("/api/update",{method:"POST"}).catch(()=>{}),className:"flex-shrink-0 text-xs px-2 py-0.5 rounded font-medium",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:"Update"})]}):null}const dr=[{icon:"terminal",label:"Terminal",desc:"Full shell access"},{icon:"desktop_windows",label:"Desktop",desc:"Remote screen control"},{icon:"folder_open",label:"Files",desc:"Browse & edit files"}],fr=[{icon:"qr_code_scanner",text:"Scan QR to connect instantly"},{icon:"wifi_off",text:"No port forwarding needed"},{icon:"devices",text:"Works on any device"}];function hr({onStart:e}){const[t,o]=F(!1),i=()=>{o(!0),e()};return c("div",{className:"flex-1 flex flex-col items-center justify-between px-6 py-6 overflow-y-auto",children:[c("div",{className:"flex flex-col items-center gap-2 text-center mt-2",children:[c("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mb-1",style:{background:"var(--brand-500)",boxShadow:"0 8px 32px rgba(255,87,10,0.35)"},children:c("span",{className:"material-symbols-outlined text-white",style:{fontSize:30},children:"terminal"})}),c("h1",{className:"text-lg font-bold tracking-tight",style:{color:"var(--text-main)"},children:"9Remote"}),c("p",{className:"text-xs leading-5 max-w-[220px]",style:{color:"var(--text-muted)"},children:"Access your terminal, desktop & files from anywhere"})]}),c("div",{className:"flex gap-2 w-full mt-5",children:dr.map(n=>c("div",{className:"flex-1 dark-card flex flex-col items-center gap-1.5 py-3 px-1",children:[c("span",{className:"material-symbols-outlined",style:{fontSize:22,color:"var(--brand-400)"},children:n.icon}),c("p",{className:"text-xs font-semibold",style:{color:"var(--text-main)"},children:n.label}),c("p",{className:"text-[10px] text-center leading-4",style:{color:"var(--text-muted)"},children:n.desc})]},n.label))}),c("div",{className:"flex flex-col gap-2 w-full mt-4",children:fr.map(n=>c("div",{className:"flex items-center gap-2.5",children:[c("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--brand-400)"},children:n.icon}),c("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:n.text})]},n.text))}),c("button",{onClick:t?void 0:i,disabled:t,className:"btn-primary w-full py-3.5 flex items-center justify-center gap-2 text-sm font-semibold mt-6",style:{borderRadius:"var(--radius-brand)",opacity:t?.7:1},children:t?c(ee,{children:[c("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(n=>c("span",{className:"w-1.5 h-1.5 rounded-full bg-white dot-bounce",style:{animationDelay:`${n*.18}s`}},n))}),"Connecting..."]}):c(ee,{children:[c("span",{className:"material-symbols-outlined text-base",children:"play_arrow"}),"Connect"]})})]})}function mr(e,t,o=[]){const i=new Map;for(const l of t){if(!l.deviceId)continue;const a=i.get(l.deviceId);(!a||l.connectedAt&&l.connectedAt<a.connectedAt)&&i.set(l.deviceId,l)}const n=e.map(l=>{const a=i.get(l.deviceId);return{deviceId:l.deviceId,status:a?"online":"offline",ip:(a==null?void 0:a.ip)||null,connectedAt:(a==null?void 0:a.connectedAt)||null,approvedAt:l.approvedAt||null}}),r=o.map(l=>({deviceId:l.deviceId,status:"pending",ip:l.ip||null,connectedAt:null,approvedAt:null,rejectedAt:l.rejectedAt||null})),s={online:0,pending:1,offline:2};return[...n,...r].sort((l,a)=>s[l.status]-s[a.status])}const $t={online:{color:"#4ade80",icon:"wifi",title:"Online"},offline:{color:"var(--text-muted)",icon:"wifi_off",title:"Offline"},pending:{color:"#f59e0b",icon:"hourglass_top",title:"Pending approval"}};function pr({client:e,onRemove:t,onApprove:o}){const i=`${e.deviceId.slice(0,8)}...`,n=$t[e.status]||$t.offline,r=e.status==="online"?`Connected · ${e.connectedAt?new Date(e.connectedAt).toLocaleTimeString():""}`:e.status==="pending"?"Pending · waiting for approval":e.approvedAt?`Offline · approved ${new Date(e.approvedAt).toLocaleDateString()}`:"Offline",s=e.status==="online"?"Disconnect":"Remove";return c("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[c("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:18,color:n.color},title:n.title,children:n.icon}),c("div",{className:"flex-1 min-w-0",children:[c("p",{className:"text-xs font-medium font-mono truncate",style:{color:"var(--text-main)"},children:[i,e.ip?` · ${e.ip}`:""]}),c("p",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:r})]}),e.status==="pending"&&c("button",{onClick:()=>o==null?void 0:o(e),className:"flex-shrink-0 text-xs px-2 py-1 rounded-lg font-medium",style:{background:"rgba(74,222,128,0.15)",color:"#4ade80"},title:"Approve this device",children:"Approve"}),c("button",{onClick:()=>t(e),className:"flex-shrink-0 text-xs px-2 py-1 rounded-lg font-medium",style:{background:"rgba(220,53,69,0.15)",color:"#dc3545"},title:"Disconnect and remove this device",children:s})]})}function _r({step:e,stepDesc:t="",healthCheck:o,tunnelUrl:i,oneTimeKey:n,oneTimeKeyExpiresAt:r,permanentKey:s,qrUrl:l,permissions:a,desktopEnabled:d,updateVersion:m,connections:u=[],version:h="",onRequestPermission:f,onDesktopToggle:y,onStop:b,onStart:P,onShutdown:p,onGenerateOneTimeKey:g,onRegenerateKey:x,logs:N=[],theme:M,onToggleTheme:v,pendingDevice:w,onDeviceApprove:C,onDeviceReject:_,approvedDevices:k=[],rejectedDevices:T=[],onDeviceRemove:A,onFetchDevices:S,onDeviceApproveRejected:R,autoApprove:O=!1,onAutoApproveToggle:z}){var oe;const[V,re]=F("connect"),[ae,Y]=F(!1),[Q,W]=F(!1),[I,L]=F(null),E=ct(null),B=e===0,H=e>0&&e<5;se(()=>{var K;V==="log"&&((K=E.current)==null||K.scrollIntoView({behavior:"smooth"})),V==="connect"&&(S==null||S())},[N,V,u.length]);const U=mr(k,u,T),X=U.filter(K=>K.status==="online").length;return c("div",{className:"h-full flex flex-col relative overflow-hidden",style:{background:"var(--bg-body)"},children:[c("div",{className:"flex-1 flex flex-col w-full min-h-0 dot-grid-bg overflow-hidden md:max-w-5xl p-3",style:{margin:"0 auto"},children:[c("div",{className:"flex items-center justify-between px-5 py-4",style:{boxShadow:"var(--header-shadow)",backdropFilter:"blur(10px)"},children:[c("div",{className:"flex items-center gap-3",children:[c("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--brand-500)"},children:c("span",{className:"material-symbols-outlined text-white text-base",children:"terminal"})}),c("div",{className:"flex flex-col leading-tight",children:[c("span",{className:"brand-text text-xs",children:"9Remote"}),h&&c("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:["v",h]})]})]}),c("div",{className:"flex items-center gap-2",children:[c("button",{onClick:v,className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},title:M==="dark"?"Switch to light mode":"Switch to dark mode",children:c("span",{className:"material-symbols-outlined text-sm",children:M==="dark"?"light_mode":"dark_mode"})}),c("button",{onClick:()=>window.open(lr,"_blank"),className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},children:c("span",{className:"material-symbols-outlined text-sm",children:"help_outline"})}),!B&&c("button",{onClick:()=>Y(!0),className:"btn-danger px-3 h-7 flex items-center gap-1.5 text-xs font-medium",children:[c("span",{className:"material-symbols-outlined text-sm",children:"stop_circle"}),"Disconnect"]}),c("button",{onClick:()=>W(!0),className:"glass-btn w-7 h-7 flex items-center justify-center",style:{color:"var(--text-muted)"},title:"Shutdown 9Remote (stop server, tunnel and quit)",children:c("span",{className:"material-symbols-outlined text-sm",children:"power_settings_new"})})]})]}),c(ur,{version:m}),B?c(hr,{onStart:P,connecting:!1}):H?c("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4 max-w-2xl mx-auto w-full",children:c(Dn,{currentStep:e,activeDesc:t,healthCheck:o})}):c("div",{className:"flex-1 flex flex-col md:flex-row min-h-0",children:[c("div",{className:"hidden md:flex md:flex-col sidebar w-96 flex-shrink-0 overflow-y-auto p-5 gap-4",children:c(Zt,{qrUrl:l,oneTimeKey:n,oneTimeKeyExpiresAt:r,permanentKey:s,tunnelUrl:i,onGenerateOneTimeKey:g,onRegenerateKey:x})}),c("div",{className:"flex-1 flex flex-col min-h-0",children:[c("div",{className:"flex px-5 pt-3 gap-3",style:{borderColor:"var(--border)"},children:[{id:"connect",label:"Connection"},{id:"log",label:"Logs"}].map(K=>c("button",{onClick:()=>re(K.id),className:"py-2 text-xs font-medium border-b-2 transition-colors",style:V===K.id?{borderColor:"var(--brand-500)",color:"var(--brand-500)"}:{borderColor:"transparent",color:"var(--text-muted)"},children:K.label},K.id))}),c("div",{className:"flex-1 overflow-y-auto px-5 py-4 flex flex-col gap-4",children:[V==="connect"&&c(ee,{children:[c("div",{className:"md:hidden",children:c(Zt,{qrUrl:l,oneTimeKey:n,oneTimeKeyExpiresAt:r,permanentKey:s,tunnelUrl:i,onGenerateOneTimeKey:g,onRegenerateKey:x})}),c(cr,{desktopEnabled:d,onDesktopToggle:y,permissions:a,onRequestPermission:f}),c("div",{className:"glass-card p-4 flex flex-col gap-1",children:[c("p",{className:"text-xs font-medium uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:["Clients",U.length>0?` (${X}/${U.length} online)`:""]}),c("div",{className:"flex items-center gap-3 py-2 border-b",style:{borderColor:"var(--border)"},children:[c("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:18,color:O?"var(--brand-400)":"var(--text-muted)"},children:O?"lock_open":"lock"}),c("div",{className:"flex-1 min-w-0",children:[c("p",{className:"text-xs font-medium",style:{color:"var(--text-main)"},children:"Auto-approve new devices"}),c("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:O?"Any new device connects without approval":"Require manual approval for new devices"})]}),c("button",{onClick:z,title:O?"Disable auto-approve":"Enable auto-approve",className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:O?"var(--brand-500)":"var(--border)",cursor:"pointer"},children:c("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:O?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),U.length===0?c("p",{className:"text-xs text-center py-3",style:{color:"var(--text-muted)"},children:"No clients yet"}):U.map(K=>c(pr,{client:K,onRemove:L,onApprove:Se=>R==null?void 0:R(Se.deviceId)},K.deviceId))]})]}),V==="log"&&c("div",{className:"flex-1 flex flex-col",children:N.length===0?c("p",{className:"text-xs text-center mt-8",style:{color:"var(--text-muted)"},children:"No logs yet"}):c("div",{className:"flex flex-col gap-0.5",children:[N.map((K,Se)=>c("p",{className:"text-xs font-mono leading-5 break-all",style:{color:"var(--text-muted)"},children:K},Se)),c("div",{ref:E})]})})]})]})]})]}),ae&&c(de,{message:"Disconnect and stop the tunnel? Remote clients will be disconnected.",confirmLabel:"Disconnect",confirmDanger:!0,onConfirm:()=>{Y(!1),b==null||b()},onCancel:()=>Y(!1)}),Q&&c(de,{message:"Shutdown 9Remote completely? This will stop the server, close the tunnel and quit the app.",confirmLabel:"Shutdown",confirmDanger:!0,onConfirm:()=>{W(!1),p==null||p()},onCancel:()=>W(!1)}),I&&c(de,{message:I.status==="online"?`Disconnect and remove device ${I.deviceId.slice(0,8)}...? The client will be disconnected and need approval again next time.`:I.status==="pending"?`Remove pending device ${I.deviceId.slice(0,8)}...? It will need a fresh approval request to connect again.`:`Remove device ${I.deviceId.slice(0,8)}...? It will need approval again next time.`,confirmLabel:I.status==="online"?"Disconnect & Remove":"Remove",confirmDanger:!0,onConfirm:()=>{A==null||A(I),L(null)},onCancel:()=>L(null)}),w&&c("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},children:c("div",{className:"glass-card p-5 flex flex-col gap-4 w-80",children:[c("div",{className:"flex items-center gap-2",children:[c("span",{className:"material-symbols-outlined",style:{color:"var(--brand-500)",fontSize:24},children:"devices"}),c("span",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"New Device Connection"})]}),c("div",{className:"flex flex-col gap-1 text-xs",style:{color:"var(--text-muted)"},children:[c("span",{children:["Device: ",c("span",{style:{color:"var(--text-main)"},children:[(oe=w.deviceId)==null?void 0:oe.slice(0,8),"..."]})]}),c("span",{children:["IP: ",c("span",{style:{color:"var(--text-main)"},children:w.ip})]})]}),c("div",{className:"flex gap-2",children:[c("button",{onClick:_,className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:"Reject"}),c("button",{onClick:C,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:"var(--brand-500)",color:"#fff"},children:"Approve"})]})]})})]})}const gr=3e3,rt={running:!1,timeoutMs:0,startedAt:null,logs:[]},Ze={step:0,stepDesc:"",tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:"",qrUrl:"",latency:null,uptime:null,healthCheck:rt},yr={screenRecording:!1,accessibility:!1},en=200;function vr(){const[e,t]=F(Ze),[o,i]=F(yr),[n,r]=F(!1),[s,l]=F([]),[a,d]=F(null),[m,u]=F([]),[h,f]=F(null),[y,b]=F([]),[P,p]=F([]),[g,x]=F(!1),[N,M]=F(""),[v,w]=F(()=>localStorage.getItem("9remote-theme")||"dark");se(()=>{document.documentElement.setAttribute("data-theme",v),localStorage.setItem("9remote-theme",v)},[v]);const C=()=>{w(I=>I==="dark"?"light":"dark")};se(()=>{fetch("/api/version").then(E=>E.json()).then(E=>M(E.version??"")).catch(()=>{}),fetch("/api/ui/state").then(E=>E.json()).then(E=>{t({step:E.step??0,stepDesc:E.stepDesc??"",tunnelUrl:E.tunnelUrl??"",oneTimeKey:E.oneTimeKey??"",oneTimeKeyExpiresAt:E.oneTimeKeyExpiresAt??null,permanentKey:E.permanentKey??"",qrUrl:E.qrUrl??"",latency:E.latency??null,uptime:E.uptime??null,healthCheck:E.healthCheck??rt}),i({screenRecording:E.screenRecording??!1,accessibility:E.accessibility??!1}),E.desktopEnabled!==void 0&&r(E.desktopEnabled),E.theme&&(E.theme==="light"||E.theme==="dark")&&w(E.theme)}).catch(()=>{});const I=new EventSource("/api/ui/events");I.onmessage=E=>{try{const B=JSON.parse(E.data);B.type==="state"?t({step:B.step??0,stepDesc:B.stepDesc??"",tunnelUrl:B.tunnelUrl??"",oneTimeKey:B.oneTimeKey??"",oneTimeKeyExpiresAt:B.oneTimeKeyExpiresAt??null,permanentKey:B.permanentKey??"",qrUrl:B.qrUrl??"",latency:B.latency??null,uptime:B.uptime??null,healthCheck:B.healthCheck??rt}):B.type==="log"?l(H=>{const U=[...H,B.message];return U.length>en?U.slice(-en):U}):B.type==="updateAvailable"?d(B.version):B.type==="permissions"?(i({screenRecording:B.screenRecording,accessibility:B.accessibility}),B.desktopEnabled!==void 0&&r(B.desktopEnabled)):B.type==="connections"?u(B.connections??[]):B.type==="deviceApproval"&&B.action==="pending"?f({socketId:B.socketId,deviceId:B.deviceId,ip:B.ip}):B.type==="deviceApproval"&&B.action==="refresh"&&z()}catch{}},I.onerror=()=>{},fetch("/api/device/auto-approve").then(E=>E.json()).then(E=>{x(!!(E!=null&&E.enabled))}).catch(()=>{});const L=setInterval(async()=>{var E;if(!_.current)try{const B=await fetch("/api/device/pending");if(!B.ok)return;const H=await B.json(),U=(E=H==null?void 0:H.pending)==null?void 0:E[0];U&&!_.current&&f({socketId:U.socketId,deviceId:U.deviceId,ip:U.ip})}catch{}},gr);return()=>{I.close(),clearInterval(L)}},[]);const _=ct(null);se(()=>{_.current=h},[h]);const k=async I=>{await fetch("/api/permissions/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:I})}).catch(()=>{})},T=()=>{fetch("/api/ui/stop",{method:"POST"}).catch(()=>{}),t(Ze)},A=()=>{fetch("/api/ui/start",{method:"POST"}).catch(()=>{})},S=()=>{fetch("/api/ui/shutdown",{method:"POST"}).catch(()=>{}),t(Ze)},R=async()=>{const I=await fetch("/api/key/one-time",{method:"POST"}).catch(()=>null);if(!(I!=null&&I.ok))return;const L=await I.json().catch(()=>null);L!=null&&L.oneTimeKey&&t(E=>({...E,oneTimeKey:L.oneTimeKey,oneTimeKeyExpiresAt:L.expiresAt,qrUrl:L.qrUrl??E.qrUrl}))},O=async()=>{const I=!n;r(I),await fetch("/api/desktop/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:I})}).catch(()=>{})},z=async()=>{try{const[I,L]=await Promise.all([fetch("/api/device/approved"),fetch("/api/device/rejected")]);if(I.ok){const E=await I.json();b(E.devices||[])}if(L.ok){const E=await L.json();p(E.rejected||[])}}catch{}},V=async I=>{const L=I.status==="pending"?"/api/device/clear-rejected":"/api/device/remove";await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceId:I.deviceId})}).catch(()=>{}),z()},re=async()=>{h&&(await fetch("/api/device/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({socketId:h.socketId})}).catch(()=>{}),f(null),z())},ae=async()=>{h&&(await fetch("/api/device/reject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({socketId:h.socketId})}).catch(()=>{}),f(null),z())},Y=async()=>{const I=!g;x(I);try{const E=await(await fetch("/api/device/auto-approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:I})})).json().catch(()=>null);E&&typeof E.enabled=="boolean"&&x(E.enabled)}catch{x(!I)}},Q=async I=>{await fetch("/api/device/approve-rejected",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceId:I})}).catch(()=>{}),z()},W=async()=>{const I=await fetch("/api/key/regenerate",{method:"POST"}).catch(()=>null);if(!(I!=null&&I.ok))return;const L=await I.json().catch(()=>null);L!=null&&L.permanentKey&&t(E=>({...E,permanentKey:L.permanentKey}))};return c(_r,{step:e.step,stepDesc:e.stepDesc,healthCheck:e.healthCheck,tunnelUrl:e.tunnelUrl,oneTimeKey:e.oneTimeKey,oneTimeKeyExpiresAt:e.oneTimeKeyExpiresAt,permanentKey:e.permanentKey,qrUrl:e.qrUrl,permissions:o,desktopEnabled:n,updateVersion:a,connections:m,onRequestPermission:k,onDesktopToggle:O,onStop:T,onStart:A,onShutdown:S,onGenerateOneTimeKey:R,onRegenerateKey:W,logs:s,version:N,theme:v,onToggleTheme:C,pendingDevice:h,onDeviceApprove:re,onDeviceReject:ae,approvedDevices:y,rejectedDevices:P,onDeviceRemove:V,onFetchDevices:z,onDeviceApproveRejected:Q,autoApprove:g,onAutoApproveToggle:Y})}En(c(vr,{}),document.getElementById("root"));
|