/* Vercel Analytics Integration */
// Load Analytics component from @vercel/analytics
// Since we're using React from CDN, we'll initialize analytics via script injection

const VercelAnalytics = () => {
  const { useEffect } = React;

  useEffect(() => {
    // Only run in browser environment
    if (typeof window === 'undefined') return;

    // Initialize Vercel Analytics
    window.va = window.va || function () { 
      (window.vaq = window.vaq || []).push(arguments); 
    };

    // Load the Vercel analytics script
    const script = document.createElement('script');
    script.defer = true;
    script.src = '/_vercel/insights/script.js';
    
    // Fallback: If not deployed on Vercel, the script won't load
    // but the app will continue to work normally
    script.onerror = () => {
      console.log('Vercel Analytics: Not loaded (expected on non-Vercel deployments)');
    };

    document.head.appendChild(script);

    return () => {
      // Cleanup if needed
      if (script.parentNode) {
        script.parentNode.removeChild(script);
      }
    };
  }, []);

  return null; // This component doesn't render anything
};

// Make it globally available
window.VercelAnalytics = VercelAnalytics;
