import { breakpointMaxes } from "../../../atoms/breakpoint/index.js";
import useBreakpointWidth from '../useBreakpointWidth';

/**
 * Determine if the current breakpoint measurement is less than the exclusive
 * ceiling of the specified breakpoint.
 *
 * @param {'xs'|'sm'|'md'|'lg'|'xl'} breakpoint
 *   The breakpoint to compare the current measurement to.
 */
const useBreakpointIsAtMost = function useBreakpointIsAtMost(breakpoint, key = 'window') {
  const width = useBreakpointWidth(key);
  const max = breakpointMaxes[breakpoint];
  return width < max;
};
export default useBreakpointIsAtMost;