const c = ({
  date: n,
  disableFuture: a,
  disablePast: o,
  maxDate: d,
  minDate: i,
  isDateDisabled: s,
  utils: r
}) => {
  const l = r.startOfDay(r.date());
  o && r.isBefore(i, l) && (i = l), a && r.isAfter(d, l) && (d = l);
  let f = n, e = n;
  for (r.isBefore(n, i) && (f = r.date(i), e = null), r.isAfter(n, d) && (e && (e = r.date(d)), f = null); f || e; ) {
    if (f && r.isAfter(f, d) && (f = null), e && r.isBefore(e, i) && (e = null), f) {
      if (!s(f))
        return f;
      f = r.addDays(f, 1);
    }
    if (e) {
      if (!s(e))
        return e;
      e = r.addDays(e, -1);
    }
  }
  return null;
}, t = (n, a) => {
  const o = n.date(a);
  return n.isValid(o) ? o : null;
}, p = (n, a, o) => {
  if (a == null)
    return o;
  const d = n.date(a);
  return n.isValid(d) ? d : o;
};
export {
  c as findClosestEnabledDate,
  p as parseNonNullablePickerDate,
  t as parsePickerInputValue
};
