"use client"; import { motion } from "framer-motion"; import React, { useState, useMemo } from "react"; import { BlurImage } from "./blur-image"; const CARD_OFFSET = 4; const ROTATION_FACTOR = 6; interface Card { id: number; imageUrl: string; rotation: number; } interface CardStackProps { photos: string[]; } // Generate stable rotations based on index (deterministic) function getRotation(index: number): number { // Use a seeded pseudo-random based on index for consistency const seed = (index * 9301 + 49297) % 233280; const random = seed / 233280; return (index % 2 === 0 ? 1 : -1) * ROTATION_FACTOR * random; } const CardStack: React.FC = ({ photos }) => { const initialCards = useMemo( () => photos.map((imageUrl, index) => ({ id: index, imageUrl, rotation: getRotation(index), })), [photos], ); const [cards, setCards] = useState(initialCards); const moveToEnd = (from: number) => { setCards((prevCards) => { const newCards = [...prevCards]; const item = newCards.splice(from, 1)[0]; newCards.push(item); return newCards; }); }; return ( ); }; export default CardStack;