'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 _class, _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 _componentForItem = require('../../../../util/componentForItem');

var _componentForItem2 = _interopRequireDefault(_componentForItem);

var _constants = require('../../../../../constants');

var _interactionTypePropsHelper = require('../../../../util/interactionTypePropsHelper');

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

var ItemOverride = (_temp2 = _class = function (_Component) {
  (0, _inherits3.default)(ItemOverride, _Component);

  function ItemOverride() {
    var _ref;

    var _temp, _this, _ret;

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

    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 = ItemOverride.__proto__ || Object.getPrototypeOf(ItemOverride)).call.apply(_ref, [this].concat(args))), _this), _this.changeOverrideState = function (newState, changes) {
      if (changes) {
        _this.props.changeQuizEntryProperties(_this.props.quizEntry.id, { itemOverrides: changes });
      }
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(ItemOverride, [{
    key: 'render',
    value: function render() {
      var item = this.props.entry;
      var interactionType = item.getInteractionType().slug;
      var Interaction = (0, _componentForItem2.default)(interactionType, _constants.COMPONENT_EDIT);
      var propsForInteraction = (0, _interactionTypePropsHelper.propsForInteractionEdit)(Object.assign({}, this.props, {
        changeItemState: function changeItemState() {},
        openImportModal: function openImportModal() {},
        workingItem: item
      }));

      return _react2.default.createElement(Interaction, Object.assign({}, propsForInteraction, {
        changeItemState: this.changeOverrideState,
        itemId: this.props.guid,
        overrideEditableForItem: true
      }));
    }
  }]);
  ItemOverride.displayName = 'ItemOverride'
  ;
  return ItemOverride;
}(_react.Component), _class.propTypes = {
  changeQuizEntryProperties: _propTypes2.default.func.isRequired,
  entry: _reactImmutableProptypes2.default.record.isRequired,
  guid: _propTypes2.default.string.isRequired,
  quizEntry: _reactImmutableProptypes2.default.record.isRequired,
  // required by propsForInteractionEdit
  addError: _propTypes2.default.func.isRequired,
  errorsAreShowing: _propTypes2.default.bool,
  handleQuizEntryPointsChange: _propTypes2.default.func.isRequired,
  interactionFileUpload: _propTypes2.default.func.isRequired,
  occludeQuizEntries: _propTypes2.default.func.isRequired,
  parentId: _propTypes2.default.string.isRequired,
  parentType: _propTypes2.default.string.isRequired,
  screenreaderNotification: _propTypes2.default.func.isRequired
}, _class.defaultProps = {
  errorsAreShowing: false
}, _temp2);
exports.default = ItemOverride;