function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
// @ts-nocheck
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
import { CalendarGridBookingClipMarkers } from "../bookingCalendarViewShared";
import { CALENDAR_WEEKDAY_IDS, tCal } from "../calendarI18n";
import { getGridBookingRowStateClasses } from "../utils/BookingCalendarStyle";
import { assignPerDateLanesCrossDayUnified, clipBookingDaySpanToWindow, fmtDate, formatHourLabel, formatShortMonthDay, getBookingSegmentForDate, isCrossDayBooking } from "../utils/bookingCalendarDateUtils";
import { MONTH_VIEW_BANNER_GAP, MONTH_VIEW_BANNER_H, MONTH_VIEW_BANNER_PAD_Y, MONTH_VIEW_DAY_HEADER_H, MONTH_VIEW_MAX_LANE, MONTH_VIEW_MORE_TILE_PX, monthViewEffectiveMaxLanes } from "../const/bookingCalendarConstants";
import { mapAxisSpan, dayGridUnit } from "../utils/bookingCalendarAxis";
var MONTH_GRID_COLS = 7;

/**
 * 月视图：5 行 × 7 列。
 *
 * 跨日 booking 用 absolute overlay 跨日列 banner 渲染（M1：跨自然周边界续画 + 端部 ◀/▶）：
 *   - 每周内跨日 booking 占统一 lane，单日 booking 逐日填剩余空位；
 *   - 行高内自适应 effectiveMaxLane，超出 → cell 级 `+N` tile；
 *   - cell 层只负责日期 header / 点击跳日 / drop 改期，不再渲染 booking 列表（被 overlay 替代）。
 */
export function BookingCalendarMonthView(_ref) {
  var isLight = _ref.isLight,
    anchorDate = _ref.anchorDate,
    monthDays = _ref.monthDays,
    bookings = _ref.bookings,
    goToDayFromCell = _ref.goToDayFromCell,
    handleGridDropMove = _ref.handleGridDropMove,
    setDraggingItem = _ref.setDraggingItem,
    openBookingDetail = _ref.openBookingDetail,
    setOverflowListModal = _ref.setOverflowListModal,
    renderMonthWeekBooking = _ref.renderMonthWeekBooking,
    tickFillMode = _ref.tickFillMode;
  var todayKey = fmtDate(new Date());
  var weekRows = useMemo(function () {
    var out = [];
    for (var i = 0; i < monthDays.length; i += MONTH_GRID_COLS) {
      out.push(monthDays.slice(i, i + MONTH_GRID_COLS));
    }
    return out;
  }, [monthDays]);

  /** 月视图不可纵向滚动：按容器均分给每行的 banner 区高度，动态决定展示几条 */
  var monthGridBodyRef = useRef(null);
  var _useState = useState(0),
    _useState2 = _slicedToArray(_useState, 2),
    monthGridBodyHeight = _useState2[0],
    setMonthGridBodyHeight = _useState2[1];
  useLayoutEffect(function () {
    var el = monthGridBodyRef.current;
    if (!el) return;
    var measure = function measure() {
      var h = el.getBoundingClientRect().height;
      if (h > 0) setMonthGridBodyHeight(h);
    };
    measure();
    var ro = new ResizeObserver(measure);
    ro.observe(el);
    return function () {
      return ro.disconnect();
    };
  }, [weekRows.length, anchorDate.getFullYear(), anchorDate.getMonth()]);
  var weekBannerZoneHeightPx = useMemo(function () {
    if (monthGridBodyHeight <= 0 || weekRows.length === 0) return 0;
    return Math.max(MONTH_VIEW_BANNER_H, monthGridBodyHeight / weekRows.length - MONTH_VIEW_DAY_HEADER_H);
  }, [monthGridBodyHeight, weekRows.length]);
  return /*#__PURE__*/React.createElement("div", {
    key: "month-".concat(anchorDate.getFullYear(), "-").concat(anchorDate.getMonth()),
    className: "flex min-h-0 flex-1 flex-col"
  }, /*#__PURE__*/React.createElement("div", {
    className: "relative flex min-h-0 flex-1 flex-col overflow-hidden"
  }, /*#__PURE__*/React.createElement("div", {
    className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-auto overflow-y-hidden"
  }, /*#__PURE__*/React.createElement("div", {
    className: "theme-panel flex min-h-[0] min-w-[980px] flex-1 flex-col overflow-hidden"
  }, /*#__PURE__*/React.createElement("div", {
    className: "theme-panel-alt grid shrink-0 grid-cols-7 border-b theme-border shadow-[0_6px_12px_rgba(0,0,0,0.08)]"
  }, CALENDAR_WEEKDAY_IDS.map(function (id) {
    return /*#__PURE__*/React.createElement("div", {
      key: id,
      className: "px-4 py-2.5 text-center text-sm font-medium"
    }, tCal(id));
  })), /*#__PURE__*/React.createElement("div", {
    ref: monthGridBodyRef,
    className: "grid min-h-0 flex-1 grid-cols-7 gap-0",
    style: {
      gridTemplateRows: "repeat(".concat(weekRows.length, ", minmax(0, 1fr))")
    }
  }, weekRows.map(function (week, wIdx) {
    var _week$0$key, _week$;
    return /*#__PURE__*/React.createElement(MonthWeekRow, {
      key: "week-".concat(wIdx, "-").concat((_week$0$key = (_week$ = week[0]) === null || _week$ === void 0 ? void 0 : _week$.key) !== null && _week$0$key !== void 0 ? _week$0$key : wIdx),
      week: week,
      bannerZoneHeightPx: weekBannerZoneHeightPx,
      isLight: isLight,
      todayKey: todayKey,
      bookings: bookings,
      goToDayFromCell: goToDayFromCell,
      handleGridDropMove: handleGridDropMove,
      setDraggingItem: setDraggingItem,
      openBookingDetail: openBookingDetail,
      setOverflowListModal: setOverflowListModal,
      renderMonthWeekBooking: renderMonthWeekBooking,
      tickFillMode: tickFillMode
    });
  }))))));
}

/* --------------------- 月视图周行：cell layer + overlay layer --------------------- */
function MonthWeekRow(_ref2) {
  var _week$0$key2, _week$2, _week$key, _week;
  var week = _ref2.week,
    bannerZoneHeightPx = _ref2.bannerZoneHeightPx,
    isLight = _ref2.isLight,
    todayKey = _ref2.todayKey,
    bookings = _ref2.bookings,
    goToDayFromCell = _ref2.goToDayFromCell,
    handleGridDropMove = _ref2.handleGridDropMove,
    setDraggingItem = _ref2.setDraggingItem,
    openBookingDetail = _ref2.openBookingDetail,
    setOverflowListModal = _ref2.setOverflowListModal,
    renderMonthWeekBooking = _ref2.renderMonthWeekBooking,
    tickFillMode = _ref2.tickFillMode;
  var weekFirstKey = (_week$0$key2 = (_week$2 = week[0]) === null || _week$2 === void 0 ? void 0 : _week$2.key) !== null && _week$0$key2 !== void 0 ? _week$0$key2 : '';
  var weekLastKey = (_week$key = (_week = week[week.length - 1]) === null || _week === void 0 ? void 0 : _week.key) !== null && _week$key !== void 0 ? _week$key : '';
  var dateKeyToCol = useMemo(function () {
    var m = new Map();
    week.forEach(function (d, i) {
      return m.set(d.key, i);
    });
    return m;
  }, [week]);

  /** id → 原始 booking 索引，banner clipped 标记需要回查未截断的 `date/endDate` */
  var bookingById = useMemo(function () {
    var m = new Map();
    var _iterator = _createForOfIteratorHelper(bookings),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var b = _step.value;
        if ((b === null || b === void 0 ? void 0 : b.id) != null) m.set(String(b.id), b);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return m;
  }, [bookings]);

  /** 把 booking 整段截到本周窗口内（同时去重：同 id 只保留 1 条，避免一条 booking 多次出现） */
  var weekClipped = useMemo(function () {
    var seen = new Set();
    var out = [];
    var _iterator2 = _createForOfIteratorHelper(bookings),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var b = _step2.value;
        if ((b === null || b === void 0 ? void 0 : b.id) == null) continue;
        var idKey = String(b.id);
        if (seen.has(idKey)) continue;
        var clipped = clipBookingDaySpanToWindow(b, weekFirstKey, weekLastKey);
        if (!clipped) continue;
        seen.add(idKey);
        out.push(clipped);
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    return out;
  }, [bookings, weekFirstKey, weekLastKey]);

  /** 跨日占统一 lane，单日逐日填位；安静日不会被其它日的 lane 数误伤 */
  var weekDateKeys = useMemo(function () {
    return week.map(function (d) {
      return d.key;
    });
  }, [week]);
  var _useMemo = useMemo(function () {
      var _assignPerDateLanesCr = assignPerDateLanesCrossDayUnified(weekClipped, weekDateKeys),
        perDate = _assignPerDateLanesCr.perDateLanes,
        laneCount = _assignPerDateLanesCr.laneCount;
      return {
        perDateLanes: perDate,
        weekMaxLaneCount: laneCount
      };
    }, [weekClipped, weekDateKeys]),
    perDateLanes = _useMemo.perDateLanes,
    weekMaxLaneCount = _useMemo.weekMaxLaneCount;
  var effectiveMaxLane = useMemo(function () {
    if (bannerZoneHeightPx > 0) {
      return monthViewEffectiveMaxLanes(bannerZoneHeightPx, weekMaxLaneCount);
    }
    return MONTH_VIEW_MAX_LANE;
  }, [bannerZoneHeightPx, weekMaxLaneCount]);

  /** 拆分成可见 banner 与 cell 级 +N：某日 lane >= effectiveMaxLane 才进该日 +N */
  var _useMemo2 = useMemo(function () {
      var bannersOut = [];
      var overflowMap = new Map();
      var pushOverflow = function pushOverflow(dateKey, item) {
        var idKey = String(item.id);
        var arr = overflowMap.get(dateKey);
        if (arr) {
          if (!arr.some(function (x) {
            return String(x.id) === idKey;
          })) arr.push(item);
        } else {
          overflowMap.set(dateKey, [item]);
        }
      };
      var _iterator3 = _createForOfIteratorHelper(weekClipped),
        _step3;
      try {
        for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
          var _bookingById$get, _dateKeyToCol$get, _dateKeyToCol$get2, _b$endDate, _original$date, _ref3, _original$endDate;
          var b = _step3.value;
          var idKey = String(b.id);
          var original = (_bookingById$get = bookingById.get(idKey)) !== null && _bookingById$get !== void 0 ? _bookingById$get : b;
          var displayLane = 0;
          var showBanner = false;
          var _iterator4 = _createForOfIteratorHelper(weekDateKeys),
            _step4;
          try {
            for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
              var _perDateLanes$get;
              var dateKey = _step4.value;
              var lane = (_perDateLanes$get = perDateLanes.get(dateKey)) === null || _perDateLanes$get === void 0 ? void 0 : _perDateLanes$get.get(idKey);
              if (lane === undefined) continue;
              displayLane = lane;
              if (lane < effectiveMaxLane) showBanner = true;
              if (lane >= effectiveMaxLane) pushOverflow(dateKey, original);
            }
          } catch (err) {
            _iterator4.e(err);
          } finally {
            _iterator4.f();
          }
          if (!showBanner) continue;
          var startCol = (_dateKeyToCol$get = dateKeyToCol.get(String(b.date))) !== null && _dateKeyToCol$get !== void 0 ? _dateKeyToCol$get : 0;
          var endCol = (_dateKeyToCol$get2 = dateKeyToCol.get(String((_b$endDate = b.endDate) !== null && _b$endDate !== void 0 ? _b$endDate : b.date))) !== null && _dateKeyToCol$get2 !== void 0 ? _dateKeyToCol$get2 : startCol;
          var origStart = String((_original$date = original === null || original === void 0 ? void 0 : original.date) !== null && _original$date !== void 0 ? _original$date : b.date);
          var origEnd = String((_ref3 = (_original$endDate = original === null || original === void 0 ? void 0 : original.endDate) !== null && _original$endDate !== void 0 ? _original$endDate : original === null || original === void 0 ? void 0 : original.date) !== null && _ref3 !== void 0 ? _ref3 : b.date);
          var clippedLeft = origStart < weekFirstKey;
          var clippedRight = origEnd > weekLastKey;
          bannersOut.push({
            item: original,
            lane: displayLane,
            startCol: startCol,
            endCol: endCol,
            clippedLeft: clippedLeft,
            clippedRight: clippedRight,
            crossDay: isCrossDayBooking(original)
          });
        }
      } catch (err) {
        _iterator3.e(err);
      } finally {
        _iterator3.f();
      }
      return {
        banners: bannersOut,
        overflowByDate: overflowMap
      };
    }, [weekClipped, perDateLanes, weekDateKeys, dateKeyToCol, bookingById, weekFirstKey, weekLastKey, effectiveMaxLane]),
    banners = _useMemo2.banners,
    overflowByDate = _useMemo2.overflowByDate;
  var visibleLanes = Math.min(weekMaxLaneCount, effectiveMaxLane);
  var moreTopOffset = MONTH_VIEW_BANNER_PAD_Y + visibleLanes * (MONTH_VIEW_BANNER_H + MONTH_VIEW_BANNER_GAP);

  /* --------------------- banner / +N tile 百分比轴映射 ---------------------
   * 月行 7 列弹性 1fr，跨自然周已由 weekClipped 逐行切片 → startCol/endCol 为行内列下标。
   * 默认 snap：startUnit=startCol、endUnit=endCol+1（整数列，与小时无关），
   * offset=startCol*(100/7)、size=(endCol-startCol+1)*(100/7)，与旧整列 gridColumn 等价。
   * 月视图无逐日营业时段输入 → 用全天兜底 dayGridMin=0、dayGridSpan=24。
   */
  var dayGridMin = 0;
  var dayGridSpan = 24;
  var monthPctAxis = {
    originUnit: 0,
    scalePerUnit: 100 / 7,
    tickUnit: 1,
    minSize: 0
  };
  return /*#__PURE__*/React.createElement("div", {
    style: {
      gridColumn: '1 / -1',
      position: 'relative',
      minHeight: 0
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: "grid h-full grid-cols-7"
  }, week.map(function (day) {
    var isToday = day.key === todayKey;
    return /*#__PURE__*/React.createElement("button", {
      key: day.key,
      type: "button",
      onClick: function onClick() {
        return goToDayFromCell(day.date, null, "month-".concat(day.key));
      },
      onDragOver: function onDragOver(e) {
        return e.preventDefault();
      },
      onDrop: function onDrop(e) {
        e.preventDefault();
        handleGridDropMove(day.key);
      },
      className: "flex h-full min-h-0 flex-col overflow-hidden border-r border-b theme-border text-left align-top ".concat(day.inMonth ? isLight ? 'theme-grid-cell theme-text' : 'bg-[#1a1b21]' : isLight ? 'theme-grid-muted theme-text-faint' : 'bg-[#111217] text-zinc-600')
    }, /*#__PURE__*/React.createElement("div", {
      className: "flex shrink-0 items-start justify-between gap-1 px-2 pb-1 pt-2"
    }, /*#__PURE__*/React.createElement("div", {
      className: "text-3xl font-semibold leading-none ".concat(isLight ? 'theme-text-soft' : '')
    }, /*#__PURE__*/React.createElement("span", {
      className: "grid h-10 w-10 place-items-center rounded-full leading-none ".concat(isToday ? isLight ? 'ring-2 ring-violet-500/70 bg-violet-50' : 'ring-2 ring-violet-400/60 bg-white/[0.06]' : ''),
      "aria-label": isToday ? 'Today' : undefined
    }, day.date.getDate())), /*#__PURE__*/React.createElement("div", {
      className: "flex shrink-0 gap-1 pt-0.5"
    }, day.bookingCount > 0 && /*#__PURE__*/React.createElement("span", {
      className: "h-2.5 w-2.5 rounded-full bg-violet-500"
    }), (day.blockCount > 0 || day.fullyBooked) && /*#__PURE__*/React.createElement("span", {
      className: "h-2.5 w-2.5 rounded-full bg-red-500"
    }))), /*#__PURE__*/React.createElement("div", {
      className: "min-h-0 flex-1"
    }));
  })), /*#__PURE__*/React.createElement("div", {
    "aria-hidden": true,
    style: {
      position: 'absolute',
      top: MONTH_VIEW_DAY_HEADER_H,
      bottom: 0,
      left: 0,
      right: 0,
      pointerEvents: 'none'
    }
  }, /*#__PURE__*/React.createElement("div", {
    style: {
      position: 'relative',
      width: '100%',
      height: '100%'
    }
  }, banners.map(function (p) {
    var _p$item, _p$item2, _p$item3, _p$item4, _p$item$id, _p$item5, _week$p$startCol$key, _week$p$startCol, _p$item7, _p$item8, _p$item9, _p$item10, _p$item$name, _p$item11, _p$item12, _p$item$name2, _p$item13;
    // 0 点（午夜）是合法值，禁止用 || dayGridMin 兜底
    var startHourVal = Number.isFinite(Number((_p$item = p.item) === null || _p$item === void 0 ? void 0 : _p$item.startHour)) ? Number((_p$item2 = p.item) === null || _p$item2 === void 0 ? void 0 : _p$item2.startHour) : dayGridMin;
    var endHourVal = Number.isFinite(Number((_p$item3 = p.item) === null || _p$item3 === void 0 ? void 0 : _p$item3.endHour)) ? Number((_p$item4 = p.item) === null || _p$item4 === void 0 ? void 0 : _p$item4.endHour) : dayGridMin;
    var startUnit = tickFillMode === 'snap' ? p.startCol : dayGridUnit(p.startCol, startHourVal, dayGridMin, dayGridSpan);
    var endUnit = tickFillMode === 'snap' ? p.endCol + 1 : dayGridUnit(p.endCol, endHourVal, dayGridMin, dayGridSpan);
    var sp = mapAxisSpan(monthPctAxis, startUnit, endUnit, tickFillMode);
    var radiusClass = p.crossDay ? "".concat(p.clippedLeft ? 'rounded-l-none' : 'rounded-l-md', " ").concat(p.clippedRight ? 'rounded-r-none' : 'rounded-r-md') : 'rounded-md';
    var layoutClassName = "flex items-center px-2 text-[11px] leading-none w-full h-full ".concat(radiusClass, " ").concat(getGridBookingRowStateClasses(p.item));
    return /*#__PURE__*/React.createElement("div", {
      key: "".concat((_p$item$id = (_p$item5 = p.item) === null || _p$item5 === void 0 ? void 0 : _p$item5.id) !== null && _p$item$id !== void 0 ? _p$item$id : 'b', "-").concat((_week$p$startCol$key = (_week$p$startCol = week[p.startCol]) === null || _week$p$startCol === void 0 ? void 0 : _week$p$startCol.key) !== null && _week$p$startCol$key !== void 0 ? _week$p$startCol$key : p.startCol),
      style: {
        position: 'absolute',
        left: "calc(".concat(sp.offset, "% + 4px)"),
        width: "calc(".concat(sp.size, "% - 8px)"),
        top: MONTH_VIEW_BANNER_PAD_Y + p.lane * (MONTH_VIEW_BANNER_H + MONTH_VIEW_BANNER_GAP),
        height: MONTH_VIEW_BANNER_H,
        pointerEvents: 'auto'
      },
      onDragOver: function onDragOver(e) {
        return e.preventDefault();
      },
      onDrop: function onDrop(e) {
        var _p$item$date, _p$item6;
        e.preventDefault();
        handleGridDropMove(String((_p$item$date = (_p$item6 = p.item) === null || _p$item6 === void 0 ? void 0 : _p$item6.date) !== null && _p$item$date !== void 0 ? _p$item$date : ''));
      }
    }, renderMonthWeekBooking ? /*#__PURE__*/React.createElement("div", {
      className: "relative h-full w-full min-h-0"
    }, renderMonthWeekBooking({
      item: p.item,
      dateKey: (_p$item7 = p.item) === null || _p$item7 === void 0 ? void 0 : _p$item7.date,
      view: 'month',
      isLight: isLight,
      layoutClassName: layoutClassName,
      onOpenDetail: openBookingDetail,
      onDragStart: function onDragStart(it) {
        return setDraggingItem(it);
      },
      // 跨日 booking 暂不支持拖拽改约
      draggable: !p.crossDay && ((_p$item8 = p.item) === null || _p$item8 === void 0 ? void 0 : _p$item8.kind) !== 'block'
    }), /*#__PURE__*/React.createElement(CalendarGridBookingClipMarkers, {
      clippedLeft: p.clippedLeft,
      clippedRight: p.clippedRight,
      size: "xs"
    })) : /*#__PURE__*/React.createElement("button", {
      type: "button",
      onClick: function onClick(e) {
        e.stopPropagation();
        openBookingDetail(p.item);
      },
      className: "relative ".concat(layoutClassName)
    }, p.clippedLeft && /*#__PURE__*/React.createElement("span", {
      "aria-hidden": true,
      className: "absolute left-0.5 top-1/2 -translate-y-1/2 text-[9px] leading-none opacity-80"
    }, "\u25C0"), p.clippedRight && /*#__PURE__*/React.createElement("span", {
      "aria-hidden": true,
      className: "absolute right-0.5 top-1/2 -translate-y-1/2 text-[9px] leading-none opacity-80"
    }, "\u25B6"), /*#__PURE__*/React.createElement("span", {
      className: "truncate"
    }, p.crossDay ? "".concat(formatShortMonthDay((_p$item9 = p.item) === null || _p$item9 === void 0 ? void 0 : _p$item9.date), " ").concat(formatHourLabel((_p$item10 = p.item) === null || _p$item10 === void 0 ? void 0 : _p$item10.startHour), " ").concat((_p$item$name = (_p$item11 = p.item) === null || _p$item11 === void 0 ? void 0 : _p$item11.name) !== null && _p$item$name !== void 0 ? _p$item$name : '') : "".concat(formatHourLabel((_p$item12 = p.item) === null || _p$item12 === void 0 ? void 0 : _p$item12.startHour), " ").concat((_p$item$name2 = (_p$item13 = p.item) === null || _p$item13 === void 0 ? void 0 : _p$item13.name) !== null && _p$item$name2 !== void 0 ? _p$item$name2 : ''))));
  }), Array.from(overflowByDate.entries()).map(function (_ref4) {
    var _dateKeyToCol$get3;
    var _ref5 = _slicedToArray(_ref4, 2),
      dk = _ref5[0],
      items = _ref5[1];
    var colIdx = (_dateKeyToCol$get3 = dateKeyToCol.get(dk)) !== null && _dateKeyToCol$get3 !== void 0 ? _dateKeyToCol$get3 : 0;
    var allHits = bookings.filter(function (b) {
      return getBookingSegmentForDate(b, dk) != null;
    });
    return /*#__PURE__*/React.createElement("div", {
      key: "more-".concat(dk),
      style: {
        position: 'absolute',
        left: "calc(".concat(colIdx * 100 / 7, "% + 4px)"),
        width: "calc(".concat(100 / 7, "% - 8px)"),
        top: moreTopOffset,
        pointerEvents: 'auto'
      }
    }, /*#__PURE__*/React.createElement("button", {
      type: "button",
      onClick: function onClick(e) {
        e.stopPropagation();
        setOverflowListModal(function (prev) {
          return prev && prev.scope === 'month' && prev.date === dk ? null : {
            scope: 'month',
            date: dk,
            title: tCal('pisell2.recordBoard.calendar.overflow.listTitleBookings', {
              date: dk
            }),
            items: allHits
          };
        });
      },
      style: {
        minHeight: MONTH_VIEW_MORE_TILE_PX
      },
      className: "flex w-full items-center justify-center rounded-md bg-violet-700/90 px-1 py-0.5 text-[11px] font-semibold text-white"
    }, "+", items.length));
  }))));
}