import getViewportSize from '../../utils/dom/getViewportSize';
import { BottomLeft } from './bottom-left';
import { BottomLeftInViewport } from './bottom-left-in-viewport';
import { TopLeft } from './top-left';
import { TopLeftInViewport } from './top-left-in-viewport';
var positionMap = {
    BottomLeft: BottomLeft,
    BottomLeftInViewport: BottomLeftInViewport,
    TopLeft: TopLeft,
    TopLeftInViewport: TopLeftInViewport,
};
export var AutoBottomLeftInViewport = function (props) {
    var contentRect = props.contentRect, cushion = props.cushion, anchorRect = props.anchorRect;
    var viewport = getViewportSize();
    var horizontal;
    var vertical;
    if (viewport.width - anchorRect.left > contentRect.width) {
        horizontal = 'Left';
    }
    else {
        horizontal = 'LeftInViewport';
    }
    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);
};
