"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
require("./index.less");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var prefix = 'ol-map-analysis-statistics';
var Statistics = function Statistics(_ref) {
  var item = _ref.item,
    activeKey = _ref.activeKey,
    _onClick = _ref.onClick;
  var name = item.name,
    count = item.count,
    unit = item.unit,
    color = item.color,
    icon = item.icon,
    noClick = item.noClick;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(prefix, "-item"), {
      active: activeKey === item.key,
      noClick: noClick
    }),
    onClick: function onClick() {
      return !noClick && _onClick(item);
    }
  }, /*#__PURE__*/_react["default"].isValidElement(icon) ? icon : /*#__PURE__*/_react["default"].createElement("img", {
    src: icon
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-item-text")
  }, /*#__PURE__*/_react["default"].createElement("div", null, name), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-item-number"),
    style: {
      color: color
    }
  }, /*#__PURE__*/_react["default"].createElement("div", null, count), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-item-unit")
  }, unit))));
};
var StatisticsList = function StatisticsList(_ref2) {
  var _ref2$list = _ref2.list,
    list = _ref2$list === void 0 ? [] : _ref2$list,
    activeKey = _ref2.activeKey,
    onClick = _ref2.onClick;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-list")
  }, list.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(Statistics, {
      item: item,
      key: item.text,
      activeKey: activeKey,
      onClick: onClick
    });
  }));
};
Statistics.propTypes = {
  item: _propTypes["default"].object,
  activeKey: _propTypes["default"].string,
  onClick: _propTypes["default"].func
};
StatisticsList.propTypes = {
  title: _propTypes["default"].string,
  list: _propTypes["default"].array,
  activeKey: _propTypes["default"].string,
  onClick: _propTypes["default"].func
};
var _default = exports["default"] = StatisticsList;
//# sourceMappingURL=index.js.map
