import{r as e}from"./chunk-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-BWRPWl8p.js";import{Da as r,Ei as i,Li as a,Qr as o,Tn as s,Zr as c,da as l,ki as u,lr as d,ma as f,ua as p}from"./index-DccLTdzK.js";import{t as m}from"./index.esm-CAAi1gzH.js";import{i as h,r as g}from"./comedor-DH3wfCLm.js";import{i as _}from"./mesas-Bjm6G_Fi.js";/* empty css                         */var v=e(t(),1),y=n();function b(){let[e,t]=(0,v.useState)(``),[n,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(``),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(!1);(0,v.useEffect)(()=>{(async()=>{try{let e=await _();console.log(`Respuesta API Mesas:`,e.data),b(e.data||[])}catch(e){console.error(`Error al obtener mesas:`,e)}})()},[]);let D=e=>{e&&!C&&(t(e),E(!1))},O=async(n,i=null)=>{let a=i||e;if(!a){r.warning(`Ingresa o escanea un correo.`);return}if(n===`entrada`&&!x){r.warning(`Por favor selecciona una mesa.`);return}w(!0);try{n===`entrada`?(await g({idUsuario:a,tipo:`Empleado`,idMesa:n===`entrada`?x:null}),r.success(`¡Buen provecho! Entrada registrada.`)):(await h({idUsuario:a}),r.success(`Salida registrada. ¡Gracias!`)),t(``),S(``)}catch(e){r.error(e.response?.data?.mensaje||`Error al procesar registro.`)}finally{w(!1)}};return(0,y.jsx)(`div`,{className:`comedor-dashboard-container d-flex align-items-center justify-content-center animate-in`,style:{background:`linear-gradient(180deg, #0c1b30 0%, #000 100%)`},children:(0,y.jsx)(p,{style:{maxWidth:`800px`},children:(0,y.jsxs)(`div`,{className:`glass-card text-center p-5`,children:[(0,y.jsxs)(`div`,{className:`mb-4`,children:[(0,y.jsx)(`h1`,{className:`dashboard-title`,children:`Checador Virtual`}),(0,y.jsx)(`p`,{className:`text-muted`,children:`Escanea tu QR o ingresa tu correo para continuar`})]}),(0,y.jsxs)(`div`,{className:`mb-4 d-flex flex-column align-items-center`,children:[T?(0,y.jsx)(`div`,{className:`modern-scanner-container glass-card mb-4`,style:{width:`100%`,maxWidth:`400px`},children:(0,y.jsxs)(`div`,{className:`scanner-wrapper`,children:[(0,y.jsx)(m,{onResult:e=>D(e?.text),onError:e=>console.log(e),options:{delayBetweenScanAttempts:1e3},styles:{container:{width:`100%`,borderRadius:`20px`,overflow:`hidden`}}}),(0,y.jsxs)(`div`,{className:`scanner-overlay`,children:[(0,y.jsx)(`div`,{className:`scanner-corners`}),(0,y.jsx)(`div`,{className:`scanner-laser`})]})]})}):(0,y.jsxs)(`div`,{className:`p-4 bg-dark rounded-4 d-flex flex-column align-items-center justify-content-center mb-3`,style:{width:`300px`,height:`300px`,border:`2px dashed #38bdf8`,cursor:`pointer`,transition:`all 0.3s ease`},onClick:()=>E(!0),children:[(0,y.jsx)(i,{icon:s,size:`4x`,className:`text-info mb-3`}),(0,y.jsx)(`span`,{className:`text-info fw-bold`,children:`ACTIVAR CÁMARA`})]}),(0,y.jsxs)(u,{className:`w-100 mt-3 justify-content-center`,children:[(0,y.jsx)(l,{md:6,children:(0,y.jsx)(a.Control,{type:`email`,size:`lg`,className:`bg-transparent text-white text-center border-0 border-bottom rounded-0`,placeholder:`CORREO ELECTRÓNICO`,value:e,onChange:e=>t(e.target.value),style:{fontSize:`1.2rem`,letterSpacing:`0.1em`}})}),(0,y.jsxs)(l,{md:6,className:`mt-3 mt-md-0`,children:[(0,y.jsxs)(a.Select,{size:`lg`,className:`bg-transparent text-white border-0 border-bottom rounded-0`,value:x,onChange:e=>S(e.target.value),style:{fontSize:`1.2rem`,backgroundColor:`#1e293b`},children:[(0,y.jsx)(`option`,{value:``,style:{color:`#000`},children:`SELECCIONAR MESA`}),n.map(e=>{let t=e.lugares?e.lugares.length:0,n=e.lugares?e.lugares.filter(e=>e.estado==`0`||!e.estado).length:0;return n===0?null:(0,y.jsxs)(`option`,{value:e._id,style:{color:`#000`},children:[`Mesa `,e.numeroMesa,` (`,n,` Libres de `,t,`)`]},e._id)})]}),n.length===0?(0,y.jsx)(`small`,{className:`text-warning`,children:`No se encontraron mesas en el sistema. Verifica que estén registradas.`}):(0,y.jsxs)(`small`,{className:`text-info`,children:[`Total mesas encontradas: `,n.length]})]})]})]}),(0,y.jsxs)(u,{className:`g-4`,children:[(0,y.jsx)(l,{sm:6,children:(0,y.jsxs)(f,{variant:`success`,className:`w-100 py-4 rounded-4 shadow-lg d-flex flex-column align-items-center`,onClick:()=>O(`entrada`),disabled:C,style:{background:`linear-gradient(45deg, #10b981, #059669)`,border:`none`},children:[(0,y.jsx)(i,{icon:o,size:`2x`,className:`mb-2`}),(0,y.jsx)(`span`,{className:`h4 mb-0`,children:`ENTRADA`})]})}),(0,y.jsx)(l,{sm:6,children:(0,y.jsxs)(f,{variant:`danger`,className:`w-100 py-4 rounded-4 shadow-lg d-flex flex-column align-items-center`,onClick:()=>O(`salida`),disabled:C,style:{background:`linear-gradient(45deg, #ef4444, #dc2626)`,border:`none`},children:[(0,y.jsx)(i,{icon:c,size:`2x`,className:`mb-2`}),(0,y.jsx)(`span`,{className:`h4 mb-0`,children:`SALIDA`})]})})]}),(0,y.jsxs)(`div`,{className:`mt-5 pt-4 text-muted border-top border-secondary opacity-50`,children:[(0,y.jsx)(i,{icon:d,className:`me-2`}),`Sistema de Biometría e Identificación ISOTECH`]})]})})})}export{b as default};