import{B as P,aE as x,a8 as G,a as w,w as S,I as d,X as B,C as m,D as b,H as i,u as a,P as c,_ as y,G as n,U as u,O as A,V as f,a7 as E,aF as N}from"./vue-DweYBrEc.js";import{x as T,u as q,y as K,_ as j}from"./index-fNs72j9w.js";import{u as H,b as O,c as X}from"./index-CLJRKiC0.js";import{c as J}from"./index-CYWPsgm-.js";import{F as C}from"./index-BlEwok4a.js";import{b as v}from"./validate-CEOscgyN.js";const Q={key:0,class:"userinfo"},W={class:"user-avatar-box"},Y=["src"],Z={class:"username"},ee={class:"user-info"},ae={class:"userinfo-buttons"},oe={href:"https://uni.buildadmin.com/user",target:"_blank",rel:"noopener noreferrer"},te={key:1,class:"ba-login"},se={class:"ba-title"},ne={target:"_blank",class:"ba-account-register",href:"https://uni.buildadmin.com/user/login?type=register",rel:"noopener noreferrer"},le=P({__name:"baAccount",props:N({loginCallback:{type:Function,default:()=>{}}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(h){const{t:l}=T.useI18n(),t=H(),F=q(),g=x(h,"modelValue"),k=G("baAccountFormRef"),L=h,o=w({loading:!0,submitLoading:!1,user:{tab:"login",username:"",password:"",captchaId:K(),captchaInfo:"",keep:!1}}),I=()=>{var s;(s=k.value)==null||s.validate(e=>{e&&J(o.user.captchaId,_=>U(_),{apiBaseURL:F.apiUrl})})},U=(s="")=>{o.submitLoading=!0,o.user.captchaInfo=s,O(o.user).then(e=>{t.dataFill(e.data.userInfo,!1),L.loginCallback(e)}).finally(()=>{o.submitLoading=!1})},z=w({username:[v({name:"required",title:l("layouts.Username")})],password:[v({name:"required",title:l("layouts.Password")}),v({name:"password"})]});return S(()=>g.value,s=>{s&&t.token&&X().then(e=>{t.dataFill(e.data.userInfo)}).catch(()=>{t.removeToken()}).finally(()=>{o.loading=!1})}),(s,e)=>{const _=d("Icon"),p=d("el-button"),R=d("el-form-item"),$=d("el-form"),D=d("el-dialog"),V=B("blur"),M=B("loading");return m(),b("div",null,[i(D,{modelValue:g.value,"onUpdate:modelValue":e[5]||(e[5]=r=>g.value=r),class:"ba-account-dialog",width:"25%",title:a(l)("layouts.Member information")},{default:c(()=>[a(t).token?y((m(),b("div",Q,[n("div",W,[n("img",{class:"user-avatar",src:a(t).avatar,alt:""},null,8,Y),i(_,{class:"user-avatar-gender",name:a(t).getGenderIcon().name,size:"14",color:a(t).getGenderIcon().color},null,8,["name","color"])]),n("p",Z,u(a(t).nickname),1),n("p",ee,[n("span",null,u(s.$t("Integral")+" "+a(t).score),1),n("span",null,u(s.$t("Balance")+" "+a(t).money),1)]),n("div",ae,[n("a",oe,[y((m(),A(p,{size:"default",type:"primary"},{default:c(()=>[f(u(s.$t("layouts.Member center")),1)]),_:1})),[[V]])]),y((m(),A(p,{onClick:e[0]||(e[0]=r=>a(t).logout()),size:"default",type:"warning"},{default:c(()=>[f(u(s.$t("layouts.Logout")),1)]),_:1})),[[V]])])])),[[M,o.loading]]):(m(),b("div",te,[n("h3",se,u(a(l)("layouts.Login to the buildadmin")),1),i($,{onKeyup:e[4]||(e[4]=E(r=>I(),["enter"])),ref_key:"baAccountFormRef",ref:k,rules:z,class:"ba-account-login-form",model:o.user},{default:c(()=>[i(C,{modelValue:o.user.username,"onUpdate:modelValue":e[1]||(e[1]=r=>o.user.username=r),type:"string",prop:"username",placeholder:a(l)("layouts.Please enter buildadmin account name or email"),"input-attr":{size:"large"}},null,8,["modelValue","placeholder"]),i(C,{modelValue:o.user.password,"onUpdate:modelValue":e[2]||(e[2]=r=>o.user.password=r),type:"password",prop:"password",placeholder:a(l)("layouts.Please enter the buildadmin account password"),"input-attr":{size:"large"}},null,8,["modelValue","placeholder"]),i(R,{class:"form-buttons"},{default:c(()=>[i(p,{onClick:e[3]||(e[3]=r=>I()),loading:o.submitLoading,round:"",type:"primary",size:"large"},{default:c(()=>[f(u(a(l)("layouts.Login")),1)]),_:1},8,["loading"]),n("a",ne,[i(p,{round:"",plain:"",type:"info",size:"large"},{default:c(()=>[f(u(a(l)("layouts.Register")),1)]),_:1})])]),_:1})]),_:1},8,["rules","model"])]))]),_:1},8,["modelValue","title"])])}}}),pe=j(le,[["__scopeId","data-v-3d2b2a16"]]);export{pe as B};
