/**
 * DevExtreme (esm/__internal/ui/overlay/m_utils.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import $ from "../../../core/renderer";
import {
    getInnerHeight,
    getOuterHeight
} from "../../../core/utils/size";
import {
    isNumeric
} from "../../../core/utils/type";
import {
    getWindow
} from "../../../core/utils/window";
var WINDOW_HEIGHT_PERCENT = .9;
export var getElementMaxHeightByWindow = ($element, startLocation) => {
    var $window = $(getWindow());
    var {
        top: elementOffset
    } = $element.offset();
    var actualOffset;
    if (isNumeric(startLocation)) {
        if (startLocation < elementOffset) {
            return elementOffset - startLocation
        }
        actualOffset = getInnerHeight($window) - startLocation + $window.scrollTop()
    } else {
        var offsetTop = elementOffset - $window.scrollTop();
        var offsetBottom = getInnerHeight($window) - offsetTop - getOuterHeight($element);
        actualOffset = Math.max(offsetTop, offsetBottom)
    }
    return actualOffset * WINDOW_HEIGHT_PERCENT
};
