const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_status = require("../../status.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/plus/productSelect/ProductCard/SkuCard/components/Action/index.tsx
const Action = ({ props, className }) => {
	const { skuActionConfig, dataSource, onAction } = props;
	const { isOpen, method, slot, iconMethod, radioMethod, checkboxMethod, buttonMethod } = skuActionConfig || {};
	if (!isOpen) return null;
	if (slot) return /* @__PURE__ */ react.default.createElement("div", { className: `${require_status.PREFIX}__card-action ${className}` }, slot);
	const Com = (0, react.useMemo)(() => {
		if (!method) return null;
		const key = {
			icon: iconMethod,
			radio: radioMethod,
			checkbox: checkboxMethod,
			button: buttonMethod
		};
		const { background, paddingY, paddingX, isBorder, borderWidth, borderColor, radius } = key[method];
		const baseStyle = {
			background,
			padding: `${paddingY}px ${paddingX}px`,
			border: isBorder ? `${borderWidth}px solid ${borderColor}` : "none",
			borderRadius: `${radius}px`
		};
		if (method === "icon" || method === "radio") {
			var _key$method;
			return /* @__PURE__ */ react.default.createElement("div", { style: require_objectSpread2._objectSpread2({}, baseStyle) }, ((_key$method = key[method]) === null || _key$method === void 0 ? void 0 : _key$method.icon) || /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
				type: method === "icon" ? "pisell2-arrow-right" : "pisell2-plus",
				size: 24,
				rotate: 0,
				spin: false,
				color: "#ffffff"
			}));
		}
		if (method === "checkbox" || method === "button") {
			const { text, fontSize, fontWeight, color } = key[method];
			return /* @__PURE__ */ react.default.createElement("div", { style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, baseStyle), {}, {
				color,
				fontSize,
				fontWeight,
				width: method === "button" ? "100%" : "auto",
				textAlign: "center"
			}) }, text);
		}
		return null;
	}, [
		method,
		radioMethod,
		checkboxMethod,
		buttonMethod,
		iconMethod
	]);
	return /* @__PURE__ */ react.default.createElement("div", { className: `${require_status.PREFIX}__card-action ${require_status.PREFIX}__card-action-${method} ${className}` }, /* @__PURE__ */ react.default.createElement("div", { onClick: (e) => {
		e.stopPropagation();
		onAction === null || onAction === void 0 || onAction(dataSource);
	} }, Com));
};
//#endregion
exports.default = Action;
