import { Children, type ReactNode } from "react"; import useEmblaCarousel from "embla-carousel-react"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { cls } from "@/lib/utils"; import { useCarouselControls } from "@/hooks/useCarouselControls"; interface GridOrCarouselProps { children: ReactNode; carouselThreshold?: 2 | 3 | 4; } const GridOrCarousel = ({ children, carouselThreshold = 4 }: GridOrCarouselProps) => { const [emblaRef, emblaApi] = useEmblaCarousel({ dragFree: true }); const { prevDisabled, nextDisabled, scrollPrev, scrollNext, scrollProgress } = useCarouselControls(emblaApi); const items = Children.toArray(children); const count = items.length; if (count <= carouselThreshold) { return (