import{_ as a}from"./public.js?v=1753954525509";import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1753954525509";import{k as s,P as t,$ as o,r as l,e as r,U as d,V as p,Q as n,a2 as u,W as _,X as b,a1 as i,al as c,a3 as m,N as v}from"./vue.js?v=1753954525509";import{b1 as h,eN as x,cZ as w,eO as f,eP as g}from"./page_layout.js?v=1753954525509";import{v as D}from"./index255.js?v=1753954525509";import{aq as $,cA as y,c1 as q}from"./naive.js?v=1753954525509";const j={class:"p-20px"},k={class:"w-260px"},U={class:"w-260px"},E={class:"w-260px"},N={class:"w-260px"},C={class:"w-260px"},P={key:0},R=s({__name:"form",props:{data:{}},setup(s,{expose:R}){const{t:A}=t(),M=s,{row:O,isEdit:Q}=M.data,V=h(),{type:W}=o(V),X=l(null),Z=r({db_host:"",db_port:null,db_user:"root",db_password:"",db_ps:""}),z={db_host:{trigger:["blur","change"],validator:(a,e)=>""===e?new Error(A("Database.tools.index_53")):!(!x(e)&&!w(e))||new Error(A("Database.tools.index_54"))},db_port:D(),db_user:{required:!0,message:A("Database.tools.index_55"),trigger:["blur","change"]},db_password:{required:!0,message:A("Database.tools.index_56"),trigger:["blur","change"]}},B=a=>{Z.db_ps=a},F=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(Q&&O)Z.db_host="".concat(O.db_host),Z.db_port=O.db_port,Z.db_user="".concat(O.db_user),Z.db_password="".concat(O.db_password),Z.db_ps="".concat(O.ps);else{const a=F.get(W.value);a&&(Z.db_port=a.port,Z.db_user=a.username)}})(),R({onConfirm:async({hide:a})=>{var e;await(null==(e=X.value)?void 0:e.validate());const s=(()=>{const{db_port:a}=Z;if(null===a)throw new Error(A("Database.tools.index_57"));return{...v(Z),db_port:a,type:W.value}})();Q&&O&&await f(W.value,{id:O.id,...s}),Q||await g(W.value,s),V.getRemote(),a()}}),(s,t)=>{const o=$,l=y,r=q,v=e,h=a;return d(),p("div",j,[n(v,{ref_key:"formRef",ref:X,model:b(Z),rules:z},{default:u((()=>[n(l,{label:s.$t("Database.tools.index_42"),path:"db_host"},{default:u((()=>[_("div",k,[n(o,{value:b(Z).db_host,"onUpdate:value":[t[0]||(t[0]=a=>b(Z).db_host=a),B],placeholder:s.$t("Database.tools.index_43"),"input-props":{name:"host"}},null,8,["value","placeholder"])])])),_:1},8,["label"]),n(l,{label:s.$t("Docker.Container.create.index_7"),path:"db_port"},{default:u((()=>[_("div",U,[n(r,{value:b(Z).db_port,"onUpdate:value":t[1]||(t[1]=a=>b(Z).db_port=a),min:1,max:65535,"show-button":!1,"input-props":{name:"port"},placeholder:s.$t("Database.tools.index_44")},null,8,["value","placeholder"])])])),_:1},8,["label"]),"redis"!==b(W)?(d(),i(l,{key:0,label:s.$t("Database.index_13"),path:"db_user"},{default:u((()=>[_("div",E,[n(o,{value:b(Z).db_user,"onUpdate:value":t[2]||(t[2]=a=>b(Z).db_user=a),placeholder:s.$t("Database.tools.index_45"),"input-props":{name:"username"}},null,8,["value","placeholder"])])])),_:1},8,["label"])):c("",!0),n(l,{label:s.$t("Database.index_14"),path:"db_password"},{default:u((()=>[_("div",N,[n(o,{value:b(Z).db_password,"onUpdate:value":t[3]||(t[3]=a=>b(Z).db_password=a),placeholder:s.$t("Database.tools.index_46"),"input-props":{name:"password"}},null,8,["value","placeholder"])])])),_:1},8,["label"]),n(l,{label:"Notes",path:"db_ps","show-feedback":!1},{default:u((()=>[_("div",C,[n(o,{value:b(Z).db_ps,"onUpdate:value":t[4]||(t[4]=a=>b(Z).db_ps=a),placeholder:s.$t("Database.tools.index_48"),"input-props":{name:"ps"}},null,8,["value","placeholder"])])])),_:1})])),_:1},8,["model"]),n(h,{class:"mt-24px"},{default:u((()=>["mysql"===b(W)?(d(),p("li",P,m(s.$t("Database.tools.index_49")),1)):c("",!0),_("li",null,m(s.$t("Database.tools.index_50")),1),_("li",null,m(s.$t("Database.tools.index_51")),1),_("li",null,m(s.$t("Database.tools.index_52")),1)])),_:1})])}}});export{R as _};
