"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.addError = addError;
exports.addSuccess = addSuccess;
exports.addInfo = addInfo;
exports.screenreaderNotification = screenreaderNotification;
exports.removeAlert = removeAlert;

var _uuid = require("uuid");

var _constants = require("@instructure/quiz-common/lib/constants");

function addAlert(_ref) {
  var message = _ref.message,
      variant = _ref.variant,
      _ref$removeIn = _ref.removeIn,
      removeIn = _ref$removeIn === void 0 ? _constants.DEFAULT_ALERT_TIME : _ref$removeIn,
      _ref$guid = _ref.guid,
      guid = _ref$guid === void 0 ? (0, _uuid.v4)() : _ref$guid;
  return {
    type: _constants.ADD_ALERT,
    payload: {
      message: message,
      removeIn: removeIn,
      uuid: guid,
      variant: variant
    }
  };
}

function addError(message, removeIn, guid) {
  return addAlert({
    message: message,
    variant: 'error',
    removeIn: removeIn,
    guid: guid
  });
}

function addSuccess(message) {
  return addAlert({
    message: message,
    variant: 'success'
  });
}

function addInfo(message) {
  return addAlert({
    message: message,
    variant: 'info'
  });
}

function screenreaderNotification(message) {
  return addAlert({
    message: message,
    variant: 'screenreader',
    removeIn: 2000
  });
}

function removeAlert(uuid) {
  return {
    type: _constants.REMOVE_ALERT,
    payload: {
      uuid: uuid
    }
  };
}