@dsh-sup/dsh-core-linux-x64 0.1.1-BETA.1

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.
Files changed (69) hide show
  1. package/README.md +9 -0
  2. package/bin/dsh-supervisor +0 -0
  3. package/package.json +26 -0
  4. package/ui-react/assets/InstancesPage-4OWacAkY.js +3 -0
  5. package/ui-react/assets/LanPage-C-TE6T23.js +4 -0
  6. package/ui-react/assets/OverviewPage-B_mlgkxf.js +2 -0
  7. package/ui-react/assets/PluginsPage-D0bs9E1H.js +5 -0
  8. package/ui-react/assets/RouterPage-DRhjxkNO.js +1 -0
  9. package/ui-react/assets/SettingsPage-C1yR8ZsG.js +1 -0
  10. package/ui-react/assets/TasksPage-CYhldFne.js +2 -0
  11. package/ui-react/assets/external-link-DblibQpb.js +1 -0
  12. package/ui-react/assets/format-QeaTKFhQ.js +1 -0
  13. package/ui-react/assets/inter-400-C38fXH4l.woff2 +0 -0
  14. package/ui-react/assets/inter-500-Cerq10X2.woff2 +0 -0
  15. package/ui-react/assets/inter-600-LgqL8muc.woff2 +0 -0
  16. package/ui-react/assets/inter-700-Yt3aPRUw.woff2 +0 -0
  17. package/ui-react/assets/noto-sans-sc-400-68UKsrZK.woff2 +0 -0
  18. package/ui-react/assets/noto-sans-sc-700-BiGzk9PQ.woff2 +0 -0
  19. package/ui-react/assets/refresh-cw-Dbn7zlS9.js +1 -0
  20. package/ui-react/assets/rocket-BDT9yN5c.js +1 -0
  21. package/ui-react/assets/supervisor-BnpEWxJX.css +2 -0
  22. package/ui-react/assets/supervisor-C3UXEQbW.js +10 -0
  23. package/ui-react/assets/supervisor-DEHXL51C.js +41 -0
  24. package/ui-react/assets/supervisor-hG2-v7mV.css +1 -0
  25. package/ui-react/assets/useSupervisorAction-Dj_nAGhv.js +1 -0
  26. package/ui-react/assets/widgets-C6MCpT1T.js +1 -0
  27. package/ui-react/dsh-logo.svg +1 -0
  28. package/ui-react/supervisor.html +116 -0
  29. package/ui-react/ui-react/assets/InstancesPage-4OWacAkY.js +3 -0
  30. package/ui-react/ui-react/assets/InstancesPage-C_FtBIyq.js +3 -0
  31. package/ui-react/ui-react/assets/LanPage-C-TE6T23.js +4 -0
  32. package/ui-react/ui-react/assets/LanPage-Cgg5RPIb.js +4 -0
  33. package/ui-react/ui-react/assets/OverviewPage-B_mlgkxf.js +2 -0
  34. package/ui-react/ui-react/assets/OverviewPage-CZfSq0px.js +2 -0
  35. package/ui-react/ui-react/assets/PluginsPage-D0bs9E1H.js +5 -0
  36. package/ui-react/ui-react/assets/PluginsPage-DadI4bCs.js +5 -0
  37. package/ui-react/ui-react/assets/RouterPage-DRhjxkNO.js +1 -0
  38. package/ui-react/ui-react/assets/RouterPage-dD81cNBC.js +1 -0
  39. package/ui-react/ui-react/assets/SettingsPage-C1yR8ZsG.js +1 -0
  40. package/ui-react/ui-react/assets/SettingsPage-C4mUOQJg.js +1 -0
  41. package/ui-react/ui-react/assets/TasksPage-COzDe_fT.js +2 -0
  42. package/ui-react/ui-react/assets/TasksPage-CYhldFne.js +2 -0
  43. package/ui-react/ui-react/assets/external-link-DblibQpb.js +1 -0
  44. package/ui-react/ui-react/assets/external-link-DfAIHbhS.js +1 -0
  45. package/ui-react/ui-react/assets/format-QeaTKFhQ.js +1 -0
  46. package/ui-react/ui-react/assets/inter-400-C38fXH4l.woff2 +0 -0
  47. package/ui-react/ui-react/assets/inter-500-Cerq10X2.woff2 +0 -0
  48. package/ui-react/ui-react/assets/inter-600-LgqL8muc.woff2 +0 -0
  49. package/ui-react/ui-react/assets/inter-700-Yt3aPRUw.woff2 +0 -0
  50. package/ui-react/ui-react/assets/noto-sans-sc-400-68UKsrZK.woff2 +0 -0
  51. package/ui-react/ui-react/assets/noto-sans-sc-700-BiGzk9PQ.woff2 +0 -0
  52. package/ui-react/ui-react/assets/refresh-cw-Dbn7zlS9.js +1 -0
  53. package/ui-react/ui-react/assets/refresh-cw-Dl1i4xVh.js +1 -0
  54. package/ui-react/ui-react/assets/rocket-BDT9yN5c.js +1 -0
  55. package/ui-react/ui-react/assets/rocket-KILE2qPr.js +1 -0
  56. package/ui-react/ui-react/assets/shield-check-CKBb6VBo.js +1 -0
  57. package/ui-react/ui-react/assets/supervisor-05X9PT9U.js +41 -0
  58. package/ui-react/ui-react/assets/supervisor-BnpEWxJX.css +2 -0
  59. package/ui-react/ui-react/assets/supervisor-C3UXEQbW.js +10 -0
  60. package/ui-react/ui-react/assets/supervisor-CKm4a1yh.js +10 -0
  61. package/ui-react/ui-react/assets/supervisor-DEHXL51C.js +41 -0
  62. package/ui-react/ui-react/assets/supervisor-DoAb2I7j.css +2 -0
  63. package/ui-react/ui-react/assets/supervisor-hG2-v7mV.css +1 -0
  64. package/ui-react/ui-react/assets/useSupervisorAction-CPqt8YnP.js +1 -0
  65. package/ui-react/ui-react/assets/useSupervisorAction-Dj_nAGhv.js +1 -0
  66. package/ui-react/ui-react/assets/widgets-C1m9qxfG.js +1 -0
  67. package/ui-react/ui-react/assets/widgets-C6MCpT1T.js +1 -0
  68. package/ui-react/ui-react/dsh-logo.svg +1 -0
  69. package/ui-react/ui-react/supervisor.html +27 -0
@@ -0,0 +1,116 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/dsh-logo.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>dsh-supervisor · 控制面板</title>
8
+ <style>
9
+ /* 品牌启动壳(内联:须在任何 JS 之前可见;React 挂载后即被替换)。
10
+ 资源一致性由架构保证:HTML no-store + 资源内容哈希 + 宿主每次重新导航,
11
+ 因此这里不需要任何"自愈/强制刷新"脚本。 */
12
+ :root {
13
+ font-family: Inter, "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
14
+ color: #171717;
15
+ background: transparent;
16
+ }
17
+ * { box-sizing: border-box; }
18
+ html, body, #root { width: 100%; height: 100%; height: 100dvh; }
19
+ body {
20
+ margin: 0;
21
+ min-width: 320px;
22
+ min-height: 100vh;
23
+ min-height: 100dvh;
24
+ overflow: hidden;
25
+ background: transparent;
26
+ user-select: none;
27
+ -webkit-user-select: none;
28
+ }
29
+ .startup-shell {
30
+ display: grid;
31
+ width: 100%;
32
+ height: 100%;
33
+ place-items: center;
34
+ overflow: hidden;
35
+ background:
36
+ radial-gradient(circle at 50% 38%, rgb(47 84 235 / 10%), transparent 30%),
37
+ #FAFBFC;
38
+ }
39
+ .startup-brand { display: grid; justify-items: center; gap: 18px; width: min(280px, calc(100% - 48px)); }
40
+ .startup-logo {
41
+ position: relative;
42
+ display: grid;
43
+ width: 64px;
44
+ height: 64px;
45
+ place-items: center;
46
+ border: 1px solid rgb(47 84 235 / 14%);
47
+ border-radius: 999px;
48
+ background: linear-gradient(145deg, rgb(255 255 255 / 96%), rgb(239 245 242 / 92%));
49
+ box-shadow: 0 18px 42px rgb(15 23 42 / 10%), inset 0 1px 0 rgb(255 255 255 / 90%);
50
+ color: #2F54EB;
51
+ }
52
+ .startup-logo::after {
53
+ position: absolute;
54
+ inset: -7px;
55
+ content: "";
56
+ border-radius: 999px;
57
+ border: 2px solid rgb(47 84 235 / 10%);
58
+ border-top-color: #2F54EB;
59
+ animation: startup-spin 960ms linear infinite;
60
+ }
61
+ .startup-logo-image {
62
+ width: 42px;
63
+ height: 42px;
64
+ background: currentColor;
65
+ mask: url("/dsh-logo.svg") center / contain no-repeat;
66
+ -webkit-mask: url("/dsh-logo.svg") center / contain no-repeat;
67
+ }
68
+ .startup-copy { display: grid; gap: 7px; justify-items: center; text-align: center; }
69
+ .startup-name { color: #0F1115; font-size: 22px; font-weight: 760; line-height: 1; }
70
+ .startup-status { color: #6b747d; font-size: 13px; line-height: 1.4; }
71
+ .startup-progress {
72
+ position: relative;
73
+ width: 100%;
74
+ height: 3px;
75
+ margin-top: 4px;
76
+ overflow: hidden;
77
+ border-radius: 999px;
78
+ background: #DDE3EC;
79
+ }
80
+ .startup-progress::after {
81
+ display: block;
82
+ width: 42%;
83
+ height: 100%;
84
+ content: "";
85
+ animation: startup-progress 1.15s ease-in-out infinite;
86
+ border-radius: inherit;
87
+ background: #2F54EB;
88
+ }
89
+ @keyframes startup-spin { to { transform: rotate(360deg); } }
90
+ @keyframes startup-progress {
91
+ 0% { transform: translateX(-120%); }
92
+ 100% { transform: translateX(260%); }
93
+ }
94
+ </style>
95
+ <script type="module" crossorigin src="/assets/supervisor-C3UXEQbW.js"></script>
96
+ <link rel="modulepreload" crossorigin href="/assets/supervisor-DEHXL51C.js">
97
+ <link rel="stylesheet" crossorigin href="/assets/supervisor-hG2-v7mV.css">
98
+ <link rel="stylesheet" crossorigin href="/assets/supervisor-BnpEWxJX.css">
99
+ </head>
100
+ <body>
101
+ <div id="root">
102
+ <main class="startup-shell" aria-label="dsh-supervisor 正在启动">
103
+ <section class="startup-brand">
104
+ <div class="startup-logo" aria-hidden="true">
105
+ <span class="startup-logo-image"></span>
106
+ </div>
107
+ <div class="startup-copy">
108
+ <strong class="startup-name">DSH-SUP</strong>
109
+ <span class="startup-status">正在连接守卫服务…</span>
110
+ </div>
111
+ <div class="startup-progress" aria-hidden="true"></div>
112
+ </section>
113
+ </main>
114
+ </div>
115
+ </body>
116
+ </html>
@@ -0,0 +1,3 @@
1
+ import{A as e,C as t,D as n,M as r,S as i,_ as a,a as o,b as s,d as c,f as l,g as u,h as d,m as f,n as p,p as m,r as h,t as g,w as _,y as v}from"./supervisor-DEHXL51C.js";import{t as y}from"./external-link-DblibQpb.js";import{n as b,t as x}from"./rocket-BDT9yN5c.js";import{c as S,f as C,o as w,s as T}from"./supervisor-C3UXEQbW.js";import{t as E}from"./useSupervisorAction-Dj_nAGhv.js";import{c as D,i as O,o as k,r as A,t as j}from"./widgets-C6MCpT1T.js";var M=n(`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`}]]),N=n(`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`}]]),P=n(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),F=n(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=r(e(),1),L=i();function R({onRegisterActions:e}){let{snap:n}=g(),{busy:r,run:i}=E(),[R,z]=(0,I.useState)(!1),[B,V]=(0,I.useState)(null),[H,U]=(0,I.useState)(``),[W,G]=(0,I.useState)(``),[K,q]=(0,I.useState)(``),[J,Y]=(0,I.useState)(`4G`),[X,Z]=(0,I.useState)(`150%`),Q=n.instances?.instances??[];(0,I.useEffect)(()=>(e?.({onAdd:()=>z(!0)}),()=>e?.(null)),[e]);let $=(e,t)=>i(e,t);async function ee(){let e=parseInt(W,10);if(!Number.isFinite(e)||e<=0){t.error(`请填写有效端口`);return}let n=K?K.split(/\n/).map(e=>e.trim()).filter(Boolean):[];try{let r=await h.instanceAdd({name:H.trim()||`沙箱 `+e,port:e,command:n,memoryMax:J||`4G`,cpuQuota:X||`150%`});if(r&&r.ok===!1){t.error(r.error||`添加失败`);return}t.success(`已添加实例`),z(!1),U(``),G(``),q(``),Y(`4G`),Z(`150%`),p.refresh()}catch(e){t.error(String(e))}}async function te(e){await i(e.id,async()=>{let n=await h.instanceCheckUpdate(e.id);n.updateAvailable?(t.success(`发现新版 `+n.latest+`,可点「更新」升级`),re(t=>new Map(t).set(e.id,!0))):n.latest?t.info(`已是最新 `+n.latest):t.error(n.error||`版本检测失败`)})}let[ne,re]=(0,I.useState)(new Map);async function ie(e){confirm(`将升级该沙箱实例的 DSH 到最新版(实例会短暂重启,进行中的请求中断)。确定升级?`)&&await i(e.id,()=>h.instanceUpgrade(e.id),{success:`升级已开始…`})}let ae=({it:e})=>{let t=e.state?.running??!1,n=e.state?.lifecyclePhase,i=T(n,t),a=e.updateJob,c=a?.state===`running`,l=e.sandbox?.memoryMax||`—`,u=e.sandbox?.cpuQuota||`—`,d=r===e.id;return(0,L.jsxs)(j,{className:`overflow-visible`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md: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]}),ne.get(e.id)?(0,L.jsxs)(v,{className:`text-primary-foreground`,onClick:()=>void ie(e),size:`chip`,children:[(0,L.jsx)(N,{className:`size-3`}),`更新`]}):(0,L.jsxs)(v,{className:`bg-primary/10 text-primary hover:bg-primary/15`,disabled:d||c,onClick:()=>void te(e),size:`chip`,variant:`ghost`,children:[(0,L.jsx)(N,{className:s(`size-3`,d&&`animate-spin`)}),`检测更新`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(D,{tone:i.tone,ping:i.tone===`ok`}),(0,L.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:i.label})]}),c?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(o,{className:`size-3`}),`正在升级 DeepSeek Harness(`,a?.step||``,`)…`]}):null,e.state?.installing?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(o,{className:`size-3`}),`正在安装…`]}):null,n===`FAILED`?(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,children:[(0,L.jsx)(_,{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)(O,{icon:(0,L.jsx)(C,{className:`size-4`}),label:`端口`,value:String(e.port),mono:!0}),(0,L.jsx)(O,{icon:(0,L.jsx)(F,{className:`size-4`}),label:`PID`,value:e.state?.pid?String(e.state.pid):`—`,mono:!0}),(0,L.jsx)(O,{icon:(0,L.jsx)(N,{className:`size-4`}),label:`重启次数`,value:String(e.state?.restartCount??0),mono:!0}),(0,L.jsx)(O,{icon:(0,L.jsx)(_,{className:`size-4`}),label:`最近故障`,value:e.state?.lastFailure?w(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:`inline-flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(A,{domain:`sandbox`}),(0,L.jsx)(k,{tone:e.remoteEnabled?`boot`:`off`,children:e.remoteEnabled?`远程开启`:`远程关闭`}),(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`内存 `,l,` · CPU `,u]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsxs)(v,{disabled:!t,onClick:()=>void $(e.id,()=>h.instanceOpenWeb(e.id)),size:`sm`,title:`打开 DSH Web(自动带认证连接)`,variant:`outline`,children:[(0,L.jsx)(y,{className:`size-4`}),`DSH Web`]}),(0,L.jsx)(v,{disabled:c,onClick:()=>void $(e.id,()=>t?h.instanceStop(e.id):h.instanceStart(e.id)),size:`sm`,variant:`outline`,children:t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{className:`size-4 text-status-error`}),`停止实例`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(x,{className:`size-4 text-primary`}),`启动实例`]})}),(0,L.jsxs)(v,{disabled:d,onClick:()=>void $(e.id,()=>h.instanceUpdate(e.id,{guardian:!e.guardian})),size:`sm`,variant:`outline`,children:[(0,L.jsx)(P,{className:s(`size-4`,e.guardian?`text-status-ok`:`text-muted-foreground`)}),e.guardian?`停止守护`:`启动守护`]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,L.jsxs)(v,{className:`h-[30px]`,disabled:d,onClick:()=>V(e.id),size:`sm`,variant:`destructive`,children:[(0,L.jsx)(S,{className:`size-4`}),`删除`]})]})]})]})};return(0,L.jsxs)(`div`,{className:`grid content-start gap-4`,children:[Q.length?(0,L.jsx)(`div`,{className:`grid gap-3`,children:Q.map(e=>(0,L.jsx)(ae,{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)(M,{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:`点击顶部「添加实例」创建沙箱`})]})}),(0,L.jsx)(m,{open:R,onOpenChange:z,children:(0,L.jsxs)(f,{className:`max-w-[440px]`,children:[(0,L.jsx)(u,{children:(0,L.jsx)(a,{children:`添加 DSH 实例`})}),(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(c,{children:`实例名称`}),(0,L.jsx)(l,{placeholder:`如 沙箱二开`,value:H,onChange:e=>U(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(c,{children:`监听端口`}),(0,L.jsx)(l,{inputMode:`numeric`,placeholder:`如 3082`,value:W,onChange:e=>G(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(c,{children:`启动命令(每项一参数,可留空用默认)`}),(0,L.jsx)(`textarea`,{className:`min-h-[72px] w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20`,placeholder:`node
2
+ /home/bowen/.npm-global/bin/dsh
3
+ web`,value:K,onChange:e=>q(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(c,{children:`内存限额`}),(0,L.jsx)(l,{placeholder:`如 4G`,value:J,onChange:e=>Y(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(c,{children:`CPU 配额`}),(0,L.jsx)(l,{placeholder:`如 150%`,value:X,onChange:e=>Z(e.target.value)})]})]})]}),(0,L.jsxs)(d,{children:[(0,L.jsx)(v,{onClick:()=>z(!1),variant:`outline`,children:`取消`}),(0,L.jsx)(v,{onClick:()=>void ee(),children:`添加`})]})]})}),(0,L.jsx)(m,{open:!!B,onOpenChange:e=>!e&&V(null),children:(0,L.jsxs)(f,{className:`max-w-[380px]`,children:[(0,L.jsx)(u,{children:(0,L.jsx)(a,{children:`删除实例?`})}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`将彻底删除该沙箱实例(含配置与运行时数据)。此操作不可恢复。`}),(0,L.jsxs)(d,{children:[(0,L.jsx)(v,{onClick:()=>V(null),variant:`outline`,children:`取消`}),(0,L.jsx)(v,{className:`h-[34px]`,onClick:()=>{B&&$(B,()=>h.instanceRemove(B)),V(null)},variant:`destructive`,children:`删除`})]})]})})]})}export{R as InstancesPage};
@@ -0,0 +1,3 @@
1
+ import{A as e,E as t,L as n,O as r,P as i,T as a,_ as o,b as s,g as c,h as l,i as u,k as d,m as f,n as p,o as m,r as h,t as g,v as _,y as v,z as y}from"./supervisor-05X9PT9U.js";import{t as b}from"./external-link-DfAIHbhS.js";import{n as x,t as S}from"./rocket-KILE2qPr.js";import{t as ee}from"./shield-check-CKBb6VBo.js";import{c as C,f as w,o as T,s as E}from"./supervisor-CKm4a1yh.js";import{t as D}from"./useSupervisorAction-CPqt8YnP.js";import{c as O,i as k,o as A,r as j,t as M}from"./widgets-C1m9qxfG.js";var N=i(`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=i(`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=i(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=y(n(),1),L=r();function R({onRegisterActions:n}){let{snap:r}=g(),{busy:i,run:y}=D(),[R,z]=(0,I.useState)(!1),[B,V]=(0,I.useState)(null),[H,U]=(0,I.useState)(``),[W,G]=(0,I.useState)(``),[K,q]=(0,I.useState)(``),[J,Y]=(0,I.useState)(`4G`),[X,Z]=(0,I.useState)(`150%`),Q=r.instances?.instances??[];(0,I.useEffect)(()=>(n?.({onAdd:()=>z(!0)}),()=>n?.(null)),[n]);let $=(e,t)=>y(e,t);async function te(){let e=parseInt(W,10);if(!Number.isFinite(e)||e<=0){d.error(`请填写有效端口`);return}let t=K?K.split(/\n/).map(e=>e.trim()).filter(Boolean):[];try{let n=await h.instanceAdd({name:H.trim()||`沙箱 `+e,port:e,command:t,memoryMax:J||`4G`,cpuQuota:X||`150%`});if(n&&n.ok===!1){d.error(n.error||`添加失败`);return}d.success(`已添加实例`),z(!1),U(``),G(``),q(``),Y(`4G`),Z(`150%`),p.refresh()}catch(e){d.error(String(e))}}async function ne(e){await y(e.id,async()=>{let t=await h.instanceCheckUpdate(e.id);t.updateAvailable?(d.success(`发现新版 `+t.latest+`,可点「更新」升级`),ie(t=>new Map(t).set(e.id,!0))):t.latest?d.info(`已是最新 `+t.latest):d.error(t.error||`版本检测失败`)})}let[re,ie]=(0,I.useState)(new Map);async function ae(e){confirm(`将升级该沙箱实例的 DSH 到最新版(实例会短暂重启,进行中的请求中断)。确定升级?`)&&await y(e.id,()=>h.instanceUpgrade(e.id),{success:`升级已开始…`})}let oe=({it:n})=>{let r=n.state?.running??!1,o=n.state?.lifecyclePhase,s=E(o,r),c=n.updateJob,l=c?.state===`running`,u=n.sandbox?.memoryMax||`—`,d=n.sandbox?.cpuQuota||`—`,f=i===n.id;return(0,L.jsxs)(M,{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:n.name}),n.version?(0,L.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:[`v`,n.version]}):null]}),re.get(n.id)?(0,L.jsxs)(a,{className:`text-primary-foreground`,onClick:()=>void ae(n),size:`chip`,children:[(0,L.jsx)(P,{className:`size-3`}),`更新`]}):(0,L.jsxs)(a,{className:`bg-primary/10 text-primary hover:bg-primary/15`,disabled:f||l,onClick:()=>void ne(n),size:`chip`,variant:`ghost`,children:[(0,L.jsx)(P,{className:t(`size-3`,f&&`animate-spin`)}),`检测更新`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(O,{tone:s.tone,ping:s.tone===`ok`}),(0,L.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:s.label})]}),l?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(m,{className:`size-3`}),`正在升级 DeepSeek Harness(`,c?.step||``,`)…`]}):null,n.state?.installing?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(m,{className:`size-3`}),`正在安装…`]}):null,o===`FAILED`?(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-destructive`,children:[(0,L.jsx)(e,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`truncate`,children:n.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)(k,{icon:(0,L.jsx)(w,{className:`size-4`}),label:`端口`,value:String(n.port),mono:!0}),(0,L.jsx)(k,{icon:(0,L.jsx)(F,{className:`size-4`}),label:`PID`,value:n.state?.pid?String(n.state.pid):`—`,mono:!0}),(0,L.jsx)(k,{icon:(0,L.jsx)(P,{className:`size-4`}),label:`重启次数`,value:String(n.state?.restartCount??0),mono:!0}),(0,L.jsx)(k,{icon:(0,L.jsx)(e,{className:`size-4`}),label:`最近故障`,value:n.state?.lastFailure?T(n.state.lastFailure):`无`,warn:!!n.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)(j,{domain:`sandbox`}),(0,L.jsx)(A,{tone:n.remoteEnabled?`boot`:`off`,children:n.remoteEnabled?`远程开启`:`远程关闭`}),(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`内存 `,u,` · CPU `,d]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsxs)(a,{disabled:!r,onClick:()=>void $(n.id,()=>h.instanceOpenWeb(n.id)),size:`sm`,title:`打开 DSH Web(自动带认证连接)`,variant:`outline`,className:`hidden md:inline-flex`,children:[(0,L.jsx)(b,{className:`size-4`}),`DSH Web`]}),(0,L.jsx)(a,{disabled:l,onClick:()=>void $(n.id,()=>r?h.instanceStop(n.id):h.instanceStart(n.id)),size:`sm`,variant:`outline`,children:r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(x,{className:`size-4 text-status-error`}),`停止实例`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(S,{className:`size-4 text-primary`}),`启动实例`]})}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,L.jsxs)(a,{disabled:f,onClick:()=>void $(n.id,()=>h.instanceUpdate(n.id,{guardian:!n.guardian})),size:`sm`,variant:`outline`,children:[(0,L.jsx)(ee,{className:t(`size-4`,n.guardian?`text-status-ok`:`text-muted-foreground`)}),n.guardian?`停止守护`:`启动守护`]}),(0,L.jsxs)(a,{className:`hidden h-[30px] md:inline-flex`,disabled:f,onClick:()=>V(n.id),size:`sm`,variant:`destructive`,children:[(0,L.jsx)(C,{className:`size-4`}),`删除`]})]})]})]})};return(0,L.jsxs)(`div`,{className:`grid content-start gap-4`,children:[Q.length?(0,L.jsx)(`div`,{className:`grid gap-3`,children:Q.map(e=>(0,L.jsx)(oe,{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)(N,{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:`点击顶部「添加实例」创建沙箱`})]})}),(0,L.jsx)(c,{open:R,onOpenChange:z,children:(0,L.jsxs)(o,{className:`max-w-[440px]`,children:[(0,L.jsx)(v,{children:(0,L.jsx)(s,{children:`添加 DSH 实例`})}),(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(f,{children:`实例名称`}),(0,L.jsx)(l,{placeholder:`如 沙箱二开`,value:H,onChange:e=>U(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(f,{children:`监听端口`}),(0,L.jsx)(l,{inputMode:`numeric`,placeholder:`如 3082`,value:W,onChange:e=>G(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(f,{children:`启动命令(每项一参数,可留空用默认)`}),(0,L.jsx)(u,{className:`min-h-[72px] font-mono text-sm`,placeholder:`node
2
+ /home/bowen/.npm-global/bin/dsh
3
+ web`,value:K,onChange:e=>q(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(f,{children:`内存限额`}),(0,L.jsx)(l,{placeholder:`如 4G`,value:J,onChange:e=>Y(e.target.value)})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsx)(f,{children:`CPU 配额`}),(0,L.jsx)(l,{placeholder:`如 150%`,value:X,onChange:e=>Z(e.target.value)})]})]})]}),(0,L.jsxs)(_,{children:[(0,L.jsx)(a,{onClick:()=>z(!1),variant:`outline`,children:`取消`}),(0,L.jsx)(a,{onClick:()=>void te(),children:`添加`})]})]})}),(0,L.jsx)(c,{open:!!B,onOpenChange:e=>!e&&V(null),children:(0,L.jsxs)(o,{className:`max-w-[380px]`,children:[(0,L.jsx)(v,{children:(0,L.jsx)(s,{children:`删除实例?`})}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`将彻底删除该沙箱实例(含配置与运行时数据)。此操作不可恢复。`}),(0,L.jsxs)(_,{children:[(0,L.jsx)(a,{onClick:()=>V(null),variant:`outline`,children:`取消`}),(0,L.jsx)(a,{className:`h-[34px]`,onClick:()=>{B&&$(B,()=>h.instanceRemove(B)),V(null)},variant:`destructive`,children:`删除`})]})]})})]})}export{R as InstancesPage};
@@ -0,0 +1,4 @@
1
+ import{A as e,D as t,M as n,S as r,b as i,d as a,f as o,i as s,j as c,r as l,t as u,y as d}from"./supervisor-DEHXL51C.js";import{t as f}from"./external-link-DblibQpb.js";import{t as p}from"./useSupervisorAction-Dj_nAGhv.js";import{n as m,o as h,r as g,t as _}from"./widgets-C6MCpT1T.js";var v=t(`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`}]]),y=t(`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`}]]),b=c(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),x=c(((e,t)=>{var n=b();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}})),S=c(((e,t)=>{t.exports=x()()})),C=n(e(),1),w=n(S(),1),T=function(e,t){let n=e,r=D[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=k.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=k.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=k.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=k.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=k.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=k.getErrorCorrectPolynomial(l),d=j(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=M.getRSBlocks(e,t),i=N();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),k.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=P(e);break;case`Alphanumeric`:n=F(e);break;case`Byte`:n=I(e);break;case`Kanji`:n=L(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=M.getRSBlocks(e,r),n=N();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),k.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 H(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
+ `}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};T.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},T.createStringToBytes=function(e,t){let n=function(){let n=B(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 E={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},D={L:1,M:0,Q:3,H:2},O={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},k=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 O.PATTERN000:return function(e,t){return(e+t)%2==0};case O.PATTERN001:return function(e,t){return e%2==0};case O.PATTERN010:return function(e,t){return t%3==0};case O.PATTERN011:return function(e,t){return(e+t)%3==0};case O.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case O.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case O.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case O.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=j([1],0);for(let n=0;n<e;n+=1)t=t.multiply(j([1,A.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case E.MODE_NUMBER:return 10;case E.MODE_ALPHA_NUM:return 9;case E.MODE_8BIT_BYTE:return 8;case E.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case E.MODE_NUMBER:return 12;case E.MODE_ALPHA_NUM:return 11;case E.MODE_8BIT_BYTE:return 16;case E.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case E.MODE_NUMBER:return 14;case E.MODE_ALPHA_NUM:return 13;case E.MODE_8BIT_BYTE:return 16;case E.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}(),A=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}(),j=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]^=A.gexp(A.glog(r.getAt(n))+A.glog(e.getAt(i)));return j(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=A.glog(r.getAt(0))-A.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]^=A.gexp(A.glog(e.getAt(r))+t);return j(n,0).mod(e)},r},M=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 D.L:return e[(t-1)*4+0];case D.M:return e[(t-1)*4+1];case D.Q:return e[(t-1)*4+2];case D.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}(),N=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},P=function(e){let t=E.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},F=function(e){let t=E.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},I=function(e){let t=E.MODE_8BIT_BYTE,n=T.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},L=function(e){let t=E.MODE_KANJI,n=T.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},R=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},z=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},B=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},V=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=R(),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},H=function(e,t,n){let r=V(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=R();r.write(i);let a=z(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};T.stringToBytes;function U(){return U=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},U.apply(null,arguments)}function W(e,t){if(e==null)return{};var n,r,i=G(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 G(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 K=[`bgColor`,`bgD`,`fgD`,`fgColor`,`size`,`title`,`viewBoxSize`,`xmlns`],q={bgColor:w.default.oneOfType([w.default.object,w.default.string]).isRequired,bgD:w.default.string.isRequired,fgColor:w.default.oneOfType([w.default.object,w.default.string]).isRequired,fgD:w.default.string.isRequired,size:w.default.number.isRequired,title:w.default.string,viewBoxSize:w.default.number.isRequired,xmlns:w.default.string},J=(0,C.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=W(e,K);return C.createElement(`svg`,U({},d,{height:o,ref:t,viewBox:`0 0 ${c} ${c}`,width:o,xmlns:u}),s?C.createElement(`title`,null,s):null,C.createElement(`path`,{d:r,fill:n}),C.createElement(`path`,{d:i,fill:a}))});J.displayName=`QRCodeSvg`,J.propTypes=q;var Y=[`bgColor`,`fgColor`,`level`,`size`,`value`];T.stringToBytes=function(e){return Array.from(new TextEncoder().encode(e))};var X={bgColor:w.default.oneOfType([w.default.object,w.default.string]),fgColor:w.default.oneOfType([w.default.object,w.default.string]),level:w.default.string,size:w.default.number,value:w.default.string.isRequired},Z=(0,C.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=W(e,Y),f=T(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 C.createElement(J,U({},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}))});Z.displayName=`QRCode`,Z.propTypes=X;var Q=r();function $(){let{snap:e}=u(),{busy:t,run:n}=p(),r=[...e.instances?.native?[e.instances.native]:[],...e.instances?.instances??[]],c=e.lan?.items??[],b=(e.lan?.addresses??[])[0]||``,x=e.frp,[S,w]=(0,C.useState)(``),[T,E]=(0,C.useState)(`7000`),[D,O]=(0,C.useState)(``),[k,A]=(0,C.useState)(!1);(0,C.useEffect)(()=>{!x||k||(w(x.settings.serverAddr||``),E(String(x.settings.serverPort||7e3)),O(x.settings.authToken||``),A(!0))},[x,k]);async function j(){await n(`frp-save`,()=>l.frpSettings({serverAddr:S,serverPort:parseInt(T,10)||7e3,authToken:D}),{success:`已保存 FRP 配置`})}return(0,Q.jsx)(`div`,{className:`grid content-start gap-4`,children:(0,Q.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(m,{title:`局域网远程控制`,subtitle:`为本地 DSH 实例开启局域网反向代理访问(需实例运行中)`}),(0,Q.jsx)(`div`,{className:`grid`,children:r.length?r.map(e=>{let t=e.state?.running??!1,r=c.find(t=>t.dshPort===e.port),a=!!r?.running,o=!!r?.enabled,u=t&&o&&a&&b?`http://`+b+`:`+r?.wanPort+`/`:null,d=t?(0,Q.jsx)(h,{tone:`boot`,children:`实例运行中`}):(0,Q.jsx)(h,{tone:`err`,children:`实例已停止`}),p=t?a?null:o?(0,Q.jsx)(h,{tone:`off`,children:`代理未就绪`}):(0,Q.jsx)(h,{tone:`off`,children:`代理未启用`}):(0,Q.jsx)(h,{tone:`off`,children:`代理停止`}),m=a?r?.inject:null,_=m?m.cookieReady?(0,Q.jsx)(`span`,{title:`DSH 会话 cookie 已注入,远程访问已认证`,children:(0,Q.jsx)(h,{tone:`ok`,children:`远程就绪`})}):m.tokenSet?(0,Q.jsx)(`span`,{title:m.lastError??`正在用令牌换取会话 cookie`,children:(0,Q.jsx)(h,{tone:`warn`,children:`正在注入`})}):(0,Q.jsx)(`span`,{title:`未捕获到 DSH 令牌:远程访问将要求登录`,children:(0,Q.jsx)(h,{tone:`err`,children:`令牌缺失`})}):null;return(0,Q.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:[u?(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center rounded-lg border border-border bg-white p-1.5`,title:`扫码访问该实例远程地址`,children:(0,Q.jsx)(Z,{value:u,size:88})}):(0,Q.jsx)(`div`,{className:`grid size-[96px] shrink-0 place-items-center rounded-lg border border-dashed border-border/70 text-[11px] leading-tight text-muted-foreground/60`,children:t?`代理就绪后生成二维码`:`启动后可用`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`pt-2.5 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(g,{domain:e.domain}),(0,Q.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:e.name}),d,p,_]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid content-end gap-1.5 pb-1`,children:[(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`端口 `,e.port,e.remoteEnabled?` · 远程已开`:` · 远程未开`]}),u?(0,Q.jsxs)(`a`,{className:`inline-flex max-w-full items-center gap-1 truncate text-xs text-primary hover:underline`,href:u,target:`_blank`,rel:`noreferrer`,children:[(0,Q.jsx)(f,{className:`size-3 shrink-0`}),u]}):(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:t?`等待代理就绪…`:`实例未运行,启动后可开启远程`})]})]}),(0,Q.jsxs)(`div`,{className:i(`flex items-center gap-2`,!t&&`pointer-events-none opacity-50`),children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`远程控制`}),(0,Q.jsx)(s,{checked:e.remoteEnabled??!1,disabled:!t,onCheckedChange:t=>void n(e.id,()=>e.domain===`native`?l.nativeSettings({remoteEnabled:t}):l.instanceUpdate(e.id,{remoteEnabled:t}),{success:t?`已开启远程控制`:`已关闭远程控制`})})]})]},e.id)}):(0,Q.jsx)(`div`,{className:`px-5 py-8 text-center text-sm text-muted-foreground`,children:`暂无实例(在「实例管理」添加后将出现在这里)`})})]}),(0,Q.jsxs)(_,{children:[(0,Q.jsx)(m,{title:`公网访问(FRP 内网穿透)`,subtitle:`通过 frpc 暴露本机端口到公网`,actions:(0,Q.jsx)(h,{tone:x?.running?`ok`:x?.installed?`warn`:`off`,children:x?.running?`frpc 运行中`:x?.installed?`已安装 · 未运行`:`未安装`})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(a,{children:`frps 地址`}),(0,Q.jsx)(o,{placeholder:`如 1.2.3.4`,value:S,onChange:e=>w(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(a,{children:`frps 端口`}),(0,Q.jsx)(o,{inputMode:`numeric`,placeholder:`7000`,value:T,onChange:e=>E(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(a,{children:`auth token`}),(0,Q.jsx)(o,{placeholder:`frps 的 auth.token`,value:D,onChange:e=>O(e.target.value)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pb-4`,children:[(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[x?.installed?``:`需安装 frpc`,(x?.instancesExposed?.length??0)>0?` · 公网暴露 `+x?.instancesExposed?.length+` 个实例`:` · 无公网暴露实例`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(d,{disabled:t===`frp-inst`,onClick:()=>void n(`frp-inst`,()=>l.frpInstall(),{success:`frpc 安装完成`}),variant:`outline`,children:[(0,Q.jsx)(y,{className:`size-4`}),`安装 frpc`]}),(0,Q.jsxs)(d,{disabled:t===`frp-save`,onClick:()=>void j(),children:[(0,Q.jsx)(v,{className:`size-4`}),`保存并应用`]})]})]}),x?.logTail?.length?(0,Q.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:x.logTail.join(`
4
+ `)}):null]})]})})}export{$ as LanPage};
@@ -0,0 +1,4 @@
1
+ import{E as e,L as t,O as n,P as r,R as i,T as a,a as o,h as s,m as c,r as l,t as u,z as d}from"./supervisor-05X9PT9U.js";import{t as f}from"./external-link-DfAIHbhS.js";import{t as p}from"./useSupervisorAction-CPqt8YnP.js";import{n as m,o as h,r as g,t as _}from"./widgets-C1m9qxfG.js";var v=r(`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`}]]),y=r(`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`}]]),b=i(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),x=i(((e,t)=>{var n=b();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}})),S=i(((e,t)=>{t.exports=x()()})),C=d(t(),1),w=d(S(),1),T=function(e,t){let n=e,r=D[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=k.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=k.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=k.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=k.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=k.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=k.getErrorCorrectPolynomial(l),d=j(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=M.getRSBlocks(e,t),i=N();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),k.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=P(e);break;case`Alphanumeric`:n=F(e);break;case`Byte`:n=I(e);break;case`Kanji`:n=L(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=M.getRSBlocks(e,r),n=N();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),k.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 H(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
+ `}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};T.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},T.createStringToBytes=function(e,t){let n=function(){let n=B(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 E={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},D={L:1,M:0,Q:3,H:2},O={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},k=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 O.PATTERN000:return function(e,t){return(e+t)%2==0};case O.PATTERN001:return function(e,t){return e%2==0};case O.PATTERN010:return function(e,t){return t%3==0};case O.PATTERN011:return function(e,t){return(e+t)%3==0};case O.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case O.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case O.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case O.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=j([1],0);for(let n=0;n<e;n+=1)t=t.multiply(j([1,A.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case E.MODE_NUMBER:return 10;case E.MODE_ALPHA_NUM:return 9;case E.MODE_8BIT_BYTE:return 8;case E.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case E.MODE_NUMBER:return 12;case E.MODE_ALPHA_NUM:return 11;case E.MODE_8BIT_BYTE:return 16;case E.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case E.MODE_NUMBER:return 14;case E.MODE_ALPHA_NUM:return 13;case E.MODE_8BIT_BYTE:return 16;case E.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}(),A=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}(),j=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]^=A.gexp(A.glog(r.getAt(n))+A.glog(e.getAt(i)));return j(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=A.glog(r.getAt(0))-A.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]^=A.gexp(A.glog(e.getAt(r))+t);return j(n,0).mod(e)},r},M=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 D.L:return e[(t-1)*4+0];case D.M:return e[(t-1)*4+1];case D.Q:return e[(t-1)*4+2];case D.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}(),N=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},P=function(e){let t=E.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},F=function(e){let t=E.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},I=function(e){let t=E.MODE_8BIT_BYTE,n=T.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},L=function(e){let t=E.MODE_KANJI,n=T.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},R=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},z=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},B=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},V=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=R(),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},H=function(e,t,n){let r=V(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=R();r.write(i);let a=z(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};T.stringToBytes;function U(){return U=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},U.apply(null,arguments)}function W(e,t){if(e==null)return{};var n,r,i=G(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 G(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 K=[`bgColor`,`bgD`,`fgD`,`fgColor`,`size`,`title`,`viewBoxSize`,`xmlns`],q={bgColor:w.default.oneOfType([w.default.object,w.default.string]).isRequired,bgD:w.default.string.isRequired,fgColor:w.default.oneOfType([w.default.object,w.default.string]).isRequired,fgD:w.default.string.isRequired,size:w.default.number.isRequired,title:w.default.string,viewBoxSize:w.default.number.isRequired,xmlns:w.default.string},J=(0,C.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=W(e,K);return C.createElement(`svg`,U({},d,{height:o,ref:t,viewBox:`0 0 ${c} ${c}`,width:o,xmlns:u}),s?C.createElement(`title`,null,s):null,C.createElement(`path`,{d:r,fill:n}),C.createElement(`path`,{d:i,fill:a}))});J.displayName=`QRCodeSvg`,J.propTypes=q;var Y=[`bgColor`,`fgColor`,`level`,`size`,`value`];T.stringToBytes=function(e){return Array.from(new TextEncoder().encode(e))};var X={bgColor:w.default.oneOfType([w.default.object,w.default.string]),fgColor:w.default.oneOfType([w.default.object,w.default.string]),level:w.default.string,size:w.default.number,value:w.default.string.isRequired},Z=(0,C.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=W(e,Y),f=T(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 C.createElement(J,U({},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}))});Z.displayName=`QRCode`,Z.propTypes=X;var Q=n();function $(){let{snap:t}=u(),{busy:n,run:r}=p(),i=[...t.instances?.native?[t.instances.native]:[],...t.instances?.instances??[]],d=t.lan?.items??[],b=(t.lan?.addresses??[])[0]||``,x=t.frp,[S,w]=(0,C.useState)(``),[T,E]=(0,C.useState)(`7000`),[D,O]=(0,C.useState)(``),[k,A]=(0,C.useState)(!1);(0,C.useEffect)(()=>{!x||k||(w(x.settings.serverAddr||``),E(String(x.settings.serverPort||7e3)),O(x.settings.authToken||``),A(!0))},[x,k]);async function j(){await r(`frp-save`,()=>l.frpSettings({serverAddr:S,serverPort:parseInt(T,10)||7e3,authToken:D}),{success:`已保存 FRP 配置`})}return(0,Q.jsx)(`div`,{className:`grid content-start gap-4`,children:(0,Q.jsxs)(`div`,{className:`grid items-start gap-4 @min-[900px]:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,Q.jsxs)(_,{children:[(0,Q.jsx)(m,{title:`局域网远程控制`,subtitle:`为本地 DSH 实例开启局域网反向代理访问(需实例运行中)`}),(0,Q.jsx)(`div`,{className:`grid`,children:i.length?i.map(t=>{let n=t.state?.running??!1,i=d.find(e=>e.dshPort===t.port),a=!!i?.running,s=!!i?.enabled,c=n&&s&&a&&b?`http://`+b+`:`+i?.wanPort+`/`:null,u=a?i?.inject:null,p=!!(n&&s&&a&&u?.cookieReady),m=n?s?a?u?.cookieReady?`DSH 会话 cookie 已注入,远程访问已认证`:u?.tokenSet?u?.lastError||`正在注入…`:`令牌缺失`:`远程服务未就绪`:`远程未开启(点右侧开关开启)`:`实例未运行`,_=p?(0,Q.jsx)(h,{tone:`ok`,children:`远程就绪`}):(0,Q.jsx)(`span`,{title:m,children:(0,Q.jsx)(h,{tone:`off`,children:`远程停止`})});return(0,Q.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:[c?(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center rounded-lg border border-border bg-white p-1.5`,title:`扫码访问该实例远程地址`,children:(0,Q.jsx)(Z,{value:c,size:88})}):(0,Q.jsx)(`div`,{className:`grid size-[96px] shrink-0 place-items-center rounded-lg border border-dashed border-border/70 text-[11px] leading-tight text-muted-foreground/60`,children:n?`代理就绪后生成二维码`:`启动后可用`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`pt-2.5 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(g,{domain:t.domain}),(0,Q.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:t.name}),_]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid content-end gap-1.5 pb-1`,children:[(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`端口 `,t.port,t.remoteEnabled?` · 远程已开`:` · 远程未开`]}),c?(0,Q.jsxs)(`a`,{className:`inline-flex max-w-full items-center gap-1 truncate text-xs text-primary hover:underline`,href:c,target:`_blank`,rel:`noreferrer`,children:[(0,Q.jsx)(f,{className:`size-3 shrink-0`}),c]}):(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:n?`等待代理就绪…`:`实例未运行,启动后可开启远程`})]})]}),(0,Q.jsxs)(`div`,{className:e(`flex items-center gap-2`,!n&&`pointer-events-none opacity-50`),children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`远程控制`}),(0,Q.jsx)(o,{checked:t.remoteEnabled??!1,disabled:!n,onCheckedChange:e=>void r(t.id,()=>t.domain===`native`?l.nativeSettings({remoteEnabled:e}):l.instanceUpdate(t.id,{remoteEnabled:e}),{success:e?`已开启远程控制`:`已关闭远程控制`})})]})]},t.id)}):(0,Q.jsx)(`div`,{className:`px-5 py-8 text-center text-sm text-muted-foreground`,children:`暂无实例(在「实例管理」添加后将出现在这里)`})})]}),(0,Q.jsxs)(_,{children:[(0,Q.jsx)(m,{title:`公网访问(FRP 内网穿透)`,subtitle:`通过 frpc 暴露本机端口到公网`,actions:(0,Q.jsx)(h,{tone:x?.running?`ok`:x?.installed?`warn`:`off`,children:x?.running?`frpc 运行中`:x?.installed?`已安装 · 未运行`:`未安装`})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(c,{children:`frps 地址`}),(0,Q.jsx)(s,{placeholder:`如 1.2.3.4`,value:S,onChange:e=>w(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(c,{children:`frps 端口`}),(0,Q.jsx)(s,{inputMode:`numeric`,placeholder:`7000`,value:T,onChange:e=>E(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(c,{children:`auth token`}),(0,Q.jsx)(s,{placeholder:`frps 的 auth.token`,value:D,onChange:e=>O(e.target.value)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-5 pb-4`,children:[(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[x?.installed?``:`需安装 frpc`,(x?.instancesExposed?.length??0)>0?` · 公网暴露 `+x?.instancesExposed?.length+` 个实例`:` · 无公网暴露实例`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(a,{disabled:n===`frp-inst`,onClick:()=>void r(`frp-inst`,()=>l.frpInstall(),{success:`frpc 安装完成`}),variant:`outline`,children:[(0,Q.jsx)(y,{className:`size-4`}),`安装 frpc`]}),(0,Q.jsxs)(a,{disabled:n===`frp-save`,onClick:()=>void j(),children:[(0,Q.jsx)(v,{className:`size-4`}),`保存并应用`]})]})]}),x?.logTail?.length?(0,Q.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:x.logTail.join(`
4
+ `)}):null]})]})})}export{$ as LanPage};
@@ -0,0 +1,2 @@
1
+ import{A as e,C as t,D as n,M as r,S as i,_ as a,b as o,g as s,h as c,m as l,p as u,r as d,t as f,w as p,y as m}from"./supervisor-DEHXL51C.js";import{t as h}from"./external-link-DblibQpb.js";import{n as g,t as _}from"./rocket-BDT9yN5c.js";import{t as v}from"./refresh-cw-Dbn7zlS9.js";import{c as y,f as b,n as x,o as S,t as C}from"./supervisor-C3UXEQbW.js";import{t as w}from"./useSupervisorAction-Dj_nAGhv.js";import{c as T,i as E,n as D,o as O,t as k}from"./widgets-C6MCpT1T.js";import{t as A}from"./format-QeaTKFhQ.js";var j=n(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),M=n(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),N=n(`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`}]]),P=r(e(),1),F=i();function I(e,t){return e===`dsh-main`||e===`supervisor-api`?`boot`:t.startsWith(`inst:`)?`ok`:e===`relay`?`warn`:`off`}function L(e){return{"dsh-main":`DSH 主实例`,"supervisor-api":`管家 API`,relay:`隧道`,user:`用户实例`}[e.role]??e.role}function R(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:`)||e.role===`oauthCallback`?`登录回调`:e.role}function z({providers:e=[]}){let{snap:t}=f(),n=t.ports?.records??null,r=(0,P.useMemo)(()=>n?[...n].sort((e,t)=>!!e.active==!!t.active?e.port-t.port:e.active?-1:1):null,[n]);return(0,F.jsxs)(k,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,F.jsx)(D,{title:`端口管理`,subtitle:`对接后端全部已注册端口`,actions:r?(0,F.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:r.length}):null}),r?(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,F.jsxs)(`div`,{className:`grid 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,F.jsx)(`span`,{children:`端口`}),(0,F.jsx)(`span`,{children:`角色`}),(0,F.jsx)(`span`,{className:`text-right`,children:`归属`}),(0,F.jsx)(`span`,{className:`text-right`,children:`状态`})]}),(0,F.jsx)(`div`,{className:`max-h-[340px] overflow-y-auto overscroll-contain`,children:r.map((t,n)=>(0,F.jsxs)(`div`,{className:o(`grid grid-cols-[56px_minmax(0,1fr)_auto_66px] items-center gap-2 px-4 py-2 hover:bg-muted/40`,n>0&&`border-t border-border/50`),children:[(0,F.jsx)(`code`,{className:`font-mono text-sm tabular-nums text-foreground`,children:t.port}),(0,F.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,F.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:L(t)})}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)(O,{tone:I(t.role,t.owner),children:R(t,e)})}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:t.active===!0?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-status-ok`,children:[(0,F.jsx)(M,{className:`size-3`}),`激活`]}):t.active===!1?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,F.jsx)(M,{className:`size-3 opacity-50`}),`停用`]}):(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,F.jsx)(M,{className:`size-3 opacity-40`}),`状态未知`]})})]},t.port+`-`+t.owner))})]}):(0,F.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`加载中…`})]})}var B=new Set([`dist_registry_selected`,`gui_autostart_changed`,`autostart_changed`,`lan_panel_changed`,`lan_dsh_token_updated`]);function V(){let{snap:e}=f(),{busy:n,run:r}=w(),[i,o]=(0,P.useState)(!1),p=e.status,C=p?.native,D=C?.installed??!1,O=C?.state||(D?`installed`:`uninstalled`),A=O===`installing`,M=A||O===`uninstalling`,I=p?.version,L=p?.upgrade,R=x[p?.phase??``]??{label:p?.phase||`未知`,tone:`off`},V=!!p?.dshPid,W=L?.state===`running`,G=(0,P.useMemo)(()=>e.events.filter(e=>!B.has(e.type)),[e.events]);async function K(){await r(`dsh`,()=>V?d.lifecycleStop(`dsh`):d.lifecycleStart(`dsh`),{success:V?`正在停止 DSH…`:`正在启动 DSH…`})}async function q(){await r(`web`,()=>d.instanceOpenWeb(`main`))}async function J(){await r(`chk`,async()=>{let e=await d.nativeCheckUpdate();if(e?.ok===!1){t.error(e.error||`检测失败`);return}e?.updateAvailable&&e.latest?t.success(`发现新版本 `+e.latest+(e.installed?`(当前 `+e.installed+`),可一键升级`:``)):t.success(`已是最新版本`+(e.installed?`(`+e.installed+`)`:``))})}async function Y(){o(!1),await r(`upg`,()=>d.nativeUpgrade(),{success:`升级已开始,请耐心等待…`})}async function X(){confirm(`将在线安装最新版 DeepSeek Harness(需数分钟,自动适配最快镜像源)。确定继续?`)&&await r(`inst`,()=>d.nativeInstall(),{success:`开始安装 DeepSeek Harness…`})}async function Z(){confirm(`将彻底卸载 DeepSeek Harness:删除全部文件、数据、缓存与日志,不留残留。确定继续?`)&&await r(`uni`,()=>d.nativeUninstall(),{success:`开始卸载…`})}let Q=D&&(C?.version||I?.installed)||`—`;return(0,F.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,F.jsxs)(k,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`,children:[(0,F.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,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,F.jsx)(`h3`,{className:`truncate text-xl font-semibold tracking-[-0.01em] text-foreground`,children:`DeepSeek Harness`}),(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-sm text-muted-foreground`,children:[`v`,Q]})]}),n===`chk`?(0,F.jsxs)(m,{size:`chip`,disabled:!0,children:[(0,F.jsx)(v,{className:`size-3 animate-spin`}),`检测中…`]}):I?.updateAvailable&&I.latest?(0,F.jsxs)(m,{className:`text-primary-foreground`,size:`chip`,onClick:()=>o(!0),children:[(0,F.jsx)(j,{className:`size-3`}),`升级到 v`,I.latest]}):W?(0,F.jsxs)(m,{size:`chip`,disabled:!0,children:[(0,F.jsx)(v,{className:`size-3 animate-spin`}),`升级中…`]}):(0,F.jsxs)(m,{className:`bg-primary/10 text-primary hover:bg-primary/15`,onClick:()=>void J(),size:`chip`,variant:`ghost`,children:[(0,F.jsx)(v,{className:`size-3`}),`检测更新`]})]}),M?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{tone:`boot`,ping:!0}),(0,F.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:A?`正在安装 DeepSeek Harness…`:`正在卸载 DeepSeek Harness…`})]}):(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{tone:R.tone,ping:R.tone===`ok`}),(0,F.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:R.label})]}),W&&L?(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-primary`}),`正在升级(`,L.step||L.targetVersion||``,`)…`]}):null,L?.state===`failed`?(0,F.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`升级失败:`,L.lastError||`未知原因`,L.rolledBack?`(已回滚)`:``]}):null,M&&(C?.installLog??[]).length?(0,F.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:(C?.installLog??[]).slice(-6).join(`
2
+ `)}):null]}),(0,F.jsx)(`div`,{className:`flex items-center bg-[image:var(--panel-accent-gradient)] px-6 py-5`,children:(0,F.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4`,children:[(0,F.jsx)(E,{icon:(0,F.jsx)(b,{className:`size-4`}),label:`DSH 端口`,value:p?.dshPort?String(p.dshPort):`—`,mono:!0}),(0,F.jsx)(E,{icon:(0,F.jsx)(N,{className:`size-4`}),label:`DSH 进程`,value:p?.dshPid?String(p.dshPid):`—`,mono:!0}),(0,F.jsx)(E,{icon:(0,F.jsx)(v,{className:`size-4`}),label:`重启次数`,value:String(p?.restartCount??0),mono:!0}),(0,F.jsx)(E,{icon:(0,F.jsx)(j,{className:`size-4`}),label:`最近故障`,value:p?.lastFailure?S(p?.lastFailure):`无`,warn:!!p?.lastFailure})]})})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-border/60 px-6 py-3`,children:[(0,F.jsx)(H,{}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!D&&!M?(0,F.jsxs)(m,{size:`sm`,disabled:n===`inst`,onClick:()=>void X(),children:[(0,F.jsx)(_,{className:`size-4`}),`安装 DSH`]}):D&&!M&&!W?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(m,{disabled:!V,onClick:()=>void q(),size:`sm`,variant:`outline`,children:[(0,F.jsx)(h,{className:`size-4`}),`进入 DSH Web`]}),(0,F.jsx)(m,{disabled:n===`dsh`,onClick:()=>void K(),size:`sm`,variant:`outline`,children:V?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{className:`size-4 text-status-error`}),`停止 DSH`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(_,{className:`size-4 text-primary`}),`启动 DSH`]})})]}):null,D&&!M?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,F.jsxs)(m,{className:`h-[30px]`,disabled:n===`uni`,onClick:()=>void Z(),size:`sm`,variant:`destructive`,children:[(0,F.jsx)(y,{className:`size-4`}),`卸载 DSH`]})]}):null]})]})]}),(0,F.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,F.jsx)(U,{events:G}),(0,F.jsx)(z,{providers:e.providers?.providers??[]})]}),(0,F.jsx)(u,{open:i,onOpenChange:o,children:(0,F.jsxs)(l,{className:`max-w-[420px]`,children:[(0,F.jsx)(s,{children:(0,F.jsx)(a,{children:`升级 DeepSeek Harness`})}),(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-3 rounded-md bg-muted px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`当前版本`}),(0,F.jsx)(`strong`,{className:`font-mono text-base text-foreground`,children:I?.installed||Q})]}),(0,F.jsx)(j,{className:`size-4 text-muted-foreground`}),(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`新版本`}),(0,F.jsx)(`strong`,{className:`font-mono text-base text-primary`,children:I?.latest||`—`})]})]}),(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`升级将先停止 DSH、安装新版本后自动拉起(需数分钟)。期间进行中的请求会中断,失败会自动回滚到当前版本。`})]}),(0,F.jsxs)(c,{children:[(0,F.jsx)(m,{onClick:()=>o(!1),variant:`outline`,children:`取消`}),(0,F.jsx)(m,{disabled:n===`upg`||W,onClick:()=>void Y(),children:n===`upg`||W?`升级中…`:`开始升级`})]})]})})]})}function H(){let[e,t]=(0,P.useState)(null);return(0,P.useEffect)(()=>{let e=!0,n=async()=>{let n=await d.nodeLts().catch(()=>null);e&&t(n)};n();let r=setInterval(n,6e5);return()=>{e=!1,clearInterval(r)}},[]),e?.current?(0,F.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`环境检测 · Node v`,e.current]}),e.updateAvailable&&e.latestLts?(0,F.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`,children:[(0,F.jsx)(p,{className:`size-3`}),`可更新到 v`,e.latestLts,e.ltsName?` LTS`:``]}):e.latestLts?(0,F.jsxs)(`span`,{className:`hidden whitespace-nowrap text-muted-foreground/70 sm:inline`,children:[`最新 LTS v`,e.latestLts]}):null]}):(0,F.jsx)(`span`,{className:`min-w-[120px] text-xs text-muted-foreground`,children:`环境检测…`})}function U({events:e}){let[t,n]=(0,P.useState)(12),r=e.length;(0,P.useEffect)(()=>{n(12)},[e]);let i=(0,P.useRef)(null),a=(0,P.useRef)(!1);(0,P.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,F.jsxs)(k,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,F.jsx)(D,{title:`事件日志`,subtitle:`核心运行状态遥测`,actions:(0,F.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:r})}),r?(0,F.jsxs)(`div`,{className:`flex max-h-[450px] min-h-0 flex-col overflow-y-auto overscroll-contain`,children:[o.map((e,t)=>(0,F.jsx)(W,{e},e.seq??t)),(0,F.jsx)(`div`,{ref:i,className:`px-5 py-2 text-center text-[11px] text-muted-foreground`,children:s?`下滑加载更多…`:`已加载全部`})]}):(0,F.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`暂无核心运行状态事件`})]})}function W({e}){let t=K[e.type]??`boot`,n=C[e.type]??e.type,r=G(e);return(0,F.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,F.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:A(e.ts)}),(0,F.jsx)(O,{tone:t,children:n}),(0,F.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]})}function G(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 S(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:``);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 K={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`,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`,proxy_update_available:`warn`,upgrade_started:`warn`,upgrade_stopping_dsh:`warn`,inst_restarted:`warn`,lan_frp_changed:`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{V as OverviewPage};
@@ -0,0 +1,2 @@
1
+ import{A as e,E as t,L as n,O as r,P as i,T as a,_ as o,b as s,g as ee,k as c,r as l,t as u,v as d,y as f,z as p}from"./supervisor-05X9PT9U.js";import{t as m}from"./external-link-DfAIHbhS.js";import{n as h,t as g}from"./rocket-KILE2qPr.js";import{t as _}from"./refresh-cw-Dl1i4xVh.js";import{t as v}from"./shield-check-CKBb6VBo.js";import{c as y,f as b,n as x,o as S,t as C}from"./supervisor-CKm4a1yh.js";import{t as w}from"./useSupervisorAction-CPqt8YnP.js";import{c as T,i as E,n as D,o as O,t as k}from"./widgets-C1m9qxfG.js";import{t as A}from"./format-QeaTKFhQ.js";var j=i(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),M=i(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),N=i(`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`}]]),P=p(n(),1),F=r();function I(e,t){return e===`dsh-main`||e===`supervisor-api`?`boot`:t.startsWith(`inst:`)?`ok`:e===`relay`?`warn`:e.startsWith(`managed:`)?`boot`:`off`}function L(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 R(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 z({providers:e=[]}){let{snap:n}=u(),r=n.ports?.records??null,i=(0,P.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,F.jsxs)(k,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,F.jsx)(D,{title:`运行状态`,subtitle:`核心服务与端口实时状态`,actions:i?(0,F.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[i.length,` 端口`]}):null}),i?(0,F.jsxs)(`div`,{className:`min-h-0 overflow-x-auto`,children:[(0,F.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,F.jsx)(`span`,{children:`端口`}),(0,F.jsx)(`span`,{children:`服务`}),(0,F.jsx)(`span`,{className:`text-right`,children:`归属`}),(0,F.jsx)(`span`,{className:`text-right`,children:`状态`})]}),(0,F.jsx)(`div`,{className:`max-h-[340px] overflow-y-auto overscroll-contain`,children:i.map((n,r)=>(0,F.jsxs)(`div`,{className:t(`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,F.jsx)(`code`,{className:`font-mono text-sm tabular-nums text-foreground`,children:n.port}),(0,F.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:(0,F.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:L(n)})}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)(O,{tone:I(n.role,n.owner),children:R(n,e)})}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:n.active===!0?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-status-ok`,children:[(0,F.jsx)(M,{className:`size-3`}),`运行中`]}):n.active===!1?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,F.jsx)(M,{className:`size-3 opacity-50`}),`未运行`]}):(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-muted-foreground`,children:[(0,F.jsx)(M,{className:`size-3 opacity-40`}),`状态未知`]})})]},n.port+`-`+n.owner))})]}):(0,F.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`运行状态加载中…`})]})}var B=new Set([`dist_registry_selected`,`gui_autostart_changed`,`autostart_changed`,`lan_panel_changed`,`lan_dsh_token_updated`]);function V(){let{snap:e}=u(),{busy:n,run:r}=w(),[i,p]=(0,P.useState)(!1),[C,D]=(0,P.useState)(null),O=e.status,A=O?.native,M=A?.installed??!1,I=A?.state||(M?`installed`:`uninstalled`),L=I===`installing`,R=L||I===`uninstalling`,V=O?.version,W=O?.upgrade,G=x[O?.phase??``]??{label:O?.phase||`未知`,tone:`off`},K=!!O?.dshPid,q=W?.state===`running`,J=(0,P.useMemo)(()=>e.events.filter(e=>!B.has(e.type)),[e.events]);async function Y(){await r(`dsh`,()=>K?l.lifecycleStop(`dsh`):l.lifecycleStart(`dsh`),{success:K?`正在停止 DSH…`:`正在启动 DSH…`})}async function X(){await r(`web`,()=>l.instanceOpenWeb(`main`))}async function Z(){await r(`chk`,async()=>{let e=await l.nativeCheckUpdate();if(e?.ok===!1){c.error(e.error||`检测失败`);return}e?.updateAvailable&&e.latest?c.success(`发现新版本 `+e.latest+(e.installed?`(当前 `+e.installed+`),可一键升级`:``)):c.success(`已是最新版本`+(e.installed?`(`+e.installed+`)`:``))})}async function Q(){p(!1),await r(`upg`,()=>l.nativeUpgrade(),{success:`升级已开始,请耐心等待…`})}async function te(){confirm(`将在线安装最新版 DeepSeek Harness(需数分钟,自动适配最快镜像源)。确定继续?`)&&await r(`inst`,()=>l.nativeInstall(),{success:`开始安装 DeepSeek Harness…`})}async function ne(){confirm(`将彻底卸载 DeepSeek Harness:删除全部文件、数据、缓存与日志,不留残留。确定继续?`)&&await r(`uni`,()=>l.nativeUninstall(),{success:`开始卸载…`})}(0,P.useEffect)(()=>{M&&l.instances().then(e=>{let t=e?.native?.guardian;typeof t==`boolean`&&D(t)}).catch(()=>{})},[M,O?.dshPid]);async function re(){let e=C!==!0;await r(`gu`,()=>l.nativeSettings({guardian:e}).then(e=>{let t=e?.main?.guardian;return typeof t==`boolean`&&D(t),e}),{success:e?`已开启 DSH 进程守护(崩溃自动拉起)`:`已关闭 DSH 进程守护(崩溃后不再自动拉起)`,refresh:!1})}let $=M&&(A?.version||V?.installed)||`—`;return(0,F.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,F.jsxs)(k,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 @min-[720px]:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`,children:[(0,F.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,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,F.jsx)(`h3`,{className:`truncate text-xl font-semibold tracking-[-0.01em] text-foreground`,children:`DeepSeek Harness`}),(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-sm text-muted-foreground`,children:[`v`,$]})]}),n===`chk`?(0,F.jsxs)(a,{size:`chip`,disabled:!0,children:[(0,F.jsx)(_,{className:`size-3 animate-spin`}),`检测中…`]}):V?.updateAvailable&&V.latest?(0,F.jsxs)(a,{className:`text-primary-foreground`,size:`chip`,onClick:()=>p(!0),children:[(0,F.jsx)(j,{className:`size-3`}),`升级到 v`,V.latest]}):q?(0,F.jsxs)(a,{size:`chip`,disabled:!0,children:[(0,F.jsx)(_,{className:`size-3 animate-spin`}),`升级中…`]}):(0,F.jsxs)(a,{className:`bg-primary/10 text-primary hover:bg-primary/15`,onClick:()=>void Z(),size:`chip`,variant:`ghost`,children:[(0,F.jsx)(_,{className:`size-3`}),`检测更新`]})]}),R?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{tone:`boot`,ping:!0}),(0,F.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:L?`正在安装 DeepSeek Harness…`:`正在卸载 DeepSeek Harness…`})]}):(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{tone:G.tone,ping:G.tone===`ok`}),(0,F.jsx)(`span`,{className:`text-base font-semibold leading-none text-foreground`,children:G.label})]}),q&&W?(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-primary`}),`正在升级(`,W.step||W.targetVersion||``,`)…`]}):null,W?.state===`failed`?(0,F.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`升级失败:`,W.lastError||`未知原因`,W.rolledBack?`(已回滚)`:``]}):null,R&&(A?.installLog??[]).length?(0,F.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:(A?.installLog??[]).slice(-6).join(`
2
+ `)}):null]}),(0,F.jsx)(`div`,{className:`flex items-center bg-[image:var(--panel-accent-gradient)] px-6 py-5`,children:(0,F.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-x-6 gap-y-4 @min-[560px]:grid-cols-4`,children:[(0,F.jsx)(E,{icon:(0,F.jsx)(b,{className:`size-4`}),label:`端口`,value:O?.dshPort?String(O.dshPort):`—`,mono:!0}),(0,F.jsx)(E,{icon:(0,F.jsx)(N,{className:`size-4`}),label:`PID`,value:O?.dshPid?String(O.dshPid):`—`,mono:!0}),(0,F.jsx)(E,{icon:(0,F.jsx)(_,{className:`size-4`}),label:`重启次数`,value:String(O?.restartCount??0),mono:!0}),(0,F.jsx)(E,{icon:(0,F.jsx)(j,{className:`size-4`}),label:`最近故障`,value:O?.lastFailure?S(O?.lastFailure):`无`,warn:!!O?.lastFailure})]})})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-border/60 px-6 py-3`,children:[(0,F.jsx)(`div`,{className:`hidden lg:block`,children:(0,F.jsx)(H,{})}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[!M&&!R?(0,F.jsxs)(a,{size:`sm`,disabled:n===`inst`,onClick:()=>void te(),children:[(0,F.jsx)(g,{className:`size-4`}),`安装 DSH`]}):M&&!R&&!q?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(a,{disabled:!K,onClick:()=>void X(),size:`sm`,variant:`outline`,className:`hidden md:inline-flex`,children:[(0,F.jsx)(m,{className:`size-4`}),`DSH Web`]}),(0,F.jsx)(a,{disabled:n===`dsh`,onClick:()=>void Y(),size:`sm`,variant:`outline`,children:K?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{className:`size-4 text-status-error`}),`停止 DSH`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{className:`size-4 text-primary`}),`启动 DSH`]})}),(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,F.jsxs)(a,{className:`h-[30px]`,disabled:n===`gu`||C===null,onClick:()=>void re(),size:`sm`,variant:`outline`,children:[(0,F.jsx)(v,{className:t(`size-4`,C===!0?`text-status-ok`:`text-muted-foreground`)}),C===!0?`停止守护`:`启动守护`]})]}):null,M&&!R?(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)(a,{className:`hidden h-[30px] md:inline-flex`,disabled:n===`uni`,onClick:()=>void ne(),size:`sm`,variant:`destructive`,children:[(0,F.jsx)(y,{className:`size-4`}),`卸载 DSH`]})}):null]})]})]}),(0,F.jsxs)(`div`,{className:`grid items-start gap-4 @min-[860px]:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,F.jsx)(U,{events:J}),(0,F.jsx)(z,{providers:e.providers?.providers??[]})]}),(0,F.jsx)(ee,{open:i,onOpenChange:p,children:(0,F.jsxs)(o,{className:`max-w-[420px]`,children:[(0,F.jsx)(f,{children:(0,F.jsx)(s,{children:`升级 DeepSeek Harness`})}),(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-3 rounded-md bg-muted px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`当前版本`}),(0,F.jsx)(`strong`,{className:`font-mono text-base text-foreground`,children:V?.installed||$})]}),(0,F.jsx)(j,{className:`size-4 text-muted-foreground`}),(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`新版本`}),(0,F.jsx)(`strong`,{className:`font-mono text-base text-primary`,children:V?.latest||`—`})]})]}),(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`升级将先停止 DSH、安装新版本后自动拉起(需数分钟)。期间进行中的请求会中断,失败会自动回滚到当前版本。`})]}),(0,F.jsxs)(d,{children:[(0,F.jsx)(a,{onClick:()=>p(!1),variant:`outline`,children:`取消`}),(0,F.jsx)(a,{disabled:n===`upg`||q,onClick:()=>void Q(),children:n===`upg`||q?`升级中…`:`开始升级`})]})]})})]})}function H(){let[t,n]=(0,P.useState)(null);return(0,P.useEffect)(()=>{let e=!0,t=async()=>{let t=await l.nodeLts().catch(()=>null);e&&n(t)};t();let r=setInterval(t,6e5);return()=>{e=!1,clearInterval(r)}},[]),t?.current?(0,F.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`环境检测 · Node v`,t.current]}),t.updateAvailable&&t.latestLts?(0,F.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`,children:[(0,F.jsx)(e,{className:`size-3`}),`可更新到 v`,t.latestLts,t.ltsName?` LTS`:``]}):t.latestLts?(0,F.jsxs)(`span`,{className:`hidden whitespace-nowrap text-muted-foreground/70 sm:inline`,children:[`最新 LTS v`,t.latestLts]}):null]}):(0,F.jsx)(`span`,{className:`min-w-[120px] text-xs text-muted-foreground`,children:`环境检测…`})}function U({events:e}){let[t,n]=(0,P.useState)(12),r=e.length;(0,P.useEffect)(()=>{n(12)},[e]);let i=(0,P.useRef)(null),a=(0,P.useRef)(!1);(0,P.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,F.jsxs)(k,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,F.jsx)(D,{title:`事件日志`,subtitle:`核心运行状态遥测`,actions:(0,F.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:r})}),r?(0,F.jsxs)(`div`,{className:`flex max-h-[450px] min-h-0 flex-col overflow-y-auto overscroll-contain`,children:[o.map((e,t)=>(0,F.jsx)(W,{e},e.seq??t)),(0,F.jsx)(`div`,{ref:i,className:`px-5 py-2 text-center text-[11px] text-muted-foreground`,children:s?`下滑加载更多…`:`已加载全部`})]}):(0,F.jsx)(`div`,{className:`px-5 py-6 text-center text-xs text-muted-foreground`,children:`暂无核心运行状态事件`})]})}function W({e}){let t=K[e.type]??`boot`,n=C[e.type]??e.type,r=G(e);return(0,F.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,F.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:A(e.ts)}),(0,F.jsx)(O,{tone:t,children:n}),(0,F.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]})}function G(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 S(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`||e.type===`dsh_remote_changed`||e.type===`dsh_frp_changed`){let n=t.name||(t.id===`main`?`原生 DSH`:t.id||`实例`),r=e.type.includes(`guardian`)?`进程守护`:e.type.includes(`remote`)?`远程控制`:`FRP`;return n+` · `+r+(t.enabled===!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 K={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`,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`,dsh_frp_changed:`warn`,proxy_update_available:`warn`,upgrade_started:`warn`,upgrade_stopping_dsh:`warn`,inst_restarted:`warn`,lan_frp_changed:`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{V as OverviewPage};
@@ -0,0 +1,5 @@
1
+ import{A as e,C as t,D as n,M as r,S as i,_ as a,b as o,c as s,f as c,g as l,l as u,m as d,o as f,p,r as m,s as h,u as g,v as _,y as v}from"./supervisor-DEHXL51C.js";import{n as y,t as b}from"./rocket-BDT9yN5c.js";import{t as x}from"./refresh-cw-Dbn7zlS9.js";import{c as S,u as C}from"./supervisor-C3UXEQbW.js";import{t as w}from"./useSupervisorAction-Dj_nAGhv.js";import{n as T,o as E,t as D}from"./widgets-C6MCpT1T.js";var O=n(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),k=n(`store`,[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]),A=r(e(),1);function j(e){return e>=1073741824?`${(e/1024/1024/1024).toFixed(1)} GB`:e>=1048576?`${(e/1024/1024).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}var M=i(),N=24;function P(){let[e,t]=(0,A.useState)(`market`);return(0,M.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-muted p-1`,children:[`market`,`installed`].map(n=>(0,M.jsxs)(v,{className:o(`font-medium`,e===n?`bg-card text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-card/60 hover:text-foreground`),onClick:()=>t(n),size:`sm`,variant:`ghost`,children:[n===`market`?(0,M.jsx)(k,{className:`size-3.5`}):(0,M.jsx)(C,{className:`size-3.5`}),n===`market`?`插件商店`:`已安装`]},n))}),e===`market`?(0,M.jsx)(F,{}):null]}),e===`market`?(0,M.jsx)(I,{}):(0,M.jsx)(z,{})]})}function F(){let[e,n]=(0,A.useState)(!1);async function r(){n(!0);try{await m.market(!0),t.success(`插件索引已刷新`)}catch(e){t.error(String(e))}n(!1)}return(0,M.jsxs)(v,{disabled:e,onClick:()=>void r(),size:`chip`,variant:`outline`,children:[(0,M.jsx)(x,{className:o(`size-3.5`,e&&`animate-spin`)}),`刷新`]})}function I(){let[e,n]=(0,A.useState)(null),[r,i]=(0,A.useState)(``),[_,y]=(0,A.useState)(`all`),[b,x]=(0,A.useState)(`all`),[S,C]=(0,A.useState)(0),[w,T]=(0,A.useState)(null),[D,k]=(0,A.useState)([]),[j,P]=(0,A.useState)(`native`);(0,A.useEffect)(()=>{let e=!0;return m.market().then(t=>{e&&(n(t),C(N))}).catch(()=>void 0),()=>{e=!1}},[]);let F=(0,A.useMemo)(()=>{if(!e)return[];let t=r.trim().toLowerCase();return e.plugins.filter(e=>(_===`all`||e.category===_)&&(b===`all`||e.source===b)&&(!t||(e.name+` `+(e.description||``)).toLowerCase().includes(t)))},[e,r,_,b]),I=(0,A.useMemo)(()=>{let t={};for(let n of e?.plugins??[])t[n.category]=(t[n.category]||0)+1;return Object.entries(t).sort((e,t)=>t[1]-e[1])},[e]);async function z(e){T(e),P(`native`);try{let e=await m.instances();k((e.instances??[]).filter(e=>e.domain===`sandbox`).map(e=>({id:e.id,name:e.name})))}catch{k([])}}async function B(){if(w)try{let e=await m.pluginInstall(w.name,j);if(e.ok===!1){t.error(e.error||`安装失败`);return}t.success(`安装任务已提交`+(e.jobId?`(job `+e.jobId+`)`:``)),T(null)}catch(e){t.error(String(e))}}return(0,M.jsxs)(`div`,{className:`grid content-start gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`relative min-w-[220px] flex-1`,children:[(0,M.jsx)(O,{className:`absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(c,{className:`pl-8`,placeholder:`搜索插件名称、描述…`,value:r,onChange:e=>i(e.target.value)})]}),(0,M.jsxs)(f,{value:_,onValueChange:y,children:[(0,M.jsx)(u,{className:`h-9 w-[150px] shrink-0`,children:(0,M.jsx)(g,{placeholder:`全部分类`})}),(0,M.jsxs)(h,{children:[(0,M.jsx)(s,{value:`all`,children:`全部分类`}),I.map(([e,t])=>(0,M.jsxs)(s,{value:e,children:[e,` (`,t,`)`]},e))]})]}),(0,M.jsxs)(f,{value:b,onValueChange:x,children:[(0,M.jsx)(u,{className:`h-9 w-[130px] shrink-0`,children:(0,M.jsx)(g,{placeholder:`全部来源`})}),(0,M.jsxs)(h,{children:[(0,M.jsx)(s,{value:`all`,children:`全部来源`}),(0,M.jsx)(s,{value:`npm`,children:`npm`}),(0,M.jsx)(s,{value:`github`,children:`GitHub`}),(0,M.jsx)(s,{value:`community`,children:`社区`}),(0,M.jsx)(s,{value:`official`,children:`官方`})]})]})]}),e?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`共 `,e.plugins.length,` 个插件 · 更新 `,e.indexedAt?new Date(e.indexedAt).toLocaleString():`—`,` · npm `,e.sources?.npm||0,` · GitHub `,e.sources?.github||0,` · 社区 `,e.sources?.community||0]}),F.length?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:F.slice(0,S).map(e=>(0,M.jsxs)(`div`,{className:`flex min-h-[150px] flex-col rounded-lg border border-border bg-card p-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`strong`,{className:`truncate font-mono text-sm text-foreground`,children:e.name}),(0,M.jsx)(E,{tone:R(e.source),children:L(e.source)})]}),(0,M.jsx)(`p`,{className:`mt-2 line-clamp-3 min-h-[36px] text-xs leading-relaxed text-muted-foreground`,children:e.description||`(无描述)`}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:e.category}),e.version?(0,M.jsxs)(`span`,{className:`font-mono`,children:[`v`,e.version]}):null,e.stars?(0,M.jsxs)(`span`,{children:[`⭐`,e.stars]}):null]}),(0,M.jsxs)(`div`,{className:`mt-auto flex items-center justify-between gap-2 pt-3`,children:[(0,M.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.author||``}),(0,M.jsx)(v,{onClick:()=>void z(e),size:`chip`,children:`安装`})]})]},e.name))}),S<F.length?(0,M.jsxs)(v,{className:`justify-self-center`,onClick:()=>C(e=>e+N),variant:`outline`,children:[`加载更多(`,S,`/`,F.length,`)`]}):null]}):(0,M.jsx)(`div`,{className:`grid place-items-center rounded-lg border border-dashed border-border py-16 text-sm text-muted-foreground`,children:`无匹配插件`})]}):(0,M.jsx)(`div`,{className:`grid place-items-center py-20 text-sm text-muted-foreground`,children:`加载插件索引…`}),(0,M.jsx)(p,{open:!!w,onOpenChange:e=>!e&&T(null),children:(0,M.jsxs)(d,{className:`max-w-[400px]`,children:[(0,M.jsx)(l,{children:(0,M.jsxs)(a,{children:[`安装插件 — `,w?.name]})}),(0,M.jsx)(`div`,{className:`grid gap-2`,children:[[`native`,`原生实例`],[`all`,`所有实例(含原生)`]].concat(D.map(e=>[`id:`+e.id,e.name+`(`+e.id.slice(0,8)+`…)`])).map(([e,t])=>(0,M.jsxs)(`label`,{className:o(`flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 text-sm`,j===e?`border-primary/40 bg-primary/[0.05] text-foreground`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,M.jsx)(`input`,{type:`radio`,className:`accent-primary`,name:`pTarget`,checked:j===e,onChange:()=>P(e)}),t]},e))}),(0,M.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,M.jsx)(v,{onClick:()=>T(null),variant:`outline`,children:`取消`}),(0,M.jsx)(v,{onClick:()=>void B(),children:`开始安装`})]})]})})]})}var L=e=>({npm:`npm`,github:`GitHub`,community:`社区`,official:`官方`})[e]??e,R=e=>e===`official`?`boot`:e===`npm`?`ok`:e===`github`?`warn`:`off`;function z(){let[e,n]=(0,A.useState)(null),[r,i]=(0,A.useState)(`all`),[a,s]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(new Map),[u,d]=(0,A.useState)(!1),{busy:f,run:p}=w(),h=async()=>{let e=await m.pluginsInstalled().catch(()=>null);n(e)};(0,A.useEffect)(()=>{h()},[]);let g=e?.thirdParty??[],O=e=>e.targets&&e.targets.length?e.targets:[`native`],k=g.filter(e=>r===`all`||O(e).includes(r)),N=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=k.length>0&&k.every(e=>a.has(e.name)),F=()=>s(P?new Set:new Set(k.map(e=>e.name))),I=k.filter(e=>a.has(e.name)),L=I.some(e=>c.has(e.name)),R=I.filter(e=>e.enabled),z=I.filter(e=>!e.enabled);async function B(){d(!0);try{let e=await m.pluginsCheckUpdates(!0),n=new Map;for(let t of e.plugins??[]){if(!t.updateAvailable)continue;let e=t.targets?.find(e=>e.latest)?.latest||``;n.set(t.name,e)}l(n),t.success(n.size?`发现 `+n.size+` 个可更新插件`:`全部插件已是最新`),await h()}catch(e){t.error(String(e))}d(!1)}async function V(){let e=I.filter(e=>c.has(e.name)).map(e=>e.name);if(!e.length){t.info(`所选插件均无可用更新`);return}s(new Set),l(t=>{let n=new Map(t);for(let t of e)n.delete(t);return n}),await p(`upd-sel`,async()=>{for(let t of e)try{await m.pluginUpdate(t)}catch{}},{success:`已提交 `+e.length+` 个插件的更新任务`,refresh:!1,onDone:()=>void h()})}async function H(){let e=I.map(e=>e.name);confirm(`将卸载所选 `+e.length+` 个插件:
2
+ `+e.join(`
3
+ `)+`
4
+
5
+ 确定继续?`)&&(s(new Set),await p(`uni-sel`,async()=>{for(let t of e)try{await m.pluginUninstall(t)}catch{}},{success:`已提交 `+e.length+` 个插件的卸载任务`,refresh:!1,onDone:()=>void h()}))}async function U(){let e=R.map(e=>e.name);s(new Set),await p(`stop-sel`,async()=>{for(let t of e)try{await m.pluginDisable(t)}catch{}},{success:`已停止 `+e.length+` 个插件`,refresh:!1,onDone:()=>void h()})}async function W(){let e=z.map(e=>e.name);s(new Set),await p(`start-sel`,async()=>{for(let t of e)try{await m.pluginEnable(t)}catch{}},{success:`已启动 `+e.length+` 个插件`,refresh:!1,onDone:()=>void h()})}let G=`grid grid-cols-[88px_minmax(0,1fr)_120px_84px_36px] items-center gap-3`;return(0,M.jsxs)(D,{className:`overflow-hidden`,children:[(0,M.jsx)(T,{title:`已安装插件`+(e?`(`+k.length+`)`:``),subtitle:r===`all`?`全部实例`:`实例:`+((e?.targets??[]).find(e=>e.id===r)?.name??r),actions:(0,M.jsxs)(M.Fragment,{children:[L?(0,M.jsxs)(v,{disabled:f===`upd-sel`,onClick:()=>void V(),size:`sm`,children:[(0,M.jsx)(x,{className:`size-3.5`}),`更新(`,I.filter(e=>c.has(e.name)).length,`)`]}):(0,M.jsxs)(v,{disabled:u,onClick:()=>void B(),size:`sm`,variant:`outline`,children:[(0,M.jsx)(x,{className:o(`size-3.5`,u&&`animate-spin`)}),u?`检查中…`:`检查更新`]}),I.length>0?(0,M.jsxs)(M.Fragment,{children:[R.length>0?(0,M.jsxs)(v,{disabled:f===`stop-sel`,onClick:()=>void U(),size:`sm`,variant:`outline`,children:[(0,M.jsx)(y,{className:`size-3.5`}),`停用(`,R.length,`)`]}):null,z.length>0?(0,M.jsxs)(v,{disabled:f===`start-sel`,onClick:()=>void W(),size:`sm`,variant:`outline`,children:[(0,M.jsx)(b,{className:`size-3.5`}),`启动(`,z.length,`)`]}):null,(0,M.jsxs)(v,{className:`h-[30px]`,disabled:f===`uni-sel`,onClick:()=>void H(),size:`sm`,variant:`destructive`,children:[(0,M.jsx)(S,{className:`size-3.5`}),`卸载(`,I.length,`)`]})]}):null]})}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border/60 px-5 py-2.5`,children:[(0,M.jsx)(v,{className:o(r===`all`?`bg-primary/10 text-primary hover:bg-primary/15`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:()=>i(`all`),size:`sm`,variant:`ghost`,children:`全部实例`}),(e?.targets??[]).map(e=>(0,M.jsx)(v,{className:o(r===e.id?`bg-primary/10 text-primary hover:bg-primary/15`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:()=>i(e.id),size:`sm`,variant:`ghost`,children:e.name},e.id))]}),e?k.length?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:o(G,`border-b border-border/70 bg-muted px-5 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`),children:[(0,M.jsx)(`span`,{children:`来源`}),(0,M.jsx)(`span`,{children:`插件`}),(0,M.jsx)(`span`,{children:`版本`}),(0,M.jsx)(`span`,{className:`text-right`,children:`大小`}),(0,M.jsx)(`span`,{className:`flex justify-end`,children:(0,M.jsx)(_,{"aria-label":`全选`,checked:P,onChange:F})})]}),(0,M.jsx)(`div`,{className:`max-h-[560px] overflow-auto`,children:k.map(e=>{let t=a.has(e.name),n=c.get(e.name);return(0,M.jsxs)(`label`,{className:o(G,`min-h-[46px] w-full cursor-pointer border-b border-border/50 px-5 py-2 text-left transition-colors last:border-b-0 hover:bg-muted/40`,t&&`bg-muted/70 shadow-[inset_3px_0_0_var(--primary)]`),children:[(0,M.jsx)(`span`,{className:`inline-flex w-fit min-w-0 items-center`,children:(0,M.jsx)(E,{tone:e.bundle?`boot`:e.source?.includes(`github`)?`warn`:e.source===`npm`?`ok`:`off`,children:e.bundle?`bundle`:e.source===`npm`?`npm`:e.source?.includes(`github`)?`GitHub`:e.source&&e.source!==e.name?`本地`:`—`})}),(0,M.jsx)(`span`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2`,children:(0,M.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`strong`,{className:`truncate font-mono text-[13px] font-semibold leading-tight text-foreground`,children:e.name}),(0,M.jsx)(E,{tone:e.enabled?`ok`:`off`,children:e.enabled?`已启用`:`已停用`})]}),e.description?(0,M.jsx)(`span`,{className:`truncate text-xs leading-tight text-muted-foreground`,children:e.description}):null]})}),(0,M.jsx)(`span`,{className:`min-w-0`,children:n?(0,M.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.version?`v`+e.version:`—`}),(0,M.jsx)(E,{tone:`warn`,children:`可更新`})]}):(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.version?`v`+e.version:`—`})}),(0,M.jsx)(`span`,{className:`text-right font-mono text-xs tabular-nums text-foreground`,children:e.size?j(e.size):`—`}),(0,M.jsx)(`span`,{className:`flex justify-end`,children:(0,M.jsx)(_,{"aria-label":`选择 `+e.name,checked:t,onChange:()=>N(e.name)})})]},e.name)})})]}):(0,M.jsxs)(`div`,{className:`grid place-items-center rounded-lg border-0 py-16 text-center`,children:[(0,M.jsx)(C,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`当前实例均未安装第三方插件`})]}):(0,M.jsx)(`div`,{className:`py-16 text-center text-sm text-muted-foreground`,children:`加载中…`})]})}export{P as PluginsPage};
@@ -0,0 +1,5 @@
1
+ import{E as e,L as t,O as n,P as r,T as i,_ as a,b as o,c as s,d as c,f as l,g as u,h as d,k as f,l as p,p as m,r as h,s as g,u as _,w as v,y,z as b}from"./supervisor-05X9PT9U.js";import{n as x,t as S}from"./rocket-KILE2qPr.js";import{t as C}from"./refresh-cw-Dl1i4xVh.js";import{c as w,u as T}from"./supervisor-CKm4a1yh.js";import{t as E}from"./useSupervisorAction-CPqt8YnP.js";import{n as D,o as O,t as k}from"./widgets-C1m9qxfG.js";var A=r(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),j=r(`store`,[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]),M=b(t(),1);function N(e){return e>=1073741824?`${(e/1024/1024/1024).toFixed(1)} GB`:e>=1048576?`${(e/1024/1024).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}var P=n(),F=24;function I(){let[t,n]=(0,M.useState)(`market`);return(0,P.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-muted p-1`,children:[`market`,`installed`].map(r=>(0,P.jsxs)(i,{className:e(`font-medium`,t===r?`bg-card text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-card/60 hover:text-foreground`),onClick:()=>n(r),size:`sm`,variant:`ghost`,children:[r===`market`?(0,P.jsx)(j,{className:`size-3.5`}):(0,P.jsx)(T,{className:`size-3.5`}),r===`market`?`插件商店`:`已安装`]},r))}),t===`market`?(0,P.jsx)(L,{}):null]}),t===`market`?(0,P.jsx)(R,{}):(0,P.jsx)(V,{})]})}function L(){let[t,n]=(0,M.useState)(!1);async function r(){n(!0);try{await h.market(!0),f.success(`插件索引已刷新`)}catch(e){f.error(String(e))}n(!1)}return(0,P.jsxs)(i,{disabled:t,onClick:()=>void r(),size:`chip`,variant:`outline`,children:[(0,P.jsx)(C,{className:e(`size-3.5`,t&&`animate-spin`)}),`刷新`]})}function R(){let[t,n]=(0,M.useState)(null),[r,v]=(0,M.useState)(``),[b,x]=(0,M.useState)(`all`),[S,C]=(0,M.useState)(`all`),[w,T]=(0,M.useState)(0),[E,D]=(0,M.useState)(null),[k,j]=(0,M.useState)([]),[N,I]=(0,M.useState)(`native`);(0,M.useEffect)(()=>{let e=!0;return h.market().then(t=>{e&&(n(t),T(F))}).catch(()=>void 0),()=>{e=!1}},[]);let L=(0,M.useMemo)(()=>{if(!t)return[];let e=r.trim().toLowerCase();return t.plugins.filter(t=>(b===`all`||t.category===b)&&(S===`all`||t.source===S)&&(!e||(t.name+` `+(t.description||``)).toLowerCase().includes(e)))},[t,r,b,S]),R=(0,M.useMemo)(()=>{let e={};for(let n of t?.plugins??[])e[n.category]=(e[n.category]||0)+1;return Object.entries(e).sort((e,t)=>t[1]-e[1])},[t]);async function V(e){D(e),I(`native`);try{let e=await h.instances();j((e.instances??[]).filter(e=>e.domain===`sandbox`).map(e=>({id:e.id,name:e.name})))}catch{j([])}}async function H(){if(E)try{let e=await h.pluginInstall(E.name,N);if(e.ok===!1){f.error(e.error||`安装失败`);return}f.success(`安装任务已提交`+(e.jobId?`(job `+e.jobId+`)`:``)),D(null)}catch(e){f.error(String(e))}}return(0,P.jsxs)(`div`,{className:`grid content-start gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative min-w-[220px] flex-1`,children:[(0,P.jsx)(A,{className:`absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,P.jsx)(d,{className:`pl-8`,placeholder:`搜索插件名称、描述…`,value:r,onChange:e=>v(e.target.value)})]}),(0,P.jsxs)(g,{value:b,onValueChange:x,children:[(0,P.jsx)(_,{className:`h-9 w-[150px] shrink-0`,children:(0,P.jsx)(c,{placeholder:`全部分类`})}),(0,P.jsxs)(s,{children:[(0,P.jsx)(p,{value:`all`,children:`全部分类`}),R.map(([e,t])=>(0,P.jsxs)(p,{value:e,children:[e,` (`,t,`)`]},e))]})]}),(0,P.jsxs)(g,{value:S,onValueChange:C,children:[(0,P.jsx)(_,{className:`h-9 w-[130px] shrink-0`,children:(0,P.jsx)(c,{placeholder:`全部来源`})}),(0,P.jsxs)(s,{children:[(0,P.jsx)(p,{value:`all`,children:`全部来源`}),(0,P.jsx)(p,{value:`npm`,children:`npm`}),(0,P.jsx)(p,{value:`github`,children:`GitHub`}),(0,P.jsx)(p,{value:`community`,children:`社区`}),(0,P.jsx)(p,{value:`official`,children:`官方`})]})]})]}),t?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`共 `,t.plugins.length,` 个插件 · 更新 `,t.indexedAt?new Date(t.indexedAt).toLocaleString():`—`,` · npm `,t.sources?.npm||0,` · GitHub `,t.sources?.github||0,` · 社区 `,t.sources?.community||0]}),L.length?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`grid grid-cols-1 gap-3 @min-[640px]:grid-cols-2 @min-[1000px]:grid-cols-3`,children:L.slice(0,w).map(e=>(0,P.jsxs)(`div`,{className:`flex min-h-[150px] flex-col rounded-lg border border-border bg-card p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsx)(`strong`,{className:`truncate font-mono text-sm text-foreground`,children:e.name}),(0,P.jsx)(O,{tone:B(e.source),children:z(e.source)})]}),(0,P.jsx)(`p`,{className:`mt-2 line-clamp-3 min-h-[36px] text-xs leading-relaxed text-muted-foreground`,children:e.description||`(无描述)`}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,P.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:e.category}),e.version?(0,P.jsxs)(`span`,{className:`font-mono`,children:[`v`,e.version]}):null,e.stars?(0,P.jsxs)(`span`,{children:[`⭐`,e.stars]}):null]}),(0,P.jsxs)(`div`,{className:`mt-auto flex items-center justify-between gap-2 pt-3`,children:[(0,P.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.author||``}),(0,P.jsx)(i,{onClick:()=>void V(e),size:`chip`,children:`安装`})]})]},e.name))}),w<L.length?(0,P.jsxs)(i,{className:`justify-self-center`,onClick:()=>T(e=>e+F),variant:`outline`,children:[`加载更多(`,w,`/`,L.length,`)`]}):null]}):(0,P.jsx)(`div`,{className:`grid place-items-center rounded-lg border border-dashed border-border py-16 text-sm text-muted-foreground`,children:`无匹配插件`})]}):(0,P.jsx)(`div`,{className:`grid place-items-center py-20 text-sm text-muted-foreground`,children:`加载插件索引…`}),(0,P.jsx)(u,{open:!!E,onOpenChange:e=>!e&&D(null),children:(0,P.jsxs)(a,{className:`max-w-[400px]`,children:[(0,P.jsx)(y,{children:(0,P.jsxs)(o,{children:[`安装插件 — `,E?.name]})}),(0,P.jsx)(`div`,{className:`grid gap-2`,children:(0,P.jsx)(l,{value:N,onValueChange:I,className:`grid gap-2`,children:[[`native`,`原生实例`],[`all`,`所有实例(含原生)`]].concat(k.map(e=>[`id:`+e.id,e.name+`(`+e.id.slice(0,8)+`…)`])).map(([t,n])=>(0,P.jsxs)(`label`,{className:e(`flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 text-sm`,N===t?`border-primary/40 bg-primary/[0.05] text-foreground`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,P.jsx)(m,{value:t}),n]},t))})}),(0,P.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,P.jsx)(i,{onClick:()=>D(null),variant:`outline`,children:`取消`}),(0,P.jsx)(i,{onClick:()=>void H(),children:`开始安装`})]})]})})]})}var z=e=>({npm:`npm`,github:`GitHub`,community:`社区`,official:`官方`})[e]??e,B=e=>e===`official`?`boot`:e===`npm`?`ok`:e===`github`?`warn`:`off`;function V(){let[t,n]=(0,M.useState)(null),[r,a]=(0,M.useState)(`all`),[o,s]=(0,M.useState)(new Set),[c,l]=(0,M.useState)(new Map),[u,d]=(0,M.useState)(!1),{busy:p,run:m}=E(),g=async()=>{let e=await h.pluginsInstalled().catch(()=>null);n(e)};(0,M.useEffect)(()=>{g()},[]);let _=t?.thirdParty??[],y=e=>e.targets&&e.targets.length?e.targets:[`native`],b=_.filter(e=>r===`all`||y(e).includes(r)),A=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),j=b.length>0&&b.every(e=>o.has(e.name)),F=()=>s(j?new Set:new Set(b.map(e=>e.name))),I=b.filter(e=>o.has(e.name)),L=I.some(e=>c.has(e.name)),R=I.filter(e=>e.enabled),z=I.filter(e=>!e.enabled);async function B(){d(!0);try{let e=await h.pluginsCheckUpdates(!0),t=new Map;for(let n of e.plugins??[]){if(!n.updateAvailable)continue;let e=n.targets?.find(e=>e.latest)?.latest||``;t.set(n.name,e)}l(t),f.success(t.size?`发现 `+t.size+` 个可更新插件`:`全部插件已是最新`),await g()}catch(e){f.error(String(e))}d(!1)}async function V(){let e=I.filter(e=>c.has(e.name)).map(e=>e.name);if(!e.length){f.info(`所选插件均无可用更新`);return}s(new Set),l(t=>{let n=new Map(t);for(let t of e)n.delete(t);return n}),await m(`upd-sel`,async()=>{for(let t of e)try{await h.pluginUpdate(t)}catch{}},{success:`已提交 `+e.length+` 个插件的更新任务`,refresh:!1,onDone:()=>void g()})}async function H(){let e=I.map(e=>e.name);confirm(`将卸载所选 `+e.length+` 个插件:
2
+ `+e.join(`
3
+ `)+`
4
+
5
+ 确定继续?`)&&(s(new Set),await m(`uni-sel`,async()=>{for(let t of e)try{await h.pluginUninstall(t)}catch{}},{success:`已提交 `+e.length+` 个插件的卸载任务`,refresh:!1,onDone:()=>void g()}))}async function U(){let e=R.map(e=>e.name);s(new Set),await m(`stop-sel`,async()=>{for(let t of e)try{await h.pluginDisable(t)}catch{}},{success:`已停止 `+e.length+` 个插件`,refresh:!1,onDone:()=>void g()})}async function W(){let e=z.map(e=>e.name);s(new Set),await m(`start-sel`,async()=>{for(let t of e)try{await h.pluginEnable(t)}catch{}},{success:`已启动 `+e.length+` 个插件`,refresh:!1,onDone:()=>void g()})}let G=`grid grid-cols-[88px_minmax(0,1fr)_120px_84px_36px] items-center gap-3`;return(0,P.jsxs)(k,{className:`overflow-hidden`,children:[(0,P.jsx)(D,{title:`已安装插件`+(t?`(`+b.length+`)`:``),subtitle:r===`all`?`全部实例`:`实例:`+((t?.targets??[]).find(e=>e.id===r)?.name??r),actions:(0,P.jsxs)(P.Fragment,{children:[L?(0,P.jsxs)(i,{disabled:p===`upd-sel`,onClick:()=>void V(),size:`sm`,children:[(0,P.jsx)(C,{className:`size-3.5`}),`更新(`,I.filter(e=>c.has(e.name)).length,`)`]}):(0,P.jsxs)(i,{disabled:u,onClick:()=>void B(),size:`sm`,variant:`outline`,children:[(0,P.jsx)(C,{className:e(`size-3.5`,u&&`animate-spin`)}),u?`检查中…`:`检查更新`]}),I.length>0?(0,P.jsxs)(P.Fragment,{children:[R.length>0?(0,P.jsxs)(i,{disabled:p===`stop-sel`,onClick:()=>void U(),size:`sm`,variant:`outline`,children:[(0,P.jsx)(x,{className:`size-3.5`}),`停用(`,R.length,`)`]}):null,z.length>0?(0,P.jsxs)(i,{disabled:p===`start-sel`,onClick:()=>void W(),size:`sm`,variant:`outline`,children:[(0,P.jsx)(S,{className:`size-3.5`}),`启动(`,z.length,`)`]}):null,(0,P.jsxs)(i,{className:`h-[30px]`,disabled:p===`uni-sel`,onClick:()=>void H(),size:`sm`,variant:`destructive`,children:[(0,P.jsx)(w,{className:`size-3.5`}),`卸载(`,I.length,`)`]})]}):null]})}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border/60 px-5 py-2.5`,children:[(0,P.jsx)(i,{className:e(r===`all`?`bg-primary/10 text-primary hover:bg-primary/15`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:()=>a(`all`),size:`sm`,variant:`ghost`,children:`全部实例`}),(t?.targets??[]).map(t=>(0,P.jsx)(i,{className:e(r===t.id?`bg-primary/10 text-primary hover:bg-primary/15`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:()=>a(t.id),size:`sm`,variant:`ghost`,children:t.name},t.id))]}),t?b.length?(0,P.jsx)(P.Fragment,{children:(0,P.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,P.jsxs)(`div`,{className:e(G,`min-w-[720px] border-b border-border/70 bg-muted px-5 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`),children:[(0,P.jsx)(`span`,{children:`来源`}),(0,P.jsx)(`span`,{children:`插件`}),(0,P.jsx)(`span`,{children:`版本`}),(0,P.jsx)(`span`,{className:`text-right`,children:`大小`}),(0,P.jsx)(`span`,{className:`flex justify-end`,children:(0,P.jsx)(v,{"aria-label":`全选`,checked:j,onChange:F})})]}),(0,P.jsx)(`div`,{className:`max-h-[560px] overflow-auto`,children:b.map(t=>{let n=o.has(t.name),r=c.get(t.name);return(0,P.jsxs)(`label`,{className:e(G,`min-h-[46px] min-w-[720px] w-full cursor-pointer border-b border-border/50 px-5 py-2 text-left transition-colors last:border-b-0 hover:bg-muted/40`,n&&`bg-muted/70 shadow-[inset_3px_0_0_var(--primary)]`),children:[(0,P.jsx)(`span`,{className:`inline-flex w-fit min-w-0 items-center`,children:(0,P.jsx)(O,{tone:t.bundle?`boot`:t.source?.includes(`github`)?`warn`:t.source===`npm`?`ok`:`off`,children:t.bundle?`bundle`:t.source===`npm`?`npm`:t.source?.includes(`github`)?`GitHub`:t.source&&t.source!==t.name?`本地`:`—`})}),(0,P.jsx)(`span`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2`,children:(0,P.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(`strong`,{className:`truncate font-mono text-[13px] font-semibold leading-tight text-foreground`,children:t.name}),(0,P.jsx)(O,{tone:t.enabled?`ok`:`off`,children:t.enabled?`已启用`:`已停用`})]}),t.description?(0,P.jsx)(`span`,{className:`truncate text-xs leading-tight text-muted-foreground`,children:t.description}):null]})}),(0,P.jsx)(`span`,{className:`min-w-0`,children:r?(0,P.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:t.version?`v`+t.version:`—`}),(0,P.jsx)(O,{tone:`warn`,children:`可更新`})]}):(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.version?`v`+t.version:`—`})}),(0,P.jsx)(`span`,{className:`text-right font-mono text-xs tabular-nums text-foreground`,children:t.size?N(t.size):`—`}),(0,P.jsx)(`span`,{className:`flex justify-end`,children:(0,P.jsx)(v,{"aria-label":`选择 `+t.name,checked:n,onChange:()=>A(t.name)})})]},t.name)})})]})}):(0,P.jsxs)(`div`,{className:`grid place-items-center rounded-lg border-0 py-16 text-center`,children:[(0,P.jsx)(T,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`当前实例均未安装第三方插件`})]}):(0,P.jsx)(`div`,{className:`py-16 text-center text-sm text-muted-foreground`,children:`加载中…`})]})}export{I as PluginsPage};
@@ -0,0 +1 @@
1
+ import{A as e,C as t,D as n,M as r,S as i,T as a,_ as o,b as s,c,g as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,y}from"./supervisor-DEHXL51C.js";import{n as b,t as x}from"./rocket-BDT9yN5c.js";import{t as S}from"./refresh-cw-Dbn7zlS9.js";import{c as C,f as w,l as T}from"./supervisor-C3UXEQbW.js";import{t as E}from"./useSupervisorAction-Dj_nAGhv.js";import{a as D,c as O,i as k,o as A,s as j,t as M}from"./widgets-C6MCpT1T.js";import{n as N}from"./format-QeaTKFhQ.js";var P=n(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),F=n(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),I=n(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),L=n(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),R=n(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),z=r(e(),1),B=i();function V(e){if(!e)return!1;let t=e=>!!(e&&(e.status===`rate-limited`||Number(e.percent)>=100));return t(e.rolling)||t(e.weekly)||t(e.monthly)}function H(e){return!e||!Number.isFinite(e)?``:new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function U(e){return[...e].sort((e,t)=>{let n=e=>e.selected?0:e.usable&&!V(e.quota)?1:2;return n(e)-n(t)})}var W=`grid-cols-[minmax(0,1fr)_230px_84px]`;function G({onRegisterActions:e}){let{snap:t}=_(),{busy:n,run:r}=E(),[i,o]=(0,z.useState)(!1),[c,l]=(0,z.useState)(!1),u=t.router,d=t.providers;(0,z.useEffect)(()=>(e?.({onAdd:()=>o(!0),onDelete:()=>l(!0)}),()=>e?.(null)),[e]);function p(e,t,n){return r(e,t,{success:n})}let m=d?.providers??[];return(0,B.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,B.jsxs)(M,{children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border/70 px-5 py-3.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(O,{tone:u?.running?`ok`:u?.conflict?`warn`:`off`,ping:!!u?.running}),(0,B.jsx)(`strong`,{className:`text-xl font-semibold tracking-[-0.01em] text-foreground`,children:u?.running?`路由运行中`:u?.conflict?`端口被占`:`路由已停止`}),u?.autostart?(0,B.jsx)(A,{tone:`boot`,children:`自动启动`}):null]}),(0,B.jsx)(y,{"aria-label":u?.running?`停止路由`:`启动路由`,className:s(`px-1`,u?.running?`text-status-error`:`text-primary`),disabled:n===`sw`,onClick:()=>void p(`sw`,()=>u?.running?h.lifecycleStop(`router`):h.lifecycleStart(`router`),u?.running?`路由已停止`:`路由已启动`),title:u?.running?`停止路由`:`启动路由`,variant:`ghost`,children:u?.running?(0,B.jsx)(b,{className:`size-6`}):(0,B.jsx)(x,{className:`size-6`})})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 divide-y divide-border/60 sm:grid-cols-2 sm:divide-y-0 lg:grid-cols-4 lg:divide-x lg:divide-border/60`,children:[(0,B.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,B.jsx)(k,{icon:(0,B.jsx)(w,{className:`size-4`}),label:`总请求 / 失败`,value:N(u?.usage.requests)+` / `+N(u?.usage.errors),mono:!0})}),(0,B.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,B.jsx)(k,{icon:(0,B.jsx)(a,{className:`size-4`}),label:`总 Tokens`,value:N(u?.usage.totalTokens),mono:!0})}),(0,B.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,B.jsx)(k,{icon:(0,B.jsx)(R,{className:`size-4`}),label:`Prompt / Completion`,value:N(u?.usage.promptTokens)+` / `+N(u?.usage.completionTokens),mono:!0})}),(0,B.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,B.jsx)(k,{icon:(0,B.jsx)(F,{className:`size-4`}),label:`估算费用`,value:u?.usage.costUsd?`$`+Number(u.usage.costUsd).toFixed(4):`—`,mono:!0,warn:!u?.usage.costUsd})})]})]}),m.length?(0,B.jsx)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:m.map(e=>(0,B.jsx)(q,{p:e,proxyApps:d?.proxyApps??[],busy:n===e.id,onAction:p},e.id))}):(0,B.jsx)(`div`,{className:`grid min-h-[200px] place-items-center rounded-lg border border-dashed border-border text-center`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(w,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,B.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`尚未添加供应商`}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`点击「添加供应商」录入 API Key / Command Code`})]})}),(0,B.jsx)(Q,{open:i,onOpenChange:o,presets:d?.presets??[],proxyApps:d?.proxyApps??[],onDone:()=>f.refresh()}),(0,B.jsx)(K,{open:c,onOpenChange:l,providers:m})]})}function K({open:e,onOpenChange:n,providers:r}){let[i,a]=(0,z.useState)(null);async function s(e){if(confirm(`删除供应商「`+e.name+`」?其下全部账号与 Key 将被移除,不可恢复。`)){a(e.id);try{await h.providerRemove(e.id),t.success(`已删除供应商「`+e.name+`」`),await f.refresh()}catch(e){t.error(String(e))}finally{a(null)}}}return(0,B.jsx)(m,{open:e,onOpenChange:n,children:(0,B.jsxs)(d,{className:`max-w-[440px]`,children:[(0,B.jsx)(l,{children:(0,B.jsx)(o,{children:`删除供应商`})}),(0,B.jsx)(`div`,{className:`grid gap-1.5`,children:r.length?r.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`strong`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.kind===`proxy`?`反代`:`直连`,` · `,(e.accounts??[]).length,` 账号`]})]}),(0,B.jsxs)(y,{disabled:i===e.id,onClick:()=>void s(e),size:`chip`,variant:`destructive`,children:[i===e.id?(0,B.jsx)(S,{className:`size-3 animate-spin`}):(0,B.jsx)(C,{className:`size-3`}),`删除`]})]},e.id)):(0,B.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`暂无供应商`})}),(0,B.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,B.jsx)(y,{onClick:()=>n(!1),variant:`outline`,children:`关闭`})})]})})}function q({p:e,proxyApps:n,busy:r,onAction:i}){let a=U(e.accounts??[]),o=a.find(e=>e.selected)||a.find(e=>e.usable&&!V(e.quota))||a[0],[c,l]=(0,z.useState)(!1),u=e.kind===`proxy`?(n??[]).find(t=>t.id===e.proxyAppId)??null:null,d=e.apiBase||(e.apiPort?`http://127.0.0.1:`+e.apiPort+`/v1`:null);return(0,B.jsxs)(M,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border/70 bg-muted px-5 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:e.name}),e.kind===`proxy`&&u&&u.installed?u.updateAvailable?(0,B.jsxs)(y,{className:`gap-1 rounded-full px-2.5 text-xs text-warning`,disabled:r,onClick:()=>void i(`proxy-upd-`+e.id,()=>h.proxyUpdateApply(e.proxyAppId).then(()=>void 0),`已提交更新,所有实例将依次更新并重启`),size:`chip`,title:`检测到新版本,点击更新该应用全部实例`,variant:`outline`,children:[(0,B.jsx)(S,{className:`size-3`}),`更新 v`,u.latest]}):(0,B.jsxs)(y,{className:`gap-1 rounded-full px-2.5 text-xs font-mono text-muted-foreground`,disabled:r,onClick:()=>{i(`proxy-chk-`+e.id,async()=>{let n=await h.proxyUpdateCheck();if(await f.refresh(),!n.ok){t.error(n.error||`版本检测失败`);return}let r=n.versions?.[e.proxyAppId||``]||null,i=u.installed;t.info(r&&r!==i?`发现新版本 v`+r+`,点击版本胶囊更新`:`已是最新版本 v`+i)},void 0)},size:`chip`,title:`检测是否有新版本`,variant:`outline`,children:[`v`,u.installed,(0,B.jsx)(S,{className:s(`size-3`,r&&`animate-spin`)})]}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[(0,B.jsxs)(y,{disabled:r,onClick:()=>l(!0),size:`sm`,variant:`outline`,children:[(0,B.jsx)(T,{className:`size-3.5`}),`添加`]}),e.activated?(0,B.jsxs)(y,{disabled:r,onClick:()=>void i(`deact`,()=>h.providerDeactivate(e.id).then(()=>void 0),`已停用供应商(资源已回收)`),size:`sm`,variant:`outline`,children:[(0,B.jsx)(b,{className:`size-3.5`}),`停用`]}):(0,B.jsxs)(y,{disabled:r,onClick:()=>void i(`act`,()=>h.providerActivate(e.id).then(()=>void 0),`已启用供应商`),size:`sm`,variant:`outline`,children:[(0,B.jsx)(x,{className:`size-3.5`}),`启用`]})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-5 py-2.5`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`API 地址`}),(0,B.jsx)(`div`,{className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border border-border bg-card px-2.5`,children:e.activated&&d?(0,B.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:d}):(0,B.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/70`,children:`服务未启用`})}),e.activated&&d?(0,B.jsxs)(y,{onClick:()=>void navigator.clipboard.writeText(d||``).then(()=>t.success(`已复制 API 地址`)),size:`sm`,title:`复制该供应商 API 地址`,variant:`outline`,children:[(0,B.jsx)(I,{className:`size-3.5`}),`复制`]}):null]}),o?(0,B.jsx)(Y,{acc:o,busy:r,p:e,onAction:i}):(0,B.jsx)(`div`,{className:`px-5 py-3 text-xs text-muted-foreground`,children:`暂无账号数据`}),a.length?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col border-t border-border/60`,children:[(0,B.jsxs)(`div`,{className:s(`grid items-center gap-2 border-b border-border/60 bg-muted/60 px-5 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,W),children:[(0,B.jsx)(`span`,{children:e.kind===`proxy`?`账号实例`:`API Key`}),(0,B.jsx)(`span`,{className:`text-center`,children:`用量`}),(0,B.jsx)(`span`,{className:`text-center`,children:`操作`})]}),(0,B.jsx)(`div`,{className:`max-h-[288px] min-h-0 overflow-y-auto overscroll-contain`,children:a.map((t,n)=>(0,B.jsx)(`div`,{className:s(n>0&&`border-t border-border/50`),children:(0,B.jsx)(X,{a:t,p:e,busy:r,onAction:i})},t.keyId))})]}):(0,B.jsx)(`p`,{className:`border-t border-border/60 px-5 py-3 text-xs text-muted-foreground`,children:`暂无 Keys — 点「添加」录入`}),(0,B.jsx)(J,{open:c,onOpenChange:l,p:e})]})}function J({open:e,onOpenChange:n,p:r}){let i=r.accounts??[],[a,s]=(0,z.useState)(``),[c,u]=(0,z.useState)(!1),[p,g]=(0,z.useState)(!1),_=r.kind===`proxy`;async function v(){g(!0);try{let e=await h.proxyLoginStart();if(!e.ok){t.error(e.error||`登录发起失败`);return}t.info(`已打开浏览器,请在 Command Code 页面完成授权…`,{duration:4e3});let i=await h.proxyLoginWait(e.waitMs??18e4);if(!i.ok||!i.apiKey){t.error(i.error||`登录未完成`);return}await h.proxyAddKey(r.id,i.apiKey),t.success(`已通过登录添加账号 `+(i.userName||i.keyName||``)),n(!1),await f.refresh()}catch(e){t.error(String(e))}finally{g(!1)}}async function b(){let e=a.split(/[,;s]+/).map(e=>e.trim()).filter(Boolean);if(!e.length){t.error(`请输入至少一个 Key`);return}u(!0);try{if(_)for(let n of e){let e=await h.proxyAddKey(r.id,n);if(e&&e.limited===`credits`){let n=e.account?.limit?.recovery;t.warning(`已添加:该账号额度用尽`+(n?.type===`at`&&n.at?`(预计 ${H(n.at)} 自动恢复)`:`(等待月度重置后自动恢复)`))}}else{let n=await h.providerKeysSet(r.id,{add:e});if(n.ok===!1){t.error(n.error||`添加失败`);return}}t.success(`已添加 `+e.length+` 个 Key(`+(_?`反代账号`:`API Key`)+`)`),s(``),n(!1),await f.refresh()}catch(e){t.error(String(e))}finally{u(!1)}}async function x(e){if(confirm(`移除 Key `+e+`?`)){u(!0);try{if(_){let t=i.find(t=>t.maskedKey===e||e.startsWith(t.maskedKey));t&&await h.proxyRemoveKey(r.id,t.keyId)}else{let n=await h.providerKeysSet(r.id,{removeMasked:[e]});if(n.ok===!1){t.error(n.error||`移除失败`);return}}t.success(`已移除`),n(!1),await f.refresh()}catch(e){t.error(String(e))}finally{u(!1)}}}return(0,B.jsx)(m,{open:e,onOpenChange:n,children:(0,B.jsxs)(d,{className:`max-w-[440px]`,children:[(0,B.jsx)(l,{children:(0,B.jsxs)(o,{children:[`添加 / 管理 Key — `,r.name]})}),(0,B.jsxs)(`div`,{className:`grid gap-3`,children:[_?(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border/70 bg-muted/40 px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`一键登录`}),(0,B.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:`浏览器打开 Command Code 授权,自动添加账号`})]}),(0,B.jsx)(y,{disabled:p||c,onClick:()=>void v(),size:`sm`,children:p?`等待授权…`:`一键登录`})]}):null,(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[_?`已录入账号(反代)`:`已录入 API Key`,`(`,i.length,`)`]}),i.length?(0,B.jsx)(`div`,{className:`grid max-h-[180px] gap-1 overflow-auto`,children:i.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 bg-muted/40 px-2.5 py-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,B.jsx)(`code`,{className:`truncate font-mono text-xs`,children:e.maskedKey}),e.selected?(0,B.jsx)(A,{tone:`ok`,children:`当前`}):null]}),(0,B.jsx)(y,{size:`chip`,variant:`ghost`,className:`text-destructive`,disabled:c,onClick:()=>void x(e.maskedKey),title:`移除该 Key`,children:(0,B.jsx)(C,{className:`size-3.5`})})]},e.keyId))}):(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`尚未录入 `,_?`账号`:`Key`]})]}),(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:[`添加 `,_?`账号 Key / Command Code`:`API Key`,`(每行一个,支持逗号/分号分隔)`]}),(0,B.jsx)(`textarea`,{className:`h-20 w-full resize-none rounded-md border border-input bg-transparent px-3 py-2 font-mono text-xs outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20`,placeholder:_?`sk-... 或 Command Code,每行一个`:`sk-... 每行一个`,value:a,onChange:e=>s(e.target.value)})]})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,B.jsx)(y,{onClick:()=>n(!1),variant:`outline`,children:`取消`}),(0,B.jsx)(y,{disabled:c||!a.trim(),onClick:()=>void b(),children:c?`保存中…`:`添加`})]})]})})}function Y({acc:e,busy:t,p:n,onAction:r}){let i=e.quota,o=!!e.selected,c=!!e.locked,l=i&&i.monthlyRemaining,u=i?.monthly?.percent,d=Number.isFinite(Number(u))?u+`%`:Number.isFinite(Number(l))?`$ `+Number(l).toFixed(2):`—`;return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-5 py-3`,children:[(0,B.jsxs)(`div`,{className:`grid min-w-[180px] content-center gap-1`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o?c?`当前账号(锁定)`:`当前在用账号`:`选择账号`}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(D,{className:`max-w-[150px]`,children:e.maskedKey}),o?(0,B.jsxs)(y,{className:`gap-1 px-2`,disabled:t,onClick:()=>r(`refresh`,()=>h.providerRefresh(n.id).then(()=>void 0),`额度已刷新`),size:`chip`,variant:`outline`,children:[(0,B.jsx)(S,{className:s(`size-3`,t&&`animate-spin`)}),`刷新`]}):null]})]}),(0,B.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-cols-3 items-stretch gap-2`,children:[(0,B.jsx)(j,{icon:(0,B.jsx)(S,{className:`size-3.5`}),label:`5小时`,value:(i?.rolling?.percent??0)+`%`,danger:i?.rolling?.status===`rate-limited`}),(0,B.jsx)(j,{icon:(0,B.jsx)(a,{className:`size-3.5`}),label:`每周`,value:(i?.weekly?.percent??0)+`%`,danger:i?.weekly?.status===`rate-limited`}),(0,B.jsx)(j,{icon:(0,B.jsx)(w,{className:`size-3.5`}),label:`每月`,value:d,danger:i?.monthly?.status===`rate-limited`||Number(i?.monthly?.percent??0)>=100})]})]})}function X({a:e,p:t,busy:n,onAction:r}){let i=!!e.selected,a=e.instanceStatus===`frozen`?`frozen`:e.status||``,o=e.limit?.kind,c=a===`frozen`||!!o||!i&&V(e.quota),l=o===`credits`?e.limit?.recovery?.type===`at`&&e.limit?.recovery?.at?`额度用尽(预计 ${H(e.limit.recovery.at)} 月度重置后自动恢复)`:`额度用尽(待月度重置后自动恢复)`:o===`window`?e.limit?.reason??`时间窗额度已用尽(到 resetAt 自动恢复)`:o===`banned`?`账号被封禁`:null,u=N(e.requests||0)+` 次 · `+N(e.totalTokens||0)+` tok`,[d,f]=(0,z.useState)(!1),p;return p=a===`review`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(y,{disabled:n,onClick:()=>void r(`in`,()=>h.providerAccountConfirm(t.id,e.keyId).then(()=>void 0),`已入池`),size:`chip`,variant:`outline`,children:`入池`}),(0,B.jsx)(y,{className:`h-[26px]`,disabled:n,onClick:()=>void r(`out`,()=>h.providerAccountDiscard(t.id,e.keyId).then(()=>void 0),`已作废`),size:`chip`,variant:`destructive`,children:`作废`})]}):c&&!i?(0,B.jsxs)(y,{size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,onClick:()=>f(!0),title:l??`查看该账号限额情况`,children:[(0,B.jsx)(P,{className:`size-3.5`}),`限额`]}):i?(0,B.jsxs)(y,{disabled:n,onClick:()=>r(`refresh`,()=>h.providerRefresh(t.id).then(()=>void 0),`额度已刷新`),size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,children:[(0,B.jsx)(S,{className:s(`size-3.5`,n&&`animate-spin`)}),`刷新`]}):(0,B.jsxs)(y,{disabled:n,size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,onClick:()=>{t.kind===`proxy`?r(`sel`,()=>h.proxySelect(t.id,e.keyId).then(()=>void 0),`已切换账号`):r(`use`,()=>h.providerKeyUse(t.id,e.keyId).then(()=>void 0),`已锁定 Key`)},children:[(0,B.jsx)(L,{className:`size-3.5`}),`切换`]}),(0,B.jsxs)(`div`,{className:s(`grid items-center gap-2 px-5 py-2.5 hover:bg-muted/40`,W,i&&`bg-muted/60 shadow-[inset_3px_0_0_var(--primary)]`),children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,B.jsx)(D,{children:e.maskedKey}),a===`registering`?(0,B.jsx)(A,{tone:`off`,children:`检测中…`}):null,a===`banned`?(0,B.jsx)(A,{tone:`err`,children:`封号`}):null,o===`credits`?(0,B.jsx)(`span`,{title:e.limit?.reason??`额度用尽`,children:(0,B.jsx)(A,{tone:`err`,children:`额度用尽`})}):null,o===`window`?(0,B.jsx)(`span`,{title:e.limit?.reason??`时间窗额度已用尽`,children:(0,B.jsx)(A,{tone:`warn`,children:`窗口用尽`})}):null]}),(0,B.jsx)(`span`,{className:`truncate text-right text-xs tabular-nums text-muted-foreground`,title:u,children:u}),(0,B.jsx)(`div`,{className:`flex justify-end`,children:p}),(0,B.jsx)(Z,{open:d,onOpenChange:f,a:e,p:t})]})}function Z({open:e,onOpenChange:t,a:n,p:r}){let i=n.quota,a=(()=>{let e=i?.monthly?.percent;if(e!=null&&Number.isFinite(Number(e)))return Number(e);let t=Number(i?.credits?.monthlyCredits??i?.monthlyRemaining);return Number.isFinite(t)&&t>=0?Math.min(100,Math.round((10-t)/10*100)):0})(),s=i?.monthly?.status?{...i.monthly,percent:a}:{status:`ok`,percent:a,resetsAt:i?.monthly?.resetsAt},c=(()=>{let e=i?.credits?.monthlyCredits,t=i?.monthlyRemaining,n=e!=null&&Number.isFinite(Number(e))?Number(e):t!=null&&Number.isFinite(Number(t))?Number(t):null;return n===null?null:`剩余 $`+n.toFixed(2)})(),u=(e,t,n)=>(0,B.jsxs)(`div`,{className:`grid gap-1 rounded-md border border-border/70 bg-muted/40 px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:t}),(0,B.jsx)(A,{tone:e?.status===`rate-limited`||Number(e?.percent)>=100?`err`:`ok`,children:e?.status===`rate-limited`||Number(e?.percent)>=100?`已限额`:`正常`})]}),(0,B.jsxs)(`strong`,{className:`text-xl font-semibold tabular-nums text-foreground`,children:[e?.percent??0,`%`]}),n?(0,B.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:n}):null,e?.resetsAt?(0,B.jsxs)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:[`重置:`,new Date(e.resetsAt).toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})]}):null]});return(0,B.jsx)(m,{open:e,onOpenChange:t,children:(0,B.jsxs)(d,{className:`max-w-[420px]`,children:[(0,B.jsx)(l,{children:(0,B.jsx)(o,{children:`限额详情`})}),(0,B.jsxs)(`div`,{className:`grid gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:`账号`}),(0,B.jsx)(`code`,{className:`font-mono`,children:n.maskedKey}),(0,B.jsx)(`span`,{className:`ml-auto text-xs`,children:r.name})]}),i?(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[u(i.rolling,`5小时`),u(i.weekly,`每周`),u(s,`每月`),i.credits||i.monthlyRemaining!=null?(0,B.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1 rounded-md border border-border/70 bg-muted/40 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`月度额度(Command)`}),i.credits?.belowThreshold?(0,B.jsx)(A,{tone:`warn`,children:`低于充值线`}):i.credits&&Number.isFinite(Number(i.credits.monthlyCredits))&&Number(i.credits.monthlyCredits)<=0?(0,B.jsx)(A,{tone:`err`,children:`额度用尽`}):(0,B.jsx)(A,{tone:`ok`,children:`正常`})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:Number(i.monthlyResetAt)>Date.now()?`月度额度预计 ${H(Number(i.monthlyResetAt))} 重置(随订阅续期)`:`月度额度已于 ${H(Number(i.monthlyResetAt))} 重置`}),c?(0,B.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-foreground`,children:c}):null]})]}):null]}):(0,B.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`暂无额度数据 — 点「刷新」获取`}),i?(0,B.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`当前用量统计:`,N(n.requests||0),` 次请求 · `,N(n.totalTokens||0),` tokens`,i.monthly?.resetsAt?`。最迟限额将于月窗口重置后自动解除。`:``]}):null]}),(0,B.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,B.jsx)(y,{onClick:()=>t(!1),variant:`outline`,children:`关闭`})})]})})}function Q({open:e,onOpenChange:n,presets:r,proxyApps:i,onDone:a}){let[f,_]=(0,z.useState)(``),[b,x]=(0,z.useState)(``),[S,C]=(0,z.useState)(``),[w,T]=(0,z.useState)(`preset`),[E,D]=(0,z.useState)(!1);async function O(){if(w===`preset`&&!f){t.error(`请选择供应商`);return}if(w===`proxy`&&!b){t.error(`请选择反代应用`);return}D(!0);try{let e=w===`preset`?await h.providerAdd({presetId:f,name:S||void 0,keys:[]}):await h.providerAdd({kind:`proxy`,appId:b,name:S||void 0,keys:[]});if(e.ok===!1){t.error(e.error||`添加失败`);return}t.success(`已添加供应商,请在卡片上点「添加」录入 Key`),n(!1),C(``),_(``),x(``),a()}catch(e){t.error(String(e))}finally{D(!1)}}let k=(r??[]).find(e=>e.id===f);return(0,B.jsx)(m,{open:e,onOpenChange:n,children:(0,B.jsxs)(d,{className:`max-w-[420px]`,children:[(0,B.jsx)(l,{children:(0,B.jsx)(o,{children:`添加供应商`})}),(0,B.jsxs)(`div`,{className:`grid gap-3`,children:[(0,B.jsx)(`div`,{className:`flex gap-1.5 rounded-lg bg-muted p-1`,children:[`preset`,`proxy`].map(e=>(0,B.jsx)(y,{className:s(`flex-1 rounded-md font-medium`,w===e?`bg-card text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-card/60 hover:text-foreground`),onClick:()=>T(e),size:`sm`,variant:`ghost`,children:e===`preset`?`直连预设`:`反代应用`},e))}),w===`preset`?(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:`供应商`}),(0,B.jsxs)(p,{value:f,onValueChange:_,children:[(0,B.jsx)(u,{className:`w-full`,children:(0,B.jsx)(v,{placeholder:`-- 选择供应商 --`})}),(0,B.jsx)(g,{children:(r??[]).map(e=>(0,B.jsx)(c,{value:e.id,children:e.name},e.id))})]}),k?.note?(0,B.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:k.note}):null]}):(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:`反代应用`}),(0,B.jsxs)(p,{value:b,onValueChange:x,children:[(0,B.jsx)(u,{className:`w-full`,children:(0,B.jsx)(v,{placeholder:`-- 选择应用 --`})}),(0,B.jsx)(g,{children:(i??[]).map(e=>(0,B.jsx)(c,{value:e.id,children:e.name},e.id))})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:`供应商名称(可选)`}),(0,B.jsx)(`input`,{className:`h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20`,placeholder:`自定义名称,如:Open Code ZEN`,value:S,onChange:e=>C(e.target.value)})]}),(0,B.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`只添加供应商不填 Key;添加后在供应商卡片上点「添加」录入 API Key。`})]}),(0,B.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,B.jsx)(y,{onClick:()=>n(!1),variant:`outline`,children:`取消`}),(0,B.jsx)(y,{disabled:E,onClick:()=>void O(),children:E?`添加中…`:`添加供应商`})]})]})})}export{G as RouterPage};