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/giftSelect/resolveCatalogProductId.ts
var resolveCatalogProductId_exports = {};
__export(resolveCatalogProductId_exports, {
  normalizeCatalogProduct: () => normalizeCatalogProduct,
  resolveCatalogProductId: () => resolveCatalogProductId
});
module.exports = __toCommonJS(resolveCatalogProductId_exports);
function resolveCatalogProductId(product) {
  var _a, _b;
  if (!product) return null;
  const candidates = [
    product.id,
    product.product_id,
    (_b = (_a = product._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.product_id
  ];
  for (const raw of candidates) {
    const n = Number(raw);
    if (Number.isFinite(n) && n > 0) {
      return Math.floor(n);
    }
  }
  return null;
}
function normalizeCatalogProduct(product) {
  const productId = resolveCatalogProductId(product);
  if (!productId) return product;
  return {
    ...product,
    id: productId,
    product_id: productId
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  normalizeCatalogProduct,
  resolveCatalogProductId
});
