import Buttons from "./Buttons/index.js";
import PageHeader from "../../page-header/index.js";
import React, { useMemo } from "react";
import { isFunction } from "@pisell/utils";
import "./index.less";
//#region src/components/table/Header/index.tsx
const Header = ({ buttons, title, subTitle, showTitle, showSubTitle }) => {
	const showHeader = useMemo(() => {
		return title && showTitle || (Array.isArray(buttons) ? buttons.length > 0 : buttons) || subTitle && showSubTitle;
	}, [
		buttons,
		title,
		subTitle,
		showTitle,
		showSubTitle
	]);
	const titleNode = useMemo(() => {
		if (isFunction(title)) return title();
		return title;
	}, [title]);
	const buttonsNode = useMemo(() => {
		if (Array.isArray(buttons)) return /* @__PURE__ */ React.createElement(Buttons, { list: buttons });
		return buttons;
	}, [buttons]);
	const subTitleNode = useMemo(() => {
		if (isFunction(subTitle)) return subTitle();
		return subTitle;
	}, [subTitle]);
	return showHeader ? /* @__PURE__ */ React.createElement(PageHeader, {
		title: titleNode,
		showTitle,
		subTitle: subTitleNode,
		showSubTitle,
		extra: buttonsNode
	}) : null;
};
//#endregion
export { Header as default };
