import React, { useState } from 'react'; import { cn } from '../lib/utils'; const Tooltip = ({ children, content, position = 'top', className = '', delay = 500 }) => { const [isVisible, setIsVisible] = useState(false); const [timeoutId, setTimeoutId] = useState(null); const handleMouseEnter = () => { const id = setTimeout(() => { setIsVisible(true); }, delay); setTimeoutId(id); }; const handleMouseLeave = () => { if (timeoutId) { clearTimeout(timeoutId); setTimeoutId(null); } setIsVisible(false); }; const getPositionClasses = () => { switch (position) { case 'top': return 'bottom-full left-1/2 transform -translate-x-1/2 mb-2'; case 'bottom': return 'top-full left-1/2 transform -translate-x-1/2 mt-2'; case 'left': return 'right-full top-1/2 transform -translate-y-1/2 mr-2'; case 'right': return 'left-full top-1/2 transform -translate-y-1/2 ml-2'; default: return 'bottom-full left-1/2 transform -translate-x-1/2 mb-2'; } }; const getArrowClasses = () => { switch (position) { case 'top': return 'top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100'; case 'bottom': return 'bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100'; case 'left': return 'left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100'; case 'right': return 'right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100'; default: return 'top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100'; } }; if (!content) { return children; } return (