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/floorRoomCard/FloorRoomCardFromData.tsx
var FloorRoomCardFromData_exports = {};
__export(FloorRoomCardFromData_exports, {
  FloorRoomCardFromData: () => FloorRoomCardFromData
});
module.exports = __toCommonJS(FloorRoomCardFromData_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_buildCardBodyViewModel = require("./buildCardBodyViewModel");
var import_floorRoomCardDensity = require("./floorRoomCardDensity");
var import_floorRoomCardLayoutOptions = require("./floorRoomCardLayoutOptions");
var import_floorRoomCardPaymentUi = require("./floorRoomCardPaymentUi");
var import_floorRoomCardDom = require("./floorRoomCardDom");
var import_floorRoomCardHeaderFormat = require("./floorRoomCardHeaderFormat");
var import_floorRoomCardUtils = require("./floorRoomCardUtils");
var import_RoomCardBodyView = require("./views/RoomCardBodyView");
var import_RoomCardHeaderView = require("./views/RoomCardHeaderView");
var import_RoomCardShellView = require("./views/RoomCardShellView");
var import_RoomCardTooltipTimeLayout = require("./views/RoomCardTooltipTimeLayout");
var import_ReservationFloorRoomCard = require("./ReservationFloorRoomCard.less");
var I18N_STATUS_LOCK = "pisell-reservation.room-status-locked";
var I18N_VIEW_ALL = "pisell-reservation.room-view-all";
var I18N_MODAL_BOOKINGS = "pisell-reservation.room-modal-bookings";
var I18N_NEXT = "pisell-reservation.room-next-prefix";
function i18nN(key, n) {
  return import_utils.locales.getText(key).replace(/\{n\}/g, String(n));
}
var floorCardStopCanvasPanHandlers = {
  onTouchStart: (e) => e.stopPropagation(),
  onTouchMove: (e) => e.stopPropagation(),
  onTouchEnd: (e) => e.stopPropagation(),
  onWheel: (e) => e.stopPropagation()
};
function scheduleCloseViewAllBookingsModal(setOpen, e) {
  var _a, _b;
  e == null ? void 0 : e.stopPropagation();
  (_b = (_a = e == null ? void 0 : e.nativeEvent) == null ? void 0 : _a.stopImmediatePropagation) == null ? void 0 : _b.call(_a);
  window.setTimeout(() => setOpen(false), 50);
}
var FLOOR_CARD_VIEW_ALL_MODAL_MASK_PROPS = {
  onMouseDown: (e) => e.stopPropagation(),
  onClick: (e) => e.stopPropagation()
};
var FLOOR_CARD_VIEW_ALL_MODAL_WRAP_CLASS = "pisell-res-floor-view-all-modal-wrap";
var MULTI_PREVIEW_MAX = 3;
var CIRCLE_MULTI_MORE_BTN_RESERVE_PX = 46;
function circleMultiCompactRowEst(innerDiameterPx) {
  return Math.round(Math.max(42, Math.min(64, innerDiameterPx * 0.15)));
}
function resolveCircleMultiPreviewCount(shellShape, bookingCount, layoutHeightPx, density) {
  if (bookingCount < 1) return 0;
  if (density === "micro") return 0;
  if (shellShape !== "circle") {
    return Math.min(MULTI_PREVIEW_MAX, bookingCount);
  }
  const H = layoutHeightPx != null && Number.isFinite(layoutHeightPx) && layoutHeightPx > 0 ? layoutHeightPx : null;
  if (H == null || H < 48) {
    return bookingCount > MULTI_PREVIEW_MAX ? 1 : Math.min(MULTI_PREVIEW_MAX, bookingCount);
  }
  const padY = Math.round(Math.max(7, Math.min(18, H * 0.065)));
  const inner = Math.max(0, H - padY * 2);
  const headerReserve = Math.min(115, Math.max(54, inner * 0.35));
  const listMax = Math.max(0, inner - headerReserve - 10);
  const moreH = CIRCLE_MULTI_MORE_BTN_RESERVE_PX;
  const rowEst = circleMultiCompactRowEst(inner);
  const topK = Math.min(MULTI_PREVIEW_MAX, bookingCount);
  const needMoreBtn = bookingCount > topK;
  if (listMax < moreH && needMoreBtn) {
    return 0;
  }
  let circleChosen = 0;
  for (let k = topK; k >= 0; k--) {
    const needMore = bookingCount > k;
    const total = k * rowEst + (needMore ? moreH + (k > 0 ? 6 : 0) : 0);
    if (total <= listMax) {
      circleChosen = k;
      break;
    }
  }
  return circleChosen;
}
function effectiveRoomTitle(data, headerMainFieldOverride) {
  const o = headerMainFieldOverride == null ? void 0 : headerMainFieldOverride.trim();
  return o || data.main_field;
}
function CardHeader(props) {
  const {
    data,
    occupancyBookings,
    hideCapacity = false,
    headerMainFieldOverride,
    paymentUnpaidFill = false
  } = props;
  const bookingsForOcc = occupancyBookings !== void 0 ? occupancyBookings : data.bookings;
  const capLabel = hideCapacity ? null : (0, import_floorRoomCardHeaderFormat.formatRoomCapLine)(data, bookingsForOcc);
  return /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardHeaderView.RoomCardHeaderView,
    {
      roomTitle: effectiveRoomTitle(data, headerMainFieldOverride),
      capacityLine: capLabel,
      status: data.status,
      statusLabel: (0, import_floorRoomCardHeaderFormat.floorRoomCardStatusTagLabel)(data.status),
      paymentUnpaidFill,
      bookingCount: data.bookingCount,
      completeBookingCount: data.completeBookingCount
    }
  );
}
function buildRoomViewAllModalTitle(data, bookingsForOcc, headerMainFieldOverride) {
  const capLabel = (0, import_floorRoomCardHeaderFormat.formatRoomCapLine)(data, bookingsForOcc);
  const n = bookingsForOcc.length;
  const bookingsLine = i18nN(I18N_MODAL_BOOKINGS, n);
  const head = (0, import_RoomCardTooltipTimeLayout.appendBookingCountSuffix)(
    effectiveRoomTitle(data, headerMainFieldOverride),
    data
  );
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "rc-view-all-modal-title" }, head, " · ", bookingsLine, " · ", capLabel);
}
function CardBody(props) {
  const {
    cardType,
    booking,
    data,
    compact = false,
    shellShape = "rect",
    bodyStatusTag
  } = props;
  const model = (0, import_buildCardBodyViewModel.buildRoomCardBodyViewModel)({
    cardType,
    booking,
    data,
    compact,
    shellShape,
    nowMs: Date.now(),
    floorDensity: "comfortable"
  });
  return /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardBodyView.RoomCardBodyView,
    {
      model,
      scrollSurfaceHandlers: floorCardStopCanvasPanHandlers,
      nextBookingPrefix: import_utils.locales.getText(I18N_NEXT),
      bodyStatusTag,
      pinProgressToBottom: shellShape !== "circle"
    }
  );
}
var CARD_CLASS = {
  not_arrived: "rc rc--reserved",
  late: "rc rc--reserved",
  payed: "rc rc--occupied",
  payment_required: "rc rc--occupied rc--occupied-pay",
  timeout: "rc rc--occupied rc--occupied-timeout"
};
function StandardCard(props) {
  var _a;
  const {
    data,
    cardType,
    hideHeader = false,
    hideHeaderCapacity = false,
    headerMainFieldOverride,
    shellShape = "rect",
    bodyStatusTag
  } = props;
  const density = (0, import_floorRoomCardDensity.useFloorRoomCardDensity)();
  const { discUnifiedLayoutEnabled, tooltipTimeDensityEnabled } = (0, import_floorRoomCardLayoutOptions.useFloorRoomCardLayoutOptions)();
  const booking = (0, import_floorRoomCardUtils.getFloorRoomCardPrimaryBooking)(data);
  if (!booking) {
    return /* @__PURE__ */ import_react.default.createElement(
      EmptyCard,
      {
        data,
        shellShape,
        hideHeaderCapacity,
        headerMainFieldOverride
      }
    );
  }
  const isOccupied = cardType === "payed" || cardType === "payment_required" || cardType === "timeout";
  const paymentKind = (0, import_floorRoomCardPaymentUi.floorRoomCardPaymentUiFromOrderStatus)(
    booking.order_payment_status
  );
  const paymentUnpaidFill = isOccupied && paymentKind === "unpaid" && (shellShape === "circle" && discUnifiedLayoutEnabled);
  const useTooltipTimeLayout = tooltipTimeDensityEnabled && (0, import_floorRoomCardDensity.isFloorRoomCardTooltipDensity)(density, shellShape);
  if (useTooltipTimeLayout) {
    const showRectEdgeProgress = shellShape === "rect" && isOccupied && (((_a = data.bookings) == null ? void 0 : _a.length) ?? 0) === 1;
    return /* @__PURE__ */ import_react.default.createElement(
      import_RoomCardShellView.RoomCardShellView,
      {
        className: (0, import_classnames.default)(CARD_CLASS[cardType], "rc--tooltip-time"),
        shellShape,
        checkoutBookingKey: (0, import_floorRoomCardDom.floorRoomCardBookingCheckoutDomKey)(booking),
        tooltipTimeStandaloneMain: true
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_RoomCardTooltipTimeLayout.RoomCardTooltipTimeLayout,
        {
          data,
          booking,
          cardType,
          shellShape,
          hideInnerLinearProgress: showRectEdgeProgress,
          headerMainFieldOverride,
          scrollSurfaceHandlers: floorCardStopCanvasPanHandlers
        }
      )
    );
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardShellView.RoomCardShellView,
    {
      className: CARD_CLASS[cardType],
      shellShape,
      checkoutBookingKey: (0, import_floorRoomCardDom.floorRoomCardBookingCheckoutDomKey)(booking),
      header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
        CardHeader,
        {
          data,
          hideCapacity: hideHeaderCapacity,
          headerMainFieldOverride,
          paymentUnpaidFill
        }
      )
    },
    /* @__PURE__ */ import_react.default.createElement(
      CardBody,
      {
        cardType,
        booking,
        data,
        shellShape,
        bodyStatusTag
      }
    )
  );
}
function EmptyCard(props) {
  const {
    data,
    hideHeader,
    hideHeaderCapacity,
    headerMainFieldOverride,
    shellShape = "rect"
  } = props;
  const density = (0, import_floorRoomCardDensity.useFloorRoomCardDensity)();
  const { tooltipTimeDensityEnabled } = (0, import_floorRoomCardLayoutOptions.useFloorRoomCardLayoutOptions)();
  const useTooltipTitleOnlyLayout = tooltipTimeDensityEnabled && (0, import_floorRoomCardDensity.isFloorRoomCardTooltipDensity)(density, shellShape);
  if (useTooltipTitleOnlyLayout) {
    return /* @__PURE__ */ import_react.default.createElement(
      import_RoomCardShellView.RoomCardShellView,
      {
        className: "rc rc--empty rc--tooltip-time",
        shellShape,
        tooltipTimeStandaloneMain: true
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_RoomCardTooltipTimeLayout.RoomCardTooltipTitleOnlyLayout,
        {
          data,
          headerMainFieldOverride,
          scrollSurfaceHandlers: floorCardStopCanvasPanHandlers
        }
      )
    );
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardShellView.RoomCardShellView,
    {
      className: "rc rc--empty",
      shellShape,
      header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
        CardHeader,
        {
          data,
          hideCapacity: hideHeaderCapacity,
          headerMainFieldOverride
        }
      )
    }
  );
}
function MultiOccupiedCard(props) {
  const {
    data,
    shellShape = "rect",
    elementLayoutHeightPx,
    hideHeader = false,
    hideHeaderCapacity,
    headerMainFieldOverride
  } = props;
  const density = (0, import_floorRoomCardDensity.useFloorRoomCardDensity)();
  const [modalOpen, setModalOpen] = (0, import_react.useState)(false);
  const mainBookings = data.bookings.filter((b) => b.isNext !== true);
  const listForPreview = mainBookings.length > 0 ? mainBookings : data.bookings;
  const explicitNextOcc = (0, import_floorRoomCardUtils.getFloorRoomCardExplicitNextBooking)(data);
  const n = listForPreview.length;
  const previewCount = resolveCircleMultiPreviewCount(
    shellShape,
    n,
    elementLayoutHeightPx,
    density
  );
  const preview = listForPreview.slice(0, previewCount);
  const hasMore = n > preview.length;
  const occPaymentKind = data.sub_status === "payed" ? "paid" : "unpaid";
  const { discUnifiedLayoutEnabled } = (0, import_floorRoomCardLayoutOptions.useFloorRoomCardLayoutOptions)();
  const multiOccPaymentUnpaidFill = occPaymentKind === "unpaid" && ((0, import_floorRoomCardDensity.isFloorRoomCardTooltipDensity)(density, shellShape) || shellShape === "circle" && discUnifiedLayoutEnabled);
  const occupiedModal = /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      open: modalOpen,
      onCancel: (e) => scheduleCloseViewAllBookingsModal(setModalOpen, e),
      maskProps: FLOOR_CARD_VIEW_ALL_MODAL_MASK_PROPS,
      focusTriggerAfterClose: false,
      wrapClassName: FLOOR_CARD_VIEW_ALL_MODAL_WRAP_CLASS,
      title: buildRoomViewAllModalTitle(
        data,
        data.bookings,
        headerMainFieldOverride
      ),
      footer: null,
      destroyOnClose: true,
      width: 560
    },
    /* @__PURE__ */ import_react.default.createElement(import_floorRoomCardDensity.FloorRoomCardDensityContext.Provider, { value: "comfortable" }, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-res-floor-room-card",
          "pisell-res-floor-room-card--modal-shell"
        )
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "rc--occupied rc--multi" }, /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: "rc-multi-modal-body",
          ...floorCardStopCanvasPanHandlers
        },
        data.bookings.map((b, bi) => {
          const progress = (0, import_floorRoomCardUtils.resolveFloorRoomCardProgressPercent)(b);
          const perType = progress >= 100 ? "timeout" : data.sub_status === "payed" ? "payed" : "payment_required";
          return /* @__PURE__ */ import_react.default.createElement(
            CardBody,
            {
              key: `${(0, import_floorRoomCardDom.floorRoomCardBookingCheckoutDomKey)(b)}-${bi}`,
              cardType: perType,
              booking: b,
              data,
              compact: true,
              shellShape: "rect"
            }
          );
        })
      ))
    ))
  );
  if (density === "micro") {
    const title = effectiveRoomTitle(data, headerMainFieldOverride);
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
      import_RoomCardShellView.RoomCardShellView,
      {
        className: (0, import_classnames.default)(
          "rc rc--occupied rc--multi",
          modalOpen && "rc--floor-detail-open"
        ),
        shellShape,
        header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
          CardHeader,
          {
            data,
            occupancyBookings: data.bookings,
            hideCapacity: hideHeaderCapacity,
            headerMainFieldOverride,
            paymentUnpaidFill: multiOccPaymentUnpaidFill
          }
        )
      },
      /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: "rc-multi-micro-summary",
          "data-pisell-floor-room-scroll-surface": "",
          ...floorCardStopCanvasPanHandlers
        },
        /* @__PURE__ */ import_react.default.createElement("span", { className: "rc-multi-micro-summary__text" }, title, " · ", "×", data.bookings.length),
        /* @__PURE__ */ import_react.default.createElement(
          "button",
          {
            type: "button",
            className: "rc-multi-more",
            onClick: (e) => {
              e.stopPropagation();
              setModalOpen(true);
            }
          },
          i18nN(I18N_VIEW_ALL, data.bookings.length)
        )
      )
    ), occupiedModal);
  }
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardShellView.RoomCardShellView,
    {
      className: (0, import_classnames.default)(
        "rc rc--occupied rc--multi",
        modalOpen && "rc--floor-detail-open"
      ),
      shellShape,
      header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
        CardHeader,
        {
          data,
          occupancyBookings: data.bookings,
          hideCapacity: hideHeaderCapacity,
          headerMainFieldOverride,
          paymentUnpaidFill: multiOccPaymentUnpaidFill
        }
      )
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "rc-multi-list",
        "data-pisell-floor-room-scroll-surface": "",
        ...floorCardStopCanvasPanHandlers
      },
      preview.map((b) => {
        const progress = (0, import_floorRoomCardUtils.resolveFloorRoomCardProgressPercent)(b);
        const perType = progress >= 100 ? "timeout" : data.sub_status === "payed" ? "payed" : "payment_required";
        return /* @__PURE__ */ import_react.default.createElement(
          CardBody,
          {
            key: (0, import_floorRoomCardDom.floorRoomCardBookingCheckoutDomKey)(b),
            cardType: perType,
            booking: b,
            data,
            compact: true,
            shellShape
          }
        );
      }),
      explicitNextOcc && density !== "micro" && !hasMore ? /* @__PURE__ */ import_react.default.createElement(
        import_RoomCardBodyView.RoomCardNextBookingStrip,
        {
          nextLabel: import_utils.locales.getText(I18N_NEXT),
          guestSegments: density !== "micro" ? (0, import_floorRoomCardUtils.floorRoomCardGuestSegments)(explicitNextOcc, true) : [],
          timeRange: (0, import_floorRoomCardUtils.formatFloorRoomCardBookingTimeRange)(explicitNextOcc)
        }
      ) : null,
      hasMore ? /* @__PURE__ */ import_react.default.createElement(
        "button",
        {
          type: "button",
          className: "rc-multi-more",
          onClick: (e) => {
            e.stopPropagation();
            setModalOpen(true);
          }
        },
        i18nN(I18N_VIEW_ALL, data.bookings.length)
      ) : null
    )
  ), occupiedModal);
}
function MultiReservedCard(props) {
  const {
    data,
    shellShape = "rect",
    elementLayoutHeightPx,
    hideHeader = false,
    hideHeaderCapacity,
    headerMainFieldOverride
  } = props;
  const density = (0, import_floorRoomCardDensity.useFloorRoomCardDensity)();
  const [modalOpen, setModalOpen] = (0, import_react.useState)(false);
  const sorted = (0, import_floorRoomCardUtils.reorderBookingsAllReservedChronological)([...data.bookings]);
  const mainReserved = sorted.filter((b) => b.isNext !== true);
  const listForReservedPreview = mainReserved.length > 0 ? mainReserved : sorted;
  const explicitNextRes = (0, import_floorRoomCardUtils.getFloorRoomCardExplicitNextBooking)(data);
  const n = listForReservedPreview.length;
  const previewCount = resolveCircleMultiPreviewCount(
    shellShape,
    n,
    elementLayoutHeightPx,
    density
  );
  const preview = listForReservedPreview.slice(0, previewCount);
  const hasMore = n > preview.length;
  const nowMs = Date.now();
  const reservedModal = /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      open: modalOpen,
      onCancel: (e) => scheduleCloseViewAllBookingsModal(setModalOpen, e),
      maskProps: FLOOR_CARD_VIEW_ALL_MODAL_MASK_PROPS,
      focusTriggerAfterClose: false,
      wrapClassName: FLOOR_CARD_VIEW_ALL_MODAL_WRAP_CLASS,
      title: buildRoomViewAllModalTitle(
        data,
        sorted,
        headerMainFieldOverride
      ),
      footer: null,
      destroyOnClose: true,
      width: 560
    },
    /* @__PURE__ */ import_react.default.createElement(import_floorRoomCardDensity.FloorRoomCardDensityContext.Provider, { value: "comfortable" }, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-res-floor-room-card",
          "pisell-res-floor-room-card--modal-shell"
        )
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "rc--reserved rc--multi" }, /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: "rc-multi-modal-body",
          ...floorCardStopCanvasPanHandlers
        },
        sorted.map((b, bi) => /* @__PURE__ */ import_react.default.createElement(
          CardBody,
          {
            key: `${(0, import_floorRoomCardDom.floorRoomCardBookingCheckoutDomKey)(b)}-${bi}`,
            cardType: (0, import_floorRoomCardUtils.getFloorRoomCardReservedRowBodyType)(b, Date.now()),
            booking: b,
            data,
            compact: true,
            shellShape: "rect"
          }
        ))
      ))
    ))
  );
  if (density === "micro") {
    const title = effectiveRoomTitle(data, headerMainFieldOverride);
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
      import_RoomCardShellView.RoomCardShellView,
      {
        className: (0, import_classnames.default)(
          "rc rc--reserved rc--multi",
          modalOpen && "rc--floor-detail-open"
        ),
        shellShape,
        header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
          CardHeader,
          {
            data,
            occupancyBookings: sorted,
            hideCapacity: hideHeaderCapacity,
            headerMainFieldOverride
          }
        )
      },
      /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: "rc-multi-micro-summary",
          "data-pisell-floor-room-scroll-surface": "",
          ...floorCardStopCanvasPanHandlers
        },
        /* @__PURE__ */ import_react.default.createElement("span", { className: "rc-multi-micro-summary__text" }, title, " · ", "×", sorted.length),
        /* @__PURE__ */ import_react.default.createElement(
          "button",
          {
            type: "button",
            className: "rc-multi-more",
            onClick: (e) => {
              e.stopPropagation();
              setModalOpen(true);
            }
          },
          i18nN(I18N_VIEW_ALL, sorted.length)
        )
      )
    ), reservedModal);
  }
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardShellView.RoomCardShellView,
    {
      className: (0, import_classnames.default)(
        "rc rc--reserved rc--multi",
        modalOpen && "rc--floor-detail-open"
      ),
      shellShape,
      header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
        CardHeader,
        {
          data,
          occupancyBookings: sorted,
          hideCapacity: hideHeaderCapacity,
          headerMainFieldOverride
        }
      )
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "rc-multi-list",
        "data-pisell-floor-room-scroll-surface": "",
        ...floorCardStopCanvasPanHandlers
      },
      preview.map((b) => {
        const perType = (0, import_floorRoomCardUtils.getFloorRoomCardReservedRowBodyType)(b, nowMs);
        return /* @__PURE__ */ import_react.default.createElement(
          CardBody,
          {
            key: (0, import_floorRoomCardDom.floorRoomCardBookingCheckoutDomKey)(b),
            cardType: perType,
            booking: b,
            data,
            compact: true,
            shellShape
          }
        );
      }),
      explicitNextRes && density !== "micro" && !hasMore ? /* @__PURE__ */ import_react.default.createElement(
        import_RoomCardBodyView.RoomCardNextBookingStrip,
        {
          nextLabel: import_utils.locales.getText(I18N_NEXT),
          guestSegments: density !== "micro" ? (0, import_floorRoomCardUtils.floorRoomCardGuestSegments)(explicitNextRes, true) : [],
          timeRange: (0, import_floorRoomCardUtils.formatFloorRoomCardBookingTimeRange)(explicitNextRes)
        }
      ) : null,
      hasMore ? /* @__PURE__ */ import_react.default.createElement(
        "button",
        {
          type: "button",
          className: "rc-multi-more",
          onClick: (e) => {
            e.stopPropagation();
            setModalOpen(true);
          }
        },
        i18nN(I18N_VIEW_ALL, sorted.length)
      ) : null
    )
  ), reservedModal);
}
function LockedCard(props) {
  const {
    data,
    hideHeader = false,
    hideHeaderCapacity,
    headerMainFieldOverride,
    shellShape = "rect"
  } = props;
  const capLabel = hideHeaderCapacity ? null : (0, import_floorRoomCardHeaderFormat.formatRoomCapLine)(data, []);
  return /* @__PURE__ */ import_react.default.createElement(
    import_RoomCardShellView.RoomCardShellView,
    {
      className: "rc rc--locked",
      shellShape,
      header: hideHeader ? void 0 : /* @__PURE__ */ import_react.default.createElement(
        import_RoomCardHeaderView.RoomCardHeaderView,
        {
          roomTitle: effectiveRoomTitle(data, headerMainFieldOverride),
          capacityLine: capLabel,
          status: "locked",
          statusLabel: "",
          showStatusTag: false
        }
      )
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "rc-body rc-body--center",
        "data-pisell-floor-room-scroll-surface": "",
        ...floorCardStopCanvasPanHandlers
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "rc-lock-icon" }, /* @__PURE__ */ import_react.default.createElement(
        "svg",
        {
          width: "28",
          height: "28",
          viewBox: "0 0 24 24",
          fill: "none",
          stroke: "currentColor",
          strokeWidth: "1.5",
          strokeLinecap: "round",
          strokeLinejoin: "round"
        },
        /* @__PURE__ */ import_react.default.createElement("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }),
        /* @__PURE__ */ import_react.default.createElement("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
      )),
      /* @__PURE__ */ import_react.default.createElement("span", { className: "rc-locked-text" }, import_utils.locales.getText(I18N_STATUS_LOCK))
    )
  );
}
var SPECIAL_RENDERERS = {
  empty: EmptyCard,
  multi_occupied: MultiOccupiedCard,
  multi_reserved: MultiReservedCard,
  locked: LockedCard
};
function FloorRoomCardFromDataInner(props) {
  const {
    data,
    shellShape = "rect",
    elementLayoutHeightPx,
    hideHeader = false,
    hideHeaderCapacity = false,
    headerMainFieldOverride,
    bodyStatusTag
  } = props;
  const cardType = (0, import_floorRoomCardUtils.getFloorRoomCardType)(data);
  const Special = SPECIAL_RENDERERS[cardType];
  if (Special) {
    return /* @__PURE__ */ import_react.default.createElement(
      Special,
      {
        data,
        shellShape,
        elementLayoutHeightPx,
        hideHeader,
        hideHeaderCapacity,
        headerMainFieldOverride,
        bodyStatusTag
      }
    );
  }
  if (cardType in CARD_CLASS) {
    return /* @__PURE__ */ import_react.default.createElement(
      StandardCard,
      {
        data,
        cardType,
        hideHeader,
        hideHeaderCapacity,
        headerMainFieldOverride,
        shellShape,
        bodyStatusTag
      }
    );
  }
  return /* @__PURE__ */ import_react.default.createElement(
    EmptyCard,
    {
      data,
      shellShape,
      elementLayoutHeightPx,
      hideHeader,
      hideHeaderCapacity,
      headerMainFieldOverride,
      bodyStatusTag
    }
  );
}
function FloorRoomCardFromData(props) {
  const {
    discUnifiedLayoutEnabled = true,
    tooltipTimeDensityEnabled = true,
    ...rest
  } = props;
  const layoutValue = {
    discUnifiedLayoutEnabled,
    tooltipTimeDensityEnabled
  };
  return /* @__PURE__ */ import_react.default.createElement(import_floorRoomCardLayoutOptions.FloorRoomCardLayoutContext.Provider, { value: layoutValue }, /* @__PURE__ */ import_react.default.createElement(FloorRoomCardFromDataInner, { ...rest }));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FloorRoomCardFromData
});
