var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/salesSdk/utils/expandMultiDayCacheItem.ts
var expandMultiDayCacheItem_exports = {};
__export(expandMultiDayCacheItem_exports, {
  expandMultiDayCacheItem: () => expandMultiDayCacheItem
});
module.exports = __toCommonJS(expandMultiDayCacheItem_exports);
var import_resolveIsMultiDayProduct = require("./resolveIsMultiDayProduct");
var import_multiDayPriceCache = require("./multiDayPriceCache");
var import_hasMultiDayDateRange = require("./hasMultiDayDateRange");
var import_resolveMultiDayQuotation = require("./resolveMultiDayQuotation");
var import_mergeCatalogDurationIntoCacheItem = require("./mergeCatalogDurationIntoCacheItem");
var import_utils = require("../../../components/booking/info/service2/Group/utils");
async function expandMultiDayCacheItem(cacheItem, bookingState, options) {
  var _a, _b;
  const catalogItem = (options == null ? void 0 : options.catalogItem) ?? null;
  const working = (0, import_mergeCatalogDurationIntoCacheItem.mergeCatalogDurationIntoCacheItem)(cacheItem, catalogItem);
  if (!(0, import_resolveIsMultiDayProduct.resolveIsMultiDayProduct)(working, catalogItem)) {
    return cacheItem;
  }
  if (!(0, import_hasMultiDayDateRange.hasMultiDayDateRange)(working)) {
    return cacheItem;
  }
  const customerId = (_b = (_a = bookingState == null ? void 0 : bookingState.client) == null ? void 0 : _a.value) == null ? void 0 : _b.id;
  let next = working;
  if (!(0, import_multiDayPriceCache.hasMatchingMultiDayQuotationOnCacheItem)(working)) {
    const quotation = await (0, import_resolveMultiDayQuotation.resolveMultiDayQuotation)({
      cacheItem: working,
      bookingState,
      customerId
    });
    next = (0, import_resolveMultiDayQuotation.applyMultiDayQuotationToCacheItem)(working, quotation);
  }
  next = (0, import_utils.createBookingItemsByGroup)(next);
  if (options == null ? void 0 : options.concatBookings) {
    next = (0, import_utils.concatBookings)(next);
    next = { ...next, new: 0 };
  }
  return next;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  expandMultiDayCacheItem
});
