import React, { forwardRef } from "react";
import { Action } from "../../ui/action/Action.js";
import { EqualActions } from "../../ui/action/EqualActions.js";
import { After, Before, Contents, StyledHeader } from "./Header.styled.js";
const Header = forwardRef((props, ref) => {
    const { position = "top", before: _before, after: _after, children, ...rest } = props;
    const chld = React.Children.toArray(props.children);
    const justActions = chld.every(c => {
        return c && typeof c === "object" && "type" in c && c.type === Action;
    });
    let contents = children;
    if (justActions) {
        const mode = position === "top" || position === "bottom" ? "horizontal" : "vertical";
        contents = React.createElement(EqualActions, { mode: mode }, contents);
    }
    let before;
    if (props.before != null) {
        before = React.createElement(Before, null, props.before);
    }
    let after;
    if (props.after != null) {
        after = React.createElement(After, null, props.after);
    }
    return (React.createElement(StyledHeader, { ...rest, position: position, "data-header-position": position, ref: ref },
        before,
        React.createElement(Contents, null, contents),
        after));
});
Header.displayName = "Header";
Header.toString = () => StyledHeader.toString();
const HeaderBeforeSelector = Before.toString();
const HeaderContentsSelector = Contents.toString();
const HeaderAfterSelector = After.toString();
export { Header, HeaderBeforeSelector, HeaderContentsSelector, HeaderAfterSelector };
//# sourceMappingURL=Header.js.map