"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 Backstage
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.InternalBackstageManager = void 0;
const core_bentley_1 = require("@itwin/core-bentley");
const CommandItemDef_1 = require("../shared/CommandItemDef");
const UiFramework_1 = require("../UiFramework");
/** Controls backstage.
 * @internal
 */
class InternalBackstageManager {
    constructor() {
        this._isOpen = false;
        /** Event raised when backstage is opened or closed. */
        this.onToggled = new core_bentley_1.BeEvent();
    }
    get isOpen() {
        return this._isOpen;
    }
    setIsOpen(isOpen) {
        if (isOpen === this._isOpen)
            return;
        this._isOpen = isOpen;
        this.onToggled.raiseEvent({
            isOpen,
        });
    }
    open() {
        this.setIsOpen(true);
    }
    close() {
        this.setIsOpen(false);
    }
    toggle() {
        this.setIsOpen(!this.isOpen);
    }
    /** Get CommandItemDef that will toggle display of Backstage and allow iconSpec to be overridden */
    getBackstageToggleCommand(overrideIconSpec) {
        // eslint-disable-next-line deprecation/deprecation
        return new CommandItemDef_1.CommandItemDef({
            commandId: "UiFramework.openBackstage",
            iconSpec: overrideIconSpec ? overrideIconSpec : "icon-home",
            labelKey: "UiFramework:commands.openBackstage",
            execute: () => {
                UiFramework_1.UiFramework.backstage.toggle();
            },
        });
    }
}
exports.InternalBackstageManager = InternalBackstageManager;
//# sourceMappingURL=InternalBackstageManager.js.map