import{u as f,r as i,aN as m,e as u,j as t,N as p,B as r,l as c,a_ as g}from"./index-91e9700c.js";import{D as x}from"./Divider-d0fc16ba.js";import{b as C,p as y}from"./env-198ff0f3.js";import{C as E}from"./Container-3bb74340.js";import{T as n}from"./Typography-05ee1d2d.js";import{C as F}from"./CssVarsProvider-76410691.js";import"./createContainer-1f2487c8.js";import"./useThemeProps-1bc4d723.js";import"./useSlot-6d750ee3.js";import"./ThemeProvider-ef8f8c5f.js";const P=()=>{const{authFederal:s,unAuthenticateFederal:l,authenticateFederal:d}=f(),[v,h]=i.useState(!1),{code:a}=m();return console.log("codigo-> ",a),console.log("authFederal-> ",s),i.useEffect(()=>{console.log("useEffect triggered with code:",a),(async()=>{if(!a){console.error("No code provided in URL parameters");return}try{g.post(`${C}/${y}/rest/federal/access-code/login-with-access-code`,{accessCode:a},{withCredentials:!0}).then(e=>{e.data.success?(d(e.data),console.log("Authentication successful:",e.data)):(l(),console.error("Authentication failed:",e.data))}).catch(e=>{console.error("Error fetching data:",e)})}catch(e){console.error("Error fetching data:",e)}})()},[]),i.useEffect(()=>{let o=!1;var e=document.cookie.match(new RegExp("(^| )JSESSIONID=([^;]+)"));e&&(o=!0),o!==!1&&h(!0)},[]),u({typography:{fontFamily:["Poppins","sans-serif"].join(",")}}),s?t(p,{to:"/federal-home"}):t(F,{children:t(r,{sx:{backgroundColor:"#F4F5FA",height:"100dvh"},children:t(E,{maxWidth:"xl",children:t(r,{sx:{},children:c(r,{sx:{paddingTop:"1em"},children:[t(x,{}),c(r,{sx:{display:"flex",justifyContent:"center",marginTop:"2em",alignItems:"center",flexDirection:"column",gap:"1em"},children:[t(n,{textAlign:"center",variant:"h6",children:"Autenticacion automatica Crédito Federal"}),t(n,{textAlign:"center",variant:"h6",children:"Espere un momento... Sera redirigido a la pantalla principal"})]})]})})})})})};export{P as default};
