import type { PageProps } from '@inertiajs/core';
import type { Component } from 'vue';

export type SearchResultIdentifier = string | number;

export interface GlobalSearchPreset {
    label: string;
    query: string;
}

export interface GlobalSearchSuggestionItem {
    title: string;
    eyebrow: string;
    kind?: 'search' | 'create';
    meta?: string | null;
    icon?: string | null;
    url: string;
    inertia?: boolean;
}

export interface GlobalSearchSuggestionGroup {
    label: string;
    items: readonly GlobalSearchSuggestionItem[];
}

export interface GlobalSearchSuggestionPayload {
    query: string;
    groups: readonly GlobalSearchSuggestionGroup[];
    actions: readonly GlobalSearchSuggestionItem[];
}

export interface SearchResultItem {
    id: SearchResultIdentifier;
    title: string;
    href: string;
    icon?: string | null;
    eyebrow?: string | null;
    meta?: string | null;
    linkProps?: Record<string, unknown>;
}

export interface SearchResultGroupData {
    id: string;
    title: string;
    description?: string | null;
    icon?: string | null;
    results: readonly SearchResultItem[];
    emptyTitle: string;
    emptyText: string;
}

export interface SearchPageProps extends PageProps {
    query: string;
    searchUrl: string;
    groups: readonly SearchResultGroupData[];
}

export type SearchLinkComponent = Component | string;
