import { useFilterOptions, defaultFilter } from '../hooks/use-filter-options';
const typeaheadOptionsFilter = (it, searchValue, searchFields, showAll) => {
  return showAll || defaultFilter(it, searchValue, searchFields);
};
export const useVisibleOptions = ({
  formatSearchValue,
  searchValue,
  options,
  searchFields,
  isShowAll
}) => {
  const formattedSearchValue = formatSearchValue && formatSearchValue(searchValue) || searchValue;
  const visibleOptions = useFilterOptions(options, formattedSearchValue ?? '', searchFields ?? [], (it, searchVal, searchFlds) => typeaheadOptionsFilter(it, searchVal, searchFlds, isShowAll));
  const isShowOptions = !(!isShowAll && !formattedSearchValue || !visibleOptions.length);
  return {
    visibleOptions,
    isShowOptions
  };
};