"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _StatisticsItem = _interopRequireDefault(require("./StatisticsItem"));
var _StatisticsWidgetSt = require("./StatisticsWidget.st.css.js");
var _constants = require("./constants");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/StatisticsWidget/StatisticsWidget.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var StatisticsWidget = /*#__PURE__*/function (_React$PureComponent) {
  function StatisticsWidget() {
    var _this;
    (0, _classCallCheck2["default"])(this, StatisticsWidget);
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _callSuper(this, StatisticsWidget, [].concat(args));
    _this._renderStat = function (stat, key) {
      var _this$props = _this.props,
        size = _this$props.size,
        alignItems = _this$props.alignItems,
        isLoading = _this$props.isLoading;
      return /*#__PURE__*/_react["default"].createElement(_StatisticsItem["default"], (0, _extends2["default"])({}, stat, {
        isLoading: isLoading,
        key: key,
        size: size,
        alignItems: alignItems,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 15,
          columnNumber: 7
        }
      }));
    };
    return _this;
  }
  (0, _inherits2["default"])(StatisticsWidget, _React$PureComponent);
  return (0, _createClass2["default"])(StatisticsWidget, [{
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
        dataHook = _this$props2.dataHook,
        size = _this$props2.size;
      var items = this.props.items;
      items = items || [];
      if (items.length > 5) {
        console.warn("".concat(items.length, " items were passed in items array. StatisticsWidget will display only the first 5."));
      }
      var firstFive = items.slice(0, 5);
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _StatisticsWidgetSt.st)(_StatisticsWidgetSt.classes.root, {
          size: size
        }),
        "data-hook": dataHook,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 39,
          columnNumber: 7
        }
      }, firstFive.map(this._renderStat));
    }
  }]);
}(_react["default"].PureComponent);
StatisticsWidget.displayName = 'StatisticsWidget';
StatisticsWidget.defaultProps = {
  size: _constants.SIZES.tiny
};
var _default = exports["default"] = StatisticsWidget;