import{J as T,X as h,a5 as R,K as k,Y as U,P as B,A as b,B as a,C as N,E as S,b as e,a6 as E,a8 as O,S as t,G as m,Q as u,c as x,V as f,U as A,an as H,a4 as p,$ as I,Z as c}from"#entry";import{V as M,a as P}from"./KZF8CoAo.js";import{V as F}from"./gMmVrYwQ.js";import{V as L,a as j,b as z}from"./DlybGOWB.js";import{V as D}from"./DArAxlee.js";import{V as w}from"./tRJ_cXK7.js";import{V as C}from"./DSnRMG2T.js";import{V as G}from"./D1vV9CHW.js";import"./xGkJbl6f.js";import"./D_qxKlPu.js";import"./BML-0xFj.js";import"./CIr4U5gS.js";import"./C1aoz2cp.js";import"./LWaCnj-p.js";import"./0VvUL2KS.js";const J=["innerHTML"],de=T({__name:"login",setup(K){const{t:V}=h(),{fetch:_}=R(),g=k("settings"),{$notify:i}=U();B({title:()=>`${g.value.title} - ${V("common.login")}`});const l=H({email:"",password:""}),n=p(!1),d=p(!1),v=p();async function $(){$fetch("/api/login",{method:"POST",body:l}).then(async()=>{await _(),await I("/"),i("login.ok",c.SUCCESS)}).catch(()=>i("login.error",c.ERROR))}async function y(){if(!l.email){v.value.focus();return}d.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),c.ERROR)}d.value=!1}return(o,s)=>(S(),b(N,{class:"pa-0 pa-md-3"},{default:a(()=>[e(M,{class:"mt-md-5 ma-0",justify:"center"},{default:a(()=>[e(P,{class:"pa-0 pa-md-3",cols:"12",md:"6",lg:"5",xl:"4"},{default:a(()=>[e(F,{ref:"form",modelValue:t(n),"onUpdate:modelValue":s[2]||(s[2]=r=>O(n)?n.value=r:null),onSubmit:E($,["prevent"])},{default:a(()=>[e(L,null,{default:a(()=>[e(j,null,{default:a(()=>[m(u(o.$t("common.login")),1)]),_:1}),e(z,null,{default:a(()=>[x("span",{innerHTML:t(V)("login.description")},null,8,J)]),_:1}),e(D,null,{default:a(()=>[e(w,{ref_key:"emailInput",ref:v,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(C,null,{default:a(()=>[e(f,{variant:"text",tabindex:"1",size:"small",onClick:y},{default:a(()=>[m(u(o.$t("login.forgot_password")),1)]),_:1})]),_:1}),e(C,null,{default:a(()=>[e(G),t(g)?.allow_registration?(S(),b(f,{key:0,to:"/register",variant:"text",color:"orange"},{default:a(()=>[m(u(o.$t("login.not_registered")),1)]),_:1})):A("",!0),e(f,{color:"success",type:"submit",variant:"outlined",disabled:!t(n)||t(d),loading:t(d)},{default:a(()=>[m(u(o.$t("common.login")),1)]),_:1},8,["disabled","loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}))}});export{de as default};
