'use strict';

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

var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _AudioBox = require('./AudioBox');

var _AudioBox2 = _interopRequireDefault(_AudioBox);

var _More = require('../components/More');

var _More2 = _interopRequireDefault(_More);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

if (process.env.BROWSER) {}

var AudioList = function (_Component) {
  _inherits(AudioList, _Component);

  function AudioList(props, context) {
    _classCallCheck(this, AudioList);

    var _this = _possibleConstructorReturn(this, (AudioList.__proto__ || Object.getPrototypeOf(AudioList)).call(this, props, context));

    _this.renderTitle = _this.renderTitle.bind(_this);
    return _this;
  }

  _createClass(AudioList, [{
    key: 'renderTitle',
    value: function renderTitle() {
      var title = _lodash2.default.get(this.props, 'title');

      return title ? _react2.default.createElement(
        'div',
        { className: 'ui text container', style: { marginBottom: '35px', paddingLeft: '1em !important', marginLeft: '0 !important' } },
        _react2.default.createElement(
          'div',
          { className: 'article-main', style: { textAlign: 'center' } },
          _react2.default.createElement(
            'h2',
            { className: 'hot-topic' },
            _react2.default.createElement('div', { className: 'colorBlock choice' }),
            title,
            _react2.default.createElement('div', { className: 'blue-line', style: { marginLeft: '16px', display: 'inline-block' } })
          )
        )
      ) : null;
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props;
      var audios = _props.audios;
      var hasMore = _props.hasMore;
      var loadMore = _props.loadMore;


      return _react2.default.createElement(
        'div',
        { className: 'container audioList' },
        this.renderTitle(),
        _react2.default.createElement(
          'div',
          { className: 'latest' },
          _lodash2.default.map(audios, function (a) {

            var id = _lodash2.default.get(a, ['audio', 'id']);
            var title = _lodash2.default.get(a, ['title'], '');
            var url = _lodash2.default.get(a, ['audio', 'url']);
            var cover = _lodash2.default.get(a, ['coverPhoto', 'image', 'resizedTargets', 'tiny', 'url']);

            return _react2.default.createElement(_AudioBox2.default, { id: id, title: title, url: url, cover: cover, key: a.id || a._id });
          })
        ),
        hasMore ? _react2.default.createElement(_More2.default, { loadMore: loadMore }) : null
      );
    }
  }]);

  return AudioList;
}(_react.Component);

exports.default = AudioList;
exports.AudioList = AudioList;