/*---------------------------------------------------------------------------------------------
 * 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 { getWidgetLocation, isFloatingWidgetLocation, isPopoutWidgetLocation, } from "./WidgetLocation.js";
/** @internal */
export function isFloatingTabLocation(location) {
    return "floatingWidgetId" in location;
}
/** @internal */
export function isPopoutTabLocation(location) {
    return "popoutWidgetId" in location;
}
/** @internal */
export function isPanelTabLocation(location) {
    return "side" in location;
}
/** Returns a tab location or `undefined` if tab is not in a widget.
 * @internal
 */
export function getTabLocation(state, id) {
    let widgetId;
    for (const [, widget] of Object.entries(state.widgets)) {
        const index = widget.tabs.indexOf(id);
        if (index >= 0) {
            widgetId = widget.id;
            break;
        }
    }
    if (!widgetId)
        return undefined;
    const location = getWidgetLocation(state, widgetId);
    if (!location)
        return undefined;
    if (isFloatingWidgetLocation(location))
        return {
            floatingWidgetId: widgetId,
            widgetId,
        };
    if (isPopoutWidgetLocation(location))
        return {
            popoutWidgetId: widgetId,
            widgetId,
        };
    return {
        side: location.side,
        widgetId,
    };
}
//# sourceMappingURL=TabLocation.js.map