var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/shoppingCart/components/Render/index.tsx
var Render_exports = {};
__export(Render_exports, {
  default: () => Render_default
});
module.exports = __toCommonJS(Render_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_useContext = require("../../hooks/useContext");
var import_Empty = __toESM(require("../Empty"));
var import_utils = require("../../utils");
var import_SelectHolderModal = __toESM(require("../SelectHolderModal"));
var import_Cart = __toESM(require("../Cart"));
var import_index = require("./index.less");
var Content = () => {
  const { state, onChange } = (0, import_useContext.useContext)();
  const selectPetRef = (0, import_react.useRef)();
  const [pet, setPet] = (0, import_react.useState)([]);
  const { isEmpty, className, holders, products, isEdit, platform } = state;
  (0, import_react.useEffect)(() => {
    var _a, _b, _c, _d;
    let _holders = holders == null ? void 0 : holders.filter((item) => (item == null ? void 0 : item.key) > 0);
    if ((_holders == null ? void 0 : _holders.length) && !(pet == null ? void 0 : pet.length) && (products == null ? void 0 : products.length) && !isEdit && platform !== "h5") {
      if (_holders.length === 1) {
        onChange(products, "update_holders", (_a = _holders[0]) == null ? void 0 : _a.key);
        return;
        const _products = (0, import_utils.formatService)(products, (_b = _holders[0]) == null ? void 0 : _b.key);
        onChange(_products);
      } else {
        (_d = (_c = selectPetRef.current) == null ? void 0 : _c.open) == null ? void 0 : _d.call(_c, {
          products,
          holders
        });
      }
    }
    setPet(_holders);
  }, [holders]);
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-lowcode__shopping-cart-wrap", className)
    },
    isEmpty ? /* @__PURE__ */ import_react.default.createElement(import_Empty.default, null) : /* @__PURE__ */ import_react.default.createElement(import_Cart.default, null)
  ), /* @__PURE__ */ import_react.default.createElement(import_SelectHolderModal.default, { ref: selectPetRef, onChange }));
};
var Render_default = Content;
