const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_locales = require("../../locales.js");
const require_useContext = require("../../hooks/useContext.js");
const require_index = require("../Empty/index.js");
const require_Product = require("./Product.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/shoppingCart/components/Cart/index.tsx
_pisell_utils.locales.init(require_locales.default, localStorage.getItem("umi_locale") || "en");
const Cart = () => {
	const { state, updateState, onActiveKey } = require_useContext.useContext();
	const { platform, carts, isProductList, collapseParams } = state;
	/**
	* @title: 折叠面板
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-11-27 15:01
	*/
	const cartsMap = (0, react.useMemo)(() => {
		return carts === null || carts === void 0 ? void 0 : carts.map((item) => {
			var _item$products, _item$products2, _item$products3;
			const _length = item === null || item === void 0 || (_item$products = item.products) === null || _item$products === void 0 ? void 0 : _item$products.length;
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
				label: /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__shopping-cart-label" }, `${item === null || item === void 0 ? void 0 : item.label} ${_pisell_utils.locales.getText("pisell2.text.shopping-cart.item")(item === null || item === void 0 || (_item$products2 = item.products) === null || _item$products2 === void 0 ? void 0 : _item$products2.length)}`),
				children: (item === null || item === void 0 || (_item$products3 = item.products) === null || _item$products3 === void 0 ? void 0 : _item$products3.length) > 0 ? /* @__PURE__ */ react.default.createElement(require_Product.default, {
					id: item === null || item === void 0 ? void 0 : item.key,
					lists: item === null || item === void 0 ? void 0 : item.products,
					isAdd: state.maxLength > _length
				}) : /* @__PURE__ */ react.default.createElement(require_index.default, { id: item === null || item === void 0 ? void 0 : item.key }),
				showArrow: platform === "shop"
			});
		});
	}, [carts, platform]);
	return (0, react.useMemo)(() => {
		console.log("render cart 22222", state.prodcuts);
		return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-lowcode__shopping-cart") }, isProductList ? /* @__PURE__ */ react.default.createElement(require_Product.default, {
			id: void 0,
			lists: state === null || state === void 0 ? void 0 : state.products
		}) : /* @__PURE__ */ react.default.createElement(_pisell_materials.Collapse, require_objectSpread2._objectSpread2({
			items: cartsMap,
			showHeader: true,
			panelBackground: "#ffffff",
			collapsible: platform !== "shop" ? "disabled" : "-",
			accordion: platform === "shop",
			onChange: (key) => {
				updateState({ activeKey: key });
				onActiveKey(key);
			}
		}, collapseParams)));
	}, [
		isProductList,
		cartsMap,
		platform,
		collapseParams,
		state === null || state === void 0 ? void 0 : state.products
	]);
};
//#endregion
exports.default = Cart;
