import * as React from 'react';
import { LastIndexContext } from '.';
var spaceSize = {
    small: 8,
    middle: 16,
    large: 24,
};
export default function Item(_a) {
    var _b;
    var _c;
    var className = _a.className, direction = _a.direction, index = _a.index, size = _a.size, marginDirection = _a.marginDirection, children = _a.children, split = _a.split;
    var latestIndex = React.useContext(LastIndexContext);
    if (children === null || children === undefined) {
        return null;
    }
    var style = index >= latestIndex
        ? {}
        : (_b = {},
            _b[direction === 'vertical' ? 'marginBottom' : marginDirection] = ((_c = (typeof size === 'string' ? spaceSize[size] : size)) !== null && _c !== void 0 ? _c : 0) / (split ? 2 : 1),
            _b);
    return (React.createElement(React.Fragment, null,
        React.createElement("div", { className: className, style: style }, children),
        index < latestIndex && split && (React.createElement("span", { className: className + "-split", style: style }, split))));
}
