import * as React from 'react';
import { useMemo } from 'react';
import { D as DateTime } from './luxon-wpz4A-OQ.js';
import { jsxs } from 'react/jsx-runtime';

import './TimezoneMessage.css';const SvgEvent = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M16 13h-3c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zm0-10v1H8V3c0-.55-.45-1-1-1s-1 .45-1 1v1H5c-1.11 0-1.99.9-1.99 2L3 20a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-1V3c0-.55-.45-1-1-1s-1 .45-1 1zm2 17H6c-.55 0-1-.45-1-1V9h14v10c0 .55-.45 1-1 1z" }));

const DateModeToFormatMap = {
  "mm/dd/yyyy": "MM/dd/yyyy",
  "dd/mm/yyyy": "dd/MM/yyyy",
  "yyyy/mm/dd": "yyyy/MM/dd"
};
const DateModeToPlaceholderMap = {
  "dd/mm/yyyy": "__/__/____",
  "mm/dd/yyyy": "__/__/____",
  "yyyy/mm/dd": "____/__/__"
};

function jsDateToUtcDateTime(jsDate) {
  return DateTime.utc(
    jsDate.getFullYear(),
    jsDate.getMonth() + 1,
    jsDate.getDate()
  );
}
function isoToUtcDate(isoString) {
  const parsed = DateTime.fromISO(isoString, { setZone: true });
  return DateTime.utc(parsed.year, parsed.month, parsed.day);
}
function convertStringToDate(v) {
  if (v === void 0 || v === null) {
    return v;
  }
  const date = DateTime.fromISO(v, { setZone: true, zone: "utc" }).startOf(
    "day"
  );
  if (date.isValid) {
    return date;
  }
  return null;
}
function validateDate({
  date,
  constraints
}) {
  const { required, unavailable, minDate, maxDate } = constraints;
  if (!date) {
    return required ? false : true;
  }
  if (unavailable?.dates?.some((d) => d.equals(date))) {
    return false;
  }
  if (unavailable?.daysOfWeek?.includes(date.weekday)) {
    return false;
  }
  if (minDate && date < minDate) {
    return false;
  }
  if (maxDate && date > maxDate) {
    return false;
  }
  return true;
}

const styles = {
	"timezone-message": "_timezone-message_1fnr4_1"
};

function TimezoneMessage({ timezone }) {
  const localTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  const showMessage = timezone && timezone !== localTimezone;
  const abbreviation = useMemo(() => {
    if (!timezone) return "";
    return DateTime.now().setZone(timezone).offsetNameShort ?? "";
  }, [timezone]);
  if (!showMessage) return null;
  return /* @__PURE__ */ jsxs("span", { className: styles["timezone-message"], "data-testid": "timezone-message", children: [
    "Dates shown in ",
    abbreviation
  ] });
}

export { DateModeToPlaceholderMap as D, SvgEvent as S, TimezoneMessage as T, DateModeToFormatMap as a, convertStringToDate as c, isoToUtcDate as i, jsDateToUtcDateTime as j, validateDate as v };
//# sourceMappingURL=TimezoneMessage-BrKB_psP.js.map
