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/PisellReservationSubcomponents.tsx
var PisellReservationSubcomponents_exports = {};
__export(PisellReservationSubcomponents_exports, {
  PisellReservationScheduleEndActions: () => PisellReservationScheduleEndActions,
  PisellReservationToolbarTabs: () => PisellReservationToolbarTabs,
  RecordBoardBodyViewCapture: () => RecordBoardBodyViewCapture,
  ReservationDefaultScheduleStart: () => ReservationDefaultScheduleStart,
  ReservationFloorMapCanvasTabsTrailing: () => ReservationFloorMapCanvasTabsTrailing,
  ReservationGridTopRight: () => ReservationGridTopRight,
  ReservationVenueScheduleStart: () => ReservationVenueScheduleStart,
  ScheduleSyncOnFloorEnter: () => ScheduleSyncOnFloorEnter
});
module.exports = __toCommonJS(PisellReservationSubcomponents_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_reservationDataUtils = require("../data/reservationDataUtils");
var import_reservationConstants = require("../reservationConstants");
function RecordBoardBodyViewCapture(props) {
  const { bodyView } = (0, import_materials.useRecordBoardContext)();
  (0, import_react.useEffect)(() => {
    props.bodyViewRef.current = bodyView;
  }, [bodyView, props.bodyViewRef]);
  return null;
}
function ScheduleSyncOnFloorEnter(props) {
  const { bodyView } = (0, import_materials.useRecordBoardContext)();
  const prevRef = (0, import_react.useRef)(null);
  (0, import_react.useEffect)(() => {
    const prev = prevRef.current;
    if (props.isInternalListData && bodyView === "floorMap" && prev !== null && prev !== "floorMap") {
      props.patchSearchParams(
        (p) => (0, import_reservationDataUtils.mergeSearchParamsBookingWindow)(p, props.schedule.date)
      );
    }
    prevRef.current = bodyView;
  }, [
    bodyView,
    props.schedule.date.valueOf(),
    props.isInternalListData,
    props.patchSearchParams,
    props.schedule.date
  ]);
  return null;
}
function PisellReservationToolbarTabs(props) {
  var _a, _b, _c, _d;
  const { bodyView, setBodyView, bodyViewSwitchable } = (0, import_materials.useRecordBoardContext)();
  const shellMeta = (0, import_materials.useRecordBoardShellBodyMeta)();
  const hasGrid = (shellMeta == null ? void 0 : shellMeta.hasGridContent) ?? true;
  const hasFloor = shellMeta == null ? void 0 : shellMeta.hasFloorMapSlot;
  const floorForToggle = shellMeta == null ? void 0 : shellMeta.effectiveFloorMapProps;
  const showTableFloorToggle = hasGrid && hasFloor && floorForToggle != null;
  const allowBodyViewToggle = showTableFloorToggle && bodyViewSwitchable !== false;
  if (bodyView === "grid") {
    return props.extraTabs ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.extraTabs) : null;
  }
  const bodyViewToggle = allowBodyViewToggle ? /* @__PURE__ */ import_react.default.createElement(
    import_antd.Segmented,
    {
      className: "pisell-reservation-body-view-segmented",
      size: "large",
      value: bodyView,
      onChange: (v) => setBodyView(v),
      options: [
        { label: import_utils.locales.getText(import_reservationConstants.I18N_VIEW_FLOOR), value: "floorMap" },
        { label: import_utils.locales.getText(import_reservationConstants.I18N_VIEW_GRID), value: "grid" }
      ]
    }
  ) : null;
  const scheduleStartMerged = /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-schedule-start-merge" }, props.scheduleStartSlot, bodyViewToggle);
  const afterDateSlot = /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-follow-time-slot" }, props.followWallClock ? /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      className: "pisell-reservation-follow-time-hint pisell-reservation-follow-time-hint--at-current",
      "aria-live": "polite"
    },
    import_utils.locales.getText(import_reservationConstants.I18N_AT_CURRENT_TIME)
  ) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      className: "pisell-reservation-follow-time-hint pisell-reservation-follow-time-hint--off-current",
      "aria-live": "polite"
    },
    import_utils.locales.getText(import_reservationConstants.I18N_NON_CURRENT_HINT)
  ), /* @__PURE__ */ import_react.default.createElement(
    "button",
    {
      type: "button",
      className: "pisell-reservation-follow-current-btn pisell-reservation-follow-current-btn--go-current",
      onClick: props.onFollowWallClockToggle,
      "aria-pressed": false
    },
    /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-reservation-follow-current-btn-label" }, import_utils.locales.getText(import_reservationConstants.I18N_GO_CURRENT))
  )));
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellReservationScheduleBand,
    {
      value: props.schedule,
      onChange: props.onScheduleChange,
      scheduleProps: {
        ...props.scheduleProps,
        navigationLocked: Boolean((_a = props.scheduleProps) == null ? void 0 : _a.navigationLocked)
      },
      timeNavigatorProps: {
        range: import_reservationConstants.RESERVATION_TIMELINE_BUSINESS_RANGE,
        businessHours: import_reservationConstants.RESERVATION_TIMELINE_BUSINESS_RANGE,
        ...props.timeNavigatorProps,
        showNowButton: ((_b = props.timeNavigatorProps) == null ? void 0 : _b.showNowButton) ?? false,
        snapToStep: false,
        cursorMode: ((_c = props.timeNavigatorProps) == null ? void 0 : _c.cursorMode) ?? "cursor-moves",
        onUserInteraction: () => {
          var _a2, _b2;
          props.onTimeNavigatorUserInteraction();
          (_b2 = (_a2 = props.timeNavigatorProps) == null ? void 0 : _a2.onUserInteraction) == null ? void 0 : _b2.call(_a2);
        },
        userInteractionLocked: Boolean(
          (_d = props.timeNavigatorProps) == null ? void 0 : _d.userInteractionLocked
        ),
        loadDensity: props.loadDensity
      },
      scheduleStartSlot: scheduleStartMerged,
      scheduleAfterDateSlot: afterDateSlot,
      scheduleEndSlot: props.scheduleEndSlot
    }
  ), props.extraTabs);
}
function ReservationGridTopRight(props) {
  const { bodyView } = (0, import_materials.useRecordBoardContext)();
  if (bodyView === "floorMap") return null;
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.extra ?? null);
}
function PisellReservationScheduleEndActions(props) {
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-schedule-end-slots" }, /* @__PURE__ */ import_react.default.createElement(
    "button",
    {
      type: "button",
      className: "pisell-reservation-new-btn",
      onClick: () => {
        var _a;
        return (_a = props.onNewReservation) == null ? void 0 : _a.call(props);
      }
    },
    import_utils.locales.getText(import_reservationConstants.I18N_NEW)
  ));
}
function ReservationFloorMapCanvasTabsTrailing(props) {
  const { bodyView } = (0, import_materials.useRecordBoardContext)();
  (0, import_react.useEffect)(() => {
    if (bodyView !== "floorMap" && props.mapEditInternal) {
      props.setMapEditInternal(false);
    }
  }, [bodyView, props.mapEditInternal, props.setMapEditInternal]);
  if (props.isFloorModeControlled || bodyView !== "floorMap") return null;
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      size: "middle",
      className: "pisell-reservation-topbar-edit-btn",
      onClick: () => {
        var _a, _b;
        if (props.mapEditInternal) {
          (_b = (_a = props.floorMapLayoutRef.current) == null ? void 0 : _a.saveLayout) == null ? void 0 : _b.call(_a);
        }
        props.setMapEditInternal((v) => !v);
      }
    },
    import_utils.locales.getText(
      props.mapEditInternal ? import_reservationConstants.I18N_EDIT_MAP_DONE : import_reservationConstants.I18N_EDIT_MAP
    )
  );
}
function ReservationDefaultScheduleStart() {
  return /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-reservation-page-title" }, import_utils.locales.getText(import_reservationConstants.I18N_PAGE_TITLE));
}
function ReservationVenueScheduleStart() {
  return /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-reservation-page-title" }, import_utils.locales.getText(import_reservationConstants.I18N_PAGE_TITLE_VENUE));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PisellReservationScheduleEndActions,
  PisellReservationToolbarTabs,
  RecordBoardBodyViewCapture,
  ReservationDefaultScheduleStart,
  ReservationFloorMapCanvasTabsTrailing,
  ReservationGridTopRight,
  ReservationVenueScheduleStart,
  ScheduleSyncOnFloorEnter
});
