import { createRootRoute, createRoute, createRouter } from '@tanstack/react-router';
import { RootLayout } from '@/app/RootLayout';
import { CampaignsPage } from '@/features/campaigns/CampaignsPage';
import { CharactersPage } from '@/features/characters/CharactersPage';
import { CharacterSheetPage } from '@/features/characters/CharacterSheetPage';
import { CombatPage } from '@/features/combat/CombatPage';
import { DicePage } from '@/features/dice/DicePage';
import { CompendiumPage } from '@/features/compendium/CompendiumPage';
import { DashboardPage } from '@/features/world/DashboardPage';
import { NotesPage } from '@/features/world/NotesPage';
import { NpcsPage } from '@/features/world/NpcsPage';
import { QuestsPage } from '@/features/world/QuestsPage';
import { CalendarPage } from '@/features/world/CalendarPage';
import { MapsPage } from '@/features/world/MapsPage';
import { PlayerViewPage } from '@/features/player/PlayerViewPage';
import { HomebrewPage } from '@/features/world/HomebrewPage';
import { SettingsPage } from '@/features/settings/SettingsPage';
import { AssistantPage } from '@/features/assistant/AssistantPage';

const rootRoute = createRootRoute({ component: RootLayout });

const indexRoute = createRoute({ getParentRoute: () => rootRoute, path: '/', component: CampaignsPage });
const charactersRoute = createRoute({ getParentRoute: () => rootRoute, path: '/characters', component: CharactersPage });
const characterSheetRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: '/characters/$characterId',
  component: CharacterSheetPage,
});
const combatRoute = createRoute({ getParentRoute: () => rootRoute, path: '/combat', component: CombatPage });
const diceRoute = createRoute({ getParentRoute: () => rootRoute, path: '/dice', component: DicePage });
const compendiumRoute = createRoute({ getParentRoute: () => rootRoute, path: '/compendium', component: CompendiumPage });
const dashboardRoute = createRoute({ getParentRoute: () => rootRoute, path: '/dashboard', component: DashboardPage });
const notesRoute = createRoute({ getParentRoute: () => rootRoute, path: '/notes', component: NotesPage });
const npcsRoute = createRoute({ getParentRoute: () => rootRoute, path: '/npcs', component: NpcsPage });
const questsRoute = createRoute({ getParentRoute: () => rootRoute, path: '/quests', component: QuestsPage });
const calendarRoute = createRoute({ getParentRoute: () => rootRoute, path: '/calendar', component: CalendarPage });
const mapsRoute = createRoute({ getParentRoute: () => rootRoute, path: '/maps', component: MapsPage });
const playRoute = createRoute({ getParentRoute: () => rootRoute, path: '/play', component: PlayerViewPage });
const homebrewRoute = createRoute({ getParentRoute: () => rootRoute, path: '/homebrew', component: HomebrewPage });
const settingsRoute = createRoute({ getParentRoute: () => rootRoute, path: '/settings', component: SettingsPage });
const assistantRoute = createRoute({ getParentRoute: () => rootRoute, path: '/assistant', component: AssistantPage });

const routeTree = rootRoute.addChildren([
  indexRoute,
  dashboardRoute,
  charactersRoute,
  characterSheetRoute,
  combatRoute,
  diceRoute,
  compendiumRoute,
  notesRoute,
  npcsRoute,
  questsRoute,
  calendarRoute,
  mapsRoute,
  playRoute,
  homebrewRoute,
  settingsRoute,
  assistantRoute,
]);

export const router = createRouter({ routeTree, defaultPreload: 'intent' });

declare module '@tanstack/react-router' {
  interface Register {
    router: typeof router;
  }
}
