!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Sweetalert2=t()}(this,function(){"use strict";function e(){if(void 0===arguments[0])return console.error("sweetAlert2 expects at least 1 attribute!"),!1;var e=c({},N);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":c(e,arguments[0]),e.extraParams=arguments[0].extraParams,"email"===e.input&&null===e.inputValidator&&(e.inputValidator=function(e){return new Promise(function(t,n){var o=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;o.test(e)?t():n("Invalid email address")})});break;default:return console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}V(e);var o=f();return new Promise(function(r,a){function l(e,t){for(var n=0;n0;)N.removeAttribute(N.attributes[0].name);for(var j in e.inputAttributes)N.setAttribute(j,e.inputAttributes[j]);N.className=I,e.inputClass&&g(N,e.inputClass),E(N)}var K;switch(e.input){case"text":case"email":case"password":case"file":N=C(o,i.input),N.value=e.inputValue,N.placeholder=e.inputPlaceholder,N.type=e.input,k(N);break;case"select":var W=C(o,i.select);if(W.innerHTML="",e.inputPlaceholder){var U=document.createElement("option");U.innerHTML=e.inputPlaceholder,U.value="",U.disabled=!0,U.selected=!0,W.appendChild(U)}K=function(t){for(var n in t){var o=document.createElement("option");o.value=n,o.innerHTML=t[n],e.inputValue===n&&(o.selected=!0),W.appendChild(o)}k(W),W.focus()};break;case"radio":var z=C(o,i.radio);z.innerHTML="",K=function(t){for(var n in t){var o=1,r=document.createElement("input"),a=document.createElement("label"),l=document.createElement("span");r.type="radio",r.name=i.radio,r.value=n,r.id=i.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),l.innerHTML=t[n],a.appendChild(r),a.appendChild(l),a["for"]=r.id,z.appendChild(a)}k(z);var c=z.querySelectorAll("input");c.length&&c[0].focus()};break;case"checkbox":var R=C(o,i.checkbox),Z=o.querySelector("#"+i.checkbox);Z.value=1,Z.checked=Boolean(e.inputValue);var $=R.getElementsByTagName("span");$.length&&R.removeChild($[0]),$=document.createElement("span"),$.innerHTML=e.inputPlaceholder,R.appendChild($),k(R);break;case"textarea":var _=C(o,i.textarea);_.value=e.inputValue,_.placeholder=e.inputPlaceholder,k(_);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got '+typeof arguments[0])}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(t.showLoading(),e.inputOptions.then(function(e){t.hideLoading(),K(e)})):"object"==typeof e.inputOptions?K(e.inputOptions):console.error("Unexpected type of inputOptions! Expected object or Promise, got "+e.inputOptions)),D(),H(e.animation,e.onOpen),l(-1,1)})}function t(){var n=arguments,o=f();return null===o&&(t.init(),o=f()),h(o,"visible")&&O(),e.apply(this,n)}var n="swal2-",o=function(e){var t={};for(var o in e)t[e[o]]=n+e[o];return t},i=o(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]),r=o(["success","warning","info","question","error"]),a={title:"",text:"",html:"",type:null,animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,preConfirm:null,confirmButtonText:"OK",confirmButtonColor:"#3085d6",confirmButtonClass:null,cancelButtonText:"Cancel",cancelButtonColor:"#aaa",cancelButtonClass:null,buttonsStyling:!0,reverseButtons:!1,showCloseButton:!1,showLoaderOnConfirm:!1,imageUrl:null,imageWidth:null,imageHeight:null,imageClass:null,timer:null,width:500,padding:20,background:"#fff",input:null,inputPlaceholder:"",inputValue:"",inputOptions:{},inputAutoTrim:!0,inputClass:null,inputAttributes:{},inputValidator:null,onOpen:null,onClose:null},l='
',c=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},s=function(e,t){e=String(e).replace(/[^0-9a-f]/gi,""),e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;for(var n="#",o=0;3>o;o++){var i=parseInt(e.substr(2*o,2),16);i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),n+=("00"+i).substr(i.length)}return n},u=n+"mediaquery",d={previousDocumentClick:null,previousWindowKeyDown:null,previousActiveElement:null},p=function(e){return document.querySelector("."+e)},f=function(){return p(i.modal)},m=function(){return p(i.overlay)},v=function(){return p(i.confirm)},y=function(){return p(i.cancel)},h=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},b=function(e){e.focus();var t=e.value;e.value="",e.value=t},g=function(e,t){t&&!h(e,t)&&(e.className+=" "+t)},w=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(h(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},C=function(e,t){for(var n=0;n1?1:i,n=+new Date,+e.style.opacity<1&&setTimeout(o,t)};o()}},A=function(e,t){if(+e.style.opacity>0){t=t||16;var n=e.style.opacity,o=+new Date,i=function(){var r=new Date-o,a=+e.style.opacity-r/(100*n);e.style.opacity=a,o=+new Date,+e.style.opacity>0?setTimeout(i,t):E(e)};i()}},M=function(e){if("function"==typeof MouseEvent){var t=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0});e.dispatchEvent(t)}else if(document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),e.dispatchEvent(n)}else document.createEventObject?e.fireEvent("onclick"):"function"==typeof e.onclick&&e.onclick()},T=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},P=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return t[n];return!1}(),O=function(){var e=f();window.onkeydown=d.previousWindowKeyDown,document.onclick=d.previousDocumentClick,d.previousActiveElement&&d.previousActiveElement.focus(),clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(u);n&&t.removeChild(n)},N=c({},a),V=function(e){var t,n=f();n.style.width=e.width+"px",n.style.padding=e.padding+"px",n.style.marginLeft=-e.width/2+"px",n.style.background=e.background;var o=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=u;var l=5,c=e.width+parseInt(e.width*(l/100)*2,10);a.innerHTML="@media screen and (max-width: "+c+"px) {."+i.modal+" {width: auto !important;left: "+l+"% !important;right: "+l+"% !important;margin-left: 0 !important;}}",o.appendChild(a);var s=n.querySelector("h2"),d=n.querySelector("."+i.content),p=v(),m=y(),h=n.querySelector("."+i.spacer),b=n.querySelector("."+i.close);if(s.innerHTML=e.title.split("\n").join("
"),e.text||e.html){if("object"==typeof e.html)if(d.innerHTML="",0 in e.html)for(t=0;t in e.html;t++)d.appendChild(e.html[t]);else d.appendChild(e.html);else d.innerHTML=e.html||e.text.split("\n").join("
");x(d)}else S(d);if(e.showCloseButton?x(b):S(b),n.className=i.modal,e.customClass&&g(n,e.customClass),S(n.querySelectorAll("."+i.icon)),e.type){var C=!1;for(var k in r)if(e.type===k){C=!0;break}if(!C)return console.error("Unknown alert type: "+e.type),!1;var E=n.querySelector("."+i.icon+"."+r[e.type]);switch(x(E),e.type){case"success":g(E,"animate"),g(E.querySelector(".tip"),"animate-success-tip"),g(E.querySelector(".long"),"animate-success-long");break;case"error":g(E,"animate-error-icon"),g(E.querySelector(".x-mark"),"animate-x-mark");break;case"warning":g(E,"pulse-warning")}}var L=n.querySelector("."+i.image);e.imageUrl?(L.setAttribute("src",e.imageUrl),x(L),e.imageWidth&&L.setAttribute("width",e.imageWidth),e.imageHeight&&L.setAttribute("height",e.imageHeight),e.imageClass&&g(L,e.imageClass)):S(L),e.showCancelButton?m.style.display="inline-block":S(m),e.showConfirmButton?B(p,"display"):S(p),e.showConfirmButton||e.showCancelButton?x(h):S(h),p.innerHTML=e.confirmButtonText,m.innerHTML=e.cancelButtonText,e.buttonsStyling&&(p.style.backgroundColor=e.confirmButtonColor,m.style.backgroundColor=e.cancelButtonColor),p.className=i.confirm,g(p,e.confirmButtonClass),m.className=i.cancel,g(m,e.cancelButtonClass),e.buttonsStyling?(g(p,"styled"),g(m,"styled")):(w(p,"styled"),w(m,"styled"),p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor="",m.style.backgroundColor=m.style.borderLeftColor=m.style.borderRightColor=""),e.animation===!0?w(n,"no-animation"):g(n,"no-animation")},H=function(e,t){var n=f();e?(q(m(),10),g(n,"show-swal2"),w(n,"hide-swal2")):x(m()),x(n),d.previousActiveElement=document.activeElement,g(n,"visible"),null!==t&&"function"==typeof t&&t.call(this,n)},D=function(){var e=f();e.style.marginTop=L(e)};return t.queue=function(e){return new Promise(function(n,o){!function i(r,a){r