import { _ as _define_property } from "@swc/helpers/_/_define_property";
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
import React from "react";
import { View } from "@tarojs/components";
import classNames from "classnames";
import { useRtl } from "../configprovider/index";
var prefixCls = 'nut-space';
var defaultProps = {
    direction: 'horizontal'
};
export var Space = function(props) {
    var _$_object_spread = _object_spread({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, children = _$_object_spread.children, wrap = _$_object_spread.wrap, align = _$_object_spread.align, direction = _$_object_spread.direction, justify = _$_object_spread.justify;
    var rtl = useRtl();
    var _obj;
    var cls = classNames(prefixCls, (_obj = {}, _define_property(_obj, "".concat(prefixCls, "-").concat(direction), direction), _define_property(_obj, "".concat(prefixCls, "-").concat(direction, "-wrap"), wrap), _define_property(_obj, "".concat(prefixCls, "-align-").concat(align), align), _define_property(_obj, "".concat(prefixCls, "-justify-").concat(justify), justify), _define_property(_obj, "".concat(className), className), _obj));
    var _obj1;
    var itemCls = classNames("".concat(prefixCls, "-item"), (_obj1 = {}, _define_property(_obj1, "".concat(prefixCls, "-").concat(direction, "-item"), direction), _define_property(_obj1, "".concat(prefixCls, "-").concat(direction, "-wrap-item"), wrap), _define_property(_obj1, "".concat(prefixCls, "-item-rtl"), rtl), _obj1));
    var childrenCount = React.Children.count(children);
    return /*#__PURE__*/ React.createElement(View, {
        className: cls,
        style: style
    }, React.Children.map(children, function(child, idx) {
        var isLast = idx === childrenCount - 1;
        return child !== null && child !== undefined && /*#__PURE__*/ React.createElement(View, {
            className: classNames(itemCls, isLast && "".concat(prefixCls, "-").concat(direction, "-item-last"))
        }, child);
    }));
};
Space.displayName = 'NutSpace';
