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/eventBooking/utils.ts
var utils_exports = {};
__export(utils_exports, {
  formatBackgroundColors: () => formatBackgroundColors,
  formatMonthDisplay: () => formatMonthDisplay,
  getScheduleColors: () => getScheduleColors,
  getUsableSchedules: () => getUsableSchedules,
  resourceTitle: () => resourceTitle
});
module.exports = __toCommonJS(utils_exports);
var import_dayjs = __toESM(require("dayjs"));
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var formatBackgroundColors = (colors) => {
  let _colors = Array.from(
    new Set(colors.map((color) => color == null ? void 0 : color.toLocaleLowerCase()) || [])
  ).filter((d) => !!d);
  let colorStr = _colors.map((color, index) => {
    return `${color} ${index * 100 / _colors.length}% ${(index + 1) * 100 / _colors.length}%`;
  }).join(", ");
  if (colorStr) {
    return `conic-gradient(${colorStr})`;
  }
  return "";
};
var getUsableSchedules = (schedule) => {
  if (!schedule) {
    return true;
  }
  if (!schedule.minTime || !schedule.maxTime) {
    return false;
  }
  let currentDate = (0, import_dayjs.default)();
  if (currentDate.isAfter(schedule.maxTime)) {
    return false;
  }
  return true;
};
var getScheduleColors = (schedules) => {
  return formatBackgroundColors(schedules.map((d) => d.color));
};
var formatMonthDisplay = (dateString) => {
  var _a;
  const context = (0, import_useEngineContext.default)();
  const utils = context.appHelper.utils || {};
  const locale = ((_a = utils == null ? void 0 : utils.storage) == null ? void 0 : _a.get("umi_locale")) || "en-US";
  const date = /* @__PURE__ */ new Date(dateString + "-01");
  return date.toLocaleString(locale, { month: "long", year: "numeric" });
};
var resourceTitle = (data) => {
  var _a, _b, _c, _d, _e, _f;
  const context = (0, import_useEngineContext.default)();
  const form = (_c = (_b = (_a = data == null ? void 0 : data.initData) == null ? void 0 : _a.boardSetting) == null ? void 0 : _b.event_v2_form) == null ? void 0 : _c.form;
  const title = ((_d = form == null ? void 0 : form.setting) == null ? void 0 : _d.title) || (form == null ? void 0 : form.title);
  const translation = (_f = (_e = context == null ? void 0 : context.appHelper) == null ? void 0 : _e.utils) == null ? void 0 : _f.translation;
  return translation(title);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatBackgroundColors,
  formatMonthDisplay,
  getScheduleColors,
  getUsableSchedules,
  resourceTitle
});
