import{r as i,g as u,j as a,m as x,X as f,h}from"./index-CqI-dFNO.js";import{C as g}from"./chevron-left-BWFm-udl.js";function w({photos:e,initialIndex:l,onClose:s}){const[d,r]=i.useState(()=>y(l,e.length)),o=i.useCallback(()=>{r(t=>(t-1+e.length)%e.length)},[e.length,r]),c=i.useCallback(()=>{r(t=>(t+1)%e.length)},[e.length,r]);i.useEffect(()=>{function t(m){m.key==="Escape"&&s(),m.key==="ArrowLeft"&&o(),m.key==="ArrowRight"&&c()}return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[s,o,c]),i.useEffect(()=>{const t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=t}},[]);const n=e[d];return n?u.createPortal(a.jsxs(x.div,{role:"dialog","aria-modal":"true","aria-label":n.alt,className:"fixed inset-0 z-[150] flex items-center justify-center bg-black/90 backdrop-blur-sm px-4 py-10 sm:px-8",initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},onClick:s,children:[a.jsx("button",{type:"button","aria-label":"Close",onClick:s,className:"glass-mist fixed right-4 top-4 z-10 flex h-11 w-11 items-center justify-center rounded-full text-white hover:text-accent-emerald gentle-animation sm:right-6 sm:top-6",children:a.jsx(f,{className:"h-5 w-5"})}),e.length>1&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button","aria-label":"Previous photo",onClick:t=>{t.stopPropagation(),o()},className:"glass-mist fixed left-2 top-1/2 z-10 flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full text-white hover:text-accent-emerald gentle-animation sm:left-6",children:a.jsx(g,{className:"h-6 w-6"})}),a.jsx("button",{type:"button","aria-label":"Next photo",onClick:t=>{t.stopPropagation(),c()},className:"glass-mist fixed right-2 top-1/2 z-10 flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full text-white hover:text-accent-emerald gentle-animation sm:right-6",children:a.jsx(h,{className:"h-6 w-6"})})]}),a.jsx(x.img,{src:n.src,alt:n.alt,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:t=>t.stopPropagation(),className:"max-h-full max-w-full rounded-2xl object-contain shadow-2xl"},n.src),e.length>1&&a.jsxs("span",{className:"glass-mist fixed bottom-4 left-1/2 z-10 -translate-x-1/2 rounded-full px-3 py-1 text-xs font-semibold text-white sm:bottom-6",children:[d+1," / ",e.length]})]}),document.body):null}function y(e,l){return l<=0?0:Math.min(Math.max(e,0),l-1)}export{w as P};
