/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Item
 */
import { UiError } from "@itwin/appui-abstract";
import { ConfigurableUiControlType } from "../configurableui/ConfigurableUiControl";
import { UiFramework } from "../UiFramework";
/** Provides information about a tool with a given id, including the ToolUiProvider.
 * @public
 */
export class ToolInformation {
    constructor(toolId) {
        this.toolId = toolId;
    }
    /** Get the ToolUiProvider registered for this tool */
    get toolUiProvider() {
        if (!this._toolUiProvider) {
            let provider;
            if (UiFramework.controls.isRegistered(this.toolId)) {
                provider = UiFramework.controls.create(this.toolId, this.toolId);
            }
            else {
                if (UiFramework.toolSettings.useDefaultToolSettingsProvider &&
                    this.toolId === UiFramework.toolSettings.toolIdForToolSettings)
                    provider = UiFramework.controls.create("DefaultToolSettings", this.toolId);
            }
            if (provider) {
                if (provider.getType() !== ConfigurableUiControlType.ToolUiProvider) {
                    // eslint-disable-next-line deprecation/deprecation
                    throw new UiError(UiFramework.loggerCategory(this), `toolUiProvider: toolId '${this.toolId}' is registered to a control that is NOT a ToolUiProvider`);
                }
                this._toolUiProvider = provider;
            }
        }
        return this._toolUiProvider;
    }
}
//# sourceMappingURL=ToolInformation.js.map