import React, { useEffect, Suspense } from 'react'; import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import Navbar from './components/layout/Navbar'; import Hero from './components/layout/Hero'; import Footer from './components/layout/Footer'; import FeaturesSection from './components/home/FeaturesSection'; import TestimonialsSection from './components/home/TestimonialsSection'; import CTASection from './components/home/CTASection'; import FAQSection from './components/home/FAQSection'; import Loading from './components/common/Loading'; import { getFirebaseAuthInfo } from './services/userService'; import { ThemeProvider } from './contexts/ThemeContext'; import { NotificationProvider } from './contexts/NotificationContext'; import { PointsProvider } from './contexts/PointsContext'; import { ProgressProvider } from './contexts/ProgressContext'; import NotificationToast from './components/notification/NotificationToast'; import PointsChangeDetector from './components/points/PointsChangeDetector'; import ApiOperationWrapper from './utils/api/wrapper'; import { Link } from 'react-router-dom'; // Lazy load components const VideoDownloader = React.lazy(() => import('./components/workspace/VideoDownloader')); const Login = React.lazy(() => import('./components/auth/Login')); const Demo = React.lazy(() => import('./components/Demo')); const GetStarted = React.lazy(() => import('./components/GetStarted')); const SubscriptionSimple = React.lazy(() => import('./components/subscription/SubscriptionSimple')); const ProtectedRoute = React.lazy(() => import('./components/auth/ProtectedRoute')); const EmailVerification = React.lazy(() => import('./components/auth/EmailVerification')); const AuthDebug = React.lazy(() => import('./components/auth/AuthDebug')); const Workspace = React.lazy(() => import('./components/workspace/index')); const ProjectEditor = React.lazy(() => import('./components/project-editor/index')); const CheckOutStripe = React.lazy(() => import('./components/payment/CheckOutStripe')); const SubscriptionSuccess = React.lazy(() => import('./pages/SubscriptionSuccess')); const SubscriptionCancel = React.lazy(() => import('./pages/SubscriptionCancel')); const TermsOfService = React.lazy(() => import('./pages/TermsOfService')); const PrivacyPolicy = React.lazy(() => import('./pages/PrivacyPolicy')); const RefundPolicy = React.lazy(() => import('./pages/RefundPolicy')); const About = React.lazy(() => import('./pages/About')); const Contact = React.lazy(() => import('./pages/Contact')); const SubscriptionManagement = React.lazy(() => import('./components/subscription/SubscriptionManagement')); const PointsCenter = React.lazy(() => import('./components/points/PointsCenter')); // Home component to display the landing page content const Home = () => { // Lazy-load the component wrapper const LazyComponentWrapper = React.lazy(() => import('./components/common/LazyComponent').then(m => ({ default: m.LazyComponent }))); return ( <> {/* Hero is above the fold, render immediately */} {/* Below-the-fold sections: lazy load when entering viewport */} }> }> }> }> }> }> ); }; // Layout component for consistent UI across protected routes const MainLayout = ({ children, hideFooter = false }: { children: React.ReactNode, hideFooter?: boolean }) => { return ( <>
{children}
{!hideFooter &&