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/components/shoppingCart/server.ts
var server_exports = {};
__export(server_exports, {
  getProductDetail: () => getProductDetail,
  getProducts: () => getProducts
});
module.exports = __toCommonJS(server_exports);
var import_utils = require("../../utils/index");
var getProducts = async (params) => {
  var _a, _b;
  const { ids, isGift = false, schedule_date } = params;
  const queryParams = {
    skip: 1,
    num: (ids == null ? void 0 : ids.length) || 100,
    status: "published",
    ids: ids || [],
    open_quotation: 1,
    schedule_date: schedule_date || void 0,
    open_bundle: 1,
    is_eject: 1,
    open_deposit: 1,
    force_ignore_cache_flag: 1,
    is_append_product_description: 1,
    with_category_tree: 1,
    category_ids: [],
    collection: [],
    with_count: ["bundleGroup", "optionGroup"],
    exclude_extension_type: [
      "product_party",
      "product_event",
      "product_series_event",
      "product_package_ticket",
      "ticket",
      "event_item"
    ],
    with: [
      "category",
      "collection",
      "resourceRelation",
      "bundleGroup.bundleItem",
      "optionGroup.optionItem",
      "variantGroup.variantItem"
    ]
  };
  let { data } = await import_utils.request.getRequest().post(
    "/shop/product/query",
    queryParams,
    {
      fullResult: true,
      useCache: true
    }
  );
  let lists = [];
  if (isGift) {
    lists = (_a = data == null ? void 0 : data.list) == null ? void 0 : _a.map((item) => {
      const originPrice = (item == null ? void 0 : item.price) || 0;
      return {
        ...item,
        price: 0,
        base_price: 0,
        origin_price: originPrice,
        total: 0,
        origin_total: originPrice,
        _extend: {
          price: 0,
          total: 0,
          origin_total: originPrice,
          quantity: (item == null ? void 0 : item.num) || 1
        },
        _initPrice: (item == null ? void 0 : item.price) || 0
      };
    });
  } else {
    lists = lists = (_b = data == null ? void 0 : data.list) == null ? void 0 : _b.map((item) => {
      const originPrice = (item == null ? void 0 : item.origin_price) || 0;
      return {
        ...item,
        total: (item == null ? void 0 : item.price) || 0,
        origin_total: originPrice,
        _extend: {
          price: (item == null ? void 0 : item.price) || 0,
          total: (item == null ? void 0 : item.price) || 0,
          origin_total: originPrice,
          quantity: (item == null ? void 0 : item.num) || 1
        }
      };
    });
  }
  return lists || [];
};
var getProductDetail = async (params) => {
  const { id, is_eject = 1 } = params;
  const queryParams = {
    is_eject
  };
  let { data } = await import_utils.request.getRequest().get(`/shop/product/query/${id}`, queryParams, {
    fullResult: true,
    useCache: true
  });
  return data || {};
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getProductDetail,
  getProducts
});
