/*---------------------------------------------------------------------------------------------
 * 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
 */
import { panelSides } from "../widget-panels/Panel";
/** @internal */
export function isFloatingWidgetLocation(location) {
    return "floatingWidgetId" in location;
}
/** @internal */
export function isPopoutWidgetLocation(location) {
    return "popoutWidgetId" in location;
}
/** @internal */
export function isPanelWidgetLocation(location) {
    return "side" in location;
}
/** Returns a widget location or `undefined` if widget is not found.
 * @internal
 */
export 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 panelSides) {
        const panel = state.panels[side];
        const index = panel.widgets.indexOf(id);
        if (index >= 0) {
            return {
                side,
                index,
            };
        }
    }
    return undefined;
}
//# sourceMappingURL=WidgetLocation.js.map