const f = (n, e, r) => {
  const t = n.date(e);
  return e === null ? "" : n.isValid(t) ? n.formatByString(
    // TODO: should `isValid` narrow `TDate | null` to `NonNullable<TDate>`?
    // Either we allow `TDate | null` to be valid and guard against calling `formatByString` with `null`.
    // Or we ensure `formatByString` is callable with `null`.
    t,
    r
  ) : "";
};
const c = "2019-11-21T22:30:00.000", h = "2019-01-01T09:00:00.000";
function p(n, e, r, t) {
  if (n)
    return n;
  const i = t.formatByString(t.date(h), e).replace(r, "_"), o = t.formatByString(t.date(c), e).replace(r, "_");
  return i === o ? i : (process.env.NODE_ENV, "");
}
function m(n, e, r, t) {
  if (!n)
    return !1;
  const i = t.formatByString(t.date(h), e).replace(r, "_"), o = t.formatByString(t.date(c), e).replace(r, "_"), a = o === i && n === o;
  return !a && t.lib !== "luxon" && process.env.NODE_ENV !== "production" && e.includes("MMM"), a;
}
const M = (n, e) => (r) => {
  let t = 0;
  return r.split("").map((s, i) => {
    if (e.lastIndex = 0, t > n.length - 1)
      return "";
    const o = n[t], a = n[t + 1], l = e.test(s) ? s : "", d = o === "_" ? l : o + l;
    return t += d.length, i === r.length - 1 && a && a !== "_" ? d ? d + a : "" : d;
  }).join("");
};
export {
  m as checkMaskIsValidForCurrentFormat,
  f as getDisplayDate,
  p as getMaskFromCurrentFormat,
  M as maskedDateFormatter
};
