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/components/ReservationHudDrawer.tsx
var ReservationHudDrawer_exports = {};
__export(ReservationHudDrawer_exports, {
  ReservationHudDrawer: () => ReservationHudDrawer,
  TEMP_HIDE_HUD_DRAWER_INNER_STATS_AND_RESOURCE_RAIL: () => TEMP_HIDE_HUD_DRAWER_INNER_STATS_AND_RESOURCE_RAIL
});
module.exports = __toCommonJS(ReservationHudDrawer_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_ReservationFloorMapHud = require("../floorMap/ReservationFloorMapHud");
var import_ReservationHudDrawerHandle = require("../floorMap/ReservationHudDrawerHandle");
var import_ReservationHudDrawerResourceRail = require("./ReservationHudDrawerResourceRail");
var import_reservationConstants = require("../reservationConstants");
var import_reservationHudResourceRootBuckets = require("../floorMap/reservationHudResourceRootBuckets");
var TEMP_HIDE_HUD_DRAWER_INNER_STATS_AND_RESOURCE_RAIL = true;
function readUniformScaleFromTransform(el) {
  const t = getComputedStyle(el).transform;
  if (!t || t === "none") return 1;
  try {
    const m = new DOMMatrixReadOnly(t);
    const sx = Math.abs(m.a);
    const sy = Math.abs(m.d);
    if (!Number.isFinite(sx) || !Number.isFinite(sy)) return 1;
    if (Math.abs(sx - sy) > 0.03) return 1;
    return sx > 1e-6 ? sx : 1;
  } catch {
    return 1;
  }
}
function ReservationHudDrawer({
  floorMapHudTableDrawer,
  showVenueHudDock,
  hudDrawerOpen,
  hudDrawerRef,
  hudMapItems,
  dataSources,
  handleOpenHudTableDrawer,
  closeHudTableDrawer,
  rowKey,
  hudDrawerPagedRows,
  hudDrawerLoading,
  hudDrawerFilteredTotal,
  hudDrawerBookingPagination,
  hudDrawerOnPageChange,
  hudDrawerLocalSearchParams,
  hudDrawerOnSearch,
  hudDrawerOnReset,
  hudDrawerGrid,
  hudDrawerToolBar,
  batchActionBar,
  hudDrawerResourceRootBuckets,
  handleHudDrawerFormRecordIdsChange
}) {
  (0, import_react.useLayoutEffect)(() => {
    if (typeof window === "undefined") return;
    if (!hudDrawerOpen) {
      const cleared = hudDrawerRef.current;
      if (cleared) {
        cleared.style.height = "";
        cleared.style.maxHeight = "";
      }
      return;
    }
    const el = hudDrawerRef.current;
    if (!el) return;
    const scale = readUniformScaleFromTransform(document.body);
    if (scale > 0 && Math.abs(scale - 1) > 1e-3) {
      el.style.height = `calc(98vh / ${scale})`;
      el.style.maxHeight = `calc(98vh / ${scale})`;
    } else {
      el.style.height = "";
      el.style.maxHeight = "";
    }
    return () => {
      const next = hudDrawerRef.current;
      if (next) {
        next.style.height = "";
        next.style.maxHeight = "";
      }
    };
  }, [hudDrawerOpen, hudDrawerRef]);
  if (!showVenueHudDock) return null;
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, !hudDrawerOpen ? /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "pisell-reservation-hud-title",
      role: "button",
      tabIndex: 0,
      "aria-label": import_utils.locales.getText(import_reservationConstants.I18N_HUD_TABLE_DRAWER_TITLE),
      onClick: handleOpenHudTableDrawer,
      onKeyDown: (e) => {
        if (e.key === "Enter" || e.key === " ") {
          e.preventDefault();
          handleOpenHudTableDrawer();
        }
      }
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_ReservationFloorMapHud.ReservationFloorMapHudTitleBar,
      {
        items: hudMapItems,
        dataSources,
        actionMode: "expand",
        onAction: handleOpenHudTableDrawer,
        embedded: true,
        className: "pisell-reservation-hud-title-inner"
      }
    )
  ) : null, hudDrawerOpen ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "pisell-reservation-hud-drawer-mask",
      onClick: closeHudTableDrawer,
      "aria-hidden": "true"
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "pisell-reservation-hud-drawer",
      role: "dialog",
      "aria-modal": "false",
      "aria-label": import_utils.locales.getText(import_reservationConstants.I18N_HUD_TABLE_DRAWER_TITLE),
      ref: hudDrawerRef
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_ReservationHudDrawerHandle.ReservationHudDrawerHandle,
      {
        onClose: closeHudTableDrawer,
        drawerRef: hudDrawerRef
      }
    ),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-hud-drawer-record-board" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-hud-drawer-split" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-hud-drawer-split-main" }, /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellRecordBoard,
      {
        layoutVariant: "phone",
        columnVisibilityStorageKey: import_reservationConstants.PISELL_RESERVATION_HUD_DRAWER_COLUMN_STORAGE_KEY,
        rowKey,
        data: hudDrawerPagedRows,
        loading: hudDrawerLoading,
        total: hudDrawerFilteredTotal,
        pagination: hudDrawerBookingPagination,
        onPageChange: hudDrawerOnPageChange,
        searchParams: hudDrawerLocalSearchParams,
        onSearch: hudDrawerOnSearch,
        onReset: hudDrawerOnReset,
        grid: hudDrawerGrid,
        toolBar: hudDrawerToolBar,
        batchActionBar,
        defaultBodyView: "grid",
        bodyViewSwitchable: false,
        lockedBodyView: "grid"
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_materials.PisellRecordBoard.ShellFrame,
        {
          belowToolbar: TEMP_HIDE_HUD_DRAWER_INNER_STATS_AND_RESOURCE_RAIL ? void 0 : /* @__PURE__ */ import_react.default.createElement(
            import_ReservationFloorMapHud.ReservationFloorMapHudTitleBar,
            {
              items: hudMapItems,
              dataSources,
              actionMode: "collapse",
              onAction: closeHudTableDrawer,
              embedded: true,
              className: "pisell-reservation-hud-drawer-stats-inner"
            }
          )
        },
        /* @__PURE__ */ import_react.default.createElement(import_materials.PisellRecordBoard.GridLayout, null)
      )
    )), floorMapHudTableDrawer && !TEMP_HIDE_HUD_DRAWER_INNER_STATS_AND_RESOURCE_RAIL ? /* @__PURE__ */ import_react.default.createElement(
      import_ReservationHudDrawerResourceRail.ReservationHudDrawerResourceRail,
      {
        className: "pisell-reservation-hud-drawer-resource-rail",
        buckets: hudDrawerResourceRootBuckets,
        value: (0, import_reservationHudResourceRootBuckets.extractFilterFormRecordIds)(hudDrawerLocalSearchParams),
        onChange: handleHudDrawerFormRecordIdsChange,
        ariaLabel: import_utils.locales.getText(
          import_reservationConstants.I18N_HUD_DRAWER_RESOURCE_CANVAS_PLACEHOLDER
        )
      }
    ) : null))
  )) : null);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ReservationHudDrawer,
  TEMP_HIDE_HUD_DRAWER_INNER_STATS_AND_RESOURCE_RAIL
});
