var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/ticketBooking/utils/formatTime.ts
var formatTime_exports = {};
__export(formatTime_exports, {
  formatMultiDayDate: () => formatMultiDayDate,
  getServiceTime: () => getServiceTime,
  isEn: () => isEn
});
module.exports = __toCommonJS(formatTime_exports);
var import_dayjs = __toESM(require("dayjs"));
var import_utils = require("@pisell/utils");
var import_zh_cn = require("dayjs/locale/zh-cn");
var import_en = require("dayjs/locale/en");
var import_zh_tw = require("dayjs/locale/zh-tw");
var import_ja = require("dayjs/locale/ja");
var import_pt = require("dayjs/locale/pt");
var isEn = (item) => {
  const locale = (item == null ? void 0 : item.locale) || "en-US";
  const _isEn = locale === "en-US" || locale === "en";
  const localeTypes = {
    "en-US": "en",
    "zh-CN": "zh-cn",
    "zh-HK": "zh-tw",
    "ja": "ja",
    "pt": "pt"
  };
  import_dayjs.default.locale(localeTypes[locale]);
  return _isEn;
};
var formatMultiDayDate = (item) => {
  const _isEn = isEn(item);
  const startDate = (0, import_dayjs.default)(item == null ? void 0 : item.start_date);
  const endDate = (0, import_dayjs.default)(item == null ? void 0 : item.end_date);
  const _format = _isEn ? "ddd, DD/MM/YYYY" : "YYYY-MM-DD，ddd";
  const date = `${startDate.format(_format)} ~ ${endDate.format(_format)}`;
  return date;
};
var getServiceTime = (item, currentDate, utils) => {
  var _a, _b, _c, _d;
  if (!(0, import_dayjs.default)(currentDate).isValid()) return "";
  const locale = (item == null ? void 0 : item.locale) || ((_a = utils == null ? void 0 : utils.storage) == null ? void 0 : _a.get("umi_locale")) || "en-US";
  const isEn2 = locale === "en-US" || locale === "en";
  const localeTypes = {
    "en-US": "en",
    "zh-CN": "zh-cn",
    "zh-HK": "zh-tw",
    "ja": "ja",
    "pt": "pt"
  };
  import_dayjs.default.locale(localeTypes[locale]);
  let startDate = (0, import_dayjs.default)(item == null ? void 0 : item.start_date);
  let endDate = (0, import_dayjs.default)(item == null ? void 0 : item.end_date);
  let diffInDays = (item == null ? void 0 : item.custom_day_count) || endDate.diff(startDate, "day");
  if (item == null ? void 0 : item.duration_type) {
    const sameDay = startDate.isSame(endDate, "day");
    const dateFormat = isEn2 ? "DD/MM/YYYY" : "YYYY-MM-DD";
    const timeFormat = "HH:mm";
    const startTime = (item == null ? void 0 : item.start_time) || startDate.format(timeFormat);
    const endTime = (item == null ? void 0 : item.end_time) || endDate.format(timeFormat);
    let dateTime = "";
    if (sameDay) {
      if (isEn2) {
        dateTime = `${startTime} ~ ${endTime} ${startDate.format(dateFormat)}`;
      } else {
        dateTime = `${startDate.format(dateFormat)} ${startTime} ~ ${endTime}`;
      }
    } else {
      if (isEn2) {
        dateTime = `${startTime} ${startDate.format(dateFormat)} ~ ${endTime} ${endDate.format(dateFormat)}`;
      } else {
        dateTime = `${startDate.format(dateFormat)} ${startTime} ~ ${endDate.format(dateFormat)} ${endTime}`;
      }
    }
    const startDateTime = `${startDate.format("YYYY-MM-DD")} ${startTime}`;
    const endDateTime = `${endDate.format("YYYY-MM-DD")} ${endTime}`;
    let _duration = (0, import_dayjs.default)(endDateTime).diff((0, import_dayjs.default)(startDateTime), item == null ? void 0 : item.duration_type);
    let durationText = "";
    if ((item == null ? void 0 : item.duration_type) === "minutes") {
      const hours = Math.floor(_duration / 60);
      const minutes = _duration % 60;
      durationText = import_utils.locales.getText("pisell2.product.card.hour.minute")(hours, minutes);
    } else if ((item == null ? void 0 : item.duration_type) === "days") {
      durationText = import_utils.locales.getText("pisell2.product.card.day")(_duration);
    } else {
      durationText = `${_duration}`;
    }
    return `${dateTime} (${durationText})`;
  }
  let _format = isEn2 ? "ddd, DD/MM/YYYY" : "YYYY-MM-DD，ddd";
  if ((item == null ? void 0 : item.hasOwnProperty("format")) && ((_b = item == null ? void 0 : item.format) == null ? void 0 : _b.length) > 0) {
    _format = isEn2 ? (_c = item == null ? void 0 : item.format) == null ? void 0 : _c[0] : (_d = item == null ? void 0 : item.format) == null ? void 0 : _d[1];
  }
  if (item == null ? void 0 : item.show_time) {
    startDate = (0, import_dayjs.default)((item == null ? void 0 : item.start_time) ? `${item == null ? void 0 : item.start_date} ${item == null ? void 0 : item.start_time}` : startDate.format("YYYY-MM-DD HH:mm"));
    endDate = (0, import_dayjs.default)((item == null ? void 0 : item.end_time) ? `${item == null ? void 0 : item.end_date} ${item == null ? void 0 : item.end_time}` : endDate.format("YYYY-MM-DD HH:mm"));
  }
  if ((item == null ? void 0 : item.duration_type) === "minutes") {
    diffInDays = endDate.diff(startDate, "minute");
  }
  const date = `${startDate.format(_format)} ~ ${endDate.format(_format)}`;
  let text = import_utils.locales.getText("pisell2.product.card.day")(diffInDays);
  if (item == null ? void 0 : item.custom_day_count) {
    text = import_utils.locales.getText("pisell2.product.card.day.event")(diffInDays);
  }
  const textTypes = {
    "minutes": import_utils.locales.getText("pisell2.product.card.minute")(diffInDays),
    "event": import_utils.locales.getText("pisell2.product.card.day.event")(diffInDays)
  };
  text = (textTypes == null ? void 0 : textTypes[item == null ? void 0 : item.duration_type]) || text;
  let duration = `${diffInDays}${text}`;
  return `${date} (${duration})`;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatMultiDayDate,
  getServiceTime,
  isEn
});
