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/pisellRecordBoard/shellFrame/Calendar/view/day/useBookingCalendarDaySelection.ts
var useBookingCalendarDaySelection_exports = {};
__export(useBookingCalendarDaySelection_exports, {
  useBookingCalendarDaySelection: () => useBookingCalendarDaySelection
});
module.exports = __toCommonJS(useBookingCalendarDaySelection_exports);
var import_react = require("react");
var import_bookingCalendarDateUtils = require("../../utils/bookingCalendarDateUtils");
function useBookingCalendarDaySelection(dayKey, bookings, hourSlots, slotStepHours, courts, selectedFreeSlots, selectedBlockSlots, setSelectedFreeSlots, setSelectedBlockSlots) {
  const isFreeSelected = (0, import_react.useCallback)(
    (courtId, hour) => selectedFreeSlots.some(
      (slot) => slot.courtId === courtId && slot.date === dayKey && slot.hour === hour
    ),
    [selectedFreeSlots, dayKey]
  );
  const isBlockSelected = (0, import_react.useCallback)(
    (courtId, hour) => selectedBlockSlots.some(
      (slot) => slot.courtId === courtId && slot.date === dayKey && slot.hour === hour
    ),
    [selectedBlockSlots, dayKey]
  );
  const toggleSlot = (0, import_react.useCallback)(
    (courtId, hour) => {
      const existing = (0, import_bookingCalendarDateUtils.dayOccupancy)(
        courtId,
        dayKey,
        bookings,
        hourSlots,
        slotStepHours
      )[hour];
      const court = courts.find((c) => c.id === courtId);
      const slot = {
        courtId,
        court: court == null ? void 0 : court.name,
        date: dayKey,
        hour
      };
      if (!existing) {
        setSelectedFreeSlots(
          (prev) => prev.some((s) => (0, import_bookingCalendarDateUtils.sameSlot)(s, slot)) ? prev.filter((s) => !(0, import_bookingCalendarDateUtils.sameSlot)(s, slot)) : [...prev, slot]
        );
        return;
      }
      if (existing.kind === "block") {
        setSelectedBlockSlots(
          (prev) => prev.some((s) => (0, import_bookingCalendarDateUtils.sameSlot)(s, slot)) ? prev.filter((s) => !(0, import_bookingCalendarDateUtils.sameSlot)(s, slot)) : [...prev, slot]
        );
      }
    },
    [
      bookings,
      courts,
      dayKey,
      hourSlots,
      setSelectedBlockSlots,
      setSelectedFreeSlots,
      slotStepHours
    ]
  );
  return { isFreeSelected, isBlockSelected, toggleSlot };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useBookingCalendarDaySelection
});
