"use client"; import { useEffect, useState } from "react"; import type { CarouselApi } from "@/components/ui/carousel"; export default function CurrentSlide({ api, total = 3, }: { api?: CarouselApi; total?: number; }) { const [current, setCurrent] = useState(0); useEffect(() => { if (!api) return; // Set initial slide setCurrent(api.selectedScrollSnap()); const handler = () => setCurrent(api.selectedScrollSnap()); api.on("select", handler); return () => api.off("select", handler); }, [api]); const handleClick = (index: number) => { if (!api) return; api.scrollTo(index); // embla API command to jump to slide }; return (