"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 Base
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWidgetLocation = exports.isPanelWidgetLocation = exports.isPopoutWidgetLocation = exports.isFloatingWidgetLocation = void 0;
const Panel_1 = require("../widget-panels/Panel");
/** @internal */
function isFloatingWidgetLocation(location) {
    return "floatingWidgetId" in location;
}
exports.isFloatingWidgetLocation = isFloatingWidgetLocation;
/** @internal */
function isPopoutWidgetLocation(location) {
    return "popoutWidgetId" in location;
}
exports.isPopoutWidgetLocation = isPopoutWidgetLocation;
/** @internal */
function isPanelWidgetLocation(location) {
    return "side" in location;
}
exports.isPanelWidgetLocation = isPanelWidgetLocation;
/** Returns a widget location or `undefined` if widget is not found.
 * @internal
 */
function getWidgetLocation(state, id) {
    if (id in state.floatingWidgets.byId) {
        return {
            floatingWidgetId: id,
        };
    }
    if (state.popoutWidgets) {
        if (id in state.popoutWidgets.byId) {
            return {
                popoutWidgetId: id,
            };
        }
    }
    for (const side of Panel_1.panelSides) {
        const panel = state.panels[side];
        const index = panel.widgets.indexOf(id);
        if (index >= 0) {
            return {
                side,
                index,
            };
        }
    }
    return undefined;
}
exports.getWidgetLocation = getWidgetLocation;
//# sourceMappingURL=WidgetLocation.js.map