'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Paragraph = require('../../atoms/text/Paragraph');

var _Paragraph2 = _interopRequireDefault(_Paragraph);

var _DecorativeLink = require('../../atoms/links/DecorativeLink');

var _DecorativeLink2 = _interopRequireDefault(_DecorativeLink);

require('./styles.css');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var UtilityPanel = function UtilityPanel(utilityPanel) {
  var descriptionClasses = ['ma__utility-panel__description'];
  var links = utilityPanel.links;
  if (!Array.isArray(links) || links.length === 0) {
    descriptionClasses.push('ma__utility-panel__description--full');
  }
  return _react2.default.createElement(
    'div',
    { className: 'ma__utility-panel' },
    _react2.default.createElement(
      'div',
      { className: descriptionClasses.join(' ') },
      _react2.default.createElement(_Paragraph2.default, utilityPanel.description)
    ),
    _react2.default.createElement(
      'ul',
      { className: 'ma__utility-panel__items' },
      links.map(function (decorativeLink, index) {
        return (
          // eslint-disable-next-line react/no-array-index-key
          _react2.default.createElement(
            'li',
            { className: 'ma__utility-panel__item js-clickable', key: index },
            _react2.default.createElement(_DecorativeLink2.default, decorativeLink)
          )
        );
      })
    )
  );
};

UtilityPanel.propTypes = process.env.NODE_ENV !== "production" ? {
  /** Text describing the contents of the panel */
  description: _propTypes2.default.shape(_Paragraph2.default.propTypes).isRequired,
  /** Links to display in the panel */
  links: _propTypes2.default.arrayOf(_propTypes2.default.shape(_DecorativeLink2.default.propTypes))
} : {};

UtilityPanel.defaultProps = {
  links: []
};

exports.default = UtilityPanel;
module.exports = exports['default'];