import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { PREFIX } from "../../status.js";
import React, { useMemo } from "react";
import { Icon } from "@pisell/materials";
import "./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.createElement("div", { className: `${PREFIX}__card-action ${className}` }, slot);
	const Com = 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.createElement("div", { style: _objectSpread2({}, baseStyle) }, ((_key$method = key[method]) === null || _key$method === void 0 ? void 0 : _key$method.icon) || /* @__PURE__ */ React.createElement(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.createElement("div", { style: _objectSpread2(_objectSpread2({}, baseStyle), {}, {
				color,
				fontSize,
				fontWeight,
				width: method === "button" ? "100%" : "auto",
				textAlign: "center"
			}) }, text);
		}
		return null;
	}, [
		method,
		radioMethod,
		checkboxMethod,
		buttonMethod,
		iconMethod
	]);
	return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__card-action ${PREFIX}__card-action-${method} ${className}` }, /* @__PURE__ */ React.createElement("div", { onClick: (e) => {
		e.stopPropagation();
		onAction === null || onAction === void 0 || onAction(dataSource);
	} }, Com));
};
//#endregion
export { Action as default };
