const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_index = require("../../iconfont/index.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
const require_index$1 = require("../components/Action/index.js");
const require_status = require("../status.js");
const require_locales = require("./locales.js");
const require_index$2 = require("./components/basicInfo/index.js");
const require_index$3 = require("./components/discountReason/index.js");
const require_index$4 = require("./components/timeRange/index.js");
const require_index$5 = require("./components/resources/index.js");
const require_index$6 = require("./components/packages/index.js");
const require_index$7 = require("./components/sales/index.js");
const require_index$8 = require("./components/swipeAction/index.js");
const require_index$9 = require("./components/Note/index.js");
const require_index$10 = require("./components/AmountFooter/index.js");
const require_index$11 = require("./components/MultiDay/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/productCard/cartSkuCard/index.tsx
const _excluded = [
	"dataSource",
	"isShowImage",
	"isShowHolder",
	"isShowNote",
	"isShowDelete",
	"isShowAmountFooter",
	"isShowPackageNote",
	"isShowEditProduct",
	"onEditProduct",
	"onAction",
	"onDelete",
	"onNote",
	"onLike",
	"onCard",
	"onChangeResource",
	"onChangeHolder",
	"type",
	"rightActions",
	"escapeDom"
];
const PREFIX = "pisell-cart-sku-card";
const CartSkuCard = (props) => {
	var _context$appHelper$ut;
	const { dataSource = require_status.defaultValue.dataSource, isShowImage = require_status.defaultValue.isShowImage, isShowHolder = require_status.defaultValue.isShowHolder, isShowNote = require_status.defaultValue.isShowNote, isShowDelete = require_status.defaultValue.isShowDelete, isShowAmountFooter = require_status.defaultValue.isShowAmountFooter, isShowPackageNote = require_status.defaultValue.isShowPackageNote, isShowEditProduct = require_status.defaultValue.isShowEditProduct, onEditProduct, onAction, onDelete, onNote, onLike, onCard, onChangeResource, onChangeHolder, type, rightActions = [], escapeDom } = props, other = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const useOpenNoteRef = (0, react.useRef)();
	const context = require_useEngineContext.default();
	_pisell_utils.locales.init(require_locales.default, ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut = _context$appHelper$ut.storage) === null || _context$appHelper$ut === void 0 ? void 0 : _context$appHelper$ut.get("umi_locale")) || "en");
	console.log("prodcut props", props);
	const { isShowAction, actionText } = dataSource;
	const _rightActions = (0, react.useMemo)(() => {
		const deleteAction = {
			key: "delete",
			text: /* @__PURE__ */ react.default.createElement("div", { style: {
				display: "flex",
				justifyContent: "center",
				alignItems: "center",
				color: "white",
				cursor: "pointer",
				padding: "10px 0px"
			} }, /* @__PURE__ */ react.default.createElement(require_index.default, {
				type: "pisell2-trash-01",
				style: {
					fontSize: 20,
					marginRight: 4
				}
			}), /* @__PURE__ */ react.default.createElement("span", { style: {
				fontSize: 12,
				fontWeight: 500
			} }, _pisell_utils.locales.getText("pisell2.cart.sku-card.actions.delete"))),
			color: "danger",
			onClick: (e) => {
				e.preventDefault();
				e.stopPropagation();
				onDelete === null || onDelete === void 0 || onDelete(dataSource);
			}
		};
		const actions = [...rightActions];
		if (isShowDelete) actions.unshift(deleteAction);
		return actions;
	}, [
		dataSource,
		onDelete,
		isShowDelete,
		rightActions
	]);
	const hideDivider = (0, react.useMemo)(() => {
		return false;
	}, [dataSource]);
	const renderA2 = () => {
		return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			isShowImage,
			dataSource,
			isMainProduct: true
		}), /* @__PURE__ */ react.default.createElement(require_index$3.default, { dataSource }), isShowNote ? /* @__PURE__ */ react.default.createElement(require_index$9.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, other), {}, {
			item: dataSource,
			openNote: () => {
				useOpenNoteRef.current.open({ item: dataSource });
			}
		})) : null);
	};
	const renderA5 = () => {
		var _dataSource$bundle, _dataSource$items;
		return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, isShowDelete ? /* @__PURE__ */ react.default.createElement("div", {
			className: `${PREFIX}__delete-btn`,
			onClick: (e) => {
				e.preventDefault();
				e.stopPropagation();
				onDelete === null || onDelete === void 0 || onDelete(dataSource);
			}
		}, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-trash-01" })) : null, /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			isShowImage,
			dataSource,
			isMainProduct: true,
			type
		}), /* @__PURE__ */ react.default.createElement(require_index$4.default, { dataSource }), /* @__PURE__ */ react.default.createElement(require_index$5.default, { dataSource }), /* @__PURE__ */ react.default.createElement(require_index$6.default, {
			dataSource,
			isShowImage
		}), /* @__PURE__ */ react.default.createElement(require_index$7.default, {
			dataSource,
			hideDivider: !!(dataSource === null || dataSource === void 0 || (_dataSource$bundle = dataSource.bundle) === null || _dataSource$bundle === void 0 ? void 0 : _dataSource$bundle.length),
			isShowImage
		}), ((_dataSource$items = dataSource.items) === null || _dataSource$items === void 0 ? void 0 : _dataSource$items.length) ? /* @__PURE__ */ react.default.createElement(require_index$11.default, {
			dataSource,
			hideDivider
		}) : isShowAmountFooter ? /* @__PURE__ */ react.default.createElement(require_index$10.default, {
			item: dataSource,
			hideDivider,
			type: "total"
		}) : null, isShowNote ? /* @__PURE__ */ react.default.createElement(require_index$9.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, other), {}, {
			item: dataSource,
			openNote: () => {
				useOpenNoteRef.current.open({ item: dataSource });
			}
		})) : null, isShowAction && actionText ? /* @__PURE__ */ react.default.createElement(require_index$1.default, {
			item: dataSource,
			onAction: () => onAction === null || onAction === void 0 ? void 0 : onAction(dataSource)
		}) : null);
	};
	const renderContent = () => {
		if (type === "a5") return renderA5();
		return renderA2();
	};
	return /* @__PURE__ */ react.default.createElement(require_index$8.SwipeAction, {
		closeOnAction: false,
		className: (0, classnames.default)(`${PREFIX}-wrapper`),
		rightActions: _rightActions,
		escapeDom
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)(PREFIX, `${PREFIX}--${type}`),
		onClick: (e) => {
			e.preventDefault();
			e.stopPropagation();
			onCard === null || onCard === void 0 || onCard(dataSource);
		}
	}, renderContent()));
};
//#endregion
exports.PREFIX = PREFIX;
exports.default = CartSkuCard;
