"use strict";
/*---------------------------------------------------------------------------------------------
 * 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useWidgetFeatures = exports.TabBarButtons = void 0;
require("./Buttons.scss");
const React = require("react");
const Dock_1 = require("./Dock");
const PinToggle_1 = require("./PinToggle");
const PopoutToggle_1 = require("./PopoutToggle");
const PreviewHorizontalPanelAlign_1 = require("../../preview/horizontal-panel-alignment/PreviewHorizontalPanelAlign");
const SendBack_1 = require("./SendBack");
const MoreButton_1 = require("../../preview/widget-action-dropdown/MoreButton");
const MaximizeToggle_1 = require("../../preview/enable-maximized-widget/MaximizeToggle");
const CloseWidgetButton_1 = require("../../preview/control-widget-visibility/CloseWidgetButton");
const AddWidgetButton_1 = require("../../preview/control-widget-visibility/AddWidgetButton");
/** @internal */
function TabBarButtons() {
    const features = useWidgetFeatures();
    const [sortedFeatures, isDropdown] = (0, MoreButton_1.useDropdownFeatures)(features);
    const buttons = sortedFeatures.map((feature) => {
        switch (feature) {
            case "popout":
                return React.createElement(PopoutToggle_1.PopoutToggle, { key: "popout" });
            case "maximize":
                return React.createElement(MaximizeToggle_1.MaximizeToggle, { key: "maximize" });
            case "sendBack":
                return React.createElement(SendBack_1.SendBack, { key: "sendBack" });
            case "dock":
                return React.createElement(Dock_1.Dock, { key: "dock" });
            case "horizontalAlign":
                return React.createElement(PreviewHorizontalPanelAlign_1.PreviewHorizontalPanelAlignButton, { key: "horizontalAlign" });
            case "pin":
                return React.createElement(PinToggle_1.PinToggle, { key: "pin" });
            case "closeWidget":
                return React.createElement(CloseWidgetButton_1.CloseWidgetButton, { key: "closeWidget" });
            case "addWidget":
                return React.createElement(AddWidgetButton_1.AddWidgetButton, { key: "addWidget" });
        }
        return undefined;
    });
    return (React.createElement("div", { className: "nz-widget-buttons" }, isDropdown ? React.createElement(MoreButton_1.MoreButton, null, buttons) : buttons));
}
exports.TabBarButtons = TabBarButtons;
/** @internal */
function useWidgetFeatures() {
    const popoutToggle = (0, PopoutToggle_1.usePopoutToggle)();
    const maximizeToggle = (0, MaximizeToggle_1.useMaximizeToggle)();
    const sendBack = (0, SendBack_1.useSendBack)();
    const dock = (0, Dock_1.useDock)();
    const horizontalPanelAlignButton = (0, PreviewHorizontalPanelAlign_1.useHorizontalPanelAlignButton)();
    const pinToggle = (0, PinToggle_1.usePinToggle)();
    const closeTab = (0, CloseWidgetButton_1.useCloseTab)();
    const addTab = (0, AddWidgetButton_1.useAddTab)();
    return [
        ...(addTab ? ["addWidget"] : []),
        ...(closeTab ? ["closeWidget"] : []),
        ...(popoutToggle ? ["popout"] : []),
        ...(maximizeToggle ? ["maximize"] : []),
        ...(sendBack ? ["sendBack"] : []),
        ...(dock ? ["dock"] : []),
        ...(horizontalPanelAlignButton ? ["horizontalAlign"] : []),
        ...(pinToggle ? ["pin"] : []),
    ];
}
exports.useWidgetFeatures = useWidgetFeatures;
//# sourceMappingURL=Buttons.js.map