import{aa as T,cm as h,cL as R,cG as k,ct as B,cl as N,X as v,cS as a,p as O,bB as S,a3 as e,cV as U,aV as M,c7 as t,a2 as d,c0 as u,W as x,V as p,Y as E,bM as H,bO as c,bj as I,l as f}from"#entry";import{a as L,V as j}from"./CSNDbwpJ.js";import{V as A}from"./D-zBkYGg.js";import{V as F,b as P,a as z}from"./RTCSF0Ks.js";import{V as D}from"./R1_j74h_.js";import{V as w}from"./C2L9cD_h.js";import{V as _}from"./BgQ5eU58.js";import{V as G}from"./VoZA954X.js";import"./BbcaTmac.js";import"./D_qxKlPu.js";import"./BKDgfSxC.js";import"./Cp3UUybv.js";import"./DmHQoNBb.js";import"./CEoxYnb5.js";import"./BPHK4Dzs.js";const W=["innerHTML"],me=T({__name:"login",setup(X){const{t:V}=h(),{fetch:y}=R(),g=k("settings"),{$notify:i}=B();N({title:()=>`${g.value.title} - ${V("common.login")}`});const l=H({email:"",password:""}),n=c(!1),m=c(!1),b=c();async function C(){$fetch("/api/login",{method:"POST",body:l}).then(async()=>{await y(),await I("/"),i("login.ok",f.SUCCESS)}).catch(()=>i("login.error",f.ERROR))}async function $(){if(!l.email){b.value.focus();return}m.value=!0;try{await $fetch("/api/user/recover",{method:"POST",body:{email:l.email}}),i("login.check_email")}catch(o){console.error(o),i(String(o),f.ERROR)}m.value=!1}return(o,s)=>(S(),v(O,{class:"pa-0 pa-md-3"},{default:a(()=>[e(L,{class:"mt-md-5 ma-0",justify:"center"},{default:a(()=>[e(j,{class:"pa-0 pa-md-3",cols:"12",md:"6",lg:"5",xl:"4"},{default:a(()=>[e(A,{ref:"form",modelValue:t(n),"onUpdate:modelValue":s[2]||(s[2]=r=>M(n)?n.value=r:null),onSubmit:U(C,["prevent"])},{default:a(()=>[e(F,null,{default:a(()=>[e(P,null,{default:a(()=>[d(u(o.$t("common.login")),1)]),_:1}),e(z,null,{default:a(()=>[x("span",{innerHTML:t(V)("login.description")},null,8,W)]),_:1}),e(D,null,{default:a(()=>[e(w,{ref_key:"emailInput",ref:b,modelValue:t(l).email,"onUpdate:modelValue":s[0]||(s[0]=r=>t(l).email=r),"validate-on":"blur",rules:o.$valid.email,autofocus:"",label:o.$t("common.email")},null,8,["modelValue","rules","label"]),e(w,{modelValue:t(l).password,"onUpdate:modelValue":s[1]||(s[1]=r=>t(l).password=r),rules:[o.$valid.password],type:"password",label:o.$t("common.password")},null,8,["modelValue","rules","label"])]),_:1}),e(_,null,{default:a(()=>[e(p,{variant:"text",tabindex:"1",size:"small",onClick:$},{default:a(()=>[d(u(o.$t("login.forgot_password")),1)]),_:1})]),_:1}),e(_,null,{default:a(()=>[e(G),t(g)?.allow_registration?(S(),v(p,{key:0,to:"/register",variant:"text",color:"orange"},{default:a(()=>[d(u(o.$t("login.not_registered")),1)]),_:1})):E("",!0),e(p,{color:"success",type:"submit",variant:"outlined",disabled:!t(n)||t(m),loading:t(m)},{default:a(()=>[d(u(o.$t("common.login")),1)]),_:1},8,["disabled","loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}))}});export{me as default};
