import{_ as x}from"./gxHWKiUc.js";import h from"./CKnen0Cc.js";import w from"./D42GNhrT.js";import{d as R,m as k,p as j,j as d,q,z as l,v as A,a as B,f as t,w as i,o as S,e as m,x as T,g as f,s as $}from"./JQJBiNWj.js";import C from"./C9T7Ycgq.js";import D from"./CJYlvWEf.js";import{h as F}from"./CH1bAkoS.js";import{u as I}from"./BwwR4PPN.js";import"./Dm5UwSfy.js";import"./Dc_YXEFz.js";import"./DqVYbxj5.js";import"./Bf7HJbA6.js";import"./BgAkS4D_.js";import"./CeWG_dyW.js";import"./CDSORL4U.js";import"./B6O9xiO5.js";const U={class:"w-screen h-screen bg-cover bg-center bg-no-repeat bg-[url('/background-login.jpg')] flex flex-col items-center justify-center"},z={class:"text-center"},te=R({__name:"login",setup(E){I("Acessar");const{signIn:_}=k(),p=j(),c=d(!1),s=q(),g=d(F(l.object({username:l.string().nonempty("Digite seu usuário"),password:l.string().nonempty("Digite sua senha")})));function v(o){var a;if(!o.valid)return;c.value=!0;const r=s.currentRoute.value.query.redirect,u=Array.isArray(r)?(a=r[0])==null?void 0:a.toString():r||"/";_({username:o.values.username,password:o.values.password},{callbackUrl:u}).catch(e=>{var n;c.value=!1,console.error(e),p.add({severity:"error",life:1e4,summary:"Erro ao acessar",detail:((n=e.data)==null?void 0:n.message)||(typeof e.data=="string"?e.data:e.message||e)})})}return A(()=>{if(s.currentRoute.value.query.code==="unauthorized"){const o=s.currentRoute.value.query.redirect?"?redirect="+s.currentRoute.value.query.redirect:"";s.replace(s.currentRoute.value.path+o);return}setTimeout(()=>{p.add({severity:"info",summary:"Bem-vindo!",detail:"Digite suas credenciais para acessar.",life:3e3})},100)}),(o,r)=>{const u=D,a=x,e=C,n=$,y=w,b=h;return S(),B("div",U,[t(b,{class:"w-full max-w-[400px]"},{content:i(()=>[r[0]||(r[0]=m("div",{class:"flex justify-center mb-6"},[m("img",{src:T,alt:"Logo"})],-1)),t(y,{resolver:f(g),onSubmit:v},{default:i(()=>[t(a,{label:"Usuário:",name:"username",class:"flex flex-col mb-4"},{default:i(()=>[t(u,{id:"username"})]),_:1}),t(a,{label:"Senha:",name:"password",class:"flex flex-col mb-4"},{default:i(()=>[t(e,{id:"password",feedback:!1,"toggle-mask":""})]),_:1}),m("div",z,[t(n,{label:"Acessar",loading:f(c),type:"submit"},null,8,["loading"])])]),_:1},8,["resolver"])]),_:1})])}}});export{te as default};
