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/resolveMultiDayQuotation.ts
var resolveMultiDayQuotation_exports = {};
__export(resolveMultiDayQuotation_exports, {
  applyMultiDayQuotationToCacheItem: () => applyMultiDayQuotationToCacheItem,
  resolveMultiDayQuotation: () => resolveMultiDayQuotation
});
module.exports = __toCommonJS(resolveMultiDayQuotation_exports);
var import_utils = require("../../../components/booking/info/utils");
var import_utils2 = require("../../../components/booking/info/service2/utils");
function applyMultiDayQuotationToCacheItem(cacheItem, quotation) {
  var _a;
  const next = {
    ...cacheItem,
    _extend: { ...cacheItem._extend || {} }
  };
  next._extend.multiDayPrices = (0, import_utils.getMultiDayPrices)(quotation.multiDayPrices || []);
  if (!((_a = quotation.multiDayPrices) == null ? void 0 : _a.length)) {
    next._extend.price = quotation.price;
  }
  return next;
}
async function resolveMultiDayQuotation(input) {
  var _a, _b, _c, _d, _e;
  const { cacheItem, bookingState } = input;
  const productId = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
  if (productId == null || productId === "") {
    console.warn("[SalesSdk] resolveMultiDayQuotation: 缺少 product_id，跳过跨日报价");
    return {
      multiDayPrices: [],
      price: Number((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.price) || 0
    };
  }
  const bookingStateForApi = {
    ...bookingState,
    service: {
      ...(bookingState == null ? void 0 : bookingState.service) || {},
      cacheItem
    }
  };
  const fetched = await (0, import_utils2.updateAppointmentServicePrice)(bookingStateForApi, {
    start_date: ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.start_date) ?? ((_c = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _c.startDate),
    end_date: ((_d = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _d.end_date) ?? ((_e = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _e.endDate),
    product_id: productId
  });
  return {
    multiDayPrices: (fetched == null ? void 0 : fetched.multiDayPrices) ?? [],
    price: Number(fetched == null ? void 0 : fetched.price) || 0
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  applyMultiDayQuotationToCacheItem,
  resolveMultiDayQuotation
});
