/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
import "./Buttons.scss";
import * as React from "react";
import { Dock, useDock } from "./Dock";
import { PinToggle, usePinToggle } from "./PinToggle";
import { PopoutToggle, usePopoutToggle } from "./PopoutToggle";
import { PreviewHorizontalPanelAlignButton, useHorizontalPanelAlignButton, } from "../../preview/horizontal-panel-alignment/PreviewHorizontalPanelAlign";
import { SendBack, useSendBack } from "./SendBack";
import { MoreButton, useDropdownFeatures, } from "../../preview/widget-action-dropdown/MoreButton";
import { MaximizeToggle, useMaximizeToggle, } from "../../preview/enable-maximized-widget/MaximizeToggle";
import { CloseWidgetButton, useCloseTab, } from "../../preview/control-widget-visibility/CloseWidgetButton";
import { AddWidgetButton, useAddTab, } from "../../preview/control-widget-visibility/AddWidgetButton";
/** @internal */
export function TabBarButtons() {
    const features = useWidgetFeatures();
    const [sortedFeatures, isDropdown] = useDropdownFeatures(features);
    const buttons = sortedFeatures.map((feature) => {
        switch (feature) {
            case "popout":
                return React.createElement(PopoutToggle, { key: "popout" });
            case "maximize":
                return React.createElement(MaximizeToggle, { key: "maximize" });
            case "sendBack":
                return React.createElement(SendBack, { key: "sendBack" });
            case "dock":
                return React.createElement(Dock, { key: "dock" });
            case "horizontalAlign":
                return React.createElement(PreviewHorizontalPanelAlignButton, { key: "horizontalAlign" });
            case "pin":
                return React.createElement(PinToggle, { key: "pin" });
            case "closeWidget":
                return React.createElement(CloseWidgetButton, { key: "closeWidget" });
            case "addWidget":
                return React.createElement(AddWidgetButton, { key: "addWidget" });
        }
        return undefined;
    });
    return (React.createElement("div", { className: "nz-widget-buttons" }, isDropdown ? React.createElement(MoreButton, null, buttons) : buttons));
}
/** @internal */
export function useWidgetFeatures() {
    const popoutToggle = usePopoutToggle();
    const maximizeToggle = useMaximizeToggle();
    const sendBack = useSendBack();
    const dock = useDock();
    const horizontalPanelAlignButton = useHorizontalPanelAlignButton();
    const pinToggle = usePinToggle();
    const closeTab = useCloseTab();
    const addTab = useAddTab();
    return [
        ...(addTab ? ["addWidget"] : []),
        ...(closeTab ? ["closeWidget"] : []),
        ...(popoutToggle ? ["popout"] : []),
        ...(maximizeToggle ? ["maximize"] : []),
        ...(sendBack ? ["sendBack"] : []),
        ...(dock ? ["dock"] : []),
        ...(horizontalPanelAlignButton ? ["horizontalAlign"] : []),
        ...(pinToggle ? ["pin"] : []),
    ];
}
//# sourceMappingURL=Buttons.js.map