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/resolveConfirmDetailQuantity.ts
var resolveConfirmDetailQuantity_exports = {};
__export(resolveConfirmDetailQuantity_exports, {
  resolveAddQuantityFromCacheItem: () => resolveAddQuantityFromCacheItem,
  resolveConfirmDetailQuantity: () => resolveConfirmDetailQuantity
});
module.exports = __toCommonJS(resolveConfirmDetailQuantity_exports);
function resolveConfirmDetailQuantity(input) {
  var _a, _b, _c, _d, _e, _f;
  const fromDetail = Number(
    ((_c = (_b = (_a = input.detailResult) == null ? void 0 : _a.detail) == null ? void 0 : _b._extend) == null ? void 0 : _c.quantity) ?? ((_e = (_d = input.detailResult) == null ? void 0 : _d.e) == null ? void 0 : _e.quantity)
  );
  if (Number.isFinite(fromDetail) && fromDetail > 0) {
    return Math.floor(fromDetail);
  }
  const fallback = (_f = input.options) == null ? void 0 : _f.quantity;
  if (fallback != null && fallback > 0) {
    return Math.floor(fallback);
  }
  return void 0;
}
function resolveAddQuantityFromCacheItem(cacheItem, explicitQuantity) {
  var _a;
  const fromCache = Number((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.quantity);
  if (Number.isFinite(fromCache) && fromCache > 0) {
    return Math.floor(fromCache);
  }
  if (explicitQuantity != null && explicitQuantity > 0) {
    return Math.floor(explicitQuantity);
  }
  return void 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  resolveAddQuantityFromCacheItem,
  resolveConfirmDetailQuantity
});
