import type { Metadata } from "next";

import configPromise from "@payload-config";
import { RootPage, generatePageMetadata } from "@payloadcms/next/views";
// @ts-ignore - Payload generates this file during the build process
import { importMap } from "../importMap";

type Args = {
  params: Promise<{
    segments: string[];
  }>;
  searchParams: Promise<{
    [key: string]: string | string[];
  }>;
};

export const generateMetadata = async ({
  params,
  searchParams,
}: Args): Promise<Metadata> =>
  generatePageMetadata({ config: configPromise, params, searchParams });

const Page = async ({ params, searchParams }: Args) =>
  RootPage({ config: configPromise, importMap, params, searchParams });

export default Page;
