import React, { useRef, useEffect, useState, ReactNode } from 'react'; import { isVideo, isAudio, encodeFilePathForUrl } from '@/utils/basic'; interface SampleImageCardProps { imageUrl: string; alt: string; numSamples: number; sampleImages: string[]; children?: ReactNode; className?: string; onDelete?: () => void; onClick?: () => void; /** pass your scroll container element (e.g. containerRef.current) */ observerRoot?: Element | null; /** optional: tweak pre-load buffer */ rootMargin?: string; // default '200px 0px' } const SampleImageCard: React.FC = ({ imageUrl, alt, numSamples, sampleImages, children, className = '', onClick = () => {}, observerRoot = null, rootMargin = '200px 0px', }) => { const cardRef = useRef(null); const videoRef = useRef(null); const [isVisible, setIsVisible] = useState(false); const [loaded, setLoaded] = useState(false); const [blobUrl, setBlobUrl] = useState(null); // videos with no pre-generated thumb (older samples) fall back to the