/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-b859c78 | Cube Dev Team */
import { TooltipProvider } from "../../overlays/Tooltip/TooltipProvider.js";
import { MenuItem } from "./MenuItem.js";
import { StyledMenu, StyledSection, StyledSectionHeading } from "./styled.js";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { useMenuSection } from "react-aria";

//#region src/components/actions/Menu/MenuSection.tsx
/** @private */
function MenuSection(props) {
	const { item, state, styles, itemStyles, headingStyles, size } = props;
	const heading = item.rendered;
	const { itemProps, headingProps, groupProps } = useMenuSection({
		heading,
		"aria-label": item["aria-label"]
	});
	return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(StyledSection, {
		...itemProps,
		styles,
		children: [heading && /* @__PURE__ */ jsx(StyledSectionHeading, {
			...headingProps,
			size,
			styles: headingStyles,
			children: heading
		}), /* @__PURE__ */ jsx(StyledMenu, {
			...groupProps,
			mods: { section: true },
			children: [...item.childNodes].map((node) => {
				let menuItem = /* @__PURE__ */ jsx(MenuItem, {
					item: node,
					styles: itemStyles,
					state,
					size,
					onAction: node.onAction
				}, node.key);
				if (node.props.tooltip) menuItem = /* @__PURE__ */ jsx(TooltipProvider, {
					activeWrap: true,
					placement: "right",
					...typeof node.props.tooltip === "string" ? { title: node.props.tooltip } : node.props.tooltip,
					children: menuItem
				}, node.key);
				if (node.props.wrapper) menuItem = node.props.wrapper(menuItem);
				return menuItem;
			})
		})]
	}) });
}

//#endregion
export { MenuSection };
//# sourceMappingURL=MenuSection.js.map