"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "CellGroup", {
    enumerable: true,
    get: function() {
        return CellGroup;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _components = require("@tarojs/components");
var _typings = require("../../utils/typings");
var _context = /*#__PURE__*/ _interop_require_default._(require("./context"));
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    title: '',
    description: '',
    divider: true
});
var classPrefix = 'nut-cell-group';
var CellGroup = function CellGroup(props) {
    var _ref = (0, _object_spread._)({}, defaultProps, props), children = _ref.children, className = _ref.className, title = _ref.title, description = _ref.description, divider = _ref.divider, rest = (0, _object_without_properties._)(_ref, [
        "children",
        "className",
        "title",
        "description",
        "divider"
    ]);
    return /*#__PURE__*/ _react.default.createElement(_components.View, (0, _object_spread._)({
        className: (0, _classnames.default)(classPrefix, className)
    }, rest), title ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-title")
    }, title) : null, description ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-description")
    }, description) : null, /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-wrap")
    }, /*#__PURE__*/ _react.default.createElement(_context.default.Provider, {
        value: {
            divider: divider,
            group: true
        }
    }, _react.default.Children.map(children, function(child, index) {
        var _child_type;
        // @ts-ignore
        return (child === null || child === void 0 ? void 0 : (_child_type = child.type) === null || _child_type === void 0 ? void 0 : _child_type.displayName) === 'NutCell' ? /*#__PURE__*/ _react.default.cloneElement(child, {
            isLast: index === _react.default.Children.count(children) - 1
        }) : child;
    }))));
};
CellGroup.displayName = 'NutCellGroup';
