import{r as e}from"./chunk-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-BWRPWl8p.js";import{i as r,t as i}from"./axios-Yyz76XvX.js";import{go as a,ri as o}from"./endpoints-BWeG8ngA.js";import{Da as s,Ei as c,Ia as l,La as u,Ma as d,Qt as f,Ti as p,Tn as m,qr as h}from"./index-DccLTdzK.js";import{t as g}from"./query-string-D4ReIoyH.js";import{t as _}from"./index.esm-CAAi1gzH.js";var v=e(t(),1);async function y(e){return await i.get(r+o+`?fecha=${e}`,{headers:{Accept:`application/json`,"Content-Type":`application/json`}})}async function b(e){return await i.post(r+a,e,{headers:{Accept:`application/json`,"Content-Type":`application/json`}})}var x=n(),S=({setShow:e,history:t})=>{let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,y]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),w=async()=>{try{let{data:e}=await d(u(l()));C(e._id)}catch(e){console.error(e)}};(0,v.useEffect)(()=>{w()},[]);let T=n=>{if(n&&!o){y(!0);let i={idMensajero:S,idDoctor:n,estado:`true`};b(i).then(n=>{let{data:r}=n;f(`Se ha registrado la visita del mensajero `+S,i),s.success(r.mensaje||`Visita registrada con éxito`),t({search:g.stringify(``)}),y(!1),e(!1)}).catch(e=>{console.error(e),s.error(`Error al registrar la visita`),y(!1)}),r(n),a(!1)}};return(0,x.jsxs)(`div`,{className:`flex flex-col items-center p-6 bg-slate-900 text-white rounded-2xl shadow-xl border border-white/10`,children:[(0,x.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,x.jsx)(`div`,{className:`w-16 h-16 bg-sky-500/10 rounded-full flex items-center justify-center text-sky-400 mx-auto mb-3`,children:(0,x.jsx)(c,{icon:h,size:`2xl`})}),(0,x.jsx)(`h2`,{className:`text-xl font-bold`,children:`Escáner de Visitas`}),(0,x.jsx)(`p`,{className:`text-xs text-white/40 uppercase tracking-widest mt-1`,children:`Escanear QR del Doctor`})]}),i?(0,x.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-black/90 backdrop-blur-sm z-[1000] p-4`,children:(0,x.jsxs)(`div`,{className:`relative w-full max-w-md bg-slate-900 rounded-3xl overflow-hidden border border-white/10 shadow-2xl`,children:[(0,x.jsxs)(`div`,{className:`p-4 flex justify-between items-center border-b border-white/5`,children:[(0,x.jsx)(`span`,{className:`text-xs font-black uppercase tracking-widest text-white/40`,children:`Escaneando...`}),(0,x.jsx)(`button`,{onClick:()=>a(!1),className:`w-8 h-8 rounded-full bg-white/5 flex items-center justify-center hover:bg-red-500/20 hover:text-red-400 transition-colors`,children:(0,x.jsx)(c,{icon:p})})]}),(0,x.jsx)(`div`,{className:`p-4`,children:(0,x.jsxs)(`div`,{className:`relative aspect-square rounded-2xl overflow-hidden border-2 border-sky-500/30`,children:[(0,x.jsx)(_,{onResult:e=>T(e?.text),onError:e=>console.error(e),options:{delayBetweenScanAttempts:1e3},styles:{container:{width:`100%`,height:`100%`}}}),(0,x.jsxs)(`div`,{className:`absolute inset-0 pointer-events-none`,children:[(0,x.jsx)(`div`,{className:`absolute inset-10 border-2 border-sky-400 opacity-20 rounded-xl`}),(0,x.jsx)(`div`,{className:`absolute top-1/2 left-0 right-0 h-0.5 bg-sky-400/50 shadow-[0_0_15px_rgba(56,189,248,0.5)] animate-pulse`})]})]})}),(0,x.jsx)(`div`,{className:`p-6 text-center bg-white/5`,children:(0,x.jsx)(`p`,{className:`text-[10px] text-white/30 uppercase font-bold`,children:`Alinee el código QR dentro del recuadro`})})]})}):(0,x.jsxs)(`button`,{onClick:()=>a(!0),className:`group relative flex items-center gap-3 bg-sky-600 hover:bg-sky-500 text-white font-bold py-4 px-8 rounded-2xl transition-all duration-300 shadow-lg shadow-sky-600/20 active:scale-95`,children:[(0,x.jsx)(c,{icon:m,className:`group-hover:rotate-12 transition-transform`}),(0,x.jsx)(`span`,{children:`INICIAR ESCÁNER`})]}),n&&(0,x.jsxs)(`div`,{className:`mt-6 p-4 bg-white/5 rounded-xl border border-white/5 w-full text-center`,children:[(0,x.jsx)(`span`,{className:`text-[10px] font-black text-white/20 uppercase block mb-1`,children:`Último folio detectado`}),(0,x.jsx)(`p`,{className:`text-sky-400 font-mono font-bold`,children:n})]})]})};export{y as n,S as t};