import { Switch, Route } from "wouter";
import { queryClient } from "./lib/queryClient";
import { QueryClientProvider } from "@tanstack/react-query";
import { Toaster } from "@/components/ui/toaster";
import { TooltipProvider } from "@/components/ui/tooltip";
import NotFound from "@/pages/not-found";
import Home from "@/pages/Home";
import Explore from "@/pages/Explore";
import Search from "@/pages/Search";
import AuthorProfile from "@/pages/authors/AuthorProfile";
import Authors from "@/pages/authors/Authors";
import SimpleWorkReading from "@/pages/works/SimpleWorkReading";
import WorkCompare from "@/pages/works/WorkCompare";
import Collections from "@/pages/collections/Collections";
import CreateCollection from "@/pages/collections/CreateCollection";
import Profile from "@/pages/user/Profile";
import Submit from "@/pages/Submit";
import { BlogList, BlogDetail, BlogCreate } from "@/pages/blog";

function Router() {
  return (
    <Switch>
      <Route path="/" component={Home} />
      <Route path="/explore" component={Explore} />
      <Route path="/search" component={Search} />
      <Route path="/authors" component={Authors} />
      <Route path="/authors/:slug" component={AuthorProfile} />
      <Route path="/works/:slug" component={SimpleWorkReading} />
      <Route path="/works/:slug/compare/:translationId" component={WorkCompare} />
      <Route path="/collections" component={Collections} />
      <Route path="/collections/create" component={CreateCollection} />
      <Route path="/profile" component={Profile} />
      <Route path="/submit" component={Submit} />
      <Route path="/blog" component={BlogList} />
      <Route path="/blog/create" component={BlogCreate} />
      <Route path="/blog/:slug" component={BlogDetail} />
      <Route component={NotFound} />
    </Switch>
  );
}

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <TooltipProvider>
        <Toaster />
        <Router />
      </TooltipProvider>
    </QueryClientProvider>
  );
}

export default App;
