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

import type { dialogVariants } from "@/components/Forms/BookingWidget/FormContent/Search/SearchList/Dialog/variants"
import type { AutoCompleteLocation } from "@/server/routers/autocomplete/schema"

export interface SearchProps {
  handlePressEnter: () => void
}

export type SearchHistoryItem = {
  type: "cities" | "hotels"
  id: string
}

type HighlightedIndex = number | null

export interface SearchListProps {
  getItemProps: PropGetters<unknown>["getItemProps"]
  getMenuProps: PropGetters<unknown>["getMenuProps"]
  isOpen: boolean
  handleClearSearchHistory: () => void
  highlightedIndex: HighlightedIndex
  searchInputName: string
  search: string
  searchHistory: AutoCompleteLocation[] | null
  includeTypes: ("cities" | "hotels" | "countries")[]
}

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
}
