import{f as g,X as w,$ as _,H as y,w as b,K as h,L as C,O as t,n as e,R as c,P as m,u as n,x,T as S,r as q,a0 as V}from"./vue-BCrBmJiU.js";import{A as v,_ as A}from"./PasswordField.vue_vue_type_script_setup_true_lang-CVgh9Mvf.js";import{d as k,U as B,V as T,h as U,W as $,i as N,o as R,q as E}from"./index-pUGkA0BX.js";import{V as F}from"./VContainer-qzE8HIh9.js";import"./vuetify-CVZPtJFd.js";const I=g({__name:"Login",setup(L){const{t:a}=k(),p=w(),o=_(),l=B(),r=q({username:"",password:""});async function i(){const u=await l.login(r.username,r.password);if(l.isAuthenticated)V.success(a("login.success")),f();else{let s=a("login.error");s+=`
Error code: ${u.status} (${u.data})`,V.error(s)}}function f(){o.query.redirect?p.push(o.query.redirect):p.push({name:"dashboard"})}return y(async()=>{o.query.username&&o.query.password&&await l.login(o.query.username,o.query.password)}),b(()=>{l.isAuthenticated&&f()}),(u,s)=>(h(),C(F,{class:"fill-height d-flex align-center justify-center"},{default:t(()=>[e(T,{class:"mx-auto",rounded:"lg","min-width":"250"},{default:t(()=>[e(U,null,{default:t(()=>[c(m(n(a)("login.title")),1)]),_:1}),e($,null,{default:t(()=>[c(m(n(a)("login.subtitle")),1)]),_:1}),e(N,null,{default:t(()=>[x("form",{onSubmit:S(i,["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:i},null,8,["modelValue","title"]),e(A,{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:i},null,8,["modelValue","title"])],32)]),_:1}),e(R,null,{default:t(()=>[e(E,{variant:"elevated",block:"",color:"accent",onClick:i},{default:t(()=>[c(m(n(a)("login.submit")),1)]),_:1})]),_:1})]),_:1})]),_:1}))}});export{I as default};
