@dsh-sup/dsh-core-linux-x64 0.1.6-BETA.16 → 0.1.6-BETA.18

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/core.cjs CHANGED
@@ -951,7 +951,7 @@ var require_version = __commonJS({
951
951
  var fs2 = require("node:fs");
952
952
  var path2 = require("node:path");
953
953
  function guardVersion() {
954
- if (true) return String("0.1.6-BETA.16");
954
+ if (true) return String("0.1.6-BETA.18");
955
955
  try {
956
956
  return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
957
957
  } catch {
@@ -7001,10 +7001,12 @@ var require_browser = __commonJS({
7001
7001
  exitIsEvidence: ownsItsWindow("browser", pl)
7002
7002
  });
7003
7003
  if (form.direct && form.engine === "chromium" && o.profileDir) {
7004
- const args = ["--incognito", "--user-data-dir=" + o.profileDir];
7005
- if (Array.isArray(o.size) && o.size.length === 2) args.push("--window-size=" + o.size[0] + "," + o.size[1]);
7006
- if (o.lang) args.push("--lang=" + o.lang);
7007
- args.push("--no-first-run", "--no-default-browser-check", "--disable-session-crashed-bubble");
7004
+ const args = [
7005
+ "--user-data-dir=" + o.profileDir,
7006
+ "--no-first-run",
7007
+ "--no-default-browser-check",
7008
+ "--disable-session-crashed-bubble"
7009
+ ];
7008
7010
  return Object.assign(common, {
7009
7011
  bin: b.bin,
7010
7012
  args: [...baseArgs, ...args, url],
@@ -7019,7 +7021,7 @@ var require_browser = __commonJS({
7019
7021
  if (form.direct && form.engine === "firefox" && o.profileDir) {
7020
7022
  return Object.assign(common, {
7021
7023
  bin: b.bin,
7022
- args: [...baseArgs, "--no-remote", "--profile", o.profileDir, "-private-window", url],
7024
+ args: [...baseArgs, "--no-remote", "--profile", o.profileDir, url],
7023
7025
  via: "isolated",
7024
7026
  isolated: true,
7025
7027
  watch: true,
@@ -7069,15 +7071,10 @@ var require_browser = __commonJS({
7069
7071
  }
7070
7072
  var OPEN_OBSERVE_MS = 1500;
7071
7073
  var LOGIN_TZ_POOL = ["Asia/Shanghai", "Asia/Seoul", "Asia/Tokyo", "Asia/Singapore", "Europe/Berlin", "Europe/London", "Europe/Paris", "America/New_York", "America/Los_Angeles", "Australia/Sydney"];
7072
- var LOGIN_LANG_POOL = ["zh-CN", "en-US", "en-GB", "ja-JP", "ko-KR", "de-DE", "fr-FR", "zh-TW"];
7073
- var LOGIN_SIZE_POOL = [[1280, 800], [1366, 768], [1440, 900], [1536, 864], [1600, 900], [1680, 1050], [1920, 1080], [1024, 768], [1152, 864], [1280, 720]];
7074
7074
  function loginEnv(rand) {
7075
- const pick = (arr) => arr[Math.floor((typeof rand === "function" ? rand() : Math.random()) * arr.length)];
7076
- const size = pick(LOGIN_SIZE_POOL);
7077
- const lang = pick(LOGIN_LANG_POOL);
7078
- const tz = pick(LOGIN_TZ_POOL);
7075
+ const tz = LOGIN_TZ_POOL[Math.floor((typeof rand === "function" ? rand() : Math.random()) * LOGIN_TZ_POOL.length)];
7079
7076
  const sysEnv = Object.assign({}, process.env, desktop.sessionEnv());
7080
- return { size, lang, sysEnv, antiEnv: Object.assign({}, sysEnv, { TZ: tz, LANG: lang }) };
7077
+ return { sysEnv, antiEnv: Object.assign({}, sysEnv, { TZ: tz }) };
7081
7078
  }
7082
7079
  function launchDiagnostics(inv, plan, picked) {
7083
7080
  const found = (inv && inv.browsers || []).map((b) => ({
@@ -7187,7 +7184,7 @@ var require_browser = __commonJS({
7187
7184
  profile = null;
7188
7185
  }
7189
7186
  }
7190
- const plan = intent === "isolated-login" ? isolatedPlan(pl, url, { inventory: inv, pick: picked, profileDir: profile, size: login.size, lang: login.lang }) : openPlan(pl, url, { inventory: inv, pick: picked });
7187
+ const plan = intent === "isolated-login" ? isolatedPlan(pl, url, { inventory: inv, pick: picked, profileDir: profile }) : openPlan(pl, url, { inventory: inv, pick: picked });
7191
7188
  run.args = plan.args;
7192
7189
  const diagnostics = launchDiagnostics(inv, plan, picked);
7193
7190
  const evidence = {
@@ -10701,11 +10698,28 @@ var require_log = __commonJS({
10701
10698
  }
10702
10699
  });
10703
10700
 
10701
+ // src/platform/contract/dsh-cli.js
10702
+ var require_dsh_cli = __commonJS({
10703
+ "src/platform/contract/dsh-cli.js"(exports2, module2) {
10704
+ "use strict";
10705
+ function withoutAutoOpen(cmd2) {
10706
+ const arr = (Array.isArray(cmd2) ? cmd2 : []).map(String);
10707
+ const webAt = arr.indexOf("web");
10708
+ if (webAt < 0 || arr.includes("--no-open") || arr.includes("--open")) return cmd2;
10709
+ const sep = arr.indexOf("--", webAt);
10710
+ if (sep < 0) return arr.concat(["--no-open"]);
10711
+ return arr.slice(0, sep).concat(["--no-open"], arr.slice(sep));
10712
+ }
10713
+ module2.exports = { withoutAutoOpen };
10714
+ }
10715
+ });
10716
+
10704
10717
  // src/app/native/command.js
10705
10718
  var require_command = __commonJS({
10706
10719
  "src/app/native/command.js"(exports2, module2) {
10707
10720
  "use strict";
10708
10721
  var fs2 = require("node:fs");
10722
+ var dshCli = require_dsh_cli();
10709
10723
  function nativeCommand(config, pluginManager) {
10710
10724
  const command = config.command || [];
10711
10725
  const [runtime, bin, ...rest] = command;
@@ -10734,7 +10748,7 @@ var require_command = __commonJS({
10734
10748
  }
10735
10749
  }
10736
10750
  if (!portSet && config.targetPort) out.push("--port", String(config.targetPort));
10737
- return out;
10751
+ return dshCli.withoutAutoOpen(out);
10738
10752
  }
10739
10753
  module2.exports = { nativeCommand };
10740
10754
  }
@@ -11223,7 +11237,7 @@ var require_signals = __commonJS({
11223
11237
  if (!cmd2) return false;
11224
11238
  const bin = d.config().command && d.config().command[1];
11225
11239
  if (typeof bin === "string" && bin && cmd2.includes(bin)) return true;
11226
- return pidlook.isDshCmdline(pid);
11240
+ return /(^|\s)web(\s|$)/.test(cmd2) && pidlook.isDshCmdline(pid);
11227
11241
  },
11228
11242
  /** 向进程组发信号(detached spawn 的子进程是组长);组信号失败退回单进程。平台层封装:
11229
11243
  * POSIX 组信号;Windows 无组语义则单进程信号,树语义由 killTree 提供。 */
@@ -21146,6 +21160,7 @@ var require_sandbox = __commonJS({
21146
21160
  "src/domains/instance/sandbox.js"(exports2, module2) {
21147
21161
  "use strict";
21148
21162
  var platform = require_os();
21163
+ var dshCli = require_dsh_cli();
21149
21164
  var path2 = require("node:path");
21150
21165
  function root(rootDir, inst) {
21151
21166
  return path2.join(rootDir, inst.id);
@@ -21183,18 +21198,10 @@ var require_sandbox = __commonJS({
21183
21198
  function defaultCommand(dshBin, inst) {
21184
21199
  return [process.execPath, dshBin, "web", "--port", String(inst.port), "--host", "127.0.0.1", "--trusted-host", "127.0.0.1", "--no-open"];
21185
21200
  }
21186
- function withoutAutoOpen(cmd2) {
21187
- const arr = (Array.isArray(cmd2) ? cmd2 : []).map(String);
21188
- const webAt = arr.indexOf("web");
21189
- if (webAt < 0 || arr.includes("--no-open") || arr.includes("--open")) return cmd2;
21190
- const sep = arr.indexOf("--", webAt);
21191
- if (sep < 0) return arr.concat(["--no-open"]);
21192
- return arr.slice(0, sep).concat(["--no-open"], arr.slice(sep));
21193
- }
21194
21201
  function effectiveCommand(rootDir, dshBin, inst) {
21195
- if (inst.domain === "sandbox" && (!inst.command || !inst.command.length)) return withoutAutoOpen(sandboxCommand(rootDir, inst));
21196
- if (inst.command && inst.command.length) return withoutAutoOpen(inst.command);
21197
- return withoutAutoOpen(defaultCommand(dshBin, inst));
21202
+ if (inst.domain === "sandbox" && (!inst.command || !inst.command.length)) return dshCli.withoutAutoOpen(sandboxCommand(rootDir, inst));
21203
+ if (inst.command && inst.command.length) return dshCli.withoutAutoOpen(inst.command);
21204
+ return dshCli.withoutAutoOpen(defaultCommand(dshBin, inst));
21198
21205
  }
21199
21206
  function unitProps(inst, alloc) {
21200
21207
  const props = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-sup/dsh-core-linux-x64",
3
- "version": "0.1.6-BETA.16",
3
+ "version": "0.1.6-BETA.18",
4
4
  "description": "DSH lifecycle guard core (Node launcher) for linux-x64 — requires Node >=18.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -1,3 +1,3 @@
1
- import{F as e,I as t,L as n,N as r,O as i,R as a,S as o,U as s,V as c,_ as l,a as u,b as d,c as f,g as p,k as m,n as h,o as g,t as _,v,x as y,y as b}from"./supervisor-DsqHrafU.js";import{i as x,t as S}from"./openExternal-CCkI5Gcp.js";import{n as C,t as w}from"./rocket-USfrjyOj.js";import{t as ee}from"./shield-check-T6r2Ozdx.js";import{c as T,f as E,o as D,s as te}from"./supervisor-B8Hi4QZf.js";import{t as O}from"./useSupervisorAction-bKiRxMdz.js";import{c as k,i as A,o as j,r as M,t as N}from"./widgets-CKp8QAOl.js";var ne=r(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),P=r(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),F=r(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=s(c(),1),L=a();function R({onRegisterActions:r}){let{snap:a}=_(),{busy:s,run:c}=O(),R=e(),[z,B]=(0,I.useState)(!1),[V,H]=(0,I.useState)(``),[U,W]=(0,I.useState)(``),[G,K]=(0,I.useState)(``),q=a.instances?.instances??[],[J,Y]=(0,I.useState)(null);(0,I.useEffect)(()=>{let e=!0;return u.envStatus().then(t=>{e&&Y(t.capabilities??null)}).catch(()=>void 0),()=>{e=!1}},[]);let X=J!==null&&J.sandboxLaunch===!1,Z=J?.sandboxEnforcement===`supervise`,Q=J==null?null:J.sandboxEnforcement===`cgroup`?`cgroup 内核硬限`:Z?`采样式软限(超限由守卫按拍数收割重启,非内核级强制)`:`无内核级限额`;(0,I.useEffect)(()=>(r?.({onAdd:()=>B(!0)}),()=>r?.(null)),[r]);let $=(e,t)=>c(e,t),re=e=>c(e,()=>S(()=>u.instanceOpenWeb(e)).then(()=>void 0));async function ie(){if(X){i.error(`当前平台不支持沙箱实例(见 /env/status 能力矩阵)`);return}let e=parseInt(U,10);if(!Number.isFinite(e)||e<=0){i.error(`请填写有效端口`);return}let t=G?G.split(/\n/).map(e=>e.trim()).filter(Boolean):[];try{let n=await u.instanceAdd({name:V.trim()||`沙箱 `+e,port:e,command:t});if(n&&n.ok===!1){i.error(n.error||`添加失败`);return}i.success(`已添加实例`),B(!1),H(``),W(``),K(``),h.refresh()}catch(e){i.error(String(e))}}async function ae(e){await c(e.id,async()=>{let t=await u.instanceCheckUpdate(e.id);t.updateAvailable?(i.success(`发现新版 `+t.latest+`,可点「更新」升级`),se(t=>new Map(t).set(e.id,!0))):t.latest?i.info(`已是最新 `+t.latest):i.error(t.error||`版本检测失败`)})}let[oe,se]=(0,I.useState)(new Map);async function ce(e){await R({title:`升级该沙箱实例的 DSH 到最新版?`,description:`实例会短暂重启,进行中的请求中断。`,confirmText:`升级`})&&await c(e.id,()=>u.instanceUpgrade(e.id),{success:`升级已开始…`})}async function le(e){await R({title:`删除实例「`+e.name+`」?`,description:`将彻底删除该沙箱实例(含配置与运行时数据)。此操作不可恢复。`,confirmText:`删除实例`,tone:`destructive`})&&await c(e.id,async()=>{let t=await u.instanceRemove(e.id);t&&t.ok!==!1&&t.dataPreserved===!0?i.warning(`实例已移除,但因其单元仍在运行,数据目录已保留(未删除)——请先停止实例再删数据`):t&&t.ok===!1&&i.error(t.error||`删除失败`),h.refresh()})}let ue=({it:e})=>{let r=e.state?.running??!1,i=e.state?.lifecyclePhase,a=te(i,r),o=e.updateJob,c=o?.state===`running`,l=e.state?.allocation?.memoryMax||`—`,d=e.state?.allocation?.cpuQuota||`—`,p=e.state?.usage,h=p&&typeof p.memMb==`number`?p.memMb:null,g=p&&typeof p.cpuPct==`number`?p.cpuPct:null,_=s===e.id;return(0,L.jsxs)(N,{className:`overflow-visible`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 @min-[720px]:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-border px-6 py-5 md:border-b-0 md:border-r`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,L.jsx)(`strong`,{className:`truncate text-lg font-semibold tracking-[-0.01em] text-foreground`,children:e.name}),e.version?(0,L.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:[`v`,e.version]}):null]}),oe.get(e.id)?(0,L.jsxs)(t,{className:`text-primary-foreground`,onClick:()=>void ce(e),size:`chip`,children:[(0,L.jsx)(P,{className:`size-3`}),`更新`]}):(0,L.jsxs)(t,{className:`bg-primary/10 text-primary hover:bg-primary/15`,disabled:_||c,onClick:()=>void ae(e),size:`chip`,variant:`ghost`,children:[(0,L.jsx)(P,{className:n(`size-3`,_&&`animate-spin`)}),`检测更新`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(k,{tone:a.tone,ping:a.tone===`ok`}),(0,L.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:a.label})]}),c?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(f,{className:`size-3`}),`正在升级 DeepSeek Harness(`,o?.step||``,`)…`]}):null,e.state?.installing?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(f,{className:`size-3`}),`正在安装…`]}):null,i===`FAILED`?(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,children:[(0,L.jsx)(m,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.state?.lastError||`失败`})]}):null]}),(0,L.jsx)(`div`,{className:`flex items-center bg-[image:var(--panel-accent-gradient)] px-6 py-5`,children:(0,L.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4`,children:[(0,L.jsx)(A,{icon:(0,L.jsx)(E,{className:`size-4`}),label:`端口`,value:String(e.port),mono:!0}),(0,L.jsx)(A,{icon:(0,L.jsx)(F,{className:`size-4`}),label:`PID`,value:e.state?.pid?String(e.state.pid):`—`,mono:!0}),(0,L.jsx)(A,{icon:(0,L.jsx)(P,{className:`size-4`}),label:`重启次数`,value:String(e.state?.restartCount??0),mono:!0}),(0,L.jsx)(A,{icon:(0,L.jsx)(m,{className:`size-4`}),label:`最近故障`,value:e.state?.lastFailure?D(e.state.lastFailure):`无`,warn:!!e.state?.lastFailure})]})})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-border/60 px-6 py-3`,children:[(0,L.jsxs)(`span`,{className:`hidden min-w-0 items-center lg:inline-flex gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(M,{domain:`sandbox`}),(0,L.jsx)(j,{tone:e.remoteMode&&e.remoteMode!==`off`?`boot`:`off`,children:e.remoteMode===`wan`?`远程·公网`:e.remoteMode===`lan`?`远程·局域网`:`远程关闭`}),(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,title:`配额由守卫按机器预算与活跃实例数动态推导`+(Q?`;执行档位:`+Q:``),children:[`配额 内存 `,l,` · CPU `,d,Z?`(软限)`:``]}),h===null&&g===null?null:(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,title:`监督拍实测值(最近一次采样;停止或未采到不显示)`,children:[`占用 `,h===null?`—`:`${h}MB`,g===null?``:` · CPU ${Math.round(g)}%`]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsxs)(t,{disabled:!r,onClick:()=>void re(e.id),size:`sm`,title:`打开 DSH Web(自动带认证连接)`,variant:`outline`,className:`hidden md:inline-flex`,children:[(0,L.jsx)(x,{className:`size-4`}),`DSH Web`]}),(0,L.jsx)(t,{disabled:c,onClick:()=>void $(e.id,()=>r?u.instanceStop(e.id):u.instanceStart(e.id)),size:`sm`,variant:`outline`,children:r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`size-4 text-status-error`}),`停止实例`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(w,{className:`size-4 text-primary`}),`启动实例`]})}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,L.jsxs)(t,{disabled:_,onClick:()=>void $(e.id,()=>u.instanceUpdate(e.id,{guardian:!e.guardian})),size:`sm`,variant:`outline`,children:[(0,L.jsx)(ee,{className:n(`size-4`,e.guardian?`text-status-ok`:`text-muted-foreground`)}),e.guardian?`停止守护`:`启动守护`]}),(0,L.jsxs)(t,{className:`hidden h-[30px] md:inline-flex`,disabled:_,onClick:()=>void le(e),size:`sm`,variant:`destructive`,children:[(0,L.jsx)(T,{className:`size-4`}),`删除`]})]})]})]})};return(0,L.jsxs)(`div`,{className:`grid content-start gap-4`,children:[X?(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(m,{className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,L.jsxs)(`span`,{children:[`当前平台(`,J?.platform||`未知`,`)不支持沙箱实例(能力矩阵见 /env/status 的 capabilities.sandboxLaunch;限额执行档位见 capabilities.sandboxEnforcement)。 原生 DSH 主实例不受影响。`]})]}):null,q.length?(0,L.jsx)(`div`,{className:`grid gap-3`,children:q.map(e=>(0,L.jsx)(ue,{it:e},e.id))}):(0,L.jsx)(`div`,{className:`grid min-h-[220px] place-items-center rounded-lg border border-dashed border-border text-center`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ne,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`尚未添加沙箱实例`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:X?`当前平台不支持沙箱实例(见上方说明)`:`点击顶部「添加实例」创建沙箱`})]})}),(0,L.jsx)(v,{open:z,onOpenChange:B,children:(0,L.jsxs)(b,{className:`max-w-[440px]`,children:[(0,L.jsx)(y,{children:(0,L.jsx)(o,{children:`添加 DSH 实例`})}),(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(p,{children:`实例名称`}),(0,L.jsx)(l,{placeholder:`如 沙箱二开`,value:V,onChange:e=>H(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(p,{children:`监听端口`}),(0,L.jsx)(l,{inputMode:`numeric`,placeholder:`如 3082`,value:U,onChange:e=>W(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(p,{children:`启动命令(每项一参数,可留空用默认)`}),(0,L.jsx)(g,{className:`min-h-[72px] font-mono text-sm`,placeholder:`node
1
+ import{F as e,I as t,L as n,N as r,O as i,R as a,S as o,U as s,V as c,_ as l,a as u,b as d,c as f,g as p,k as m,n as h,o as g,t as _,v,x as y,y as b}from"./supervisor-DsqHrafU.js";import{n as x,o as S}from"./openExternal-EAMqvnZq.js";import{n as C,t as w}from"./rocket-USfrjyOj.js";import{t as ee}from"./shield-check-T6r2Ozdx.js";import{c as T,f as E,o as D,s as te}from"./supervisor-DUOKbKN7.js";import{t as O}from"./useSupervisorAction-bKiRxMdz.js";import{c as k,i as A,o as j,r as M,t as N}from"./widgets-CKp8QAOl.js";var ne=r(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),P=r(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),F=r(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=s(c(),1),L=a();function R({onRegisterActions:r}){let{snap:a}=_(),{busy:s,run:c}=O(),R=e(),[z,B]=(0,I.useState)(!1),[V,H]=(0,I.useState)(``),[U,W]=(0,I.useState)(``),[G,K]=(0,I.useState)(``),q=a.instances?.instances??[],[J,Y]=(0,I.useState)(null);(0,I.useEffect)(()=>{let e=!0;return u.envStatus().then(t=>{e&&Y(t.capabilities??null)}).catch(()=>void 0),()=>{e=!1}},[]);let X=J!==null&&J.sandboxLaunch===!1,Z=J?.sandboxEnforcement===`supervise`,Q=J==null?null:J.sandboxEnforcement===`cgroup`?`cgroup 内核硬限`:Z?`采样式软限(超限由守卫按拍数收割重启,非内核级强制)`:`无内核级限额`;(0,I.useEffect)(()=>(r?.({onAdd:()=>B(!0)}),()=>r?.(null)),[r]);let $=(e,t)=>c(e,t),re=e=>c(e,()=>x(()=>u.instanceOpenWeb(e)).then(()=>void 0));async function ie(){if(X){i.error(`当前平台不支持沙箱实例(见 /env/status 能力矩阵)`);return}let e=parseInt(U,10);if(!Number.isFinite(e)||e<=0){i.error(`请填写有效端口`);return}let t=G?G.split(/\n/).map(e=>e.trim()).filter(Boolean):[];try{let n=await u.instanceAdd({name:V.trim()||`沙箱 `+e,port:e,command:t});if(n&&n.ok===!1){i.error(n.error||`添加失败`);return}i.success(`已添加实例`),B(!1),H(``),W(``),K(``),h.refresh()}catch(e){i.error(String(e))}}async function ae(e){await c(e.id,async()=>{let t=await u.instanceCheckUpdate(e.id);t.updateAvailable?(i.success(`发现新版 `+t.latest+`,可点「更新」升级`),se(t=>new Map(t).set(e.id,!0))):t.latest?i.info(`已是最新 `+t.latest):i.error(t.error||`版本检测失败`)})}let[oe,se]=(0,I.useState)(new Map);async function ce(e){await R({title:`升级该沙箱实例的 DSH 到最新版?`,description:`实例会短暂重启,进行中的请求中断。`,confirmText:`升级`})&&await c(e.id,()=>u.instanceUpgrade(e.id),{success:`升级已开始…`})}async function le(e){await R({title:`删除实例「`+e.name+`」?`,description:`将彻底删除该沙箱实例(含配置与运行时数据)。此操作不可恢复。`,confirmText:`删除实例`,tone:`destructive`})&&await c(e.id,async()=>{let t=await u.instanceRemove(e.id);t&&t.ok!==!1&&t.dataPreserved===!0?i.warning(`实例已移除,但因其单元仍在运行,数据目录已保留(未删除)——请先停止实例再删数据`):t&&t.ok===!1&&i.error(t.error||`删除失败`),h.refresh()})}let ue=({it:e})=>{let r=e.state?.running??!1,i=e.state?.lifecyclePhase,a=te(i,r),o=e.updateJob,c=o?.state===`running`,l=e.state?.allocation?.memoryMax||`—`,d=e.state?.allocation?.cpuQuota||`—`,p=e.state?.usage,h=p&&typeof p.memMb==`number`?p.memMb:null,g=p&&typeof p.cpuPct==`number`?p.cpuPct:null,_=s===e.id;return(0,L.jsxs)(N,{className:`overflow-visible`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 @min-[720px]:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-border px-6 py-5 md:border-b-0 md:border-r`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,L.jsx)(`strong`,{className:`truncate text-lg font-semibold tracking-[-0.01em] text-foreground`,children:e.name}),e.version?(0,L.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:[`v`,e.version]}):null]}),oe.get(e.id)?(0,L.jsxs)(t,{className:`text-primary-foreground`,onClick:()=>void ce(e),size:`chip`,children:[(0,L.jsx)(P,{className:`size-3`}),`更新`]}):(0,L.jsxs)(t,{className:`bg-primary/10 text-primary hover:bg-primary/15`,disabled:_||c,onClick:()=>void ae(e),size:`chip`,variant:`ghost`,children:[(0,L.jsx)(P,{className:n(`size-3`,_&&`animate-spin`)}),`检测更新`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(k,{tone:a.tone,ping:a.tone===`ok`}),(0,L.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:a.label})]}),c?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(f,{className:`size-3`}),`正在升级 DeepSeek Harness(`,o?.step||``,`)…`]}):null,e.state?.installing?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(f,{className:`size-3`}),`正在安装…`]}):null,i===`FAILED`?(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,children:[(0,L.jsx)(m,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.state?.lastError||`失败`})]}):null]}),(0,L.jsx)(`div`,{className:`flex items-center bg-[image:var(--panel-accent-gradient)] px-6 py-5`,children:(0,L.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4`,children:[(0,L.jsx)(A,{icon:(0,L.jsx)(E,{className:`size-4`}),label:`端口`,value:String(e.port),mono:!0}),(0,L.jsx)(A,{icon:(0,L.jsx)(F,{className:`size-4`}),label:`PID`,value:e.state?.pid?String(e.state.pid):`—`,mono:!0}),(0,L.jsx)(A,{icon:(0,L.jsx)(P,{className:`size-4`}),label:`重启次数`,value:String(e.state?.restartCount??0),mono:!0}),(0,L.jsx)(A,{icon:(0,L.jsx)(m,{className:`size-4`}),label:`最近故障`,value:e.state?.lastFailure?D(e.state.lastFailure):`无`,warn:!!e.state?.lastFailure})]})})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-border/60 px-6 py-3`,children:[(0,L.jsxs)(`span`,{className:`hidden min-w-0 items-center lg:inline-flex gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(M,{domain:`sandbox`}),(0,L.jsx)(j,{tone:e.remoteMode&&e.remoteMode!==`off`?`boot`:`off`,children:e.remoteMode===`wan`?`远程·公网`:e.remoteMode===`lan`?`远程·局域网`:`远程关闭`}),(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,title:`配额由守卫按机器预算与活跃实例数动态推导`+(Q?`;执行档位:`+Q:``),children:[`配额 内存 `,l,` · CPU `,d,Z?`(软限)`:``]}),h===null&&g===null?null:(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,title:`监督拍实测值(最近一次采样;停止或未采到不显示)`,children:[`占用 `,h===null?`—`:`${h}MB`,g===null?``:` · CPU ${Math.round(g)}%`]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsxs)(t,{disabled:!r,onClick:()=>void re(e.id),size:`sm`,title:`打开 DSH Web(自动带认证连接)`,variant:`outline`,className:`hidden md:inline-flex`,children:[(0,L.jsx)(S,{className:`size-4`}),`DSH Web`]}),(0,L.jsx)(t,{disabled:c,onClick:()=>void $(e.id,()=>r?u.instanceStop(e.id):u.instanceStart(e.id)),size:`sm`,variant:`outline`,children:r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`size-4 text-status-error`}),`停止实例`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(w,{className:`size-4 text-primary`}),`启动实例`]})}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,L.jsxs)(t,{disabled:_,onClick:()=>void $(e.id,()=>u.instanceUpdate(e.id,{guardian:!e.guardian})),size:`sm`,variant:`outline`,children:[(0,L.jsx)(ee,{className:n(`size-4`,e.guardian?`text-status-ok`:`text-muted-foreground`)}),e.guardian?`停止守护`:`启动守护`]}),(0,L.jsxs)(t,{className:`hidden h-[30px] md:inline-flex`,disabled:_,onClick:()=>void le(e),size:`sm`,variant:`destructive`,children:[(0,L.jsx)(T,{className:`size-4`}),`删除`]})]})]})]})};return(0,L.jsxs)(`div`,{className:`grid content-start gap-4`,children:[X?(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(m,{className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,L.jsxs)(`span`,{children:[`当前平台(`,J?.platform||`未知`,`)不支持沙箱实例(能力矩阵见 /env/status 的 capabilities.sandboxLaunch;限额执行档位见 capabilities.sandboxEnforcement)。 原生 DSH 主实例不受影响。`]})]}):null,q.length?(0,L.jsx)(`div`,{className:`grid gap-3`,children:q.map(e=>(0,L.jsx)(ue,{it:e},e.id))}):(0,L.jsx)(`div`,{className:`grid min-h-[220px] place-items-center rounded-lg border border-dashed border-border text-center`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ne,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`尚未添加沙箱实例`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:X?`当前平台不支持沙箱实例(见上方说明)`:`点击顶部「添加实例」创建沙箱`})]})}),(0,L.jsx)(v,{open:z,onOpenChange:B,children:(0,L.jsxs)(b,{className:`max-w-[440px]`,children:[(0,L.jsx)(y,{children:(0,L.jsx)(o,{children:`添加 DSH 实例`})}),(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(p,{children:`实例名称`}),(0,L.jsx)(l,{placeholder:`如 沙箱二开`,value:V,onChange:e=>H(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(p,{children:`监听端口`}),(0,L.jsx)(l,{inputMode:`numeric`,placeholder:`如 3082`,value:U,onChange:e=>W(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(p,{children:`启动命令(每项一参数,可留空用默认)`}),(0,L.jsx)(g,{className:`min-h-[72px] font-mono text-sm`,placeholder:`node
2
2
  /usr/local/bin/dsh
3
3
  web`,value:G,onChange:e=>K(e.target.value)})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`内存/CPU 配额无需填写:启动时由守卫按机器预算与活跃实例数自动推导,实例增减后动态重分配。`,Q?` 执行档位:${Q}。`:``]})]}),(0,L.jsxs)(d,{children:[(0,L.jsx)(t,{onClick:()=>B(!1),variant:`outline`,children:`取消`}),(0,L.jsx)(t,{onClick:()=>void ie(),children:`添加`})]})]})})]})}export{R as InstancesPage};
@@ -1,4 +1,4 @@
1
- import{F as e,H as t,I as n,L as r,N as i,O as a,R as o,S as s,U as c,V as l,_ as u,a as d,b as f,g as p,s as m,t as h,v as g,x as _,y as v}from"./supervisor-DsqHrafU.js";import{i as y,n as b,t as ee}from"./openExternal-CCkI5Gcp.js";import{t as x}from"./useSupervisorAction-bKiRxMdz.js";import{n as S,o as C,r as w,t as T}from"./widgets-CKp8QAOl.js";var te=i(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ne=i(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),re=i(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ie=i(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),ae=i(`landmark`,[[`path`,{d:`M10 18v-7`,key:`wt116b`}],[`path`,{d:`M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z`,key:`yxxwt6`}],[`path`,{d:`M14 18v-7`,key:`vav6t3`}],[`path`,{d:`M18 18v-7`,key:`aexdmj`}],[`path`,{d:`M3 22h18`,key:`8prr45`}],[`path`,{d:`M6 18v-7`,key:`1ivflk`}]]),oe=i(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),se=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),E=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),D=t(((e,t)=>{var n=E();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),O=t(((e,t)=>{t.exports=D()()})),k=c(l(),1),A=c(O(),1),j=function(e,t){let n=e,r=N[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=F.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=F.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=F.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=F.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=F.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=F.getErrorCorrectPolynomial(l),d=L(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=R.getRSBlocks(e,t),i=z();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),F.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=B(e);break;case`Alphanumeric`:n=V(e);break;case`Byte`:n=H(e);break;case`Kanji`:n=U(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=R.getRSBlocks(e,r),n=z();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),F.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return J(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`&lt;`;break;case`>`:t+=`&gt;`;break;case`&`:t+=`&amp;`;break;case`"`:t+=`&quot;`;break;default:t+=r}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
1
+ import{F as e,H as t,I as n,L as r,N as i,O as a,R as o,S as s,U as c,V as l,_ as u,a as d,b as f,g as p,s as m,t as h,v as g,x as _,y as v}from"./supervisor-DsqHrafU.js";import{n as y,o as b,r as ee}from"./openExternal-EAMqvnZq.js";import{t as x}from"./useSupervisorAction-bKiRxMdz.js";import{n as S,o as C,r as w,t as T}from"./widgets-CKp8QAOl.js";var te=i(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ne=i(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),re=i(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ie=i(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),ae=i(`landmark`,[[`path`,{d:`M10 18v-7`,key:`wt116b`}],[`path`,{d:`M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z`,key:`yxxwt6`}],[`path`,{d:`M14 18v-7`,key:`vav6t3`}],[`path`,{d:`M18 18v-7`,key:`aexdmj`}],[`path`,{d:`M3 22h18`,key:`8prr45`}],[`path`,{d:`M6 18v-7`,key:`1ivflk`}]]),oe=i(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),se=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),E=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),D=t(((e,t)=>{var n=E();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),O=t(((e,t)=>{t.exports=D()()})),k=c(l(),1),A=c(O(),1),j=function(e,t){let n=e,r=N[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=F.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=F.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=F.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=F.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=F.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=F.getErrorCorrectPolynomial(l),d=L(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=R.getRSBlocks(e,t),i=z();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),F.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=B(e);break;case`Alphanumeric`:n=V(e);break;case`Byte`:n=H(e);break;case`Kanji`:n=U(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=R.getRSBlocks(e,r),n=z();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),F.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return J(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`&lt;`;break;case`>`:t+=`&gt;`;break;case`&`:t+=`&amp;`;break;case`"`:t+=`&quot;`;break;default:t+=r}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
2
2
  `}return t%2&&e>0?f.substring(0,f.length-t-1)+Array(t+1).join(`▀`):f.substring(0,f.length-1)};return c.createASCII=function(e,t){if(e||=1,e<2)return b(t);--e,t=t===void 0?e*2:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,l,u=Array(e+1).join(`██`),d=Array(e+1).join(` `),f=``,p=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),p=``,o=0;o<n;o+=1)l=1,r<=o&&o<i&&r<=a&&a<i&&c.isDark(s,Math.floor((o-r)/e))&&(l=0),p+=l?u:d;for(s=0;s<e;s+=1)f+=p+`
3
- `}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};j.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},j.createStringToBytes=function(e,t){let n=function(){let n=K(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var M={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},N={L:1,M:0,Q:3,H:2},P={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},F=function(){let e=[[],[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]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case P.PATTERN000:return function(e,t){return(e+t)%2==0};case P.PATTERN001:return function(e,t){return e%2==0};case P.PATTERN010:return function(e,t){return t%3==0};case P.PATTERN011:return function(e,t){return(e+t)%3==0};case P.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case P.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case P.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case P.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=L([1],0);for(let n=0;n<e;n+=1)t=t.multiply(L([1,I.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case M.MODE_NUMBER:return 10;case M.MODE_ALPHA_NUM:return 9;case M.MODE_8BIT_BYTE:return 8;case M.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case M.MODE_NUMBER:return 12;case M.MODE_ALPHA_NUM:return 11;case M.MODE_8BIT_BYTE:return 16;case M.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case M.MODE_NUMBER:return 14;case M.MODE_ALPHA_NUM:return 13;case M.MODE_8BIT_BYTE:return 16;case M.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),I=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),L=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=I.gexp(I.glog(r.getAt(n))+I.glog(e.getAt(i)));return L(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=I.glog(r.getAt(0))-I.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=I.gexp(I.glog(e.getAt(r))+t);return L(n,0).mod(e)},r},R=function(){let e=[[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,7,37,13],[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]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case N.L:return e[(t-1)*4+0];case N.M:return e[(t-1)*4+1];case N.Q:return e[(t-1)*4+2];case N.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),z=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},B=function(e){let t=M.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},V=function(e){let t=M.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},H=function(e){let t=M.MODE_8BIT_BYTE,n=j.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},U=function(e){let t=M.MODE_KANJI,n=j.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},W=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},G=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},K=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},q=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=W(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},J=function(e,t,n){let r=q(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=W();r.write(i);let a=G(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};j.stringToBytes;function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(null,arguments)}function X(e,t){if(e==null)return{};var n,r,i=ce(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ce(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var le=[`bgColor`,`bgD`,`fgD`,`fgColor`,`size`,`title`,`viewBoxSize`,`xmlns`],ue={bgColor:A.default.oneOfType([A.default.object,A.default.string]).isRequired,bgD:A.default.string.isRequired,fgColor:A.default.oneOfType([A.default.object,A.default.string]).isRequired,fgD:A.default.string.isRequired,size:A.default.number.isRequired,title:A.default.string,viewBoxSize:A.default.number.isRequired,xmlns:A.default.string},Z=(0,k.forwardRef)(function(e,t){var n=e.bgColor,r=e.bgD,i=e.fgD,a=e.fgColor,o=e.size,s=e.title,c=e.viewBoxSize,l=e.xmlns,u=l===void 0?`http://www.w3.org/2000/svg`:l,d=X(e,le);return k.createElement(`svg`,Y({},d,{height:o,ref:t,viewBox:`0 0 ${c} ${c}`,width:o,xmlns:u}),s?k.createElement(`title`,null,s):null,k.createElement(`path`,{d:r,fill:n}),k.createElement(`path`,{d:i,fill:a}))});Z.displayName=`QRCodeSvg`,Z.propTypes=ue;var de=[`bgColor`,`fgColor`,`level`,`size`,`value`];j.stringToBytes=function(e){return Array.from(new TextEncoder().encode(e))};var fe={bgColor:A.default.oneOfType([A.default.object,A.default.string]),fgColor:A.default.oneOfType([A.default.object,A.default.string]),level:A.default.string,size:A.default.number,value:A.default.string.isRequired},Q=(0,k.forwardRef)(function(e,t){var n=e.bgColor,r=n===void 0?`#FFFFFF`:n,i=e.fgColor,a=i===void 0?`#000000`:i,o=e.level,s=o===void 0?`L`:o,c=e.size,l=c===void 0?256:c,u=e.value,d=X(e,de),f=j(0,s);f.addData(u),f.make();var p=f.getModuleCount(),m=Array.from({length:p},function(e,t){return Array.from({length:p},function(e,n){return f.isDark(t,n)})});return k.createElement(Z,Y({},d,{bgColor:r,bgD:m.map(function(e,t){return e.map(function(e,n){return e?``:`M ${n} ${t} l 1 0 0 1 -1 0 Z`}).join(` `)}).join(` `),fgColor:a,fgD:m.map(function(e,t){return e.map(function(e,n){return e?`M ${n} ${t} l 1 0 0 1 -1 0 Z`:``}).join(` `)}).join(` `),ref:t,size:l,viewBoxSize:p}))});Q.displayName=`QRCode`,Q.propTypes=fe;var $=o(),pe=e=>({mode:e,ready:!1,accessUrl:null,reasons:[`远程服务未就绪`]});function me(){let{snap:t}=h(),{busy:i,run:o}=x(),c=[...t.instances?.native?[t.instances.native]:[],...t.instances?.instances??[]],l=t.lan?.items??[],E=t.frp,[D,O]=(0,k.useState)(``),[A,j]=(0,k.useState)(`7000`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(``),[B,V]=(0,k.useState)(!1),H=e();(0,k.useEffect)(()=>{!E||P||(O(E.settings.serverAddr||``),j(String(E.settings.serverPort||7e3)),F(!0))},[E,P]);function U(){let e={serverAddr:D,serverPort:parseInt(A,10)||7e3},t=M.trim();return t&&(e.authToken=t),e}async function W(e,t,n){let r=!1,i=await o(e.id,()=>d.remoteSetMode(e.id,t).then(e=>(r=e?.tokenAutoAllocated===!0,e)),{success:n});return i&&r&&a.info(`已自动生成访问令牌,点钥匙按钮可查看或修改`),i}async function G(e){await H({title:`开启远程控制?`,description:`「`+(e.name||e.id)+`」将开启局域网反向代理,同网段设备可访问该实例(无访问令牌时自动生成一个,可在钥匙按钮处查看)。`,confirmText:`开启远程控制`})&&await W(e,`lan`,`已开启远程控制(局域网)`)}async function K(e){await H({title:`切换到公网访问?`,description:`「`+(e.name||e.id)+`」的访问端口将映射到公网(frps),互联网上任何人都可尝试触达(访问令牌是硬性前置,缺失时自动生成)。`,confirmText:`切换到公网`})&&await W(e,`wan`,`已切换到公网访问`)}function q(e,t){z(t??``),V(!1),L({id:e.id,name:e.name,current:t})}async function J(){let e=I;if(!e)return;let t=R.trim();if(!t){a.error(`令牌不能为空`);return}if(t.length<8){a.error(`远程访问令牌至少 8 位(公网暴露可被暴力枚举)`);return}L(null),(e.current===null||e.current!==t)&&await o(e.id,()=>d.remoteSetToken(e.id,t),{success:`访问令牌已设置`})}async function Y(){await o(`frp-save`,()=>d.remoteFrpServer(U()),{success:`已保存 FRP 配置`})}return(0,$.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,$.jsxs)(`div`,{className:`grid items-start gap-4 @min-[900px]:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,$.jsxs)(T,{children:[(0,$.jsx)(S,{title:`远程控制`,subtitle:`为本地 DSH 实例开启远程访问:局域网直连或经 FRP 公网(需实例运行中)`}),(0,$.jsx)(`div`,{className:`grid`,children:c.length?c.map(e=>{let t=e.state?.running??!1,a=l.find(t=>t.dshPort===e.port),o=e.remoteMode??`off`,s=o===`off`?null:a?.remote??pe(o),c=s?.accessUrl??null,u=typeof e.remoteToken==`string`&&e.remoteToken.trim()?e.remoteToken.trim():null,d=s?.ready&&c?u?c+`?token=`+encodeURIComponent(u):c:null,f=u!==null||!!a?.tokenSet,p=o===`off`?(0,$.jsx)(C,{tone:`off`,children:`远程关闭`}):s?.ready?(0,$.jsx)(C,{tone:o===`wan`?`boot`:`ok`,children:o===`wan`?`公网就绪`:`局域网就绪`}):(0,$.jsx)(`span`,{title:(s?.reasons??[]).join(`;`),children:(0,$.jsx)(C,{tone:`off`,children:`远程停止`})});return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-stretch gap-4 border-b border-border/60 px-5 py-4 last:border-b-0`,children:[d?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center rounded-lg border border-border bg-white p-1.5`,title:u?`扫码访问该实例远程地址(已带访问令牌,一次出示后凭 Cookie)`:`扫码访问该实例远程地址`,children:(0,$.jsx)(Q,{value:d,size:88})}):(0,$.jsx)(`div`,{className:`grid size-[96px] shrink-0 place-items-center rounded-lg border border-dashed border-border/70 text-center text-[11px] leading-tight text-muted-foreground/60`,children:t?o===`off`?`开启远程后生成二维码`:`远程就绪后生成二维码`:`启动后可用`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`pt-2.5 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(w,{domain:e.domain}),(0,$.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:e.name}),p]}),(0,$.jsxs)(`div`,{className:`mt-auto grid content-end gap-1.5 pb-1`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`端口 `,e.port,o!==`off`&&a?.wanPort?` · 访问端口 `+a.wanPort+(o===`wan`?`(公网同号)`:``):``]}),c?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void ee(()=>b(c)),className:`inline-flex max-w-full items-center gap-1 truncate text-xs text-primary hover:underline`,title:u?`令牌绝不进浏览器启动参数,故直接打开需自行附加 ?token=;扫码可直达`:`在系统浏览器中打开该地址`,children:[(0,$.jsx)(y,{className:`size-3 shrink-0`}),c]}):!t||o===`off`?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:t?`远程未开启`:`实例未运行,启动后可开启远程`}):null,s&&!s.ready?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:(s.reasons??[]).slice(0,2).join(`;`)||`等待代理分配访问地址…`}):null]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-end justify-center gap-2`,children:[(0,$.jsxs)(`div`,{className:r(`flex items-center gap-2`,!t&&`pointer-events-none opacity-50`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`远程控制`}),(0,$.jsx)(m,{checked:o!==`off`,disabled:!t||i===e.id,onCheckedChange:t=>{if(!t){W(e,`off`,`已关闭远程控制`);return}G(e)}})]}),o!==`off`&&(0,$.jsxs)(`div`,{className:r(`flex items-center gap-1`,(!t||i===e.id)&&`pointer-events-none opacity-50`),children:[(0,$.jsxs)(n,{className:`h-7 px-2 text-xs`,size:`chip`,variant:o===`lan`?`default`:`outline`,title:`局域网反向代理访问(同网段)`,onClick:()=>{o!==`lan`&&W(e,`lan`,`已切换到局域网访问`)},children:[(0,$.jsx)(ae,{className:`size-3.5`}),`局域网`]}),(0,$.jsxs)(n,{className:`h-7 px-2 text-xs`,size:`chip`,variant:o===`wan`?`default`:`outline`,title:E?.settings?.serverAddr?`经 FRP 暴露到公网(需访问令牌)`:`需先在右侧配置 frps 服务器地址`,onClick:()=>{o!==`wan`&&K(e)},children:[(0,$.jsx)(re,{className:`size-3.5`}),`公网`]})]}),(0,$.jsx)(n,{className:`h-7 px-1.5`,disabled:i===e.id,onClick:()=>void q(e,u),size:`chip`,title:f?`访问令牌已设置(点击查看或修改)`:`未设访问令牌:局域网侧同网段可直接访问,公网模式会被安全闸拒绝,点击设置`,variant:`outline`,children:(0,$.jsx)(ie,{className:r(`size-3.5`,f?`text-status-ok`:`text-amber-500`)})})]})]},e.id)}):(0,$.jsx)(`div`,{className:`px-5 py-8 text-center text-sm text-muted-foreground`,children:`暂无实例(在「实例管理」添加后将出现在这里)`})})]}),(0,$.jsxs)(T,{children:[(0,$.jsx)(S,{title:`公网访问(FRP 内网穿透)`,subtitle:`存在「公网」模式的实例时 frpc 自动常驻并建立隧道`,actions:(0,$.jsx)(C,{tone:E?.running?`ok`:E?.installed?`warn`:`off`,children:E?.running?`frpc 运行中`:E?.installed?`已安装 · 未运行`:`未安装`})}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,$.jsx)(p,{children:`frps 地址`}),(0,$.jsx)(u,{placeholder:`如 1.2.3.4`,value:D,onChange:e=>O(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,$.jsx)(p,{children:`frps 端口`}),(0,$.jsx)(u,{inputMode:`numeric`,placeholder:`7000`,value:A,onChange:e=>j(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,$.jsx)(p,{children:`auth token`}),(0,$.jsx)(u,{type:`password`,autoComplete:`new-password`,placeholder:E?.settings?.authTokenSet?`已设置 · 留空不修改,输入即轮换`:`frps 的 auth.token`,value:M,onChange:e=>N(e.target.value)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pb-4`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[E?.installed?``:`需安装 frpc`,(E?.instancesExposed?.length??0)>0?` · 公网实例 `+E?.instancesExposed?.length+` 个`:` · 无公网模式实例`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(n,{disabled:i===`frp-inst`,onClick:()=>void o(`frp-inst`,()=>d.remoteFrpInstall(),{success:`frpc 安装完成`}),variant:`outline`,children:[(0,$.jsx)(se,{className:`size-4`}),`安装 frpc`]}),(0,$.jsxs)(n,{disabled:i===`frp-save`,onClick:()=>void Y(),children:[(0,$.jsx)(oe,{className:`size-4`}),`保存并应用`]})]})]}),E?.logTail?.length?(0,$.jsx)(`pre`,{className:`mx-5 mb-4 max-h-[160px] overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/70 p-3 font-mono text-xs leading-relaxed text-muted-foreground`,children:E.logTail.join(`
3
+ `}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};j.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},j.createStringToBytes=function(e,t){let n=function(){let n=K(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var M={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},N={L:1,M:0,Q:3,H:2},P={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},F=function(){let e=[[],[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]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case P.PATTERN000:return function(e,t){return(e+t)%2==0};case P.PATTERN001:return function(e,t){return e%2==0};case P.PATTERN010:return function(e,t){return t%3==0};case P.PATTERN011:return function(e,t){return(e+t)%3==0};case P.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case P.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case P.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case P.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=L([1],0);for(let n=0;n<e;n+=1)t=t.multiply(L([1,I.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case M.MODE_NUMBER:return 10;case M.MODE_ALPHA_NUM:return 9;case M.MODE_8BIT_BYTE:return 8;case M.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case M.MODE_NUMBER:return 12;case M.MODE_ALPHA_NUM:return 11;case M.MODE_8BIT_BYTE:return 16;case M.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case M.MODE_NUMBER:return 14;case M.MODE_ALPHA_NUM:return 13;case M.MODE_8BIT_BYTE:return 16;case M.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),I=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),L=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=I.gexp(I.glog(r.getAt(n))+I.glog(e.getAt(i)));return L(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=I.glog(r.getAt(0))-I.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=I.gexp(I.glog(e.getAt(r))+t);return L(n,0).mod(e)},r},R=function(){let e=[[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,7,37,13],[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]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case N.L:return e[(t-1)*4+0];case N.M:return e[(t-1)*4+1];case N.Q:return e[(t-1)*4+2];case N.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),z=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},B=function(e){let t=M.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},V=function(e){let t=M.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},H=function(e){let t=M.MODE_8BIT_BYTE,n=j.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},U=function(e){let t=M.MODE_KANJI,n=j.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},W=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},G=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},K=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},q=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=W(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},J=function(e,t,n){let r=q(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=W();r.write(i);let a=G(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};j.stringToBytes;function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(null,arguments)}function X(e,t){if(e==null)return{};var n,r,i=ce(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ce(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var le=[`bgColor`,`bgD`,`fgD`,`fgColor`,`size`,`title`,`viewBoxSize`,`xmlns`],ue={bgColor:A.default.oneOfType([A.default.object,A.default.string]).isRequired,bgD:A.default.string.isRequired,fgColor:A.default.oneOfType([A.default.object,A.default.string]).isRequired,fgD:A.default.string.isRequired,size:A.default.number.isRequired,title:A.default.string,viewBoxSize:A.default.number.isRequired,xmlns:A.default.string},Z=(0,k.forwardRef)(function(e,t){var n=e.bgColor,r=e.bgD,i=e.fgD,a=e.fgColor,o=e.size,s=e.title,c=e.viewBoxSize,l=e.xmlns,u=l===void 0?`http://www.w3.org/2000/svg`:l,d=X(e,le);return k.createElement(`svg`,Y({},d,{height:o,ref:t,viewBox:`0 0 ${c} ${c}`,width:o,xmlns:u}),s?k.createElement(`title`,null,s):null,k.createElement(`path`,{d:r,fill:n}),k.createElement(`path`,{d:i,fill:a}))});Z.displayName=`QRCodeSvg`,Z.propTypes=ue;var de=[`bgColor`,`fgColor`,`level`,`size`,`value`];j.stringToBytes=function(e){return Array.from(new TextEncoder().encode(e))};var fe={bgColor:A.default.oneOfType([A.default.object,A.default.string]),fgColor:A.default.oneOfType([A.default.object,A.default.string]),level:A.default.string,size:A.default.number,value:A.default.string.isRequired},Q=(0,k.forwardRef)(function(e,t){var n=e.bgColor,r=n===void 0?`#FFFFFF`:n,i=e.fgColor,a=i===void 0?`#000000`:i,o=e.level,s=o===void 0?`L`:o,c=e.size,l=c===void 0?256:c,u=e.value,d=X(e,de),f=j(0,s);f.addData(u),f.make();var p=f.getModuleCount(),m=Array.from({length:p},function(e,t){return Array.from({length:p},function(e,n){return f.isDark(t,n)})});return k.createElement(Z,Y({},d,{bgColor:r,bgD:m.map(function(e,t){return e.map(function(e,n){return e?``:`M ${n} ${t} l 1 0 0 1 -1 0 Z`}).join(` `)}).join(` `),fgColor:a,fgD:m.map(function(e,t){return e.map(function(e,n){return e?`M ${n} ${t} l 1 0 0 1 -1 0 Z`:``}).join(` `)}).join(` `),ref:t,size:l,viewBoxSize:p}))});Q.displayName=`QRCode`,Q.propTypes=fe;var $=o(),pe=e=>({mode:e,ready:!1,accessUrl:null,reasons:[`远程服务未就绪`]});function me(){let{snap:t}=h(),{busy:i,run:o}=x(),c=[...t.instances?.native?[t.instances.native]:[],...t.instances?.instances??[]],l=t.lan?.items??[],E=t.frp,[D,O]=(0,k.useState)(``),[A,j]=(0,k.useState)(`7000`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(``),[B,V]=(0,k.useState)(!1),H=e();(0,k.useEffect)(()=>{!E||P||(O(E.settings.serverAddr||``),j(String(E.settings.serverPort||7e3)),F(!0))},[E,P]);function U(){let e={serverAddr:D,serverPort:parseInt(A,10)||7e3},t=M.trim();return t&&(e.authToken=t),e}async function W(e,t,n){let r=!1,i=await o(e.id,()=>d.remoteSetMode(e.id,t).then(e=>(r=e?.tokenAutoAllocated===!0,e)),{success:n});return i&&r&&a.info(`已自动生成访问令牌,点钥匙按钮可查看或修改`),i}async function G(e){await H({title:`开启远程控制?`,description:`「`+(e.name||e.id)+`」将开启局域网反向代理,同网段设备可访问该实例(无访问令牌时自动生成一个,可在钥匙按钮处查看)。`,confirmText:`开启远程控制`})&&await W(e,`lan`,`已开启远程控制(局域网)`)}async function K(e){await H({title:`切换到公网访问?`,description:`「`+(e.name||e.id)+`」的访问端口将映射到公网(frps),互联网上任何人都可尝试触达(访问令牌是硬性前置,缺失时自动生成)。`,confirmText:`切换到公网`})&&await W(e,`wan`,`已切换到公网访问`)}function q(e,t){z(t??``),V(!1),L({id:e.id,name:e.name,current:t})}async function J(){let e=I;if(!e)return;let t=R.trim();if(!t){a.error(`令牌不能为空`);return}if(t.length<8){a.error(`远程访问令牌至少 8 位(公网暴露可被暴力枚举)`);return}L(null),(e.current===null||e.current!==t)&&await o(e.id,()=>d.remoteSetToken(e.id,t),{success:`访问令牌已设置`})}async function Y(){await o(`frp-save`,()=>d.remoteFrpServer(U()),{success:`已保存 FRP 配置`})}return(0,$.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,$.jsxs)(`div`,{className:`grid items-start gap-4 @min-[900px]:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,$.jsxs)(T,{children:[(0,$.jsx)(S,{title:`远程控制`,subtitle:`为本地 DSH 实例开启远程访问:局域网直连或经 FRP 公网(需实例运行中)`}),(0,$.jsx)(`div`,{className:`grid`,children:c.length?c.map(e=>{let t=e.state?.running??!1,a=l.find(t=>t.dshPort===e.port),o=e.remoteMode??`off`,s=o===`off`?null:a?.remote??pe(o),c=s?.accessUrl??null,u=typeof e.remoteToken==`string`&&e.remoteToken.trim()?e.remoteToken.trim():null,d=s?.ready&&c?u?c+`?token=`+encodeURIComponent(u):c:null,f=u!==null||!!a?.tokenSet,p=o===`off`?(0,$.jsx)(C,{tone:`off`,children:`远程关闭`}):s?.ready?(0,$.jsx)(C,{tone:o===`wan`?`boot`:`ok`,children:o===`wan`?`公网就绪`:`局域网就绪`}):(0,$.jsx)(`span`,{title:(s?.reasons??[]).join(`;`),children:(0,$.jsx)(C,{tone:`off`,children:`远程停止`})});return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-stretch gap-4 border-b border-border/60 px-5 py-4 last:border-b-0`,children:[d?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center rounded-lg border border-border bg-white p-1.5`,title:u?`扫码访问该实例远程地址(已带访问令牌,一次出示后凭 Cookie)`:`扫码访问该实例远程地址`,children:(0,$.jsx)(Q,{value:d,size:88})}):(0,$.jsx)(`div`,{className:`grid size-[96px] shrink-0 place-items-center rounded-lg border border-dashed border-border/70 text-center text-[11px] leading-tight text-muted-foreground/60`,children:t?o===`off`?`开启远程后生成二维码`:`远程就绪后生成二维码`:`启动后可用`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`pt-2.5 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(w,{domain:e.domain}),(0,$.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:e.name}),p]}),(0,$.jsxs)(`div`,{className:`mt-auto grid content-end gap-1.5 pb-1`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`端口 `,e.port,o!==`off`&&a?.wanPort?` · 访问端口 `+a.wanPort+(o===`wan`?`(公网同号)`:``):``]}),c?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void y(()=>ee(c)),className:`inline-flex max-w-full items-center gap-1 truncate text-xs text-primary hover:underline`,title:u?`令牌绝不进浏览器启动参数,故直接打开需自行附加 ?token=;扫码可直达`:`在系统浏览器中打开该地址`,children:[(0,$.jsx)(b,{className:`size-3 shrink-0`}),c]}):!t||o===`off`?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:t?`远程未开启`:`实例未运行,启动后可开启远程`}):null,s&&!s.ready?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:(s.reasons??[]).slice(0,2).join(`;`)||`等待代理分配访问地址…`}):null]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-end justify-center gap-2`,children:[(0,$.jsxs)(`div`,{className:r(`flex items-center gap-2`,!t&&`pointer-events-none opacity-50`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`远程控制`}),(0,$.jsx)(m,{checked:o!==`off`,disabled:!t||i===e.id,onCheckedChange:t=>{if(!t){W(e,`off`,`已关闭远程控制`);return}G(e)}})]}),o!==`off`&&(0,$.jsxs)(`div`,{className:r(`flex items-center gap-1`,(!t||i===e.id)&&`pointer-events-none opacity-50`),children:[(0,$.jsxs)(n,{className:`h-7 px-2 text-xs`,size:`chip`,variant:o===`lan`?`default`:`outline`,title:`局域网反向代理访问(同网段)`,onClick:()=>{o!==`lan`&&W(e,`lan`,`已切换到局域网访问`)},children:[(0,$.jsx)(ae,{className:`size-3.5`}),`局域网`]}),(0,$.jsxs)(n,{className:`h-7 px-2 text-xs`,size:`chip`,variant:o===`wan`?`default`:`outline`,title:E?.settings?.serverAddr?`经 FRP 暴露到公网(需访问令牌)`:`需先在右侧配置 frps 服务器地址`,onClick:()=>{o!==`wan`&&K(e)},children:[(0,$.jsx)(re,{className:`size-3.5`}),`公网`]})]}),(0,$.jsx)(n,{className:`h-7 px-1.5`,disabled:i===e.id,onClick:()=>void q(e,u),size:`chip`,title:f?`访问令牌已设置(点击查看或修改)`:`未设访问令牌:局域网侧同网段可直接访问,公网模式会被安全闸拒绝,点击设置`,variant:`outline`,children:(0,$.jsx)(ie,{className:r(`size-3.5`,f?`text-status-ok`:`text-amber-500`)})})]})]},e.id)}):(0,$.jsx)(`div`,{className:`px-5 py-8 text-center text-sm text-muted-foreground`,children:`暂无实例(在「实例管理」添加后将出现在这里)`})})]}),(0,$.jsxs)(T,{children:[(0,$.jsx)(S,{title:`公网访问(FRP 内网穿透)`,subtitle:`存在「公网」模式的实例时 frpc 自动常驻并建立隧道`,actions:(0,$.jsx)(C,{tone:E?.running?`ok`:E?.installed?`warn`:`off`,children:E?.running?`frpc 运行中`:E?.installed?`已安装 · 未运行`:`未安装`})}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,$.jsx)(p,{children:`frps 地址`}),(0,$.jsx)(u,{placeholder:`如 1.2.3.4`,value:D,onChange:e=>O(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,$.jsx)(p,{children:`frps 端口`}),(0,$.jsx)(u,{inputMode:`numeric`,placeholder:`7000`,value:A,onChange:e=>j(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,$.jsx)(p,{children:`auth token`}),(0,$.jsx)(u,{type:`password`,autoComplete:`new-password`,placeholder:E?.settings?.authTokenSet?`已设置 · 留空不修改,输入即轮换`:`frps 的 auth.token`,value:M,onChange:e=>N(e.target.value)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pb-4`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[E?.installed?``:`需安装 frpc`,(E?.instancesExposed?.length??0)>0?` · 公网实例 `+E?.instancesExposed?.length+` 个`:` · 无公网模式实例`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(n,{disabled:i===`frp-inst`,onClick:()=>void o(`frp-inst`,()=>d.remoteFrpInstall(),{success:`frpc 安装完成`}),variant:`outline`,children:[(0,$.jsx)(se,{className:`size-4`}),`安装 frpc`]}),(0,$.jsxs)(n,{disabled:i===`frp-save`,onClick:()=>void Y(),children:[(0,$.jsx)(oe,{className:`size-4`}),`保存并应用`]})]})]}),E?.logTail?.length?(0,$.jsx)(`pre`,{className:`mx-5 mb-4 max-h-[160px] overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/70 p-3 font-mono text-xs leading-relaxed text-muted-foreground`,children:E.logTail.join(`
4
4
  `)}):null]})]}),(0,$.jsx)(g,{open:!!I,onOpenChange:e=>!e&&L(null),children:(0,$.jsxs)(v,{className:`max-w-[420px]`,children:[(0,$.jsx)(_,{children:(0,$.jsxs)(s,{children:[`访问令牌`,I?.name?` · `+I.name:``]})}),(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`远程访问需携带此令牌:首次在地址后附加 `,(0,$.jsx)(`code`,{className:`break-all`,children:`?token=令牌`}),`(只需一次,之后凭会话 Cookie 访问)。`,I?.current==null?`令牌明文只在内核所在机器上下发,当前面板读不到现值——输入即设为新令牌。`:`公网模式硬性要求它;此处显示的是当前生效值,改成新值即轮换。`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(u,{className:`flex-1`,type:B?`text`:`password`,autoComplete:`off`,placeholder:`输入访问令牌`,value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&J()}}),I?.current!=null&&(0,$.jsx)(n,{className:`h-9 px-2`,size:`chip`,variant:`outline`,title:B?`隐藏令牌`:`显示令牌`,onClick:()=>V(e=>!e),children:B?(0,$.jsx)(te,{className:`size-4`}):(0,$.jsx)(ne,{className:`size-4`})})]}),(0,$.jsxs)(f,{children:[(0,$.jsx)(n,{variant:`outline`,onClick:()=>L(null),children:`取消`}),(0,$.jsx)(n,{disabled:!R.trim()||i===I?.id,onClick:()=>void J(),children:`保存`})]})]})})]})}export{me as LanPage};
@@ -1,2 +1,2 @@
1
- import{F as e,I as t,L as n,N as r,O as i,R as a,S as o,U as s,V as c,a as l,b as ee,h as u,k as d,m as f,t as p,v as m,x as h,y as g}from"./supervisor-DsqHrafU.js";import{i as _,t as v}from"./openExternal-CCkI5Gcp.js";import{n as y,t as b}from"./rocket-USfrjyOj.js";import{t as x}from"./refresh-cw-DL1X7yMA.js";import{t as S}from"./shield-check-T6r2Ozdx.js";import{c as C,f as te,n as w,o as T,t as E}from"./supervisor-B8Hi4QZf.js";import{t as D}from"./useSupervisorAction-bKiRxMdz.js";import{c as O,i as k,n as A,o as j,t as M}from"./widgets-CKp8QAOl.js";import{t as N}from"./format-QeaTKFhQ.js";var P=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),F=r(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),I=r(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),L=s(c(),1),R=a();function z(e,t){return e===`dsh-main`||e===`supervisor-api`?`boot`:(t||``).startsWith(`inst:`)?`ok`:e===`relay`?`warn`:e.startsWith(`managed:`)?`boot`:`off`}function B(e){let t={"dsh-main":`DSH 主实例`,"supervisor-api":`管家 API`,user:`沙箱实例`,relay:`局域网隧道`,oauthCallback:`登录回调`,proxyInstance:`反代实例`,providerApi:`供应商 API`,"managed:router-daemon":`智能路由`,"managed:lan-daemon":`远程控制`,dynamic:`动态端口`},n=/^managed:(.+)$/.exec(e.role);return n?t[e.role]??n[1]:t[e.role]??e.role}function V(e,t){let n=e.owner||``;if(e.role===`proxyInstance`){let e=(n.split(`:`).pop()||``).slice(-4),r=(t??[]).find(t=>(t.accounts??[]).some(t=>(t.maskedKey||``).endsWith(e)));return r?r.name:`反代`}return n.startsWith(`inst:`)?`沙箱实例`:n.startsWith(`system:`)?`系统`:n.startsWith(`relay:`)?`局域网隧道`:n.startsWith(`dynamic:`)?`动态`:n.startsWith(`providerApi:`)?`供应商`:n.startsWith(`oauth:`)?`登录回调`:n===`router-daemon`||e.role===`managed:router-daemon`?`智能路由`:n===`lan-daemon`||e.role===`managed:lan-daemon`?`远程控制`:e.role===`oauthCallback`?`登录回调`:e.role}function H({providers:e=[]}){let{snap:t}=p(),r=t.ports?.records??null,i=(0,L.useMemo)(()=>r?[...r.filter(e=>e.role!==`supervisor-api`||e.port!==3100&&e.port!==3101)].sort((e,t)=>!!e.active==!!t.active?e.port-t.port:e.active?-1:1):null,[r]);return(0,R.jsxs)(M,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,R.jsx)(A,{title:`运行状态`,subtitle:`核心服务与端口实时状态`,actions:i?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[i.length,` 端口`]}):null}),i?(0,R.jsxs)(`div`,{className:`min-h-0 overflow-x-auto`,children:[(0,R.jsxs)(`div`,{className:`grid min-w-[400px] grid-cols-[56px_minmax(0,1fr)_auto_66px] items-center gap-2 border-b border-border/60 bg-muted/60 px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`端口`}),(0,R.jsx)(`span`,{children:`服务`}),(0,R.jsx)(`span`,{className:`text-right`,children:`归属`}),(0,R.jsx)(`span`,{className:`text-right`,children:`状态`})]}),(0,R.jsx)(`div`,{className:`max-h-[340px] overflow-y-auto overscroll-contain`,children:i.map((t,r)=>(0,R.jsxs)(`div`,{className:n(`grid grid-cols-[56px_minmax(0,1fr)_auto_66px] items-center gap-2 px-4 py-2 hover:bg-muted/40`,r>0&&`border-t border-border/50`),children:[(0,R.jsx)(`code`,{className:`font-mono text-sm tabular-nums text-foreground`,children:t.port}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,R.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:B(t)})}),(0,R.jsx)(`div`,{className:`flex justify-end`,children:(0,R.jsx)(j,{tone:z(t.role,t.owner),children:V(t,e)})}),(0,R.jsx)(`div`,{className:`flex justify-end`,children:t.active===!0?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-status-ok`,children:[(0,R.jsx)(F,{className:`size-3`}),`运行中`]}):t.active===!1?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,R.jsx)(F,{className:`size-3 opacity-50`}),`未运行`]}):(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,R.jsx)(F,{className:`size-3 opacity-40`}),`状态未知`]})})]},t.port+`-`+t.owner))})]}):(0,R.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`运行状态加载中…`})]})}function U(e){if(!e)return`未读出`;let t=String(e.state||`?`),n=e.detail?`(`+String(e.detail)+`)`:``;return(String(e.label||``)||`条目`)+` `+t+n}function W(e){return!e||e.state===`pending`?`未探测(点「重新探测」补齐)`:e.state===`error`?`探测失败:`+(e.error||`未给出原因`):e.state===`empty`?`已探测,无内容`:`已探测`+(e.at?` `+new Date(e.at).toLocaleTimeString():``)}function G(e){let t=e||{};return t.state===`on`?`在用(`+(t.server||t.pac||`地址未读出`)+`)`:t.state===`off`?`系统里明确未启用`:t.state===`unknown`?`取不到`+(t.source?`(`+t.source+`)`:``)+`,按判不出处理`:`未探测`}function K(e){return e===!0?`可达`:e===!1?`不通`:`判不出`}function q(e){return(e.section?e.section+`:`:``)+e.source+`:`+String(e.detail??``)}function J(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`时间未读出`:e<6e4?`刚刚`:e<36e5?Math.floor(e/6e4)+` 分钟前`:e<864e5?Math.floor(e/36e5)+` 小时前`:Math.floor(e/864e5)+` 天前`}function Y(e){return e===!0?`是`:e===!1?`否`:`未读出`}function X(e,t,n){let r=t||``,i=n||``,a=r&&i&&r!==i?`(两份不一致:装内核用的是壳那套,本进程解析到的是内核这套)`:``;return e+` 内核 `+(r||`未读出`)+` / 壳 `+(i||`未报`)+a}function Z(e){let t=e.ok===!0?`通`:e.ok===!1?`不通`:`判不出`;return(e.probe||`明细`)+` `+t+(e.target?`(`+e.target+`)`:``)+(typeof e.ms==`number`?` `+e.ms+` 毫秒`:``)}function ne(e,t){return e?t?`没落盘(这一拍读的是内核缓存拍)`:e.written===!0?`已写入`:e.error?`失败:`+e.error:`没落盘(也没报错误)`:`未给出(这一拍没装配)`}function re(e,t){if(t)return`读不回:`+t;if(!e)return`未读`;if(e.available===!0){let t=typeof e.at==`number`?new Date(e.at).toLocaleString():`时间未读出`,n=e.data&&e.data.browsers?e.data.browsers.length:null;return t+`(`+J(e.ageMs)+`)`+(n===null?``:`,候选 `+n+` 个`)}return e.reason===`never-written`?`这台机器还没落过盘`:`快照文件读不出或版本不符(不是没写过,得查文件)`}function ie(e){let t=e||{},n=Object.keys(t).filter(e=>t[e]!==`ok`);return n.length?`未补齐:`+n.join(`、`):`全部维度补齐`}function ae(e){let t=e&&e.name?e.name:`未定出`;return!e||!e.how?`现在会用:`+t:e.how===`user-preference`?`现在会用:`+t+`(你选的)`:e.how===`candidate-rank`?`现在会用:`+t+`(系统未报默认项,按候选次序取首个,可在此改)`:e.how===`only-installed`?`现在会用:`+t+`(本机唯一候选)`:e.how===`none-found`?`本机未探到可用浏览器,请安装或启用一个后重新探测`:`现在会用:`+t+`(系统默认项)`}var Q=`__system__`;function oe(){let[e,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),[p,v]=(0,L.useState)(null),[y,b]=(0,L.useState)(!1),[S,C]=(0,L.useState)(!1),[te,w]=(0,L.useState)(null),[T,E]=(0,L.useState)(null),D=(0,L.useCallback)(async e=>{e&&b(!0);try{let t=await l.environment(e);a(t),v(null),c(null)}catch(e){c(String(e.message||e))}b(!1),l.environmentLast().then(e=>{w(e),E(null)}).catch(e=>{w(null),E(String(e.message||e))})},[]);(0,L.useEffect)(()=>{e&&D(!1)},[e,D]);let O=async e=>{C(!0);let t={ok:!1,error:`偏好写入未返回结果`};try{t=await l.setExternalBrowser(e)}catch(e){t={ok:!1,error:String(e.message||e)}}if(C(!1),!t||t.ok!==!0){c(t&&t.error||`偏好写入失败`);return}c(null),await D(!0)},k=i?.browsers??[],A=i?.sections,j=i?.pick?.stale===!0,M=i?.preference?.id||Q,N=p===null?M:p,P=A?.startup?.data,F=A?.shell?.data,I=F?.registry,z=I?.probes||[],B=F?.records||[],V=I?.latencyMs,H=I?.probesTotal??0,oe=A?.runtime?.data?.node?.version||null,$=A?.runtime?.data?.npm?.detail||null;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,R.jsxs)(t,{size:`sm`,variant:`ghost`,className:`h-6 gap-1 px-1.5 text-xs text-muted-foreground`,onClick:()=>r(!0),children:[(0,R.jsx)(_,{className:`size-3`}),`环境表单`]}),i?.pick?.name?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:i.pick.name}):null]}),(0,R.jsx)(m,{open:e,onOpenChange:r,children:(0,R.jsxs)(g,{className:`max-w-[560px]`,children:[(0,R.jsx)(h,{children:(0,R.jsx)(o,{children:`本机环境表单`})}),(0,R.jsxs)(`div`,{className:`grid max-h-[60vh] gap-3 overflow-y-auto text-sm`,children:[(0,R.jsx)(`p`,{className:n(`text-xs`,j||!k.length?`font-semibold text-warning`:`text-muted-foreground`),children:ae(i?.pick)}),j?(0,R.jsxs)(`p`,{className:`inline-flex items-start gap-1.5 rounded-md bg-warning-background px-2 py-1.5 text-xs font-semibold text-warning`,children:[(0,R.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0`}),`你先前选的浏览器已不在本机候选清单(可能已卸载或路径变更),下方选择已回落到系统判定,请重选或清除。`]}):null,s?(0,R.jsx)(`p`,{className:`text-xs text-status-error`,children:s}):null,(0,R.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`打开地址用哪个浏览器`}),(0,R.jsxs)(f,{value:N,onValueChange:v,className:`grid gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-xs`,children:[(0,R.jsx)(u,{value:Q,id:`env-pref-system`}),(0,R.jsx)(`span`,{children:`跟随系统默认(本机探不到默认项时按候选次序)`})]}),k.map(e=>(0,R.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-xs`,children:[(0,R.jsx)(u,{value:e.id,id:`env-pref-`+e.id}),(0,R.jsx)(`span`,{children:e.name||e.bin}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:e.engine}),e.isDefault?(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`系统默认`}):null]},e.id))]}),k.length?(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(t,{size:`sm`,variant:`outline`,disabled:S||N===M,onClick:()=>void O(N===Q?``:N),children:`保存偏好`}),(0,R.jsx)(t,{size:`sm`,variant:`ghost`,disabled:S||M===Q,onClick:()=>void O(``),children:`清除`})]}):(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`候选为空:重新探测后仍为空时,请先在系统里安装或启用一个浏览器。`})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`出网条件(隔离登录窗口的分发依据)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.egress)}),A?.egress?.data?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs`,children:[(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`系统代理:`,G(A?.egress?.data?.proxy)]}),Object.entries(A?.egress?.data?.targets||{}).map(([e,t])=>(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`,K(t?.ok),t?.stage?`(停在 `+t.stage+(t.detail?` `+t.detail:``)+`)`:``]},e)),Object.keys(A?.egress?.data?.targets||{}).length?null:(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`还没有目标域被问过:一键登录时会当场判定并记在这里。`})]}):null,A?.egress?.data?.proxy?.state===`off`?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`没有在用系统代理时,直连不通的授权域只能靠现有浏览器窗口的既有出网路径打开(隔离冷档案会是空白页)。`}):null]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`运行时与 DSH(安装/升级动作的分发依据)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.runtime)}),A?.runtime?.data?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[U(A?.runtime?.data?.node),` · `,U(A?.runtime?.data?.npm),` · `,U(A?.runtime?.data?.git)]}),(0,R.jsxs)(`span`,{children:[`镜像源:`,A?.runtime?.data?.registry?.origin||`未读出`,A?.runtime?.data?.registry?.mode?`(`+A.runtime.data.registry.mode+`)`:``,` · 候选 `+(A?.runtime?.data?.registry?.candidates||[]).length+` 个`]}),(0,R.jsxs)(`span`,{className:`break-all`,children:[`全局前缀:`,A?.runtime?.data?.prefix||`未实测(npm root -g 未返回)`]})]}):null,(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`桌面壳所见(装内核时真正用的那一套,与上面的内核读数并排对照)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.shell)}),F?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:F.available===!0?`壳上报于 `+J(F.ageMs)+`,写入者 `+(F.writtenBy||`未署名`)+`(报告版本 `+(F.schema??`未读出`)+`)`:F.reason===`never-written`?`这台机器的壳还没报过:内核由命令行或别的进程拉起时这是常态,不是故障`:`壳报的文件读不出或版本不符(不是没写过,得查那个文件)`}),F.available===!0?(0,R.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,R.jsx)(`span`,{className:`break-all`,children:X(`Node:`,oe,F.node?.version)}),(0,R.jsx)(`span`,{className:`break-all`,children:X(`npm:`,$,F.npm?.version)}),(0,R.jsx)(`span`,{className:`break-all`,children:X(`镜像源:`,A?.runtime?.data?.registry?.origin,F.registry?.best)}),(0,R.jsx)(`span`,{className:`break-all`,children:X(`全局前缀:`,A?.runtime?.data?.prefix,F.prefix?.dir)}),F.node&&F.node.ok!==!0?(0,R.jsxs)(`span`,{children:[`壳判 Node 达标:`,Y(F.node.ok),`(`,F.node.version||`版本未报`,`,门槛 `,F.node.min||`未报`,`)`]}):null,F.prefix&&F.prefix.writable!==!0?(0,R.jsxs)(`span`,{className:`break-all`,children:[`壳判前缀可写:`,Y(F.prefix.writable),F.prefix.why?`(`+F.prefix.why+`)`:``]}):null,z.length||I?.best?(0,R.jsxs)(`span`,{className:`break-all`,children:[`壳的镜像源候选:`,z.map(e=>(e.url||`?`)+` `+K(e.ok)).join(`、`),typeof V==`number`?`(择优选中用时 `+V+` 毫秒)`:``,H>z.length?`(报告里共 `+H+` 个候选,此处只列前 `+z.length+` 个)`:``]}):null,B.length?(0,R.jsxs)(`span`,{children:[`壳的探测明细 `,B.length,` 条:`,B.slice(0,8).map(Z).join(`;`),B.length>8?`…其余见内核快照文件`:``,F.droppedRecords?`(报告送达时被截断 `+F.droppedRecords+` 条)`:``]}):null]}):null]}):null,(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.dsh)}),A?.dsh?.data?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[U(A?.dsh?.data?.dsh),` · `,U(A?.dsh?.data?.selfUpdate)]}),(0,R.jsxs)(`span`,{children:[`看护:`,A?.dsh?.data?.managed?`守卫托管`:`未托管`,A?.dsh?.data?.phase?` · `+A.dsh.data.phase:``]})]}):null]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`启动既成事实(守卫这一拍真的跑过什么)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.startup)}),P?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[`守卫启动于 `,typeof P.bootAt==`number`?new Date(P.bootAt).toLocaleTimeString():`未读出`,`,环境表单首拍排在启动后 `,P.envDelayMs??`未读出`,` 毫秒`]}),(0,R.jsxs)(`span`,{children:[`选路:自动启动 `,Y(P.routerAutostart),`,模式 `,P.routerMode||`未读出(这一拍没走到那步)`]}),(0,R.jsxs)(`span`,{children:[`更新检查:`,P.updateCheck?P.updateCheck.enabled?`开(首查排在启动后 `+(P.updateCheck.initialDelayMs??`未读出`)+` 毫秒,之后每 `+(P.updateCheck.intervalMs??`未读出`)+` 毫秒)`:`关(配置里就禁掉了,这同样是一条既成事实)`:`未记录`]}),(0,R.jsxs)(`span`,{children:[`壳看护:`,Y(P.shellWatchdog)]}),(0,R.jsx)(`span`,{children:P.lastRefresh?`最近一次表单刷新于 `+(typeof P.lastRefresh.at==`number`?new Date(P.lastRefresh.at).toLocaleTimeString():`未读出`)+`,耗时 `+(P.lastRefresh.tookMs??`未读出`)+` 毫秒,浏览器 `+(P.lastRefresh.browsers??`未读出`)+` 个,分发依据 `+(P.lastRefresh.pick||`未定出`)+`,落盘 `+Y(P.lastRefresh.snapshotWritten)+`;`+ie(P.lastRefresh.dims):`这一拍还没跑过表单刷新(首拍排在上面那个延迟之后)`})]}):null]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`平台`}),(0,R.jsx)(`dd`,{className:`font-mono`,children:[i?.identity?.platform,i?.identity?.arch].filter(Boolean).join(` / `)||`—`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`图形会话`}),(0,R.jsx)(`dd`,{children:i?.session?.available?`可用(`+(i?.session?.reason||`—`)+`)`:`不可用(`+(i?.session?.reason||`—`)+`)`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`系统默认项`}),(0,R.jsx)(`dd`,{children:i?.default?i.default.id+`(来源 `+(i.default.source||`未读出`)+`)`:`未读出`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`候选`}),(0,R.jsx)(`dd`,{children:k.length?k.map(e=>(e.name||e.bin)+`[`+(e.sources||[]).join(`+`)+`]`).join(`、`):`无`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`探测留痕`}),(0,R.jsx)(`dd`,{className:`grid gap-0.5`,children:(i?.probed??[]).map((e,t)=>(0,R.jsx)(`span`,{className:`text-muted-foreground/80`,children:q(e)},t))}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`快照落盘`}),(0,R.jsxs)(`dd`,{className:`break-all font-mono text-muted-foreground/80`,children:[ne(i?.snapshot,i?.cached===!0),(0,R.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` `,i?.snapshot?.path||`未给出路径`]})]}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`上一拍留痕`}),(0,R.jsx)(`dd`,{className:`text-muted-foreground`,children:re(te,T)})]})]}),(0,R.jsxs)(ee,{children:[(0,R.jsxs)(t,{variant:`outline`,disabled:y,onClick:()=>void D(!0),children:[(0,R.jsx)(x,{className:`size-4`}),y?`探测中…`:`重新探测`]}),(0,R.jsx)(t,{onClick:()=>r(!1),children:`关闭`})]})]})})]})}var $=new Set([`dist_registry_selected`,`gui_autostart_changed`,`autostart_changed`,`lan_panel_changed`,`lan_dsh_token_updated`]);function se(){let{snap:r}=p(),{busy:a,run:s}=D(),c=e(),[u,d]=(0,L.useState)(!1),[f,E]=(0,L.useState)(null),A=r.status,j=A?.native,N=j?.installed??!1,F=j?.state||(N?`installed`:`uninstalled`),z=F===`installing`,B=z||F===`uninstalling`,V=A?.version,U=A?.upgrade,W=w[A?.phase??``]??{label:A?.phase||`未知`,tone:`off`},G=!!A?.dshPid,K=U?.state===`running`,q=(0,L.useMemo)(()=>r.events.filter(e=>!$.has(e.type)),[r.events]);async function J(){await s(`dsh`,()=>G?l.lifecycleStop(`dsh`):l.lifecycleStart(`dsh`),{success:G?`正在停止 DSH…`:`正在启动 DSH…`})}async function Y(){await c({title:`停止 DSH?`,description:`主干 DeepSeek Harness 正在运行;停止会中断进行中的请求,远程访问同时不可用。`,confirmText:`停止 DSH`})&&await J()}async function X(){await s(`web`,()=>v(()=>l.instanceOpenWeb(`main`)).then(()=>void 0))}async function Z(){await s(`chk`,async()=>{let e=await l.nativeCheckUpdate();if(e?.ok===!1){i.error(e.error||`检测失败`);return}e?.updateAvailable&&e.latest?i.success(`发现新版本 `+e.latest+(e.installed?`(当前 `+e.installed+`),可一键升级`:``)):i.success(`已是最新版本`+(e.installed?`(`+e.installed+`)`:``))})}async function ne(){d(!1),await s(`upg`,()=>l.nativeUpgrade(),{success:`升级已开始,请耐心等待…`})}async function re(){await c({title:`在线安装最新版 DeepSeek Harness?`,description:`需数分钟,自动适配最快镜像源。`,confirmText:`安装`})&&await s(`inst`,()=>l.nativeInstall(),{success:`开始安装 DeepSeek Harness…`})}async function ie(){await c({title:`彻底卸载 DeepSeek Harness?`,description:`删除全部文件、数据、缓存与日志,不留残留。`,confirmText:`卸载 DSH`,tone:`destructive`})&&await s(`uni`,()=>l.nativeUninstall(),{success:`开始卸载…`})}(0,L.useEffect)(()=>{N&&l.instances().then(e=>{let t=e?.native?.guardian;typeof t==`boolean`&&E(t)}).catch(()=>{})},[N,A?.dshPid]);async function ae(){let e=f!==!0;await s(`gu`,()=>l.nativeSettings({guardian:e}).then(e=>{let t=e?.main?.guardian;return typeof t==`boolean`&&E(t),e}),{success:e?`已开启 DSH 进程守护(崩溃自动拉起)`:`已关闭 DSH 进程守护(崩溃后不再自动拉起)`,refresh:!1})}let Q=N&&(j?.version||V?.installed)||`—`;return(0,R.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,R.jsxs)(M,{children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-1 @min-[720px]:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-5 border-b border-border px-6 py-5 md:border-b-0 md:border-r`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`h3`,{className:`truncate text-xl font-semibold tracking-[-0.01em] text-foreground`,children:`DeepSeek Harness`}),(0,R.jsxs)(`span`,{className:`shrink-0 font-mono text-sm text-muted-foreground`,children:[`v`,Q]})]}),a===`chk`?(0,R.jsxs)(t,{size:`chip`,disabled:!0,children:[(0,R.jsx)(x,{className:`size-3 animate-spin`}),`检测中…`]}):V?.updateAvailable&&V.latest?(0,R.jsxs)(t,{className:`text-primary-foreground`,size:`chip`,onClick:()=>d(!0),children:[(0,R.jsx)(P,{className:`size-3`}),`升级到 v`,V.latest]}):K?(0,R.jsxs)(t,{size:`chip`,disabled:!0,children:[(0,R.jsx)(x,{className:`size-3 animate-spin`}),`升级中…`]}):(0,R.jsxs)(t,{className:`bg-primary/10 text-primary hover:bg-primary/15`,onClick:()=>void Z(),size:`chip`,variant:`ghost`,children:[(0,R.jsx)(x,{className:`size-3`}),`检测更新`]})]}),B?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(O,{tone:`boot`,ping:!0}),(0,R.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:z?`正在安装 DeepSeek Harness…`:`正在卸载 DeepSeek Harness…`})]}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(O,{tone:W.tone,ping:W.tone===`ok`}),(0,R.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:W.label})]}),K&&U?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-primary`}),`正在升级(`,U.step||U.targetVersion||``,`)…`]}):null,U?.state===`failed`?(0,R.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`升级失败:`,U.lastError||`未知原因`,U.rolledBack?`(已回滚)`:``]}):null,B&&(j?.installLog??[]).length?(0,R.jsx)(`pre`,{className:`max-h-[120px] overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/70 p-3 font-mono text-xs leading-relaxed text-muted-foreground`,children:(j?.installLog??[]).slice(-6).join(`
2
- `)}):null]}),(0,R.jsx)(`div`,{className:`flex items-center bg-[image:var(--panel-accent-gradient)] px-6 py-5`,children:(0,R.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-x-6 gap-y-4 @min-[560px]:grid-cols-4`,children:[(0,R.jsx)(k,{icon:(0,R.jsx)(te,{className:`size-4`}),label:`端口`,value:A?.dshPort?String(A.dshPort):`—`,mono:!0}),(0,R.jsx)(k,{icon:(0,R.jsx)(I,{className:`size-4`}),label:`PID`,value:A?.dshPid?String(A.dshPid):`—`,mono:!0}),(0,R.jsx)(k,{icon:(0,R.jsx)(x,{className:`size-4`}),label:`重启次数`,value:String(A?.restartCount??0),mono:!0}),(0,R.jsx)(k,{icon:(0,R.jsx)(P,{className:`size-4`}),label:`最近故障`,value:A?.lastFailure?T(A?.lastFailure):`无`,warn:!!A?.lastFailure})]})})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-border/60 px-6 py-3`,children:[(0,R.jsx)(`div`,{className:`hidden lg:block`,children:(0,R.jsx)(ce,{})}),(0,R.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[!N&&!B?(0,R.jsxs)(t,{size:`sm`,disabled:a===`inst`,onClick:()=>void re(),children:[(0,R.jsx)(b,{className:`size-4`}),`安装 DSH`]}):N&&!B&&!K?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(t,{disabled:!G,onClick:()=>void X(),size:`sm`,variant:`outline`,className:`hidden md:inline-flex`,children:[(0,R.jsx)(_,{className:`size-4`}),`DSH Web`]}),(0,R.jsx)(t,{disabled:a===`dsh`,onClick:()=>void(G?Y():J()),size:`sm`,variant:`outline`,children:G?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(y,{className:`size-4 text-status-error`}),`停止 DSH`]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(b,{className:`size-4 text-primary`}),`启动 DSH`]})}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,R.jsxs)(t,{className:`h-[30px]`,disabled:a===`gu`||f===null,onClick:()=>void ae(),size:`sm`,variant:`outline`,children:[(0,R.jsx)(S,{className:n(`size-4`,f===!0?`text-status-ok`:`text-muted-foreground`)}),f===!0?`停止守护`:`启动守护`]})]}):null,N&&!B?(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(t,{className:`hidden h-[30px] md:inline-flex`,disabled:a===`uni`,onClick:()=>void ie(),size:`sm`,variant:`destructive`,children:[(0,R.jsx)(C,{className:`size-4`}),`卸载 DSH`]})}):null]})]})]}),(0,R.jsxs)(`div`,{className:`grid items-start gap-4 @min-[860px]:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,R.jsx)(le,{events:q}),(0,R.jsx)(H,{providers:r.providers?.providers??[]})]}),(0,R.jsx)(m,{open:u,onOpenChange:d,children:(0,R.jsxs)(g,{className:`max-w-[420px]`,children:[(0,R.jsx)(h,{children:(0,R.jsx)(o,{children:`升级 DeepSeek Harness`})}),(0,R.jsxs)(`div`,{className:`grid gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-3 rounded-md bg-muted px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`当前版本`}),(0,R.jsx)(`strong`,{className:`font-mono text-base text-foreground`,children:V?.installed||Q})]}),(0,R.jsx)(P,{className:`size-4 text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`新版本`}),(0,R.jsx)(`strong`,{className:`font-mono text-base text-primary`,children:V?.latest||`—`})]})]}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`升级将先停止 DSH、安装新版本后自动拉起(需数分钟)。期间进行中的请求会中断,失败会自动回滚到当前版本。`})]}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(t,{onClick:()=>d(!1),variant:`outline`,children:`取消`}),(0,R.jsx)(t,{disabled:a===`upg`||K,onClick:()=>void ne(),children:a===`upg`||K?`升级中…`:`开始升级`})]})]})})]})}function ce(){let[e,t]=(0,L.useState)(null),[r,i]=(0,L.useState)(null);(0,L.useEffect)(()=>{let e=!0,n=async()=>{let[n,r]=await Promise.all([l.nodeLts().catch(()=>null),l.envStatus().catch(()=>null)]);e&&(t(n),i(r?.catalog?.items??null))};n();let r=setInterval(n,6e5);return()=>{e=!1,clearInterval(r)}},[]);let a=Object.entries(r??{}).filter(([,e])=>e.required);return!e?.current&&a.length===0?(0,R.jsx)(`span`,{className:`min-w-[120px] text-xs text-muted-foreground`,children:`环境检测…`}):(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:`环境检测`}),a.map(([e,t])=>{let r=t.state===`ok`||t.state===`configured`;return(0,R.jsxs)(`span`,{title:t.detail||void 0,className:n(`inline-flex items-center gap-1 whitespace-nowrap rounded-full px-2 py-0.5`,r?`text-muted-foreground/70`:`bg-warning-background font-semibold text-warning`),children:[!r&&(0,R.jsx)(d,{className:`size-3`}),t.label,` `,t.detail||`—`]},e)}),(0,R.jsx)(oe,{}),e?.ltsLine===!1?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap rounded-full bg-warning-background px-2 py-0.5 font-semibold text-warning`,title:e.suggested||void 0,children:[(0,R.jsx)(d,{className:`size-3`}),`非 LTS 线(建议偶数主版本)`]}):e?.ltsLine===!0?(0,R.jsx)(`span`,{className:`hidden whitespace-nowrap text-muted-foreground/70 sm:inline`,children:`LTS 线`}):null]})}function le({events:e}){let[t,n]=(0,L.useState)(12),r=e.length;(0,L.useEffect)(()=>{n(12)},[e]);let i=(0,L.useRef)(null),a=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let e=i.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(a.current||(a.current=!0,n(e=>Math.min(e+12,r)),setTimeout(()=>{a.current=!1},80)))},{rootMargin:`120px 0px`});return t.observe(e),()=>t.disconnect()},[r]);let o=e.slice(0,t),s=t<r;return(0,R.jsxs)(M,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,R.jsx)(A,{title:`事件日志`,subtitle:`核心运行状态遥测`,actions:(0,R.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:r})}),r?(0,R.jsxs)(`div`,{className:`flex max-h-[450px] min-h-0 flex-col overflow-y-auto overscroll-contain`,children:[o.map((e,t)=>(0,R.jsx)(ue,{e},e.seq??t)),(0,R.jsx)(`div`,{ref:i,className:`px-5 py-2 text-center text-[11px] text-muted-foreground`,children:s?`下滑加载更多…`:`已加载全部`})]}):(0,R.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`暂无核心运行状态事件`})]})}function ue({e}){let t=fe[e.type]??`boot`,n=E[e.type]??e.type,r=de(e);return(0,R.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[64px_auto_minmax(0,1fr)] items-center gap-2.5 border-b border-border/60 px-5 py-2 last:border-b-0 max-[640px]:grid-cols-[56px_auto_minmax(0,1fr)] max-[640px]:gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:N(e.ts)}),(0,R.jsx)(j,{tone:t,children:n}),(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]})}function de(e){let t=e.data;if(!t)return``;let n=e=>Number(e??0).toLocaleString(`en-US`);if(typeof t.message==`string`)return t.message;if(typeof t.reason==`string`)return T(t.reason);if(typeof t.desired==`string`)return`期望 `+t.desired;if(e.type===`router_usage`)return(t.model||``)+(t.model?` · `:``)+n(t.tokens)+` tokens`;if(e.type===`router_pick`)return[t.provider||``,t.key||``].filter(Boolean).join(` · `);if(e.type===`account_ready`||e.type===`account_frozen`||e.type===`account_banned`||e.type===`account_recovered`||e.type===`account_review`||e.type===`account_exhausted`)return(t.key||``)+(t.key?` · `:``)+(t.provider||``);if(e.type===`provider_quota_refreshed`)return(t.provider||``)+` 额度已刷新`;if(e.type===`proxy_update_available`)return[t.pkg||``,t.from||``,t.to||``].filter(Boolean).join(` → `);if(e.type===`proxy_instance_started`)return`port=`+(t.port??``)+(t.pid?` pid=`+t.pid:``);if(e.type===`dsh_guardian_changed`||e.type===`inst_guardian_changed`)return(t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`))+` · 进程守护`+(t.enabled===!0?` → 开启`:` → 关闭`);if(e.type===`dsh_remote_changed`||e.type===`inst_remote_changed`)return(t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`))+` · 远程控制 → `+(t.mode===`lan`?`局域网`:t.mode===`wan`?`公网`:`关闭`);if(e.type===`dsh_remote_token_changed`||e.type===`inst_remote_token_changed`)return(t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`))+` · 访问令牌`+(t.tokenSet===!0?` → 已设置`:` → 已清除`);let r=[];return t.pid!==void 0&&r.push(`pid=`+t.pid),t.port!==void 0&&r.push(`port=`+String(t.port)),t.version!==void 0&&r.push(`v`+String(t.version)),t.model&&t.tokens!==void 0&&r.push(n(t.tokens)+` tok`),t.ms!==void 0&&r.push(n(t.ms)+`ms`),r.join(` · `)}var fe={running:`ok`,adopted:`ok`,spawned:`ok`,main_instance_registered:`ok`,upgrade_installed:`ok`,upgrade_done:`ok`,api_listening:`ok`,account_ready:`ok`,account_confirmed:`ok`,account_recovered:`ok`,proxy_instance_started:`ok`,proxy_update_applied:`ok`,router_provider_activated:`ok`,router_provider_endpoint:`ok`,inst_running:`ok`,inst_added:`ok`,inst_started:`ok`,lan_instance_started:`ok`,frpc_installed:`ok`,frpc_started:`ok`,plugin_install_done:`ok`,native_installed:`ok`,inst_upgraded:`ok`,plugin_update_done:`ok`,account_frozen:`err`,account_banned:`err`,dsh_exited:`err`,unhealthy:`err`,spawn_failed:`err`,spawn_error:`err`,upgrade_failed:`err`,api_error:`err`,api_offline:`err`,proxy_instance_failed:`err`,inst_failed:`err`,inst_start_failed:`err`,native_install_failed:`err`,native_uninstall_failed:`err`,plugin_install_job_failed:`err`,plugin_update_job_failed:`err`,plugin_uninstall_job_failed:`err`,frpc_install_failed:`err`,router_stream_aborted:`err`,sigkill_sent:`err`,start_timeout:`err`,crash_loop_entered:`err`,guard_exit:`warn`,version_check_failed:`warn`,restart_triggered:`warn`,dsh_not_installed:`warn`,sigterm_sent:`warn`,account_review:`warn`,dsh_guardian_changed:`warn`,inst_guardian_changed:`warn`,dsh_remote_changed:`warn`,inst_remote_changed:`warn`,dsh_remote_token_changed:`warn`,inst_remote_token_changed:`warn`,lan_frp_blocked:`warn`,proxy_update_available:`warn`,upgrade_started:`warn`,upgrade_stopping_dsh:`warn`,inst_restarted:`warn`,native_uninstall_started:`warn`,account_discarded:`off`,router_stopped:`off`,proxy_instance_stopped:`off`,inst_stopped:`off`,inst_removed:`off`,lan_instance_removed:`off`,frpc_stopped:`off`,plugin_uninstall_done:`off`,native_uninstalled:`off`,upgrade_skipped:`off`,router_provider_deactivated:`off`,stop:`off`};export{se as OverviewPage};
1
+ import{F as e,I as t,L as n,N as r,O as i,R as a,S as o,U as s,V as c,a as l,b as ee,h as u,k as d,m as f,t as p,v as m,x as h,y as g}from"./supervisor-DsqHrafU.js";import{n as _,o as v}from"./openExternal-EAMqvnZq.js";import{n as y,t as b}from"./rocket-USfrjyOj.js";import{t as x}from"./refresh-cw-DL1X7yMA.js";import{t as S}from"./shield-check-T6r2Ozdx.js";import{c as C,f as te,n as w,o as T,t as E}from"./supervisor-DUOKbKN7.js";import{t as D}from"./useSupervisorAction-bKiRxMdz.js";import{c as O,i as k,n as A,o as j,t as M}from"./widgets-CKp8QAOl.js";import{t as N}from"./format-QeaTKFhQ.js";var P=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),F=r(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),I=r(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),L=s(c(),1),R=a();function z(e,t){return e===`dsh-main`||e===`supervisor-api`?`boot`:(t||``).startsWith(`inst:`)?`ok`:e===`relay`?`warn`:e.startsWith(`managed:`)?`boot`:`off`}function B(e){let t={"dsh-main":`DSH 主实例`,"supervisor-api":`管家 API`,user:`沙箱实例`,relay:`局域网隧道`,oauthCallback:`登录回调`,proxyInstance:`反代实例`,providerApi:`供应商 API`,"managed:router-daemon":`智能路由`,"managed:lan-daemon":`远程控制`,dynamic:`动态端口`},n=/^managed:(.+)$/.exec(e.role);return n?t[e.role]??n[1]:t[e.role]??e.role}function V(e,t){let n=e.owner||``;if(e.role===`proxyInstance`){let e=(n.split(`:`).pop()||``).slice(-4),r=(t??[]).find(t=>(t.accounts??[]).some(t=>(t.maskedKey||``).endsWith(e)));return r?r.name:`反代`}return n.startsWith(`inst:`)?`沙箱实例`:n.startsWith(`system:`)?`系统`:n.startsWith(`relay:`)?`局域网隧道`:n.startsWith(`dynamic:`)?`动态`:n.startsWith(`providerApi:`)?`供应商`:n.startsWith(`oauth:`)?`登录回调`:n===`router-daemon`||e.role===`managed:router-daemon`?`智能路由`:n===`lan-daemon`||e.role===`managed:lan-daemon`?`远程控制`:e.role===`oauthCallback`?`登录回调`:e.role}function H({providers:e=[]}){let{snap:t}=p(),r=t.ports?.records??null,i=(0,L.useMemo)(()=>r?[...r.filter(e=>e.role!==`supervisor-api`||e.port!==3100&&e.port!==3101)].sort((e,t)=>!!e.active==!!t.active?e.port-t.port:e.active?-1:1):null,[r]);return(0,R.jsxs)(M,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,R.jsx)(A,{title:`运行状态`,subtitle:`核心服务与端口实时状态`,actions:i?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[i.length,` 端口`]}):null}),i?(0,R.jsxs)(`div`,{className:`min-h-0 overflow-x-auto`,children:[(0,R.jsxs)(`div`,{className:`grid min-w-[400px] grid-cols-[56px_minmax(0,1fr)_auto_66px] items-center gap-2 border-b border-border/60 bg-muted/60 px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`端口`}),(0,R.jsx)(`span`,{children:`服务`}),(0,R.jsx)(`span`,{className:`text-right`,children:`归属`}),(0,R.jsx)(`span`,{className:`text-right`,children:`状态`})]}),(0,R.jsx)(`div`,{className:`max-h-[340px] overflow-y-auto overscroll-contain`,children:i.map((t,r)=>(0,R.jsxs)(`div`,{className:n(`grid grid-cols-[56px_minmax(0,1fr)_auto_66px] items-center gap-2 px-4 py-2 hover:bg-muted/40`,r>0&&`border-t border-border/50`),children:[(0,R.jsx)(`code`,{className:`font-mono text-sm tabular-nums text-foreground`,children:t.port}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,R.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:B(t)})}),(0,R.jsx)(`div`,{className:`flex justify-end`,children:(0,R.jsx)(j,{tone:z(t.role,t.owner),children:V(t,e)})}),(0,R.jsx)(`div`,{className:`flex justify-end`,children:t.active===!0?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-status-ok`,children:[(0,R.jsx)(F,{className:`size-3`}),`运行中`]}):t.active===!1?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,R.jsx)(F,{className:`size-3 opacity-50`}),`未运行`]}):(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,R.jsx)(F,{className:`size-3 opacity-40`}),`状态未知`]})})]},t.port+`-`+t.owner))})]}):(0,R.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`运行状态加载中…`})]})}function U(e){if(!e)return`未读出`;let t=String(e.state||`?`),n=e.detail?`(`+String(e.detail)+`)`:``;return(String(e.label||``)||`条目`)+` `+t+n}function W(e){return!e||e.state===`pending`?`未探测(点「重新探测」补齐)`:e.state===`error`?`探测失败:`+(e.error||`未给出原因`):e.state===`empty`?`已探测,无内容`:`已探测`+(e.at?` `+new Date(e.at).toLocaleTimeString():``)}function G(e){let t=e||{};return t.state===`on`?`在用(`+(t.server||t.pac||`地址未读出`)+`)`:t.state===`off`?`系统里明确未启用`:t.state===`unknown`?`取不到`+(t.source?`(`+t.source+`)`:``)+`,按判不出处理`:`未探测`}function K(e){return e===!0?`可达`:e===!1?`不通`:`判不出`}function q(e){return(e.section?e.section+`:`:``)+e.source+`:`+String(e.detail??``)}function J(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`时间未读出`:e<6e4?`刚刚`:e<36e5?Math.floor(e/6e4)+` 分钟前`:e<864e5?Math.floor(e/36e5)+` 小时前`:Math.floor(e/864e5)+` 天前`}function Y(e){return e===!0?`是`:e===!1?`否`:`未读出`}function X(e,t,n){let r=t||``,i=n||``,a=r&&i&&r!==i?`(两份不一致:装内核用的是壳那套,本进程解析到的是内核这套)`:``;return e+` 内核 `+(r||`未读出`)+` / 壳 `+(i||`未报`)+a}function Z(e){let t=e.ok===!0?`通`:e.ok===!1?`不通`:`判不出`;return(e.probe||`明细`)+` `+t+(e.target?`(`+e.target+`)`:``)+(typeof e.ms==`number`?` `+e.ms+` 毫秒`:``)}function ne(e,t){return e?t?`没落盘(这一拍读的是内核缓存拍)`:e.written===!0?`已写入`:e.error?`失败:`+e.error:`没落盘(也没报错误)`:`未给出(这一拍没装配)`}function re(e,t){if(t)return`读不回:`+t;if(!e)return`未读`;if(e.available===!0){let t=typeof e.at==`number`?new Date(e.at).toLocaleString():`时间未读出`,n=e.data&&e.data.browsers?e.data.browsers.length:null;return t+`(`+J(e.ageMs)+`)`+(n===null?``:`,候选 `+n+` 个`)}return e.reason===`never-written`?`这台机器还没落过盘`:`快照文件读不出或版本不符(不是没写过,得查文件)`}function ie(e){let t=e||{},n=Object.keys(t).filter(e=>t[e]!==`ok`);return n.length?`未补齐:`+n.join(`、`):`全部维度补齐`}function ae(e){let t=e&&e.name?e.name:`未定出`;return!e||!e.how?`现在会用:`+t:e.how===`user-preference`?`现在会用:`+t+`(你选的)`:e.how===`candidate-rank`?`现在会用:`+t+`(系统未报默认项,按候选次序取首个,可在此改)`:e.how===`only-installed`?`现在会用:`+t+`(本机唯一候选)`:e.how===`none-found`?`本机未探到可用浏览器,请安装或启用一个后重新探测`:`现在会用:`+t+`(系统默认项)`}var Q=`__system__`;function oe(){let[e,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),[p,_]=(0,L.useState)(null),[y,b]=(0,L.useState)(!1),[S,C]=(0,L.useState)(!1),[te,w]=(0,L.useState)(null),[T,E]=(0,L.useState)(null),D=(0,L.useCallback)(async e=>{e&&b(!0);try{let t=await l.environment(e);a(t),_(null),c(null)}catch(e){c(String(e.message||e))}b(!1),l.environmentLast().then(e=>{w(e),E(null)}).catch(e=>{w(null),E(String(e.message||e))})},[]);(0,L.useEffect)(()=>{e&&D(!1)},[e,D]);let O=async e=>{C(!0);let t={ok:!1,error:`偏好写入未返回结果`};try{t=await l.setExternalBrowser(e)}catch(e){t={ok:!1,error:String(e.message||e)}}if(C(!1),!t||t.ok!==!0){c(t&&t.error||`偏好写入失败`);return}c(null),await D(!0)},k=i?.browsers??[],A=i?.sections,j=i?.pick?.stale===!0,M=i?.preference?.id||Q,N=p===null?M:p,P=A?.startup?.data,F=A?.shell?.data,I=F?.registry,z=I?.probes||[],B=F?.records||[],V=I?.latencyMs,H=I?.probesTotal??0,oe=A?.runtime?.data?.node?.version||null,$=A?.runtime?.data?.npm?.detail||null;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,R.jsxs)(t,{size:`sm`,variant:`ghost`,className:`h-6 gap-1 px-1.5 text-xs text-muted-foreground`,onClick:()=>r(!0),children:[(0,R.jsx)(v,{className:`size-3`}),`环境表单`]}),i?.pick?.name?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:i.pick.name}):null]}),(0,R.jsx)(m,{open:e,onOpenChange:r,children:(0,R.jsxs)(g,{className:`max-w-[560px]`,children:[(0,R.jsx)(h,{children:(0,R.jsx)(o,{children:`本机环境表单`})}),(0,R.jsxs)(`div`,{className:`grid max-h-[60vh] gap-3 overflow-y-auto text-sm`,children:[(0,R.jsx)(`p`,{className:n(`text-xs`,j||!k.length?`font-semibold text-warning`:`text-muted-foreground`),children:ae(i?.pick)}),j?(0,R.jsxs)(`p`,{className:`inline-flex items-start gap-1.5 rounded-md bg-warning-background px-2 py-1.5 text-xs font-semibold text-warning`,children:[(0,R.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0`}),`你先前选的浏览器已不在本机候选清单(可能已卸载或路径变更),下方选择已回落到系统判定,请重选或清除。`]}):null,s?(0,R.jsx)(`p`,{className:`text-xs text-status-error`,children:s}):null,(0,R.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`打开地址用哪个浏览器`}),(0,R.jsxs)(f,{value:N,onValueChange:_,className:`grid gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-xs`,children:[(0,R.jsx)(u,{value:Q,id:`env-pref-system`}),(0,R.jsx)(`span`,{children:`跟随系统默认(本机探不到默认项时按候选次序)`})]}),k.map(e=>(0,R.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-xs`,children:[(0,R.jsx)(u,{value:e.id,id:`env-pref-`+e.id}),(0,R.jsx)(`span`,{children:e.name||e.bin}),(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:e.engine}),e.isDefault?(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`系统默认`}):null]},e.id))]}),k.length?(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(t,{size:`sm`,variant:`outline`,disabled:S||N===M,onClick:()=>void O(N===Q?``:N),children:`保存偏好`}),(0,R.jsx)(t,{size:`sm`,variant:`ghost`,disabled:S||M===Q,onClick:()=>void O(``),children:`清除`})]}):(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`候选为空:重新探测后仍为空时,请先在系统里安装或启用一个浏览器。`})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`出网条件(隔离登录窗口的分发依据)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.egress)}),A?.egress?.data?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs`,children:[(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`系统代理:`,G(A?.egress?.data?.proxy)]}),Object.entries(A?.egress?.data?.targets||{}).map(([e,t])=>(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`,K(t?.ok),t?.stage?`(停在 `+t.stage+(t.detail?` `+t.detail:``)+`)`:``]},e)),Object.keys(A?.egress?.data?.targets||{}).length?null:(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`还没有目标域被问过:一键登录时会当场判定并记在这里。`})]}):null,A?.egress?.data?.proxy?.state===`off`?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`没有在用系统代理时,直连不通的授权域只能靠现有浏览器窗口的既有出网路径打开(隔离冷档案会是空白页)。`}):null]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`运行时与 DSH(安装/升级动作的分发依据)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.runtime)}),A?.runtime?.data?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[U(A?.runtime?.data?.node),` · `,U(A?.runtime?.data?.npm),` · `,U(A?.runtime?.data?.git)]}),(0,R.jsxs)(`span`,{children:[`镜像源:`,A?.runtime?.data?.registry?.origin||`未读出`,A?.runtime?.data?.registry?.mode?`(`+A.runtime.data.registry.mode+`)`:``,` · 候选 `+(A?.runtime?.data?.registry?.candidates||[]).length+` 个`]}),(0,R.jsxs)(`span`,{className:`break-all`,children:[`全局前缀:`,A?.runtime?.data?.prefix||`未实测(npm root -g 未返回)`]})]}):null,(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`桌面壳所见(装内核时真正用的那一套,与上面的内核读数并排对照)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.shell)}),F?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:F.available===!0?`壳上报于 `+J(F.ageMs)+`,写入者 `+(F.writtenBy||`未署名`)+`(报告版本 `+(F.schema??`未读出`)+`)`:F.reason===`never-written`?`这台机器的壳还没报过:内核由命令行或别的进程拉起时这是常态,不是故障`:`壳报的文件读不出或版本不符(不是没写过,得查那个文件)`}),F.available===!0?(0,R.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,R.jsx)(`span`,{className:`break-all`,children:X(`Node:`,oe,F.node?.version)}),(0,R.jsx)(`span`,{className:`break-all`,children:X(`npm:`,$,F.npm?.version)}),(0,R.jsx)(`span`,{className:`break-all`,children:X(`镜像源:`,A?.runtime?.data?.registry?.origin,F.registry?.best)}),(0,R.jsx)(`span`,{className:`break-all`,children:X(`全局前缀:`,A?.runtime?.data?.prefix,F.prefix?.dir)}),F.node&&F.node.ok!==!0?(0,R.jsxs)(`span`,{children:[`壳判 Node 达标:`,Y(F.node.ok),`(`,F.node.version||`版本未报`,`,门槛 `,F.node.min||`未报`,`)`]}):null,F.prefix&&F.prefix.writable!==!0?(0,R.jsxs)(`span`,{className:`break-all`,children:[`壳判前缀可写:`,Y(F.prefix.writable),F.prefix.why?`(`+F.prefix.why+`)`:``]}):null,z.length||I?.best?(0,R.jsxs)(`span`,{className:`break-all`,children:[`壳的镜像源候选:`,z.map(e=>(e.url||`?`)+` `+K(e.ok)).join(`、`),typeof V==`number`?`(择优选中用时 `+V+` 毫秒)`:``,H>z.length?`(报告里共 `+H+` 个候选,此处只列前 `+z.length+` 个)`:``]}):null,B.length?(0,R.jsxs)(`span`,{children:[`壳的探测明细 `,B.length,` 条:`,B.slice(0,8).map(Z).join(`;`),B.length>8?`…其余见内核快照文件`:``,F.droppedRecords?`(报告送达时被截断 `+F.droppedRecords+` 条)`:``]}):null]}):null]}):null,(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.dsh)}),A?.dsh?.data?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[U(A?.dsh?.data?.dsh),` · `,U(A?.dsh?.data?.selfUpdate)]}),(0,R.jsxs)(`span`,{children:[`看护:`,A?.dsh?.data?.managed?`守卫托管`:`未托管`,A?.dsh?.data?.phase?` · `+A.dsh.data.phase:``]})]}):null]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-border/60 px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium`,children:`启动既成事实(守卫这一拍真的跑过什么)`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(A?.startup)}),P?(0,R.jsxs)(`div`,{className:`grid gap-0.5 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{children:[`守卫启动于 `,typeof P.bootAt==`number`?new Date(P.bootAt).toLocaleTimeString():`未读出`,`,环境表单首拍排在启动后 `,P.envDelayMs??`未读出`,` 毫秒`]}),(0,R.jsxs)(`span`,{children:[`选路:自动启动 `,Y(P.routerAutostart),`,模式 `,P.routerMode||`未读出(这一拍没走到那步)`]}),(0,R.jsxs)(`span`,{children:[`更新检查:`,P.updateCheck?P.updateCheck.enabled?`开(首查排在启动后 `+(P.updateCheck.initialDelayMs??`未读出`)+` 毫秒,之后每 `+(P.updateCheck.intervalMs??`未读出`)+` 毫秒)`:`关(配置里就禁掉了,这同样是一条既成事实)`:`未记录`]}),(0,R.jsxs)(`span`,{children:[`壳看护:`,Y(P.shellWatchdog)]}),(0,R.jsx)(`span`,{children:P.lastRefresh?`最近一次表单刷新于 `+(typeof P.lastRefresh.at==`number`?new Date(P.lastRefresh.at).toLocaleTimeString():`未读出`)+`,耗时 `+(P.lastRefresh.tookMs??`未读出`)+` 毫秒,浏览器 `+(P.lastRefresh.browsers??`未读出`)+` 个,分发依据 `+(P.lastRefresh.pick||`未定出`)+`,落盘 `+Y(P.lastRefresh.snapshotWritten)+`;`+ie(P.lastRefresh.dims):`这一拍还没跑过表单刷新(首拍排在上面那个延迟之后)`})]}):null]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`平台`}),(0,R.jsx)(`dd`,{className:`font-mono`,children:[i?.identity?.platform,i?.identity?.arch].filter(Boolean).join(` / `)||`—`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`图形会话`}),(0,R.jsx)(`dd`,{children:i?.session?.available?`可用(`+(i?.session?.reason||`—`)+`)`:`不可用(`+(i?.session?.reason||`—`)+`)`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`系统默认项`}),(0,R.jsx)(`dd`,{children:i?.default?i.default.id+`(来源 `+(i.default.source||`未读出`)+`)`:`未读出`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`候选`}),(0,R.jsx)(`dd`,{children:k.length?k.map(e=>(e.name||e.bin)+`[`+(e.sources||[]).join(`+`)+`]`).join(`、`):`无`}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`探测留痕`}),(0,R.jsx)(`dd`,{className:`grid gap-0.5`,children:(i?.probed??[]).map((e,t)=>(0,R.jsx)(`span`,{className:`text-muted-foreground/80`,children:q(e)},t))}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`快照落盘`}),(0,R.jsxs)(`dd`,{className:`break-all font-mono text-muted-foreground/80`,children:[ne(i?.snapshot,i?.cached===!0),(0,R.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` `,i?.snapshot?.path||`未给出路径`]})]}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`上一拍留痕`}),(0,R.jsx)(`dd`,{className:`text-muted-foreground`,children:re(te,T)})]})]}),(0,R.jsxs)(ee,{children:[(0,R.jsxs)(t,{variant:`outline`,disabled:y,onClick:()=>void D(!0),children:[(0,R.jsx)(x,{className:`size-4`}),y?`探测中…`:`重新探测`]}),(0,R.jsx)(t,{onClick:()=>r(!1),children:`关闭`})]})]})})]})}var $=new Set([`dist_registry_selected`,`gui_autostart_changed`,`autostart_changed`,`lan_panel_changed`,`lan_dsh_token_updated`]);function se(){let{snap:r}=p(),{busy:a,run:s}=D(),c=e(),[u,d]=(0,L.useState)(!1),[f,E]=(0,L.useState)(null),A=r.status,j=A?.native,N=j?.installed??!1,F=j?.state||(N?`installed`:`uninstalled`),z=F===`installing`,B=z||F===`uninstalling`,V=A?.version,U=A?.upgrade,W=w[A?.phase??``]??{label:A?.phase||`未知`,tone:`off`},G=!!A?.dshPid,K=U?.state===`running`,q=(0,L.useMemo)(()=>r.events.filter(e=>!$.has(e.type)),[r.events]);async function J(){await s(`dsh`,()=>G?l.lifecycleStop(`dsh`):l.lifecycleStart(`dsh`),{success:G?`正在停止 DSH…`:`正在启动 DSH…`})}async function Y(){await c({title:`停止 DSH?`,description:`主干 DeepSeek Harness 正在运行;停止会中断进行中的请求,远程访问同时不可用。`,confirmText:`停止 DSH`})&&await J()}async function X(){await s(`web`,()=>_(()=>l.instanceOpenWeb(`main`)).then(()=>void 0))}async function Z(){await s(`chk`,async()=>{let e=await l.nativeCheckUpdate();if(e?.ok===!1){i.error(e.error||`检测失败`);return}e?.updateAvailable&&e.latest?i.success(`发现新版本 `+e.latest+(e.installed?`(当前 `+e.installed+`),可一键升级`:``)):i.success(`已是最新版本`+(e.installed?`(`+e.installed+`)`:``))})}async function ne(){d(!1),await s(`upg`,()=>l.nativeUpgrade(),{success:`升级已开始,请耐心等待…`})}async function re(){await c({title:`在线安装最新版 DeepSeek Harness?`,description:`需数分钟,自动适配最快镜像源。`,confirmText:`安装`})&&await s(`inst`,()=>l.nativeInstall(),{success:`开始安装 DeepSeek Harness…`})}async function ie(){await c({title:`彻底卸载 DeepSeek Harness?`,description:`删除全部文件、数据、缓存与日志,不留残留。`,confirmText:`卸载 DSH`,tone:`destructive`})&&await s(`uni`,()=>l.nativeUninstall(),{success:`开始卸载…`})}(0,L.useEffect)(()=>{N&&l.instances().then(e=>{let t=e?.native?.guardian;typeof t==`boolean`&&E(t)}).catch(()=>{})},[N,A?.dshPid]);async function ae(){let e=f!==!0;await s(`gu`,()=>l.nativeSettings({guardian:e}).then(e=>{let t=e?.main?.guardian;return typeof t==`boolean`&&E(t),e}),{success:e?`已开启 DSH 进程守护(崩溃自动拉起)`:`已关闭 DSH 进程守护(崩溃后不再自动拉起)`,refresh:!1})}let Q=N&&(j?.version||V?.installed)||`—`;return(0,R.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,R.jsxs)(M,{children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-1 @min-[720px]:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-5 border-b border-border px-6 py-5 md:border-b-0 md:border-r`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`h3`,{className:`truncate text-xl font-semibold tracking-[-0.01em] text-foreground`,children:`DeepSeek Harness`}),(0,R.jsxs)(`span`,{className:`shrink-0 font-mono text-sm text-muted-foreground`,children:[`v`,Q]})]}),a===`chk`?(0,R.jsxs)(t,{size:`chip`,disabled:!0,children:[(0,R.jsx)(x,{className:`size-3 animate-spin`}),`检测中…`]}):V?.updateAvailable&&V.latest?(0,R.jsxs)(t,{className:`text-primary-foreground`,size:`chip`,onClick:()=>d(!0),children:[(0,R.jsx)(P,{className:`size-3`}),`升级到 v`,V.latest]}):K?(0,R.jsxs)(t,{size:`chip`,disabled:!0,children:[(0,R.jsx)(x,{className:`size-3 animate-spin`}),`升级中…`]}):(0,R.jsxs)(t,{className:`bg-primary/10 text-primary hover:bg-primary/15`,onClick:()=>void Z(),size:`chip`,variant:`ghost`,children:[(0,R.jsx)(x,{className:`size-3`}),`检测更新`]})]}),B?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(O,{tone:`boot`,ping:!0}),(0,R.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:z?`正在安装 DeepSeek Harness…`:`正在卸载 DeepSeek Harness…`})]}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(O,{tone:W.tone,ping:W.tone===`ok`}),(0,R.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:W.label})]}),K&&U?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-primary`}),`正在升级(`,U.step||U.targetVersion||``,`)…`]}):null,U?.state===`failed`?(0,R.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`升级失败:`,U.lastError||`未知原因`,U.rolledBack?`(已回滚)`:``]}):null,B&&(j?.installLog??[]).length?(0,R.jsx)(`pre`,{className:`max-h-[120px] overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/70 p-3 font-mono text-xs leading-relaxed text-muted-foreground`,children:(j?.installLog??[]).slice(-6).join(`
2
+ `)}):null]}),(0,R.jsx)(`div`,{className:`flex items-center bg-[image:var(--panel-accent-gradient)] px-6 py-5`,children:(0,R.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-x-6 gap-y-4 @min-[560px]:grid-cols-4`,children:[(0,R.jsx)(k,{icon:(0,R.jsx)(te,{className:`size-4`}),label:`端口`,value:A?.dshPort?String(A.dshPort):`—`,mono:!0}),(0,R.jsx)(k,{icon:(0,R.jsx)(I,{className:`size-4`}),label:`PID`,value:A?.dshPid?String(A.dshPid):`—`,mono:!0}),(0,R.jsx)(k,{icon:(0,R.jsx)(x,{className:`size-4`}),label:`重启次数`,value:String(A?.restartCount??0),mono:!0}),(0,R.jsx)(k,{icon:(0,R.jsx)(P,{className:`size-4`}),label:`最近故障`,value:A?.lastFailure?T(A?.lastFailure):`无`,warn:!!A?.lastFailure})]})})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-border/60 px-6 py-3`,children:[(0,R.jsx)(`div`,{className:`hidden lg:block`,children:(0,R.jsx)(ce,{})}),(0,R.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[!N&&!B?(0,R.jsxs)(t,{size:`sm`,disabled:a===`inst`,onClick:()=>void re(),children:[(0,R.jsx)(b,{className:`size-4`}),`安装 DSH`]}):N&&!B&&!K?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(t,{disabled:!G,onClick:()=>void X(),size:`sm`,variant:`outline`,className:`hidden md:inline-flex`,children:[(0,R.jsx)(v,{className:`size-4`}),`DSH Web`]}),(0,R.jsx)(t,{disabled:a===`dsh`,onClick:()=>void(G?Y():J()),size:`sm`,variant:`outline`,children:G?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(y,{className:`size-4 text-status-error`}),`停止 DSH`]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(b,{className:`size-4 text-primary`}),`启动 DSH`]})}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,R.jsxs)(t,{className:`h-[30px]`,disabled:a===`gu`||f===null,onClick:()=>void ae(),size:`sm`,variant:`outline`,children:[(0,R.jsx)(S,{className:n(`size-4`,f===!0?`text-status-ok`:`text-muted-foreground`)}),f===!0?`停止守护`:`启动守护`]})]}):null,N&&!B?(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(t,{className:`hidden h-[30px] md:inline-flex`,disabled:a===`uni`,onClick:()=>void ie(),size:`sm`,variant:`destructive`,children:[(0,R.jsx)(C,{className:`size-4`}),`卸载 DSH`]})}):null]})]})]}),(0,R.jsxs)(`div`,{className:`grid items-start gap-4 @min-[860px]:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,R.jsx)(le,{events:q}),(0,R.jsx)(H,{providers:r.providers?.providers??[]})]}),(0,R.jsx)(m,{open:u,onOpenChange:d,children:(0,R.jsxs)(g,{className:`max-w-[420px]`,children:[(0,R.jsx)(h,{children:(0,R.jsx)(o,{children:`升级 DeepSeek Harness`})}),(0,R.jsxs)(`div`,{className:`grid gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-3 rounded-md bg-muted px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`当前版本`}),(0,R.jsx)(`strong`,{className:`font-mono text-base text-foreground`,children:V?.installed||Q})]}),(0,R.jsx)(P,{className:`size-4 text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`新版本`}),(0,R.jsx)(`strong`,{className:`font-mono text-base text-primary`,children:V?.latest||`—`})]})]}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`升级将先停止 DSH、安装新版本后自动拉起(需数分钟)。期间进行中的请求会中断,失败会自动回滚到当前版本。`})]}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(t,{onClick:()=>d(!1),variant:`outline`,children:`取消`}),(0,R.jsx)(t,{disabled:a===`upg`||K,onClick:()=>void ne(),children:a===`upg`||K?`升级中…`:`开始升级`})]})]})})]})}function ce(){let[e,t]=(0,L.useState)(null),[r,i]=(0,L.useState)(null);(0,L.useEffect)(()=>{let e=!0,n=async()=>{let[n,r]=await Promise.all([l.nodeLts().catch(()=>null),l.envStatus().catch(()=>null)]);e&&(t(n),i(r?.catalog?.items??null))};n();let r=setInterval(n,6e5);return()=>{e=!1,clearInterval(r)}},[]);let a=Object.entries(r??{}).filter(([,e])=>e.required);return!e?.current&&a.length===0?(0,R.jsx)(`span`,{className:`min-w-[120px] text-xs text-muted-foreground`,children:`环境检测…`}):(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:`环境检测`}),a.map(([e,t])=>{let r=t.state===`ok`||t.state===`configured`;return(0,R.jsxs)(`span`,{title:t.detail||void 0,className:n(`inline-flex items-center gap-1 whitespace-nowrap rounded-full px-2 py-0.5`,r?`text-muted-foreground/70`:`bg-warning-background font-semibold text-warning`),children:[!r&&(0,R.jsx)(d,{className:`size-3`}),t.label,` `,t.detail||`—`]},e)}),(0,R.jsx)(oe,{}),e?.ltsLine===!1?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap rounded-full bg-warning-background px-2 py-0.5 font-semibold text-warning`,title:e.suggested||void 0,children:[(0,R.jsx)(d,{className:`size-3`}),`非 LTS 线(建议偶数主版本)`]}):e?.ltsLine===!0?(0,R.jsx)(`span`,{className:`hidden whitespace-nowrap text-muted-foreground/70 sm:inline`,children:`LTS 线`}):null]})}function le({events:e}){let[t,n]=(0,L.useState)(12),r=e.length;(0,L.useEffect)(()=>{n(12)},[e]);let i=(0,L.useRef)(null),a=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let e=i.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(a.current||(a.current=!0,n(e=>Math.min(e+12,r)),setTimeout(()=>{a.current=!1},80)))},{rootMargin:`120px 0px`});return t.observe(e),()=>t.disconnect()},[r]);let o=e.slice(0,t),s=t<r;return(0,R.jsxs)(M,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,R.jsx)(A,{title:`事件日志`,subtitle:`核心运行状态遥测`,actions:(0,R.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:r})}),r?(0,R.jsxs)(`div`,{className:`flex max-h-[450px] min-h-0 flex-col overflow-y-auto overscroll-contain`,children:[o.map((e,t)=>(0,R.jsx)(ue,{e},e.seq??t)),(0,R.jsx)(`div`,{ref:i,className:`px-5 py-2 text-center text-[11px] text-muted-foreground`,children:s?`下滑加载更多…`:`已加载全部`})]}):(0,R.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`暂无核心运行状态事件`})]})}function ue({e}){let t=fe[e.type]??`boot`,n=E[e.type]??e.type,r=de(e);return(0,R.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[64px_auto_minmax(0,1fr)] items-center gap-2.5 border-b border-border/60 px-5 py-2 last:border-b-0 max-[640px]:grid-cols-[56px_auto_minmax(0,1fr)] max-[640px]:gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:N(e.ts)}),(0,R.jsx)(j,{tone:t,children:n}),(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]})}function de(e){let t=e.data;if(!t)return``;let n=e=>Number(e??0).toLocaleString(`en-US`);if(typeof t.message==`string`)return t.message;if(typeof t.reason==`string`)return T(t.reason);if(typeof t.desired==`string`)return`期望 `+t.desired;if(e.type===`router_usage`)return(t.model||``)+(t.model?` · `:``)+n(t.tokens)+` tokens`;if(e.type===`router_pick`)return[t.provider||``,t.key||``].filter(Boolean).join(` · `);if(e.type===`account_ready`||e.type===`account_frozen`||e.type===`account_banned`||e.type===`account_recovered`||e.type===`account_review`||e.type===`account_exhausted`)return(t.key||``)+(t.key?` · `:``)+(t.provider||``);if(e.type===`provider_quota_refreshed`)return(t.provider||``)+` 额度已刷新`;if(e.type===`proxy_update_available`)return[t.pkg||``,t.from||``,t.to||``].filter(Boolean).join(` → `);if(e.type===`proxy_instance_started`)return`port=`+(t.port??``)+(t.pid?` pid=`+t.pid:``);if(e.type===`dsh_guardian_changed`||e.type===`inst_guardian_changed`)return(t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`))+` · 进程守护`+(t.enabled===!0?` → 开启`:` → 关闭`);if(e.type===`dsh_remote_changed`||e.type===`inst_remote_changed`)return(t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`))+` · 远程控制 → `+(t.mode===`lan`?`局域网`:t.mode===`wan`?`公网`:`关闭`);if(e.type===`dsh_remote_token_changed`||e.type===`inst_remote_token_changed`)return(t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`))+` · 访问令牌`+(t.tokenSet===!0?` → 已设置`:` → 已清除`);let r=[];return t.pid!==void 0&&r.push(`pid=`+t.pid),t.port!==void 0&&r.push(`port=`+String(t.port)),t.version!==void 0&&r.push(`v`+String(t.version)),t.model&&t.tokens!==void 0&&r.push(n(t.tokens)+` tok`),t.ms!==void 0&&r.push(n(t.ms)+`ms`),r.join(` · `)}var fe={running:`ok`,adopted:`ok`,spawned:`ok`,main_instance_registered:`ok`,upgrade_installed:`ok`,upgrade_done:`ok`,api_listening:`ok`,account_ready:`ok`,account_confirmed:`ok`,account_recovered:`ok`,proxy_instance_started:`ok`,proxy_update_applied:`ok`,router_provider_activated:`ok`,router_provider_endpoint:`ok`,inst_running:`ok`,inst_added:`ok`,inst_started:`ok`,lan_instance_started:`ok`,frpc_installed:`ok`,frpc_started:`ok`,plugin_install_done:`ok`,native_installed:`ok`,inst_upgraded:`ok`,plugin_update_done:`ok`,account_frozen:`err`,account_banned:`err`,dsh_exited:`err`,unhealthy:`err`,spawn_failed:`err`,spawn_error:`err`,upgrade_failed:`err`,api_error:`err`,api_offline:`err`,proxy_instance_failed:`err`,inst_failed:`err`,inst_start_failed:`err`,native_install_failed:`err`,native_uninstall_failed:`err`,plugin_install_job_failed:`err`,plugin_update_job_failed:`err`,plugin_uninstall_job_failed:`err`,frpc_install_failed:`err`,router_stream_aborted:`err`,sigkill_sent:`err`,start_timeout:`err`,crash_loop_entered:`err`,guard_exit:`warn`,version_check_failed:`warn`,restart_triggered:`warn`,dsh_not_installed:`warn`,sigterm_sent:`warn`,account_review:`warn`,dsh_guardian_changed:`warn`,inst_guardian_changed:`warn`,dsh_remote_changed:`warn`,inst_remote_changed:`warn`,dsh_remote_token_changed:`warn`,inst_remote_token_changed:`warn`,lan_frp_blocked:`warn`,proxy_update_available:`warn`,upgrade_started:`warn`,upgrade_stopping_dsh:`warn`,inst_restarted:`warn`,native_uninstall_started:`warn`,account_discarded:`off`,router_stopped:`off`,proxy_instance_stopped:`off`,inst_stopped:`off`,inst_removed:`off`,lan_instance_removed:`off`,frpc_stopped:`off`,plugin_uninstall_done:`off`,native_uninstalled:`off`,upgrade_skipped:`off`,router_provider_deactivated:`off`,stop:`off`};export{se as OverviewPage};