/**
 * Public site entry point (server-side rendered).
 * The admin panel has its own entry: resources/js/app.tsx.
 *
 * The @inertiajs/vite plugin turns this single createInertiaApp() call into
 * both the browser bootstrap and the SSR render function, and expands the
 * `pages` option into a lazy import map limited to resources/js/pages/site.
 */
import { createInertiaApp } from '@inertiajs/react';
import SiteLayout from '@/site/layouts/site-layout';

void createInertiaApp({
    // Component names arrive as "site/…"; the glob is rooted at pages/site.
    pages: {
        path: './pages/site',
        transform: (name: string) => name.replace(/^site\//, ''),
    },

    layout: () => SiteLayout,

    // <head> comes from the server: every page sends its elements in the
    // `head` prop (App\Seo\HeadBuilder) and Inertia keeps the document head
    // in sync with it — during SSR and on client-side navigation. Pages do
    // not use <Head> for titles or meta tags (docs/SEO.md §4).
    serverHead: true,
    title: (title) => title,

    strictMode: true,

    progress: {
        color: '#c8a97a',
        showSpinner: false,
    },

    defaults: {
        // Cross-fade between pages where the View Transitions API exists.
        visitOptions: (_href, options) => ({
            viewTransition: true,
            ...options,
        }),
    },
});
