"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _immutable = require("immutable");

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactDropzone = _interopRequireDefault(require("react-dropzone"));

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

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'flcWS',
  template: function template(theme) {
    return "\n\n.quiz-core__file_selector--dropzone {\n  background-color: ".concat(theme.dropzoneBackgroundColor || 'inherit', ";\n  border: ").concat(theme.dropzoneBorderWidth || 'inherit', " dashed ").concat(theme.dropzoneBorderColor || 'inherit', ";\n  cursor: pointer;\n  padding: ").concat(theme.dropzonePadding || 'inherit', ";\n}\n");
  },
  'dropzone': 'quiz-core__file_selector--dropzone'
};
var FileSelector = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(FileSelector, _Component);

  function FileSelector() {
    var _this;

    (0, _classCallCheck2.default)(this, FileSelector);
    _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(FileSelector).call(this));
    _this.onDrop = _this.onDrop.bind((0, _assertThisInitialized2.default)(_this));
    return _this;
  }

  (0, _createClass2.default)(FileSelector, [{
    key: "onDrop",
    value: function onDrop(files) {
      this.props.fileHandler((0, _immutable.List)(files));
    }
  }, {
    key: "renderContent",
    value: function renderContent() {
      return this.props.content;
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", null, _react.default.createElement(_reactDropzone.default, {
        className: styles.dropzone,
        multiple: this.props.multiple,
        onDrop: this.onDrop,
        accept: this.props.acceptAttribute
      }, this.renderContent()));
    }
  }]);
  FileSelector.displayName = "FileSelector";
  return FileSelector;
}(_react.Component), _class2.propTypes = {
  acceptAttribute: _propTypes.default.string.isRequired,
  content: _propTypes.default.node.isRequired,
  fileHandler: _propTypes.default.func.isRequired,
  multiple: _propTypes.default.bool
}, _class2.defaultProps = {
  multiple: false
}, _temp)) || _class);
exports.default = FileSelector;