'use client'; import * as React from 'react'; import { cn } from '@/utils/cn'; type BlurTextProps = { text?: string; delay?: number; className?: string; animateBy?: 'words' | 'letters'; direction?: 'top' | 'bottom'; threshold?: number; rootMargin?: string; onAnimationComplete?: () => void; stepDuration?: number; }; export default function BlurText({ text = '', delay = 80, className, animateBy = 'words', direction = 'top', threshold = 0.1, rootMargin = '0px', onAnimationComplete, stepDuration = 0.35, }: BlurTextProps) { const elements = React.useMemo( () => (animateBy === 'words' ? text.split(' ') : text.split('')), [animateBy, text], ); const [inView, setInView] = React.useState(false); const ref = React.useRef(null); React.useEffect(() => { const element = ref.current; if (!element) return; const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { setInView(true); observer.unobserve(element); } }, { threshold, rootMargin }, ); observer.observe(element); return () => observer.disconnect(); }, [rootMargin, threshold]); return (

{elements.map((segment, index) => ( {segment === ' ' ? '\u00A0' : segment} {animateBy === 'words' && index < elements.length - 1 ? '\u00A0' : null} ))}

); }