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/overview-page"));
const DashboardBookingsRoute = lazy(() => import("./routes/dashboard/bookings-page"));
const DashboardCustomersRoute = lazy(() => import("./routes/dashboard/customers-page"));
const DashboardZonesRoute = lazy(() => import("./routes/dashboard/zones-page"));
const DashboardBillingRoute = lazy(() => import("./routes/dashboard/billing-page"));
const DashboardSettingsRoute = lazy(() => import("./routes/dashboard/settings-page"));
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="/dashboard/bookings" component={DashboardBookingsRoute} />
      <Route path="/dashboard/customers" component={DashboardCustomersRoute} />
      <Route path="/dashboard/zones" component={DashboardZonesRoute} />
      <Route path="/dashboard/billing" component={DashboardBillingRoute} />
      <Route path="/dashboard/settings" component={DashboardSettingsRoute} />
      <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")!,
);
