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/components/booking/adjustTime/AdjustTimeModalHost.tsx
var AdjustTimeModalHost_exports = {};
__export(AdjustTimeModalHost_exports, {
  AdjustTimeModalHost: () => AdjustTimeModalHost,
  default: () => AdjustTimeModalHost_default
});
module.exports = __toCommonJS(AdjustTimeModalHost_exports);
var import_react = __toESM(require("react"));
var import_adjustTime = require("../../../plus/salesSdk/adjustTime");
var import_model = require("../info/model");
var import_adapter = require("./adapter");
var AdjustTimeModalHost = () => {
  var _a, _b, _c;
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
  const open = Boolean((_a = state.service) == null ? void 0 : _a.addTimeModal);
  const cacheItem = (_b = state.service) == null ? void 0 : _b.cacheItem;
  const resourceEndTime = (0, import_react.useMemo)(() => {
    if (!open || !cacheItem) return void 0;
    return (0, import_adapter.getResourceEndTime)(state, cacheItem);
  }, [open, cacheItem, (_c = state.service) == null ? void 0 : _c.resourcesOrigin]);
  const booking = (0, import_react.useMemo)(() => {
    if (!cacheItem) return null;
    return (0, import_adapter.mapAdjustTimeBooking)(cacheItem);
  }, [cacheItem]);
  const products = (0, import_react.useMemo)(() => {
    if (!cacheItem) return [];
    return (0, import_adapter.mapAdjustTimeProducts)(state, cacheItem);
  }, [cacheItem, state.addTimeProducts]);
  const handleClose = () => {
    dispatch({
      type: "setService",
      payload: {
        addTimeModal: false
      }
    });
  };
  if (!booking) {
    return null;
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_adjustTime.AdjustTimeModal,
    {
      open,
      booking,
      products,
      resourceEndTime,
      currencySymbol: state.amountSymbol || "$",
      onCancel: handleClose,
      onCheckout: (result) => {
        handleClose();
        console.info("[AdjustTime] checkout result", result);
      }
    }
  );
};
var AdjustTimeModalHost_default = AdjustTimeModalHost;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AdjustTimeModalHost
});
