import React, { useEffect, lazy, Suspense } from 'react'; import ReactDOM from 'react-dom/client'; import { ChakraProvider } from '@chakra-ui/react'; import { BrowserRouter as Router, Route, Routes, useLocation, useParams, useNavigate, Navigate } from 'react-router-dom'; import { HelmetProvider } from 'react-helmet-async'; import createCache from '@emotion/cache'; import { CacheProvider } from '@emotion/react'; // Authentication-related imports - keep these eager loaded as they're critical import { AuthProvider, useAuth } from './context/AuthContext'; import LoginPage from './login'; import SignUpPage from './signup'; import Logout from './logout'; import SuccessPage from './SuccessPage'; import CancelPage from './CancelPage'; import NotFoundPage from './components/NotFoundPage'; import TawkToWidget from './TawkToWidget'; import ThemeColorUpdater from './ThemeColorUpdater'; // Import PostHog utilities import { initPostHog, PostHogTracking } from './utils/posthog-config'; // Initialize PostHog initPostHog(); // Lazy-loaded components for public routes const App = lazy(() => import('./MainPage/App.jsx')); const PricingPage = lazy(() => import('./MainPage/Pricingpage.jsx')); const PolicyPage = lazy(() => import('./MainPage/PolicyPage')); const TermsPage = lazy(() => import('./MainPage/TermsPage.jsx')); const AboutUsPage = lazy(() => import('./MainPage/AboutUsPage')); const ContactUsPage = lazy(() => import('./MainPage/ContactUsPage')); const AiMockInterviewPage = lazy(() => import('./components/AiMockInterview/AIMockInterviewPage.jsx')); const JobHuntTrackerPage = lazy(() => import('./components/JobHuntTracker/JobHuntTrackerPage')); const BlogList = lazy(() => import('./Blog').then(module => ({ default: module.BlogList }))); const BlogPost = lazy(() => import('./Blog').then(module => ({ default: module.BlogPost }))); // Lazy-loaded components for authenticated routes const Dashboard = lazy(() => import('./GetStarted/Dashboard.jsx')); const InterviewBoard = lazy(() => import('./Interview/interview-board.jsx')); const NewInterview = lazy(() => import('./Interview/new-interview.jsx')); const CreateInterview = lazy(() => import('./Interview/NewInterview/CreateInterview.jsx')); const InterviewDetail = lazy(() => import('./Interview/InterviewDetail/InterviewDetail.jsx')); const InterviewFeedback = lazy(() => import('./Interview/interviewFeedback.jsx')); const OnboardingForm = lazy(() => import('./Onboarding/OnboardingForm')); const InterviewV2 = lazy(() => import('./VideoCallV2/InterviewV2.jsx')); const InterviewFeedbackV2 = lazy(() => import('./VideoCallV2/InterviewFeedback')); const DeviceTestV2Page = lazy(() => import('./VideoCallV2/DeviceTestV2Page')); const QuestionBank = lazy(() => import('./QuestionBank/QuestionBank')); const QuestionDetails = lazy(() => import('./QuestionBank/QuestionDetails')); const Goals = lazy(() => import('./Goals/goals')); const Subscriptions = lazy(() => import('./Subscriptions/subscriptions')); const MyDocuments = lazy(() => import('./my-documents')); const EducationMaterials = lazy(() => import('./education-materials')); const WaveformDemo = lazy(() => import('./WaveformDemo.jsx')); const InterviewTemplates = lazy(() => import('./Interview/InterviewTemplates')); // Lazy-loaded admin components const AdminTemplateManagement = lazy(() => import('./Admin/TemplateManagement.jsx')); const CreateTemplate = lazy(() => import('./Admin/CreateTemplate.jsx')); // Create emotion cache with key const emotionCache = createCache({ key: 'prepin', prepend: true, speedy: true, // Enable speedy mode for production container: document.head, insertionPoint: document.querySelector('meta[name="emotion-insertion-point"]') }); // Simple loading component const LoadingFallback = () => (