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");
require("./gridComponents.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
//#region src/plus/productSelect/ProductList/index.tsx
const _excluded = ["children"], _excluded2 = ["children", "index"];
const DefaultListComponent = (0, react.memo)((_ref) => {
	let { children } = _ref, listProps = require_objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
	return /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2({ className: "product-list-wrapper" }, listProps), children);
});
const DefaultItemComponent = (0, react.memo)((_ref2) => {
	let { children, index } = _ref2, itemProps = require_objectWithoutProperties._objectWithoutProperties(_ref2, _excluded2);
	return /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, itemProps), {}, {
		"data-index": index,
		"data-item-index": index
	}), children);
});
const ProductList = (0, react.forwardRef)((props, ref) => {
	const { className, data, context, components, itemContent } = props;
	const ListComponent = (0, react.useMemo)(() => (components === null || components === void 0 ? void 0 : components.List) || DefaultListComponent, [components === null || components === void 0 ? void 0 : components.List]);
	const ItemComponent = (0, react.useMemo)(() => (components === null || components === void 0 ? void 0 : components.Item) || DefaultItemComponent, [components === null || components === void 0 ? void 0 : components.Item]);
	const itemContentRenderer = (0, react.useMemo)(() => {
		if (itemContent) return (item, index) => itemContent(index, item, context);
		return (item, index) => /* @__PURE__ */ react.default.createElement("div", null, index);
	}, [itemContent, context]);
	const renderedItems = (0, react.useMemo)(() => {
		return data === null || data === void 0 ? void 0 : data.map((item, index) => {
			const content = itemContentRenderer(item, index);
			return /* @__PURE__ */ react.default.createElement(ItemComponent, {
				key: `${item.id || index}-${index}`,
				item,
				index,
				"data-index": index,
				"data-item-index": index,
				context
			}, content);
		});
	}, [
		data,
		ItemComponent,
		itemContentRenderer
	]);
	return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)(className) }, /* @__PURE__ */ react.default.createElement(ListComponent, {
		ref,
		context
	}, renderedItems));
});
//#endregion
exports.default = ProductList;
