"use client"; import { useState, useEffect, useCallback } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { ChevronLeft, ChevronRight } from "lucide-react"; interface GalleryProps { images: string[]; } export default function ImageCarousel({ images }: GalleryProps) { const [[page, direction], setPage] = useState([0, 0]); const [isAutoPlaying, setIsAutoPlaying] = useState(true); const imageIndex = Math.abs(page % images.length); const paginate = useCallback((newDirection: number) => { setPage([page + newDirection, newDirection]); }, [page]); // AUTO-PLAY LOGIC useEffect(() => { if (!isAutoPlaying) return; const interval = setInterval(() => { paginate(1); }, 5000); // 5 seconds is the "sweet spot" for technical analysis return () => clearInterval(interval); }, [paginate, isAutoPlaying]); const variants = { enter: (direction: number) => ({ x: direction > 0 ? 1000 : -1000, opacity: 0, }), center: { zIndex: 1, x: 0, opacity: 1 }, exit: (direction: number) => ({ zIndex: 0, x: direction < 0 ? 1000 : -1000, opacity: 0, }), }; return (