import{_ as x}from"./BqnRxGiA.js";import h from"./CPbAwy4t.js";import w from"./iZ-xiGRB.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 c,o as S,e as m,x as T,g as f,s as $}from"./dVzHJMF1.js";import C from"./UP-7C8ii.js";import D from"./B7Hqpkvs.js";import{h as F}from"./CH1bAkoS.js";import{u as I}from"./DhLu8RVk.js";import"./cMkL48JQ.js";import"./BSLzRQpY.js";import"./Bhud8mbC.js";import"./awxGv8xl.js";import"./B79Hoqpc.js";import"./DiwqsPB4.js";import"./KcBrPYTF.js";import"./CWHHmK0V.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(),i=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;i.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;i.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:c(()=>[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:c(()=>[t(a,{label:"Usuário:",name:"username",class:"flex flex-col mb-4"},{default:c(()=>[t(u)]),_:1}),t(a,{label:"Senha:",name:"password",class:"flex flex-col mb-4"},{default:c(()=>[t(e,{feedback:!1,"toggle-mask":""})]),_:1}),m("div",z,[t(n,{label:"Acessar",loading:f(i),type:"submit"},null,8,["loading"])])]),_:1},8,["resolver"])]),_:1})])}}});export{te as default};
