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/schedules/calendar/calendarItem.tsx
var calendarItem_exports = {};
__export(calendarItem_exports, {
  default: () => calendarItem_default
});
module.exports = __toCommonJS(calendarItem_exports);
var import_antd = require("antd");
var import_dayjs = __toESM(require("dayjs"));
var import_react = __toESM(require("react"));
var import_utils = require("../products/utils");
var CalendarItem = (props) => {
  const { month, schedulesData, selectDate, onSelect, isEdit } = props;
  const scheduleMap = (0, import_react.useMemo)(
    () => new Map(
      schedulesData.map((schedule) => [schedule.date, schedule])
    ),
    [schedulesData]
  );
  let startDate = (0, import_dayjs.default)(month).startOf("month").format("YYYY-MM-DD");
  let endDate = (0, import_dayjs.default)(month).endOf("month").format("YYYY-MM-DD");
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "month-item" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "caleddar-month" }, (0, import_dayjs.default)(month).format("MMMM")), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Calendar,
    {
      headerRender: () => null,
      fullscreen: false,
      value: (0, import_dayjs.default)(month),
      disabledDate: (currentDate) => {
        return currentDate.isAfter(endDate) || currentDate.isBefore(startDate);
      },
      fullCellRender: (e) => {
        const currentDayText = e.format("YYYY-MM-DD");
        const currentDayData = scheduleMap.get(currentDayText);
        const isCurrentMonth = e.format("YYYY-MM") === month;
        const isSelectDate = currentDayText === selectDate;
        const isExcluded = currentDayData == null ? void 0 : currentDayData.isExcluded;
        let style = {};
        const colors = !isEdit ? ["#7D89B0"] : (currentDayData == null ? void 0 : currentDayData.color) || [];
        style = {
          background: (0, import_utils.formatBackgroundColors)(colors)
        };
        if (e.isAfter(endDate) || e.isBefore(startDate)) {
          return e.date();
        }
        return /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            className: `caleddar-date-cell ${isSelectDate ? "select" : ""} ${isExcluded ? "excluded" : ""}`,
            onClick: () => onSelect(currentDayText, scheduleMap.get(currentDayText))
          },
          /* @__PURE__ */ import_react.default.createElement(
            "div",
            {
              className: `caleddar-date ${colors.filter(Boolean).length ? "has-status" : ""} ${isCurrentMonth ? "" : "disabled-date"}`,
              style
            },
            e.date()
          )
        );
      }
    }
  ));
};
var calendarItem_default = CalendarItem;
