'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.withConfirm = withConfirm;
exports.openAddContentModal = openAddContentModal;
exports.openDeleteStimulusModal = openDeleteStimulusModal;
exports.openMoveImmutableModal = openMoveImmutableModal;
exports.openModal = openModal;
exports.closeModal = closeModal;

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

function withConfirm(onContinue) {
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

  var defaultConfirmOptions = {
    text: opts.text,
    onContinue: onContinue,
    title: void 0,
    confirmation: true,
    onCancel: void 0,
    continueText: void 0,
    continueVariant: void 0,
    cancelText: void 0,
    size: void 0,
    shouldReturnFocus: true
  };

  var modalOptions = Object.assign({}, defaultConfirmOptions, opts);

  return {
    type: _constants.OPEN_MODAL,
    payload: {
      title: modalOptions.title,
      options: modalOptions
    }
  };
}

function openAddContentModal(data) {
  return {
    type: _constants.OPEN_ADD_CONTENT_MODAL,
    payload: {
      allowStimulusCreation: data.allowStimulusCreation,
      parentEntryId: data.parentEntryId,
      position: data.position,
      quizId: data.quizId,
      stimulusId: data.stimulusId
    }
  };
}

function openDeleteStimulusModal(entry) {
  return {
    type: _constants.OPEN_DELETE_STIMULUS_MODAL,
    payload: { entry: entry }
  };
}

function openMoveImmutableModal() {
  return {
    type: _constants.OPEN_MOVE_IMMUTABLE_MODAL,
    payload: {}
  };
}

function openModal(title) {
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

  return {
    type: _constants.OPEN_MODAL,
    payload: {
      title: title,
      options: opts
    }
  };
}

function closeModal(title) {
  return {
    type: _constants.CLOSE_MODAL,
    payload: { title: title }
  };
}