text: // SweetAlert
  // 2014-2015 (c) - Tristan Edwards
  // github.com/t4t5/sweetalert
  
  /*
   * jQuery-like functions for manipulating the DOM
   */
  'use strict';
  
  Object.defineProperty(exports, '__esModule', {
    value: true
  });
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  
  var _modulesHandleDom = require('./modules/handle-dom');
  
  /*
   * Handy utilities
   */
  
  var _modulesUtils = require('./modules/utils');
  
  /*
   *  Handle sweetAlert's DOM elements
   */
  
  var _modulesHandleSwalDom = require('./modules/handle-swal-dom');
  
  // Handle button events and keyboard events
  
  var _modulesHandleClick = require('./modules/handle-click');
  
  var _modulesHandleKey = require('./modules/handle-key');
  
  var _modulesHandleKey2 = _interopRequireDefault(_modulesHandleKey);
  
  // Default values
  
  var _modulesDefaultParams = require('./modules/default-params');
  
  var _modulesDefaultParams2 = _interopRequireDefault(_modulesDefaultParams);
  
  var _modulesSetParams = require('./modules/set-params');
  
  var _modulesSetParams2 = _interopRequireDefault(_modulesSetParams);
  
  /*
   * Remember state in cases where opening and handling a modal will fiddle with it.
   * (We also use window.previousActiveElement as a global variable)
   */
  var previousWindowKeyDown;
  var lastFocusedButton;
  
  /*
   * Global sweetAlert function
   * (this is what the user calls)
   */
  var sweetAlert, swal;
  
  exports['default'] = sweetAlert = swal = function () {
    var customizations = arguments[0];
  
    (0, _modulesHandleDom.addClass)(document.body, 'stop-scrolling');
    (0, _modulesHandleSwalDom.resetInput)();
  
    /*
     * Use argument if defined or default value from params object otherwise.
     * Supports the case where a default value is boolean true and should be
     * overridden by a corresponding explicit argument which is boolean false.
     */
    function argumentOrDefault(key) {
      var args = customizations;
      return args[key] === undefined ? _modulesDefaultParams2['default'][key] : args[key];
    }
  
    if (customizations === undefined) {
      (0, _modulesUtils.logStr)('SweetAlert expects at least 1 attribute!');
      return false;
    }
  
    var params = (0, _modulesUtils.extend)({}, _modulesDefaultParams2['default']);
  
    switch (typeof customizations) {
  
      // Ex: swal("Hello", "Just testing", "info");
      case 'string':
        params.title = customizations;
        params.text = arguments[1] || '';
        params.type = arguments[2] || '';
        break;
  
      // Ex: swal({ title:"Hello", text: "Just testing", type: "info" });
      case 'object':
        if (customizations.title === undefined) {
          (0, _modulesUtils.logStr)('Missing "title" argument!');
          return false;
        }
  
        params.title = customizations.title;
  
        for (var customName in _modulesDefaultParams2['default']) {
          params[customName] = argumentOrDefault(customName);
        }
  
        // Show "Confirm" instead of "OK" if cancel button is visible
        params.confirmButtonText = params.showCancelButton ? 'Confirm' : _modulesDefaultParams2['default'].confirmButtonText;
        params.confirmButtonText = argumentOrDefault('confirmButtonText');
  
        // Callback function when clicking on "OK"/"Cancel"
        params.doneFunction = arguments[1] || null;
  
        break;
  
      default:
        (0, _modulesUtils.logStr)('Unexpected type of argument! Expected "string" or "object", got ' + typeof customizations);
        return false;
  
    }
  
    (0, _modulesSetParams2['default'])(params);
    (0, _modulesHandleSwalDom.fixVerticalPosition)();
    (0, _modulesHandleSwalDom.openModal)(arguments[1]);
  
    // Modal interactions
    var modal = (0, _modulesHandleSwalDom.getModal)();
  
    /*
     * Make sure all modal buttons respond to all events
     */
    var $buttons = modal.querySelectorAll('button');
    var buttonEvents = ['onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'onfocus'];
    var onButtonEvent = function onButtonEvent(e) {
      return (0, _modulesHandleClick.handleButton)(e, params, modal);
    };
  
    for (var btnIndex = 0; btnIndex < $buttons.length; btnIndex++) {
      for (var evtIndex = 0; evtIndex < buttonEvents.length; evtIndex++) {
        var btnEvt = buttonEvents[evtIndex];
        $buttons[btnIndex][btnEvt] = onButtonEvent;
      }
    }
  
    // Clicking outside the modal dismisses it (if allowed by user)
    (0, _modulesHandleSwalDom.getOverlay)().onclick = onButtonEvent;
  
    previousWindowKeyDown = window.onkeydown;
  
    var onKeyEvent = function onKeyEvent(e) {
      return (0, _modulesHandleKey2['default'])(e, params, modal);
    };
    window.onkeydown = onKeyEvent;
  
    window.onfocus = function () {
      // When the user has focused away and focused back from the whole window.
      setTimeout(function () {
        // Put in a timeout to jump out of the event sequence.
        // Calling focus() in the event sequence confuses things.
        if (lastFocusedButton !== undefined) {
          lastFocusedButton.focus();
          lastFocusedButton = undefined;
        }
      }, 0);
    };
  
    // Show alert with enabled buttons always
    swal.enableButtons();
  };
  
  /*
   * Set default params for each popup
   * @param {Object} userParams
   */
  sweetAlert.setDefaults = swal.setDefaults = function (userParams) {
    if (!userParams) {
      throw new Error('userParams is required');
    }
    if (typeof userParams !== 'object') {
      throw new Error('userParams has to be a object');
    }
  
    (0, _modulesUtils.extend)(_modulesDefaultParams2['default'], userParams);
  };
  
  /*
   * Animation when closing modal
   */
  sweetAlert.close = swal.close = function () {
    var modal = (0, _modulesHandleSwalDom.getModal)();
  
    (0, _modulesHandleDom.fadeOut)((0, _modulesHandleSwalDom.getOverlay)(), 5);
    (0, _modulesHandleDom.fadeOut)(modal, 5);
    (0, _modulesHandleDom.removeClass)(modal, 'showSweetAlert');
    (0, _modulesHandleDom.addClass)(modal, 'hideSweetAlert');
    (0, _modulesHandleDom.removeClass)(modal, 'visible');
  
    /*
     * Reset icon animations
     */
    var $successIcon = modal.querySelector('.sa-icon.sa-success');
    (0, _modulesHandleDom.removeClass)($successIcon, 'animate');
    (0, _modulesHandleDom.removeClass)($successIcon.querySelector('.sa-tip'), 'animateSuccessTip');
    (0, _modulesHandleDom.removeClass)($successIcon.querySelector('.sa-long'), 'animateSuccessLong');
  
    var $errorIcon = modal.querySelector('.sa-icon.sa-error');
    (0, _modulesHandleDom.removeClass)($errorIcon, 'animateErrorIcon');
    (0, _modulesHandleDom.removeClass)($errorIcon.querySelector('.sa-x-mark'), 'animateXMark');
  
    var $warningIcon = modal.querySelector('.sa-icon.sa-warning');
    (0, _modulesHandleDom.removeClass)($warningIcon, 'pulseWarning');
    (0, _modulesHandleDom.removeClass)($warningIcon.querySelector('.sa-body'), 'pulseWarningIns');
    (0, _modulesHandleDom.removeClass)($warningIcon.querySelector('.sa-dot'), 'pulseWarningIns');
  
    // Reset custom class (delay so that UI changes aren't visible)
    setTimeout(function () {
      var customClass = modal.getAttribute('data-custom-class');
      (0, _modulesHandleDom.removeClass)(modal, customClass);
    }, 300);
  
    // Make page scrollable again
    (0, _modulesHandleDom.removeClass)(document.body, 'stop-scrolling');
  
    // Reset the page to its previous state
    window.onkeydown = previousWindowKeyDown;
    if (window.previousActiveElement) {
      window.previousActiveElement.focus();
    }
    lastFocusedButton = undefined;
    clearTimeout(modal.timeout);
  
    return true;
  };
  
  /*
   * Validation of the input field is done by user
   * If something is wrong => call showInputError with errorMessage
   */
  sweetAlert.showInputError = swal.showInputError = function (errorMessage) {
    var modal = (0, _modulesHandleSwalDom.getModal)();
  
    var $errorIcon = modal.querySelector('.sa-input-error');
    (0, _modulesHandleDom.addClass)($errorIcon, 'show');
  
    var $errorContainer = modal.querySelector('.sa-error-container');
    (0, _modulesHandleDom.addClass)($errorContainer, 'show');
  
    $errorContainer.querySelector('p').innerHTML = errorMessage;
  
    setTimeout(function () {
      sweetAlert.enableButtons();
    }, 1);
  
    modal.querySelector('input').focus();
  };
  
  /*
   * Reset input error DOM elements
   */
  sweetAlert.resetInputError = swal.resetInputError = function (event) {
    // If press enter => ignore
    if (event && event.keyCode === 13) {
      return false;
    }
  
    var $modal = (0, _modulesHandleSwalDom.getModal)();
  
    var $errorIcon = $modal.querySelector('.sa-input-error');
    (0, _modulesHandleDom.removeClass)($errorIcon, 'show');
  
    var $errorContainer = $modal.querySelector('.sa-error-container');
    (0, _modulesHandleDom.removeClass)($errorContainer, 'show');
  };
  
  /*
   * Disable confirm and cancel buttons
   */
  sweetAlert.disableButtons = swal.disableButtons = function (event) {
    var modal = (0, _modulesHandleSwalDom.getModal)();
    var $confirmButton = modal.querySelector('button.confirm');
    var $cancelButton = modal.querySelector('button.cancel');
    $confirmButton.disabled = true;
    $cancelButton.disabled = true;
  };
  
  /*
   * Enable confirm and cancel buttons
   */
  sweetAlert.enableButtons = swal.enableButtons = function (event) {
    var modal = (0, _modulesHandleSwalDom.getModal)();
    var $confirmButton = modal.querySelector('button.confirm');
    var $cancelButton = modal.querySelector('button.cancel');
    $confirmButton.disabled = false;
    $cancelButton.disabled = false;
  };
  
  if (typeof window !== 'undefined') {
    // The 'handle-click' module requires
    // that 'sweetAlert' was set as global.
    window.sweetAlert = window.swal = sweetAlert;
  } else {
    (0, _modulesUtils.logStr)('SweetAlert is a frontend module!');
  }
  module.exports = exports['default'];