import{f as w,X as g,$ as _,r as y,H as b,w as C,K as h,L as S,O as t,n as e,R as c,P as m,u as n,y as q,T as A,a0 as V}from"./vue-CbNcDebW.js";import{A as v,_ as x}from"./PasswordField.vue_vue_type_script_setup_true_lang-BIjG79hr.js";import{n as k,$,V as B,q as T,a0 as N,r as R,y as U,A as E}from"./index-Ct76C36l.js";import{V as F}from"./VContainer-BIS2pIyk.js";import"./vuetify-CnSZir_0.js";const K=w({__name:"Login",setup(L){const{t:a}=k(),p=g(),o=_(),u=$(),r=y({username:"",password:""});async function l(){const i=await u.login(r.username,r.password);if(u.isAuthenticated)V.success(a("login.success")),f();else{let s=a("login.error");i.status!==200&&(s+=`
Error code: ${i.status} (${i.data})`),V.error(s)}}function f(){o.query.redirect?p.push(o.query.redirect):p.push({name:"dashboard"})}return b(async()=>{o.query.username&&o.query.password&&await u.login(o.query.username,o.query.password)}),C(()=>{u.isAuthenticated&&f()}),(i,s)=>(S(),h(F,{class:"fill-height"},{default:t(()=>[e(B,{class:"mx-auto",rounded:"lg","min-width":"250"},{default:t(()=>[e(T,null,{default:t(()=>[c(m(n(a)("login.title")),1)]),_:1}),e(N,null,{default:t(()=>[c(m(n(a)("login.subtitle")),1)]),_:1}),e(R,null,{default:t(()=>[q("form",{onSubmit:A(l,["prevent"])},[e(v,{id:"username",modelValue:r.username,"onUpdate:modelValue":s[0]||(s[0]=d=>r.username=d),title:n(a)("login.username"),autocomplete:"username",autofocus:"",name:"username","prepend-icon":"mdi-account",onSubmit:l},null,8,["modelValue","title"]),e(x,{id:"password",modelValue:r.password,"onUpdate:modelValue":s[1]||(s[1]=d=>r.password=d),title:n(a)("login.password"),autocomplete:"current-password",name:"password","prepend-icon":"mdi-lock",onSubmit:l},null,8,["modelValue","title"])],32)]),_:1}),e(U,null,{default:t(()=>[e(E,{variant:"elevated",block:"",color:"accent",onClick:l},{default:t(()=>[c(m(n(a)("login.submit")),1)]),_:1})]),_:1})]),_:1})]),_:1}))}});export{K as default};
