PageSourceSearch

https://paraty.rj.gov.br/scripts/sweetalert2.js

js paraty.rj.gov.br collected 2026-10-02 16:18:21 UTC 55,656 bytes, 1,772 lines download raw bytes

1/*!
2 * sweetalert2 v6.9.0
3 * Released under the MIT License.
4 */
5(function (global, factory) {
6	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7	typeof define === 'function' && define.amd ? define(factory) :
8	(global.Sweetalert2 = factory());
9}(this, (function () { 'use strict';
10
11var defaultParams = {
12  title: '',
13  titleText: '',
14  text: '',
15  html: '',
16  type: null,
17  customClass: '',
18  target: 'body',
19  animation: true,
20  allowOutsideClick: true,
21  allowEscapeKey: true,
22  allowEnterKey: true,
23  showConfirmButton: true,
24  showCancelButton: false,
25  preConfirm: null,
26  confirmButtonText: 'OK',
27  confirmButtonAriaLabel: '',
28  confirmButtonColor: '#3085d6',
29  confirmButtonClass: null,
30  cancelButtonText: 'Cancel',
31  cancelButtonAriaLabel: '',
32  cancelButtonColor: '#aaa',
33  cancelButtonClass: null,
34  buttonsStyling: true,
35  reverseButtons: false,
36  focusConfirm: true,
37  focusCancel: false,
38  showCloseButton: false,
39  closeButtonAriaLabel: 'Close this dialog',
40  showLoaderOnConfirm: false,
41  imageUrl: null,
42  imageWidth: null,
43  imageHeight: null,
44  imageAlt: '',
45  imageClass: null,
46  timer: null,
47  width: 500,
48  padding: 20,
49  background: '#fff',
50  input: null,
51  inputPlaceholder: '',
52  inputValue: '',
53  inputOptions: {},
54  inputAutoTrim: true,
55  inputClass: null,
56  inputAttributes: {},
57  inputValidator: null,
58  progressSteps: [],
59  currentProgressStep: null,
60  progressStepsDistance: '40px',
61  onOpen: null,
62  onClose: null,
63  useRejections: true
64};
65
66var swalPrefix = 'swal2-';
67
68var prefix = function prefix(items) {
69  var result = {};
70  for (var i in items) {
71    result[items[i]] = swalPrefix + items[i];
72  }
73  return result;
74};
75
76var swalClasses = prefix(['container', 'shown', 'iosfix', 'modal', 'overlay', 'fade', 'show', 'hide', 'noanimation', 'close', 'title', 'content', 'buttonswrapper', 'confirm', 'cancel', 'icon', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea', 'inputerror', 'validationerror', 'progresssteps', 'activeprogressstep', 'progresscircle', 'progressline', 'loading', 'styled']);
77
78var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
79
80/*
81 * Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
82 */
83var colorLuminance = function colorLuminance(hex, lum) {
84  // Validate hex string
85  hex = String(hex).replace(/[^0-9a-f]/gi, '');
86  if (hex.length < 6) {
87    hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
88  }
89  lum = lum || 0;
90
91  // Convert to decimal and change luminosity
92  var rgb = '#';
93  for (var i = 0; i < 3; i++) {
94    var c = parseInt(hex.substr(i * 2, 2), 16);
95    c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
96    rgb += ('00' + c).substr(c.length);
97  }
98
99  return rgb;
100};
101
102var uniqueArray = function uniqueArray(arr) {
103  var result = [];
104  for (var i in arr) {
105    if (result.indexOf(arr[i]) === -1) {
106      result.push(arr[i]);
107    }
108  }
109  return result;
110};
111
112// Remember state in cases where opening and handling a modal will fiddle with it.
113var states = {
114  previousWindowKeyDown: null,
115  previousActiveElement: null,
116  previousBodyPadding: null
117
118  /*
119   * Add modal + overlay to DOM
120   */
121};var init = function init(params) {
122  // Clean up the old modal if it exists
123  var c = getContainer();
124  if (c) {
125    c.parentNode.removeChild(c);
126  }
127
128  if (typeof document === 'undefined') {
129    console.error('SweetAlert2 requires document to initialize');
130    return;
131  }
132
133  var container = document.createElement('div');
134  container.className = swalClasses.container;
135  container.innerHTML = sweetHTML;
136
137  var targetElement = typeof params.target === 'string' ? document.querySelector(params.target) : params.target;
138  targetElement.appendChild(container);
139
140  var modal = getModal();
141  var input = getChildByClass(modal, swalClasses.input);
142  var file = getChildByClass(modal, swalClasses.file);
143  var range = modal.querySelector('.' + swalClasses.range + ' input');
144  var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
145  var select = getChildByClass(modal, swalClasses.select);
146  var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
147  var textarea = getChildByClass(modal, swalClasses.textarea);
148
149  input.oninput = function () {
150    sweetAlert.resetValidationError();
151  };
152
153  input.onkeydown = function (event) {
154    setTimeout(function () {
155      if (event.keyCode === 13 && params.allowEnterKey) {
156        event.stopPropagation();
157        sweetAlert.clickConfirm();
158      }
159    }, 0);
160  };
161
162  file.onchange = function () {
163    sweetAlert.resetValidationError();
164  };
165
166  range.oninput = function () {
167    sweetAlert.resetValidationError();
168    rangeOutput.value = range.value;
169  };
170
171  range.onchange = function () {
172    sweetAlert.resetValidationError();
173    range.previousSibling.value = range.value;
174  };
175
176  select.onchange = function () {
177    sweetAlert.resetValidationError();
178  };
179
180  checkbox.onchange = function () {
181    sweetAlert.resetValidationError();
182  };
183
184  textarea.oninput = function () {
185    sweetAlert.resetValidationError();
186  };
187
188  return modal;
189};
190
191/*
192 * Manipulate DOM
193 */
194
195var sweetHTML = ('\n <div role="dialog" aria-labelledby="' + swalClasses.title + '" aria-describedby="' + swalClasses.content + '" class="' + swalClasses.modal + '" tabindex="-1">\n   <ul class="' + swalClasses.progresssteps + '"></ul>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.error + '">\n     <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n   </div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.question + '">?</div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.warning + '">!</div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.info + '">i</div>\n   <div class="' + swalClasses.icon + ' ' + iconTypes.success + '">\n     <div class="swal2-success-circular-line-left"></div>\n     <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n     <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n     <div class="swal2-success-circular-line-right"></div>\n   </div>\n   <img class="' + swalClasses.image + '" />\n   <h2 class="' + swalClasses.title + '" id="' + swalClasses.title + '"></h2>\n   <div id="' + swalClasses.content + '" class="' + swalClasses.content + '"></div>\n   <input class="' + swalClasses.input + '" />\n   <input type="file" class="' + swalClasses.file + '" />\n   <div class="' + swalClasses.range + '">\n     <output></output>\n     <input type="range" />\n   </div>\n   <select class="' + swalClasses.select + '"></select>\n   <div class="' + swalClasses.radio + '"></div>\n   <label for="' + swalClasses.checkbox + '" class="' + swalClasses.checkbox + '">\n     <input type="checkbox" />\n   </label>\n   <textarea class="' + swalClasses.textarea + '"></textarea>\n   <div class="' + swalClasses.validationerror + '" id="' + swalClasses.validationerror + '"></div>\n   <div class="' + swalClasses.buttonswrapper + '">\n     <button type="button" class="' + swalClasses.confirm + '">OK</button>\n     <button type="button" class="' + swalClasses.cancel + '">Cancel</button>\n   </div>\n   <button type="button" class="' + swalClasses.close + '">\xD7</button>\n </div>\n').replace(/(^|\n)\s*/g, '');
196
197var getContainer = function getContainer() {
198  return document.body.querySelector('.' + swalClasses.container);
199};
200
201var getModal = function getModal() {
202  return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
203};
204
205var getIcons = function getIcons() {
206  var modal = getModal();
207  return modal.querySelectorAll('.' + swalClasses.icon);
208};
209
210var elementByClass = function elementByClass(className) {
211  return getContainer() ? getContainer().querySelector('.' + className) : null;
212};
213
214var getTitle = function getTitle() {
215  return elementByClass(swalClasses.title);
216};
217
218var getContent = function getContent() {
219  return elementByClass(swalClasses.content);
220};
221
222var getImage = function getImage() {
223  return elementByClass(swalClasses.image);
224};
225
226var getButtonsWrapper = function getButtonsWrapper() {
227  return elementByClass(swalClasses.buttonswrapper);
228};
229
230var getProgressSteps = function getProgressSteps() {
231  return elementByClass(swalClasses.progresssteps);
232};
233
234var getValidationError = function getValidationError() {
235  return elementByClass(swalClasses.validationerror);
236};
237
238var getConfirmButton = function getConfirmButton() {
239  return elementByClass(swalClasses.confirm);
240};
241
242var getCancelButton = function getCancelButton() {
243  return elementByClass(swalClasses.cancel);
244};
245
246var getCloseButton = function getCloseButton() {
247  return elementByClass(swalClasses.close);
248};
249
250var getFocusableElements = function getFocusableElements() {
251  var focusableElementsWithTabindex = Array.from(getModal().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'))
252  // sort according to tabindex
253  .sort(function (a, b) {
254    a = parseInt(a.getAttribute('tabindex'));
255    b = parseInt(b.getAttribute('tabindex'));
256    if (a > b) {
257      return 1;
258    } else if (a < b) {
259      return -1;
260    }
261    return 0;
262  });
263
264  var otherFocusableElements = Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, [tabindex="0"]'));
265
266  return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements));
267};
268
269var hasClass = function hasClass(elem, className) {
270  if (elem.classList) {
271    return elem.classList.contains(className);
272  }
273  return false;
274};
275
276var focusInput = function focusInput(input) {
277  input.focus();
278
279  // place cursor at end of text in text input
280  if (input.type !== 'file') {
281    // http://stackoverflow.com/a/2345915/1331425
282    var val = input.value;
283    input.value = '';
284    input.value = val;
285  }
286};
287
288var addClass = function addClass(elem, className) {
289  if (!elem || !className) {
290    return;
291  }
292  var classes = className.split(/\s+/).filter(Boolean);
293  classes.forEach(function (className) {
294    elem.classList.add(className);
295  });
296};
297
298var removeClass = function removeClass(elem, className) {
299  if (!elem || !className) {
300    return;
301  }
302  var classes = className.split(/\s+/).filter(Boolean);
303  classes.forEach(function (className) {
304    elem.classList.remove(className);
305  });
306};
307
308var getChildByClass = function getChildByClass(elem, className) {
309  for (var i = 0; i < elem.childNodes.length; i++) {
310    if (hasClass(elem.childNodes[i], className)) {
311      return elem.childNodes[i];
312    }
313  }
314};
315
316var show = function show(elem, display) {
317  if (!display) {
318    display = 'block';
319  }
320  elem.style.opacity = '';
321  elem.style.display = display;
322};
323
324var hide = function hide(elem) {
325  elem.style.opacity = '';
326  elem.style.display = 'none';
327};
328
329var empty = function empty(elem) {
330  while (elem.firstChild) {
331    elem.removeChild(elem.firstChild);
332  }
333};
334
335// borrowed from jqeury $(elem).is(':visible') implementation
336var isVisible = function isVisible(elem) {
337  return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
338};
339
340var removeStyleProperty = function removeStyleProperty(elem, property) {
341  if (elem.style.removeProperty) {
342    elem.style.removeProperty(property);
343  } else {
344    elem.style.removeAttribute(property);
345  }
346};
347
348var animationEndEvent = function () {
349  var testEl = document.createElement('div');
350  var transEndEventNames = {
351    'WebkitAnimation': 'webkitAnimationEnd',
352    'OAnimation': 'oAnimationEnd oanimationend',
353    'msAnimation': 'MSAnimationEnd',
354    'animation': 'animationend'
355  };
356  for (var i in transEndEventNames) {
357    if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
358      return transEndEventNames[i];
359    }
360  }
361
362  return false;
363}();
364
365// Reset previous window keydown handler and focued element
366var resetPrevState = function resetPrevState() {
367  window.onkeydown = states.previousWindowKeyDown;
368  if (states.previousActiveElement && states.previousActiveElement.focus) {
369    var x = window.scrollX;
370    var y = window.scrollY;
371    states.previousActiveElement.focus();
372    if (x && y) {
373      // IE has no scrollX/scrollY support
374      window.scrollTo(x, y);
375    }
376  }
377};
378
379// Measure width of scrollbar
380// https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
381var measureScrollbar = function measureScrollbar() {
382  var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
383  if (supportsTouch) {
384    return 0;
385  }
386  var scrollDiv = document.createElement('div');
387  scrollDiv.style.width = '50px';
388  scrollDiv.style.height = '50px';
389  scrollDiv.style.overflow = 'scroll';
390  document.body.appendChild(scrollDiv);
391  var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
392  document.body.removeChild(scrollDiv);
393  return scrollbarWidth;
394};
395
396// JavaScript Debounce Function
397// Simplivied version of https://davidwalsh.name/javascript-debounce-function
398var debounce = function debounce(func, wait) {
399  var timeout = void 0;
400  return function () {
401    var later = function later() {
402      timeout = null;
403      func();
404    };
405    clearTimeout(timeout);
406    timeout = setTimeout(later, wait);
407  };
408};
409
410var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
411  return typeof obj;
412} : function (obj) {
413  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
414};
415
416
417
418
419
420var asyncGenerator = function () {
421  function AwaitValue(value) {
422    this.value = value;
423  }
424
425  function AsyncGenerator(gen) {
426    var front, back;
427
428    function send(key, arg) {
429      return new Promise(function (resolve, reject) {
430        var request = {
431          key: key,
432          arg: arg,
433          resolve: resolve,
434          reject: reject,
435          next: null
436        };
437
438        if (back) {
439          back = back.next = request;
440        } else {
441          front = back = request;
442          resume(key, arg);
443        }
444      });
445    }
446
447    function resume(key, arg) {
448      try {
449        var result = gen[key](arg);
450        var value = result.value;
451
452        if (value instanceof AwaitValue) {
453          Promise.resolve(value.value).then(function (arg) {
454            resume("next", arg);
455          }, function (arg) {
456            resume("throw", arg);
457          });
458        } else {
459          settle(result.done ? "return" : "normal", result.value);
460        }
461      } catch (err) {
462        settle("throw", err);
463      }
464    }
465
466    function settle(type, value) {
467      switch (type) {
468        case "return":
469          front.resolve({
470            value: value,
471            done: true
472          });
473          break;
474
475        case "throw":
476          front.reject(value);
477          break;
478
479        default:
480          front.resolve({
481            value: value,
482            done: false
483          });
484          break;
485      }
486
487      front = front.next;
488
489      if (front) {
490        resume(front.key, front.arg);
491      } else {
492        back = null;
493      }
494    }
495
496    this._invoke = send;
497
498    if (typeof gen.return !== "function") {
499      this.return = undefined;
500    }
501  }
502
503  if (typeof Symbol === "function" && Symbol.asyncIterator) {
504    AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
505      return this;
506    };
507  }
508
509  AsyncGenerator.prototype.next = function (arg) {
510    return this._invoke("next", arg);
511  };
512
513  AsyncGenerator.prototype.throw = function (arg) {
514    return this._invoke("throw", arg);
515  };
516
517  AsyncGenerator.prototype.return = function (arg) {
518    return this._invoke("return", arg);
519  };
520
521  return {
522    wrap: function (fn) {
523      return function () {
524        return new AsyncGenerator(fn.apply(this, arguments));
525      };
526    },
527    await: function (value) {
528      return new AwaitValue(value);
529    }
530  };
531}();
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547var _extends = Object.assign || function (target) {
548  for (var i = 1; i < arguments.length; i++) {
549    var source = arguments[i];
550
551    for (var key in source) {
552      if (Object.prototype.hasOwnProperty.call(source, key)) {
553        target[key] = source[key];
554      }
555    }
556  }
557
558  return target;
559};
560
561var modalParams = _extends({}, defaultParams);
562var queue = [];
563var swal2Observer = void 0;
564
565/*
566 * Set type, text and actions on modal
567 */
568var setParameters = function setParameters(params) {
569  // If a custom element is set, determine if it is valid
570  if (typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
571    console.warn('SweetAlert2: Target parameter is not valid, defaulting to "body"');
572    params.target = 'body';
573  }
574
575  var modal = void 0;
576  var oldModal = getModal();
577  var targetElement = typeof params.target === 'string' ? document.querySelector(params.target) : params.target;
578  // If the model target has changed, refresh the modal
579  if (oldModal && targetElement && oldModal.parentNode !== targetElement.parentNode) {
580    modal = init(params);
581  } else {
582    modal = oldModal || init(params);
583  }
584
585  for (var param in params) {
586    if (!sweetAlert.isValidParameter(param)) {
587      console.warn('SweetAlert2: Unknown parameter "' + param + '"');
588    }
589  }
590
591  // Set modal width
592  modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
593
594  modal.style.padding = params.padding + 'px';
595  modal.style.background = params.background;
596  var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
597  for (var i = 0; i < successIconParts.length; i++) {
598    successIconParts[i].style.background = params.background;
599  }
600
601  var title = getTitle();
602  var content = getContent();
603  var buttonsWrapper = getButtonsWrapper();
604  var confirmButton = getConfirmButton();
605  var cancelButton = getCancelButton();
606  var closeButton = getCloseButton();
607
608  // Title
609  if (params.titleText) {
610    title.innerText = params.titleText;
611  } else {
612    title.innerHTML = params.title.split('\n').join('<br />');
613  }
614
615  // Content
616  if (params.text || params.html) {
617    if (_typeof(params.html) === 'object') {
618      content.innerHTML = '';
619      if (0 in params.html) {
620        for (var _i = 0; _i in params.html; _i++) {
621          content.appendChild(params.html[_i].cloneNode(true));
622        }
623      } else {
624        content.appendChild(params.html.cloneNode(true));
625      }
626    } else if (params.html) {
627      content.innerHTML = params.html;
628    } else if (params.text) {
629      content.textContent = params.text;
630    }
631    show(content);
632  } else {
633    hide(content);
634  }
635
636  // Close button
637  if (params.showCloseButton) {
638    closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
639    show(closeButton);
640  } else {
641    hide(closeButton);
642  }
643
644  // Custom Class
645  modal.className = swalClasses.modal;
646  if (params.customClass) {
647    addClass(modal, params.customClass);
648  }
649
650  // Progress steps
651  var progressStepsContainer = getProgressSteps();
652  var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
653  if (params.progressSteps.length) {
654    show(progressStepsContainer);
655    empty(progressStepsContainer);
656    if (currentProgressStep >= params.progressSteps.length) {
657      console.warn('SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
658    }
659    params.progressSteps.forEach(function (step, index) {
660      var circle = document.createElement('li');
661      addClass(circle, swalClasses.progresscircle);
662      circle.innerHTML = step;
663      if (index === currentProgressStep) {
664        addClass(circle, swalClasses.activeprogressstep);
665      }
666      progressStepsContainer.appendChild(circle);
667      if (index !== params.progressSteps.length - 1) {
668        var line = document.createElement('li');
669        addClass(line, swalClasses.progressline);
670        line.style.width = params.progressStepsDistance;
671        progressStepsContainer.appendChild(line);
672      }
673    });
674  } else {
675    hide(progressStepsContainer);
676  }
677
678  // Icon
679  var icons = getIcons();
680  for (var _i2 = 0; _i2 < icons.length; _i2++) {
681    hide(icons[_i2]);
682  }
683  if (params.type) {
684    var validType = false;
685    for (var iconType in iconTypes) {
686      if (params.type === iconType) {
687        validType = true;
688        break;
689      }
690    }
691    if (!validType) {
692      console.error('SweetAlert2: Unknown alert type: ' + params.type);
693      return false;
694    }
695    var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
696    show(icon);
697
698    // Animate icon
699    if (params.animation) {
700      switch (params.type) {
701        case 'success':
702          addClass(icon, 'swal2-animate-success-icon');
703          addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
704          addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
705          break;
706        case 'error':
707          addClass(icon, 'swal2-animate-error-icon');
708          addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
709          break;
710        default:
711          break;
712      }
713    }
714  }
715
716  // Custom image
717  var image = getImage();
718  if (params.imageUrl) {
719    image.setAttribute('src', params.imageUrl);
720    image.setAttribute('alt', params.imageAlt);
721    show(image);
722
723    if (params.imageWidth) {
724      image.setAttribute('width', params.imageWidth);
725    } else {
726      image.removeAttribute('width');
727    }
728
729    if (params.imageHeight) {
730      image.setAttribute('height', params.imageHeight);
731    } else {
732      image.removeAttribute('height');
733    }
734
735    image.className = swalClasses.image;
736    if (params.imageClass) {
737      addClass(image, params.imageClass);
738    }
739  } else {
740    hide(image);
741  }
742
743  // Cancel button
744  if (params.showCancelButton) {
745    cancelButton.style.display = 'inline-block';
746  } else {
747    hide(cancelButton);
748  }
749
750  // Confirm button
751  if (params.showConfirmButton) {
752    removeStyleProperty(confirmButton, 'display');
753  } else {
754    hide(confirmButton);
755  }
756
757  // Buttons wrapper
758  if (!params.showConfirmButton && !params.showCancelButton) {
759    hide(buttonsWrapper);
760  } else {
761    show(buttonsWrapper);
762  }
763
764  // Edit text on confirm and cancel buttons
765  confirmButton.innerHTML = params.confirmButtonText;
766  cancelButton.innerHTML = params.cancelButtonText;
767
768  // ARIA labels for confirm and cancel buttons
769  confirmButton.setAttribute('aria-label', params.confirmButtonAriaLabel);
770  cancelButton.setAttribute('aria-label', params.cancelButtonAriaLabel);
771
772  // Set buttons to selected background colors
773  if (params.buttonsStyling) {
774    confirmButton.style.backgroundColor = params.confirmButtonColor;
775    cancelButton.style.backgroundColor = params.cancelButtonColor;
776  }
777
778  // Add buttons custom classes
779  confirmButton.className = swalClasses.confirm;
780  addClass(confirmButton, params.confirmButtonClass);
781  cancelButton.className = swalClasses.cancel;
782  addClass(cancelButton, params.cancelButtonClass);
783
784  // Buttons styling
785  if (params.buttonsStyling) {
786    addClass(confirmButton, swalClasses.styled);
787    addClass(cancelButton, swalClasses.styled);
788  } else {
789    removeClass(confirmButton, swalClasses.styled);
790    removeClass(cancelButton, swalClasses.styled);
791
792    confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
793    cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
794  }
795
796  // CSS animation
797  if (params.animation === true) {
798    removeClass(modal, swalClasses.noanimation);
799  } else {
800    addClass(modal, swalClasses.noanimation);
801  }
802
803  // showLoaderOnConfirm && preConfirm
804  if (params.showLoaderOnConfirm && !params.preConfirm) {
805    console.warn('SweetAlert2: showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://limonte.github.io/sweetalert2/#ajax-request');
806  }
807};
808
809/*
810 * Animations
811 */
812var openModal = function openModal(animation, onComplete) {
813  var container = getContainer();
814  var modal = getModal();
815
816  if (animation) {
817    addClass(modal, swalClasses.show);
818    addClass(container, swalClasses.fade);
819    removeClass(modal, swalClasses.hide);
820  } else {
821    removeClass(modal, swalClasses.fade);
822  }
823  show(modal);
824
825  // scrolling is 'hidden' until animation is done, after that 'auto'
826  container.style.overflowY = 'hidden';
827  if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
828    modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
829      modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
830      container.style.overflowY = 'auto';
831    });
832  } else {
833    container.style.overflowY = 'auto';
834  }
835
836  addClass(document.documentElement, swalClasses.shown);
837  addClass(document.body, swalClasses.shown);
838  addClass(container, swalClasses.shown);
839  fixScrollbar();
840  iOSfix();
841  states.previousActiveElement = document.activeElement;
842  if (onComplete !== null && typeof onComplete === 'function') {
843    setTimeout(function () {
844      onComplete(modal);
845    });
846  }
847};
848
849var fixScrollbar = function fixScrollbar() {
850  // for queues, do not do this more than once
851  if (states.previousBodyPadding !== null) {
852    return;
853  }
854  // if the body has overflow
855  if (document.body.scrollHeight > window.innerHeight) {
856    // add padding so the content doesn't shift after removal of scrollbar
857    states.previousBodyPadding = document.body.style.paddingRight;
858    document.body.style.paddingRight = measureScrollbar() + 'px';
859  }
860};
861
862var undoScrollbar = function undoScrollbar() {
863  if (states.previousBodyPadding !== null) {
864    document.body.style.paddingRight = states.previousBodyPadding;
865    states.previousBodyPadding = null;
866  }
867};
868
869// Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
870var iOSfix = function iOSfix() {
871  var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
872  if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
873    var offset = document.body.scrollTop;
874    document.body.style.top = offset * -1 + 'px';
875    addClass(document.body, swalClasses.iosfix);
876  }
877};
878
879var undoIOSfix = function undoIOSfix() {
880  if (hasClass(document.body, swalClasses.iosfix)) {
881    var offset = parseInt(document.body.style.top, 10);
882    removeClass(document.body, swalClasses.iosfix);
883    document.body.style.top = '';
884    document.body.scrollTop = offset * -1;
885  }
886};
887
888// SweetAlert entry point
889var sweetAlert = function sweetAlert() {
890  for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
891    args[_key] = arguments[_key];
892  }
893
894  if (args[0] === undefined) {
895    console.error('SweetAlert2 expects at least 1 attribute!');
896    return false;
897  }
898
899  var params = _extends({}, modalParams);
900
901  switch (_typeof(args[0])) {
902    case 'string':
903      params.title = args[0];
904      params.html = args[1];
905      params.type = args[2];
906
907      break;
908
909    case 'object':
910      _extends(params, args[0]);
911      params.extraParams = args[0].extraParams;
912
913      if (params.input === 'email' && params.inputValidator === null) {
914        params.inputValidator = function (email) {
915          return new Promise(function (resolve, reject) {
916            var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
917            if (emailRegex.test(email)) {
918              resolve();
919            } else {
920              reject('Invalid email address');
921            }
922          });
923        };
924      }
925
926      if (params.input === 'url' && params.inputValidator === null) {
927        params.inputValidator = function (url) {
928          return new Promise(function (resolve, reject) {
929            // taken from https://stackoverflow.com/a/3809435/1331425
930            var urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/;
931            if (urlRegex.test(url)) {
932              resolve();
933            } else {
934              reject('Invalid URL');
935            }
936          });
937        };
938      }
939      break;
940
941    default:
942      console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
943      return false;
944  }
945
946  setParameters(params);
947
948  var container = getContainer();
949  var modal = getModal();
950
951  return new Promise(function (resolve, reject) {
952    // Close on timer
953    if (params.timer) {
954      modal.timeout = setTimeout(function () {
955        sweetAlert.closeModal(params.onClose);
956        if (params.useRejections) {
957          reject('timer');
958        } else {
959          resolve({ dismiss: 'timer' });
960        }
961      }, params.timer);
962    }
963
964    // Get input element by specified type or, if type isn't specified, by params.input
965    var getInput = function getInput(inputType) {
966      inputType = inputType || params.input;
967      if (!inputType) {
968        return null;
969      }
970      switch (inputType) {
971        case 'select':
972        case 'textarea':
973        case 'file':
974          return getChildByClass(modal, swalClasses[inputType]);
975        case 'checkbox':
976          return modal.querySelector('.' + swalClasses.checkbox + ' input');
977        case 'radio':
978          return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
979        case 'range':
980          return modal.querySelector('.' + swalClasses.range + ' input');
981        default:
982          return getChildByClass(modal, swalClasses.input);
983      }
984    };
985
986    // Get the value of the modal input
987    var getInputValue = function getInputValue() {
988      var input = getInput();
989      if (!input) {
990        return null;
991      }
992      switch (params.input) {
993        case 'checkbox':
994          return input.checked ? 1 : 0;
995        case 'radio':
996          return input.checked ? input.value : null;
997        case 'file':
998          return input.files.length ? input.files[0] : null;
999        default:
1000          return params.inputAutoTrim ? input.value.trim() : input.value;
1001      }
1002    };
1003
1004    // input autofocus
1005    if (params.input) {
1006      setTimeout(function () {
1007        var input = getInput();
1008        if (input) {
1009          focusInput(input);
1010        }
1011      }, 0);
1012    }
1013
1014    var confirm = function confirm(value) {
1015      if (params.showLoaderOnConfirm) {
1016        sweetAlert.showLoading();
1017      }
1018
1019      if (params.preConfirm) {
1020        params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
1021          sweetAlert.closeModal(params.onClose);
1022          resolve(preConfirmValue || value);
1023        }, function (error) {
1024          sweetAlert.hideLoading();
1025          if (error) {
1026            sweetAlert.showValidationError(error);
1027          }
1028        });
1029      } else {
1030        sweetAlert.closeModal(params.onClose);
1031        if (params.useRejections) {
1032          resolve(value);
1033        } else {
1034          resolve({ value: value });
1035        }
1036      }
1037    };
1038
1039    // Mouse interactions
1040    var onButtonEvent = function onButtonEvent(event) {
1041      var e = event || window.event;
1042      var target = e.target || e.srcElement;
1043      var confirmButton = getConfirmButton();
1044      var cancelButton = getCancelButton();
1045      var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
1046      var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
1047
1048      switch (e.type) {
1049        case 'mouseover':
1050        case 'mouseup':
1051          if (params.buttonsStyling) {
1052            if (targetedConfirm) {
1053              confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
1054            } else if (targetedCancel) {
1055              cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
1056            }
1057          }
1058          break;
1059        case 'mouseout':
1060          if (params.buttonsStyling) {
1061            if (targetedConfirm) {
1062              confirmButton.style.backgroundColor = params.confirmButtonColor;
1063            } else if (targetedCancel) {
1064              cancelButton.style.backgroundColor = params.cancelButtonColor;
1065            }
1066          }
1067          break;
1068        case 'mousedown':
1069          if (params.buttonsStyling) {
1070            if (targetedConfirm) {
1071              confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
1072            } else if (targetedCancel) {
1073              cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
1074            }
1075          }
1076          break;
1077        case 'click':
1078          // Clicked 'confirm'
1079          if (targetedConfirm && sweetAlert.isVisible()) {
1080            sweetAlert.disableButtons();
1081            if (params.input) {
1082              var inputValue = getInputValue();
1083
1084              if (params.inputValidator) {
1085                sweetAlert.disableInput();
1086                params.inputValidator(inputValue, params.extraParams).then(function () {
1087                  sweetAlert.enableButtons();
1088                  sweetAlert.enableInput();
1089                  confirm(inputValue);
1090                }, function (error) {
1091                  sweetAlert.enableButtons();
1092                  sweetAlert.enableInput();
1093                  if (error) {
1094                    sweetAlert.showValidationError(error);
1095                  }
1096                });
1097              } else {
1098                confirm(inputValue);
1099              }
1100            } else {
1101              confirm(true);
1102            }
1103
1104            // Clicked 'cancel'
1105          } else if (targetedCancel && sweetAlert.isVisible()) {
1106            sweetAlert.disableButtons();
1107            sweetAlert.closeModal(params.onClose);
1108            if (params.useRejections) {
1109              reject('cancel');
1110            } else {
1111              resolve({ dismiss: 'cancel' });
1112            }
1113          }
1114          break;
1115        default:
1116      }
1117    };
1118
1119    var buttons = modal.querySelectorAll('button');
1120    for (var i = 0; i < buttons.length; i++) {
1121      buttons[i].onclick = onButtonEvent;
1122      buttons[i].onmouseover = onButtonEvent;
1123      buttons[i].onmouseout = onButtonEvent;
1124      buttons[i].onmousedown = onButtonEvent;
1125    }
1126
1127    // Closing modal by close button
1128    getCloseButton().onclick = function () {
1129      sweetAlert.closeModal(params.onClose);
1130      if (params.useRejections) {
1131        reject('close');
1132      } else {
1133        resolve({ dismiss: 'close' });
1134      }
1135    };
1136
1137    // Closing modal by overlay click
1138    container.onclick = function (e) {
1139      if (e.target !== container) {
1140        return;
1141      }
1142      if (params.allowOutsideClick) {
1143        sweetAlert.closeModal(params.onClose);
1144        if (params.useRejections) {
1145          reject('overlay');
1146        } else {
1147          resolve({ dismiss: 'overlay' });
1148        }
1149      }
1150    };
1151
1152    var buttonsWrapper = getButtonsWrapper();
1153    var confirmButton = getConfirmButton();
1154    var cancelButton = getCancelButton();
1155
1156    // Reverse buttons (Confirm on the right side)
1157    if (params.reverseButtons) {
1158      confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
1159    } else {
1160      confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
1161    }
1162
1163    // Focus handling
1164    var setFocus = function setFocus(index, increment) {
1165      var focusableElements = getFocusableElements(params.focusCancel);
1166      // search for visible elements and select the next possible match
1167      for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
1168        index = index + increment;
1169
1170        // rollover to first item
1171        if (index === focusableElements.length) {
1172          index = 0;
1173
1174          // go to last item
1175        } else if (index === -1) {
1176          index = focusableElements.length - 1;
1177        }
1178
1179        // determine if element is visible
1180        var el = focusableElements[index];
1181        if (isVisible(el)) {
1182          return el.focus();
1183        }
1184      }
1185    };
1186
1187    var handleKeyDown = function handleKeyDown(event) {
1188      var e = event || window.event;
1189      var keyCode = e.keyCode || e.which;
1190
1191      if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
1192        // Don't do work on keys we don't care about.
1193        return;
1194      }
1195
1196      var targetElement = e.target || e.srcElement;
1197
1198      var focusableElements = getFocusableElements(params.focusCancel);
1199      var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
1200      for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
1201        if (targetElement === focusableElements[_i4]) {
1202          btnIndex = _i4;
1203          break;
1204        }
1205      }
1206
1207      // TAB
1208      if (keyCode === 9) {
1209        if (!e.shiftKey) {
1210          // Cycle to the next button
1211          setFocus(btnIndex, 1);
1212        } else {
1213          // Cycle to the prev button
1214          setFocus(btnIndex, -1);
1215        }
1216        e.stopPropagation();
1217        e.preventDefault();
1218
1219        // ARROWS - switch focus between buttons
1220      } else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
1221        // focus Cancel button if Confirm button is currently focused
1222        if (document.activeElement === confirmButton && isVisible(cancelButton)) {
1223          cancelButton.focus();
1224          // and vice versa
1225        } else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
1226          confirmButton.focus();
1227        }
1228
1229        // ESC
1230      } else if (keyCode === 27 && params.allowEscapeKey === true) {
1231        sweetAlert.closeModal(params.onClose);
1232        if (params.useRejections) {
1233          reject('esc');
1234        } else {
1235          resolve({ dismiss: 'esc' });
1236        }
1237      }
1238    };
1239
1240    if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
1241      states.previousWindowKeyDown = window.onkeydown;
1242      window.onkeydown = handleKeyDown;
1243    }
1244
1245    // Loading state
1246    if (params.buttonsStyling) {
1247      confirmButton.style.borderLeftColor = params.confirmButtonColor;
1248      confirmButton.style.borderRightColor = params.confirmButtonColor;
1249    }
1250
1251    /**
1252     * Show spinner instead of Confirm button and disable Cancel button
1253     */
1254    sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
1255      if (!params.showConfirmButton) {
1256        hide(confirmButton);
1257        if (!params.showCancelButton) {
1258          hide(getButtonsWrapper());
1259        }
1260      }
1261      removeClass(buttonsWrapper, swalClasses.loading);
1262      removeClass(modal, swalClasses.loading);
1263      modal.removeAttribute('aria-busy');
1264      confirmButton.disabled = false;
1265      cancelButton.disabled = false;
1266    };
1267
1268    sweetAlert.getTitle = function () {
1269      return getTitle();
1270    };
1271    sweetAlert.getContent = function () {
1272      return getContent();
1273    };
1274    sweetAlert.getInput = function () {
1275      return getInput();
1276    };
1277    sweetAlert.getImage = function () {
1278      return getImage();
1279    };
1280    sweetAlert.getButtonsWrapper = function () {
1281      return getButtonsWrapper();
1282    };
1283    sweetAlert.getConfirmButton = function () {
1284      return getConfirmButton();
1285    };
1286    sweetAlert.getCancelButton = function () {
1287      return getCancelButton();
1288    };
1289
1290    sweetAlert.enableButtons = function () {
1291      confirmButton.disabled = false;
1292      cancelButton.disabled = false;
1293    };
1294
1295    sweetAlert.disableButtons = function () {
1296      confirmButton.disabled = true;
1297      cancelButton.disabled = true;
1298    };
1299
1300    sweetAlert.enableConfirmButton = function () {
1301      confirmButton.disabled = false;
1302    };
1303
1304    sweetAlert.disableConfirmButton = function () {
1305      confirmButton.disabled = true;
1306    };
1307
1308    sweetAlert.enableInput = function () {
1309      var input = getInput();
1310      if (!input) {
1311        return false;
1312      }
1313      if (input.type === 'radio') {
1314        var radiosContainer = input.parentNode.parentNode;
1315        var radios = radiosContainer.querySelectorAll('input');
1316        for (var _i5 = 0; _i5 < radios.length; _i5++) {
1317          radios[_i5].disabled = false;
1318        }
1319      } else {
1320        input.disabled = false;
1321      }
1322    };
1323
1324    sweetAlert.disableInput = function () {
1325      var input = getInput();
1326      if (!input) {
1327        return false;
1328      }
1329      if (input && input.type === 'radio') {
1330        var radiosContainer = input.parentNode.parentNode;
1331        var radios = radiosContainer.querySelectorAll('input');
1332        for (var _i6 = 0; _i6 < radios.length; _i6++) {
1333          radios[_i6].disabled = true;
1334        }
1335      } else {
1336        input.disabled = true;
1337      }
1338    };
1339
1340    // Set modal min-height to disable scrolling inside the modal
1341    sweetAlert.recalculateHeight = debounce(function () {
1342      var modal = getModal();
1343      if (!modal) {
1344        return;
1345      }
1346      var prevState = modal.style.display;
1347      modal.style.minHeight = '';
1348      show(modal);
1349      modal.style.minHeight = modal.scrollHeight + 1 + 'px';
1350      modal.style.display = prevState;
1351    }, 50);
1352
1353    // Show block with validation error
1354    sweetAlert.showValidationError = function (error) {
1355      var validationError = getValidationError();
1356      validationError.innerHTML = error;
1357      show(validationError);
1358
1359      var input = getInput();
1360      if (input) {
1361        input.setAttribute('aria-invalid', true);
1362        input.setAttribute('aria-describedBy', swalClasses.validationerror);
1363        focusInput(input);
1364        addClass(input, swalClasses.inputerror);
1365      }
1366    };
1367
1368    // Hide block with validation error
1369    sweetAlert.resetValidationError = function () {
1370      var validationError = getValidationError();
1371      hide(validationError);
1372      sweetAlert.recalculateHeight();
1373
1374      var input = getInput();
1375      if (input) {
1376        input.removeAttribute('aria-invalid');
1377        input.removeAttribute('aria-describedBy');
1378        removeClass(input, swalClasses.inputerror);
1379      }
1380    };
1381
1382    sweetAlert.getProgressSteps = function () {
1383      return params.progressSteps;
1384    };
1385
1386    sweetAlert.setProgressSteps = function (progressSteps) {
1387      params.progressSteps = progressSteps;
1388      setParameters(params);
1389    };
1390
1391    sweetAlert.showProgressSteps = function () {
1392      show(getProgressSteps());
1393    };
1394
1395    sweetAlert.hideProgressSteps = function () {
1396      hide(getProgressSteps());
1397    };
1398
1399    sweetAlert.enableButtons();
1400    sweetAlert.hideLoading();
1401    sweetAlert.resetValidationError();
1402
1403    // inputs
1404    var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
1405    var input = void 0;
1406    for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
1407      var inputClass = swalClasses[inputTypes[_i7]];
1408      var inputContainer = getChildByClass(modal, inputClass);
1409      input = getInput(inputTypes[_i7]);
1410
1411      // set attributes
1412      if (input) {
1413        for (var j in input.attributes) {
1414          if (input.attributes.hasOwnProperty(j)) {
1415            var attrName = input.attributes[j].name;
1416            if (attrName !== 'type' && attrName !== 'value') {
1417              input.removeAttribute(attrName);
1418            }
1419          }
1420        }
1421        for (var attr in params.inputAttributes) {
1422          input.setAttribute(attr, params.inputAttributes[attr]);
1423        }
1424      }
1425
1426      // set class
1427      inputContainer.className = inputClass;
1428      if (params.inputClass) {
1429        addClass(inputContainer, params.inputClass);
1430      }
1431
1432      hide(inputContainer);
1433    }
1434
1435    var populateInputOptions = void 0;
1436    switch (params.input) {
1437      case 'text':
1438      case 'email':
1439      case 'password':
1440      case 'number':
1441      case 'tel':
1442      case 'url':
1443        input = getChildByClass(modal, swalClasses.input);
1444        input.value = params.inputValue;
1445        input.placeholder = params.inputPlaceholder;
1446        input.type = params.input;
1447        show(input);
1448        break;
1449      case 'file':
1450        input = getChildByClass(modal, swalClasses.file);
1451        input.placeholder = params.inputPlaceholder;
1452        input.type = params.input;
1453        show(input);
1454        break;
1455      case 'range':
1456        var range = getChildByClass(modal, swalClasses.range);
1457        var rangeInput = range.querySelector('input');
1458        var rangeOutput = range.querySelector('output');
1459        rangeInput.value = params.inputValue;
1460        rangeInput.type = params.input;
1461        rangeOutput.value = params.inputValue;
1462        show(range);
1463        break;
1464      case 'select':
1465        var select = getChildByClass(modal, swalClasses.select);
1466        select.innerHTML = '';
1467        if (params.inputPlaceholder) {
1468          var placeholder = document.createElement('option');
1469          placeholder.innerHTML = params.inputPlaceholder;
1470          placeholder.value = '';
1471          placeholder.disabled = true;
1472          placeholder.selected = true;
1473          select.appendChild(placeholder);
1474        }
1475        populateInputOptions = function populateInputOptions(inputOptions) {
1476          for (var optionValue in inputOptions) {
1477            var option = document.createElement('option');
1478            option.value = optionValue;
1479            option.innerHTML = inputOptions[optionValue];
1480            if (params.inputValue === optionValue) {
1481              option.selected = true;
1482            }
1483            select.appendChild(option);
1484          }
1485          show(select);
1486          select.focus();
1487        };
1488        break;
1489      case 'radio':
1490        var radio = getChildByClass(modal, swalClasses.radio);
1491        radio.innerHTML = '';
1492        populateInputOptions = function populateInputOptions(inputOptions) {
1493          for (var radioValue in inputOptions) {
1494            var radioInput = document.createElement('input');
1495            var radioLabel = document.createElement('label');
1496            var radioLabelSpan = document.createElement('span');
1497            radioInput.type = 'radio';
1498            radioInput.name = swalClasses.radio;
1499            radioInput.value = radioValue;
1500            if (params.inputValue === radioValue) {
1501              radioInput.checked = true;
1502            }
1503            radioLabelSpan.innerHTML = inputOptions[radioValue];
1504            radioLabel.appendChild(radioInput);
1505            radioLabel.appendChild(radioLabelSpan);
1506            radioLabel.for = radioInput.id;
1507            radio.appendChild(radioLabel);
1508          }
1509          show(radio);
1510          var radios = radio.querySelectorAll('input');
1511          if (radios.length) {
1512            radios[0].focus();
1513          }
1514        };
1515        break;
1516      case 'checkbox':
1517        var checkbox = getChildByClass(modal, swalClasses.checkbox);
1518        var checkboxInput = getInput('checkbox');
1519        checkboxInput.type = 'checkbox';
1520        checkboxInput.value = 1;
1521        checkboxInput.id = swalClasses.checkbox;
1522        checkboxInput.checked = Boolean(params.inputValue);
1523        var label = checkbox.getElementsByTagName('span');
1524        if (label.length) {
1525          checkbox.removeChild(label[0]);
1526        }
1527        label = document.createElement('span');
1528        label.innerHTML = params.inputPlaceholder;
1529        checkbox.appendChild(label);
1530        show(checkbox);
1531        break;
1532      case 'textarea':
1533        var textarea = getChildByClass(modal, swalClasses.textarea);
1534        textarea.value = params.inputValue;
1535        textarea.placeholder = params.inputPlaceholder;
1536        show(textarea);
1537        break;
1538      case null:
1539        break;
1540      default:
1541        console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
1542        break;
1543    }
1544
1545    if (params.input === 'select' || params.input === 'radio') {
1546      if (params.inputOptions instanceof Promise) {
1547        sweetAlert.showLoading();
1548        params.inputOptions.then(function (inputOptions) {
1549          sweetAlert.hideLoading();
1550          populateInputOptions(inputOptions);
1551        });
1552      } else if (_typeof(params.inputOptions) === 'object') {
1553        populateInputOptions(params.inputOptions);
1554      } else {
1555        console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
1556      }
1557    }
1558
1559    openModal(params.animation, params.onOpen);
1560
1561    if (!params.allowEnterKey) {
1562      if (document.activeElement) {
1563        document.activeElement.blur();
1564      }
1565    } else if (params.focusCancel && isVisible(cancelButton)) {
1566      cancelButton.focus();
1567    } else if (params.focusConfirm && isVisible(confirmButton)) {
1568      confirmButton.focus();
1569    } else {
1570      setFocus(-1, 1);
1571    }
1572
1573    // fix scroll
1574    getContainer().scrollTop = 0;
1575
1576    // Observe changes inside the modal and adjust height
1577    if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
1578      swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
1579      swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
1580    }
1581  });
1582};
1583
1584/*
1585 * Global function to determine if swal2 modal is shown
1586 */
1587sweetAlert.isVisible = function () {
1588  return !!getModal();
1589};
1590
1591/*
1592 * Global function for chaining sweetAlert modals
1593 */
1594sweetAlert.queue = function (steps) {
1595  queue = steps;
1596  var resetQueue = function resetQueue() {
1597    queue = [];
1598    document.body.removeAttribute('data-swal2-queue-step');
1599  };
1600  var queueResult = [];
1601  return new Promise(function (resolve, reject) {
1602    (function step(i, callback) {
1603      if (i < queue.length) {
1604        document.body.setAttribute('data-swal2-queue-step', i);
1605
1606        sweetAlert(queue[i]).then(function (result) {
1607          queueResult.push(result);
1608          step(i + 1, callback);
1609        }, function (dismiss) {
1610          resetQueue();
1611          reject(dismiss);
1612        });
1613      } else {
1614        resetQueue();
1615        resolve(queueResult);
1616      }
1617    })(0);
1618  });
1619};
1620
1621/*
1622 * Global function for getting the index of current modal in queue
1623 */
1624sweetAlert.getQueueStep = function () {
1625  return document.body.getAttribute('data-swal2-queue-step');
1626};
1627
1628/*
1629 * Global function for inserting a modal to the queue
1630 */
1631sweetAlert.insertQueueStep = function (step, index) {
1632  if (index && index < queue.length) {
1633    return queue.splice(index, 0, step);
1634  }
1635  return queue.push(step);
1636};
1637
1638/*
1639 * Global function for deleting a modal from the queue
1640 */
1641sweetAlert.deleteQueueStep = function (index) {
1642  if (typeof queue[index] !== 'undefined') {
1643    queue.splice(index, 1);
1644  }
1645};
1646
1647/*
1648 * Global function to close sweetAlert
1649 */
1650sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
1651  var container = getContainer();
1652  var modal = getModal();
1653  if (!modal) {
1654    return;
1655  }
1656  removeClass(modal, swalClasses.show);
1657  addClass(modal, swalClasses.hide);
1658  clearTimeout(modal.timeout);
1659
1660  resetPrevState();
1661
1662  var removeModalAndResetState = function removeModalAndResetState() {
1663    if (container.parentNode) {
1664      container.parentNode.removeChild(container);
1665    }
1666    removeClass(document.documentElement, swalClasses.shown);
1667    removeClass(document.body, swalClasses.shown);
1668    undoScrollbar();
1669    undoIOSfix();
1670  };
1671
1672  // If animation is supported, animate
1673  if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
1674    modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
1675      modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
1676      if (hasClass(modal, swalClasses.hide)) {
1677        removeModalAndResetState();
1678      }
1679    });
1680  } else {
1681    // Otherwise, remove immediately
1682    removeModalAndResetState();
1683  }
1684  if (onComplete !== null && typeof onComplete === 'function') {
1685    setTimeout(function () {
1686      onComplete(modal);
1687    });
1688  }
1689};
1690
1691/*
1692 * Global function to click 'Confirm' button
1693 */
1694sweetAlert.clickConfirm = function () {
1695  return getConfirmButton().click();
1696};
1697
1698/*
1699 * Global function to click 'Cancel' button
1700 */
1701sweetAlert.clickCancel = function () {
1702  return getCancelButton().click();
1703};
1704
1705/**
1706 * Show spinner instead of Confirm button and disable Cancel button
1707 */
1708sweetAlert.showLoading = sweetAlert.enableLoading = function () {
1709  var modal = getModal();
1710  if (!modal) {
1711    sweetAlert('');
1712  }
1713  modal = getModal();
1714  var buttonsWrapper = getButtonsWrapper();
1715  var confirmButton = getConfirmButton();
1716  var cancelButton = getCancelButton();
1717
1718  show(buttonsWrapper);
1719  show(confirmButton, 'inline-block');
1720  addClass(buttonsWrapper, swalClasses.loading);
1721  addClass(modal, swalClasses.loading);
1722  confirmButton.disabled = true;
1723  cancelButton.disabled = true;
1724
1725  modal.setAttribute('aria-busy', true);
1726  modal.focus();
1727};
1728
1729/**
1730 * Is valid parameter
1731 * @param {String} paramName
1732 */
1733sweetAlert.isValidParameter = function (paramName) {
1734  return defaultParams.hasOwnProperty(paramName) || paramName === 'extraParams';
1735};
1736
1737/**
1738* Set default params for each popup
1739* @param {Object} userParams
1740*/
1741sweetAlert.setDefaults = function (userParams) {
1742  if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
1743    return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object');
1744  }
1745
1746  for (var param in userParams) {
1747    if (!sweetAlert.isValidParameter(param)) {
1748      console.warn('SweetAlert2: Unknown parameter "' + param + '"');
1749      delete userParams[param];
1750    }
1751  }
1752
1753  _extends(modalParams, userParams);
1754};
1755
1756/**
1757 * Reset default params for each popup
1758 */
1759sweetAlert.resetDefaults = function () {
1760  modalParams = _extends({}, defaultParams);
1761};
1762
1763sweetAlert.noop = function () {};
1764
1765sweetAlert.version = '6.9.0';
1766
1767sweetAlert.default = sweetAlert;
1768
1769return sweetAlert;
1770
1771})));
1772if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.