/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Utilities
 */
/** A set of Dom helper methods
 * @public
 */
export class ToolbarButtonHelper {
    static searchToolbarsByTitle(title, horizontal) {
        // first look for simple tool buttons
        const nodeList = document.documentElement.querySelectorAll(`div.nz-toolbar-items.nz-${horizontal ? "horizontal" : "vertical"}.nz-items .nz-toolbar-item-item`);
        // istanbul ignore else
        if (nodeList && nodeList.length > 0) {
            for (const node of nodeList) {
                const button = node;
                if (button.title === title) {
                    return button;
                }
            }
        }
        return null;
    }
    /** Search Horizontal Toolbars for button by title. */
    static searchHorizontalToolbarsByTitle(title) {
        return ToolbarButtonHelper.searchToolbarsByTitle(title, true);
    }
    /** Search Vertical Toolbars by Title for button by title. */
    static searchVerticalToolbarsByTitle(title) {
        return ToolbarButtonHelper.searchToolbarsByTitle(title, false);
    }
    /** Get toolbar button by title. */
    static getToolbarButtonByTitle(title) {
        let button = ToolbarButtonHelper.searchHorizontalToolbarsByTitle(title);
        // istanbul ignore if
        if (button)
            return button;
        button = ToolbarButtonHelper.searchVerticalToolbarsByTitle(title);
        // istanbul ignore else
        if (button)
            return button;
        // istanbul ignore next
        return null;
    }
    /** Get App button. */
    static getAppButton() {
        const node = document.documentElement.querySelector("div.nz-app-button > button");
        // istanbul ignore else
        if (node)
            return node;
        // istanbul ignore next
        return null;
    }
}
//# sourceMappingURL=ToolbarButtonHelper.js.map