import { createBrowserRouter, RouterProvider, Navigate } from 'react-router-dom';
import { AuthGuard } from './shared/layout/AuthGuard';
import { AdminGuard } from './shared/layout/AdminGuard';
import { AuthenticatedShell } from './shared/layout/AuthenticatedShell';
import { LoginPage } from './shared/layout/LoginPage';
import CommandPillar from './pillars/command/CommandPillar';
import OracleWorkspacePage from './pillars/command/OracleWorkspacePage';
import PipelinePillar from './pillars/pipeline/PipelinePillar';
import Client360 from './pillars/pipeline/client360/Client360';
import ShowroomMode from './pillars/pipeline/ShowroomMode';
import StudioPillar from './pillars/studio/StudioPillar';
import PropertyEntity from './pillars/studio/PropertyEntity';
import ControlRoom from './control-room/ControlRoom';
import VaultPublicPage from './shared/layout/VaultPublicPage';

const router = createBrowserRouter([
  {
    path: '/login',
    element: <LoginPage />,
  },
  {
    path: '/',
    element: (
      <AuthGuard>
        <AuthenticatedShell />
      </AuthGuard>
    ),
    children: [
      { index: true, element: <Navigate to="/command" replace /> },
      { path: 'command', element: <CommandPillar /> },
      { path: 'oracle', element: <OracleWorkspacePage /> },
      { path: 'pipeline', element: <PipelinePillar /> },
      { path: 'pipeline/:personId', element: <Client360 /> },
      { path: 'showroom', element: <ShowroomMode /> },
      { path: 'studio', element: <StudioPillar /> },
      { path: 'studio/:propertyId', element: <PropertyEntity /> },
    ],
  },
  {
    path: '/control-room/:panel?',
    element: (
      <AuthGuard>
        <AdminGuard>
          <ControlRoom />
        </AdminGuard>
      </AuthGuard>
    ),
  },
  {
    path: '/vault/:trackingHash',
    element: <VaultPublicPage />,
  },
  {
    path: '*',
    element: <Navigate to="/command" replace />,
  },
]);

export default function App() {
  return <RouterProvider router={router} />;
}
