import type { Auth } from '@/types/auth';

// Extend ImportMeta interface for Vite...
declare module 'vite/client' {
    interface ImportMetaEnv {
        readonly VITE_APP_NAME: string;
        [key: string]: string | boolean | undefined;
    }

    interface ImportMeta {
        readonly env: ImportMetaEnv;
        readonly glob: <T>(pattern: string) => Record<string, () => Promise<T>>;
    }
}

declare module '@inertiajs/core' {
    export interface InertiaConfig {
        sharedPageProps: {
            name: string;
            auth: Auth;
            sidebarOpen: boolean;
            logos?: {
                login?: { path: string } | null;
                header?: { path: string } | null;
            };
            sidebar_data?: Array<{
                name: string;
                href: string;
                icon: string;
                active_rule?: string;
                counts?: number;
                children: Array<{
                    name: string;
                    href: string;
                    icon?: string | null;
                    active_rule?: string;
                    counts?: number;
                    children?: [];
                }>;
            }>;
            [key: string]: unknown;
        };
    }
}

declare function route(
    name?: string,
    params?: Record<string, unknown> | unknown[],
    absolute?: boolean,
): string;

declare module 'vue' {
    interface ComponentCustomProperties {
        $inertia: typeof Router;
        $page: Page;
        $headManager: ReturnType<typeof createHeadManager>;
        route: typeof route;
    }
}
