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/venueBooking/components/VenueSelection/index.tsx
var VenueSelection_exports = {};
__export(VenueSelection_exports, {
  default: () => VenueSelection
});
module.exports = __toCommonJS(VenueSelection_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_context = require("../../context");
var import_utils2 = require("../../utils");
var import_DateNavigator = __toESM(require("./components/DateNavigator"));
var import_DayTabs = __toESM(require("./components/DayTabs"));
var import_CourtFilter = __toESM(require("./components/CourtFilter"));
var import_TimeGrid = __toESM(require("./components/TimeGrid"));
function VenueSelection() {
  const { setAnchorDate, anchorDate, fetchWeekData } = (0, import_context.useVenueBookingContext)();
  const tableSectionRef = (0, import_react.useRef)(null);
  const navigateWeek = (0, import_react.useCallback)(async (offset) => {
    const newAnchor = anchorDate.add(offset, "day");
    setAnchorDate(newAnchor);
    const days = (0, import_utils2.getWeekDays)(newAnchor);
    const startDate = (0, import_utils2.formatDateKey)(days[0]);
    const endDate = (0, import_utils2.formatDateKey)(days[days.length - 1]);
    await fetchWeekData(startDate, endDate);
  }, [anchorDate, setAnchorDate, fetchWeekData]);
  function goPrevWeek() {
    navigateWeek(-7);
  }
  function goNextWeek() {
    navigateWeek(7);
  }
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "rounded-b-[24px] bg-white p-3 shadow-[0_10px_40px_rgba(20,20,20,0.06)] ring-1 ring-black/6 md:rounded-[28px] md:p-6" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "flex flex-col gap-2 xl:flex-row xl:items-center xl:justify-between" }, /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h2", { className: "text-2xl font-extrabold leading-tight text-zinc-900 md:text-[30px]" }, import_utils.locales.getText("pisell2.venue.step1.title") || "选择场地"), /* @__PURE__ */ import_react.default.createElement("p", { className: "mt-1 text-xs leading-5 text-zinc-500 md:mt-2 md:text-sm md:leading-6" }, import_utils.locales.getText("pisell2.venue.step1.subtitle") || "仅显示可用时段和价格。")), /* @__PURE__ */ import_react.default.createElement(import_DateNavigator.default, { onPrevWeek: goPrevWeek, onNextWeek: goNextWeek })), /* @__PURE__ */ import_react.default.createElement("div", { className: "mt-3 md:mt-5" }, /* @__PURE__ */ import_react.default.createElement(import_DayTabs.default, { onPrevWeek: goPrevWeek, onNextWeek: goNextWeek })), /* @__PURE__ */ import_react.default.createElement(import_CourtFilter.default, null)), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      ref: tableSectionRef,
      className: "w-full max-w-full isolate rounded-[28px] bg-white shadow-[0_10px_40px_rgba(20,20,20,0.06)] ring-1 ring-black/6"
    },
    /* @__PURE__ */ import_react.default.createElement(import_TimeGrid.default, null)
  ));
}
