"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAllowedWidgetTarget = void 0;
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
const React = require("react");
const WidgetLocation_1 = require("../state/WidgetLocation");
const useAllowedSideTarget_1 = require("./useAllowedSideTarget");
const LayoutStore_1 = require("../base/LayoutStore");
const DragManager_1 = require("../base/DragManager");
/** Checks the proposed docking target to see if it's allowed by the dragged widget or tab
 * @internal
 */
function useAllowedWidgetTarget(widgetId) {
    const draggedWidget = React.useContext(DragManager_1.DraggedWidgetIdContext);
    return (0, LayoutStore_1.useLayout)((state) => {
        const widgetLocation = (0, WidgetLocation_1.getWidgetLocation)(state, widgetId);
        if (!widgetLocation || (0, WidgetLocation_1.isPopoutWidgetLocation)(widgetLocation)) {
            return false;
        }
        else if ((0, WidgetLocation_1.isFloatingWidgetLocation)(widgetLocation)) {
            return true;
        }
        return (0, useAllowedSideTarget_1.isAllowedSideTarget)(state, draggedWidget, widgetLocation.side);
    });
}
exports.useAllowedWidgetTarget = useAllowedWidgetTarget;
//# sourceMappingURL=useAllowedWidgetTarget.js.map