import { PREFIX } from "../../index.js";
import React from "react";
import { Tag } from "antd";
import "./index.less";
//#region src/components/productCard/cartSkuCard/components/resources/index.tsx
const colors = [
	"magenta",
	"volcano",
	"orange",
	"gold",
	"green",
	"cyan",
	"blue",
	"geekblue",
	"purple"
];
function getColor(n) {
	return colors[n * 31 % colors.length];
}
const Resources = (props) => {
	const { dataSource = {} } = props;
	const { multiResources, isMultipleResource } = dataSource;
	const renderResourceItem = (item, index) => {
		const { id: ids, lists, _id } = item;
		return Array.isArray(ids) ? ids.map((id) => {
			const targetRes = lists.find((l) => l.id === id);
			if (targetRes === null || targetRes === void 0 ? void 0 : targetRes.label) return /* @__PURE__ */ React.createElement(Tag, {
				color: getColor(_id),
				className: "resource-tag"
			}, targetRes.label);
			return null;
		}) : null;
	};
	if (isMultipleResource && (multiResources === null || multiResources === void 0 ? void 0 : multiResources.length) > 0) return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__resources` }, multiResources.map(renderResourceItem));
	return null;
};
//#endregion
export { Resources as default };
