'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactImmutableProptypes = require('react-immutable-proptypes');

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

var _react3 = require('format-message/react');

var _Button = require('@instructure/ui-buttons/lib/components/Button');

var _Button2 = _interopRequireDefault(_Button);

var _Grid = require('@instructure/ui-layout/lib/components/Grid');

var _Grid2 = _interopRequireDefault(_Grid);

var _lib = require('@instructure/ui-themeable/lib');

var _lib2 = _interopRequireDefault(_lib);

var _IconUploadLine = require('instructure-icons/lib/Line/IconUploadLine');

var _IconUploadLine2 = _interopRequireDefault(_IconUploadLine);

var _IconCompleteLine = require('instructure-icons/lib/Line/IconCompleteLine');

var _IconCompleteLine2 = _interopRequireDefault(_IconCompleteLine);

var _formatMessage = require('../../../../common/format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _FileSelector = require('../../../../common/components/shared/file_selector/FileSelector');

var _FileSelector2 = _interopRequireDefault(_FileSelector);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

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

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.ImportFileSelector__styles__uploadIconContainer {\n  color: ' + theme.uploadIconContainerColor + ';\n  font-size: ' + theme.uploadIconContainerColorFontSize + ';\n  text-align: right;\n}\n\n[dir="ltr"] .ImportFileSelector__styles__uploadIconContainer {\n  text-align: right;\n}\n\n[dir="rtl"] .ImportFileSelector__styles__uploadIconContainer {\n  text-align: right;\n}\n\n.ImportFileSelector__styles__checkIconContainer {\n  color: ' + theme.checkIconContainerColor + ';\n  font-size: ' + theme.checkIconContainerFontSize + ';\n  text-align: right;\n}\n\n[dir="ltr"] .ImportFileSelector__styles__checkIconContainer {\n  text-align: right;\n}\n\n[dir="rtl"] .ImportFileSelector__styles__checkIconContainer {\n  text-align: right;\n}\n\n.ImportFileSelector__styles__smallText {\n  padding: 0 ' + theme.smallTextPadding + ';\n  font-size: ' + theme.smallTextFontSize + ';\n  color: ' + theme.smallTextColor + ';\n}\n\n.ImportFileSelector__styles__selector {\n  margin-top: ' + theme.selectorMargin + ';\n}\n\n.ImportFileSelector__styles__fileListSuccess {\n  color: ' + theme.fileListSuccessColor + ';\n}\n';
  },
  'uploadIconContainer': 'ImportFileSelector__styles__uploadIconContainer',
  'checkIconContainer': 'ImportFileSelector__styles__checkIconContainer',
  'smallText': 'ImportFileSelector__styles__smallText',
  'selector': 'ImportFileSelector__styles__selector',
  'fileListSuccess': 'ImportFileSelector__styles__fileListSuccess'
};
var ImportFileSelector = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp2 = _class2 = function (_Component) {
  (0, _inherits3.default)(ImportFileSelector, _Component);

  function ImportFileSelector() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, ImportFileSelector);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = ImportFileSelector.__proto__ || Object.getPrototypeOf(ImportFileSelector)).call.apply(_ref, [this].concat(args))), _this), _this.renderFileList = function () {
      var fileName = _this.props.files.get(0).name;
      return _react2.default.createElement(
        'div',
        null,
        (0, _react3.formatChildren)('<0>' + fileName + '</0> <1>pare.</1>', [_react2.default.createElement('span', { className: styles.fileListSuccess, key: '0' }), _react2.default.createElement('span', { key: '1' })])
      );
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(ImportFileSelector, [{
    key: 'renderUploadIcon',
    value: function renderUploadIcon() {
      return _react2.default.createElement(
        'div',
        { className: styles.uploadIconContainer },
        _react2.default.createElement(_IconUploadLine2.default, null)
      );
    }
  }, {
    key: 'renderCheckmarkIcon',
    value: function renderCheckmarkIcon() {
      return _react2.default.createElement(
        'div',
        { className: styles.checkIconContainer },
        _react2.default.createElement(_IconCompleteLine2.default, null)
      );
    }
  }, {
    key: 'renderFilePickerText',
    value: function renderFilePickerText() {
      return _react2.default.createElement(
        'div',
        null,
        (0, _react3.formatChildren)('Pran laje la <0>oswa</0> <1>Navige</1>', [_react2.default.createElement('span', { className: styles.smallText, key: '0' }), _react2.default.createElement(_Button2.default, { key: '1' })])
      );
    }
  }, {
    key: 'renderWrapper',
    value: function renderWrapper(renderIcon, renderText) {
      return _react2.default.createElement(
        _Grid2.default,
        null,
        _react2.default.createElement(
          _Grid.GridRow,
          { vAlign: 'middle' },
          _react2.default.createElement(
            _Grid.GridCol,
            { width: 3 },
            renderIcon()
          ),
          _react2.default.createElement(
            _Grid.GridCol,
            null,
            renderText()
          )
        )
      );
    }
  }, {
    key: 'renderContent',
    value: function renderContent() {
      if (this.props.files && this.props.files.size) {
        return this.renderWrapper(this.renderCheckmarkIcon, this.renderFileList);
      } else {
        return this.renderWrapper(this.renderUploadIcon, this.renderFilePickerText);
      }
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        'div',
        { className: styles.selector },
        _react2.default.createElement(_FileSelector2.default, {
          content: this.renderContent(),
          fileHandler: this.props.receiveFile,
          acceptAttribute: this.props.acceptAttribute
        })
      );
    }
  }]);
  ImportFileSelector.displayName = 'ImportFileSelector'
  ;
  return ImportFileSelector;
}(_react.Component), _class2.propTypes = {
  files: _reactImmutableProptypes2.default.list.isRequired,
  receiveFile: _propTypes2.default.func.isRequired,
  acceptAttribute: _propTypes2.default.string.isRequired
}, _temp2)) || _class);
exports.default = ImportFileSelector;