text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports["default"] = void 0;
  
  var _react = _interopRequireWildcard(require("react"));
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _classnames = _interopRequireDefault(require("classnames"));
  
  var _PureRender = _interopRequireDefault(require("../util/PureRender"));
  
  var _Surface = _interopRequireDefault(require("../container/Surface"));
  
  var _Symbols = _interopRequireDefault(require("../shape/Symbols"));
  
  var _ReactUtils = require("../util/ReactUtils");
  
  var _class, _class2, _temp;
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
  
  function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  
  var SIZE = 32;
  
  var ICON_TYPES = _ReactUtils.LEGEND_TYPES.filter(function (type) {
    return type !== 'none';
  });
  
  var DefaultLegendContent = (0, _PureRender["default"])(_class = (_temp = _class2 =
  /*#__PURE__*/
  function (_Component) {
    _inherits(DefaultLegendContent, _Component);
  
    function DefaultLegendContent() {
      _classCallCheck(this, DefaultLegendContent);
  
      return _possibleConstructorReturn(this, _getPrototypeOf(DefaultLegendContent).apply(this, arguments));
    }
  
    _createClass(DefaultLegendContent, [{
      key: "renderIcon",
  
      /**
       * Render the path of icon
       * @param {Object} data Data of each legend item
       * @return {String} Path element
       */
      value: function renderIcon(data) {
        var inactiveColor = this.props.inactiveColor;
        var halfSize = SIZE / 2;
        var sixthSize = SIZE / 6;
        var thirdSize = SIZE / 3;
        var color = data.inactive ? inactiveColor : data.color;
  
        if (data.type === 'plainline') {
          return _react["default"].createElement("line", {
            strokeWidth: 4,
            fill: "none",
            stroke: color,
            strokeDasharray: data.payload.strokeDasharray,
            x1: 0,
            y1: halfSize,
            x2: SIZE,
            y2: halfSize,
            className: "recharts-legend-icon"
          });
        }
  
        if (data.type === 'line') {
          return _react["default"].createElement("path", {
            strokeWidth: 4,
            fill: "none",
            stroke: color,
            d: "M0,".concat(halfSize, "h").concat(thirdSize, "\n            A").concat(sixthSize, ",").concat(sixthSize, ",0,1,1,").concat(2 * thirdSize, ",").concat(halfSize, "\n            H").concat(SIZE, "M").concat(2 * thirdSize, ",").concat(halfSize, "\n            A").concat(sixthSize, ",").concat(sixthSize, ",0,1,1,").concat(thirdSize, ",").concat(halfSize),
            className: "recharts-legend-icon"
          });
        }
  
        if (data.type === 'rect') {
          return _react["default"].createElement("path", {
            stroke: "none",
            fill: color,
            d: "M0,".concat(SIZE / 8, "h").concat(SIZE, "v").concat(SIZE * 3 / 4, "h").concat(-SIZE, "z"),
            className: "recharts-legend-icon"
          });
        }
  
        return _react["default"].createElement(_Symbols["default"], {
          fill: color,
          cx: halfSize,
          cy: halfSize,
          size: SIZE,
          sizeType: "diameter",
          type: data.type
        });
      }
      /**
       * Draw items of legend
       * @return {ReactElement} Items
       */
  
    }, {
      key: "renderItems",
      value: function renderItems() {
        var _this = this;
  
        var _this$props = this.props,
            payload = _this$props.payload,
            iconSize = _this$props.iconSize,
            layout = _this$props.layout,
            formatter = _this$props.formatter;
        var viewBox = {
          x: 0,
          y: 0,
          width: SIZE,
          height: SIZE
        };
        var itemStyle = {
          display: layout === 'horizontal' ? 'inline-block' : 'block',
          marginRight: 10
        };
        var svgStyle = {
          display: 'inline-block',
          verticalAlign: 'middle',
          marginRight: 4
        };
        return payload.map(function (entry, i) {
          var _classNames;
  
          var finalFormatter = entry.formatter || formatter;
          var className = (0, _classnames["default"])((_classNames = {
            'recharts-legend-item': true
          }, _defineProperty(_classNames, "legend-item-".concat(i), true), _defineProperty(_classNames, "inactive", entry.inactive), _classNames));
  
          if (entry.type === 'none') {
            return null;
          }
  
          return _react["default"].createElement("li", _extends({
            className: className,
            style: itemStyle,
            key: "legend-item-".concat(i)
          }, (0, _ReactUtils.filterEventsOfChild)(_this.props, entry, i)), _react["default"].createElement(_Surface["default"], {
            width: iconSize,
            height: iconSize,
            viewBox: viewBox,
            style: svgStyle
          }, _this.renderIcon(entry)), _react["default"].createElement("span", {
            className: "recharts-legend-item-text"
          }, finalFormatter ? finalFormatter(entry.value, entry, i) : entry.value));
        });
      }
    }, {
      key: "render",
      value: function render() {
        var _this$props2 = this.props,
            payload = _this$props2.payload,
            layout = _this$props2.layout,
            align = _this$props2.align;
  
        if (!payload || !payload.length) {
          return null;
        }
  
        var finalStyle = {
          padding: 0,
          margin: 0,
          textAlign: layout === 'horizontal' ? align : 'left'
        };
        return _react["default"].createElement("ul", {
          className: "recharts-default-legend",
          style: finalStyle
        }, this.renderItems());
      }
    }]);
  
    return DefaultLegendContent;
  }(_react.Component), _class2.displayName = 'Legend', _class2.propTypes = {
    content: _propTypes["default"].element,
    iconSize: _propTypes["default"].number,
    iconType: _propTypes["default"].oneOf(ICON_TYPES),
    layout: _propTypes["default"].oneOf(['horizontal', 'vertical']),
    align: _propTypes["default"].oneOf(['center', 'left', 'right']),
    verticalAlign: _propTypes["default"].oneOf(['top', 'bottom', 'middle']),
    payload: _propTypes["default"].arrayOf(_propTypes["default"].shape({
      value: _propTypes["default"].any,
      id: _propTypes["default"].any,
      type: _propTypes["default"].oneOf(_ReactUtils.LEGEND_TYPES)
    })),
    inactiveColor: _propTypes["default"].string,
    formatter: _propTypes["default"].func,
    onMouseEnter: _propTypes["default"].func,
    onMouseLeave: _propTypes["default"].func,
    onClick: _propTypes["default"].func
  }, _class2.defaultProps = {
    iconSize: 14,
    layout: 'horizontal',
    align: 'center',
    verticalAlign: 'middle',
    inactiveColor: '#ccc'
  }, _temp)) || _class;
  
  var _default = DefaultLegendContent;
  exports["default"] = _default;