import type { Metadata } from 'next';
import { getServerBranding } from '@server/lib/branding';
import PrivacyPageContent from './PrivacyPageContent';

export const revalidate = 60;

export async function generateMetadata(): Promise<Metadata> {
  const branding = await getServerBranding();
  const title = `Privacy Policy — ${branding.siteTitle}`;
  const description = `How ${branding.siteTitle} collects, uses, and protects your information.`;
  return {
    title,
    description,
    alternates: branding.marketingUrl ? { canonical: `${branding.marketingUrl.replace(/\/$/, '')}/privacy` } : undefined,
    openGraph: {
      title,
      description,
      siteName: branding.siteTitle,
      ...(branding.marketingUrl ? { url: `${branding.marketingUrl.replace(/\/$/, '')}/privacy` } : {}),
      type: 'website',
    },
    twitter: {
      card: 'summary',
      title,
      description,
    },
  };
}

export default async function PrivacyPage() {
  const branding = await getServerBranding();
  return <PrivacyPageContent supportEmail={branding.supportEmail} />;
}
