export var DEFAULT_SIZE_AND_POSITION_ELEMENT = {
    width: 0,
    height: 0,
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    x: 0,
    y: 0
};
export var calculateSizeAnPositionElement = function (el) {
    if (el) {
        var _a = el.getBoundingClientRect(), width = _a.width, height = _a.height, top_1 = _a.top, left = _a.left, bottom = _a.bottom, right = _a.right, x = _a.x, y = _a.y;
        return {
            width: width,
            height: height,
            top: top_1 + window.scrollY,
            left: left,
            bottom: bottom + window.scrollY,
            right: right,
            x: x,
            y: y
        };
    }
    return DEFAULT_SIZE_AND_POSITION_ELEMENT;
};
// проверяет влазит ли тултип в по текущему местоположению иначе меняет его на противоположное
export var getComputedDirection = function (_a) {
    var componentSizeAndPosition = _a.componentSizeAndPosition, textContentSize = _a.textContentSize, offset = _a.offset, direction = _a.direction;
    var viewerSize = {
        width: document.documentElement.clientWidth,
        height: document.documentElement.clientHeight
    };
    var isRight = componentSizeAndPosition.right +
        componentSizeAndPosition.width +
        textContentSize.width +
        offset <=
        viewerSize.width;
    var isLeft = componentSizeAndPosition.x - textContentSize.width - offset >= 0;
    var isTop = componentSizeAndPosition.y - textContentSize.height - offset >= 0;
    var isBottom = componentSizeAndPosition.y +
        componentSizeAndPosition.height +
        textContentSize.height +
        offset <=
        viewerSize.height;
    switch (direction) {
        case "left":
            if (isLeft) {
                return "left";
            }
            return "right";
        case "right":
            if (isRight) {
                return "right";
            }
            return "left";
        case "top":
            if (isTop) {
                return "top";
            }
            return "bottom";
        case "topRight":
            if (isTop) {
                return "topRight";
            }
            return "bottomRight";
        case "topLeft":
            if (isTop) {
                return "topLeft";
            }
            return "bottomLeft";
        case "bottom":
            if (isBottom) {
                return "bottom";
            }
            return "top";
        case "bottomLeft":
            if (isBottom) {
                return "bottomLeft";
            }
            return "topLeft";
        case "bottomRight":
            if (isBottom) {
                return "bottomRight";
            }
            return "topRight";
        default:
            return direction;
    }
};
