function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
import { useEffect } from 'react';
import dayjs from 'dayjs';
import { DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY } from '@pisell/materials';
import { dedupeResourceWallIdsPreserveOrder } from "../data/resourceWallLocalStorage";
/**
 * 非生产环境调试日志（与 PisellReservation 旧版顺序、deps 一致）。
 */
export function useReservationDebugLoggers(p) {
  useEffect(function () {
    if (process.env.NODE_ENV === 'production') return;
    if (!p.isInternalListData) return;
    var raw = p.salesResourceBookings;
    if (raw == null) {
      // eslint-disable-next-line no-console
      console.log('[PisellReservation] salesResourceBookings', null);
      return;
    }
    if (!Array.isArray(raw)) {
      // eslint-disable-next-line no-console
      console.log('[PisellReservation] salesResourceBookings (non-array)', raw);
      return;
    }
    // eslint-disable-next-line no-console
    console.log('[PisellReservation] salesResourceBookings', {
      length: raw.length
    });
  }, [p.isInternalListData, p.salesResourceBookings]);
  useEffect(function () {
    var _p$dataSourcesProp;
    if (process.env.NODE_ENV === 'production') return;
    if (!dayjs(p.debouncedSchedule.date).isValid() || !dayjs(p.debouncedSchedule.at).isValid()) {
      return;
    }
    var propTables = (_p$dataSourcesProp = p.dataSourcesProp) === null || _p$dataSourcesProp === void 0 ? void 0 : _p$dataSourcesProp[p.gridDataSourceKey];
    var sceneEls = p.floorConfigForBindings.sceneElements;
    // eslint-disable-next-line no-console
    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 : undefined,
      floorDayBookingLoading: p.isInternalListData ? p.floorDayBookingData.loading : undefined,
      gridBookingCount: p.isInternalListData ? Array.isArray(p.gridBookingData.data) ? p.gridBookingData.data.length : 0 : undefined,
      floorDayBookingCount: p.isInternalListData ? Array.isArray(p.floorDayBookingData.data) ? p.floorDayBookingData.data.length : 0 : undefined,
      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]);
  useEffect(function () {
    if (process.env.NODE_ENV === 'production') return;
    if (p.shellBodyView !== 'calendar') return;
    var summarizeBooking = function summarizeBooking(b) {
      var x = b;
      return {
        id: x.id,
        courtId: x.courtId,
        date: x.date,
        startHour: x.startHour,
        endHour: x.endHour,
        name: x.name,
        kind: x.kind
      };
    };
    var summarizeResource = function summarizeResource(r) {
      return {
        id: r.id,
        name: r.name,
        groupType: r.groupType
      };
    };
    // eslint-disable-next-line no-console
    console.log('[PisellReservation] calendar 展示数据', {
      shellBodyView: p.shellBodyView,
      calendarGranularity: p.calendarGranularity,
      anchorDate: p.schedule.date.toISOString(),
      scheduleAt: dayjs(p.schedule.at).isValid() ? dayjs(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]);
  useEffect(function () {
    if (process.env.NODE_ENV === 'production') return;
    if (p.shellBodyView !== 'resourceWall') return;
    var filterKey = DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY;
    var sp = p.searchParams;
    var fv = sp === null || sp === void 0 ? void 0 : sp.filter;
    var vals = fv && _typeof(fv) === 'object' && fv !== null && _typeof(fv.values) === 'object' && fv.values !== null ? fv.values : {};
    var selectedRaw = vals[filterKey];
    var selectedIds = Array.isArray(selectedRaw) ? dedupeResourceWallIdsPreserveOrder(selectedRaw.map(function (x) {
      return String(x);
    })) : [];
    var allCards = p.venueWallCards;
    var byId = new Map(allCards.map(function (c) {
      return [String(c.resourceId), c];
    }));
    var visibleCards = selectedIds.length === 0 ? [] : selectedIds.map(function (id) {
      var hit = byId.get(id);
      return hit !== null && hit !== void 0 ? hit : {
        resourceId: id,
        resource: id,
        status: 'available'
      };
    });
    var summarize = function summarize(c) {
      var _c$nextList;
      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: (_c$nextList = c.nextList) === null || _c$nextList === void 0 ? void 0 : _c$nextList.slice(0, 2)
      };
    };
    // eslint-disable-next-line no-console -- 调试资源墙展示数据
    console.log('[PisellReservation] resourceWall 展示数据', {
      shellBodyView: p.shellBodyView,
      filterFieldKey: filterKey,
      searchParamsFilterValues: vals,
      selectedIds: 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]);
}