import { dialogVariants } from "@/components/Forms/BookingWidget/FormContent/Search/SearchList/Dialog/variants"

import type { VariantProps } from "class-variance-authority"
import type { PropGetters } from "downshift"

import type { Location, Locations } from "../trpc/routers/hotel/locations"

export interface SearchProps {
  locations: Locations
}

type HighlightedIndex = number | null

export interface SearchListProps {
  getItemProps: PropGetters<unknown>["getItemProps"]
  getMenuProps: PropGetters<unknown>["getMenuProps"]
  isOpen: boolean
  handleClearSearchHistory: () => void
  highlightedIndex: HighlightedIndex
  locations: Locations
  search: string
  searchHistory: Locations | null
}

export interface ListProps
  extends Pick<
    SearchListProps,
    "getItemProps" | "highlightedIndex" | "locations"
  > {
  initialIndex?: number
  label?: string
}

export interface ListItemProps
  extends Pick<SearchListProps, "getItemProps" | "highlightedIndex"> {
  index: number
  location: Location
}

export interface DialogProps
  extends React.PropsWithChildren,
    VariantProps<typeof dialogVariants>,
    Pick<SearchListProps, "getMenuProps"> {
  className?: string
}

export interface ErrorDialogProps
  extends React.PropsWithChildren,
    Pick<SearchListProps, "getMenuProps"> {}

export interface ClearSearchButtonProps
  extends Pick<
    SearchListProps,
    "getItemProps" | "handleClearSearchHistory" | "highlightedIndex"
  > {
  index: number
}
