var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellDateTimeDisplay/utils/formatDate.ts
var formatDate_exports = {};
__export(formatDate_exports, {
  formatDate: () => formatDate
});
module.exports = __toCommonJS(formatDate_exports);
var import_localeUtils = require("./localeUtils");
function formatDate(date, config) {
  const {
    order = "YMD",
    shortMonth = true,
    numericMonth = false,
    showChineseUnit = false,
    separator = "-",
    showYear = false,
    showMonth = true,
    showDay = true,
    useCommaBeforeYear = true
  } = config || {};
  const locale = date.locale();
  const isChinese = (0, import_localeUtils.isChinese)(locale);
  const parts = [];
  const yearFormat = isChinese && showChineseUnit ? "YYYY年" : "YYYY";
  let monthFormat = "";
  if (numericMonth) {
    monthFormat = isChinese && showChineseUnit ? "M月" : "MM";
  } else {
    if (isChinese) {
      monthFormat = showChineseUnit ? "M月" : "M";
    } else {
      monthFormat = shortMonth ? "MMM" : "MMMM";
    }
  }
  const dayFormat = isChinese && showChineseUnit ? "D日" : "DD";
  switch (order) {
    case "YMD":
      if (showYear) parts.push(yearFormat);
      if (showMonth) parts.push(monthFormat);
      if (showDay) parts.push(dayFormat);
      break;
    case "MDY":
      if (showMonth) parts.push(monthFormat);
      if (showDay) parts.push(dayFormat);
      if (showYear) parts.push(yearFormat);
      break;
    case "DMY":
      if (showDay) parts.push(dayFormat);
      if (showMonth) parts.push(monthFormat);
      if (showYear) parts.push(yearFormat);
      break;
  }
  if (parts.length === 0) {
    return "";
  }
  if (isChinese && showChineseUnit) {
    return date.format(parts.join(""));
  }
  if (order === "MDY" && !isChinese) {
    const formatted = date.format(parts.join(" "));
    if (showYear && showMonth && showDay) {
      const [month, day, year] = formatted.split(" ");
      return `${month} ${day}, ${year}`;
    }
    if (showYear && showDay && !showMonth) {
      const [day, year] = formatted.split(" ");
      return `${day}, ${year}`;
    }
    return formatted;
  }
  if (order === "DMY" && !isChinese) {
    const formatted = date.format(parts.join(" "));
    if (showYear && showMonth && showDay && useCommaBeforeYear) {
      const [day, month, year] = formatted.split(" ");
      return `${day} ${month}, ${year}`;
    }
    if (showYear && showDay && !showMonth && useCommaBeforeYear) {
      const [day, year] = formatted.split(" ");
      return `${day}, ${year}`;
    }
    return formatted;
  }
  return date.format(parts.join(separator));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatDate
});
