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 Row = function (props) {
    var _a;
    var _b = props.gutter, gutter = _b === void 0 ? 0 : _b, _c = props.gutterSide, gutterSide = _c === void 0 ? false : _c, customisedCls = props.prefixCls, align = props.align, justify = props.justify, className = props.className, style = props.style, children = props.children, otherProps = __rest(props, ["gutter", "gutterSide", "prefixCls", "align", "justify", "className", "style", "children"]);
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('row', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, className, (_a = {},
        _a[prefixCls + "_align-" + align] = align,
        _a[prefixCls + "_justify-" + justify] = justify,
        _a));
    var getGutter = function () {
        return Array.isArray(gutter) ? gutter : [gutter, gutter];
    };
    var normalisedGutter = getGutter();
    return (React.createElement("div", __assign({}, otherProps, { className: cls, style: style }), React.Children.map(children, function (child, idx) {
        var childElement = child;
        if (childElement.type.displayName === 'Col') {
            var gutterStyle = gutter
                ? {
                    paddingLeft: !gutterSide && idx === 0 ? 0 : normalisedGutter[0] / 2,
                    paddingRight: !gutterSide && idx === React.Children.count(children) - 1
                        ? 0
                        : normalisedGutter[0] / 2,
                }
                : {};
            var childProps = {
                style: __assign(__assign({}, child.props.style), gutterStyle),
            };
            return React.cloneElement(childElement, childProps);
        }
        return childElement;
    })));
};
Row.displayName = 'Row';
export default Row;
//# sourceMappingURL=row.js.map