import { __assign, __rest } from "tslib";
import React, { useContext } from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var Timeline = function (props) {
    var _a;
    var _b = props.position, position = _b === void 0 ? 'left' : _b, customisedCls = props.prefixCls, className = props.className, children = props.children, otherProps = __rest(props, ["position", "prefixCls", "className", "children"]);
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('timeline', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, className, (_a = {},
        _a[prefixCls + "_" + position] = position,
        _a));
    return (React.createElement("ul", __assign({}, otherProps, { className: cls }), React.Children.map(children, function (child, idx) {
        var childElement = child;
        if (childElement.type.displayName === 'TimelineItem') {
            var childProps = {
                className: position === 'center'
                    ? idx % 2 === 0
                        ? prefixCls + "-item_left"
                        : prefixCls + "-item_right"
                    : childElement.props.className,
            };
            return React.cloneElement(childElement, childProps);
        }
        else {
            return null;
        }
    })));
};
Timeline.displayName = 'Timeline';
export default Timeline;
//# sourceMappingURL=timeline.js.map