import{l as e,K as s,aM as t,t as a,aX as l,v as r,L as i}from"./utils-lib.js?v=20260328163632";import{a as o,f as p,r as u,c as n,B as c,s as d}from"./index190.js?v=20260328163632";import{k as h,r as v,c as y,O as m,j as b,o as _,V as k,W as f,Y as j,a3 as w,N as x}from"./base-lib.js?v=20260328163632";import"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";import"./index91.js?v=20260328163632";import"./index92.js?v=20260328163632";import"./index50.js?v=20260328163632";import"./index97.js?v=20260328163632";import"./wsl.js?v=20260328163632";const g={class:"p-20px"},O=h({__name:"add-docker",setup(h,{expose:O}){const S=v(!1),N=v(!1),E=[{content:e("添加SSH信息后支持命令行创建和docker-composer")}],K=v({formAttrs:{labelWidth:"auto"},formItems:[]}),H=v({label:e("主机名"),attrs:o,ruleKey:"host",rules:[s({message:e("请输入主机名"),trigger:["blur","input"]})],children:[{key:"host",type:"input",attrs:{class:"!w-[380px]",placeholder:e("请输入主机名，如：192.168.1.1")}}]}),V=v({label:e("别名"),attrs:o,ruleKey:"title",rules:[s({message:e("请输入别名"),trigger:["blur","input"]})],children:[{key:"title",type:"input",attrs:{class:"!w-[380px]",placeholder:e("请输入别名")}}]}),C=v({label:"Docker"+e("端口"),attrs:o,ruleKey:"port",rules:[{validator:(s,a,l)=>!(""!==a&&!t(a))||new Error(e("请填写正确的端口(1-65535之间的数字)")),trigger:["blur","input"]}],children:[{key:"port",type:"input",attrs:{class:"!w-[380px]",placeholder:e("请输入Docker端口，默认为2375")}}]}),D=v({label:"TLS验证",attrs:o,children:[{key:"tls",type:"switch",style:"min-width: 70px;",attrs:{"onUpdate:value":e=>{S.value=e}}}]}),J=v({label:e("密钥(KEY)"),attrs:o,children:[{key:"key",type:"input",attrs:{type:"textarea",class:"!w-[380px]"}}]}),A=v({label:e("证书(PEM格式)"),attrs:o,children:[{key:"cert",type:"input",attrs:{type:"textarea",class:"!w-[380px]"}}]}),I=v({label:e("CA证书"),attrs:o,children:[{key:"ca",type:"input",attrs:{type:"textarea",class:"!w-[380px]"}}]}),L=y((()=>({label:e("SSH信息"),attrs:o,children:[{type:"custom",key:"ssh-info",render:()=>m("a",{href:"javascript:;",class:"bt-link",onClick:()=>N.value=!0},[e("点击配置"),b(" >>")])}]}))),M=y((()=>(K.value.formItems=[V.value,H.value,C.value,D.value,...S.value?[J.value,A.value,I.value]:[],L.value],K.value))),[U,W,Y]=a(M);return _((()=>{if(p.value.type="password",u.value){const{host:e,port:s,title:t,id:a,sftp:r,tls:{ca:i,cert:o,key:n,tls:c}}=u.value,d=l(r)?JSON.parse(r):r||{};Object.assign(W.value,{host:e,port:s,title:t,tls:c,ca:i,cert:o,key:n,id:a}),Object.assign(p.value,{ssh_port:d.port,ssh_username:d.username,ssh_password:d.password,ssh_pkey:d.pkey,ssh_pkey_passwd:d.pkey_passwd}),c&&(S.value=!0),p.value.type=d.pkey?"private":"password"}else Object.assign(W.value,{port:"2375"}),Object.assign(p.value,{ssh_port:"22",ssh_username:"root"});n.value=p.value.type})),O({onConfirm:async()=>{var s;try{await(null==(s=Y.value)?void 0:s.validate());let t={tls:{},ssh_info:{}};Object.entries(W.value).forEach((([e,s])=>{e.includes("ssh_")?t.ssh_info[e.replace("ssh_","")]=e.includes("port")?Number(s):s:["tls","ca","cert","key"].includes(e)?t.tls[e]=s:(t[e]="port"===e?Number(s):s,"host"===e&&(t.ssh_info.host=s))})),Object.entries(p.value).forEach((([e,s])=>{e.includes("ssh_")&&(t.ssh_info[e.replace("ssh_","")]=e.includes("port")?Number(s):s)})),t.tls=JSON.stringify(t.tls),t.ssh_info=JSON.stringify(t.ssh_info);return(await d(t,e("正在{0}远程Docker...",[u.value?e("编辑"):e("添加")]))).status}catch(t){}}}),(s,t)=>(k(),f("div",g,[m(j(U)),m(j(r),{options:E}),m(j(i),{title:j(e)("配置SSH信息"),modelValue:j(N),"onUpdate:modelValue":t[0]||(t[0]=e=>x(N)?N.value=e:null),showFooter:"",area:640},{default:w((()=>[m(j(c),{class:"p-20px"})])),_:1},8,["title","modelValue"])]))}});export{O as default};
