import{_ as N}from"./index-DIKmrNCq.js?v=1773287522785";import{_ as B}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{k as I,R as S,a6 as V,r as F,e as M,$ as c,Z as v,a0 as s,a9 as p,_ as l,S as t,a8 as P,ak as w,aa as b,N as H}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{go as T,gp as Z}from"./index-BTglIPU2.js?v=1773287522785";import{e as j,d as z}from"./check-CNel7fTH.js?v=1773287522785";import{u as A}from"./index-B5d4M70B.js?v=1773287522785";import{v as G}from"./index-DhnhmU-6.js?v=1773287522785";import{a1 as J,b as K,_ as L}from"./naive-ui--dJnpVcV.js?v=1773287522785";const O={class:"p-20px"},Q={class:"w-260px"},W={class:"w-260px"},X={class:"w-260px"},Y={class:"w-260px"},ee={class:"w-260px"},oe={key:0},ie=I({__name:"form",props:{data:{}},setup(g,{expose:D}){const{t:i}=S(),$=g,{row:n,isEdit:m}=$.data,f=A(),{type:_}=V(f),h=F(null),o=M({db_host:"",db_port:null,db_user:"root",db_password:"",db_ps:""}),x={db_host:{trigger:["blur","change"],validator:(e,a)=>a===""?new Error(i("Database.tools.index_53")):!j(a)&&!z(a)?new Error(i("Database.tools.index_54")):!0},db_port:G(),db_user:{required:!0,message:i("Database.tools.index_55"),trigger:["blur","change"]},db_password:{required:!0,message:i("Database.tools.index_56"),trigger:["blur","change"]}},k=e=>{o.db_ps=e},y=()=>{const{db_port:e}=o;if(e===null)throw new Error(i("Database.tools.index_57"));return{...H(o),db_port:e,type:_.value}},R=async({hide:e})=>{var d;await((d=h.value)==null?void 0:d.validate());const a=y();m&&n&&await T(_.value,{id:n.id,...a}),m||await Z(_.value,a),f.getRemote(),e()},q=new Map([["mysql",{port:3306,username:"root"}],["sqlserver",{port:1433,username:"sa"}],["redis",{port:6379,username:"root"}],["mongodb",{port:27017,username:"root"}],["pgsql",{port:5432,username:"postgres"}]]);return(()=>{if(m&&n)o.db_host="".concat(n.db_host),o.db_port=n.db_port,o.db_user="".concat(n.db_user),o.db_password="".concat(n.db_password),o.db_ps="".concat(n.ps);else{const e=q.get(_.value);e&&(o.db_port=e.port,o.db_user=e.username)}})(),D({onConfirm:R}),(e,a)=>{const d=K,u=J,U=L,C=B,E=N;return c(),v("div",O,[s(C,{ref_key:"formRef",ref:h,model:t(o),rules:x},{default:p(()=>[s(u,{label:e.$t("Database.tools.index_42"),path:"db_host"},{default:p(()=>[l("div",Q,[s(d,{value:t(o).db_host,"onUpdate:value":[a[0]||(a[0]=r=>t(o).db_host=r),k],placeholder:e.$t("Database.tools.index_43"),"input-props":{name:"host"}},null,8,["value","placeholder"])])]),_:1},8,["label"]),s(u,{label:e.$t("Docker.Container.create.index_7"),path:"db_port"},{default:p(()=>[l("div",W,[s(U,{value:t(o).db_port,"onUpdate:value":a[1]||(a[1]=r=>t(o).db_port=r),min:1,max:65535,"show-button":!1,"input-props":{name:"port"},placeholder:e.$t("Database.tools.index_44")},null,8,["value","placeholder"])])]),_:1},8,["label"]),t(_)!=="redis"?(c(),P(u,{key:0,label:e.$t("Database.index_13"),path:"db_user"},{default:p(()=>[l("div",X,[s(d,{value:t(o).db_user,"onUpdate:value":a[2]||(a[2]=r=>t(o).db_user=r),placeholder:e.$t("Database.tools.index_45"),"input-props":{name:"username"}},null,8,["value","placeholder"])])]),_:1},8,["label"])):w("",!0),s(u,{label:e.$t("Database.index_14"),path:"db_password"},{default:p(()=>[l("div",Y,[s(d,{value:t(o).db_password,"onUpdate:value":a[3]||(a[3]=r=>t(o).db_password=r),placeholder:e.$t("Database.tools.index_46"),"input-props":{name:"password"}},null,8,["value","placeholder"])])]),_:1},8,["label"]),s(u,{label:"Notes",path:"db_ps","show-feedback":!1},{default:p(()=>[l("div",ee,[s(d,{value:t(o).db_ps,"onUpdate:value":a[4]||(a[4]=r=>t(o).db_ps=r),placeholder:e.$t("Database.tools.index_48"),"input-props":{name:"ps"}},null,8,["value","placeholder"])])]),_:1})]),_:1},8,["model"]),s(E,{class:"mt-24px"},{default:p(()=>[t(_)==="mysql"?(c(),v("li",oe,b(e.$t("Database.tools.index_49")),1)):w("",!0),l("li",null,b(e.$t("Database.tools.index_50")),1),l("li",null,b(e.$t("Database.tools.index_51")),1),l("li",null,b(e.$t("Database.tools.index_52")),1)]),_:1})])}}});export{ie as _};
