'use strict';

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

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

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, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames3 = require('classnames');

var _classnames4 = _interopRequireDefault(_classnames3);

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

var _lib2 = _interopRequireDefault(_lib);

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

var _formatMessage2 = _interopRequireDefault(_formatMessage);

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.cHe8plLmePn50qYqfMq2K { /* stylelint-disable-line selector-class-pattern */\n  border: ' + theme.DnDZoneBorderWidth + ' dashed ' + theme.DnDZoneBorderColor + ';\n  background-color: ' + theme.DnDZoneBackgroundColor + ';\n  padding: ' + theme.DnDZonePadding + ';\n  display: flex;\n  justify-content: center;\n  width: 100%;\n}\n\n.X9JuKFIds_aDNGU16EpB9 {\n  border: ' + theme.sidebarDnDZoneBorderWidth + ' dashed ' + theme.sidebarDnDZoneBorderColor + ';\n  background-color: ' + theme.sidebarDnDZoneBackgroundColor + ';\n  padding: ' + theme.sidebarDnDZonePadding + ';\n  margin: ' + theme.sidebarDnDZoneMargin + ';\n  color: ' + theme.sidebarDnDZoneColor + ';\n  justify-content: center;\n  text-align: center;\n  width: 100%;\n}\n\n[dir="ltr"] .X9JuKFIds_aDNGU16EpB9 {\n  text-align: center;\n}\n\n[dir="rtl"] .X9JuKFIds_aDNGU16EpB9 {\n  text-align: center;\n}\n\n.X9JuKFIds_aDNGU16EpB9._1fKD653IO2J3kArVM6apA_ {\n  margin-left: 10%;\n  width: 90%;\n}\n\n._198GwLt820uFDWWoE4NjoF {\n  justify-content: center;\n  display: flex;\n  flex: 1 0 100%;\n  width: 100%;\n}\n\n._33T_74I5yat1SIl6Wvaf8v {\n  display: none;\n  width: 100%;\n}\n';
  },
  'DnDZone': 'cHe8plLmePn50qYqfMq2K',
  'sidebarDnDZone': 'X9JuKFIds_aDNGU16EpB9',
  'inSidebarStimulus': '_1fKD653IO2J3kArVM6apA_',
  'wrapper': '_198GwLt820uFDWWoE4NjoF',
  'hide': '_33T_74I5yat1SIl6Wvaf8v'
};
var DragAndDropZone = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(DragAndDropZone, _Component);

  function DragAndDropZone() {
    (0, _classCallCheck3.default)(this, DragAndDropZone);
    return (0, _possibleConstructorReturn3.default)(this, (DragAndDropZone.__proto__ || Object.getPrototypeOf(DragAndDropZone)).apply(this, arguments));
  }

  (0, _createClass3.default)(DragAndDropZone, [{
    key: 'shouldRender',
    value: function shouldRender() {
      var _props = this.props,
          inSidebar = _props.inSidebar,
          sidebarOpen = _props.sidebarOpen,
          inStimulus = _props.inStimulus,
          location = _props.location,
          draggingOver = _props.draggingOver,
          draggingAboveHalf = _props.draggingAboveHalf,
          dropIntoEmptyStimulus = _props.dropIntoEmptyStimulus;


      if (inSidebar && !sidebarOpen) {
        return false;
      }

      if (inStimulus) {
        if (location === 'above') {
          return draggingOver && draggingAboveHalf && !dropIntoEmptyStimulus;
        } else if (location === 'below') {
          return draggingOver && !draggingAboveHalf && !dropIntoEmptyStimulus;
        } else if (location === 'in') {
          return draggingOver && dropIntoEmptyStimulus;
        }
      } else if (location === 'above') {
        return draggingOver && draggingAboveHalf;
      } else if (location === 'below') {
        return draggingOver && !draggingAboveHalf;
      }
      return false;
    }
  }, {
    key: 'render',
    value: function render() {
      var _classnames;

      var _props2 = this.props,
          inSidebar = _props2.inSidebar,
          inStimulus = _props2.inStimulus;

      var style = (0, _classnames4.default)((_classnames = {}, (0, _defineProperty3.default)(_classnames, styles.DnDZone, !inSidebar), (0, _defineProperty3.default)(_classnames, styles.sidebarDnDZone, inSidebar), (0, _defineProperty3.default)(_classnames, styles.inSidebarStimulus, inSidebar && inStimulus), _classnames));

      var wrapper = (0, _classnames4.default)(styles.wrapper, (0, _defineProperty3.default)({}, styles.hide, !this.shouldRender()));

      return _react2.default.createElement(
        'div',
        { className: wrapper },
        _react2.default.createElement(
          'div',
          { className: style },
          (0, _formatMessage2.default)('Drop Question Here')
        )
      );
    }
  }]);
  DragAndDropZone.displayName = 'DragAndDropZone'
  ;
  return DragAndDropZone;
}(_react.Component), _class2.propTypes = {
  draggingAboveHalf: _propTypes2.default.bool.isRequired,
  draggingOver: _propTypes2.default.bool.isRequired,
  dropIntoEmptyStimulus: _propTypes2.default.bool,
  inSidebar: _propTypes2.default.bool,
  inStimulus: _propTypes2.default.bool,
  location: _propTypes2.default.oneOf(['above', 'below', 'in']).isRequired,
  sidebarOpen: _propTypes2.default.bool
}, _class2.defaultProps = {
  draggingAboveHalf: false,
  draggingOver: false,
  dropIntoEmptyStimulus: false,
  inSidebar: false,
  inStimulus: false,
  sidebarOpen: true
}, _temp)) || _class);
exports.default = DragAndDropZone;