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/floorMap/reservationCards.tsx
var reservationCards_exports = {};
__export(reservationCards_exports, {
  findReservationRow: () => findReservationRow,
  getReservationRenderItemByKind: () => getReservationRenderItemByKind,
  renderReservationBarCard: () => renderReservationBarCard,
  renderReservationPartyCard: () => renderReservationPartyCard,
  renderReservationTableCard: () => renderReservationTableCard
});
module.exports = __toCommonJS(reservationCards_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_reservationMock = require("./reservationMock");
var import_floorRoomCard = require("../floorRoomCard");
var import_ReservationCards = require("./ReservationCards.less");
var I18N_BOUND = "pisell-reservation.room-kind-bound";
var I18N_CARD_HINT_SELECT_ROW = "pisell-reservation.card-placeholder.hint-select-row";
var I18N_CARD_HINT_BIND_DATASOURCE = "pisell-reservation.card-placeholder.hint-bind-datasource";
var I18N_CARD_HINT_NEW_SLOT = "pisell-reservation.card-placeholder.hint-new-slot";
var I18N_CARD_HINT_ROW_NOT_FOUND = "pisell-reservation.card-placeholder.hint-row-not-found";
function findReservationRow(item, dataSources) {
  return (0, import_materials.findFloorMapRowByDataBinding)(
    item,
    dataSources
  );
}
function getReservationPlaceholderCopy(item, dataSources) {
  const el = item._sceneElement;
  const kindLabel = import_utils.locales.getText(I18N_BOUND);
  const nameText = (el == null ? void 0 : el.name) != null ? String(el.name).trim() : "";
  const title = nameText || kindLabel;
  const reason = (0, import_materials.getFloorMapBindingPlaceholderReason)(item, dataSources);
  let hint;
  switch (reason) {
    case "missing_data_source_key":
      hint = import_utils.locales.getText(I18N_CARD_HINT_BIND_DATASOURCE);
      break;
    case "missing_record_id":
      hint = import_utils.locales.getText(I18N_CARD_HINT_SELECT_ROW);
      break;
    case "new_unsaved_slot":
      hint = import_utils.locales.getText(I18N_CARD_HINT_NEW_SLOT);
      break;
    default:
      hint = import_utils.locales.getText(I18N_CARD_HINT_ROW_NOT_FOUND);
  }
  const shape = item.elementKind === import_reservationMock.RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND || item.shape === "circle" ? "circle" : "rect";
  return { title, hint, shape };
}
function ReservationNoDataPlaceholder(props) {
  const { title, hint, shape } = props;
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(
        "pisell-reservation-card-placeholder",
        shape === "circle" && "pisell-reservation-card-placeholder--circle"
      )
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-card-placeholder-title" }, title),
    hint ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-card-placeholder-hint" }, hint) : null
  );
}
function boundTableCardShape(item) {
  return item.elementKind === import_reservationMock.RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND || item.shape === "circle" ? "circle" : "rect";
}
function renderReservationBoundRoomCardInner(item, dataSources) {
  var _a;
  const row = findReservationRow(item, dataSources);
  const cardShape = boundTableCardShape(item);
  if (!row) {
    const ph = getReservationPlaceholderCopy(item, dataSources);
    return /* @__PURE__ */ import_react.default.createElement(
      ReservationNoDataPlaceholder,
      {
        title: ph.title,
        hint: ph.hint,
        shape: ph.shape
      }
    );
  }
  const sceneName = ((_a = item._sceneElement) == null ? void 0 : _a.name) != null ? String(item._sceneElement.name).trim() : void 0;
  const roomTitle = (0, import_floorRoomCard.displayRoomTitleFromRow)(row, sceneName);
  const data = (0, import_floorRoomCard.mapPisellReservationRowToFloorRoomCardData)(
    row,
    roomTitle || row.code || import_utils.locales.getText(I18N_BOUND)
  );
  const layoutH = item.height != null && Number.isFinite(item.height) && item.height > 0 ? item.height : item.width;
  return /* @__PURE__ */ import_react.default.createElement(
    import_floorRoomCard.ReservationFloorRoomCard,
    {
      data,
      shellShape: cardShape,
      elementLayoutHeightPx: layoutH != null && Number.isFinite(layoutH) && layoutH > 0 && cardShape === "circle" ? layoutH : void 0
    }
  );
}
function renderReservationTableCard(item, dataSources) {
  return renderReservationBoundRoomCardInner(item, dataSources);
}
function renderReservationPartyCard(item, dataSources) {
  return renderReservationBoundRoomCardInner(item, dataSources);
}
function renderReservationBarCard(item, dataSources) {
  return renderReservationBoundRoomCardInner(item, dataSources);
}
function getReservationRenderItemByKind(dataSources) {
  const bound = (item, _index, _options) => renderReservationBoundRoomCardInner(
    item,
    dataSources
  );
  return {
    [import_materials.FLOOR_MAP_IMAGE_ELEMENT_KIND]: (item, _index, _options) => (0, import_materials.renderFloorMapFallbackPlaceholder)(item),
    [import_reservationMock.RESERVATION_BOUND_TABLE_ELEMENT_KIND]: bound,
    [import_reservationMock.RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND]: bound,
    reservationTable: bound,
    reservationPartyBench: bound,
    reservationBarSeat: bound
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  findReservationRow,
  getReservationRenderItemByKind,
  renderReservationBarCard,
  renderReservationPartyCard,
  renderReservationTableCard
});
