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/ReservationFloorRoomCard.tsx
var ReservationFloorRoomCard_exports = {};
__export(ReservationFloorRoomCard_exports, {
  ReservationFloorRoomCard: () => ReservationFloorRoomCard
});
module.exports = __toCommonJS(ReservationFloorRoomCard_exports);
var import_react = __toESM(require("react"));
var import_FloorRoomCardFromData = require("./FloorRoomCardFromData");
var import_floorRoomCardDensity = require("./floorRoomCardDensity");
var import_floorRoomCardUtils = require("./floorRoomCardUtils");
var import_floorRoomCardDiscEdge = require("./floorRoomCardDiscEdge");
var import_RoomCardDiscEdgeProgress = require("./views/RoomCardDiscEdgeProgress");
var import_RoomCardRectEdgeProgress = require("./views/RoomCardRectEdgeProgress");
function resolveCircleSingleOccupiedDiscEdgeProgress(data) {
  const t = (0, import_floorRoomCardUtils.getFloorRoomCardType)(data);
  if (t !== "payed" && t !== "payment_required" && t !== "timeout") {
    return null;
  }
  const booking = (0, import_floorRoomCardUtils.getFloorRoomCardPrimaryBooking)(data);
  if (!booking) return null;
  return {
    percent: (0, import_floorRoomCardUtils.resolveFloorRoomCardProgressPercent)(booking),
    isTimeout: t === "timeout"
  };
}
function resolveRectSingleOccupiedEdgeProgress(data) {
  const t = (0, import_floorRoomCardUtils.getFloorRoomCardType)(data);
  if (t !== "payed" && t !== "payment_required" && t !== "timeout") {
    return null;
  }
  const booking = (0, import_floorRoomCardUtils.getFloorRoomCardPrimaryBooking)(data);
  if (!booking) return null;
  return {
    percent: (0, import_floorRoomCardUtils.resolveFloorRoomCardProgressPercent)(booking),
    isTimeout: t === "timeout"
  };
}
function ReservationFloorRoomCard(props) {
  var _a, _b;
  const {
    data,
    theme = "default",
    shellShape = "rect",
    elementLayoutHeightPx,
    hideHeaderCapacity = false,
    density = "auto",
    viewportScale = 1,
    discUnifiedLayoutEnabled = true,
    tooltipTimeDensityEnabled = true
  } = props;
  const rootRef = (0, import_react.useRef)(null);
  const isMultiCard = (((_a = data.bookings) == null ? void 0 : _a.length) ?? 0) > 1;
  const autoResolvedDensity = (0, import_floorRoomCardDensity.useResolvedFloorRoomCardDensity)({
    rootRef,
    density,
    viewportScale
  });
  const resolvedDensity = (0, import_react.useMemo)(() => {
    if (isMultiCard) return "comfortable";
    return density === "auto" ? autoResolvedDensity : density;
  }, [isMultiCard, density, autoResolvedDensity]);
  const uiDensity = (0, import_react.useMemo)(
    () => (0, import_floorRoomCardDensity.toFloorRoomCardUiDensity)(resolvedDensity, shellShape),
    [resolvedDensity, shellShape]
  );
  const shapeData = shellShape === "circle" ? { "data-shape": "circle" } : {};
  const discEdgeProgress = import_floorRoomCardDiscEdge.FLOOR_ROOM_CARD_DISC_EDGE_RING_ENABLED && shellShape === "circle" ? resolveCircleSingleOccupiedDiscEdgeProgress(data) : null;
  const rootCardType = (0, import_floorRoomCardUtils.getFloorRoomCardType)(data);
  const reservedHaloEnabled = rootCardType === "not_arrived" || rootCardType === "late" || rootCardType === "multi_reserved";
  const rectEdgeProgress = shellShape === "rect" && (0, import_floorRoomCardDensity.isFloorRoomCardTooltipDensity)(resolvedDensity, shellShape) && (((_b = data.bookings) == null ? void 0 : _b.length) ?? 0) === 1 ? resolveRectSingleOccupiedEdgeProgress(data) : null;
  const vs = Number.isFinite(viewportScale) && viewportScale > 0 ? viewportScale : 1;
  const viewportCompensateScale = isMultiCard ? 1 : Math.min(vs, 1);
  const [, bumpLayoutTick] = (0, import_react.useReducer)((x) => x + 1, 0);
  (0, import_react.useEffect)(() => {
    const id = window.setInterval(() => {
      bumpLayoutTick();
    }, 6e4);
    return () => window.clearInterval(id);
  }, []);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      ref: rootRef,
      className: "pisell-res-floor-room-card",
      "data-theme": theme === "default" ? void 0 : theme,
      "data-density": uiDensity,
      "data-disc-layout": discUnifiedLayoutEnabled ? "unified" : "legacy",
      "data-tooltip-time": tooltipTimeDensityEnabled && (0, import_floorRoomCardDensity.isFloorRoomCardTooltipDensity)(resolvedDensity, shellShape) ? "on" : "off",
      "data-reserved-halo": reservedHaloEnabled ? "on" : "off",
      "data-rect-edge-progress": rectEdgeProgress ? "on" : "off",
      style: {
        ["--floor-card-vs"]: String(viewportCompensateScale)
      },
      ...shapeData
    },
    /* @__PURE__ */ import_react.default.createElement(import_floorRoomCardDensity.FloorRoomCardDensityContext.Provider, { value: resolvedDensity }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-res-floor-room-card__viewport-compensate" }, /* @__PURE__ */ import_react.default.createElement(
      import_FloorRoomCardFromData.FloorRoomCardFromData,
      {
        data,
        shellShape,
        elementLayoutHeightPx,
        hideHeaderCapacity,
        discUnifiedLayoutEnabled,
        tooltipTimeDensityEnabled
      }
    ), discEdgeProgress ? /* @__PURE__ */ import_react.default.createElement(
      import_RoomCardDiscEdgeProgress.RoomCardDiscEdgeProgress,
      {
        percent: discEdgeProgress.percent,
        isTimeout: discEdgeProgress.isTimeout
      }
    ) : null, rectEdgeProgress ? /* @__PURE__ */ import_react.default.createElement(
      import_RoomCardRectEdgeProgress.RoomCardRectEdgeProgress,
      {
        percent: rectEdgeProgress.percent,
        isTimeout: rectEdgeProgress.isTimeout
      }
    ) : null))
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ReservationFloorRoomCard
});
