import { contrastDate, isBeyondRangeTime } from './helper';

function useDisable(props) {
  const innerDisabledDate = (date, format, flagDate) => {
    var _props$disabledDate;
    const min = props.minDate && contrastDate(date, props.minDate, format) === -1;
    const max = props.maxDate && contrastDate(date, props.maxDate, format) === 1;
    let isBeyondRange = false;
    if (props.maxRange && flagDate) {
      isBeyondRange = isBeyondRangeTime({
        currentDate: date,
        maxRange: props.maxRange,
        flagDate,
        format
      });
    }
    return min || max || isBeyondRange || ((_props$disabledDate = props.disabledDate) === null || _props$disabledDate === void 0 ? void 0 : _props$disabledDate.call(props, date));
  };
  return {
    innerDisabledDate
  };
}

export { useDisable };
