'use strict';

var React = require('react');
var uuid = require('../uuid-1eceb0c8.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const componentClassName = 'sendbird-sort-by-row';
function SortByRow(_ref) {
  let {
    className = '',
    maxItemCount,
    itemWidth,
    itemHeight,
    children
  } = _ref;
  if (Array.isArray(children) && children.length > maxItemCount) {
    const result = [];
    for (let i = 0; i < children.length; i += maxItemCount) {
      result.push( /*#__PURE__*/React__default["default"].createElement("div", {
        className: [...(Array.isArray(className) ? className : [className]), componentClassName].join(' '),
        key: uuid.uuidv4(),
        style: {
          width: itemWidth * maxItemCount,
          height: itemHeight
        }
      }, children.slice(i, i + maxItemCount)));
    }
    return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, result);
  }
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: [...(Array.isArray(className) ? className : [className]), componentClassName].join(' '),
    style: {
      width: itemWidth * (Array.isArray(children) ? children.length : 1),
      height: itemHeight
    }
  }, children);
}

module.exports = SortByRow;
//# sourceMappingURL=SortByRow.js.map
