"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
require("dayjs");
const shiftTimezone = require("../../utils/shift-timezone.cjs");
const useDatesContext = require("../DatesProvider/use-dates-context.cjs");
function formatValue(value, type) {
  const ctx = useDatesContext.useDatesContext();
  const formatDateWithTimezone = (date) => {
    return shiftTimezone.shiftTimezone("remove", date, ctx.getTimezone()).toISOString();
  };
  if (type === "range" && Array.isArray(value)) {
    const [startDate, endDate] = value;
    if (!startDate) {
      return "";
    }
    if (!endDate) {
      return `${formatDateWithTimezone(startDate)} –`;
    }
    return `${formatDateWithTimezone(startDate)} – ${formatDateWithTimezone(endDate)}`;
  }
  if (type === "multiple" && Array.isArray(value)) {
    return value.map((date) => date && formatDateWithTimezone(date)).filter(Boolean).join(", ");
  }
  if (!Array.isArray(value) && value) {
    return formatDateWithTimezone(value);
  }
  return "";
}
function HiddenDatesInput({ value, type, name, form }) {
  return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", value: formatValue(value, type), name, form });
}
HiddenDatesInput.displayName = "@mantine/dates/HiddenDatesInput";
exports.HiddenDatesInput = HiddenDatesInput;
