"use client" import { AnimatePresence, motion } from "framer-motion" import { useState } from "react" import { useIntl } from "react-intl" import { ChevronLeftIcon } from "@/components/Icons" import ArrowRightIcon from "@/components/Icons/ArrowRight" import CloseIcon from "@/components/Icons/Close" import Image from "@/components/Image" import Button from "@/components/TempDesignSystem/Button" import Caption from "@/components/TempDesignSystem/Text/Caption" import styles from "./Lightbox.module.css" import type { GalleryProps } from "@/types/components/lightbox/lightbox" export default function Gallery({ images, onClose, onSelectImage, onImageClick, selectedImage, }: GalleryProps) { const intl = useIntl() const [animateLeft, setAnimateLeft] = useState(true) const mainImage = selectedImage || images[0] const mainImageIndex = images.findIndex((img) => img === mainImage) function getThumbImages() { const thumbs = [] for (let i = 1; i <= Math.min(5, images.length); i++) { const index = (mainImageIndex + i) % images.length thumbs.push(images[index]) } return thumbs } function handleNext() { setAnimateLeft(true) const nextIndex = (mainImageIndex + 1) % images.length onSelectImage(images[nextIndex]) } function handlePrev() { setAnimateLeft(false) const prevIndex = (mainImageIndex - 1 + images.length) % images.length onSelectImage(images[prevIndex]) } const variants = { initial: (animateLeft: boolean) => ({ opacity: 0, x: animateLeft ? 300 : -300, }), animate: { opacity: 1, x: 0 }, exit: (animateLeft: boolean) => ({ opacity: 0, x: animateLeft ? -300 : 300, }), } return (