import { lazy } from "react";
import type { MetaFunction } from "react-router";
import { Placeholder } from "~/components/Placeholder";
import { useHydrated } from "~/hooks/useHydrated";
import { metaTags } from "~/utils/remix";
import type { SendouRouteHandle } from "~/utils/remix.server";
import { navIconUrl, PLANNER_URL } from "~/utils/urls";

import "../plans-global.css";

export const meta: MetaFunction = (args) => {
	return metaTags({
		title: "Map Planner",
		ogTitle: "Splatoon 3 Map planner",
		description:
			"Make perfect Splatoon 3 battle plans by drawing on maps and adding weapon images",
		location: args.location,
	});
};

export const handle: SendouRouteHandle = {
	i18n: ["weapons"],
	breadcrumb: () => ({
		imgPath: navIconUrl("plans"),
		href: PLANNER_URL,
		type: "IMAGE",
	}),
};

const Planner = lazy(() => import("~/features/map-planner/components/Planner"));

export default function MapPlannerPage() {
	const isHydrated = useHydrated();

	if (!isHydrated) return <Placeholder />;

	return <Planner />;
}
