import Navbar from '@/components/layout/Navbar';
import Hero from '@/components/home/Hero';
import Products from '@/components/home/Products';
import LargeText from '@/components/home/LargeText';
import Features from '@/components/home/Features';
import CTA from '@/components/home/CTA';
import Footer from '@/components/layout/Footer';
import { getTranslations } from 'next-intl/server';
import type { Metadata } from 'next';

const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://quaros.network';

export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }): Promise<Metadata> {
    const { locale } = await params;
    const t = await getTranslations({ locale, namespace: 'HomePage' });

    const title = t('title');
    const description = t('subtitle');

    return {
        title,
        description,
        alternates: {
            canonical: `/${locale}`,
            languages: {
                'en': '/en',
                'vi': '/vi',
            },
        },
        openGraph: {
            title,
            description,
            url: `${baseUrl}/${locale}`,
            type: 'website',
            locale: locale,
            images: [
                {
                    url: `${baseUrl}/og-image.png`,
                    width: 1200,
                    height: 630,
                    alt: title,
                },
            ],
        },
        twitter: {
            card: 'summary_large_image',
            title,
            description,
            images: [`${baseUrl}/og-image.png`],
        },
    };
}

export default function Home() {
    return (
        <>
            <script
                type="application/ld+json"
                dangerouslySetInnerHTML={{
                    __html: JSON.stringify({
                        '@context': 'https://schema.org',
                        '@type': 'Organization',
                        name: 'Goodgo Documentation',
                        description: 'Post-Quantum Security. EVM Compatibility. Web3-Ready.',
                        url: baseUrl,
                        logo: `${baseUrl}/logo.png`,
                        sameAs: [
                            // Add social media links when available
                            // 'https://twitter.com/quarosnetwork',
                            // 'https://github.com/quaros-network',
                        ],
                        contactPoint: {
                            '@type': 'ContactPoint',
                            contactType: 'Technical Support',
                        },
                    }),
                }}
            />
            <script
                type="application/ld+json"
                dangerouslySetInnerHTML={{
                    __html: JSON.stringify({
                        '@context': 'https://schema.org',
                        '@type': 'WebSite',
                        name: 'Goodgo Documentation',
                        url: baseUrl,
                        potentialAction: {
                            '@type': 'SearchAction',
                            target: {
                                '@type': 'EntryPoint',
                                urlTemplate: `${baseUrl}/docs?q={search_term_string}`,
                            },
                            'query-input': 'required name=search_term_string',
                        },
                    }),
                }}
            />
            <main>
                <Navbar />
                <Hero />
                <Products />
                <LargeText />
                <Features />
                <CTA />
                <Footer />
            </main>
        </>
    );
}
