import type {
  AutoCorrect, ContentListPage, DidYouMean, Navigation, PrimaryList, SecondaryList, RelatedSearch,
  ProductParams, ProductListParams, SearchParams, PrimaryListPageBody, NavigationPageBody, ContentListPageBody
} from './common/mod.ts';


export type SearchOrigin = 'ORGANIC' | 'PHRASE_SUGGEST' | 'DID_YOU_MEAN' | 'UNDO_AUTO_CORRECT' | 'RELATED_SEARCHES' | 'RECENT_SEARCH';

export interface SearchPageParams extends ProductParams, ProductListParams, SearchParams {
  /**
   * Used to correctly track and analyze search behavior. For example, use `'UNDO_AUTO_CORRECT'`
   * with a search query to avoid the query being autocorrected.
   */
  origin?: SearchOrigin;
  /** The selected category, will return all categories above and including */
  selectedCategory?: string;
  /** Show an expanded view of the secondary list instead of the primary list */
  viewAllSecondary?: boolean;
}

export interface SearchPageBody extends PrimaryListPageBody, NavigationPageBody, ContentListPageBody {}

export interface SearchPage extends ContentListPage {
  /** Search query */
  q: string;
  /** Autocorrected the query. Information about search results */
  autoCorrect?: AutoCorrect;
  /** Did you mean suggestions */
  didYouMean: DidYouMean[];
  /** A product list with facets, sort orders and hit count */
  primaryList: PrimaryList;
  /** Navigation, can be `undefined` if disabled */
  navigation?: Navigation;
  /** An extension of the PrimaryList, that can show e.g. relaxed or related listing of products */
  secondaryList?: SecondaryList;
  /** A list of phrases related to the search phrase. */
  relatedSearches?: RelatedSearch[];
}
