@hyzyn/dsh-docker 0.3.0 → 0.3.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 (3) hide show
  1. package/README.md +7 -1
  2. package/client.js +72 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -60,6 +60,8 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
60
60
 
61
61
  面板内:
62
62
 
63
+ ![容器列表:目标选择 / 搜索与状态筛选 / 卡片动作条(查看 · 变更两组)](../../docs/dsh-plugin-kit-docker-panel.png)
64
+
63
65
  - **目标选择**:面板先选目标(来自配置 `targets`,本机 / SSH);只配置了一个
64
66
  目标时默认选中它,agent 工具也可以省略 `target` 参数。
65
67
  - **容器列表**:名称 / 状态 / 健康态 / 镜像 / 端口映射 / compose 项目与服务 /
@@ -91,12 +93,16 @@ add。装完重启 `dsh web`,侧边栏出现「容器」入口;设置 →
91
93
  检查输出;下方可执行一次性 `docker exec`(需 `allowExec`)。
92
94
  - **日志**:`docker logs --tail` 的尾部快照(默认 `logTailDefault` 行),可切
93
95
  时间戳与 `--since`;输出超过 `maxOutputKb` 会截断并标记。
96
+
97
+ ![日志页:级别着色 + 常驻过滤框 + 行数统计](../../docs/dsh-plugin-kit-docker-logs.png)
94
98
  - **统计**:`docker stats --no-stream` 快照(CPU% / 内存用量与占比 / 网络 IO /
95
99
  块 IO / PIDs),面板按 `pollIntervalSec` 轮询刷新。
96
100
  - **镜像**:`docker images` 列表(reference / 大小 / 创建时间 / 短 ID);
97
101
  `<none>:<none>` 的 dangling 镜像带 `dangling` 标记。**只有列表,没有删除 /
98
102
  拉取 / 构建**。搜索框与「N / M 个镜像」计数**固定在工具条里**(不随列表滚走),
99
103
  表头列名在表体内吸顶——镜像多的时候滚到哪都还知道自己在看什么列。
104
+
105
+ ![镜像页:搜索框固定在工具条,表头吸顶](../../docs/dsh-plugin-kit-docker-images.png)
100
106
  - **一次性 exec**:`allowExec` 开启后可输入命令,等价
101
107
  `docker exec <容器> sh -c "<命令>"`,返回退出码与 stdout/stderr(无 TTY)。
102
108
  - **交互式终端(卡片第一个图标)**:跑 `docker exec -it '<容器>' sh`。按 tty 能力
@@ -403,4 +409,4 @@ stats 解析(百分比 / 内存 / IO / PIDs)、size 与 percent 的异常输
403
409
 
404
410
  ## 版本 / 许可证
405
411
 
406
- `@hyzyn/dsh-docker` 0.3.0 · [Apache License 2.0](../../LICENSE)
412
+ `@hyzyn/dsh-docker` 0.3.1 · [Apache License 2.0](../../LICENSE)
package/client.js CHANGED
@@ -396,7 +396,11 @@
396
396
  transition: border-color var(--dk-dur) var(--dk-ease), box-shadow var(--dk-dur) var(--dk-ease);
397
397
  }
398
398
 
399
- .dk_input { min-width: 180px; }
399
+ /*
400
+ * \u8F93\u5165\u6846\u4E00\u5F8B\u53EF\u6536\u7F29\uFF1A\u4EE5\u524D\u8FD9\u91CC\u662F min-width: 180px\uFF0C\u9047\u5230\u7A84\u5BB9\u5668\uFF08\u8BBE\u7F6E\u9762\u677F ~600px \u65F6
401
+ * \u6BCF\u5217\u53EA\u6709 ~180px\uFF09\u4F1A\u628A\u5217\u6491\u7834\u3001\u548C\u9694\u58C1\u5B57\u6BB5\u53E0\u5728\u4E00\u8D77\u3002\u5BBD\u5EA6\u4EA4\u7ED9\u5BB9\u5668\u7684\u6805\u683C/\u5F39\u6027\u5E03\u5C40\u51B3\u5B9A\u3002
402
+ */
403
+ .dk_input { min-width: 0; }
400
404
  .dk_select:focus-visible,
401
405
  .dk_input:focus-visible {
402
406
  outline: none;
@@ -1138,15 +1142,57 @@
1138
1142
  display: flex;
1139
1143
  flex-direction: column;
1140
1144
  gap: var(--dk-gap-sm);
1145
+ min-width: 0;
1141
1146
  }
1142
1147
 
1143
- .dk_label { font-size: 12px; color: var(--dk-label-2); }
1148
+ /*
1149
+ * \u6807\u7B7E\u884C\u9AD8\u5FC5\u987B\u9501\u6B7B\u3002
1150
+ * \u4E2D\u6587\u8D70 PingFang SC \u56DE\u9000\u5B57\u4F53\uFF0C\u884C\u6846\u6BD4\u7EAF\u62C9\u4E01\u6587\u672C\u9AD8 ~2.5px\uFF0816.5 vs 14\uFF09\uFF1B\u6805\u683C\u662F
1151
+ * align-items:start\uFF0C\u540C\u4E00\u884C\u91CC\u300Cdocker CLI\u300D\u548C\u300C\u7EDF\u8BA1\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09\u300D\u7684\u8F93\u5165\u6846\u5C31\u4F1A
1152
+ * \u5DEE 2.5px \u9519\u5F00\uFF0C\u57FA\u7EBF\u4E5F\u9AD8\u4F4E\u4E0D\u9F50\u3002\u7ED9\u6B7B\u884C\u9AD8\u540E\u4E24\u79CD\u6587\u672C\u7684\u884C\u6846\u7B49\u9AD8\uFF0C\u8F93\u5165\u6846\u9876\u8FB9\u5BF9\u9F50\u3002
1153
+ * \u522B\u5220\u6210 line-height: normal \u2014\u2014 \u4E00\u5220\u5C31\u9000\u56DE\u5B57\u4F53\u5EA6\u91CF\u51B3\u5B9A\u884C\u6846\u3002
1154
+ */
1155
+ .dk_label { font-size: 12px; line-height: 1.4; color: var(--dk-label-2); }
1144
1156
  .dk_hint { font-size: 11px; color: var(--dk-label-3); line-height: 1.6; }
1145
1157
  .dk_row { display: flex; align-items: center; gap: var(--dk-gap-md); flex-wrap: wrap; }
1146
1158
 
1159
+ /*
1160
+ * \u8BBE\u7F6E\u5361\u7247\u7684\u5B57\u6BB5\u6805\u683C\uFF1A**\u7B49\u5BBD** 3 \u5217\uFF08\u7A84\u5C4F 2 \u5217\uFF09\u3002
1161
+ * \u4E0D\u8981\u518D\u7ED9\u5355\u4E2A\u5B57\u6BB5\u8DE8\u5217\u2014\u2014\u7B2C\u4E00\u884C\u8DE8 2 \u5217\u3001\u7B2C\u4E8C\u884C\u5355\u5217\uFF0C\u884C\u4E0E\u884C\u4E4B\u95F4\u5BBD\u5EA6\u4E0D\u4E00\u81F4\uFF0C
1162
+ * \u770B\u8D77\u6765\u6BD4\u4E0D\u5BF9\u9F50\u8FD8\u4E71\uFF08v0.1.22 \u7684\u6559\u8BAD\uFF09\u3002
1163
+ */
1164
+ .dk_fieldGrid {
1165
+ display: grid;
1166
+ /* auto-fit + minmax\uFF1A\u5217\u5BBD\u8DDF\u7740**\u5BB9\u5668**\u8D70\uFF0C\u800C\u4E0D\u662F\u89C6\u53E3 \u2014\u2014 \u8BBE\u7F6E\u9762\u677F\u672C\u8EAB\u53EF\u80FD\u662F\u7A84\u7684\u3002
1167
+ \u5361\u7247 ~966px \u2192 3 \u5217\uFF1B~570px \u2192 2 \u5217\uFF1B\u518D\u7A84 \u2192 1 \u5217\uFF0C\u6C38\u8FDC\u4E0D\u4F1A\u53E0 */
1168
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
1169
+ gap: var(--dk-gap-lg) var(--dk-gap-xl);
1170
+ align-items: start;
1171
+ }
1172
+
1173
+ .dk_fieldGrid .dk_input,
1174
+ .dk_fieldGrid .dk_select { min-width: 0; }
1175
+
1176
+ /* \u6570\u5B57\u8F93\u5165\u53BB\u6389\u6D4F\u89C8\u5668\u539F\u751F\u4E0A\u4E0B\u7BAD\u5934\uFF1A\u5404\u5E73\u53F0\u6837\u5F0F\u4E0D\u4E00\uFF0C\u8FD8\u4F1A\u5403\u6389\u53F3\u5185\u8FB9\u8DDD */
1177
+ .dk_input[type="number"] {
1178
+ -moz-appearance: textfield;
1179
+ appearance: textfield;
1180
+ font-variant-numeric: tabular-nums;
1181
+ }
1182
+
1183
+ .dk_input[type="number"]::-webkit-outer-spin-button,
1184
+ .dk_input[type="number"]::-webkit-inner-spin-button {
1185
+ -webkit-appearance: none;
1186
+ margin: 0;
1187
+ }
1188
+
1189
+ /*
1190
+ * \u76EE\u6807\u884C\u4E0E\u5185\u8054 SSH \u5B57\u6BB5\u5171\u7528\u540C\u4E00\u5957\u5217\u5BBD\u6A21\u677F\uFF081fr \xB7 96px \xB7 1fr \xB7 150px\uFF09\uFF0C
1191
+ * \u5185\u8054\u5757\u6574\u5BBD\u94FA\u5F00 \u2192 host/port/username/auth \u6B63\u597D\u843D\u5728\u76EE\u6807\u540D/\u7C7B\u578B/\u8FDE\u63A5\u7C3F/\u64CD\u4F5C\u5217\u4E0B\u65B9\u3002
1192
+ */
1147
1193
  .dk_targetRow {
1148
1194
  display: grid;
1149
- grid-template-columns: 1fr 96px 1fr auto;
1195
+ grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr) minmax(0, 150px);
1150
1196
  gap: var(--dk-gap-sm);
1151
1197
  align-items: center;
1152
1198
  padding: var(--dk-gap-sm);
@@ -1155,6 +1201,21 @@
1155
1201
  background: var(--dk-surface-2);
1156
1202
  }
1157
1203
 
1204
+ /* \u5220\u9664\u6309\u94AE\u9760\u53F3\uFF0C\u4E0D\u8DDF\u7740\u5217\u5BBD\u88AB\u62C9\u957F */
1205
+ .dk_targetRow > .dk_btnDanger { justify-self: end; }
1206
+
1207
+ .dk_targetInline {
1208
+ display: grid;
1209
+ grid-column: 1 / -1;
1210
+ grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr) minmax(0, 150px);
1211
+ gap: var(--dk-gap-sm);
1212
+ align-items: center;
1213
+ }
1214
+
1215
+ /* \u51ED\u636E\u5360\u524D\u4E09\u5217\uFF0C\u590D\u9009\u6846\u56FA\u5B9A\u7B2C 4 \u5217\uFF08\u4E0E\u4E0A\u9762\u7684 auth \u4E0B\u62C9\u4E0A\u4E0B\u5BF9\u9F50\uFF09 */
1216
+ .dk_targetInline > .dk_credential { grid-column: 1 / span 3; }
1217
+ .dk_targetInline > .dk_check { grid-row: 2; grid-column: 4; }
1218
+
1158
1219
  .dk_targetRow .dk_input,
1159
1220
  .dk_targetRow .dk_select {
1160
1221
  height: var(--dk-h-md);
@@ -1199,11 +1260,14 @@
1199
1260
  /* \u7A84\u5C4F\uFF1A\u62BD\u5C49\u6539\u4E3A\u8986\u76D6\u6574\u680F */
1200
1261
  @media (max-width: 860px) {
1201
1262
  .dk_body { flex-direction: column; }
1202
- .dk_targetRow { grid-template-columns: 1fr 1fr; }
1263
+ .dk_targetRow,
1264
+ .dk_targetInline { grid-template-columns: minmax(0, 1fr) 80px; }
1265
+ .dk_targetInline > .dk_credential { grid-column: 1 / -1; }
1266
+ .dk_targetInline > .dk_check { grid-row: auto; grid-column: 2; }
1203
1267
  .dk_cardRow { grid-template-columns: 40px 1fr; }
1204
1268
  }
1205
- `;var Tt="/api/dsh-docker",Qe="dsh-docker-style";function Pe(){if(document.getElementById(Qe)!==null)return;let i=document.createElement("style");i.id=Qe,i.textContent=Xe,document.head.appendChild(i)}async function V(i,m){let e=await fetch(Tt+i,{...m,headers:{"content-type":"application/json",...m?.headers??{}}}),d=null;try{d=await e.json()}catch{}if(!e.ok){let E=d!==null&&typeof d.error=="string"?d.error:`HTTP ${String(e.status)}`;throw new Error(E)}if(d!==null&&d.ok===!1)throw new Error(typeof d.error=="string"?d.error:"\u8BF7\u6C42\u5931\u8D25");return d}var H={config:()=>V("/config"),saveConfig:i=>V("/config",{method:"POST",body:JSON.stringify(i)}),targets:()=>V("/targets"),probe:i=>V("/probe",{method:"POST",body:JSON.stringify({target:i})}),containers:(i,m)=>V("/containers",{method:"POST",body:JSON.stringify({target:i,all:m})}),inspect:(i,m)=>V("/inspect",{method:"POST",body:JSON.stringify({target:i,id:m})}),logs:(i,m,e)=>V("/logs",{method:"POST",body:JSON.stringify({target:i,id:m,...e})}),stats:(i,m)=>V("/stats",{method:"POST",body:JSON.stringify({target:i,ids:m})}),images:i=>V("/images",{method:"POST",body:JSON.stringify({target:i})}),action:(i,m,e)=>V("/action",{method:"POST",body:JSON.stringify({target:i,action:m,id:e})}),exec:(i,m,e,d)=>V("/exec",{method:"POST",body:JSON.stringify({target:i,id:m,command:e,timeoutSec:d})})};function Lt(i){return i==null||!Number.isFinite(i)?"\u2014":i.toFixed(i>=10?1:2)+"%"}function Et(i){return i.hostPort===void 0?String(i.containerPort)+"/"+i.protocol:String(i.hostPort)+"\u2192"+String(i.containerPort)+"/"+i.protocol}function Ze(i){if(!Array.isArray(i)||i.length===0)return"\u65E0\u7AEF\u53E3\u6620\u5C04";let m=new Set,e=[];for(let d of i){let E=Et(d);m.has(E)||(m.add(E),e.push(E))}return e.join(" ")}function Bt(i){let m=/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/.exec(i);return m===null?i:m[1]+" "+m[2]}function It(i){return{running:"\u8FD0\u884C\u4E2D",exited:"\u5DF2\u505C\u6B62",created:"\u5DF2\u521B\u5EFA",paused:"\u5DF2\u6682\u505C",restarting:"\u91CD\u542F\u4E2D",dead:"dead",removing:"\u5220\u9664\u4E2D",unknown:"\u672A\u77E5"}[i]??i}function Mt(i,m){let e=new Blob([m],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(e),E=document.createElement("a");E.href=d,E.download=i,E.click(),setTimeout(()=>URL.revokeObjectURL(d),1e3)}function et(i){return"docker exec -it '"+String(i).replaceAll("'","'\\''")+"' sh"}var Z=null,re=null,ce=null,Fe=[],rt=0;function ze(i){i!==null&&typeof i=="object"&&(ce=i),rt=Date.now()}async function Se(){try{let[i,m]=await Promise.all([H.config(),H.targets()]);return ce=i.config,Fe=m.targets??[],rt=Date.now(),!0}catch(i){return console.warn("[dsh-docker] \u76EE\u6807\u7F13\u5B58\u5237\u65B0\u5931\u8D25\uFF1A"+(i instanceof Error?i.message:String(i))),!1}}async function Ot(i,m){let e=je(i,m);return e!==void 0?e:(await Se(),je(i,m))}function je(i,m){let e=ce!==null&&Array.isArray(ce.targets)?ce.targets:[];if(typeof m=="string"&&m!==""){let C=e.find(P=>P.kind==="ssh"&&P.book===m);if(C!==void 0)return C.name}let d=typeof i?.host=="string"?i.host:"";if(d==="")return;let E=Number(i?.port),g=Number.isInteger(E)&&E>0?E:22;for(let C of Fe){if(C.kind!=="ssh"||typeof C.label!="string")continue;let P=/^([^@]+)@(.+?)(?::(\d+))?$/.exec(C.label);if(P!==null&&P[2]===d&&Number(P[3]??22)===g)return C.name}}var tt='<svg viewBox="0 0 16 16" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Rt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Ne='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Ce='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M4.5 4.5l7 7"/><path d="M11.5 4.5l-7 7"/></svg>',Dt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3.4l7.4 4.6L5 12.6z"/></svg>',At='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4.2" y="4.2" width="7.6" height="7.6" rx="1.2"/></svg>',Ht='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Pt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4.6h10"/><path d="M6.2 4.6V3.4a.8.8 0 0 1 .8-.8h2a.8.8 0 0 1 .8.8v1.2"/><path d="M4.6 4.6l.6 8a.9.9 0 0 0 .9.8h3.8a.9.9 0 0 0 .9-.8l.6-8"/></svg>';var zt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v7.2"/><path d="M5 7.4L8 10.4l3-3"/><path d="M3.4 12.8h9.2"/></svg>',jt='<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.6l5.8 10.4H2.2z"/><path d="M8 6.4v3.2"/><path d="M8 11.6h.01"/></svg>',nt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5l3.5 3L3 11"/><path d="M8.5 11H13"/></svg>',Ft='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3 4.5h10"/><path d="M3 8h10"/><path d="M3 11.5h6"/></svg>',Vt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3.5 12.5v-4"/><path d="M7 12.5v-8"/><path d="M10.5 12.5v-5"/><path d="M13 12.5v-2"/></svg>',Gt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.5 8h-9"/><path d="M7 4.5L3.5 8 7 11.5"/></svg>',at='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6.5L8 10.5l4-4"/></svg>';window.__ModuleLoader__.load({id:"@hyzyn/dsh-docker",factory:i=>{let m=i("react"),{jsx:e,jsxs:d}=i("react/jsx-runtime"),{createRoot:E}=i("react-dom/client"),{useState:g,useEffect:C,useRef:P,useCallback:de}=m;function dt(t,a,o){if(a==="")return t;let c=t.toLowerCase(),v=a.toLowerCase(),r=[],b=0,x=c.indexOf(v),w=0;for(;x>=0&&w<500;)x>b&&r.push(t.slice(b,x)),r.push(e("mark",{children:t.slice(x,x+v.length)},o+"-m"+String(w))),b=x+v.length,w+=1,x=c.indexOf(v,b);return b<t.length&&r.push(t.slice(b)),r}function Ve(t){let a=t.health==="unhealthy"?"unhealthy":t.state,o=t.health==="unhealthy"?"\u4E0D\u5065\u5EB7":It(t.state);return e("span",{className:"dk_badge","data-state":a,title:t.status??"",children:o})}function G(t){return d("div",{className:"dk_banner","data-kind":t.kind??"error",children:[e("span",{className:"dk_bannerIcon",dangerouslySetInnerHTML:{__html:jt}},"icon"),d("div",{className:"dk_bannerBody",children:[e("div",{children:t.title}),t.hint===void 0?null:e("div",{className:"dk_hint",style:{marginTop:4},children:t.hint})]},"body"),t.action===void 0?null:e("div",{className:"dk_bannerAction",children:t.action},"action")]})}function Te(t){return d("div",{className:"dk_confirmBackdrop",onMouseDown:a=>a.stopPropagation(),children:[d("div",{className:"dk_confirm",children:[e("div",{className:"dk_confirmTitle",children:t.title}),e("div",{className:"dk_confirmText",children:t.text}),d("div",{className:"dk_confirmActions",children:[e("button",{type:"button",className:"dk_btn",onClick:t.onCancel,children:"\u53D6\u6D88"}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:t.onConfirm,children:t.confirmLabel})]})]})]})}function Kt(t){return e("button",{type:"button",className:"dk_btn"+(t.danger===!0?" dk_btnDanger":""),disabled:t.disabled===!0,title:t.title??"",onClick:a=>{a.stopPropagation(),t.onClick()},children:t.children})}function ke(t){return d("div",{className:"dk_cardRow",children:[e("span",{className:"dk_cardLabel",children:t.label}),e("span",{className:"dk_cardValue",title:String(t.value),children:t.value})]})}function K(t){let a=t.disabled===!0;return e("button",{type:"button",className:"dk_iconBtn"+(t.danger===!0?" dk_iconBtnDanger":""),"data-on":t.on===!0?"1":void 0,"data-spin":t.spin===!0?"1":void 0,disabled:a,title:t.title,"aria-label":t.title,onClick:o=>{o.stopPropagation(),!a&&t.onClick()},children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:t.icon}})})}function ot(t){let a=t.item,o=t.allowMutations!==!0,c=a.state==="running"||a.state==="paused"||a.state==="restarting",v=a.createdAt===null?a.runningFor===""?"\u2014":a.runningFor:Bt(a.createdAt);return d("div",{className:"dk_card",role:"button",tabIndex:0,"data-selected":t.selected===!0?"1":"0",onClick:()=>t.onOpen(a,"overview"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.onOpen(a,"overview"))},children:[d("div",{className:"dk_cardHead",children:[e("span",{className:"dk_cardName",title:a.name,children:a.name}),e(Ve,{state:a.state,health:a.health,status:a.status})]},"head"),d("div",{className:"dk_cardRows",children:[e(ke,{label:"\u955C\u50CF",value:a.image},"image"),e(ke,{label:"ID",value:a.shortId},"id"),e(ke,{label:"\u7AEF\u53E3",value:Ze(a.ports)},"ports"),e(ke,{label:"\u521B\u5EFA",value:v},"created"),a.composeProject===null?null:e(ke,{label:"compose",value:a.composeProject+(a.composeService===null?"":"/"+a.composeService)},"compose")]},"rows"),d("div",{className:"dk_actionBar",children:[e(K,{icon:nt,title:"\u5728\u5BB9\u5668\u5185\u6253\u5F00\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\uFF08docker exec -it "+a.name+" sh\uFF09",onClick:()=>t.onExec(a)},"exec"),e(K,{icon:Ft,title:"\u67E5\u770B\u65E5\u5FD7",onClick:()=>t.onOpen(a,"logs")},"logs"),e(K,{icon:Vt,title:"\u8D44\u6E90\u5360\u7528",onClick:()=>t.onOpen(a,"stats")},"stats"),e("span",{className:"dk_actionBarSep","aria-hidden":"true"},"sep"),e(K,{icon:c?At:Dt,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":c?"\u505C\u6B62\u5BB9\u5668":"\u542F\u52A8\u5BB9\u5668",disabled:o,onClick:()=>t.onAction(c?"stop":"start",a)},"power"),e(K,{icon:Ht,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u91CD\u542F\u5BB9\u5668",disabled:o,onClick:()=>t.onAction("restart",a)},"restart"),e(K,{icon:Pt,danger:!0,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u5220\u9664\u5BB9\u5668\uFF08\u4E0D\u53EF\u6062\u590D\uFF09",disabled:o,onClick:()=>t.onAction("remove",a)},"remove")]},"actions")]})}let lt=/^\s*(\[\d{4}-\d{2}-\d{2}[ T][0-9:.,]+\]|\d{2}:\d{2}:\d{2}[,.]\d{3})/,it=/^\s*(\[(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\]|\|\s*(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL))/,st=/(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)/,Le=2e3;function ct(t,a,o){let c=[],v=t;for(let r=0;r<2;r+=1){let b=lt.exec(v);if(b!==null){c.push(e("span",{className:"dk_logTs",children:b[1]},"ts"+String(r))),v=v.slice(b[0].length);continue}let x=it.exec(v);if(x!==null){let w=st.exec(x[1]);c.push(e("span",{className:"dk_logLevel","data-level":w===null?"":w[1],children:x[1].trim()},"lv"+String(r))),v=v.slice(x[0].length);continue}break}return c.push(e("span",{className:"dk_logText",children:dt(v,o,"x"+String(a))},"tx")),d("div",{className:"dk_logLine",children:c},String(a))}function kt(t){let a=t.item,o=t.config,[c,v]=g(t.initialTab??"overview"),[r,b]=g(null),[x,w]=g(""),[N,j]=g({tail:o.logTailDefault,timestamps:!1}),[B,I]=g(null),[T,$]=g(""),[Y,ee]=g(!1),[M,O]=g(""),[S,F]=g(!1),[J,l]=g(3),[s,h]=g(null),[z,q]=g(""),[ge,X]=g(""),[R,be]=g(null),[he,D]=g(""),[te,pe]=g(!1);C(()=>{let p=!0;return b(null),w(""),H.inspect(t.target,a.id).then(_=>{p&&b(_.details?.[0]??null)}).catch(_=>{p&&w(_.message)}),()=>{p=!1}},[t.target,a.id,t.refreshToken]);let Q=de(()=>{ee(!0),$(""),H.logs(t.target,a.id,{tail:N.tail,timestamps:N.timestamps}).then(p=>I(p.logs)).catch(p=>$(p.message)).finally(()=>ee(!1))},[t.target,a.id,N.tail,N.timestamps]);C(()=>{c==="logs"&&Q()},[c,Q,t.refreshToken]),C(()=>{if(c!=="logs"||!S)return;let p=setInterval(Q,Math.max(1,J)*1e3);return()=>clearInterval(p)},[c,S,J,Q]),C(()=>{if(c!=="stats")return;let p=!0,_=()=>{H.stats(t.target,[a.id]).then(y=>{p&&(h(y.stats?.[0]??null),q(""))}).catch(y=>{p&&q(y.message)})};_();let k=setInterval(_,Math.max(2,o.pollIntervalSec)*1e3);return()=>{p=!1,clearInterval(k)}},[c,t.target,a.id,o.pollIntervalSec,t.refreshToken]);let U=()=>{ge.trim()!==""&&(pe(!0),D(""),be(null),H.exec(t.target,a.id,ge,o.execTimeoutSec).then(p=>be(p.result)).catch(p=>D(p.message)).finally(()=>pe(!1)))},W=()=>{if(x!=="")return e(G,{title:"\u8BFB\u53D6\u5BB9\u5668\u8BE6\u60C5\u5931\u8D25",hint:x});if(r===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let p=[["\u72B6\u6001",r.state+(r.health===null?"":" / "+r.health)+(r.status===""?"":"\uFF08"+r.status+"\uFF09")],["\u955C\u50CF",r.image],["\u5BB9\u5668 ID",r.shortId],["\u542F\u52A8\u65F6\u95F4",r.startedAt??"\u2014"],["\u7ED3\u675F\u65F6\u95F4",r.finishedAt??"\u2014"],["\u9000\u51FA\u7801",r.exitCode===null?"\u2014":String(r.exitCode)],["\u91CD\u542F\u6B21\u6570",r.restartCount===null?"\u2014":String(r.restartCount)],["\u91CD\u542F\u7B56\u7565",r.restartPolicy??"\u2014"],["PID",r.pid===null?"\u2014":String(r.pid)],["\u7AEF\u53E3",r.ports.length===0?"\u2014":Ze(r.ports)],["\u6302\u8F7D",r.mounts.length===0?"\u2014":r.mounts.map(k=>k.source+"\u2192"+k.destination+(k.readWrite?"":"\uFF08\u53EA\u8BFB\uFF09")).join(`
1206
- `)],["\u7F51\u7EDC",r.networks.length===0?"\u2014":r.networks.map(k=>k.name+(k.ip===null?"":"\uFF08"+k.ip+"\uFF09")).join(", ")],["\u547D\u4EE4",(r.entrypoint+" "+r.command).trim()||"\u2014"],["\u5DE5\u4F5C\u76EE\u5F55",r.workingDir===""?"\u2014":r.workingDir],["\u7528\u6237",r.user===""?"\u2014":r.user]],_=d("div",{className:"dk_kv",children:p.flatMap(([k,y],L)=>[e("div",{className:"dk_kvKey",children:k},"k"+String(L)),e("div",{className:"dk_kvVal"+(k==="\u5BB9\u5668 ID"||k==="\u547D\u4EE4"||k==="\u955C\u50CF"?" dk_kvValMono":""),children:y},"v"+String(L))])});return d("div",{children:[r.healthLogTail===null?null:e("div",{className:"dk_hint",style:{marginBottom:8},children:"\u6700\u8FD1\u5065\u5EB7\u68C0\u67E5\u8F93\u51FA\uFF1A"+r.healthLogTail}),_,e("div",{className:"dk_cardSection",style:{marginTop:16},children:"\u4E00\u6B21\u6027\u547D\u4EE4\uFF08docker exec\uFF09"}),o.allowExec!==!0?e(G,{kind:"info",title:"exec \u672A\u542F\u7528",hint:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8 exec\u300D\uFF0C\u6216\u76F4\u63A5\u590D\u5236\u5361\u7247\u4E0A\u7684 exec \u547D\u4EE4\u5230\u7EC8\u7AEF\u9762\u677F\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u3002"}):d("div",{children:[d("div",{className:"dk_row",children:[e("input",{className:"dk_input",style:{flex:"1 1 auto"},placeholder:"\u5982 ls -la /app \u6216 cat /etc/nginx/nginx.conf",value:ge,onChange:k=>X(k.target.value),onKeyDown:k=>{k.key==="Enter"&&U()}}),e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:te,onClick:U,children:te?"\u6267\u884C\u4E2D\u2026":"\u6267\u884C"})]}),he===""?null:e(G,{title:"\u6267\u884C\u5931\u8D25",hint:he}),R===null?null:d("div",{style:{marginTop:8},children:[e("div",{className:"dk_hint",children:"\u9000\u51FA\u7801 "+(R.code===null?"?":String(R.code))+" \xB7 \u8017\u65F6 "+String(R.durationMs)+"ms"+(R.truncated?" \xB7 \u8F93\u51FA\u5DF2\u622A\u65AD":"")}),e("pre",{className:"dk_logBox",style:{marginTop:6},children:(R.stdout||"")+(R.stderr===""?"":`
1269
+ `;var Tt="/api/dsh-docker",Qe="dsh-docker-style";function Pe(){if(document.getElementById(Qe)!==null)return;let i=document.createElement("style");i.id=Qe,i.textContent=Xe,document.head.appendChild(i)}async function G(i,m){let e=await fetch(Tt+i,{...m,headers:{"content-type":"application/json",...m?.headers??{}}}),d=null;try{d=await e.json()}catch{}if(!e.ok){let I=d!==null&&typeof d.error=="string"?d.error:`HTTP ${String(e.status)}`;throw new Error(I)}if(d!==null&&d.ok===!1)throw new Error(typeof d.error=="string"?d.error:"\u8BF7\u6C42\u5931\u8D25");return d}var P={config:()=>G("/config"),saveConfig:i=>G("/config",{method:"POST",body:JSON.stringify(i)}),targets:()=>G("/targets"),probe:i=>G("/probe",{method:"POST",body:JSON.stringify({target:i})}),containers:(i,m)=>G("/containers",{method:"POST",body:JSON.stringify({target:i,all:m})}),inspect:(i,m)=>G("/inspect",{method:"POST",body:JSON.stringify({target:i,id:m})}),logs:(i,m,e)=>G("/logs",{method:"POST",body:JSON.stringify({target:i,id:m,...e})}),stats:(i,m)=>G("/stats",{method:"POST",body:JSON.stringify({target:i,ids:m})}),images:i=>G("/images",{method:"POST",body:JSON.stringify({target:i})}),action:(i,m,e)=>G("/action",{method:"POST",body:JSON.stringify({target:i,action:m,id:e})}),exec:(i,m,e,d)=>G("/exec",{method:"POST",body:JSON.stringify({target:i,id:m,command:e,timeoutSec:d})})};function Lt(i){return i==null||!Number.isFinite(i)?"\u2014":i.toFixed(i>=10?1:2)+"%"}function It(i){return i.hostPort===void 0?String(i.containerPort)+"/"+i.protocol:String(i.hostPort)+"\u2192"+String(i.containerPort)+"/"+i.protocol}function Ze(i){if(!Array.isArray(i)||i.length===0)return"\u65E0\u7AEF\u53E3\u6620\u5C04";let m=new Set,e=[];for(let d of i){let I=It(d);m.has(I)||(m.add(I),e.push(I))}return e.join(" ")}function Et(i){let m=/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/.exec(i);return m===null?i:m[1]+" "+m[2]}function Bt(i){return{running:"\u8FD0\u884C\u4E2D",exited:"\u5DF2\u505C\u6B62",created:"\u5DF2\u521B\u5EFA",paused:"\u5DF2\u6682\u505C",restarting:"\u91CD\u542F\u4E2D",dead:"dead",removing:"\u5220\u9664\u4E2D",unknown:"\u672A\u77E5"}[i]??i}function Mt(i,m){let e=new Blob([m],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(e),I=document.createElement("a");I.href=d,I.download=i,I.click(),setTimeout(()=>URL.revokeObjectURL(d),1e3)}function et(i){return"docker exec -it '"+String(i).replaceAll("'","'\\''")+"' sh"}var Z=null,re=null,ce=null,Fe=[],rt=0;function ze(i){i!==null&&typeof i=="object"&&(ce=i),rt=Date.now()}async function Se(){try{let[i,m]=await Promise.all([P.config(),P.targets()]);return ce=i.config,Fe=m.targets??[],rt=Date.now(),!0}catch(i){return console.warn("[dsh-docker] \u76EE\u6807\u7F13\u5B58\u5237\u65B0\u5931\u8D25\uFF1A"+(i instanceof Error?i.message:String(i))),!1}}async function Ot(i,m){let e=je(i,m);return e!==void 0?e:(await Se(),je(i,m))}function je(i,m){let e=ce!==null&&Array.isArray(ce.targets)?ce.targets:[];if(typeof m=="string"&&m!==""){let C=e.find(z=>z.kind==="ssh"&&z.book===m);if(C!==void 0)return C.name}let d=typeof i?.host=="string"?i.host:"";if(d==="")return;let I=Number(i?.port),g=Number.isInteger(I)&&I>0?I:22;for(let C of Fe){if(C.kind!=="ssh"||typeof C.label!="string")continue;let z=/^([^@]+)@(.+?)(?::(\d+))?$/.exec(C.label);if(z!==null&&z[2]===d&&Number(z[3]??22)===g)return C.name}}var tt='<svg viewBox="0 0 16 16" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Rt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.8l5.4 3.1v6.2L8 14.2 2.6 11.1V4.9z"/><path d="M2.6 4.9L8 8l5.4-3.1"/><path d="M8 8v6.2"/></svg>',Ne='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Ce='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M4.5 4.5l7 7"/><path d="M11.5 4.5l-7 7"/></svg>',Dt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3.4l7.4 4.6L5 12.6z"/></svg>',At='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4.2" y="4.2" width="7.6" height="7.6" rx="1.2"/></svg>',Ht='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.2 8a5.2 5.2 0 1 1-1.5-3.7"/><path d="M13.4 2.2v2.6h-2.6"/></svg>',Pt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4.6h10"/><path d="M6.2 4.6V3.4a.8.8 0 0 1 .8-.8h2a.8.8 0 0 1 .8.8v1.2"/><path d="M4.6 4.6l.6 8a.9.9 0 0 0 .9.8h3.8a.9.9 0 0 0 .9-.8l.6-8"/></svg>';var zt='<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v7.2"/><path d="M5 7.4L8 10.4l3-3"/><path d="M3.4 12.8h9.2"/></svg>',jt='<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.6l5.8 10.4H2.2z"/><path d="M8 6.4v3.2"/><path d="M8 11.6h.01"/></svg>',nt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 5l3.5 3L3 11"/><path d="M8.5 11H13"/></svg>',Ft='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3 4.5h10"/><path d="M3 8h10"/><path d="M3 11.5h6"/></svg>',Gt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3.5 12.5v-4"/><path d="M7 12.5v-8"/><path d="M10.5 12.5v-5"/><path d="M13 12.5v-2"/></svg>',Vt='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.5 8h-9"/><path d="M7 4.5L3.5 8 7 11.5"/></svg>',at='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6.5L8 10.5l4-4"/></svg>';window.__ModuleLoader__.load({id:"@hyzyn/dsh-docker",factory:i=>{let m=i("react"),{jsx:e,jsxs:d}=i("react/jsx-runtime"),{createRoot:I}=i("react-dom/client"),{useState:g,useEffect:C,useRef:z,useCallback:de}=m;function dt(t,a,o){if(a==="")return t;let c=t.toLowerCase(),v=a.toLowerCase(),r=[],b=0,x=c.indexOf(v),w=0;for(;x>=0&&w<500;)x>b&&r.push(t.slice(b,x)),r.push(e("mark",{children:t.slice(x,x+v.length)},o+"-m"+String(w))),b=x+v.length,w+=1,x=c.indexOf(v,b);return b<t.length&&r.push(t.slice(b)),r}function Ge(t){let a=t.health==="unhealthy"?"unhealthy":t.state,o=t.health==="unhealthy"?"\u4E0D\u5065\u5EB7":Bt(t.state);return e("span",{className:"dk_badge","data-state":a,title:t.status??"",children:o})}function V(t){return d("div",{className:"dk_banner","data-kind":t.kind??"error",children:[e("span",{className:"dk_bannerIcon",dangerouslySetInnerHTML:{__html:jt}},"icon"),d("div",{className:"dk_bannerBody",children:[e("div",{children:t.title}),t.hint===void 0?null:e("div",{className:"dk_hint",style:{marginTop:4},children:t.hint})]},"body"),t.action===void 0?null:e("div",{className:"dk_bannerAction",children:t.action},"action")]})}function Te(t){return d("div",{className:"dk_confirmBackdrop",onMouseDown:a=>a.stopPropagation(),children:[d("div",{className:"dk_confirm",children:[e("div",{className:"dk_confirmTitle",children:t.title}),e("div",{className:"dk_confirmText",children:t.text}),d("div",{className:"dk_confirmActions",children:[e("button",{type:"button",className:"dk_btn",onClick:t.onCancel,children:"\u53D6\u6D88"}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:t.onConfirm,children:t.confirmLabel})]})]})]})}function Kt(t){return e("button",{type:"button",className:"dk_btn"+(t.danger===!0?" dk_btnDanger":""),disabled:t.disabled===!0,title:t.title??"",onClick:a=>{a.stopPropagation(),t.onClick()},children:t.children})}function ke(t){return d("div",{className:"dk_cardRow",children:[e("span",{className:"dk_cardLabel",children:t.label}),e("span",{className:"dk_cardValue",title:String(t.value),children:t.value})]})}function K(t){let a=t.disabled===!0;return e("button",{type:"button",className:"dk_iconBtn"+(t.danger===!0?" dk_iconBtnDanger":""),"data-on":t.on===!0?"1":void 0,"data-spin":t.spin===!0?"1":void 0,disabled:a,title:t.title,"aria-label":t.title,onClick:o=>{o.stopPropagation(),!a&&t.onClick()},children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:t.icon}})})}function ot(t){let a=t.item,o=t.allowMutations!==!0,c=a.state==="running"||a.state==="paused"||a.state==="restarting",v=a.createdAt===null?a.runningFor===""?"\u2014":a.runningFor:Et(a.createdAt);return d("div",{className:"dk_card",role:"button",tabIndex:0,"data-selected":t.selected===!0?"1":"0",onClick:()=>t.onOpen(a,"overview"),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.onOpen(a,"overview"))},children:[d("div",{className:"dk_cardHead",children:[e("span",{className:"dk_cardName",title:a.name,children:a.name}),e(Ge,{state:a.state,health:a.health,status:a.status})]},"head"),d("div",{className:"dk_cardRows",children:[e(ke,{label:"\u955C\u50CF",value:a.image},"image"),e(ke,{label:"ID",value:a.shortId},"id"),e(ke,{label:"\u7AEF\u53E3",value:Ze(a.ports)},"ports"),e(ke,{label:"\u521B\u5EFA",value:v},"created"),a.composeProject===null?null:e(ke,{label:"compose",value:a.composeProject+(a.composeService===null?"":"/"+a.composeService)},"compose")]},"rows"),d("div",{className:"dk_actionBar",children:[e(K,{icon:nt,title:"\u5728\u5BB9\u5668\u5185\u6253\u5F00\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\uFF08docker exec -it "+a.name+" sh\uFF09",onClick:()=>t.onExec(a)},"exec"),e(K,{icon:Ft,title:"\u67E5\u770B\u65E5\u5FD7",onClick:()=>t.onOpen(a,"logs")},"logs"),e(K,{icon:Gt,title:"\u8D44\u6E90\u5360\u7528",onClick:()=>t.onOpen(a,"stats")},"stats"),e("span",{className:"dk_actionBarSep","aria-hidden":"true"},"sep"),e(K,{icon:c?At:Dt,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":c?"\u505C\u6B62\u5BB9\u5668":"\u542F\u52A8\u5BB9\u5668",disabled:o,onClick:()=>t.onAction(c?"stop":"start",a)},"power"),e(K,{icon:Ht,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u91CD\u542F\u5BB9\u5668",disabled:o,onClick:()=>t.onAction("restart",a)},"restart"),e(K,{icon:Pt,danger:!0,title:o?"\u9700\u8981\u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D":"\u5220\u9664\u5BB9\u5668\uFF08\u4E0D\u53EF\u6062\u590D\uFF09",disabled:o,onClick:()=>t.onAction("remove",a)},"remove")]},"actions")]})}let lt=/^\s*(\[\d{4}-\d{2}-\d{2}[ T][0-9:.,]+\]|\d{2}:\d{2}:\d{2}[,.]\d{3})/,it=/^\s*(\[(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\]|\|\s*(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL))/,st=/(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)/,Le=2e3;function ct(t,a,o){let c=[],v=t;for(let r=0;r<2;r+=1){let b=lt.exec(v);if(b!==null){c.push(e("span",{className:"dk_logTs",children:b[1]},"ts"+String(r))),v=v.slice(b[0].length);continue}let x=it.exec(v);if(x!==null){let w=st.exec(x[1]);c.push(e("span",{className:"dk_logLevel","data-level":w===null?"":w[1],children:x[1].trim()},"lv"+String(r))),v=v.slice(x[0].length);continue}break}return c.push(e("span",{className:"dk_logText",children:dt(v,o,"x"+String(a))},"tx")),d("div",{className:"dk_logLine",children:c},String(a))}function kt(t){let a=t.item,o=t.config,[c,v]=g(t.initialTab??"overview"),[r,b]=g(null),[x,w]=g(""),[N,j]=g({tail:o.logTailDefault,timestamps:!1}),[E,B]=g(null),[T,$]=g(""),[Y,ee]=g(!1),[O,R]=g(""),[S,F]=g(!1),[J,l]=g(3),[s,h]=g(null),[M,q]=g(""),[ge,X]=g(""),[D,be]=g(null),[he,A]=g(""),[te,pe]=g(!1);C(()=>{let p=!0;return b(null),w(""),P.inspect(t.target,a.id).then(_=>{p&&b(_.details?.[0]??null)}).catch(_=>{p&&w(_.message)}),()=>{p=!1}},[t.target,a.id,t.refreshToken]);let Q=de(()=>{ee(!0),$(""),P.logs(t.target,a.id,{tail:N.tail,timestamps:N.timestamps}).then(p=>B(p.logs)).catch(p=>$(p.message)).finally(()=>ee(!1))},[t.target,a.id,N.tail,N.timestamps]);C(()=>{c==="logs"&&Q()},[c,Q,t.refreshToken]),C(()=>{if(c!=="logs"||!S)return;let p=setInterval(Q,Math.max(1,J)*1e3);return()=>clearInterval(p)},[c,S,J,Q]),C(()=>{if(c!=="stats")return;let p=!0,_=()=>{P.stats(t.target,[a.id]).then(y=>{p&&(h(y.stats?.[0]??null),q(""))}).catch(y=>{p&&q(y.message)})};_();let k=setInterval(_,Math.max(2,o.pollIntervalSec)*1e3);return()=>{p=!1,clearInterval(k)}},[c,t.target,a.id,o.pollIntervalSec,t.refreshToken]);let U=()=>{ge.trim()!==""&&(pe(!0),A(""),be(null),P.exec(t.target,a.id,ge,o.execTimeoutSec).then(p=>be(p.result)).catch(p=>A(p.message)).finally(()=>pe(!1)))},W=()=>{if(x!=="")return e(V,{title:"\u8BFB\u53D6\u5BB9\u5668\u8BE6\u60C5\u5931\u8D25",hint:x});if(r===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let p=[["\u72B6\u6001",r.state+(r.health===null?"":" / "+r.health)+(r.status===""?"":"\uFF08"+r.status+"\uFF09")],["\u955C\u50CF",r.image],["\u5BB9\u5668 ID",r.shortId],["\u542F\u52A8\u65F6\u95F4",r.startedAt??"\u2014"],["\u7ED3\u675F\u65F6\u95F4",r.finishedAt??"\u2014"],["\u9000\u51FA\u7801",r.exitCode===null?"\u2014":String(r.exitCode)],["\u91CD\u542F\u6B21\u6570",r.restartCount===null?"\u2014":String(r.restartCount)],["\u91CD\u542F\u7B56\u7565",r.restartPolicy??"\u2014"],["PID",r.pid===null?"\u2014":String(r.pid)],["\u7AEF\u53E3",r.ports.length===0?"\u2014":Ze(r.ports)],["\u6302\u8F7D",r.mounts.length===0?"\u2014":r.mounts.map(k=>k.source+"\u2192"+k.destination+(k.readWrite?"":"\uFF08\u53EA\u8BFB\uFF09")).join(`
1270
+ `)],["\u7F51\u7EDC",r.networks.length===0?"\u2014":r.networks.map(k=>k.name+(k.ip===null?"":"\uFF08"+k.ip+"\uFF09")).join(", ")],["\u547D\u4EE4",(r.entrypoint+" "+r.command).trim()||"\u2014"],["\u5DE5\u4F5C\u76EE\u5F55",r.workingDir===""?"\u2014":r.workingDir],["\u7528\u6237",r.user===""?"\u2014":r.user]],_=d("div",{className:"dk_kv",children:p.flatMap(([k,y],L)=>[e("div",{className:"dk_kvKey",children:k},"k"+String(L)),e("div",{className:"dk_kvVal"+(k==="\u5BB9\u5668 ID"||k==="\u547D\u4EE4"||k==="\u955C\u50CF"?" dk_kvValMono":""),children:y},"v"+String(L))])});return d("div",{children:[r.healthLogTail===null?null:e("div",{className:"dk_hint",style:{marginBottom:8},children:"\u6700\u8FD1\u5065\u5EB7\u68C0\u67E5\u8F93\u51FA\uFF1A"+r.healthLogTail}),_,e("div",{className:"dk_cardSection",style:{marginTop:16},children:"\u4E00\u6B21\u6027\u547D\u4EE4\uFF08docker exec\uFF09"}),o.allowExec!==!0?e(V,{kind:"info",title:"exec \u672A\u542F\u7528",hint:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8 exec\u300D\uFF0C\u6216\u76F4\u63A5\u590D\u5236\u5361\u7247\u4E0A\u7684 exec \u547D\u4EE4\u5230\u7EC8\u7AEF\u9762\u677F\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u3002"}):d("div",{children:[d("div",{className:"dk_row",children:[e("input",{className:"dk_input",style:{flex:"1 1 auto"},placeholder:"\u5982 ls -la /app \u6216 cat /etc/nginx/nginx.conf",value:ge,onChange:k=>X(k.target.value),onKeyDown:k=>{k.key==="Enter"&&U()}}),e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:te,onClick:U,children:te?"\u6267\u884C\u4E2D\u2026":"\u6267\u884C"})]}),he===""?null:e(V,{title:"\u6267\u884C\u5931\u8D25",hint:he}),D===null?null:d("div",{style:{marginTop:8},children:[e("div",{className:"dk_hint",children:"\u9000\u51FA\u7801 "+(D.code===null?"?":String(D.code))+" \xB7 \u8017\u65F6 "+String(D.durationMs)+"ms"+(D.truncated?" \xB7 \u8F93\u51FA\u5DF2\u622A\u65AD":"")}),e("pre",{className:"dk_logBox",style:{marginTop:6},children:(D.stdout||"")+(D.stderr===""?"":`
1207
1271
  [stderr]
1208
- `+R.stderr)||"(\u65E0\u8F93\u51FA)"})]})]})]})},ne=()=>{let p=B!==null&&typeof B=="object"&&typeof B.text=="string"?B.text:"",_=M.trim().toLowerCase(),k=p===""?[]:p.split(`
1209
- `),y=_===""?k:k.filter(L=>L.toLowerCase().includes(_));return{raw:p,needle:_,allLines:k,matchedLines:y}},me=(p,_,k)=>e("button",{type:"button",className:"dk_pill","data-on":p?"1":"0",onClick:k,children:_}),Ie=()=>{let{raw:p}=ne(),_=[...new Set([100,200,500,1e3,5e3,Number(o.logTailDefault)||200,Number(N.tail)||200])].filter(k=>Number.isInteger(k)&&k>0).sort((k,y)=>k-y);return d("div",{className:"dk_logTools",children:[e("span",{className:"dk_toolLabel",children:"LINES"}),e("select",{className:"dk_select dk_selectSm",value:String(N.tail),onChange:k=>j({...N,tail:Number(k.target.value)}),children:_.map(k=>e("option",{value:String(k),children:k===5e3?"Last 5000":"Last "+String(k)},String(k)))}),e("span",{className:"dk_toolLabel",children:"TIMESTAMPS"}),me(N.timestamps,N.timestamps?"On":"Off",()=>j({...N,timestamps:!N.timestamps})),e("span",{className:"dk_toolLabel",children:"AUTO REFRESH"}),me(S,S?"On":"Off",()=>F(k=>!k)),e("select",{className:"dk_select dk_selectSm",value:String(J),title:"\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u5F00\u542F AUTO REFRESH \u540E\u6309\u6B64\u8F6E\u8BE2\uFF09",onChange:k=>l(Number(k.target.value)),children:[2,3,5,10].map(k=>e("option",{value:String(k),children:String(k)+"s"},String(k)))}),Y?e("span",{className:"dk_spin"}):null,e(K,{icon:Ne,title:"\u5237\u65B0\u65E5\u5FD7",onClick:Q},"refresh"),e(K,{icon:zt,title:"\u4E0B\u8F7D\u65E5\u5FD7",disabled:p==="",onClick:()=>Mt(a.name+".log",p)},"download")]})},_e=()=>{let{needle:p,allLines:_,matchedLines:k}=ne();return d("div",{className:"dk_filterBar",children:[d("div",{className:"dk_filterWrap",children:[e("input",{className:"dk_input dk_filterInput",placeholder:"\u8FC7\u6EE4\u65E5\u5FD7\u2026",value:M,onChange:y=>O(y.target.value),onKeyDown:y=>{y.key==="Escape"&&M!==""&&(y.stopPropagation(),O(""))}}),M===""?null:e("button",{type:"button",className:"dk_filterClear",title:"\u6E05\u7A7A\u8FC7\u6EE4","aria-label":"\u6E05\u7A7A\u8FC7\u6EE4",onClick:()=>O(""),children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ce}})},"clear")]}),e("span",{className:"dk_filterCount",children:p===""?String(_.length)+" \u884C":String(k.length)+" / "+String(_.length)+" \u884C\u5339\u914D"})]})},Me=()=>{let{needle:p,matchedLines:_}=ne(),k=_.length>Le?_.slice(-Le):_;return d("div",{className:"dk_logs",children:[T===""?null:e(G,{title:"\u8BFB\u53D6\u65E5\u5FD7\u5931\u8D25",hint:T+(T.includes("Failed to fetch")?"\uFF08\u7F51\u7EDC\u8BF7\u6C42\u6CA1\u5230\u5BBF\u4E3B\uFF1A\u5BBF\u4E3B\u53EF\u80FD\u521A\u91CD\u542F\u3001\u6216\u8FDE\u63A5\u88AB\u4E2D\u65AD\uFF09":""),action:e("button",{type:"button",className:"dk_btn",disabled:Y,onClick:Q,children:"\u91CD\u8BD5"})}),B!==null&&B.truncated===!0?e(G,{kind:"warn",title:"\u65E5\u5FD7\u8F93\u51FA\u8D85\u8FC7\u4E0A\u9650\uFF0C\u5DF2\u622A\u65AD",hint:"\u8C03\u5C0F\u300CLINES\u300D\u6216\u5230\u8BBE\u7F6E\u5361\u7247\u8C03\u5927\u300C\u5355\u6B21\u547D\u4EE4\u8F93\u51FA\u4E0A\u9650\u300D\u3002"}):null,d("div",{className:"dk_logBody",children:[_.length>k.length?e("div",{className:"dk_logLine dk_logMore",children:"\uFF08\u53EA\u663E\u793A\u6700\u8FD1 "+String(Le)+" \u884C\uFF0C\u5171 "+String(_.length)+" \u884C\u5339\u914D\uFF09"},"more"):null,T!==""?null:B===null?e("div",{className:"dk_logLine",children:"\u8BFB\u53D6\u4E2D\u2026"},"loading"):k.length===0?e("div",{className:"dk_logLine",children:p===""?"(\u65E0\u65E5\u5FD7)":"(\u65E0\u5339\u914D\u65E5\u5FD7)"},"empty"):k.map((y,L)=>ct(y,L,p))]})]})},Oe=()=>{if(z!=="")return e(G,{title:"\u8BFB\u53D6\u7EDF\u8BA1\u5931\u8D25",hint:z});if(s===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let p=s.cpuPercent??0,_=s.memPercent??0,k=L=>d("div",{className:"dk_bar",children:[e("div",{className:"dk_barFill","data-warn":L>=60&&L<85?"1":void 0,"data-danger":L>=85?"1":void 0,style:{width:Math.min(100,Math.max(0,L))+"%"}})]}),y=(L,xe,De)=>d("tr",{children:[e("td",{children:L}),e("td",{className:"dk_num",children:xe}),e("td",{children:De??null})]},L);return d("table",{className:"dk_stats",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u6307\u6807"}),e("th",{children:"\u6570\u503C"}),e("th",{children:"\u5360\u7528"})]})}),e("tbody",{children:[y("CPU",Lt(s.cpuPercent),k(p)),y("\u5185\u5B58",s.memUsage,k(_)),y("\u7F51\u7EDC IO",s.netIO,null),y("\u78C1\u76D8 IO",s.blockIO,null),y("PIDs",s.pids===null?"\u2014":String(s.pids),null)]})]})},Re=[["overview","\u6982\u89C8"],["logs","\u65E5\u5FD7"],["stats","\u7EDF\u8BA1"]],fe=c==="overview"?r===null&&x==="":c==="stats"?s===null&&z==="":!1;return d("div",{className:"dk_detail",children:[d("div",{className:"dk_header dk_headerDetail",children:[e(K,{icon:Gt,title:"\u8FD4\u56DE\u5BB9\u5668\u5217\u8868",onClick:t.onBack},"back"),e("span",{className:"dk_detailTitle",title:a.name,children:a.name}),e(Ve,{state:a.state,health:a.health,status:a.status}),e("span",{className:"dk_detailSub",children:t.targetLabel??""}),e("span",{className:"dk_headerSpacer"}),c==="logs"?Ie():e(K,{icon:Ne,title:"\u5237\u65B0",spin:fe,onClick:t.onRefresh},"refresh"),t.docked===!0?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:t.onClose,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ce}})},"close")]}),d("div",{className:"dk_tabs",children:[...Re.map(([p,_])=>e("button",{type:"button",className:"dk_tab","data-on":c===p?"1":"0",onClick:()=>v(p),children:_},p)),c==="logs"?e("span",{className:"dk_headerSpacer"},"spacer"):null,c==="logs"?_e():null]}),e("div",{className:"dk_detailBody",children:c==="overview"?W():c==="logs"?Me():Oe()})]})}function ut(t){let a=t.collapsed===!0;return d("div",{className:"dk_drawer","data-collapsed":a?"1":void 0,style:a||t.height===null?void 0:{height:String(t.height)+"px"},children:[e("div",{className:"dk_drawerResize",title:"\u62D6\u52A8\u8C03\u6574\u7EC8\u7AEF\u9AD8\u5EA6\uFF08\u53CC\u51FB\u6298\u53E0 / \u5C55\u5F00\uFF09",onMouseDown:t.onResizeStart,onDoubleClick:t.onToggleCollapse},"resize"),d("div",{className:"dk_drawerHead",children:[e("span",{className:"dk_drawerIcon",dangerouslySetInnerHTML:{__html:nt}}),e("span",{className:"dk_drawerTitle",title:t.label,children:t.label}),e("span",{className:"dk_drawerHint",children:a?"\u5DF2\u6298\u53E0 \xB7 \u4F1A\u8BDD\u4FDD\u6301\u8FD0\u884C":"\u7531\u7EC8\u7AEF\u9762\u677F\u627F\u8F7D \xB7 \u6298\u53E0\u4FDD\u7559\u4F1A\u8BDD"}),e("span",{className:"dk_headerSpacer"}),e("button",{type:"button",className:"dk_iconBtn dk_drawerFold",title:a?"\u5C55\u5F00\u7EC8\u7AEF\uFF08\u4F1A\u8BDD\u672A\u4E2D\u65AD\uFF09":"\u6298\u53E0\u7EC8\u7AEF\uFF08\u4F1A\u8BDD\u4FDD\u6301\u8FD0\u884C\uFF09",onClick:t.onToggleCollapse,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:at}})},"fold"),e("button",{type:"button",className:"dk_iconBtn",title:"\u7ED3\u675F\u7EC8\u7AEF\u4F1A\u8BDD\u5E76\u6536\u8D77\u62BD\u5C49",onClick:t.onClose,children:e("span",{dangerouslySetInnerHTML:{__html:Ce}})},"close")]}),e("div",{className:"dk_drawerBody",ref:t.hostRef})]})}function Ge(t){let[a,o]=g(null),[c,v]=g([]),[r,b]=g(t.initialTarget??""),x=t.sessionHint!==void 0&&(t.initialTarget??"")==="",[w,N]=g("containers"),[j,B]=g([]),[I,T]=g([]),[$,Y]=g(!1),[ee,M]=g(""),[O,S]=g(""),[F,J]=g(!0),[l,s]=g(""),[h,z]=g("all"),[q,ge]=g(!1),[X,R]=g(null),[be,he]=g(0),[D,te]=g(null),[pe,Q]=g(""),U=P(!0),[W,ne]=g(null),me=P(null),[Ie,_e]=g(!1),[Me,Oe]=g(null),[Re,fe]=g(!1),p=P(null),_=P(!1);C(()=>()=>{U.current=!1},[]),C(()=>{if(W===null)return;let n=me.current;if(n===null)return;let u=null;try{u=Z.mount(n,W.options)}catch(f){S("\u7EC8\u7AEF\u542F\u52A8\u5931\u8D25\uFF1A"+(f instanceof Error?f.message:String(f))),ne(null);return}return()=>{try{u?.()}catch{}}},[W]);let k=n=>{if(n.button!==void 0&&n.button!==0)return;let u=n.currentTarget.parentElement,f=p.current;if(u===null||f===null)return;n.preventDefault();let ie=n.clientY,se=u.getBoundingClientRect().height,A=Math.max(160,Math.round(f.getBoundingClientRect().height*.75)),$e=Nt=>{let Ct=Math.round(se+(ie-Nt.clientY));Oe(Math.min(A,Math.max(160,Ct)))},qe=()=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",qe),document.body.style.userSelect=""};document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",qe)},y=()=>{if(W===null){t.onClose();return}fe(!0)};C(()=>{H.config().then(n=>{let u=n.config;o(u),!x&&Array.isArray(u.targets)&&u.targets.length>0&&b(f=>f===""?u.targets[0].name:f),ze(u)}).catch(n=>M(n.message)),H.targets().then(n=>{v(n.targets??[]),Fe=n.targets??[];let u=(n.targets??[])[0];u!==void 0&&!x&&b(f=>f===""?u.name:f)}).catch(()=>{})},[]);let L=de(()=>{r!==""&&(Y(!0),H.containers(r,F).then(n=>{U.current&&(B(n.containers??[]),M(""))}).catch(n=>{U.current&&M(n.message)}).finally(()=>{U.current&&Y(!1)}))},[r,F]),xe=de(()=>{r!==""&&(Y(!0),H.images(r).then(n=>{U.current&&(T(n.images??[]),M(""))}).catch(n=>{U.current&&M(n.message)}).finally(()=>{U.current&&Y(!1)}))},[r]),De=de(()=>he(n=>n+1),[]),le=de(()=>{w==="images"?xe():L(),he(n=>n+1)},[w,L,xe]);C(()=>{r!==""&&le()},[r,F,w]),C(()=>{if(!q||r===""||w!=="containers")return;let n=setInterval(le,Math.max(2,a?.pollIntervalSec??5)*1e3);return()=>clearInterval(n)},[q,le,r,a,w]),C(()=>{if(O==="")return;let n=setTimeout(()=>S(""),4e3);return()=>clearTimeout(n)},[O]);let we=(n,u)=>{let f=et(n.name);navigator.clipboard.writeText(f).then(()=>{S("\u5DF2\u590D\u5236\uFF1A"+f+(u===void 0?"":"\uFF08"+u+"\uFF09"))}).catch(()=>S("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C\uFF1A"+f))},_t=n=>{let u=et(n.name);if(Z===null){let A=document.querySelector("[data-dsh-tty-entry]")!==null;we(n,A?"\u7EC8\u7AEF\u9762\u677F\u7248\u672C\u8FC7\u65E7\uFF08\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u9700\u8981 dsh-tty \u2265 0.14.0\uFF09\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C":"\u672A\u5B89\u88C5 dsh-tty \u7EC8\u7AEF\u9762\u677F\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C\uFF08\u88C5 dsh-tty \u540E\u53EF\u76F4\u63A5\u5728\u6B64\u5F00\u7EC8\u7AEF\uFF09");return}let f=(a?.targets??[]).find(A=>A.name===r),ie=n.name+" \xB7 exec",se=f===void 0||f.kind==="local"?{command:u,label:ie}:typeof f.book=="string"&&f.book!==""?{book:f.book,command:u,label:ie}:(f.auth??"agent")==="agent"?{spec:{host:f.host,port:f.port,username:f.username,auth:"agent",agentForward:f.agentForward===!0},command:u,label:ie}:null;if(se===null){we(n,"\u5185\u8054\u76EE\u6807\u7528\u4E86 key/password \u8BA4\u8BC1\uFF0C\u6D4F\u89C8\u5668\u7AEF\u62FF\u4E0D\u5230\u51ED\u8BC1");return}if(t.docked===!0){try{Z.open(se)}catch(A){we(n,A instanceof Error?A.message:String(A))}return}if(typeof Z.mount=="function"&&Number(Z.version??0)>=2){ne({label:ie,options:se}),_e(!1);return}try{Z.open(se),t.onClose()}catch(A){we(n,A instanceof Error?A.message:String(A))}},xt=(n,u)=>{te({title:n==="remove"?"\u5220\u9664\u5BB9\u5668":n==="stop"?"\u505C\u6B62\u5BB9\u5668":n==="start"?"\u542F\u52A8\u5BB9\u5668":"\u91CD\u542F\u5BB9\u5668",text:n==="remove"?`\u786E\u5B9A\u5220\u9664\u5BB9\u5668 ${u.name}\uFF1F\u5BB9\u5668\u7684\u53EF\u5199\u5C42\u4E0E\u914D\u7F6E\u4F1A\u88AB\u5220\u9664\uFF08\u547D\u540D\u6570\u636E\u5377\u4FDD\u7559\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`:`\u786E\u5B9A\u5BF9\u5BB9\u5668 ${u.name} \u6267\u884C${n==="stop"?"\u505C\u6B62":n==="start"?"\u542F\u52A8":"\u91CD\u542F"}\u64CD\u4F5C\uFF1F`,confirmLabel:n==="remove"?"\u5220\u9664":"\u786E\u5B9A",run:()=>{te(null),H.action(r,n,u.id).then(f=>{S(`${f.result.action} ${u.name}\uFF1A${f.result.message}`),le()}).catch(f=>M(f.message))}})},ye=X===null?null:j.find(n=>n.id===X.id)??X.item,We=j.filter(n=>{if(h==="running"&&!(n.state==="running"||n.state==="paused"||n.state==="restarting")||h==="stopped"&&n.state==="running"||h==="unhealthy"&&n.health!=="unhealthy")return!1;let u=l.trim().toLowerCase();return u===""?!0:n.name.toLowerCase().includes(u)||n.image.toLowerCase().includes(u)||n.id.toLowerCase().includes(u)}),Ae=I.filter(n=>{let u=pe.trim().toLowerCase();return u===""||n.reference.toLowerCase().includes(u)||n.id.toLowerCase().includes(u)}),He=n=>{let u=c.find(f=>f.name===n);return u===void 0||u.label===void 0?n:n+" \xB7 "+u.label},Ye=()=>$?e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]}):r===""?x?d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u4E0D\u662F Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u6309\u4E0A\u9762\u7684\u63D0\u793A\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761\u76EE\u6807\uFF08\u63A8\u8350\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u3002\u4E3A\u907F\u514D\u5F20\u51A0\u674E\u6234\uFF0C\u9762\u677F\u4E0D\u4F1A\u81EA\u52A8\u5207\u5230\u5176\u4ED6\u76EE\u6807\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u8FD8\u6CA1\u6709\u914D\u7F6E Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u4E2A\u76EE\u6807\uFF1A\u672C\u673A\u76F4\u63A5\u9009\u300C\u672C\u673A\u300D\uFF1B\u8FDC\u7A0B\u4E3B\u673A\u53EF\u4EE5\u5F15\u7528 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:w==="images"?"\u6CA1\u6709\u955C\u50CF":"\u6CA1\u6709\u5BB9\u5668"}),e("div",{className:"dk_emptyHint",children:l.trim()===""?"\u76EE\u6807\u4E0A\u6CA1\u6709\u5339\u914D\u7684\u6570\u636E\uFF0C\u6216\u7B5B\u9009\u6761\u4EF6\u8FC7\u7A84\u3002":"\u6CA1\u6709\u5339\u914D\u300C"+l.trim()+"\u300D\u7684\u7ED3\u679C\u3002"})]}),wt=()=>w==="images"?d("div",{className:"dk_imagesView",children:[Ae.length===0?Ye():e("div",{className:"dk_tableWrap",children:d("table",{className:"dk_images",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u955C\u50CF"}),e("th",{children:"\u5927\u5C0F"}),e("th",{children:"\u521B\u5EFA"}),e("th",{children:"ID"})]})}),e("tbody",{children:Ae.map(n=>d("tr",{children:[e("td",{className:"dk_mono",children:n.reference}),e("td",{children:n.sizeText}),e("td",{children:n.createdSince}),e("td",{className:"dk_mono",children:n.shortId})]},n.id+n.reference))})]})})]}):We.length===0?Ye():e("div",{className:"dk_grid",children:We.map(n=>e(ot,{item:n,selected:X!==null&&n.id===X.id,allowMutations:a?.allowMutations===!0,onOpen:(u,f)=>R({id:u.id,tab:f,item:u}),onExec:_t,onAction:xt,onCopyExec:u=>{navigator.clipboard.writeText("docker exec -it "+u.name+" sh").then(()=>S("\u5DF2\u590D\u5236\uFF1Adocker exec -it "+u.name+" sh")).catch(()=>S("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236"))}},n.id))}),ae=t.docked===!0,yt=[ye!==null?[e(kt,{item:ye,target:r,targetLabel:He(r),config:a??{pollIntervalSec:5,logTailDefault:200,allowExec:!1,execTimeoutSec:30},initialTab:X.tab,refreshToken:be,onBack:()=>R(null),onRefresh:De,onClose:y,docked:ae},"detail"),D===null?null:e(Te,{title:D.title,text:D.text,confirmLabel:D.confirmLabel,onCancel:()=>te(null),onConfirm:D.run},"confirm")]:[ae?null:d("div",{className:"dk_header",children:[e("span",{className:"dk_titleIcon",dangerouslySetInnerHTML:{__html:tt}}),e("span",{className:"dk_title",children:"Docker \u5BB9\u5668"}),a?.allowMutations===!0?null:e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"}),e("span",{className:"dk_headerSpacer"}),ye!==null?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868","data-spin":$?"1":void 0,onClick:le,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ne}})}),e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:y,children:e("span",{dangerouslySetInnerHTML:{__html:Ce}})})]}),ye!==null?null:d("div",{className:"dk_toolbar",children:[ae?e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868","data-spin":$?"1":void 0,onClick:le,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ne}})},"refresh"):null,ae&&a?.allowMutations!==!0?e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"},"readonly"):null,e("select",{className:"dk_select",value:r,onChange:n=>{b(n.target.value),R(null),t.onTargetChange?.(He(n.target.value))},children:[...r===""?[e("option",{value:"",children:"\uFF08\u672A\u9009\u62E9\u76EE\u6807\uFF09"},"__none")]:[],...(c.length===0&&r!==""?[{name:r,label:void 0}]:c).map(n=>e("option",{value:n.name,children:He(n.name)},n.name))]}),e("div",{className:"dk_seg",children:[["containers","\u5BB9\u5668"],["images","\u955C\u50CF"]].map(([n,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":w===n?"1":"0",onClick:()=>{N(n),R(null)},children:u},n))}),w==="containers"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u540D\u79F0 / \u955C\u50CF / ID",value:l,onChange:n=>s(n.target.value)}):null,w==="images"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u955C\u50CF\uFF08\u4ED3\u5E93 / \u6807\u7B7E / ID\uFF09",value:pe,onChange:n=>Q(n.target.value)}):null,w==="images"?e("span",{className:"dk_hint dk_searchCount",children:String(Ae.length)+" / "+String(I.length)+" \u4E2A\u955C\u50CF"}):null,w==="containers"?e("div",{className:"dk_seg",children:[["all","\u5168\u90E8"],["running","\u8FD0\u884C\u4E2D"],["stopped","\u5DF2\u505C\u6B62"],["unhealthy","\u4E0D\u5065\u5EB7"]].map(([n,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":h===n?"1":"0",onClick:()=>z(n),children:u},n))}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:F,onChange:n=>J(n.target.checked)}),"\u542B\u5DF2\u505C\u6B62"]}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:q,onChange:n=>ge(n.target.checked)}),"\u81EA\u52A8\u5237\u65B0"]}):null]}),d("div",{className:"dk_body",children:[d("div",{className:"dk_main"+(w==="images"?" dk_mainImages":""),children:[ee===""?null:e(G,{title:"\u64CD\u4F5C\u5931\u8D25",hint:ee}),O===""?null:e(G,{kind:"info",title:O}),t.sessionHint===void 0?null:e(G,{kind:"info",title:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u6CA1\u914D\u7F6E\u4E3A Docker \u76EE\u6807",hint:"\u4F1A\u8BDD\u4E3B\u673A\uFF1A"+t.sessionHint.host+(t.sessionHint.port===22?"":":"+String(t.sessionHint.port))+(t.sessionHint.book===""?"":"\uFF08\u8FDE\u63A5\u7C3F\uFF1A"+t.sessionHint.book+"\uFF09")+" \u2014 \u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761 kind=ssh \u76EE\u6807"+(t.sessionHint.book===""?"\uFF08\u586B host/username\uFF0C\u6216\u7528\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09":"\uFF0C\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\u300C"+t.sessionHint.book+"\u300D")+"\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u5373\u53EF\u3002"}),a!==null&&a.allowMutations!==!0?e(G,{kind:"info",title:"\u5F53\u524D\u4E3A\u53EA\u8BFB\u6A21\u5F0F",hint:"\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\u9700\u8981\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D\u3002"}):null,wt()]})]}),D===null?null:e(Te,{title:D.title,text:D.text,confirmLabel:D.confirmLabel,onCancel:()=>te(null),onConfirm:D.run})],W===null?null:e(ut,{label:W.label,hostRef:me,collapsed:Ie,height:Me,onToggleCollapse:()=>_e(n=>!n),onResizeStart:k,onClose:()=>ne(null)},"execDrawer"),Re&&W!==null?e(Te,{title:"\u7ED3\u675F\u5BB9\u5668\u7EC8\u7AEF\u4F1A\u8BDD",text:"\u5173\u95ED\u9762\u677F\u4F1A\u7ED3\u675F\u300C"+W.label+"\u300D\u7684\u7EC8\u7AEF\u4F1A\u8BDD\uFF08docker exec -it \u2026\uFF09\u3002\u82E5\u53EA\u662F\u60F3\u7ED9\u65E5\u5FD7 / \u5217\u8868\u817E\u5730\u65B9\uFF0C\u5148\u70B9\u62BD\u5C49\u53F3\u4E0A\u89D2\u7684\u6298\u53E0\u6309\u94AE\u5373\u53EF\uFF0C\u4F1A\u8BDD\u4F1A\u4FDD\u6301\u8FD0\u884C\u3002",confirmLabel:"\u7ED3\u675F\u5E76\u5173\u95ED",onCancel:()=>fe(!1),onConfirm:()=>{fe(!1),t.onClose()}},"closeConfirm"):null],Je=d("div",{className:"dk_panel"+(ae?" dk_panelDock":""),"data-dock":ae?"1":void 0,ref:p,onMouseDown:n=>n.stopPropagation(),children:yt});return ae?Je:d("div",{className:"dk_backdrop",onMouseDown:n=>{_.current=n.target===n.currentTarget},onMouseUp:n=>{let u=_.current&&n.target===n.currentTarget;_.current=!1,u&&y()},children:[Je]})}function gt(){let[t,a]=g(!1),[o,c]=g(null),[v,r]=g(!1),[b,x]=g(!1),[w,N]=g({kind:"",text:""}),j=P(0),B=de(()=>{H.config().then(l=>{c(l.config),ze(l.config),j.current=Array.isArray(l.config?.targets)?l.config.targets.length:0,r(!0)}).catch(l=>{N({kind:"error",text:"\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25\uFF1A"+l.message}),r(!0)})},[]);C(()=>{t&&!v&&B()},[t,v,B]);let I=l=>c(s=>({...s,...l})),T=(l,s)=>c(h=>{let z=h.targets.slice();return z[l]={...z[l],...s},{...h,targets:z}}),$=()=>c(l=>({...l,targets:[...l.targets,{name:"\u76EE\u6807"+String(l.targets.length+1),kind:"local",book:"",host:"",port:22,username:"",auth:"agent",keyPath:"",agentForward:!1,passwordSet:!1,passphraseSet:!1}]})),Y=l=>c(s=>({...s,targets:s.targets.filter((h,z)=>z!==l)})),ee=l=>c(s=>({...s,hostKeys:s.hostKeys.filter(h=>!(h.host===l.host&&h.port===l.port))})),M=()=>{x(!0),N({kind:"",text:""});let l={enabled:o.enabled,announceToAgent:o.announceToAgent,dockerBin:o.dockerBin,allowMutations:o.allowMutations,allowExec:o.allowExec,execTimeoutSec:o.execTimeoutSec,pollIntervalSec:o.pollIntervalSec,logTailDefault:o.logTailDefault,maxOutputKb:o.maxOutputKb,targets:o.targets.map(s=>({name:s.name,kind:s.kind,book:s.book??"",host:s.host??"",port:Number(s.port)||22,username:s.username??"",auth:s.auth??"agent",keyPath:s.keyPath??"",...s.password===void 0||s.password===""?{}:{password:s.password},...s.passphrase===void 0||s.passphrase===""?{}:{passphrase:s.passphrase},agentForward:s.agentForward===!0})),hostKeys:o.hostKeys,...o.targets.length===0&&j.current>0?{clearTargets:!0}:{}};H.saveConfig(l).then(s=>{c(s.config),ze(s.config),j.current=Array.isArray(s.config?.targets)?s.config.targets.length:0,Se(),N(s.warning===void 0?{kind:"ok",text:"\u5DF2\u4FDD\u5B58\u5E76\u70ED\u751F\u6548"}:{kind:"error",text:s.warning})}).catch(s=>{N({kind:"error",text:"\u4FDD\u5B58\u5931\u8D25\uFF1A"+s.message})}).finally(()=>x(!1))},O=l=>e("div",{className:"dk_cardSection",children:l}),S=(l,s,h)=>d("div",{className:"dk_field",children:[e("span",{className:"dk_label",children:l}),s,h===void 0?null:e("span",{className:"dk_hint",children:h})]}),F=(l,s,h,z)=>e("input",{className:"dk_input",type:"number",min:s,max:h,value:o[l],onChange:q=>I({[l]:Number(q.target.value)})}),J=l=>d("li",{className:"dk_settingsCard"+(t?" dk_settingsCardOpen":""),children:[d("button",{type:"button",className:"dk_settingsHead","aria-expanded":t,onClick:()=>a(s=>!s),children:[d("span",{className:"dk_settingsHeadText",children:[e("span",{className:"dk_settingsName",children:"Docker \u5BB9\u5668\u9762\u677F"}),e("span",{className:"dk_settingsDesc",children:"\u672C\u673A / SSH \u4E3B\u673A\u4E0A\u7684\u5BB9\u5668\u4E0E\u955C\u50CF\uFF1B\u9ED8\u8BA4\u53EA\u8BFB\uFF0C\u53D8\u66F4\u64CD\u4F5C\u9700\u663E\u5F0F\u5F00\u542F"})]}),e("span",{className:"dk_settingsChevron",dangerouslySetInnerHTML:{__html:at}})]}),t?e("div",{className:"dk_settingsBody",children:l}):null]});return J(t?!v||o===null?d("div",{className:"dk_row",children:[e("span",{className:"dk_spin"}),"\u8BFB\u53D6\u914D\u7F6E\u2026"]}):[O("\u57FA\u672C"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.enabled,onChange:l=>I({enabled:l.target.checked})}),"\u542F\u7528\u63D2\u4EF6"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.announceToAgent,onChange:l=>I({announceToAgent:l.target.checked})}),"\u5411 agent \u516C\u544A\u80FD\u529B"]})]}),d("div",{className:"dk_row",children:[S("docker CLI",e("input",{className:"dk_input",value:o.dockerBin,onChange:l=>I({dockerBin:l.target.value})}),"\u9ED8\u8BA4 docker\uFF1Bpodman \u53EF\u586B podman"),S("\u7EDF\u8BA1\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09",F("pollIntervalSec",1,60)),S("\u65E5\u5FD7\u9ED8\u8BA4\u884C\u6570",F("logTailDefault",1,5e3)),S("\u8F93\u51FA\u4E0A\u9650\uFF08KB\uFF09",F("maxOutputKb",1,8192)),S("exec \u8D85\u65F6\uFF08\u79D2\uFF09",F("execTimeoutSec",1,120))]}),O("\u80FD\u529B\u5F00\u5173\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF09"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.allowMutations,onChange:l=>I({allowMutations:l.target.checked})}),"\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\uFF08\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\uFF09"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.allowExec,onChange:l=>I({allowExec:l.target.checked})}),"\u5141\u8BB8 exec\uFF08\u5728\u5BB9\u5668\u5185\u6267\u884C\u547D\u4EE4\uFF09"]})]}),e("span",{className:"dk_hint",children:"docker socket \u7B49\u4EF7\u4E8E\u76EE\u6807\u4E3B\u673A\u7684 root \u6743\u9650\u3002\u5F00\u542F\u540E\uFF0C\u6D4F\u89C8\u5668\u9762\u677F\u4E0E agent \u90FD\u80FD\u6267\u884C\u5BF9\u5E94\u64CD\u4F5C\uFF0C\u8BF7\u53EA\u5728\u53EF\u4FE1\u73AF\u5883\u4E0B\u6253\u5F00\u3002"}),O("\u76EE\u6807"),...o.targets.map((l,s)=>d("div",{className:"dk_targetRow",children:[e("input",{className:"dk_input",value:l.name,placeholder:"\u76EE\u6807\u540D",onChange:h=>T(s,{name:h.target.value})}),e("select",{className:"dk_select",value:l.kind,onChange:h=>T(s,{kind:h.target.value}),children:[e("option",{value:"local",children:"\u672C\u673A"}),e("option",{value:"ssh",children:"SSH \u4E3B\u673A"})]}),l.kind==="local"?e("span",{className:"dk_hint",children:"\u5BBF\u4E3B\u6240\u5728\u673A\u5668\u4E0A\u7684 docker"}):d("div",{className:"dk_row",style:{gridColumn:"span 1"},children:[e("select",{className:"dk_select",value:l.book??"",onChange:h=>T(s,{book:h.target.value}),children:[e("option",{value:"",children:o.ttyBooks.length===0?"\uFF08\u65E0 tty \u8FDE\u63A5\u7C3F\uFF0C\u8BF7\u586B\u5185\u8054\u4FE1\u606F\uFF09":"\uFF08\u4E0D\u7528\u8FDE\u63A5\u7C3F\uFF0C\u624B\u586B\uFF09"}),...o.ttyBooks.map(h=>e("option",{value:h,children:"\u8FDE\u63A5\u7C3F\uFF1A"+h},h))]})]}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:()=>Y(s),children:"\u5220\u9664"}),l.kind==="ssh"&&(l.book??"")===""?d("div",{className:"dk_row",style:{gridColumn:"1 / -1"},children:[e("input",{className:"dk_input",placeholder:"host",value:l.host??"",onChange:h=>T(s,{host:h.target.value})}),e("input",{className:"dk_input",style:{width:90},placeholder:"port",value:l.port??22,onChange:h=>T(s,{port:Number(h.target.value)||22})}),e("input",{className:"dk_input",placeholder:"username",value:l.username??"",onChange:h=>T(s,{username:h.target.value})}),e("select",{className:"dk_select",value:l.auth??"agent",onChange:h=>T(s,{auth:h.target.value}),children:[e("option",{value:"agent",children:"ssh-agent"}),e("option",{value:"key",children:"\u79C1\u94A5"}),e("option",{value:"password",children:"\u5BC6\u7801"})]}),(l.auth??"agent")==="key"?e("input",{className:"dk_input",placeholder:"~/.ssh/id_ed25519",value:l.keyPath??"",onChange:h=>T(s,{keyPath:h.target.value})}):null,(l.auth??"agent")==="password"?e("input",{className:"dk_input",type:"password",placeholder:l.passwordSet===!0?"\uFF08\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8\uFF09":"env:SSH_PASSWORD",value:l.password??"",onChange:h=>T(s,{password:h.target.value})}):null,e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:l.agentForward===!0,onChange:h=>T(s,{agentForward:h.target.checked})}),"agent forwarding"]})]}):null]},String(s)+l.name)),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn",onClick:$,children:"\u6DFB\u52A0\u76EE\u6807"}),e("span",{className:"dk_hint",children:"SSH \u76EE\u6807\u63A8\u8350\u76F4\u63A5\u9009 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF08\u51ED\u8BC1\u53EA\u9700\u7EF4\u62A4\u4E00\u5904\uFF09\uFF1B\u624B\u586B\u65F6\u5BC6\u7801 / \u53E3\u4EE4\u5EFA\u8BAE\u5199 env:VAR\u3002"})]}),O("SSH \u4E3B\u673A\u5BC6\u94A5\u8BB0\u5F55\uFF08TOFU\uFF09"),...o.hostKeys.length===0?[e("span",{className:"dk_hint",children:"\u6682\u65E0\u8BB0\u5F55 \u2014 \u9996\u6B21 SSH \u8FDE\u63A5\u6210\u529F\u540E\u81EA\u52A8\u8BB0\u5F55\u4E3B\u673A\u6307\u7EB9\uFF08\u82E5 tty \u5DF2\u8BB0\u5F55\u540C\u4E00\u4E3B\u673A\uFF0C\u4F1A\u76F4\u63A5\u590D\u7528\uFF09\u3002"},"none")]:o.hostKeys.map(l=>d("div",{className:"dk_targetRow",children:[e("span",{children:l.host+":"+String(l.port)}),e("span",{className:"dk_hint",style:{gridColumn:"span 2",wordBreak:"break-all"},children:"sha256:"+l.fingerprint}),e("button",{type:"button",className:"dk_btn",onClick:()=>ee(l),children:"\u5220\u9664"})]},l.host+":"+String(l.port))),e("span",{className:"dk_hint",children:"\u6307\u7EB9\u53D8\u66F4\u65F6\u8FDE\u63A5\u4F1A\u88AB\u62D2\u7EDD\uFF08\u9632\u4E2D\u95F4\u4EBA\uFF09\uFF1B\u786E\u8BA4\u5B89\u5168\u540E\u5220\u9664\u5BF9\u5E94\u8BB0\u5F55\u5373\u53EF\u91CD\u8FDE\u3002"}),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:b,onClick:M,children:b?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58"}),e("span",{className:"dk_msg","data-kind":w.kind,children:w.text})]})]:null)}let ue=null,oe=null,Ee=null;function ve(){let t=oe,a=ue,o=Ee;if(oe=null,ue=null,Ee=null,a!==null&&a.remove(),t!==null&&setTimeout(()=>{try{t.unmount()}catch{}},0),o!==null)try{o.dispose()}catch{}}function ht(t){return t!==null&&typeof t=="object"&&typeof t.appendChild=="function"}function pt(){return typeof re?.mountPane=="function"&&typeof re.isOpen=="function"&&Number(re.version??0)>=1&&re.isOpen()===!0}function Ke(t){ve(),Pe();let a={onClose:ve,initialTarget:t?.target??"",sessionHint:t?.sessionHint};if(pt()){let o=null;try{o=re.mountPane({title:"Docker \u5BB9\u5668",hint:t?.target===void 0||t.target===""?"":t.target,size:520,min:360,onClose:()=>ve()})}catch(c){o=null,console.warn("[dsh-docker] \u6302\u8F7D\u5230\u7EC8\u7AEF\u9762\u677F\u5931\u8D25\uFF0C\u56DE\u9000\u5F39\u7A97\uFF1A"+(c instanceof Error?c.message:String(c)))}if(o!==null&&ht(o.element)){Ee=o,oe=E(o.element),oe.render(e(Ge,{...a,docked:!0,onTargetChange:c=>{try{o.setHint(c)}catch{}}}));return}}ue=document.createElement("div"),document.body.appendChild(ue),oe=E(ue),oe.render(e(Ge,a))}function mt(){let t=document.querySelector('[data-pane="sidebar"], [class*="sidebarCol"]');if(t!==null)return t.querySelector('[class*="logoRow"]')?.parentElement??t.firstElementChild}function ft(t){let a=t.querySelector('button[class*="newSession"]');if(a!==null)return a;for(let o of t.children)if(o.tagName==="BUTTON")return o}function vt(){let t=document.createElement("div");return t.dataset.dshDockerEntry="",t.className="dk_sidebarEntry",t.setAttribute("role","button"),t.setAttribute("aria-label","\u5BB9\u5668"),t.innerHTML='<span class="dk_entryIcon">'+tt+'</span><span class="dk_entryLabel">\u5BB9\u5668</span>',t.addEventListener("click",a=>{a.preventDefault(),Ke()}),t}function Ue(t,a){let o=ft(t);if(o===void 0)return!1;if(a.parentElement!==t){let c=o.closest('[class*="logoRow"]'),v=c!==null&&c.parentElement===t?c:o,r=Array.from(t.children).filter(b=>b instanceof HTMLElement&&b.matches("[data-dsh-global-search-entry], [data-dsh-rss-entry], [data-dsh-taskboard-entry], [data-dsh-ssh-entry], [data-dsh-tty-entry], [data-dsh-docker-entry]"));if(r.length>0){let b=r[r.length-1];t.insertBefore(a,b.nextSibling)}else t.insertBefore(a,v.nextElementSibling)}return!0}function bt(){if(Pe(),document.querySelector("[data-dsh-docker-entry]")!==null)return()=>{};let t=vt(),a,o=!1,c=()=>{if(a!==void 0&&!a.isConnected&&(r.disconnect(),a=void 0,o=!1),o){if(document.body.contains(t))return;r.disconnect(),a=void 0,o=!1}a??(a=mt()),a!==void 0&&(o=Ue(a,t),o&&r.observe(a,{childList:!0,subtree:!0}))},v=new MutationObserver(()=>{c()});v.observe(document.body,{childList:!0,subtree:!0});let r=new MutationObserver(()=>{if(a===void 0||!a.isConnected){o=!1,c();return}a.contains(t)||(o=Ue(a,t))});return c(),()=>{v.disconnect(),r.disconnect(),t.remove()}}let Be={};return Be.inject=["slots"],Be.apply=t=>{Pe();let a=bt(),o=t.slots.inject("settings.plugin.item",()=>t.slots.register({name:"settings.plugin.item",key:"docker",order:112},gt));t.inject(["ttyTerminal"],v=>(Z=v.ttyTerminal??null,()=>{Z=null})),t.inject(["ttyPanel"],v=>(re=v.ttyPanel??null,()=>{re=null}));let c=()=>{};return Se(),t.inject(["ttyConnbar"],v=>{let r=v.ttyConnbar;r!==void 0&&(c=r.addAction(b=>{let x=b?.spec??{};if(x.t!=="ssh")return;let w=typeof b?.bookName=="string"?b.bookName:"",N=je(x,w),j=N!==void 0?`\u6253\u5F00\u8BE5\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F\uFF08\u76EE\u6807\uFF1A${N}\uFF09`:ce===null?"\u6253\u5F00\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F":"\u8BE5\u4E3B\u673A\u5C1A\u672A\u914D\u7F6E\u4E3A Docker \u76EE\u6807 \u2014 \u70B9\u51FB\u6253\u5F00\u9762\u677F\u67E5\u770B/\u914D\u7F6E";b.addAction(Rt,"\u5BB9\u5668",j,()=>{(async()=>{let B=await Ot(x,w),I=Number(x.port);Ke({target:B??"",sessionHint:B===void 0?{host:typeof x.host=="string"?x.host:"",port:Number.isInteger(I)&&I>0?I:22,book:w}:void 0})})()})}),(async()=>{for(let b=0;b<3;b+=1){if(await Se()){typeof r.requestRender=="function"&&r.requestRender();return}await new Promise(x=>setTimeout(x,2e3))}})())}),()=>{c(),o(),a(),ve()}},Be}});})();
1272
+ `+D.stderr)||"(\u65E0\u8F93\u51FA)"})]})]})]})},ne=()=>{let p=E!==null&&typeof E=="object"&&typeof E.text=="string"?E.text:"",_=O.trim().toLowerCase(),k=p===""?[]:p.split(`
1273
+ `),y=_===""?k:k.filter(L=>L.toLowerCase().includes(_));return{raw:p,needle:_,allLines:k,matchedLines:y}},me=(p,_,k)=>e("button",{type:"button",className:"dk_pill","data-on":p?"1":"0",onClick:k,children:_}),Be=()=>{let{raw:p}=ne(),_=[...new Set([100,200,500,1e3,5e3,Number(o.logTailDefault)||200,Number(N.tail)||200])].filter(k=>Number.isInteger(k)&&k>0).sort((k,y)=>k-y);return d("div",{className:"dk_logTools",children:[e("span",{className:"dk_toolLabel",children:"LINES"}),e("select",{className:"dk_select dk_selectSm",value:String(N.tail),onChange:k=>j({...N,tail:Number(k.target.value)}),children:_.map(k=>e("option",{value:String(k),children:k===5e3?"Last 5000":"Last "+String(k)},String(k)))}),e("span",{className:"dk_toolLabel",children:"TIMESTAMPS"}),me(N.timestamps,N.timestamps?"On":"Off",()=>j({...N,timestamps:!N.timestamps})),e("span",{className:"dk_toolLabel",children:"AUTO REFRESH"}),me(S,S?"On":"Off",()=>F(k=>!k)),e("select",{className:"dk_select dk_selectSm",value:String(J),title:"\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u5F00\u542F AUTO REFRESH \u540E\u6309\u6B64\u8F6E\u8BE2\uFF09",onChange:k=>l(Number(k.target.value)),children:[2,3,5,10].map(k=>e("option",{value:String(k),children:String(k)+"s"},String(k)))}),e(K,{icon:Ne,title:"\u5237\u65B0\u65E5\u5FD7",spin:Y,onClick:Q},"refresh"),e(K,{icon:zt,title:"\u4E0B\u8F7D\u65E5\u5FD7",disabled:p==="",onClick:()=>Mt(a.name+".log",p)},"download")]})},_e=()=>{let{needle:p,allLines:_,matchedLines:k}=ne();return d("div",{className:"dk_filterBar",children:[d("div",{className:"dk_filterWrap",children:[e("input",{className:"dk_input dk_filterInput",placeholder:"\u8FC7\u6EE4\u65E5\u5FD7\u2026",value:O,onChange:y=>R(y.target.value),onKeyDown:y=>{y.key==="Escape"&&O!==""&&(y.stopPropagation(),R(""))}}),O===""?null:e("button",{type:"button",className:"dk_filterClear",title:"\u6E05\u7A7A\u8FC7\u6EE4","aria-label":"\u6E05\u7A7A\u8FC7\u6EE4",onClick:()=>R(""),children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ce}})},"clear")]}),e("span",{className:"dk_filterCount",children:p===""?String(_.length)+" \u884C":String(k.length)+" / "+String(_.length)+" \u884C\u5339\u914D"})]})},Me=()=>{let{needle:p,matchedLines:_}=ne(),k=_.length>Le?_.slice(-Le):_;return d("div",{className:"dk_logs",children:[T===""?null:e(V,{title:"\u8BFB\u53D6\u65E5\u5FD7\u5931\u8D25",hint:T+(T.includes("Failed to fetch")?"\uFF08\u7F51\u7EDC\u8BF7\u6C42\u6CA1\u5230\u5BBF\u4E3B\uFF1A\u5BBF\u4E3B\u53EF\u80FD\u521A\u91CD\u542F\u3001\u6216\u8FDE\u63A5\u88AB\u4E2D\u65AD\uFF09":""),action:e("button",{type:"button",className:"dk_btn",disabled:Y,onClick:Q,children:"\u91CD\u8BD5"})}),E!==null&&E.truncated===!0?e(V,{kind:"warn",title:"\u65E5\u5FD7\u8F93\u51FA\u8D85\u8FC7\u4E0A\u9650\uFF0C\u5DF2\u622A\u65AD",hint:"\u8C03\u5C0F\u300CLINES\u300D\u6216\u5230\u8BBE\u7F6E\u5361\u7247\u8C03\u5927\u300C\u5355\u6B21\u547D\u4EE4\u8F93\u51FA\u4E0A\u9650\u300D\u3002"}):null,d("div",{className:"dk_logBody",children:[_.length>k.length?e("div",{className:"dk_logLine dk_logMore",children:"\uFF08\u53EA\u663E\u793A\u6700\u8FD1 "+String(Le)+" \u884C\uFF0C\u5171 "+String(_.length)+" \u884C\u5339\u914D\uFF09"},"more"):null,T!==""?null:E===null?e("div",{className:"dk_logLine",children:"\u8BFB\u53D6\u4E2D\u2026"},"loading"):k.length===0?e("div",{className:"dk_logLine",children:p===""?"(\u65E0\u65E5\u5FD7)":"(\u65E0\u5339\u914D\u65E5\u5FD7)"},"empty"):k.map((y,L)=>ct(y,L,p))]})]})},Oe=()=>{if(M!=="")return e(V,{title:"\u8BFB\u53D6\u7EDF\u8BA1\u5931\u8D25",hint:M});if(s===null)return e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]});let p=s.cpuPercent??0,_=s.memPercent??0,k=L=>d("div",{className:"dk_bar",children:[e("div",{className:"dk_barFill","data-warn":L>=60&&L<85?"1":void 0,"data-danger":L>=85?"1":void 0,style:{width:Math.min(100,Math.max(0,L))+"%"}})]}),y=(L,xe,De)=>d("tr",{children:[e("td",{children:L}),e("td",{className:"dk_num",children:xe}),e("td",{children:De??null})]},L);return d("table",{className:"dk_stats",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u6307\u6807"}),e("th",{children:"\u6570\u503C"}),e("th",{children:"\u5360\u7528"})]})}),e("tbody",{children:[y("CPU",Lt(s.cpuPercent),k(p)),y("\u5185\u5B58",s.memUsage,k(_)),y("\u7F51\u7EDC IO",s.netIO,null),y("\u78C1\u76D8 IO",s.blockIO,null),y("PIDs",s.pids===null?"\u2014":String(s.pids),null)]})]})},Re=[["overview","\u6982\u89C8"],["logs","\u65E5\u5FD7"],["stats","\u7EDF\u8BA1"]],fe=c==="overview"?r===null&&x==="":c==="stats"?s===null&&M==="":!1;return d("div",{className:"dk_detail",children:[d("div",{className:"dk_header dk_headerDetail",children:[e(K,{icon:Vt,title:"\u8FD4\u56DE\u5BB9\u5668\u5217\u8868",onClick:t.onBack},"back"),e("span",{className:"dk_detailTitle",title:a.name,children:a.name}),e(Ge,{state:a.state,health:a.health,status:a.status}),e("span",{className:"dk_detailSub",children:t.targetLabel??""}),e("span",{className:"dk_headerSpacer"}),c==="logs"?Be():e(K,{icon:Ne,title:"\u5237\u65B0",spin:fe,onClick:t.onRefresh},"refresh"),t.docked===!0?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:t.onClose,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ce}})},"close")]}),d("div",{className:"dk_tabs",children:[...Re.map(([p,_])=>e("button",{type:"button",className:"dk_tab","data-on":c===p?"1":"0",onClick:()=>v(p),children:_},p)),c==="logs"?e("span",{className:"dk_headerSpacer"},"spacer"):null,c==="logs"?_e():null]}),e("div",{className:"dk_detailBody",children:c==="overview"?W():c==="logs"?Me():Oe()})]})}function ut(t){let a=t.collapsed===!0;return d("div",{className:"dk_drawer","data-collapsed":a?"1":void 0,style:a||t.height===null?void 0:{height:String(t.height)+"px"},children:[e("div",{className:"dk_drawerResize",title:"\u62D6\u52A8\u8C03\u6574\u7EC8\u7AEF\u9AD8\u5EA6\uFF08\u53CC\u51FB\u6298\u53E0 / \u5C55\u5F00\uFF09",onMouseDown:t.onResizeStart,onDoubleClick:t.onToggleCollapse},"resize"),d("div",{className:"dk_drawerHead",children:[e("span",{className:"dk_drawerIcon",dangerouslySetInnerHTML:{__html:nt}}),e("span",{className:"dk_drawerTitle",title:t.label,children:t.label}),e("span",{className:"dk_drawerHint",children:a?"\u5DF2\u6298\u53E0 \xB7 \u4F1A\u8BDD\u4FDD\u6301\u8FD0\u884C":"\u7531\u7EC8\u7AEF\u9762\u677F\u627F\u8F7D \xB7 \u6298\u53E0\u4FDD\u7559\u4F1A\u8BDD"}),e("span",{className:"dk_headerSpacer"}),e("button",{type:"button",className:"dk_iconBtn dk_drawerFold",title:a?"\u5C55\u5F00\u7EC8\u7AEF\uFF08\u4F1A\u8BDD\u672A\u4E2D\u65AD\uFF09":"\u6298\u53E0\u7EC8\u7AEF\uFF08\u4F1A\u8BDD\u4FDD\u6301\u8FD0\u884C\uFF09",onClick:t.onToggleCollapse,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:at}})},"fold"),e("button",{type:"button",className:"dk_iconBtn",title:"\u7ED3\u675F\u7EC8\u7AEF\u4F1A\u8BDD\u5E76\u6536\u8D77\u62BD\u5C49",onClick:t.onClose,children:e("span",{dangerouslySetInnerHTML:{__html:Ce}})},"close")]}),e("div",{className:"dk_drawerBody",ref:t.hostRef})]})}function Ve(t){let[a,o]=g(null),[c,v]=g([]),[r,b]=g(t.initialTarget??""),x=t.sessionHint!==void 0&&(t.initialTarget??"")==="",[w,N]=g("containers"),[j,E]=g([]),[B,T]=g([]),[$,Y]=g(!1),[ee,O]=g(""),[R,S]=g(""),[F,J]=g(!0),[l,s]=g(""),[h,M]=g("all"),[q,ge]=g(!1),[X,D]=g(null),[be,he]=g(0),[A,te]=g(null),[pe,Q]=g(""),U=z(!0),[W,ne]=g(null),me=z(null),[Be,_e]=g(!1),[Me,Oe]=g(null),[Re,fe]=g(!1),p=z(null),_=z(!1);C(()=>()=>{U.current=!1},[]),C(()=>{if(W===null)return;let n=me.current;if(n===null)return;let u=null;try{u=Z.mount(n,W.options)}catch(f){S("\u7EC8\u7AEF\u542F\u52A8\u5931\u8D25\uFF1A"+(f instanceof Error?f.message:String(f))),ne(null);return}return()=>{try{u?.()}catch{}}},[W]);let k=n=>{if(n.button!==void 0&&n.button!==0)return;let u=n.currentTarget.parentElement,f=p.current;if(u===null||f===null)return;n.preventDefault();let ie=n.clientY,se=u.getBoundingClientRect().height,H=Math.max(160,Math.round(f.getBoundingClientRect().height*.75)),$e=Nt=>{let Ct=Math.round(se+(ie-Nt.clientY));Oe(Math.min(H,Math.max(160,Ct)))},qe=()=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",qe),document.body.style.userSelect=""};document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",qe)},y=()=>{if(W===null){t.onClose();return}fe(!0)};C(()=>{P.config().then(n=>{let u=n.config;o(u),!x&&Array.isArray(u.targets)&&u.targets.length>0&&b(f=>f===""?u.targets[0].name:f),ze(u)}).catch(n=>O(n.message)),P.targets().then(n=>{v(n.targets??[]),Fe=n.targets??[];let u=(n.targets??[])[0];u!==void 0&&!x&&b(f=>f===""?u.name:f)}).catch(()=>{})},[]);let L=de(()=>{r!==""&&(Y(!0),P.containers(r,F).then(n=>{U.current&&(E(n.containers??[]),O(""))}).catch(n=>{U.current&&O(n.message)}).finally(()=>{U.current&&Y(!1)}))},[r,F]),xe=de(()=>{r!==""&&(Y(!0),P.images(r).then(n=>{U.current&&(T(n.images??[]),O(""))}).catch(n=>{U.current&&O(n.message)}).finally(()=>{U.current&&Y(!1)}))},[r]),De=de(()=>he(n=>n+1),[]),le=de(()=>{w==="images"?xe():L(),he(n=>n+1)},[w,L,xe]);C(()=>{r!==""&&le()},[r,F,w]),C(()=>{if(!q||r===""||w!=="containers")return;let n=setInterval(le,Math.max(2,a?.pollIntervalSec??5)*1e3);return()=>clearInterval(n)},[q,le,r,a,w]),C(()=>{if(R==="")return;let n=setTimeout(()=>S(""),4e3);return()=>clearTimeout(n)},[R]);let we=(n,u)=>{let f=et(n.name);navigator.clipboard.writeText(f).then(()=>{S("\u5DF2\u590D\u5236\uFF1A"+f+(u===void 0?"":"\uFF08"+u+"\uFF09"))}).catch(()=>S("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C\uFF1A"+f))},_t=n=>{let u=et(n.name);if(Z===null){let H=document.querySelector("[data-dsh-tty-entry]")!==null;we(n,H?"\u7EC8\u7AEF\u9762\u677F\u7248\u672C\u8FC7\u65E7\uFF08\u4EA4\u4E92\u5F0F\u8FDB\u5165\u5BB9\u5668\u9700\u8981 dsh-tty \u2265 0.14.0\uFF09\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C":"\u672A\u5B89\u88C5 dsh-tty \u7EC8\u7AEF\u9762\u677F\uFF0C\u547D\u4EE4\u5DF2\u590D\u5236\uFF0C\u53EF\u7C98\u8D34\u5230\u7CFB\u7EDF\u7EC8\u7AEF\u6267\u884C\uFF08\u88C5 dsh-tty \u540E\u53EF\u76F4\u63A5\u5728\u6B64\u5F00\u7EC8\u7AEF\uFF09");return}let f=(a?.targets??[]).find(H=>H.name===r),ie=n.name+" \xB7 exec",se=f===void 0||f.kind==="local"?{command:u,label:ie}:typeof f.book=="string"&&f.book!==""?{book:f.book,command:u,label:ie}:(f.auth??"agent")==="agent"?{spec:{host:f.host,port:f.port,username:f.username,auth:"agent",agentForward:f.agentForward===!0},command:u,label:ie}:null;if(se===null){we(n,"\u5185\u8054\u76EE\u6807\u7528\u4E86 key/password \u8BA4\u8BC1\uFF0C\u6D4F\u89C8\u5668\u7AEF\u62FF\u4E0D\u5230\u51ED\u8BC1");return}if(t.docked===!0){try{Z.open(se)}catch(H){we(n,H instanceof Error?H.message:String(H))}return}if(typeof Z.mount=="function"&&Number(Z.version??0)>=2){ne({label:ie,options:se}),_e(!1);return}try{Z.open(se),t.onClose()}catch(H){we(n,H instanceof Error?H.message:String(H))}},xt=(n,u)=>{te({title:n==="remove"?"\u5220\u9664\u5BB9\u5668":n==="stop"?"\u505C\u6B62\u5BB9\u5668":n==="start"?"\u542F\u52A8\u5BB9\u5668":"\u91CD\u542F\u5BB9\u5668",text:n==="remove"?`\u786E\u5B9A\u5220\u9664\u5BB9\u5668 ${u.name}\uFF1F\u5BB9\u5668\u7684\u53EF\u5199\u5C42\u4E0E\u914D\u7F6E\u4F1A\u88AB\u5220\u9664\uFF08\u547D\u540D\u6570\u636E\u5377\u4FDD\u7559\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`:`\u786E\u5B9A\u5BF9\u5BB9\u5668 ${u.name} \u6267\u884C${n==="stop"?"\u505C\u6B62":n==="start"?"\u542F\u52A8":"\u91CD\u542F"}\u64CD\u4F5C\uFF1F`,confirmLabel:n==="remove"?"\u5220\u9664":"\u786E\u5B9A",run:()=>{te(null),P.action(r,n,u.id).then(f=>{S(`${f.result.action} ${u.name}\uFF1A${f.result.message}`),le()}).catch(f=>O(f.message))}})},ye=X===null?null:j.find(n=>n.id===X.id)??X.item,We=j.filter(n=>{if(h==="running"&&!(n.state==="running"||n.state==="paused"||n.state==="restarting")||h==="stopped"&&n.state==="running"||h==="unhealthy"&&n.health!=="unhealthy")return!1;let u=l.trim().toLowerCase();return u===""?!0:n.name.toLowerCase().includes(u)||n.image.toLowerCase().includes(u)||n.id.toLowerCase().includes(u)}),Ae=B.filter(n=>{let u=pe.trim().toLowerCase();return u===""||n.reference.toLowerCase().includes(u)||n.id.toLowerCase().includes(u)}),He=n=>{let u=c.find(f=>f.name===n);return u===void 0||u.label===void 0?n:n+" \xB7 "+u.label},Ye=()=>$?e("div",{className:"dk_empty",children:[e("span",{className:"dk_spin"}),e("div",{children:"\u8BFB\u53D6\u4E2D\u2026"})]}):r===""?x?d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u4E0D\u662F Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u6309\u4E0A\u9762\u7684\u63D0\u793A\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761\u76EE\u6807\uFF08\u63A8\u8350\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u3002\u4E3A\u907F\u514D\u5F20\u51A0\u674E\u6234\uFF0C\u9762\u677F\u4E0D\u4F1A\u81EA\u52A8\u5207\u5230\u5176\u4ED6\u76EE\u6807\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:"\u8FD8\u6CA1\u6709\u914D\u7F6E Docker \u76EE\u6807"}),e("div",{className:"dk_emptyHint",children:"\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u4E2A\u76EE\u6807\uFF1A\u672C\u673A\u76F4\u63A5\u9009\u300C\u672C\u673A\u300D\uFF1B\u8FDC\u7A0B\u4E3B\u673A\u53EF\u4EE5\u5F15\u7528 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\u3002"})]}):d("div",{className:"dk_empty",children:[e("div",{className:"dk_emptyTitle",children:w==="images"?"\u6CA1\u6709\u955C\u50CF":"\u6CA1\u6709\u5BB9\u5668"}),e("div",{className:"dk_emptyHint",children:l.trim()===""?"\u76EE\u6807\u4E0A\u6CA1\u6709\u5339\u914D\u7684\u6570\u636E\uFF0C\u6216\u7B5B\u9009\u6761\u4EF6\u8FC7\u7A84\u3002":"\u6CA1\u6709\u5339\u914D\u300C"+l.trim()+"\u300D\u7684\u7ED3\u679C\u3002"})]}),wt=()=>w==="images"?d("div",{className:"dk_imagesView",children:[Ae.length===0?Ye():e("div",{className:"dk_tableWrap",children:d("table",{className:"dk_images",children:[e("thead",{children:d("tr",{children:[e("th",{children:"\u955C\u50CF"}),e("th",{children:"\u5927\u5C0F"}),e("th",{children:"\u521B\u5EFA"}),e("th",{children:"ID"})]})}),e("tbody",{children:Ae.map(n=>d("tr",{children:[e("td",{className:"dk_mono",children:n.reference}),e("td",{children:n.sizeText}),e("td",{children:n.createdSince}),e("td",{className:"dk_mono",children:n.shortId})]},n.id+n.reference))})]})})]}):We.length===0?Ye():e("div",{className:"dk_grid",children:We.map(n=>e(ot,{item:n,selected:X!==null&&n.id===X.id,allowMutations:a?.allowMutations===!0,onOpen:(u,f)=>D({id:u.id,tab:f,item:u}),onExec:_t,onAction:xt,onCopyExec:u=>{navigator.clipboard.writeText("docker exec -it "+u.name+" sh").then(()=>S("\u5DF2\u590D\u5236\uFF1Adocker exec -it "+u.name+" sh")).catch(()=>S("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236"))}},n.id))}),ae=t.docked===!0,yt=[ye!==null?[e(kt,{item:ye,target:r,targetLabel:He(r),config:a??{pollIntervalSec:5,logTailDefault:200,allowExec:!1,execTimeoutSec:30},initialTab:X.tab,refreshToken:be,onBack:()=>D(null),onRefresh:De,onClose:y,docked:ae},"detail"),A===null?null:e(Te,{title:A.title,text:A.text,confirmLabel:A.confirmLabel,onCancel:()=>te(null),onConfirm:A.run},"confirm")]:[ae?null:d("div",{className:"dk_header",children:[e("span",{className:"dk_titleIcon",dangerouslySetInnerHTML:{__html:tt}}),e("span",{className:"dk_title",children:"Docker \u5BB9\u5668"}),a?.allowMutations===!0?null:e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"}),e("span",{className:"dk_headerSpacer"}),ye!==null?null:e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868","data-spin":$?"1":void 0,onClick:le,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ne}})}),e("button",{type:"button",className:"dk_iconBtn",title:"\u5173\u95ED\u9762\u677F",onClick:y,children:e("span",{dangerouslySetInnerHTML:{__html:Ce}})})]}),ye!==null?null:d("div",{className:"dk_toolbar",children:[ae?e("button",{type:"button",className:"dk_iconBtn",title:"\u5237\u65B0\u5217\u8868","data-spin":$?"1":void 0,onClick:le,children:e("span",{className:"dk_iconGlyph",dangerouslySetInnerHTML:{__html:Ne}})},"refresh"):null,ae&&a?.allowMutations!==!0?e("span",{className:"dk_badge","data-state":"paused",children:"\u53EA\u8BFB\u6A21\u5F0F"},"readonly"):null,e("select",{className:"dk_select",value:r,onChange:n=>{b(n.target.value),D(null),t.onTargetChange?.(He(n.target.value))},children:[...r===""?[e("option",{value:"",children:"\uFF08\u672A\u9009\u62E9\u76EE\u6807\uFF09"},"__none")]:[],...(c.length===0&&r!==""?[{name:r,label:void 0}]:c).map(n=>e("option",{value:n.name,children:He(n.name)},n.name))]}),e("div",{className:"dk_seg",children:[["containers","\u5BB9\u5668"],["images","\u955C\u50CF"]].map(([n,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":w===n?"1":"0",onClick:()=>{N(n),D(null)},children:u},n))}),w==="containers"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u540D\u79F0 / \u955C\u50CF / ID",value:l,onChange:n=>s(n.target.value)}):null,w==="images"?e("input",{className:"dk_input dk_search",placeholder:"\u641C\u7D22\u955C\u50CF\uFF08\u4ED3\u5E93 / \u6807\u7B7E / ID\uFF09",value:pe,onChange:n=>Q(n.target.value)}):null,w==="images"?e("span",{className:"dk_hint dk_searchCount",children:String(Ae.length)+" / "+String(B.length)+" \u4E2A\u955C\u50CF"}):null,w==="containers"?e("div",{className:"dk_seg",children:[["all","\u5168\u90E8"],["running","\u8FD0\u884C\u4E2D"],["stopped","\u5DF2\u505C\u6B62"],["unhealthy","\u4E0D\u5065\u5EB7"]].map(([n,u])=>e("button",{type:"button",className:"dk_segBtn","data-on":h===n?"1":"0",onClick:()=>M(n),children:u},n))}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:F,onChange:n=>J(n.target.checked)}),"\u542B\u5DF2\u505C\u6B62"]}):null,w==="containers"?e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:q,onChange:n=>ge(n.target.checked)}),"\u81EA\u52A8\u5237\u65B0"]}):null]}),d("div",{className:"dk_body",children:[d("div",{className:"dk_main"+(w==="images"?" dk_mainImages":""),children:[ee===""?null:e(V,{title:"\u64CD\u4F5C\u5931\u8D25",hint:ee}),R===""?null:e(V,{kind:"info",title:R}),t.sessionHint===void 0?null:e(V,{kind:"info",title:"\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u8FD8\u6CA1\u914D\u7F6E\u4E3A Docker \u76EE\u6807",hint:"\u4F1A\u8BDD\u4E3B\u673A\uFF1A"+t.sessionHint.host+(t.sessionHint.port===22?"":":"+String(t.sessionHint.port))+(t.sessionHint.book===""?"":"\uFF08\u8FDE\u63A5\u7C3F\uFF1A"+t.sessionHint.book+"\uFF09")+" \u2014 \u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6DFB\u52A0\u4E00\u6761 kind=ssh \u76EE\u6807"+(t.sessionHint.book===""?"\uFF08\u586B host/username\uFF0C\u6216\u7528\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF09":"\uFF0C\u76F4\u63A5\u9009\u8FDE\u63A5\u7C3F\u6761\u76EE\u300C"+t.sessionHint.book+"\u300D")+"\uFF0C\u4FDD\u5B58\u540E\u56DE\u5230\u8FD9\u91CC\u5237\u65B0\u5373\u53EF\u3002"}),a!==null&&a.allowMutations!==!0?e(V,{kind:"info",title:"\u5F53\u524D\u4E3A\u53EA\u8BFB\u6A21\u5F0F",hint:"\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\u9700\u8981\u5230 \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 Docker \u5BB9\u5668\u9762\u677F \u6253\u5F00\u300C\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\u300D\u3002"}):null,wt()]})]}),A===null?null:e(Te,{title:A.title,text:A.text,confirmLabel:A.confirmLabel,onCancel:()=>te(null),onConfirm:A.run})],W===null?null:e(ut,{label:W.label,hostRef:me,collapsed:Be,height:Me,onToggleCollapse:()=>_e(n=>!n),onResizeStart:k,onClose:()=>ne(null)},"execDrawer"),Re&&W!==null?e(Te,{title:"\u7ED3\u675F\u5BB9\u5668\u7EC8\u7AEF\u4F1A\u8BDD",text:"\u5173\u95ED\u9762\u677F\u4F1A\u7ED3\u675F\u300C"+W.label+"\u300D\u7684\u7EC8\u7AEF\u4F1A\u8BDD\uFF08docker exec -it \u2026\uFF09\u3002\u82E5\u53EA\u662F\u60F3\u7ED9\u65E5\u5FD7 / \u5217\u8868\u817E\u5730\u65B9\uFF0C\u5148\u70B9\u62BD\u5C49\u53F3\u4E0A\u89D2\u7684\u6298\u53E0\u6309\u94AE\u5373\u53EF\uFF0C\u4F1A\u8BDD\u4F1A\u4FDD\u6301\u8FD0\u884C\u3002",confirmLabel:"\u7ED3\u675F\u5E76\u5173\u95ED",onCancel:()=>fe(!1),onConfirm:()=>{fe(!1),t.onClose()}},"closeConfirm"):null],Je=d("div",{className:"dk_panel"+(ae?" dk_panelDock":""),"data-dock":ae?"1":void 0,ref:p,onMouseDown:n=>n.stopPropagation(),children:yt});return ae?Je:d("div",{className:"dk_backdrop",onMouseDown:n=>{_.current=n.target===n.currentTarget},onMouseUp:n=>{let u=_.current&&n.target===n.currentTarget;_.current=!1,u&&y()},children:[Je]})}function gt(){let[t,a]=g(!1),[o,c]=g(null),[v,r]=g(!1),[b,x]=g(!1),[w,N]=g({kind:"",text:""}),j=z(0),E=de(()=>{P.config().then(l=>{c(l.config),ze(l.config),j.current=Array.isArray(l.config?.targets)?l.config.targets.length:0,r(!0)}).catch(l=>{N({kind:"error",text:"\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25\uFF1A"+l.message}),r(!0)})},[]);C(()=>{t&&!v&&E()},[t,v,E]);let B=l=>c(s=>({...s,...l})),T=(l,s)=>c(h=>{let M=h.targets.slice();return M[l]={...M[l],...s},{...h,targets:M}}),$=()=>c(l=>({...l,targets:[...l.targets,{name:"\u76EE\u6807"+String(l.targets.length+1),kind:"local",book:"",host:"",port:22,username:"",auth:"agent",keyPath:"",agentForward:!1,passwordSet:!1,passphraseSet:!1}]})),Y=l=>c(s=>({...s,targets:s.targets.filter((h,M)=>M!==l)})),ee=l=>c(s=>({...s,hostKeys:s.hostKeys.filter(h=>!(h.host===l.host&&h.port===l.port))})),O=()=>{x(!0),N({kind:"",text:""});let l={enabled:o.enabled,announceToAgent:o.announceToAgent,dockerBin:o.dockerBin,allowMutations:o.allowMutations,allowExec:o.allowExec,execTimeoutSec:o.execTimeoutSec,pollIntervalSec:o.pollIntervalSec,logTailDefault:o.logTailDefault,maxOutputKb:o.maxOutputKb,targets:o.targets.map(s=>({name:s.name,kind:s.kind,book:s.book??"",host:s.host??"",port:Number(s.port)||22,username:s.username??"",auth:s.auth??"agent",keyPath:s.keyPath??"",...s.password===void 0||s.password===""?{}:{password:s.password},...s.passphrase===void 0||s.passphrase===""?{}:{passphrase:s.passphrase},agentForward:s.agentForward===!0})),hostKeys:o.hostKeys,...o.targets.length===0&&j.current>0?{clearTargets:!0}:{}};P.saveConfig(l).then(s=>{c(s.config),ze(s.config),j.current=Array.isArray(s.config?.targets)?s.config.targets.length:0,Se(),N(s.warning===void 0?{kind:"ok",text:"\u5DF2\u4FDD\u5B58\u5E76\u70ED\u751F\u6548"}:{kind:"error",text:s.warning})}).catch(s=>{N({kind:"error",text:"\u4FDD\u5B58\u5931\u8D25\uFF1A"+s.message})}).finally(()=>x(!1))},R=l=>e("div",{className:"dk_cardSection",children:l}),S=(l,s,h,M)=>d("div",{className:"dk_field","data-span":M===void 0?void 0:String(M),children:[e("span",{className:"dk_label",children:l}),s,h===void 0?null:e("span",{className:"dk_hint",children:h})]}),F=(l,s,h,M)=>e("input",{className:"dk_input",type:"number",min:s,max:h,value:o[l],onChange:q=>B({[l]:Number(q.target.value)})}),J=l=>d("li",{className:"dk_settingsCard"+(t?" dk_settingsCardOpen":""),children:[d("button",{type:"button",className:"dk_settingsHead","aria-expanded":t,onClick:()=>a(s=>!s),children:[d("span",{className:"dk_settingsHeadText",children:[e("span",{className:"dk_settingsName",children:"Docker \u5BB9\u5668\u9762\u677F"}),e("span",{className:"dk_settingsDesc",children:"\u672C\u673A / SSH \u4E3B\u673A\u4E0A\u7684\u5BB9\u5668\u4E0E\u955C\u50CF\uFF1B\u9ED8\u8BA4\u53EA\u8BFB\uFF0C\u53D8\u66F4\u64CD\u4F5C\u9700\u663E\u5F0F\u5F00\u542F"})]}),e("span",{className:"dk_settingsChevron",dangerouslySetInnerHTML:{__html:at}})]}),t?e("div",{className:"dk_settingsBody",children:l}):null]});return J(t?!v||o===null?d("div",{className:"dk_row",children:[e("span",{className:"dk_spin"}),"\u8BFB\u53D6\u914D\u7F6E\u2026"]}):[R("\u57FA\u672C"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.enabled,onChange:l=>B({enabled:l.target.checked})}),"\u542F\u7528\u63D2\u4EF6"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.announceToAgent,onChange:l=>B({announceToAgent:l.target.checked})}),"\u5411 agent \u516C\u544A\u80FD\u529B"]})]}),d("div",{className:"dk_fieldGrid",children:[S("docker CLI",e("input",{className:"dk_input",value:o.dockerBin,onChange:l=>B({dockerBin:l.target.value})}),"\u9ED8\u8BA4 docker\uFF1Bpodman \u53EF\u586B podman"),S("\u7EDF\u8BA1\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09",F("pollIntervalSec",1,60)),S("\u65E5\u5FD7\u9ED8\u8BA4\u884C\u6570",F("logTailDefault",1,5e3)),S("\u8F93\u51FA\u4E0A\u9650\uFF08KB\uFF09",F("maxOutputKb",1,8192)),S("exec \u8D85\u65F6\uFF08\u79D2\uFF09",F("execTimeoutSec",1,120))]}),R("\u80FD\u529B\u5F00\u5173\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF09"),d("div",{className:"dk_row",children:[e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.allowMutations,onChange:l=>B({allowMutations:l.target.checked})}),"\u5141\u8BB8\u53D8\u66F4\u64CD\u4F5C\uFF08\u542F\u52A8 / \u505C\u6B62 / \u91CD\u542F / \u5220\u9664\uFF09"]}),e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:o.allowExec,onChange:l=>B({allowExec:l.target.checked})}),"\u5141\u8BB8 exec\uFF08\u5728\u5BB9\u5668\u5185\u6267\u884C\u547D\u4EE4\uFF09"]})]}),e("span",{className:"dk_hint",children:"docker socket \u7B49\u4EF7\u4E8E\u76EE\u6807\u4E3B\u673A\u7684 root \u6743\u9650\u3002\u5F00\u542F\u540E\uFF0C\u6D4F\u89C8\u5668\u9762\u677F\u4E0E agent \u90FD\u80FD\u6267\u884C\u5BF9\u5E94\u64CD\u4F5C\uFF0C\u8BF7\u53EA\u5728\u53EF\u4FE1\u73AF\u5883\u4E0B\u6253\u5F00\u3002"}),R("\u76EE\u6807"),...o.targets.map((l,s)=>d("div",{className:"dk_targetRow",children:[e("input",{className:"dk_input",value:l.name,placeholder:"\u76EE\u6807\u540D",onChange:h=>T(s,{name:h.target.value})}),e("select",{className:"dk_select",value:l.kind,onChange:h=>T(s,{kind:h.target.value}),children:[e("option",{value:"local",children:"\u672C\u673A"}),e("option",{value:"ssh",children:"SSH \u4E3B\u673A"})]}),l.kind==="local"?e("span",{className:"dk_hint",children:"\u5BBF\u4E3B\u6240\u5728\u673A\u5668\u4E0A\u7684 docker"}):d("div",{className:"dk_row",style:{gridColumn:"span 1"},children:[e("select",{className:"dk_select",value:l.book??"",onChange:h=>T(s,{book:h.target.value}),children:[e("option",{value:"",children:o.ttyBooks.length===0?"\uFF08\u65E0 tty \u8FDE\u63A5\u7C3F\uFF0C\u8BF7\u586B\u5185\u8054\u4FE1\u606F\uFF09":"\uFF08\u4E0D\u7528\u8FDE\u63A5\u7C3F\uFF0C\u624B\u586B\uFF09"}),...o.ttyBooks.map(h=>e("option",{value:h,children:"\u8FDE\u63A5\u7C3F\uFF1A"+h},h))]})]}),e("button",{type:"button",className:"dk_btn dk_btnDanger",onClick:()=>Y(s),children:"\u5220\u9664"}),l.kind==="ssh"&&(l.book??"")===""?d("div",{className:"dk_targetInline",children:[e("input",{className:"dk_input",placeholder:"host",value:l.host??"",onChange:h=>T(s,{host:h.target.value})}),e("input",{className:"dk_input",placeholder:"22",title:"\u7AEF\u53E3",value:l.port??22,onChange:h=>T(s,{port:Number(h.target.value)||22})}),e("input",{className:"dk_input",placeholder:"username",value:l.username??"",onChange:h=>T(s,{username:h.target.value})}),e("select",{className:"dk_select",value:l.auth??"agent",onChange:h=>T(s,{auth:h.target.value}),children:[e("option",{value:"agent",children:"ssh-agent"}),e("option",{value:"key",children:"\u79C1\u94A5"}),e("option",{value:"password",children:"\u5BC6\u7801"})]}),(l.auth??"agent")==="key"?e("input",{className:"dk_input dk_credential",placeholder:"~/.ssh/id_ed25519",value:l.keyPath??"",onChange:h=>T(s,{keyPath:h.target.value})}):null,(l.auth??"agent")==="password"?e("input",{className:"dk_input dk_credential",type:"password",placeholder:l.passwordSet===!0?"\uFF08\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u4FDD\u6301\u4E0D\u53D8\uFF09":"env:SSH_PASSWORD",value:l.password??"",onChange:h=>T(s,{password:h.target.value})}):null,e("label",{className:"dk_check",children:[e("input",{type:"checkbox",checked:l.agentForward===!0,onChange:h=>T(s,{agentForward:h.target.checked})}),"agent forwarding"]})]}):null]},String(s)+l.name)),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn",onClick:$,children:"\u6DFB\u52A0\u76EE\u6807"}),e("span",{className:"dk_hint",children:"SSH \u76EE\u6807\u63A8\u8350\u76F4\u63A5\u9009 tty \u7EC8\u7AEF\u9762\u677F\u7684\u8FDE\u63A5\u7C3F\u6761\u76EE\uFF08\u51ED\u8BC1\u53EA\u9700\u7EF4\u62A4\u4E00\u5904\uFF09\uFF1B\u624B\u586B\u65F6\u5BC6\u7801 / \u53E3\u4EE4\u5EFA\u8BAE\u5199 env:VAR\u3002"})]}),R("SSH \u4E3B\u673A\u5BC6\u94A5\u8BB0\u5F55\uFF08TOFU\uFF09"),...o.hostKeys.length===0?[e("span",{className:"dk_hint",children:"\u6682\u65E0\u8BB0\u5F55 \u2014 \u9996\u6B21 SSH \u8FDE\u63A5\u6210\u529F\u540E\u81EA\u52A8\u8BB0\u5F55\u4E3B\u673A\u6307\u7EB9\uFF08\u82E5 tty \u5DF2\u8BB0\u5F55\u540C\u4E00\u4E3B\u673A\uFF0C\u4F1A\u76F4\u63A5\u590D\u7528\uFF09\u3002"},"none")]:o.hostKeys.map(l=>d("div",{className:"dk_targetRow",children:[e("span",{children:l.host+":"+String(l.port)}),e("span",{className:"dk_hint",style:{gridColumn:"span 2",wordBreak:"break-all"},children:"sha256:"+l.fingerprint}),e("button",{type:"button",className:"dk_btn",onClick:()=>ee(l),children:"\u5220\u9664"})]},l.host+":"+String(l.port))),e("span",{className:"dk_hint",children:"\u6307\u7EB9\u53D8\u66F4\u65F6\u8FDE\u63A5\u4F1A\u88AB\u62D2\u7EDD\uFF08\u9632\u4E2D\u95F4\u4EBA\uFF09\uFF1B\u786E\u8BA4\u5B89\u5168\u540E\u5220\u9664\u5BF9\u5E94\u8BB0\u5F55\u5373\u53EF\u91CD\u8FDE\u3002"}),d("div",{className:"dk_row",children:[e("button",{type:"button",className:"dk_btn dk_btnPrimary",disabled:b,onClick:O,children:b?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58"}),e("span",{className:"dk_msg","data-kind":w.kind,children:w.text})]})]:null)}let ue=null,oe=null,Ie=null;function ve(){let t=oe,a=ue,o=Ie;if(oe=null,ue=null,Ie=null,a!==null&&a.remove(),t!==null&&setTimeout(()=>{try{t.unmount()}catch{}},0),o!==null)try{o.dispose()}catch{}}function ht(t){return t!==null&&typeof t=="object"&&typeof t.appendChild=="function"}function pt(){return typeof re?.mountPane=="function"&&typeof re.isOpen=="function"&&Number(re.version??0)>=1&&re.isOpen()===!0}function Ke(t){ve(),Pe();let a={onClose:ve,initialTarget:t?.target??"",sessionHint:t?.sessionHint};if(pt()){let o=null;try{o=re.mountPane({title:"Docker \u5BB9\u5668",hint:t?.target===void 0||t.target===""?"":t.target,size:520,min:360,onClose:()=>ve()})}catch(c){o=null,console.warn("[dsh-docker] \u6302\u8F7D\u5230\u7EC8\u7AEF\u9762\u677F\u5931\u8D25\uFF0C\u56DE\u9000\u5F39\u7A97\uFF1A"+(c instanceof Error?c.message:String(c)))}if(o!==null&&ht(o.element)){Ie=o,oe=I(o.element),oe.render(e(Ve,{...a,docked:!0,onTargetChange:c=>{try{o.setHint(c)}catch{}}}));return}}ue=document.createElement("div"),document.body.appendChild(ue),oe=I(ue),oe.render(e(Ve,a))}function mt(){let t=document.querySelector('[data-pane="sidebar"], [class*="sidebarCol"]');if(t!==null)return t.querySelector('[class*="logoRow"]')?.parentElement??t.firstElementChild}function ft(t){let a=t.querySelector('button[class*="newSession"]');if(a!==null)return a;for(let o of t.children)if(o.tagName==="BUTTON")return o}function vt(){let t=document.createElement("div");return t.dataset.dshDockerEntry="",t.className="dk_sidebarEntry",t.setAttribute("role","button"),t.setAttribute("aria-label","\u5BB9\u5668"),t.innerHTML='<span class="dk_entryIcon">'+tt+'</span><span class="dk_entryLabel">\u5BB9\u5668</span>',t.addEventListener("click",a=>{a.preventDefault(),Ke()}),t}function Ue(t,a){let o=ft(t);if(o===void 0)return!1;if(a.parentElement!==t){let c=o.closest('[class*="logoRow"]'),v=c!==null&&c.parentElement===t?c:o,r=Array.from(t.children).filter(b=>b instanceof HTMLElement&&b.matches("[data-dsh-global-search-entry], [data-dsh-rss-entry], [data-dsh-taskboard-entry], [data-dsh-ssh-entry], [data-dsh-tty-entry], [data-dsh-docker-entry]"));if(r.length>0){let b=r[r.length-1];t.insertBefore(a,b.nextSibling)}else t.insertBefore(a,v.nextElementSibling)}return!0}function bt(){if(Pe(),document.querySelector("[data-dsh-docker-entry]")!==null)return()=>{};let t=vt(),a,o=!1,c=()=>{if(a!==void 0&&!a.isConnected&&(r.disconnect(),a=void 0,o=!1),o){if(document.body.contains(t))return;r.disconnect(),a=void 0,o=!1}a??(a=mt()),a!==void 0&&(o=Ue(a,t),o&&r.observe(a,{childList:!0,subtree:!0}))},v=new MutationObserver(()=>{c()});v.observe(document.body,{childList:!0,subtree:!0});let r=new MutationObserver(()=>{if(a===void 0||!a.isConnected){o=!1,c();return}a.contains(t)||(o=Ue(a,t))});return c(),()=>{v.disconnect(),r.disconnect(),t.remove()}}let Ee={};return Ee.inject=["slots"],Ee.apply=t=>{Pe();let a=bt(),o=t.slots.inject("settings.plugin.item",()=>t.slots.register({name:"settings.plugin.item",key:"docker",order:112},gt));t.inject(["ttyTerminal"],v=>(Z=v.ttyTerminal??null,()=>{Z=null})),t.inject(["ttyPanel"],v=>(re=v.ttyPanel??null,()=>{re=null}));let c=()=>{};return Se(),t.inject(["ttyConnbar"],v=>{let r=v.ttyConnbar;r!==void 0&&(c=r.addAction(b=>{let x=b?.spec??{};if(x.t!=="ssh")return;let w=typeof b?.bookName=="string"?b.bookName:"",N=je(x,w),j=N!==void 0?`\u6253\u5F00\u8BE5\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F\uFF08\u76EE\u6807\uFF1A${N}\uFF09`:ce===null?"\u6253\u5F00\u5F53\u524D\u4F1A\u8BDD\u4E3B\u673A\u7684 Docker \u5BB9\u5668\u9762\u677F":"\u8BE5\u4E3B\u673A\u5C1A\u672A\u914D\u7F6E\u4E3A Docker \u76EE\u6807 \u2014 \u70B9\u51FB\u6253\u5F00\u9762\u677F\u67E5\u770B/\u914D\u7F6E";b.addAction(Rt,"\u5BB9\u5668",j,()=>{(async()=>{let E=await Ot(x,w),B=Number(x.port);Ke({target:E??"",sessionHint:E===void 0?{host:typeof x.host=="string"?x.host:"",port:Number.isInteger(B)&&B>0?B:22,book:w}:void 0})})()})}),(async()=>{for(let b=0;b<3;b+=1){if(await Se()){typeof r.requestRender=="function"&&r.requestRender();return}await new Promise(x=>setTimeout(x,2e3))}})())}),()=>{c(),o(),a(),ve()}},Ee}});})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyzyn/dsh-docker",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "DSH Web GUI 的 Docker 容器面板插件:本机或 SSH 主机上的容器列表 / 启停删 / 日志 / 统计 / 镜像 / 一次性 exec,默认只读,配套只读优先的 agent 工具。",
5
5
  "keywords": [
6
6
  "dsh",