import getViewportSize from '../../utils/dom/getViewportSize';
import { BottomLeft } from './bottom-left';
import { BottomRight } from './bottom-right';
import { TopLeft } from './top-left';
import { TopRight } from './top-right';
var positionMap = {
    BottomLeft: BottomLeft,
    BottomRight: BottomRight,
    TopLeft: TopLeft,
    TopRight: TopRight,
};
export var AutoBottomRight = function (props) {
    var contentRect = props.contentRect, cushion = props.cushion, anchorRect = props.anchorRect;
    var viewport = getViewportSize();
    var horizontal;
    var vertical;
    if (anchorRect.right - contentRect.width < 0 &&
        anchorRect.left + contentRect.width < viewport.width) {
        horizontal = 'Left';
    }
    else {
        horizontal = 'Right';
    }
    if (anchorRect.bottom + cushion + contentRect.height > viewport.height &&
        anchorRect.top - cushion - contentRect.height > 0) {
        vertical = 'Top';
    }
    else {
        vertical = 'Bottom';
    }
    var key = "" + vertical + horizontal;
    return positionMap[key](props);
};
