import { createBrowserRouter } from 'react-router-dom'
import App from './App'
import RouteGuard from './components/RouteGuard'
import DashboardLayout from './components/DashboardLayout'
import LoginPage from './pages/LoginPage'
import CallbackPage from './pages/CallbackPage'
import DashboardPage from './pages/DashboardPage'
import ProjectListPage from './pages/ProjectListPage'
import ProjectDetailPage from './pages/ProjectDetailPage'
import ProjectFormPage from './pages/ProjectFormPage'
import ToolsPage from './pages/ToolsPage'
import ToolSpawnPage from './pages/ToolSpawnPage'
import ToolInstanceDetailPage from './pages/ToolInstanceDetailPage'
import SettingsPage from './pages/SettingsPage'
import RepositoriesPage from './pages/RepositoriesPage'

export const router = createBrowserRouter([
  {
    path: '/',
    element: <App />,
    children: [
      {
        element: (
          <RouteGuard>
            <DashboardLayout />
          </RouteGuard>
        ),
        children: [
          { path: '/', element: <DashboardPage /> },
          { path: '/projects', element: <ProjectListPage /> },
          { path: '/projects/new', element: <ProjectFormPage /> },
          { path: '/projects/:id', element: <ProjectDetailPage /> },
          { path: '/projects/:id/edit', element: <ProjectFormPage /> },
          { path: '/tools', element: <ToolsPage /> },
          { path: '/tools/spawn', element: <ToolSpawnPage /> },
          { path: '/projects/:projectId/instances/:instanceId', element: <ToolInstanceDetailPage /> },
          { path: '/settings', element: <SettingsPage /> },
          { path: '/repositories', element: <RepositoriesPage /> },
        ],
      },
      { path: '/login', element: <LoginPage /> },
      { path: '/callback', element: <CallbackPage /> },
    ],
  },
])
