import{f as w,X as g,$ as _,H as b,w as h,K as y,L as C,O as t,n as e,R as c,P as m,u as n,x as S,T as x,r as k,a0 as V}from"./vue-CPEHuaRL.js";import{A as q,_ as v}from"./PasswordField.vue_vue_type_script_setup_true_lang-wEN9-jco.js";import{h as A,W as B,V as T,k as $,X as N,l as R,r as U,t as E}from"./index-vmUNdjsE.js";import{V as F}from"./VContainer-cHiGxTgO.js";import"./vuetify-DlufGdsb.js";const I=w({__name:"Login",setup(L){const{t:a}=A(),p=g(),o=_(),l=B(),r=k({username:"",password:""});async function u(){const i=await l.login(r.username,r.password);if(l.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 l.login(o.query.username,o.query.password)}),h(()=>{l.isAuthenticated&&f()}),(i,s)=>(y(),C(F,{class:"fill-height"},{default:t(()=>[e(T,{class:"mx-auto",rounded:"lg","min-width":"250"},{default:t(()=>[e($,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(()=>[S("form",{onSubmit:x(u,["prevent"])},[e(q,{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:u},null,8,["modelValue","title"]),e(v,{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:u},null,8,["modelValue","title"])],32)]),_:1}),e(U,null,{default:t(()=>[e(E,{variant:"elevated",block:"",color:"accent",onClick:u},{default:t(()=>[c(m(n(a)("login.submit")),1)]),_:1})]),_:1})]),_:1})]),_:1}))}});export{I as default};
