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");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/actionBar/index.tsx
const _excluded = [
	"headerProps",
	"contentProps",
	"footerProps"
];
const ActionBar = (0, react.forwardRef)((props, ref) => {
	const { headerProps, contentProps, footerProps } = props, restProps = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const [slot, setSlot] = (0, react.useState)([]);
	const set = (dom) => {
		setSlot((prev) => [...prev, dom]);
	};
	const destroyAll = () => {
		setSlot([]);
	};
	const destroyById = (id) => {
		setSlot((prev) => prev.filter((item) => item.id !== id));
	};
	(0, react.useEffect)(() => {
		document.body.id = "body";
		window.actionBar = {
			set,
			destroyAll,
			destroyById
		};
		return () => {
			window.actionBar = null;
		};
	}, []);
	(0, react.useImperativeHandle)(ref, () => ({
		set,
		destroyAll,
		destroyById
	}));
	const header = (0, react.useMemo)(() => {
		return slot.filter((item) => item.position === "header").sort((a, b) => a.sort - b.sort).map((item) => item.component);
	}, [slot]);
	const content = (0, react.useMemo)(() => {
		return slot.filter((item) => item.position === "content").sort((a, b) => a.sort - b.sort).map((item) => item.component);
	}, [slot]);
	const footer = (0, react.useMemo)(() => {
		return slot.filter((item) => item.position === "footer").sort((a, b) => a.sort - b.sort).map((item) => item.component);
	}, [slot]);
	return /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, restProps), {}, { className: (0, classnames.default)("pisell-action-bar", restProps.className) }), /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, headerProps), {}, { className: (0, classnames.default)("pisell-action-bar-header", headerProps === null || headerProps === void 0 ? void 0 : headerProps.className) }), header), /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, contentProps), {}, { className: (0, classnames.default)("pisell-action-bar-content", contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }), content), /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, footerProps), {}, { className: (0, classnames.default)("pisell-action-bar-footer", footerProps === null || footerProps === void 0 ? void 0 : footerProps.className) }), footer));
});
//#endregion
exports.default = ActionBar;
