import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter, Routes, Route } from "react-router";
import "./index.css";
import { AuthProvider } from "./contexts/AuthContext";
import { SupervisorQuestionsProvider } from "./contexts/SupervisorQuestionsContext";
import { GridOverlay } from "./components/GridOverlay";
import { SupervisorQuestionNotification } from "./components/SupervisorQuestionNotification";
import { PhaseConfirmationNotification } from "./components/PhaseConfirmationNotification";
import { ProtectedRoute } from "./components/ProtectedRoute";
import HomePage from "./routes/_index";
import ListenPage from "./routes/listen";
import FilesPage from "./routes/files";
import ContractsPage from "./routes/contracts";
import WorkflowPage from "./routes/workflow";
import MeshPage from "./routes/mesh";
import HistoryPage from "./routes/history";
import LoginPage from "./routes/login";
import SettingsPage from "./routes/settings";
import ContractFilePage from "./routes/contract-file";
import TemplatesPage from "./routes/templates";
import SpeakPage from "./routes/speak";

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <AuthProvider>
      <SupervisorQuestionsProvider>
        <BrowserRouter>
          <GridOverlay />
          <SupervisorQuestionNotification />
          <PhaseConfirmationNotification />
          <Routes>
          <Route path="/" element={<HomePage />} />
          <Route path="/login" element={<LoginPage />} />
          <Route
            path="/listen"
            element={
              <ProtectedRoute>
                <ListenPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/files"
            element={
              <ProtectedRoute>
                <FilesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/files/:id"
            element={
              <ProtectedRoute>
                <FilesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/contracts"
            element={
              <ProtectedRoute>
                <ContractsPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/contracts/:id"
            element={
              <ProtectedRoute>
                <ContractsPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/contracts/:id/files/:fileId"
            element={
              <ProtectedRoute>
                <ContractFilePage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/workflow"
            element={
              <ProtectedRoute>
                <WorkflowPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/mesh"
            element={
              <ProtectedRoute>
                <MeshPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/mesh/:id"
            element={
              <ProtectedRoute>
                <MeshPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/history"
            element={
              <ProtectedRoute>
                <HistoryPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/history/:id"
            element={
              <ProtectedRoute>
                <HistoryPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/settings"
            element={
              <ProtectedRoute>
                <SettingsPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/templates"
            element={
              <ProtectedRoute>
                <TemplatesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/speak"
            element={
              <ProtectedRoute>
                <SpeakPage />
              </ProtectedRoute>
            }
          />
          </Routes>
        </BrowserRouter>
      </SupervisorQuestionsProvider>
    </AuthProvider>
  </StrictMode>
);
