'use strict';

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

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

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 _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

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

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

var _differenceWith = require('lodash/differenceWith');

var _differenceWith2 = _interopRequireDefault(_differenceWith);

var _intersectionWith = require('lodash/intersectionWith');

var _intersectionWith2 = _interopRequireDefault(_intersectionWith);

var _isEqual = require('lodash/isEqual');

var _isEqual2 = _interopRequireDefault(_isEqual);

var _Alert = require('@instructure/ui-alerts/lib/components/Alert');

var _Alert2 = _interopRequireDefault(_Alert);

var _BreadcrumbLink = require('@instructure/ui-breadcrumb/lib/components/Breadcrumb/BreadcrumbLink');

var _BreadcrumbLink2 = _interopRequireDefault(_BreadcrumbLink);

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

var _Button2 = _interopRequireDefault(_Button);

var _Heading = require('@instructure/ui-elements/lib/components/Heading');

var _Heading2 = _interopRequireDefault(_Heading);

var _IconDiscussionLine = require('instructure-icons/lib/Line/IconDiscussionLine');

var _IconDiscussionLine2 = _interopRequireDefault(_IconDiscussionLine);

var _IconDiscussionSolid = require('instructure-icons/lib/Solid/IconDiscussionSolid');

var _IconDiscussionSolid2 = _interopRequireDefault(_IconDiscussionSolid);

var _PresentationContent = require('@instructure/ui-a11y/lib/components/PresentationContent');

var _PresentationContent2 = _interopRequireDefault(_PresentationContent);

var _ScreenReaderContent = require('@instructure/ui-a11y/lib/components/ScreenReaderContent');

var _ScreenReaderContent2 = _interopRequireDefault(_ScreenReaderContent);

var _Text = require('@instructure/ui-elements/lib/components/Text');

var _Text2 = _interopRequireDefault(_Text);

var _TextInput = require('@instructure/ui-forms/lib/components/TextInput');

var _TextInput2 = _interopRequireDefault(_TextInput);

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

var _lib2 = _interopRequireDefault(_lib);

var _EntrySave = require('../../../../common/components/resources/entry/EntrySave');

var _EntrySave2 = _interopRequireDefault(_EntrySave);

var _ItemEdit = require('../../../../common/components/resources/item/ItemEdit');

var _ItemEdit2 = _interopRequireDefault(_ItemEdit);

var _ItemFeedbackModal = require('../../../../building/components/resources/ItemFeedbackModal');

var _ItemFeedbackModal2 = _interopRequireDefault(_ItemFeedbackModal);

var _ItemShow = require('../../../../common/components/resources/item/ItemShow');

var _ItemShow2 = _interopRequireDefault(_ItemShow);

var _Page = require('../../../../common/components/layout/Page');

var _Page2 = _interopRequireDefault(_Page);

var _Spinner = require('../../../../common/components/shared/spinner/Spinner');

var _Spinner2 = _interopRequireDefault(_Spinner);

var _StimulusEditInfo = require('../../../../common/components/resources/stimulus/StimulusEditInfo');

var _StimulusEditInfo2 = _interopRequireDefault(_StimulusEditInfo);

var _StimulusShowInfo = require('../../../../common/components/resources/stimulus/StimulusShowInfo');

var _StimulusShowInfo2 = _interopRequireDefault(_StimulusShowInfo);

var _index = require('../../../../common/components/shared/TagSelect/index');

var _index2 = _interopRequireDefault(_index);

var _WarningWrapper = require('../../../../common/components/resources/WarningWrapper');

var _WarningWrapper2 = _interopRequireDefault(_WarningWrapper);

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

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _items = require('../../../../building/api/items');

var _stimuli = require('../../../../building/api/stimuli');

var _warningHelpers = require('../../../../common/util/warningHelpers');

var _NavWrapper = require('../NavWrapper');

var _NavWrapper2 = _interopRequireDefault(_NavWrapper);

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

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.BankEntry__styles__content {\n  padding: ' + theme.contentPaddingTopBottom + ' ' + theme.contentPaddingLeftRight + ';\n  background-color: ' + theme.contentBackgroundColor + ';\n}\n\n.BankEntry__styles__entryRow {\n  margin-bottom: ' + theme.entryRowMargin + ';\n}\n\n.BankEntry__styles__headerRow {\n  display: flex;\n  flex-direction: row;\n  justify-content: space-between;\n  align-items: flex-start;\n  color: ' + theme.headerRowColor + ';\n  padding: ' + theme.headerRowPadding + ';\n}\n\n.BankEntry__styles__leftHeader {\n  flex: 0 0 auto;\n  display: flex;\n  flex-direction: column;\n  align-items: flex-start;\n  margin-right: ' + theme.leftHeaderMargin + ';\n}\n\n.BankEntry__styles__headerText {\n  font-size: ' + theme.headerTextFontSize + ';\n}\n\n.BankEntry__styles__header {\n  background-color: ' + theme.headerBackgroundColor + ';\n  color: ' + theme.headerColor + ';\n  padding: ' + theme.headerPaddingTopBottom + ' ' + theme.headerPaddingLeftRight + ';\n  display: flex;\n  justify-content: space-between;\n  vertical-align: middle;\n  align-items: center;\n}\n\n.BankEntry__styles__rightHeader {\n  text-align: right;\n}\n\n[dir="ltr"] .BankEntry__styles__rightHeader {\n  text-align: right;\n}\n\n[dir="rtl"] .BankEntry__styles__rightHeader {\n  text-align: right;\n}\n\n.BankEntry__styles__footer,\n.BankEntry__styles__leftFooter,\n.BankEntry__styles__rightFooter {\n  display: flex;\n  flex-direction: row;\n}\n\n.BankEntry__styles__footer {\n  text-align: left;\n  padding-bottom: ' + theme.footerPaddingBottom + ';\n  padding-top: ' + theme.footerPaddingTop + ';\n}\n\n[dir="ltr"] .BankEntry__styles__footer {\n  text-align: left;\n}\n\n[dir="rtl"] .BankEntry__styles__footer {\n  text-align: left;\n}\n\n.BankEntry__styles__rightFooter {\n  flex: 8 0 0;\n  justify-content: flex-end;\n  padding-left: ' + theme.rightFooterPaddingLeftRight + ';\n  padding-right: ' + theme.rightFooterPaddingLeftRight + ';\n}\n\n.BankEntry__styles__entryEdit {\n  border-bottom: ' + theme.entryEditBorderWidth + ' solid ' + theme.entryEditBorderColor + ';\n}\n';
  },
  'content': 'BankEntry__styles__content',
  'entryRow': 'BankEntry__styles__entryRow',
  'headerRow': 'BankEntry__styles__headerRow',
  'leftHeader': 'BankEntry__styles__leftHeader',
  'headerText': 'BankEntry__styles__headerText',
  'header': 'BankEntry__styles__header',
  'rightHeader': 'BankEntry__styles__rightHeader',
  'footer': 'BankEntry__styles__footer',
  'leftFooter': 'BankEntry__styles__leftFooter',
  'rightFooter': 'BankEntry__styles__rightFooter',
  'entryEdit': 'BankEntry__styles__entryEdit'
};
var BankEntry = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp2 = _class2 = function (_Component) {
  (0, _inherits3.default)(BankEntry, _Component);

  function BankEntry() {
    var _ref,
        _this2 = this;

    var _temp, _this, _ret;

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

    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 = BankEntry.__proto__ || Object.getPrototypeOf(BankEntry)).call.apply(_ref, [this].concat(args))), _this), _this.navigateToBank = function () {
      _this.props.navigateToBank(_this.props.bankId);
    }, _this.handleTitleChange = function (e) {
      _this.props.changeItemTitle(_this.getEntry().id, e.target.value);
    }, _this.submitHandler = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
      return _regenerator2.default.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              if (!_this.getEntry().isTemporary()) {
                _context.next = 5;
                break;
              }

              _context.next = 3;
              return _this.temporarySubmit();

            case 3:
              _context.next = 7;
              break;

            case 5:
              _context.next = 7;
              return _this.normalSubmit();

            case 7:
              _this.navigateToBank();

            case 8:
            case 'end':
              return _context.stop();
          }
        }
      }, _callee, _this2);
    })), _this.clearChanges = function () {
      if (!_this.getEntry()) return;
      _this.props.clearModifications('items', _this.getEntry().id);
      _this.props.setPendingDeletionTagAssociations(_this.props.bankEntry.entryType, _this.getEntry().id, []);
      _this.props.setPendingAdditionTagAssociations(_this.props.bankEntry.entryType, _this.getEntry().id, []);
      if (_this.getEntry().isTemporary()) {
        _this.props.clearTemporaryBankItem(_this.props.bankId);
      }
    }, _this.handlePointsChange = function (points) {
      _this.props.changeQuizEntryPoints(_this.getEntry().id, points);
    }, _this.editProps = function (entry) {
      return {
        cancelHandler: _this.navigateToBank,
        clearChanges: _this.clearChanges,
        contextUuid: null,
        entry: entry,
        guid: _this.props.bankEntry.id + '_bank_entry_edit',
        handleQuizEntryPointsChange: _this.handlePointsChange,
        parentId: _this.props.bankId,
        parentType: _constants.PARENT_TYPE_BANK,
        stimulus: entry,
        submitHandler: _this.submitHandler
      };
    }, _this.openFeedbackModal = function () {
      _this.props.setUi(_constants.ITEM_FEEDBACK_MODAL_ITEM, _this.getEntry().getWorkingInstance());
      _this.props.setUi(_constants.ITEM_FEEDBACK_MODAL_FEEDBACK, _this.getEntry().getWorkingInstance().feedback);
      _this.props.openModal(_constants.ITEM_FEEDBACK_MODAL, { modalTrigger: _this.addFeedbackButton });
    }, _this.storeFeedbackButtonRef = function (button) {
      _this.addFeedbackButton = button;
    }, _this.compareTags = function (left, right) {
      return left.tag_value === right.tag_value;
    }, _this.handleTagChange = function (tags) {
      var bankEntry = _this.props.bankEntry;

      var tagAssociations = _this.props.tagAssociations.toJS();
      var deletedTags = (0, _differenceWith2.default)(tagAssociations, tags, _isEqual2.default);
      var addedTags = tags.filter(function (tag) {
        return tag.id == null;
      });
      // If a tag that was removed is being re-added,
      // remove from both addedTags and deletedTags
      var restoreTags = (0, _intersectionWith2.default)(addedTags, deletedTags, _this.compareTags);
      addedTags = (0, _differenceWith2.default)(addedTags, restoreTags, _isEqual2.default);
      deletedTags = (0, _differenceWith2.default)(deletedTags, restoreTags, _this.compareTags);
      var bankEntryId = _this.getBankEntryId(bankEntry);
      _this.props.setPendingDeletionTagAssociations(bankEntry.entryType, bankEntryId, deletedTags);
      _this.props.setPendingAdditionTagAssociations(bankEntry.entryType, bankEntryId, addedTags);
    }, _this.handleTagInputChange = function (tagText) {
      var bankEntry = _this.props.bankEntry;

      _this.props.setTagInput(bankEntry.entryType, _this.getBankEntryId(bankEntry), tagText);
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(BankEntry, [{
    key: 'componentDidMount',
    value: function componentDidMount() {
      if (!this.isTemporary()) {
        this.props.getBankEntry(this.props.bankId, this.props.bankEntryId);
      }
      this.props.getBank(this.props.bankId);
    }
  }, {
    key: 'componentWillUnmount',
    value: function componentWillUnmount() {
      this.props.setShouldClone(false);
    }
  }, {
    key: 'componentWillMount',
    value: function componentWillMount() {
      this.props.setShouldClone(false);
    }
  }, {
    key: 'isTemporary',
    value: function isTemporary() {
      return this.getEntry() && this.getEntry().isTemporary();
    }
  }, {
    key: 'getEntry',
    value: function getEntry() {
      return this.props.bankEntry.getEntry();
    }
  }, {
    key: 'isItemEntry',
    value: function isItemEntry() {
      return this.props.bankEntry.entryType === 'Item';
    }
  }, {
    key: 'entryLinkName',
    value: function entryLinkName() {
      if (this.isTemporary()) {
        return this.isItemEntry() ? 'Nouvel \xE9l\xE9ment' : 'Nouveau stimulus';
      } else {
        return this.isItemEntry() ? 'Modifier l\'\xE9l\xE9ment' : 'Modifier stimulus';
      }
    }
  }, {
    key: 'renderNav',
    value: function renderNav() {
      return _react2.default.createElement(
        _NavWrapper2.default,
        {
          closeTray: this.props.closeTray,
          navigateToBanks: this.props.navigateToBanks,
          navigateToBuild: this.props.navigateToBuild
        },
        _react2.default.createElement(
          _BreadcrumbLink2.default,
          { key: 'bank', onClick: this.navigateToBank, autoFocus: true },
          this.props.bank.title
        ),
        _react2.default.createElement(
          _BreadcrumbLink2.default,
          { key: 'bankEntry' },
          this.entryLinkName()
        )
      );
    }
  }, {
    key: 'renderTitle',
    value: function renderTitle(entry) {
      if (this.isItemEntry()) {
        return _react2.default.createElement(_TextInput2.default, {
          label: _react2.default.createElement(
            _ScreenReaderContent2.default,
            null,
            'Modifier le titre de la question'
          ),
          type: 'text',
          placeholder: 'Nom de la question',
          onChange: this.handleTitleChange,
          value: entry.getWorkingInstance().title
        });
      }
    }
  }, {
    key: 'renderHeader',
    value: function renderHeader(entry) {
      if (!entry) return;
      var props = this.editProps(entry);
      var identifier = this.isItemEntry() ? '\xC9l\xE9ment ' + entry.id : 'Stimulus ' + entry.id;
      var tempIdentifier = this.isItemEntry() ? 'Nouvel \xE9l\xE9ment' : 'Nouveau stimulus';
      var itemIdentifier = this.isTemporary() ? tempIdentifier : identifier;
      var entryName = this.isItemEntry() ? entry.getInteractionType().name : 'Stimulus';
      return _react2.default.createElement(
        'div',
        { className: styles.header },
        _react2.default.createElement(
          'div',
          { className: styles.leftHeader },
          _react2.default.createElement(
            'div',
            { className: styles.headerText },
            _react2.default.createElement(
              _Heading2.default,
              { level: 'reset', as: 'h2' },
              entryName,
              _react2.default.createElement(
                _PresentationContent2.default,
                null,
                ' | '
              ),
              itemIdentifier
            )
          )
        ),
        this.renderTitle(entry),
        _react2.default.createElement(
          'div',
          { className: styles.rightHeader },
          _react2.default.createElement(_EntrySave2.default, props)
        )
      );
    }
  }, {
    key: 'hasPendingTagModifications',
    value: function hasPendingTagModifications() {
      return !this.props.pendingDeletionTags.isEmpty() || !this.props.pendingAdditionTags.isEmpty();
    }
  }, {
    key: 'createTagsForClone',
    value: function createTagsForClone(newBankEntry, tags) {
      this.props.createTagAssociations(newBankEntry.id, newBankEntry.entry_type, newBankEntry.entry.id, tags.map(function (tag) {
        return tag.tag_value;
      }));
      // Pending tag associations were applied to the original bank entry, so clear those out
      this.props.setPendingAdditionTagAssociations(this.props.bankEntry.entryType, this.getEntry().id, []);
      this.props.setPendingDeletionTagAssociations(this.props.bankEntry.entryType, this.getEntry().id, []);
    }
  }, {
    key: 'updateTagsForEntry',
    value: function () {
      var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
        return _regenerator2.default.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                if (this.props.shouldClone) {
                  _context2.next = 5;
                  break;
                }

                _context2.next = 3;
                return this.props.createTagAssociations(this.props.bankEntryId, this.props.bankEntry.entryType, this.getBankEntryId(this.props.bankEntry), this.props.pendingAdditionTags.map(function (tagToAdd) {
                  return tagToAdd.get('tag_value');
                }));

              case 3:
                _context2.next = 5;
                return this.props.deleteTagAssociations(this.props.bankEntryId, this.props.bankEntry.entryType, this.getBankEntryId(this.props.bankEntry), this.props.pendingDeletionTags.map(function (tagToDelete) {
                  return tagToDelete.get('id');
                }));

              case 5:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, this);
      }));

      function updateTagsForEntry() {
        return _ref3.apply(this, arguments);
      }

      return updateTagsForEntry;
    }()
  }, {
    key: 'normalSubmit',
    value: function () {
      var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
        var entry, tags, createEntryCb, newBankEntry, workingEntry, updateFunc, toClear;
        return _regenerator2.default.wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                entry = this.getEntry();

                if (!(entry.hasModifications() || this.props.shouldClone && this.hasPendingTagModifications())) {
                  _context3.next = 17;
                  break;
                }

                if (!this.props.shouldClone) {
                  _context3.next = 11;
                  break;
                }

                tags = this.visibleTags();
                createEntryCb = this.isItemEntry() ? _items.createItem : _stimuli.createStimulus;
                _context3.next = 7;
                return this.props.cloneBankEntry(this.props.bankEntry, createEntryCb);

              case 7:
                newBankEntry = _context3.sent;

                this.createTagsForClone(newBankEntry, tags);
                _context3.next = 15;
                break;

              case 11:
                workingEntry = entry.getWorkingInstance();
                updateFunc = this.isItemEntry() ? this.props.updateItem : this.props.updateStimulus;
                _context3.next = 15;
                return updateFunc(workingEntry, this.props.bankId, 'bank');

              case 15:
                toClear = this.isItemEntry() ? 'items' : 'stimuli';

                this.props.clearModifications(toClear, entry.id);

              case 17:
                if (!this.hasPendingTagModifications()) {
                  _context3.next = 20;
                  break;
                }

                _context3.next = 20;
                return this.updateTagsForEntry();

              case 20:
              case 'end':
                return _context3.stop();
            }
          }
        }, _callee3, this);
      }));

      function normalSubmit() {
        return _ref4.apply(this, arguments);
      }

      return normalSubmit;
    }()
  }, {
    key: 'temporarySubmit',
    value: function () {
      var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
        var entry, workingEntry, workingBankEntry, createEntryCb, newBankEntry, toClear;
        return _regenerator2.default.wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                entry = this.getEntry();
                workingEntry = entry.getWorkingInstance();
                workingBankEntry = this.props.bankEntry.getWorkingInstance();
                createEntryCb = this.isItemEntry() ? _items.createItem : _stimuli.createStimulus;
                _context4.next = 6;
                return this.props.createEntryAndBankEntry(this.props.bankId, workingEntry, workingBankEntry, createEntryCb);

              case 6:
                newBankEntry = _context4.sent;

                if (this.hasPendingTagModifications()) {
                  this.props.createTagAssociations(newBankEntry.id, newBankEntry.entry_type, newBankEntry.entry.id, this.props.pendingAdditionTags.map(function (tagToAdd) {
                    return tagToAdd.get('tag_value');
                  }));
                }
                toClear = this.isItemEntry() ? 'items' : 'stimuli';

                this.props.clearModifications(toClear, entry.id);
                this.props.clearTemporaryBankItem(this.props.bankId);

              case 11:
              case 'end':
                return _context4.stop();
            }
          }
        }, _callee4, this);
      }));

      function temporarySubmit() {
        return _ref5.apply(this, arguments);
      }

      return temporarySubmit;
    }()
  }, {
    key: 'renderFeedbackSection',
    value: function renderFeedbackSection() {
      if (!this.isItemEntry()) {
        return;
      }
      var shouldClone = this.props.shouldClone;

      var disabled = this.getEntry().isImmutable() && !shouldClone;
      var icon = this.getEntry().getWorkingInstance().hasFeedback() ? _IconDiscussionSolid2.default : _IconDiscussionLine2.default;
      return _react2.default.createElement(
        _Button2.default,
        {
          variant: 'icon',
          onClick: this.openFeedbackModal,
          disabled: disabled,
          ref: this.storeFeedbackButtonRef,
          icon: icon
        },
        _react2.default.createElement(
          _ScreenReaderContent2.default,
          null,
          'Modifier remarque au niveau de l\'\xE9l\xE9ment'
        )
      );
    }
  }, {
    key: 'getBankEntryId',
    value: function getBankEntryId(bankEntry) {
      // bankEntry.entry can be either 'TEMPORARY_ITEM' or an entire Map
      return bankEntry.entry ? bankEntry.entry.get ? bankEntry.entry.get('id') : bankEntry.entry : null;
    }
  }, {
    key: 'visibleTags',
    value: function visibleTags() {
      var _props = this.props,
          pendingAdditionTags = _props.pendingAdditionTags,
          pendingDeletionTags = _props.pendingDeletionTags,
          tagAssociations = _props.tagAssociations;

      return tagAssociations.filter(function (tag) {
        return !pendingDeletionTags.includes(tag);
      }).concat(pendingAdditionTags).toJS();
    }
  }, {
    key: 'newTagSuggest',
    value: function newTagSuggest() {
      var visibleTags = this.visibleTags();
      var tagInput = this.props.tagInput;
      // Don't allow tag creation if the value matches an existing tag

      if (visibleTags.some(function (tag) {
        return tag.tag_value === tagInput;
      })) {
        return null;
      } else {
        return tagInput;
      }
    }
  }, {
    key: 'renderEntry',
    value: function renderEntry(entry) {
      if (!entry) return;
      var useBankTags = this.props.useBankTags;

      var props = this.editProps(entry);
      var propsFunc = this.isItemEntry() ? _warningHelpers.propsForItemVersioningWrapper : _warningHelpers.propsForStimulusVersioningWrapper;
      var versioningProps = propsFunc(entry.isImmutable(), this.props.shouldClone, this.props.setShouldClone, this.navigateToBank, true);

      var canEdit = !entry.isImmutable() || this.props.shouldClone;
      var ItemComponent = canEdit ? _ItemEdit2.default : _ItemShow2.default;
      var StimulusComponent = canEdit ? _StimulusEditInfo2.default : _StimulusShowInfo2.default;

      var EntryComponent = this.isItemEntry() ? ItemComponent : StimulusComponent;

      return _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(
          'div',
          { className: styles.entryEdit },
          _react2.default.createElement(
            _WarningWrapper2.default,
            versioningProps,
            canEdit && _react2.default.createElement(
              _Alert2.default,
              { closeButtonLabel: 'Ignorer', margin: '0 0 medium 0' },
              _react2.default.createElement(
                _Text2.default,
                null,
                'Les modifications apport\xE9es ici appara\xEEtront sur les \xE9valuations utilisant cet \xE9l\xE9ment.'
              )
            ),
            _react2.default.createElement(EntryComponent, props),
            useBankTags && _react2.default.createElement(_index2.default, { tags: this.visibleTags(),
              newTagSuggest: this.newTagSuggest(),
              onChange: this.handleTagChange,
              onInputChange: this.handleTagInputChange })
          )
        ),
        _react2.default.createElement(
          'div',
          { className: styles.footer },
          _react2.default.createElement(
            'div',
            { className: styles.leftFooter },
            this.renderFeedbackSection()
          ),
          _react2.default.createElement(
            'div',
            { className: styles.rightFooter },
            _react2.default.createElement(_EntrySave2.default, props)
          )
        )
      );
    }
  }, {
    key: 'render',
    value: function render() {
      var entry = this.getEntry();
      if (entry && !entry.isLoaded()) {
        return _react2.default.createElement(_Spinner2.default, null);
      }
      return _react2.default.createElement(
        _Page2.default,
        null,
        this.renderNav(),
        _react2.default.createElement(
          'div',
          { className: styles.content },
          this.renderHeader(entry),
          this.renderEntry(entry),
          !this.props.isCompact && _react2.default.createElement(_ItemFeedbackModal2.default, { parentId: this.props.bankId, parentType: _constants.PARENT_TYPE_BANK })
        )
      );
    }
  }]);
  BankEntry.displayName = 'BankEntry'
  ;
  return BankEntry;
}(_react.Component), _class2.propTypes = {
  bankEntryId: _propTypes2.default.string.isRequired,
  bankId: _propTypes2.default.string.isRequired,
  bank: _reactImmutableProptypes2.default.record.isRequired,
  bankEntry: _reactImmutableProptypes2.default.record.isRequired,
  changeItemTitle: _propTypes2.default.func.isRequired,
  changeQuizEntryPoints: _propTypes2.default.func.isRequired,
  cloneBankEntry: _propTypes2.default.func.isRequired,
  clearModifications: _propTypes2.default.func.isRequired,
  clearTemporaryBankItem: _propTypes2.default.func.isRequired,
  createEntryAndBankEntry: _propTypes2.default.func.isRequired,
  closeTray: _propTypes2.default.func.isRequired,
  createTagAssociations: _propTypes2.default.func.isRequired,
  deleteTagAssociations: _propTypes2.default.func.isRequired,
  getBankEntry: _propTypes2.default.func.isRequired,
  getBank: _propTypes2.default.func.isRequired,
  getItemTagAssociations: _propTypes2.default.func.isRequired,
  getStimulusTagAssociations: _propTypes2.default.func.isRequired,
  isCompact: _propTypes2.default.bool,
  navigateToBanks: _propTypes2.default.func.isRequired, // can be from consumer
  navigateToBank: _propTypes2.default.func.isRequired, // can be from consumer
  navigateToBuild: _propTypes2.default.func.isRequired, // from consumer
  openModal: _propTypes2.default.func.isRequired,
  pendingAdditionTags: _reactImmutableProptypes2.default.listOf(_reactImmutableProptypes2.default.map),
  pendingDeletionTags: _reactImmutableProptypes2.default.listOf(_reactImmutableProptypes2.default.map),
  setPendingDeletionTagAssociations: _propTypes2.default.func.isRequired,
  setShouldClone: _propTypes2.default.func.isRequired,
  setTagInput: _propTypes2.default.func.isRequired,
  setUi: _propTypes2.default.func.isRequired,
  shouldClone: _propTypes2.default.bool.isRequired,
  tagAssociations: _reactImmutableProptypes2.default.listOf(_reactImmutableProptypes2.default.map),
  tagInput: _propTypes2.default.string,
  updateItem: _propTypes2.default.func.isRequired,
  updateStimulus: _propTypes2.default.func.isRequired,
  useBankTags: _propTypes2.default.bool.isRequired
}, _class2.defaultProps = {
  isCompact: false,
  pendingAdditionTags: _immutable2.default.List(),
  pendingDeletionTags: _immutable2.default.List(),
  tagAssociations: _immutable2.default.List(),
  tagInput: null
}, _temp2)) || _class);
exports.default = BankEntry;