import * as r from "react";
import { useValidation as D } from "./index-useValidation.js";
import { useLocalizationContext as c } from "./index-useUtils.js";
import { parseNonNullablePickerDate as o } from "./index-date-utils.js";
const u = ({
  props: t,
  value: s,
  adapter: e
}) => {
  const l = e.utils.date(), a = e.utils.date(s), i = o(e.utils, t.minDate, e.defaultDates.minDate), n = o(e.utils, t.maxDate, e.defaultDates.maxDate);
  if (a === null)
    return null;
  switch (!0) {
    case !e.utils.isValid(s):
      return "invalidDate";
    case !!(t.shouldDisableDate && t.shouldDisableDate(a)):
      return "shouldDisableDate";
    case !!(t.disableFuture && e.utils.isAfterDay(a, l)):
      return "disableFuture";
    case !!(t.disablePast && e.utils.isBeforeDay(a, l)):
      return "disablePast";
    case !!(i && e.utils.isBeforeDay(a, i)):
      return "minDate";
    case !!(n && e.utils.isAfterDay(a, n)):
      return "maxDate";
    default:
      return null;
  }
}, B = ({
  shouldDisableDate: t,
  minDate: s,
  maxDate: e,
  disableFuture: l,
  disablePast: a
}) => {
  const i = c();
  return r.useCallback((n) => u({
    adapter: i,
    value: n,
    props: {
      shouldDisableDate: t,
      minDate: s,
      maxDate: e,
      disableFuture: l,
      disablePast: a
    }
  }) !== null, [i, t, s, e, l, a]);
}, m = (t, s) => t === s, x = (t) => D(t, u, m);
export {
  m as isSameDateError,
  x as useDateValidation,
  B as useIsDayDisabled,
  u as validateDate
};
