import React from "react";
import { Tag } from "antd";
import { CloseOutlined } from "@ant-design/icons";
//#region src/components/pisellLookup/components/SearchHistory.tsx
/**
* SearchHistory 组件
* 展示搜索历史记录
*/
const SearchHistory = (props) => {
	const { history, onSelect, onRemove, onClear, render, className, style } = props;
	if (!history || history.length === 0) return null;
	if (render) return /* @__PURE__ */ React.createElement(React.Fragment, null, render(history, onSelect));
	/**
	* 处理点击历史记录
	*/
	const handleClick = (keyword) => {
		onSelect(keyword);
	};
	/**
	* 处理删除历史记录
	*/
	const handleRemove = (e, keyword) => {
		e.stopPropagation();
		onRemove === null || onRemove === void 0 || onRemove(keyword);
	};
	return /* @__PURE__ */ React.createElement("div", {
		className: `pisell-lookup-history ${className || ""}`,
		style
	}, /* @__PURE__ */ React.createElement("div", { className: "pisell-lookup-history-list" }, history.map((item, index) => /* @__PURE__ */ React.createElement(Tag, {
		key: `${item}-${index}`,
		className: "pisell-lookup-history-item",
		onClick: () => handleClick(item),
		closable: !!onRemove,
		onClose: (e) => handleRemove(e, item),
		closeIcon: /* @__PURE__ */ React.createElement(CloseOutlined, null)
	}, item))));
};
SearchHistory.displayName = "SearchHistory";
//#endregion
export { SearchHistory };
