/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module UiProvider
 */
import { StageUsage } from "../frontstage/StageUsage.js";
import { UiItemsManager } from "./UiItemsManager.js";
/** Base implementation of a UiItemsProvider. The base class allows the user to pass in a function that is used to determine if the
 * active stage should be provided items. Derived provider classes should override the `xxxInternal` methods to provide items.
 * @public
 * @deprecated in 4.17.0. Use {@link UiItemsProviderOverrides} to specify supported frontstages when registering the provider.
 */
export class BaseUiItemsProvider {
    _providerId;
    isSupportedStage;
    /*
     * @param providerId - unique identifier for this instance of the provider. This is required in case separate packages want
     * to set up custom stage with their own subset of standard tools.
     * @param isSupportedStage - optional function that will be called to determine if tools should be added to current stage. If not set and
     * the current stage's `usage` is set to `StageUsage.General` then the provider will add items to frontstage.
     */
    constructor(_providerId, isSupportedStage) {
        this._providerId = _providerId;
        this.isSupportedStage = isSupportedStage;
    }
    get id() {
        return this._providerId;
    }
    onUnregister() { }
    unregister() {
        UiItemsManager.unregister(this._providerId);
    }
    provideToolbarItemsInternal(_stageId, _stageUsage, _toolbarUsage, _toolbarOrientation, _stageAppData) {
        return [];
    }
    provideToolbarItems(stageId, stageUsage, toolbarUsage, toolbarOrientation, stageAppData) {
        let provideToStage = false;
        if (this.isSupportedStage) {
            provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
        }
        else {
            provideToStage = stageUsage === StageUsage.General.valueOf();
        }
        return provideToStage
            ? this.provideToolbarItemsInternal(stageId, stageUsage, toolbarUsage, toolbarOrientation, stageAppData)
            : [];
    }
    provideStatusBarItemsInternal(_stageId, _stageUsage, _stageAppData) {
        return [];
    }
    provideStatusBarItems(stageId, stageUsage, stageAppData) {
        let provideToStage = false;
        if (this.isSupportedStage) {
            provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
        }
        else {
            provideToStage = stageUsage === StageUsage.General.valueOf();
        }
        return provideToStage
            ? this.provideStatusBarItemsInternal(stageId, stageUsage, stageAppData)
            : [];
    }
    provideWidgetsInternal(_stageId, _stageUsage, _location, _section, _stageAppData) {
        return [];
    }
    provideWidgets(stageId, stageUsage, location, section, stageAppData) {
        let provideToStage = false;
        if (this.isSupportedStage) {
            provideToStage = this.isSupportedStage(stageId, stageUsage, stageAppData, this);
        }
        else {
            provideToStage = stageUsage === StageUsage.General.valueOf();
        }
        return provideToStage
            ? this.provideWidgetsInternal(stageId, stageUsage, location, section, stageAppData)
            : [];
    }
}
//# sourceMappingURL=BaseUiItemsProvider.js.map