import { render } from "solid-js/web";
import { lazy } from "solid-js";
import { Route, Router } from "@solidjs/router";
import App from "./App";
import "./styles/index.css";
import { initSentry } from "./lib/sentry";

initSentry();

const HomeRoute = lazy(() => import("./routes/home-route").then((module) => ({ default: module.HomeRoute })));
const PricingRoute = lazy(() => import("./routes/pricing-route"));
const AboutRoute = lazy(() => import("./routes/about-route").then((module) => ({ default: module.AboutRoute })));
const AuthCallbackRoute = lazy(() => import("./routes/auth-callback-route").then((module) => ({ default: module.AuthCallbackRoute })));
const ContactRoute = lazy(() => import("./routes/contact-route").then((module) => ({ default: module.ContactRoute })));
const DashboardRoute = lazy(() => import("./routes/dashboard-route").then((module) => ({ default: module.DashboardRoute })));
const PublicBookingRoute = lazy(() => import("./routes/public-booking-route").then((module) => ({ default: module.PublicBookingRoute })));
const BookingManageRoute = lazy(() => import("./routes/booking-manage-route").then((module) => ({ default: module.BookingManageRoute })));
const LegalRoute = lazy(() => import("./routes/legal-route").then((module) => ({ default: module.LegalRoute })));
const NotFoundRoute = lazy(() => import("./routes/not-found-route").then((module) => ({ default: module.NotFoundRoute })));

render(
  () => (
    <Router root={App}>
      <Route path="/" component={HomeRoute} />
      <Route path="/pricing" component={PricingRoute} />
      <Route path="/about" component={AboutRoute} />
      <Route path="/auth/callback" component={AuthCallbackRoute} />
      <Route path="/contact" component={ContactRoute} />
      <Route path="/dashboard" component={DashboardRoute} />
      <Route path="/book/:tenantSlug" component={PublicBookingRoute} />
      <Route path="/manage/:reference" component={BookingManageRoute} />
      <Route path="/:kind" component={LegalRoute} matchFilters={{ kind: ["privacy", "terms"] }} />
      <Route path="*404" component={NotFoundRoute} />
    </Router>
  ),
  document.getElementById("root")!,
);
