/*eslint no-unused-vars:0*/
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.HeadingAuthor = undefined;

var _index = require('../../constants/index');

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _Common = {
  "inner-block": "Common__inner-block___2cOrF",
  "disable-inner-block": "Common__disable-inner-block___1MLd0",
  "components": "Common__components___2fQuj",
  "component": "Common__component___3bwMg",
  "hide": "Common__hide___2HyoH",
  "desc-text-color": "Common__desc-text-color___2fV3l",
  "desc-text-block": "Common__desc-text-block___1Z4b-",
  "text-link": "Common__text-link___1jaLy",
  "image": "Common__image___AKB6W",
  "imagediff": "Common__imagediff___2j7tX",
  "slideshow": "Common__slideshow___1Fz23",
  "embeddedcode": "Common__embeddedcode___3Avmp",
  "youtube": "Common__youtube___2oq1n",
  "topic-box": "Common__topic-box___2Q-kN"
};

var _Common2 = _interopRequireDefault(_Common);

var _HeadingAuthor = {
  "author-container": "HeadingAuthor__author-container___2Y9W-",
  "author-item": "HeadingAuthor__author-item___1WwEs"
};

var _HeadingAuthor2 = _interopRequireDefault(_HeadingAuthor);

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

var HeadingAuthor = exports.HeadingAuthor = function HeadingAuthor(_ref) {
  var authors = _ref.authors;
  var children = _ref.children;
  var extendByline = _ref.extendByline;


  function _groupAuthor(authors) {
    return _lodash2.default.groupBy(authors, 'type');
  }

  function _renderAuthor(author, key) {
    // TBD After we have author page,
    // we can add link onto each author
    /*
    return (
      <a href="">
        <span className={commonStyles['text-link']}>
          {author.name}
        </span>
      </a>
      )
      */
    return _react2.default.createElement(
      'span',
      { key: key },
      author.name
    );
  }

  function _renderAuthors(authors) {
    return _lodash2.default.map(authors, function (author, index) {
      return _renderAuthor(author, index);
    });
  }

  var groupedAuthors = _groupAuthor(authors);
  var count = 0;
  var authorRows = [];
  _lodash2.default.forIn(groupedAuthors, function (authors, type) {
    var _authors = _renderAuthors(authors);
    authorRows.push(_react2.default.createElement(
      'div',
      { key: count++, className: (0, _classnames2.default)(_HeadingAuthor2.default['author-item']) },
      _react2.default.createElement(
        'span',
        null,
        _index.authorTypes[type]
      ),
      _authors
    ));
  });

  return _react2.default.createElement(
    'div',
    { className: _HeadingAuthor2.default['author-container'] },
    authorRows,
    _react2.default.createElement(
      'span',
      { style: { paddingRight: '8px' } },
      extendByline
    ),
    children
  );
};