const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../../utils.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/plus/selectHolder/components/HolderItem/index.tsx
const PREFIX = "pisell-lowcode-holder-item";
const HolderItem = ({ item, displayConfig, value, isAddItem }) => {
	const { showAvatar = true, showTitle = true, showSubtitle = false, selectType = "single", direction = "vertical", showExtraFields = false, extraFields = [] } = displayConfig || {};
	const isSelected = (0, react.useMemo)(() => {
		if (!(value === null || value === void 0 ? void 0 : value.length) || !(item === null || item === void 0 ? void 0 : item.value)) return false;
		return value.includes(item.value);
	}, [value, item === null || item === void 0 ? void 0 : item.value]);
	/**
	* @title: 渲染额外字段
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-10-11 14:24
	*/
	const extraFieldsCom = (0, react.useMemo)(() => {
		if (!showExtraFields || !(extraFields === null || extraFields === void 0 ? void 0 : extraFields.length)) return null;
		return extraFields.map((field) => {
			return /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}-extra-field` }, (field === null || field === void 0 ? void 0 : field.isShowLabel) && /* @__PURE__ */ react.default.createElement("span", { className: `pisell-lowcode-holder-item-extra-field-label` }, field.label, ":"), (field === null || field === void 0 ? void 0 : field.isShowValue) && (field === null || field === void 0 ? void 0 : field.value) && /* @__PURE__ */ react.default.createElement("span", { className: `pisell-lowcode-holder-item-extra-field-value` }, item === null || item === void 0 ? void 0 : item[field.value]));
		});
	}, [
		showExtraFields,
		extraFields,
		item
	]);
	return /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}-wrap ${isSelected ? `${PREFIX}-wrap-selected` : ""}` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellCard, {
		padding: 20,
		selected: isSelected
	}, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}-card ${direction === "horizontal" ? `${PREFIX}-card-horizontal` : ""}` }, showAvatar ? /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, {
		src: item === null || item === void 0 ? void 0 : item.avatar,
		useTextAvatar: !(item === null || item === void 0 ? void 0 : item.avatar) && !isAddItem,
		className: `${isAddItem ? `${PREFIX}-add-avatar` : ""}`,
		size: "xxl"
	}, require_utils.getAvatarText(item.label)) : null, (showTitle || showSubtitle) && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-lowcode-holder-item-info` }, showTitle && /* @__PURE__ */ react.default.createElement("span", { className: `pisell-lowcode-holder-item-name` }, item.label), showSubtitle && item.subtitle && /* @__PURE__ */ react.default.createElement("span", { className: `pisell-lowcode-holder-item-subtitle` }, item.subtitle), extraFieldsCom), selectType === "multiple" && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-lowcode-holder-item-check-icon ${isSelected ? `pisell-lowcode-holder-item-check-icon-selected` : ""}` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: "CheckCircleFilled" })))));
};
//#endregion
exports.default = HolderItem;
