import type { PageProps } from '@inertiajs/core';
import type { KviewUiSerializedContext } from '@kview/ui-core/vue';
import type {
    GlobalSearchPreset,
    GlobalSearchSuggestionItem,
} from '@/types/search';

export interface AuthUser {
    id: number;
    name: string;
    email: string;
    avatarUrl: string | null;
}

export interface AuthProps {
    user: AuthUser | null;
    permissions: {
        admin: boolean;
    };
}

export interface FlashProps {
    id: string | null;
    success: string | null;
    error: string | null;
    warning: string | null;
    info: string | null;
    status: string | null;
    toasts: FlashToastProps[];
}

export interface FlashToastProps {
    id?: string | null;
    type?: 'info' | 'success' | 'warning' | 'error';
    title?: string | null;
    message?: string | null;
    icon?: string | null;
    duration?: number | null;
}

export interface PreferenceProps {
    targetCurrency: string;
    itemsPerPage: number;
    amountScaling: 'unit' | 'thousand' | 'million';
    decimalSeparator: '.' | ',';
    dateFormatView: string;
    dateFormatList: string;
}

export interface ApplicationNavigationItem {
    id: string;
    route: string;
    href: string;
    label: string;
    icon: string;
    section: string | null;
    active: boolean;
    footer: boolean;
    modal: string | null;
    inertia: boolean;
}

export interface ApplicationNavigationProps {
    brand: string;
    byline: string;
    version: string | null;
    logoUrl: string;
    homeUrl: string;
    searchUrl: string;
    searchSuggestUrl: string;
    searchInertia: boolean;
    searchPresets: GlobalSearchPreset[];
    searchDefaultActions: GlobalSearchSuggestionItem[];
    logoutUrl: string;
    settings: {
        dataUrl: string;
    };
    account: {
        workspaceLabel: string;
        userSettingsUrl: string;
        dataStatusUrl: string;
        workspaceUrl: string;
        excelTokenUrl: string;
    };
    items: ApplicationNavigationItem[];
}

export interface SharedPageProps extends PageProps {
    auth: AuthProps;
    flash: FlashProps;
    preferences: PreferenceProps;
    locale: string;
    ui: KviewUiSerializedContext;
    navigation: ApplicationNavigationProps;
}

export interface FoundationRoutes {
    index: string;
    navigation: string;
    components: string;
    validate: string;
    componentLab: string;
    shell: string;
    shellSecondary: string;
}

export interface FoundationCheckpoint {
    phase: number;
    label: string;
}

export interface FoundationPageProps extends PageProps {
    checkpoint: FoundationCheckpoint;
    routes: FoundationRoutes;
}

export interface KviewComponentsPageProps extends FoundationPageProps {
    embedded: boolean;
}
