import { lazy, Suspense } from "react";
import { Toaster } from "@/components/ui/toaster";
import { Navigate } from "react-router-dom";
import { TooltipProvider } from "@/components/ui/tooltip";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Routes, Route } from "react-router-dom";
import AppErrorBoundary from "@/components/AppErrorBoundary";
import Index from "./pages/Index";
import NotFound from "./pages/NotFound";
import BlogPost from "./pages/BlogPost";
import Downloads from "./pages/Downloads";
import Changelog from "./pages/Changelog";
import Blog from "./pages/Blog";
import Contact from "./pages/Contact";
import ActivateWindows11 from "./pages/ActivateWindows11";
import ActivateOffice365 from "./pages/ActivateOffice365";
import KmspicoAlternative from "./pages/KmspicoAlternative";
import HwidDocs from "./pages/HwidDocs";
import ManualHwid from "./pages/ManualHwid";
import GuidesPage from "./pages/GuidesPage";
import GuideDetail from "./pages/GuideDetail";
import CreditsPage from "./pages/CreditsPage";
import UnsupportedProducts from "./pages/UnsupportedProducts";
import WindowsActivationGuide from "./pages/WindowsActivationGuide";
import IsKmsautoSafe from "./pages/IsKmsautoSafe";
import KmspicoVsKmsauto from "./pages/KmspicoVsKmsauto";
import HwidVsKms from "./pages/HwidVsKms";
import HowToUseKmsauto from "./pages/HowToUseKmsauto";
import KmsautoFaq from "./pages/KmsautoFaq";
import KmsautoFeatures from "./pages/KmsautoFeatures";
import DownloadWindows11 from "./pages/downloads/DownloadWindows11";
import DownloadWindows10 from "./pages/downloads/DownloadWindows10";
import DownloadWindowsLTSC from "./pages/downloads/DownloadWindowsLTSC";
import DownloadWindowsARM64 from "./pages/downloads/DownloadWindowsARM64";
import DownloadWindowsServer from "./pages/downloads/DownloadWindowsServer";
import DownloadWindowsEmbedded from "./pages/downloads/DownloadWindowsEmbedded";
import DownloadOffice from "./pages/downloads/DownloadOffice";
import DownloadOfficeCustom from "./pages/downloads/DownloadOfficeCustom";
import DownloadOfficeMSI from "./pages/downloads/DownloadOfficeMSI";
import DownloadOfficeMac from "./pages/downloads/DownloadOfficeMac";
import CleanInstallGuide from "./pages/downloads/CleanInstallGuide";
import InPlaceUpgradeGuide from "./pages/downloads/InPlaceUpgradeGuide";
import UpdateWindowsISO from "./pages/downloads/UpdateWindowsISO";
const AdminDownloads = lazy(() => import("./pages/AdminDownloads"));

const queryClient = new QueryClient();

const App = () => (
  <AppErrorBoundary>
    <QueryClientProvider client={queryClient}>
      <TooltipProvider>
        <Toaster />
        <Routes>
          <Route path="/" element={<Index />} />
          <Route path="/blog/:slug" element={<BlogPost />} />
          <Route path="/downloads" element={<Downloads />} />
          <Route path="/changelog" element={<Changelog />} />
          <Route path="/blog" element={<Blog />} />
          <Route path="/contact" element={<Contact />} />
          <Route path="/activate-windows-11" element={<ActivateWindows11 />} />
          <Route path="/activate-office-365" element={<ActivateOffice365 />} />
          <Route path="/kmspico-alternative" element={<KmspicoAlternative />} />
          <Route path="/windows-activation-guide" element={<WindowsActivationGuide />} />
          <Route path="/is-kmsauto-safe" element={<IsKmsautoSafe />} />
          <Route path="/kmspico-vs-kmsauto" element={<KmspicoVsKmsauto />} />
          <Route path="/hwid-vs-kms" element={<HwidVsKms />} />
          <Route path="/how-to-use-kmsauto" element={<HowToUseKmsauto />} />
          <Route path="/kmsauto-faq" element={<KmsautoFaq />} />
          <Route path="/kmsauto-features" element={<KmsautoFeatures />} />
          <Route path="/docs/hwid" element={<HwidDocs />} />
          <Route path="/docs/manual-hwid" element={<ManualHwid />} />
          <Route path="/docs/guides" element={<GuidesPage />} />
          <Route path="/guides/:slug" element={<GuideDetail />} />
          <Route path="/docs/unsupported-products" element={<Navigate to="/guides/unsupported-products" replace />} />
          <Route path="/downloads/windows-11" element={<DownloadWindows11 />} />
          <Route path="/downloads/windows-10" element={<DownloadWindows10 />} />
          <Route path="/downloads/windows-ltsc" element={<DownloadWindowsLTSC />} />
          <Route path="/downloads/windows-arm64" element={<DownloadWindowsARM64 />} />
          <Route path="/downloads/windows-server" element={<DownloadWindowsServer />} />
          <Route path="/downloads/windows-embedded" element={<DownloadWindowsEmbedded />} />
          <Route path="/downloads/office" element={<DownloadOffice />} />
          <Route path="/downloads/office-custom" element={<DownloadOfficeCustom />} />
          <Route path="/downloads/office-msi" element={<DownloadOfficeMSI />} />
          <Route path="/downloads/office-mac" element={<DownloadOfficeMac />} />
          <Route path="/downloads/guides/clean-install" element={<CleanInstallGuide />} />
          <Route path="/downloads/guides/in-place-upgrade" element={<InPlaceUpgradeGuide />} />
          <Route path="/downloads/guides/update-iso" element={<UpdateWindowsISO />} />
          <Route path="/credits" element={<CreditsPage />} />
          <Route path="/admin/downloads" element={<Suspense fallback={null}><AdminDownloads /></Suspense>} />
          <Route path="*" element={<NotFound />} />
        </Routes>
      </TooltipProvider>
    </QueryClientProvider>
  </AppErrorBoundary>
);

export default App;
