import{g as v,K as b,$ as h,aa as q,r as x,d as C,x as k,a as S,a1 as K,a2 as T,a3 as s,m as e,W as m,Z as p,u as l,Y as f,ao as _,a9 as y}from"./vue-d2584a6d.js";import{_ as A}from"./PasswordField.vue_vue_type_script_setup_true_lang-f7d196be.js";import{aS as B,aT as F,f as L,aL as U,g as I,h as M,i as N,V as O,j as R,k as $,l as j}from"./index-135ae4c1.js";import"./faker-c43f92d4.js";import"./vuetify-e547ef1b.js";const G=v({__name:"Login",setup(D){const{t:a}=b(),V=h(),o=q(),u=B(),r=x({username:"",password:""}),c=C(!1),w={username:[d=>!!d||a("login.rules.username_required")],password:[d=>!!d||a("login.rules.password_required")]},i=async()=>{c.value&&(await u.login(r.username,r.password),u.isAuthenticated?(y.success(a("login.success")),g()):y.error(a("login.error")))},g=()=>{o.query.redirect?V.push(o.query.redirect):V.push({name:"dashboard"})};return k(async()=>{o.query.username&&o.query.password&&await u.login(o.query.username,o.query.password)}),S(()=>{u.isAuthenticated&&g()}),(d,t)=>(K(),T(F,{class:"mt-16"},{default:s(()=>[e(j,{class:"mx-auto",rounded:"lg","min-width":"250"},{default:s(()=>[e(L,null,{default:s(()=>[m(p(l(a)("login.title")),1)]),_:1}),e(U,null,{default:s(()=>[m(p(l(a)("login.subtitle")),1)]),_:1}),e(I,null,{default:s(()=>[e(M,{modelValue:c.value,"onUpdate:modelValue":t[2]||(t[2]=n=>c.value=n),onSubmit:f(i,["prevent"])},{default:s(()=>[e(N,{modelValue:r.username,"onUpdate:modelValue":t[0]||(t[0]=n=>r.username=n),label:l(a)("login.username"),autofocus:"",rules:w.username,onKeydown:_(f(i,["prevent"]),["enter"]),variant:"outlined"},{prepend:s(()=>[e(O,{color:"accent",icon:"mdi-account"})]),_:1},8,["modelValue","label","rules","onKeydown"]),e(A,{modelValue:r.password,"onUpdate:modelValue":t[1]||(t[1]=n=>r.password=n),label:l(a)("login.password"),rules:w.password,"prepend-icon":"mdi-lock",onKeydown:_(f(i,["prevent"]),["enter"]),variant:"outlined"},null,8,["modelValue","label","rules","onKeydown"])]),_:1},8,["modelValue"])]),_:1}),e(R,null,{default:s(()=>[e($,{variant:"elevated",block:"",color:"accent",onClick:i},{default:s(()=>[m(p(l(a)("login.submit")),1)]),_:1})]),_:1})]),_:1})]),_:1}))}});export{G as default};
