import{_ as S}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{_ as U,fc as q,m as B}from"./index-BTglIPU2.js?v=1773287522785";import{_ as V}from"./index.vue_vue_type_script_setup_true_lang-DG86e1NA.js?v=1773287522785";import{k as E,R as T,a6 as j,r as I,e as L,c as O,$ as P,a8 as z,a9 as i,a0 as o,_ as d,S as t,l as f,v as b,j as A,aa as F,N as G}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{u as H}from"./index-B5d4M70B.js?v=1773287522785";import{g as J}from"./index-wgWqrNqx.js?v=1773287522785";import{a1 as K,b as M,a6 as Q}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index-K4YGya6V.js?v=1773287522785";import"./index-COOnaZWq.js?v=1773287522785";const W={class:"w-240px"},X={class:"w-240px"},Y={class:"w-240px"},Z={class:"w-240px"},ee={class:"ml-8px"},pe=E({__name:"index",props:{data:{}},setup(v,{expose:g}){const{t:r}=T(),w=v,{status:m}=w.data,_=H(),{remoteList:p}=j(_),c=I(null),a=L({sid:p.value.length>0?p.value[0].id:null,name:"",db_user:"",password:"",active:!1,ssl:""}),h=O(()=>p.value.map(e=>({label:"".concat(e.ps," (").concat(e.db_host,")"),value:e.id}))),x={name:{required:!0,message:r("Database.form.index_15"),trigger:["blur","change"]},db_user:{required:!0,message:r("Database.form.index_16"),trigger:["blur","change"]},password:{required:!0,message:r("Database.form.index_17"),trigger:["blur","change"]},sid:{trigger:"change",validator:(e,s)=>s===null?new Error(r("Database.tools.index_64")):!0}},D=e=>{a.db_user=e},$=()=>{J()},R=()=>{const{sid:e}=a;if(e===null)throw B.error(r("Database.tools.index_64")),new Error(r("Database.tools.index_64"));return{...G(a),sid:e,ps:a.name}};return g({onConfirm:async({hide:e})=>{var s;try{await((s=c.value)==null?void 0:s.validate());const l=R();await q(_.type,l),_.setRefresh(!0),e()}catch(l){console.error(l)}}}),(e,s)=>{const l=M,u=K,k=V,y=Q,C=U,N=S;return P(),z(N,{ref_key:"formRef",ref:c,model:t(a),rules:x,class:"p-20px"},{default:i(()=>[o(u,{label:e.$t("Database.index_12"),path:"name"},{default:i(()=>[d("div",W,[o(l,{value:t(a).name,"onUpdate:value":[s[0]||(s[0]=n=>t(a).name=n),D],placeholder:e.$t("Database.form.index_2")},null,8,["value","placeholder"])])]),_:1},8,["label"]),f(o(u,{label:e.$t("Database.index_13"),path:"db_user"},{default:i(()=>[d("div",X,[o(l,{value:t(a).db_user,"onUpdate:value":s[1]||(s[1]=n=>t(a).db_user=n),placeholder:e.$t("Database.form.index_4")},null,8,["value","placeholder"])])]),_:1},8,["label"]),[[b,t(m)]]),f(o(u,{label:e.$t("Database.index_14"),path:"password"},{default:i(()=>[d("div",Y,[o(k,{value:t(a).password,"onUpdate:value":s[2]||(s[2]=n=>t(a).password=n)},null,8,["value"])])]),_:1},8,["label"]),[[b,t(m)]]),o(u,{label:e.$t("Database.form.index_9"),path:"sid"},{default:i(()=>[d("div",Z,[o(y,{value:t(a).sid,"onUpdate:value":s[3]||(s[3]=n=>t(a).sid=n),options:t(h)},null,8,["value","options"])]),d("div",ee,[o(C,{onClick:$},{default:i(()=>[A(F(e.$t("Database.form.index_10")),1)]),_:1})])]),_:1},8,["label"])]),_:1},8,["model"])}}});export{pe as default};
