/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
import "./HeaderTopBar.scss";
import classNames from "classnames";
import * as React from "react";
import { HeaderIconToolbar } from "./HeaderIconToolbar.js";
/**
 * Internal layout component that renders the top bar of the widget header,
 * including optional left content and a top-right icon/search area.
 * @internal
 */
export function HeaderTopBar(props) {
    const menuIcons = React.useMemo(() => {
        let icons = props.icons || [];
        if (props.onSearch) {
            if (icons.length > 0)
                icons = [
                    { type: "divider", key: "search-divider" },
                    ...icons.map((icon, index) => icon.type === "divider"
                        ? { ...icon, key: `divider-${index}` }
                        : icon),
                ];
            icons = [{ type: "search" }, ...icons];
        }
        return icons;
    }, [props.icons, props.onSearch]);
    const searchExpandedState = React.useState(false);
    return (React.createElement("div", { className: classNames("nz-widget-widgetContentLayout-header-headerTopBar", (props.primaryContent.length === 0 || menuIcons.length === 0) &&
            "nz-singleColumn"), "data-search-expanded": searchExpandedState[0] },
        props.primaryContent.length > 0 && (React.createElement("div", { className: "nz-primaryContent" }, props.primaryContent)),
        menuIcons.length > 0 && (React.createElement(HeaderIconToolbar, { menuIcons: menuIcons, onSearch: props.onSearch, searchExpandedState: searchExpandedState, iconSize: props.iconSize }))));
}
//# sourceMappingURL=HeaderTopBar.js.map