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/plus/pisellReservation/hooks/useReservationDebugLoggers.ts
var useReservationDebugLoggers_exports = {};
__export(useReservationDebugLoggers_exports, {
  useReservationDebugLoggers: () => useReservationDebugLoggers
});
module.exports = __toCommonJS(useReservationDebugLoggers_exports);
var import_react = require("react");
var import_dayjs = __toESM(require("dayjs"));
var import_materials = require("@pisell/materials");
var import_resourceWallLocalStorage = require("../data/resourceWallLocalStorage");
function useReservationDebugLoggers(p) {
  (0, import_react.useEffect)(() => {
    if (process.env.NODE_ENV === "production") return;
    if (!p.isInternalListData) return;
    const raw = p.salesResourceBookings;
    if (raw == null) {
      console.log("[PisellReservation] salesResourceBookings", null);
      return;
    }
    if (!Array.isArray(raw)) {
      console.log("[PisellReservation] salesResourceBookings (non-array)", raw);
      return;
    }
    console.log("[PisellReservation] salesResourceBookings", {
      length: raw.length
    });
  }, [p.isInternalListData, p.salesResourceBookings]);
  (0, import_react.useEffect)(() => {
    var _a;
    if (process.env.NODE_ENV === "production") return;
    if (!(0, import_dayjs.default)(p.debouncedSchedule.date).isValid() || !(0, import_dayjs.default)(p.debouncedSchedule.at).isValid()) {
      return;
    }
    const propTables = (_a = p.dataSourcesProp) == null ? void 0 : _a[p.gridDataSourceKey];
    const sceneEls = p.floorConfigForBindings.sceneElements;
    console.log("[PisellReservation] 当前日程下的展示数据", {
      debouncedScheduleKey: p.debouncedScheduleKey,
      reservationDate: p.debouncedSchedule.date.toISOString(),
      reservationAt: p.debouncedSchedule.at.toISOString(),
      isInternalListData: p.isInternalListData,
      gridDataSourceKey: p.gridDataSourceKey,
      dataSourcesPropTablesLength: Array.isArray(propTables) ? propTables.length : 0,
      floorSceneElementsCount: Array.isArray(sceneEls) ? sceneEls.length : 0,
      floorBoundFormRecordIdsHead: p.floorBoundFormRecordIds.slice(0, 24),
      gridBookingLoading: p.isInternalListData ? p.gridBookingData.loading : void 0,
      floorDayBookingLoading: p.isInternalListData ? p.floorDayBookingData.loading : void 0,
      gridBookingCount: p.isInternalListData ? Array.isArray(p.gridBookingData.data) ? p.gridBookingData.data.length : 0 : void 0,
      floorDayBookingCount: p.isInternalListData ? Array.isArray(p.floorDayBookingData.data) ? p.floorDayBookingData.data.length : 0 : void 0,
      mergedTableRowCount: p.tables.length
    });
  }, [
    p.debouncedScheduleKey,
    p.debouncedSchedule.date,
    p.debouncedSchedule.at,
    p.isInternalListData,
    p.gridBookingData.data,
    p.gridBookingData.loading,
    p.floorDayBookingData.data,
    p.floorDayBookingData.loading,
    p.tables,
    p.dataProp,
    p.dataSourcesProp,
    p.gridDataSourceKey,
    p.floorConfigForBindings.sceneElements,
    p.floorBoundFormRecordIds
  ]);
  (0, import_react.useEffect)(() => {
    if (process.env.NODE_ENV === "production") return;
    if (p.shellBodyView !== "calendar") return;
    const summarizeBooking = (b) => {
      const x = b;
      return {
        id: x.id,
        courtId: x.courtId,
        date: x.date,
        startHour: x.startHour,
        endHour: x.endHour,
        name: x.name,
        kind: x.kind
      };
    };
    const summarizeResource = (r) => ({
      id: r.id,
      name: r.name,
      groupType: r.groupType
    });
    console.log("[PisellReservation] calendar 展示数据", {
      shellBodyView: p.shellBodyView,
      calendarGranularity: p.calendarGranularity,
      anchorDate: p.schedule.date.toISOString(),
      scheduleAt: (0, import_dayjs.default)(p.schedule.at).isValid() ? (0, import_dayjs.default)(p.schedule.at).toISOString() : String(p.schedule.at),
      timelineRange: p.effectiveTimelineRange,
      floorDayBookingLoading: p.floorDayBookingData.loading,
      floorDayBookingCount: Array.isArray(p.floorDayBookingData.data) ? p.floorDayBookingData.data.length : 0,
      calendarOrderedResourceIdsCount: p.calendarOrderedResourceIds.length,
      resourcesCount: p.calendarResources.length,
      resourcesPreview: p.calendarResources.slice(0, 12).map(summarizeResource),
      bookingsCount: p.calendarBookings.length,
      bookingsPreview: p.calendarBookings.slice(0, 12).map(summarizeBooking)
    });
  }, [
    p.shellBodyView,
    p.calendarGranularity,
    p.schedule.date,
    p.schedule.at,
    p.effectiveTimelineRange,
    p.floorDayBookingData.loading,
    p.floorDayBookingData.data,
    p.calendarOrderedResourceIds,
    p.calendarResources,
    p.calendarBookings
  ]);
  (0, import_react.useEffect)(() => {
    if (process.env.NODE_ENV === "production") return;
    if (p.shellBodyView !== "resourceWall") return;
    const filterKey = import_materials.DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY;
    const sp = p.searchParams;
    const fv = sp == null ? void 0 : sp.filter;
    const vals = fv && typeof fv === "object" && fv !== null && typeof fv.values === "object" && fv.values !== null ? fv.values : {};
    const selectedRaw = vals[filterKey];
    const selectedIds = Array.isArray(selectedRaw) ? (0, import_resourceWallLocalStorage.dedupeResourceWallIdsPreserveOrder)(selectedRaw.map((x) => String(x))) : [];
    const allCards = p.venueWallCards;
    const byId = new Map(allCards.map((c) => [String(c.resourceId), c]));
    const visibleCards = selectedIds.length === 0 ? [] : selectedIds.map((id) => {
      const hit = byId.get(id);
      return hit ?? {
        resourceId: id,
        resource: id,
        status: "available"
      };
    });
    const summarize = (c) => {
      var _a;
      return {
        resourceId: c.resourceId,
        resource: c.resource,
        area: c.area,
        status: c.status,
        currentTime: c.currentTime,
        currentBooking: c.currentBooking,
        startsInMin: c.startsInMin,
        lateMin: c.lateMin,
        remainingMin: c.remainingMin,
        nextListHead: (_a = c.nextList) == null ? void 0 : _a.slice(0, 2)
      };
    };
    console.log("[PisellReservation] resourceWall 展示数据", {
      shellBodyView: p.shellBodyView,
      filterFieldKey: filterKey,
      searchParamsFilterValues: vals,
      selectedIds,
      floorDayBookingLoading: p.floorDayBookingData.loading,
      floorBookingExtraParams: p.floorBookingExtraParams,
      cardsCount: allCards.length,
      visibleCount: visibleCards.length,
      cardsPreview: allCards.slice(0, 8).map(summarize),
      visiblePreview: visibleCards.slice(0, 8).map(summarize)
    });
  }, [
    p.shellBodyView,
    p.venueWallCards,
    p.floorDayBookingData.loading,
    p.searchParams,
    p.floorBookingExtraParams
  ]);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useReservationDebugLoggers
});
