import useResizeObserver from "../../../hooks/useResizeObserver/index.js";
import { optionsByFormat, optionsBySize } from './formatOptions';
import sizes from './sizes';
const useFormatOptions = function useFormatOptions(format, expandable, includeDescription) {
  const [ref, [width]] = useResizeObserver();

  // Get our default options from our given format
  const defaultOptions = optionsByFormat[format];

  // Find the size based on the container width
  const matchingSize = sizes.find(step => width < step.max);
  const sizeOptions = optionsBySize[matchingSize.key];

  // Override the format options if needed
  const formatOptions = {
    ...defaultOptions,
    ...sizeOptions,
    size: matchingSize.key,
    expandable,
    format
  };
  if (includeDescription) {
    formatOptions.showContestDescription = true;
  }
  return [ref, formatOptions];
};
export default useFormatOptions;