'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VideoList = 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 _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _truncate = require('truncate');

var _truncate2 = _interopRequireDefault(_truncate);

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

var _More2 = _interopRequireDefault(_More);

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 VideoList = function (_Component) {
  _inherits(VideoList, _Component);

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

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

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

  _createClass(VideoList, [{
    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 playlist = _props.playlist;
      var hasMore = _props.hasMore;
      var loadMore = _props.loadMore;


      return _react2.default.createElement(
        'div',
        { className: 'container' },
        this.renderTitle(),
        _react2.default.createElement(
          'div',
          { className: 'latest' },
          _lodash2.default.map(playlist, function (a) {
            //let image = imageComposer(a).mobileImage
            var image = _lodash2.default.get(a, ['snippet', 'thumbnails', 'medium', 'url'], '/asset/review.png');
            var title = _lodash2.default.get(a, ['snippet', 'title'], '');
            var brief = _lodash2.default.get(a, ['snippet', 'description'], '');
            var link = 'https://youtu.be/' + _lodash2.default.get(a, ['snippet', 'resourceId', 'videoId'], '');

            return _react2.default.createElement(
              'div',
              { className: 'latest-block', key: a.id || a._id },
              _react2.default.createElement(
                'a',
                { href: link },
                _react2.default.createElement('div', { className: 'latest-img', style: { background: 'url(' + image + ') no-repeat center center', backgroundSize: 'cover' } })
              ),
              _react2.default.createElement(
                'div',
                { className: 'latest-content' },
                _react2.default.createElement(
                  'a',
                  { href: link },
                  _react2.default.createElement(
                    'h2',
                    null,
                    _react2.default.createElement('span', { dangerouslySetInnerHTML: { __html: title } }),
                    _react2.default.createElement(
                      'div',
                      { className: 'cat-label' },
                      _react2.default.createElement('div', { className: 'separator' }),
                      _react2.default.createElement(
                        'span',
                        null,
                        'VideoHub'
                      )
                    )
                  )
                ),
                _react2.default.createElement('div', { className: 'line' }),
                _react2.default.createElement(
                  'div',
                  { className: 'brief' },
                  (0, _truncate2.default)(brief, 75)
                )
              )
            );
          })
        ),
        hasMore ? _react2.default.createElement(_More2.default, { loadMore: loadMore }) : null
      );
    }
  }]);

  return VideoList;
}(_react.Component);

exports.default = VideoList;
exports.VideoList = VideoList;