sweetalert2.all.js 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123
  1. /*!
  2. * sweetalert2 v11.1.5
  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 = global || self, global.Sweetalert2 = factory());
  9. }(this, function () { 'use strict';
  10. const DismissReason = Object.freeze({
  11. cancel: 'cancel',
  12. backdrop: 'backdrop',
  13. close: 'close',
  14. esc: 'esc',
  15. timer: 'timer'
  16. });
  17. const consolePrefix = 'SweetAlert2:';
  18. /**
  19. * Filter the unique values into a new array
  20. * @param arr
  21. */
  22. const uniqueArray = arr => {
  23. const result = [];
  24. for (let i = 0; i < arr.length; i++) {
  25. if (result.indexOf(arr[i]) === -1) {
  26. result.push(arr[i]);
  27. }
  28. }
  29. return result;
  30. };
  31. /**
  32. * Capitalize the first letter of a string
  33. * @param str
  34. */
  35. const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
  36. /**
  37. * Convert NodeList to Array
  38. * @param nodeList
  39. */
  40. const toArray = nodeList => Array.prototype.slice.call(nodeList);
  41. /**
  42. * Standardise console warnings
  43. * @param message
  44. */
  45. const warn = message => {
  46. console.warn("".concat(consolePrefix, " ").concat(typeof message === 'object' ? message.join(' ') : message));
  47. };
  48. /**
  49. * Standardise console errors
  50. * @param message
  51. */
  52. const error = message => {
  53. console.error("".concat(consolePrefix, " ").concat(message));
  54. };
  55. /**
  56. * Private global state for `warnOnce`
  57. * @type {Array}
  58. * @private
  59. */
  60. const previousWarnOnceMessages = [];
  61. /**
  62. * Show a console warning, but only if it hasn't already been shown
  63. * @param message
  64. */
  65. const warnOnce = message => {
  66. if (!previousWarnOnceMessages.includes(message)) {
  67. previousWarnOnceMessages.push(message);
  68. warn(message);
  69. }
  70. };
  71. /**
  72. * Show a one-time console warning about deprecated params/methods
  73. */
  74. const warnAboutDeprecation = (deprecatedParam, useInstead) => {
  75. warnOnce("\"".concat(deprecatedParam, "\" is deprecated and will be removed in the next major release. Please use \"").concat(useInstead, "\" instead."));
  76. };
  77. /**
  78. * If `arg` is a function, call it (with no arguments or context) and return the result.
  79. * Otherwise, just pass the value through
  80. * @param arg
  81. */
  82. const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
  83. const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
  84. const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
  85. const isPromise = arg => arg && Promise.resolve(arg) === arg;
  86. const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
  87. const isElement = elem => elem instanceof Element || isJqueryElement(elem);
  88. const argsToParams = args => {
  89. const params = {};
  90. if (typeof args[0] === 'object' && !isElement(args[0])) {
  91. Object.assign(params, args[0]);
  92. } else {
  93. ['title', 'html', 'icon'].forEach((name, index) => {
  94. const arg = args[index];
  95. if (typeof arg === 'string' || isElement(arg)) {
  96. params[name] = arg;
  97. } else if (arg !== undefined) {
  98. error("Unexpected type of ".concat(name, "! Expected \"string\" or \"Element\", got ").concat(typeof arg));
  99. }
  100. });
  101. }
  102. return params;
  103. };
  104. const swalPrefix = 'swal2-';
  105. const prefix = items => {
  106. const result = {};
  107. for (const i in items) {
  108. result[items[i]] = swalPrefix + items[i];
  109. }
  110. return result;
  111. };
  112. const swalClasses = prefix(['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'default-outline', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error']);
  113. const iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
  114. const getContainer = () => document.body.querySelector(".".concat(swalClasses.container));
  115. const elementBySelector = selectorString => {
  116. const container = getContainer();
  117. return container ? container.querySelector(selectorString) : null;
  118. };
  119. const elementByClass = className => {
  120. return elementBySelector(".".concat(className));
  121. };
  122. const getPopup = () => elementByClass(swalClasses.popup);
  123. const getIcon = () => elementByClass(swalClasses.icon);
  124. const getTitle = () => elementByClass(swalClasses.title);
  125. const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
  126. const getImage = () => elementByClass(swalClasses.image);
  127. const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
  128. const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
  129. const getConfirmButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.confirm));
  130. const getDenyButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.deny));
  131. const getInputLabel = () => elementByClass(swalClasses['input-label']);
  132. const getLoader = () => elementBySelector(".".concat(swalClasses.loader));
  133. const getCancelButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.cancel));
  134. const getActions = () => elementByClass(swalClasses.actions);
  135. const getFooter = () => elementByClass(swalClasses.footer);
  136. const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
  137. const getCloseButton = () => elementByClass(swalClasses.close); // https://github.com/jkup/focusable/blob/master/index.js
  138. const focusable = "\n a[href],\n area[href],\n input:not([disabled]),\n select:not([disabled]),\n textarea:not([disabled]),\n button:not([disabled]),\n iframe,\n object,\n embed,\n [tabindex=\"0\"],\n [contenteditable],\n audio[controls],\n video[controls],\n summary\n";
  139. const getFocusableElements = () => {
  140. const focusableElementsWithTabindex = toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')) // sort according to tabindex
  141. .sort((a, b) => {
  142. a = parseInt(a.getAttribute('tabindex'));
  143. b = parseInt(b.getAttribute('tabindex'));
  144. if (a > b) {
  145. return 1;
  146. } else if (a < b) {
  147. return -1;
  148. }
  149. return 0;
  150. });
  151. const otherFocusableElements = toArray(getPopup().querySelectorAll(focusable)).filter(el => el.getAttribute('tabindex') !== '-1');
  152. return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter(el => isVisible(el));
  153. };
  154. const isModal = () => {
  155. return !isToast() && !document.body.classList.contains(swalClasses['no-backdrop']);
  156. };
  157. const isToast = () => {
  158. return document.body.classList.contains(swalClasses['toast-shown']);
  159. };
  160. const isLoading = () => {
  161. return getPopup().hasAttribute('data-loading');
  162. };
  163. const states = {
  164. previousBodyPadding: null
  165. };
  166. const setInnerHtml = (elem, html) => {
  167. // #1926
  168. elem.textContent = '';
  169. if (html) {
  170. const parser = new DOMParser();
  171. const parsed = parser.parseFromString(html, "text/html");
  172. toArray(parsed.querySelector('head').childNodes).forEach(child => {
  173. elem.appendChild(child);
  174. });
  175. toArray(parsed.querySelector('body').childNodes).forEach(child => {
  176. elem.appendChild(child);
  177. });
  178. }
  179. };
  180. const hasClass = (elem, className) => {
  181. if (!className) {
  182. return false;
  183. }
  184. const classList = className.split(/\s+/);
  185. for (let i = 0; i < classList.length; i++) {
  186. if (!elem.classList.contains(classList[i])) {
  187. return false;
  188. }
  189. }
  190. return true;
  191. };
  192. const removeCustomClasses = (elem, params) => {
  193. toArray(elem.classList).forEach(className => {
  194. if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass).includes(className)) {
  195. elem.classList.remove(className);
  196. }
  197. });
  198. };
  199. const applyCustomClass = (elem, params, className) => {
  200. removeCustomClasses(elem, params);
  201. if (params.customClass && params.customClass[className]) {
  202. if (typeof params.customClass[className] !== 'string' && !params.customClass[className].forEach) {
  203. return warn("Invalid type of customClass.".concat(className, "! Expected string or iterable object, got \"").concat(typeof params.customClass[className], "\""));
  204. }
  205. addClass(elem, params.customClass[className]);
  206. }
  207. };
  208. const getInput = (popup, inputType) => {
  209. if (!inputType) {
  210. return null;
  211. }
  212. switch (inputType) {
  213. case 'select':
  214. case 'textarea':
  215. case 'file':
  216. return getChildByClass(popup, swalClasses[inputType]);
  217. case 'checkbox':
  218. return popup.querySelector(".".concat(swalClasses.checkbox, " input"));
  219. case 'radio':
  220. return popup.querySelector(".".concat(swalClasses.radio, " input:checked")) || popup.querySelector(".".concat(swalClasses.radio, " input:first-child"));
  221. case 'range':
  222. return popup.querySelector(".".concat(swalClasses.range, " input"));
  223. default:
  224. return getChildByClass(popup, swalClasses.input);
  225. }
  226. };
  227. const focusInput = input => {
  228. input.focus(); // place cursor at end of text in text input
  229. if (input.type !== 'file') {
  230. // http://stackoverflow.com/a/2345915
  231. const val = input.value;
  232. input.value = '';
  233. input.value = val;
  234. }
  235. };
  236. const toggleClass = (target, classList, condition) => {
  237. if (!target || !classList) {
  238. return;
  239. }
  240. if (typeof classList === 'string') {
  241. classList = classList.split(/\s+/).filter(Boolean);
  242. }
  243. classList.forEach(className => {
  244. if (target.forEach) {
  245. target.forEach(elem => {
  246. condition ? elem.classList.add(className) : elem.classList.remove(className);
  247. });
  248. } else {
  249. condition ? target.classList.add(className) : target.classList.remove(className);
  250. }
  251. });
  252. };
  253. const addClass = (target, classList) => {
  254. toggleClass(target, classList, true);
  255. };
  256. const removeClass = (target, classList) => {
  257. toggleClass(target, classList, false);
  258. };
  259. const getChildByClass = (elem, className) => {
  260. for (let i = 0; i < elem.childNodes.length; i++) {
  261. if (hasClass(elem.childNodes[i], className)) {
  262. return elem.childNodes[i];
  263. }
  264. }
  265. };
  266. const applyNumericalStyle = (elem, property, value) => {
  267. if (value === "".concat(parseInt(value))) {
  268. value = parseInt(value);
  269. }
  270. if (value || parseInt(value) === 0) {
  271. elem.style[property] = typeof value === 'number' ? "".concat(value, "px") : value;
  272. } else {
  273. elem.style.removeProperty(property);
  274. }
  275. };
  276. const show = (elem, display = 'flex') => {
  277. elem.style.display = display;
  278. };
  279. const hide = elem => {
  280. elem.style.display = 'none';
  281. };
  282. const setStyle = (parent, selector, property, value) => {
  283. const el = parent.querySelector(selector);
  284. if (el) {
  285. el.style[property] = value;
  286. }
  287. };
  288. const toggle = (elem, condition, display) => {
  289. condition ? show(elem, display) : hide(elem);
  290. }; // borrowed from jquery $(elem).is(':visible') implementation
  291. const isVisible = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
  292. const allButtonsAreHidden = () => !isVisible(getConfirmButton()) && !isVisible(getDenyButton()) && !isVisible(getCancelButton());
  293. const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight); // borrowed from https://stackoverflow.com/a/46352119
  294. const hasCssAnimation = elem => {
  295. const style = window.getComputedStyle(elem);
  296. const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
  297. const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
  298. return animDuration > 0 || transDuration > 0;
  299. };
  300. const animateTimerProgressBar = (timer, reset = false) => {
  301. const timerProgressBar = getTimerProgressBar();
  302. if (isVisible(timerProgressBar)) {
  303. if (reset) {
  304. timerProgressBar.style.transition = 'none';
  305. timerProgressBar.style.width = '100%';
  306. }
  307. setTimeout(() => {
  308. timerProgressBar.style.transition = "width ".concat(timer / 1000, "s linear");
  309. timerProgressBar.style.width = '0%';
  310. }, 10);
  311. }
  312. };
  313. const stopTimerProgressBar = () => {
  314. const timerProgressBar = getTimerProgressBar();
  315. const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
  316. timerProgressBar.style.removeProperty('transition');
  317. timerProgressBar.style.width = '100%';
  318. const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
  319. const timerProgressBarPercent = parseInt(timerProgressBarWidth / timerProgressBarFullWidth * 100);
  320. timerProgressBar.style.removeProperty('transition');
  321. timerProgressBar.style.width = "".concat(timerProgressBarPercent, "%");
  322. };
  323. // Detect Node env
  324. const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
  325. const sweetHTML = "\n <div aria-labelledby=\"".concat(swalClasses.title, "\" aria-describedby=\"").concat(swalClasses['html-container'], "\" class=\"").concat(swalClasses.popup, "\" tabindex=\"-1\">\n <button type=\"button\" class=\"").concat(swalClasses.close, "\"></button>\n <ul class=\"").concat(swalClasses['progress-steps'], "\"></ul>\n <div class=\"").concat(swalClasses.icon, "\"></div>\n <img class=\"").concat(swalClasses.image, "\" />\n <h2 class=\"").concat(swalClasses.title, "\" id=\"").concat(swalClasses.title, "\"></h2>\n <div class=\"").concat(swalClasses['html-container'], "\" id=\"").concat(swalClasses['html-container'], "\"></div>\n <input class=\"").concat(swalClasses.input, "\" />\n <input type=\"file\" class=\"").concat(swalClasses.file, "\" />\n <div class=\"").concat(swalClasses.range, "\">\n <input type=\"range\" />\n <output></output>\n </div>\n <select class=\"").concat(swalClasses.select, "\"></select>\n <div class=\"").concat(swalClasses.radio, "\"></div>\n <label for=\"").concat(swalClasses.checkbox, "\" class=\"").concat(swalClasses.checkbox, "\">\n <input type=\"checkbox\" />\n <span class=\"").concat(swalClasses.label, "\"></span>\n </label>\n <textarea class=\"").concat(swalClasses.textarea, "\"></textarea>\n <div class=\"").concat(swalClasses['validation-message'], "\" id=\"").concat(swalClasses['validation-message'], "\"></div>\n <div class=\"").concat(swalClasses.actions, "\">\n <div class=\"").concat(swalClasses.loader, "\"></div>\n <button type=\"button\" class=\"").concat(swalClasses.confirm, "\"></button>\n <button type=\"button\" class=\"").concat(swalClasses.deny, "\"></button>\n <button type=\"button\" class=\"").concat(swalClasses.cancel, "\"></button>\n </div>\n <div class=\"").concat(swalClasses.footer, "\"></div>\n <div class=\"").concat(swalClasses['timer-progress-bar-container'], "\">\n <div class=\"").concat(swalClasses['timer-progress-bar'], "\"></div>\n </div>\n </div>\n").replace(/(^|\n)\s*/g, '');
  326. const resetOldContainer = () => {
  327. const oldContainer = getContainer();
  328. if (!oldContainer) {
  329. return false;
  330. }
  331. oldContainer.remove();
  332. removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]);
  333. return true;
  334. };
  335. const resetValidationMessage = () => {
  336. if (Swal.isVisible()) {
  337. Swal.resetValidationMessage();
  338. }
  339. };
  340. const addInputChangeListeners = () => {
  341. const popup = getPopup();
  342. const input = getChildByClass(popup, swalClasses.input);
  343. const file = getChildByClass(popup, swalClasses.file);
  344. const range = popup.querySelector(".".concat(swalClasses.range, " input"));
  345. const rangeOutput = popup.querySelector(".".concat(swalClasses.range, " output"));
  346. const select = getChildByClass(popup, swalClasses.select);
  347. const checkbox = popup.querySelector(".".concat(swalClasses.checkbox, " input"));
  348. const textarea = getChildByClass(popup, swalClasses.textarea);
  349. input.oninput = resetValidationMessage;
  350. file.onchange = resetValidationMessage;
  351. select.onchange = resetValidationMessage;
  352. checkbox.onchange = resetValidationMessage;
  353. textarea.oninput = resetValidationMessage;
  354. range.oninput = () => {
  355. resetValidationMessage();
  356. rangeOutput.value = range.value;
  357. };
  358. range.onchange = () => {
  359. resetValidationMessage();
  360. range.nextSibling.value = range.value;
  361. };
  362. };
  363. const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;
  364. const setupAccessibility = params => {
  365. const popup = getPopup();
  366. popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
  367. popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
  368. if (!params.toast) {
  369. popup.setAttribute('aria-modal', 'true');
  370. }
  371. };
  372. const setupRTL = targetElement => {
  373. if (window.getComputedStyle(targetElement).direction === 'rtl') {
  374. addClass(getContainer(), swalClasses.rtl);
  375. }
  376. };
  377. /*
  378. * Add modal + backdrop to DOM
  379. */
  380. const init = params => {
  381. // Clean up the old popup container if it exists
  382. const oldContainerExisted = resetOldContainer();
  383. /* istanbul ignore if */
  384. if (isNodeEnv()) {
  385. error('SweetAlert2 requires document to initialize');
  386. return;
  387. }
  388. const container = document.createElement('div');
  389. container.className = swalClasses.container;
  390. if (oldContainerExisted) {
  391. addClass(container, swalClasses['no-transition']);
  392. }
  393. setInnerHtml(container, sweetHTML);
  394. const targetElement = getTarget(params.target);
  395. targetElement.appendChild(container);
  396. setupAccessibility(params);
  397. setupRTL(targetElement);
  398. addInputChangeListeners();
  399. };
  400. const parseHtmlToContainer = (param, target) => {
  401. // DOM element
  402. if (param instanceof HTMLElement) {
  403. target.appendChild(param); // Object
  404. } else if (typeof param === 'object') {
  405. handleObject(param, target); // Plain string
  406. } else if (param) {
  407. setInnerHtml(target, param);
  408. }
  409. };
  410. const handleObject = (param, target) => {
  411. // JQuery element(s)
  412. if (param.jquery) {
  413. handleJqueryElem(target, param); // For other objects use their string representation
  414. } else {
  415. setInnerHtml(target, param.toString());
  416. }
  417. };
  418. const handleJqueryElem = (target, elem) => {
  419. target.textContent = '';
  420. if (0 in elem) {
  421. for (let i = 0; (i in elem); i++) {
  422. target.appendChild(elem[i].cloneNode(true));
  423. }
  424. } else {
  425. target.appendChild(elem.cloneNode(true));
  426. }
  427. };
  428. const animationEndEvent = (() => {
  429. // Prevent run in Node env
  430. /* istanbul ignore if */
  431. if (isNodeEnv()) {
  432. return false;
  433. }
  434. const testEl = document.createElement('div');
  435. const transEndEventNames = {
  436. WebkitAnimation: 'webkitAnimationEnd',
  437. OAnimation: 'oAnimationEnd oanimationend',
  438. animation: 'animationend'
  439. };
  440. for (const i in transEndEventNames) {
  441. if (Object.prototype.hasOwnProperty.call(transEndEventNames, i) && typeof testEl.style[i] !== 'undefined') {
  442. return transEndEventNames[i];
  443. }
  444. }
  445. return false;
  446. })();
  447. // https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
  448. const measureScrollbar = () => {
  449. const scrollDiv = document.createElement('div');
  450. scrollDiv.className = swalClasses['scrollbar-measure'];
  451. document.body.appendChild(scrollDiv);
  452. const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  453. document.body.removeChild(scrollDiv);
  454. return scrollbarWidth;
  455. };
  456. const renderActions = (instance, params) => {
  457. const actions = getActions();
  458. const loader = getLoader();
  459. const confirmButton = getConfirmButton();
  460. const denyButton = getDenyButton();
  461. const cancelButton = getCancelButton(); // Actions (buttons) wrapper
  462. if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
  463. hide(actions);
  464. } else {
  465. show(actions);
  466. } // Custom class
  467. applyCustomClass(actions, params, 'actions'); // Render buttons
  468. renderButton(confirmButton, 'confirm', params);
  469. renderButton(denyButton, 'deny', params);
  470. renderButton(cancelButton, 'cancel', params);
  471. handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
  472. if (params.reverseButtons) {
  473. actions.insertBefore(cancelButton, loader);
  474. actions.insertBefore(denyButton, loader);
  475. actions.insertBefore(confirmButton, loader);
  476. } // Loader
  477. setInnerHtml(loader, params.loaderHtml);
  478. applyCustomClass(loader, params, 'loader');
  479. };
  480. function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
  481. if (!params.buttonsStyling) {
  482. return removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
  483. }
  484. addClass([confirmButton, denyButton, cancelButton], swalClasses.styled); // Buttons background colors
  485. if (params.confirmButtonColor) {
  486. confirmButton.style.backgroundColor = params.confirmButtonColor;
  487. addClass(confirmButton, swalClasses['default-outline']);
  488. }
  489. if (params.denyButtonColor) {
  490. denyButton.style.backgroundColor = params.denyButtonColor;
  491. addClass(denyButton, swalClasses['default-outline']);
  492. }
  493. if (params.cancelButtonColor) {
  494. cancelButton.style.backgroundColor = params.cancelButtonColor;
  495. addClass(cancelButton, swalClasses['default-outline']);
  496. }
  497. }
  498. function renderButton(button, buttonType, params) {
  499. toggle(button, params["show".concat(capitalizeFirstLetter(buttonType), "Button")], 'inline-block');
  500. setInnerHtml(button, params["".concat(buttonType, "ButtonText")]); // Set caption text
  501. button.setAttribute('aria-label', params["".concat(buttonType, "ButtonAriaLabel")]); // ARIA label
  502. // Add buttons custom classes
  503. button.className = swalClasses[buttonType];
  504. applyCustomClass(button, params, "".concat(buttonType, "Button"));
  505. addClass(button, params["".concat(buttonType, "ButtonClass")]);
  506. }
  507. function handleBackdropParam(container, backdrop) {
  508. if (typeof backdrop === 'string') {
  509. container.style.background = backdrop;
  510. } else if (!backdrop) {
  511. addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
  512. }
  513. }
  514. function handlePositionParam(container, position) {
  515. if (position in swalClasses) {
  516. addClass(container, swalClasses[position]);
  517. } else {
  518. warn('The "position" parameter is not valid, defaulting to "center"');
  519. addClass(container, swalClasses.center);
  520. }
  521. }
  522. function handleGrowParam(container, grow) {
  523. if (grow && typeof grow === 'string') {
  524. const growClass = "grow-".concat(grow);
  525. if (growClass in swalClasses) {
  526. addClass(container, swalClasses[growClass]);
  527. }
  528. }
  529. }
  530. const renderContainer = (instance, params) => {
  531. const container = getContainer();
  532. if (!container) {
  533. return;
  534. }
  535. handleBackdropParam(container, params.backdrop);
  536. handlePositionParam(container, params.position);
  537. handleGrowParam(container, params.grow); // Custom class
  538. applyCustomClass(container, params, 'container');
  539. };
  540. /**
  541. * This module containts `WeakMap`s for each effectively-"private property" that a `Swal` has.
  542. * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
  543. * This is the approach that Babel will probably take to implement private methods/fields
  544. * https://github.com/tc39/proposal-private-methods
  545. * https://github.com/babel/babel/pull/7555
  546. * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
  547. * then we can use that language feature.
  548. */
  549. var privateProps = {
  550. promise: new WeakMap(),
  551. innerParams: new WeakMap(),
  552. domCache: new WeakMap()
  553. };
  554. const inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
  555. const renderInput = (instance, params) => {
  556. const popup = getPopup();
  557. const innerParams = privateProps.innerParams.get(instance);
  558. const rerender = !innerParams || params.input !== innerParams.input;
  559. inputTypes.forEach(inputType => {
  560. const inputClass = swalClasses[inputType];
  561. const inputContainer = getChildByClass(popup, inputClass); // set attributes
  562. setAttributes(inputType, params.inputAttributes); // set class
  563. inputContainer.className = inputClass;
  564. if (rerender) {
  565. hide(inputContainer);
  566. }
  567. });
  568. if (params.input) {
  569. if (rerender) {
  570. showInput(params);
  571. } // set custom class
  572. setCustomClass(params);
  573. }
  574. };
  575. const showInput = params => {
  576. if (!renderInputType[params.input]) {
  577. return error("Unexpected type of input! Expected \"text\", \"email\", \"password\", \"number\", \"tel\", \"select\", \"radio\", \"checkbox\", \"textarea\", \"file\" or \"url\", got \"".concat(params.input, "\""));
  578. }
  579. const inputContainer = getInputContainer(params.input);
  580. const input = renderInputType[params.input](inputContainer, params);
  581. show(input); // input autofocus
  582. setTimeout(() => {
  583. focusInput(input);
  584. });
  585. };
  586. const removeAttributes = input => {
  587. for (let i = 0; i < input.attributes.length; i++) {
  588. const attrName = input.attributes[i].name;
  589. if (!['type', 'value', 'style'].includes(attrName)) {
  590. input.removeAttribute(attrName);
  591. }
  592. }
  593. };
  594. const setAttributes = (inputType, inputAttributes) => {
  595. const input = getInput(getPopup(), inputType);
  596. if (!input) {
  597. return;
  598. }
  599. removeAttributes(input);
  600. for (const attr in inputAttributes) {
  601. input.setAttribute(attr, inputAttributes[attr]);
  602. }
  603. };
  604. const setCustomClass = params => {
  605. const inputContainer = getInputContainer(params.input);
  606. if (params.customClass) {
  607. addClass(inputContainer, params.customClass.input);
  608. }
  609. };
  610. const setInputPlaceholder = (input, params) => {
  611. if (!input.placeholder || params.inputPlaceholder) {
  612. input.placeholder = params.inputPlaceholder;
  613. }
  614. };
  615. const setInputLabel = (input, prependTo, params) => {
  616. if (params.inputLabel) {
  617. input.id = swalClasses.input;
  618. const label = document.createElement('label');
  619. const labelClass = swalClasses['input-label'];
  620. label.setAttribute('for', input.id);
  621. label.className = labelClass;
  622. addClass(label, params.customClass.inputLabel);
  623. label.innerText = params.inputLabel;
  624. prependTo.insertAdjacentElement('beforebegin', label);
  625. }
  626. };
  627. const getInputContainer = inputType => {
  628. const inputClass = swalClasses[inputType] ? swalClasses[inputType] : swalClasses.input;
  629. return getChildByClass(getPopup(), inputClass);
  630. };
  631. const renderInputType = {};
  632. renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = (input, params) => {
  633. if (typeof params.inputValue === 'string' || typeof params.inputValue === 'number') {
  634. input.value = params.inputValue;
  635. } else if (!isPromise(params.inputValue)) {
  636. warn("Unexpected type of inputValue! Expected \"string\", \"number\" or \"Promise\", got \"".concat(typeof params.inputValue, "\""));
  637. }
  638. setInputLabel(input, input, params);
  639. setInputPlaceholder(input, params);
  640. input.type = params.input;
  641. return input;
  642. };
  643. renderInputType.file = (input, params) => {
  644. setInputLabel(input, input, params);
  645. setInputPlaceholder(input, params);
  646. return input;
  647. };
  648. renderInputType.range = (range, params) => {
  649. const rangeInput = range.querySelector('input');
  650. const rangeOutput = range.querySelector('output');
  651. rangeInput.value = params.inputValue;
  652. rangeInput.type = params.input;
  653. rangeOutput.value = params.inputValue;
  654. setInputLabel(rangeInput, range, params);
  655. return range;
  656. };
  657. renderInputType.select = (select, params) => {
  658. select.textContent = '';
  659. if (params.inputPlaceholder) {
  660. const placeholder = document.createElement('option');
  661. setInnerHtml(placeholder, params.inputPlaceholder);
  662. placeholder.value = '';
  663. placeholder.disabled = true;
  664. placeholder.selected = true;
  665. select.appendChild(placeholder);
  666. }
  667. setInputLabel(select, select, params);
  668. return select;
  669. };
  670. renderInputType.radio = radio => {
  671. radio.textContent = '';
  672. return radio;
  673. };
  674. renderInputType.checkbox = (checkboxContainer, params) => {
  675. const checkbox = getInput(getPopup(), 'checkbox');
  676. checkbox.value = 1;
  677. checkbox.id = swalClasses.checkbox;
  678. checkbox.checked = Boolean(params.inputValue);
  679. const label = checkboxContainer.querySelector('span');
  680. setInnerHtml(label, params.inputPlaceholder);
  681. return checkboxContainer;
  682. };
  683. renderInputType.textarea = (textarea, params) => {
  684. textarea.value = params.inputValue;
  685. setInputPlaceholder(textarea, params);
  686. setInputLabel(textarea, textarea, params);
  687. const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
  688. setTimeout(() => {
  689. // #2291
  690. if ('MutationObserver' in window) {
  691. // #1699
  692. const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
  693. const textareaResizeHandler = () => {
  694. const textareaWidth = textarea.offsetWidth + getMargin(textarea);
  695. if (textareaWidth > initialPopupWidth) {
  696. getPopup().style.width = "".concat(textareaWidth, "px");
  697. } else {
  698. getPopup().style.width = null;
  699. }
  700. };
  701. new MutationObserver(textareaResizeHandler).observe(textarea, {
  702. attributes: true,
  703. attributeFilter: ['style']
  704. });
  705. }
  706. });
  707. return textarea;
  708. };
  709. const renderContent = (instance, params) => {
  710. const htmlContainer = getHtmlContainer();
  711. applyCustomClass(htmlContainer, params, 'htmlContainer'); // Content as HTML
  712. if (params.html) {
  713. parseHtmlToContainer(params.html, htmlContainer);
  714. show(htmlContainer, 'block'); // Content as plain text
  715. } else if (params.text) {
  716. htmlContainer.textContent = params.text;
  717. show(htmlContainer, 'block'); // No content
  718. } else {
  719. hide(htmlContainer);
  720. }
  721. renderInput(instance, params);
  722. };
  723. const renderFooter = (instance, params) => {
  724. const footer = getFooter();
  725. toggle(footer, params.footer);
  726. if (params.footer) {
  727. parseHtmlToContainer(params.footer, footer);
  728. } // Custom class
  729. applyCustomClass(footer, params, 'footer');
  730. };
  731. const renderCloseButton = (instance, params) => {
  732. const closeButton = getCloseButton();
  733. setInnerHtml(closeButton, params.closeButtonHtml); // Custom class
  734. applyCustomClass(closeButton, params, 'closeButton');
  735. toggle(closeButton, params.showCloseButton);
  736. closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
  737. };
  738. const renderIcon = (instance, params) => {
  739. const innerParams = privateProps.innerParams.get(instance);
  740. const icon = getIcon(); // if the given icon already rendered, apply the styling without re-rendering the icon
  741. if (innerParams && params.icon === innerParams.icon) {
  742. // Custom or default content
  743. setContent(icon, params);
  744. applyStyles(icon, params);
  745. return;
  746. }
  747. if (!params.icon && !params.iconHtml) {
  748. return hide(icon);
  749. }
  750. if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
  751. error("Unknown icon! Expected \"success\", \"error\", \"warning\", \"info\" or \"question\", got \"".concat(params.icon, "\""));
  752. return hide(icon);
  753. }
  754. show(icon); // Custom or default content
  755. setContent(icon, params);
  756. applyStyles(icon, params); // Animate icon
  757. addClass(icon, params.showClass.icon);
  758. };
  759. const applyStyles = (icon, params) => {
  760. for (const iconType in iconTypes) {
  761. if (params.icon !== iconType) {
  762. removeClass(icon, iconTypes[iconType]);
  763. }
  764. }
  765. addClass(icon, iconTypes[params.icon]); // Icon color
  766. setColor(icon, params); // Success icon background color
  767. adjustSuccessIconBackgoundColor(); // Custom class
  768. applyCustomClass(icon, params, 'icon');
  769. }; // Adjust success icon background color to match the popup background color
  770. const adjustSuccessIconBackgoundColor = () => {
  771. const popup = getPopup();
  772. const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
  773. const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
  774. for (let i = 0; i < successIconParts.length; i++) {
  775. successIconParts[i].style.backgroundColor = popupBackgroundColor;
  776. }
  777. };
  778. const setContent = (icon, params) => {
  779. icon.textContent = '';
  780. if (params.iconHtml) {
  781. setInnerHtml(icon, iconContent(params.iconHtml));
  782. } else if (params.icon === 'success') {
  783. setInnerHtml(icon, "\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 ");
  784. } else if (params.icon === 'error') {
  785. setInnerHtml(icon, "\n <span class=\"swal2-x-mark\">\n <span class=\"swal2-x-mark-line-left\"></span>\n <span class=\"swal2-x-mark-line-right\"></span>\n </span>\n ");
  786. } else {
  787. const defaultIconHtml = {
  788. question: '?',
  789. warning: '!',
  790. info: 'i'
  791. };
  792. setInnerHtml(icon, iconContent(defaultIconHtml[params.icon]));
  793. }
  794. };
  795. const setColor = (icon, params) => {
  796. if (!params.iconColor) {
  797. return;
  798. }
  799. icon.style.color = params.iconColor;
  800. icon.style.borderColor = params.iconColor;
  801. for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
  802. setStyle(icon, sel, 'backgroundColor', params.iconColor);
  803. }
  804. setStyle(icon, '.swal2-success-ring', 'borderColor', params.iconColor);
  805. };
  806. const iconContent = content => "<div class=\"".concat(swalClasses['icon-content'], "\">").concat(content, "</div>");
  807. const renderImage = (instance, params) => {
  808. const image = getImage();
  809. if (!params.imageUrl) {
  810. return hide(image);
  811. }
  812. show(image, ''); // Src, alt
  813. image.setAttribute('src', params.imageUrl);
  814. image.setAttribute('alt', params.imageAlt); // Width, height
  815. applyNumericalStyle(image, 'width', params.imageWidth);
  816. applyNumericalStyle(image, 'height', params.imageHeight); // Class
  817. image.className = swalClasses.image;
  818. applyCustomClass(image, params, 'image');
  819. };
  820. const createStepElement = step => {
  821. const stepEl = document.createElement('li');
  822. addClass(stepEl, swalClasses['progress-step']);
  823. setInnerHtml(stepEl, step);
  824. return stepEl;
  825. };
  826. const createLineElement = params => {
  827. const lineEl = document.createElement('li');
  828. addClass(lineEl, swalClasses['progress-step-line']);
  829. if (params.progressStepsDistance) {
  830. lineEl.style.width = params.progressStepsDistance;
  831. }
  832. return lineEl;
  833. };
  834. const renderProgressSteps = (instance, params) => {
  835. const progressStepsContainer = getProgressSteps();
  836. if (!params.progressSteps || params.progressSteps.length === 0) {
  837. return hide(progressStepsContainer);
  838. }
  839. show(progressStepsContainer);
  840. progressStepsContainer.textContent = '';
  841. if (params.currentProgressStep >= params.progressSteps.length) {
  842. warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
  843. }
  844. params.progressSteps.forEach((step, index) => {
  845. const stepEl = createStepElement(step);
  846. progressStepsContainer.appendChild(stepEl);
  847. if (index === params.currentProgressStep) {
  848. addClass(stepEl, swalClasses['active-progress-step']);
  849. }
  850. if (index !== params.progressSteps.length - 1) {
  851. const lineEl = createLineElement(params);
  852. progressStepsContainer.appendChild(lineEl);
  853. }
  854. });
  855. };
  856. const renderTitle = (instance, params) => {
  857. const title = getTitle();
  858. toggle(title, params.title || params.titleText, 'block');
  859. if (params.title) {
  860. parseHtmlToContainer(params.title, title);
  861. }
  862. if (params.titleText) {
  863. title.innerText = params.titleText;
  864. } // Custom class
  865. applyCustomClass(title, params, 'title');
  866. };
  867. const renderPopup = (instance, params) => {
  868. const container = getContainer();
  869. const popup = getPopup(); // Width
  870. if (params.toast) {
  871. // #2170
  872. applyNumericalStyle(container, 'width', params.width);
  873. popup.style.width = '100%';
  874. popup.insertBefore(getLoader(), getIcon());
  875. } else {
  876. applyNumericalStyle(popup, 'width', params.width);
  877. } // Padding
  878. applyNumericalStyle(popup, 'padding', params.padding); // Background
  879. if (params.background) {
  880. popup.style.background = params.background;
  881. }
  882. hide(getValidationMessage()); // Classes
  883. addClasses(popup, params);
  884. };
  885. const addClasses = (popup, params) => {
  886. // Default Class + showClass when updating Swal.update({})
  887. popup.className = "".concat(swalClasses.popup, " ").concat(isVisible(popup) ? params.showClass.popup : '');
  888. if (params.toast) {
  889. addClass([document.documentElement, document.body], swalClasses['toast-shown']);
  890. addClass(popup, swalClasses.toast);
  891. } else {
  892. addClass(popup, swalClasses.modal);
  893. } // Custom class
  894. applyCustomClass(popup, params, 'popup');
  895. if (typeof params.customClass === 'string') {
  896. addClass(popup, params.customClass);
  897. } // Icon class (#1842)
  898. if (params.icon) {
  899. addClass(popup, swalClasses["icon-".concat(params.icon)]);
  900. }
  901. };
  902. const render = (instance, params) => {
  903. renderPopup(instance, params);
  904. renderContainer(instance, params);
  905. renderProgressSteps(instance, params);
  906. renderIcon(instance, params);
  907. renderImage(instance, params);
  908. renderTitle(instance, params);
  909. renderCloseButton(instance, params);
  910. renderContent(instance, params);
  911. renderActions(instance, params);
  912. renderFooter(instance, params);
  913. if (typeof params.didRender === 'function') {
  914. params.didRender(getPopup());
  915. }
  916. };
  917. /*
  918. * Global function to determine if SweetAlert2 popup is shown
  919. */
  920. const isVisible$1 = () => {
  921. return isVisible(getPopup());
  922. };
  923. /*
  924. * Global function to click 'Confirm' button
  925. */
  926. const clickConfirm = () => getConfirmButton() && getConfirmButton().click();
  927. /*
  928. * Global function to click 'Deny' button
  929. */
  930. const clickDeny = () => getDenyButton() && getDenyButton().click();
  931. /*
  932. * Global function to click 'Cancel' button
  933. */
  934. const clickCancel = () => getCancelButton() && getCancelButton().click();
  935. function fire(...args) {
  936. const Swal = this;
  937. return new Swal(...args);
  938. }
  939. /**
  940. * Returns an extended version of `Swal` containing `params` as defaults.
  941. * Useful for reusing Swal configuration.
  942. *
  943. * For example:
  944. *
  945. * Before:
  946. * const textPromptOptions = { input: 'text', showCancelButton: true }
  947. * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
  948. * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
  949. *
  950. * After:
  951. * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
  952. * const {value: firstName} = await TextPrompt('What is your first name?')
  953. * const {value: lastName} = await TextPrompt('What is your last name?')
  954. *
  955. * @param mixinParams
  956. */
  957. function mixin(mixinParams) {
  958. class MixinSwal extends this {
  959. _main(params, priorityMixinParams) {
  960. return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
  961. }
  962. }
  963. return MixinSwal;
  964. }
  965. /**
  966. * Shows loader (spinner), this is useful with AJAX requests.
  967. * By default the loader be shown instead of the "Confirm" button.
  968. */
  969. const showLoading = buttonToReplace => {
  970. let popup = getPopup();
  971. if (!popup) {
  972. Swal.fire();
  973. }
  974. popup = getPopup();
  975. const loader = getLoader();
  976. if (isToast()) {
  977. hide(getIcon());
  978. } else {
  979. replaceButton(popup, buttonToReplace);
  980. }
  981. show(loader);
  982. popup.setAttribute('data-loading', true);
  983. popup.setAttribute('aria-busy', true);
  984. popup.focus();
  985. };
  986. const replaceButton = (popup, buttonToReplace) => {
  987. const actions = getActions();
  988. const loader = getLoader();
  989. if (!buttonToReplace && isVisible(getConfirmButton())) {
  990. buttonToReplace = getConfirmButton();
  991. }
  992. show(actions);
  993. if (buttonToReplace) {
  994. hide(buttonToReplace);
  995. loader.setAttribute('data-button-to-replace', buttonToReplace.className);
  996. }
  997. loader.parentNode.insertBefore(loader, buttonToReplace);
  998. addClass([popup, actions], swalClasses.loading);
  999. };
  1000. const RESTORE_FOCUS_TIMEOUT = 100;
  1001. const globalState = {};
  1002. const focusPreviousActiveElement = () => {
  1003. if (globalState.previousActiveElement && globalState.previousActiveElement.focus) {
  1004. globalState.previousActiveElement.focus();
  1005. globalState.previousActiveElement = null;
  1006. } else if (document.body) {
  1007. document.body.focus();
  1008. }
  1009. }; // Restore previous active (focused) element
  1010. const restoreActiveElement = returnFocus => {
  1011. return new Promise(resolve => {
  1012. if (!returnFocus) {
  1013. return resolve();
  1014. }
  1015. const x = window.scrollX;
  1016. const y = window.scrollY;
  1017. globalState.restoreFocusTimeout = setTimeout(() => {
  1018. focusPreviousActiveElement();
  1019. resolve();
  1020. }, RESTORE_FOCUS_TIMEOUT); // issues/900
  1021. window.scrollTo(x, y);
  1022. });
  1023. };
  1024. /**
  1025. * If `timer` parameter is set, returns number of milliseconds of timer remained.
  1026. * Otherwise, returns undefined.
  1027. */
  1028. const getTimerLeft = () => {
  1029. return globalState.timeout && globalState.timeout.getTimerLeft();
  1030. };
  1031. /**
  1032. * Stop timer. Returns number of milliseconds of timer remained.
  1033. * If `timer` parameter isn't set, returns undefined.
  1034. */
  1035. const stopTimer = () => {
  1036. if (globalState.timeout) {
  1037. stopTimerProgressBar();
  1038. return globalState.timeout.stop();
  1039. }
  1040. };
  1041. /**
  1042. * Resume timer. Returns number of milliseconds of timer remained.
  1043. * If `timer` parameter isn't set, returns undefined.
  1044. */
  1045. const resumeTimer = () => {
  1046. if (globalState.timeout) {
  1047. const remaining = globalState.timeout.start();
  1048. animateTimerProgressBar(remaining);
  1049. return remaining;
  1050. }
  1051. };
  1052. /**
  1053. * Resume timer. Returns number of milliseconds of timer remained.
  1054. * If `timer` parameter isn't set, returns undefined.
  1055. */
  1056. const toggleTimer = () => {
  1057. const timer = globalState.timeout;
  1058. return timer && (timer.running ? stopTimer() : resumeTimer());
  1059. };
  1060. /**
  1061. * Increase timer. Returns number of milliseconds of an updated timer.
  1062. * If `timer` parameter isn't set, returns undefined.
  1063. */
  1064. const increaseTimer = n => {
  1065. if (globalState.timeout) {
  1066. const remaining = globalState.timeout.increase(n);
  1067. animateTimerProgressBar(remaining, true);
  1068. return remaining;
  1069. }
  1070. };
  1071. /**
  1072. * Check if timer is running. Returns true if timer is running
  1073. * or false if timer is paused or stopped.
  1074. * If `timer` parameter isn't set, returns undefined
  1075. */
  1076. const isTimerRunning = () => {
  1077. return globalState.timeout && globalState.timeout.isRunning();
  1078. };
  1079. let bodyClickListenerAdded = false;
  1080. const clickHandlers = {};
  1081. function bindClickHandler(attr = 'data-swal-template') {
  1082. clickHandlers[attr] = this;
  1083. if (!bodyClickListenerAdded) {
  1084. document.body.addEventListener('click', bodyClickListener);
  1085. bodyClickListenerAdded = true;
  1086. }
  1087. }
  1088. const bodyClickListener = event => {
  1089. // TODO: replace with event.composedPath()
  1090. for (let el = event.target; el && el !== document; el = el.parentNode) {
  1091. for (const attr in clickHandlers) {
  1092. const template = el.getAttribute(attr);
  1093. if (template) {
  1094. clickHandlers[attr].fire({
  1095. template
  1096. });
  1097. return;
  1098. }
  1099. }
  1100. }
  1101. };
  1102. const defaultParams = {
  1103. title: '',
  1104. titleText: '',
  1105. text: '',
  1106. html: '',
  1107. footer: '',
  1108. icon: undefined,
  1109. iconColor: undefined,
  1110. iconHtml: undefined,
  1111. template: undefined,
  1112. toast: false,
  1113. showClass: {
  1114. popup: 'swal2-show',
  1115. backdrop: 'swal2-backdrop-show',
  1116. icon: 'swal2-icon-show'
  1117. },
  1118. hideClass: {
  1119. popup: 'swal2-hide',
  1120. backdrop: 'swal2-backdrop-hide',
  1121. icon: 'swal2-icon-hide'
  1122. },
  1123. customClass: {},
  1124. target: 'body',
  1125. backdrop: true,
  1126. heightAuto: true,
  1127. allowOutsideClick: true,
  1128. allowEscapeKey: true,
  1129. allowEnterKey: true,
  1130. stopKeydownPropagation: true,
  1131. keydownListenerCapture: false,
  1132. showConfirmButton: true,
  1133. showDenyButton: false,
  1134. showCancelButton: false,
  1135. preConfirm: undefined,
  1136. preDeny: undefined,
  1137. confirmButtonText: 'OK',
  1138. confirmButtonAriaLabel: '',
  1139. confirmButtonColor: undefined,
  1140. denyButtonText: 'No',
  1141. denyButtonAriaLabel: '',
  1142. denyButtonColor: undefined,
  1143. cancelButtonText: 'Cancel',
  1144. cancelButtonAriaLabel: '',
  1145. cancelButtonColor: undefined,
  1146. buttonsStyling: true,
  1147. reverseButtons: false,
  1148. focusConfirm: true,
  1149. focusDeny: false,
  1150. focusCancel: false,
  1151. returnFocus: true,
  1152. showCloseButton: false,
  1153. closeButtonHtml: '&times;',
  1154. closeButtonAriaLabel: 'Close this dialog',
  1155. loaderHtml: '',
  1156. showLoaderOnConfirm: false,
  1157. showLoaderOnDeny: false,
  1158. imageUrl: undefined,
  1159. imageWidth: undefined,
  1160. imageHeight: undefined,
  1161. imageAlt: '',
  1162. timer: undefined,
  1163. timerProgressBar: false,
  1164. width: undefined,
  1165. padding: undefined,
  1166. background: undefined,
  1167. input: undefined,
  1168. inputPlaceholder: '',
  1169. inputLabel: '',
  1170. inputValue: '',
  1171. inputOptions: {},
  1172. inputAutoTrim: true,
  1173. inputAttributes: {},
  1174. inputValidator: undefined,
  1175. returnInputValueOnDeny: false,
  1176. validationMessage: undefined,
  1177. grow: false,
  1178. position: 'center',
  1179. progressSteps: [],
  1180. currentProgressStep: undefined,
  1181. progressStepsDistance: undefined,
  1182. willOpen: undefined,
  1183. didOpen: undefined,
  1184. didRender: undefined,
  1185. willClose: undefined,
  1186. didClose: undefined,
  1187. didDestroy: undefined,
  1188. scrollbarPadding: true
  1189. };
  1190. const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'willClose'];
  1191. const deprecatedParams = {};
  1192. const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
  1193. /**
  1194. * Is valid parameter
  1195. * @param {String} paramName
  1196. */
  1197. const isValidParameter = paramName => {
  1198. return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
  1199. };
  1200. /**
  1201. * Is valid parameter for Swal.update() method
  1202. * @param {String} paramName
  1203. */
  1204. const isUpdatableParameter = paramName => {
  1205. return updatableParams.indexOf(paramName) !== -1;
  1206. };
  1207. /**
  1208. * Is deprecated parameter
  1209. * @param {String} paramName
  1210. */
  1211. const isDeprecatedParameter = paramName => {
  1212. return deprecatedParams[paramName];
  1213. };
  1214. const checkIfParamIsValid = param => {
  1215. if (!isValidParameter(param)) {
  1216. warn("Unknown parameter \"".concat(param, "\""));
  1217. }
  1218. };
  1219. const checkIfToastParamIsValid = param => {
  1220. if (toastIncompatibleParams.includes(param)) {
  1221. warn("The parameter \"".concat(param, "\" is incompatible with toasts"));
  1222. }
  1223. };
  1224. const checkIfParamIsDeprecated = param => {
  1225. if (isDeprecatedParameter(param)) {
  1226. warnAboutDeprecation(param, isDeprecatedParameter(param));
  1227. }
  1228. };
  1229. /**
  1230. * Show relevant warnings for given params
  1231. *
  1232. * @param params
  1233. */
  1234. const showWarningsForParams = params => {
  1235. if (!params.backdrop && params.allowOutsideClick) {
  1236. warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
  1237. }
  1238. for (const param in params) {
  1239. checkIfParamIsValid(param);
  1240. if (params.toast) {
  1241. checkIfToastParamIsValid(param);
  1242. }
  1243. checkIfParamIsDeprecated(param);
  1244. }
  1245. };
  1246. var staticMethods = /*#__PURE__*/Object.freeze({
  1247. isValidParameter: isValidParameter,
  1248. isUpdatableParameter: isUpdatableParameter,
  1249. isDeprecatedParameter: isDeprecatedParameter,
  1250. argsToParams: argsToParams,
  1251. isVisible: isVisible$1,
  1252. clickConfirm: clickConfirm,
  1253. clickDeny: clickDeny,
  1254. clickCancel: clickCancel,
  1255. getContainer: getContainer,
  1256. getPopup: getPopup,
  1257. getTitle: getTitle,
  1258. getHtmlContainer: getHtmlContainer,
  1259. getImage: getImage,
  1260. getIcon: getIcon,
  1261. getInputLabel: getInputLabel,
  1262. getCloseButton: getCloseButton,
  1263. getActions: getActions,
  1264. getConfirmButton: getConfirmButton,
  1265. getDenyButton: getDenyButton,
  1266. getCancelButton: getCancelButton,
  1267. getLoader: getLoader,
  1268. getFooter: getFooter,
  1269. getTimerProgressBar: getTimerProgressBar,
  1270. getFocusableElements: getFocusableElements,
  1271. getValidationMessage: getValidationMessage,
  1272. isLoading: isLoading,
  1273. fire: fire,
  1274. mixin: mixin,
  1275. showLoading: showLoading,
  1276. enableLoading: showLoading,
  1277. getTimerLeft: getTimerLeft,
  1278. stopTimer: stopTimer,
  1279. resumeTimer: resumeTimer,
  1280. toggleTimer: toggleTimer,
  1281. increaseTimer: increaseTimer,
  1282. isTimerRunning: isTimerRunning,
  1283. bindClickHandler: bindClickHandler
  1284. });
  1285. /**
  1286. * Hides loader and shows back the button which was hidden by .showLoading()
  1287. */
  1288. function hideLoading() {
  1289. // do nothing if popup is closed
  1290. const innerParams = privateProps.innerParams.get(this);
  1291. if (!innerParams) {
  1292. return;
  1293. }
  1294. const domCache = privateProps.domCache.get(this);
  1295. hide(domCache.loader);
  1296. if (isToast()) {
  1297. if (innerParams.icon) {
  1298. show(getIcon());
  1299. }
  1300. } else {
  1301. showRelatedButton(domCache);
  1302. }
  1303. removeClass([domCache.popup, domCache.actions], swalClasses.loading);
  1304. domCache.popup.removeAttribute('aria-busy');
  1305. domCache.popup.removeAttribute('data-loading');
  1306. domCache.confirmButton.disabled = false;
  1307. domCache.denyButton.disabled = false;
  1308. domCache.cancelButton.disabled = false;
  1309. }
  1310. const showRelatedButton = domCache => {
  1311. const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute('data-button-to-replace'));
  1312. if (buttonToReplace.length) {
  1313. show(buttonToReplace[0], 'inline-block');
  1314. } else if (allButtonsAreHidden()) {
  1315. hide(domCache.actions);
  1316. }
  1317. };
  1318. function getInput$1(instance) {
  1319. const innerParams = privateProps.innerParams.get(instance || this);
  1320. const domCache = privateProps.domCache.get(instance || this);
  1321. if (!domCache) {
  1322. return null;
  1323. }
  1324. return getInput(domCache.popup, innerParams.input);
  1325. }
  1326. const fixScrollbar = () => {
  1327. // for queues, do not do this more than once
  1328. if (states.previousBodyPadding !== null) {
  1329. return;
  1330. } // if the body has overflow
  1331. if (document.body.scrollHeight > window.innerHeight) {
  1332. // add padding so the content doesn't shift after removal of scrollbar
  1333. states.previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
  1334. document.body.style.paddingRight = "".concat(states.previousBodyPadding + measureScrollbar(), "px");
  1335. }
  1336. };
  1337. const undoScrollbar = () => {
  1338. if (states.previousBodyPadding !== null) {
  1339. document.body.style.paddingRight = "".concat(states.previousBodyPadding, "px");
  1340. states.previousBodyPadding = null;
  1341. }
  1342. };
  1343. /* istanbul ignore file */
  1344. const iOSfix = () => {
  1345. const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
  1346. if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
  1347. const offset = document.body.scrollTop;
  1348. document.body.style.top = "".concat(offset * -1, "px");
  1349. addClass(document.body, swalClasses.iosfix);
  1350. lockBodyScroll();
  1351. addBottomPaddingForTallPopups(); // #1948
  1352. }
  1353. };
  1354. const addBottomPaddingForTallPopups = () => {
  1355. const safari = !navigator.userAgent.match(/(CriOS|FxiOS|EdgiOS|YaBrowser|UCBrowser)/i);
  1356. if (safari) {
  1357. const bottomPanelHeight = 44;
  1358. if (getPopup().scrollHeight > window.innerHeight - bottomPanelHeight) {
  1359. getContainer().style.paddingBottom = "".concat(bottomPanelHeight, "px");
  1360. }
  1361. }
  1362. };
  1363. const lockBodyScroll = () => {
  1364. // #1246
  1365. const container = getContainer();
  1366. let preventTouchMove;
  1367. container.ontouchstart = e => {
  1368. preventTouchMove = shouldPreventTouchMove(e);
  1369. };
  1370. container.ontouchmove = e => {
  1371. if (preventTouchMove) {
  1372. e.preventDefault();
  1373. e.stopPropagation();
  1374. }
  1375. };
  1376. };
  1377. const shouldPreventTouchMove = event => {
  1378. const target = event.target;
  1379. const container = getContainer();
  1380. if (isStylys(event) || isZoom(event)) {
  1381. return false;
  1382. }
  1383. if (target === container) {
  1384. return true;
  1385. }
  1386. if (!isScrollable(container) && target.tagName !== 'INPUT' && // #1603
  1387. target.tagName !== 'TEXTAREA' && // #2266
  1388. !(isScrollable(getHtmlContainer()) && // #1944
  1389. getHtmlContainer().contains(target))) {
  1390. return true;
  1391. }
  1392. return false;
  1393. };
  1394. const isStylys = event => {
  1395. // #1786
  1396. return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';
  1397. };
  1398. const isZoom = event => {
  1399. // #1891
  1400. return event.touches && event.touches.length > 1;
  1401. };
  1402. const undoIOSfix = () => {
  1403. if (hasClass(document.body, swalClasses.iosfix)) {
  1404. const offset = parseInt(document.body.style.top, 10);
  1405. removeClass(document.body, swalClasses.iosfix);
  1406. document.body.style.top = '';
  1407. document.body.scrollTop = offset * -1;
  1408. }
  1409. };
  1410. // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
  1411. // elements not within the active modal dialog will not be surfaced if a user opens a screen
  1412. // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
  1413. const setAriaHidden = () => {
  1414. const bodyChildren = toArray(document.body.children);
  1415. bodyChildren.forEach(el => {
  1416. if (el === getContainer() || el.contains(getContainer())) {
  1417. return;
  1418. }
  1419. if (el.hasAttribute('aria-hidden')) {
  1420. el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden'));
  1421. }
  1422. el.setAttribute('aria-hidden', 'true');
  1423. });
  1424. };
  1425. const unsetAriaHidden = () => {
  1426. const bodyChildren = toArray(document.body.children);
  1427. bodyChildren.forEach(el => {
  1428. if (el.hasAttribute('data-previous-aria-hidden')) {
  1429. el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden'));
  1430. el.removeAttribute('data-previous-aria-hidden');
  1431. } else {
  1432. el.removeAttribute('aria-hidden');
  1433. }
  1434. });
  1435. };
  1436. /**
  1437. * This module containts `WeakMap`s for each effectively-"private property" that a `Swal` has.
  1438. * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
  1439. * This is the approach that Babel will probably take to implement private methods/fields
  1440. * https://github.com/tc39/proposal-private-methods
  1441. * https://github.com/babel/babel/pull/7555
  1442. * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
  1443. * then we can use that language feature.
  1444. */
  1445. var privateMethods = {
  1446. swalPromiseResolve: new WeakMap()
  1447. };
  1448. /*
  1449. * Instance method to close sweetAlert
  1450. */
  1451. function removePopupAndResetState(instance, container, returnFocus, didClose) {
  1452. if (isToast()) {
  1453. triggerDidCloseAndDispose(instance, didClose);
  1454. } else {
  1455. restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
  1456. globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
  1457. capture: globalState.keydownListenerCapture
  1458. });
  1459. globalState.keydownHandlerAdded = false;
  1460. }
  1461. const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // workaround for #2088
  1462. // for some reason removing the container in Safari will scroll the document to bottom
  1463. if (isSafari) {
  1464. container.setAttribute('style', 'display:none !important');
  1465. container.removeAttribute('class');
  1466. container.innerHTML = '';
  1467. } else {
  1468. container.remove();
  1469. }
  1470. if (isModal()) {
  1471. undoScrollbar();
  1472. undoIOSfix();
  1473. unsetAriaHidden();
  1474. }
  1475. removeBodyClasses();
  1476. }
  1477. function removeBodyClasses() {
  1478. removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
  1479. }
  1480. function close(resolveValue) {
  1481. const popup = getPopup();
  1482. if (!popup) {
  1483. return;
  1484. }
  1485. resolveValue = prepareResolveValue(resolveValue);
  1486. const innerParams = privateProps.innerParams.get(this);
  1487. if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
  1488. return;
  1489. }
  1490. const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
  1491. removeClass(popup, innerParams.showClass.popup);
  1492. addClass(popup, innerParams.hideClass.popup);
  1493. const backdrop = getContainer();
  1494. removeClass(backdrop, innerParams.showClass.backdrop);
  1495. addClass(backdrop, innerParams.hideClass.backdrop);
  1496. handlePopupAnimation(this, popup, innerParams); // Resolve Swal promise
  1497. swalPromiseResolve(resolveValue);
  1498. }
  1499. const prepareResolveValue = resolveValue => {
  1500. // When user calls Swal.close()
  1501. if (typeof resolveValue === 'undefined') {
  1502. return {
  1503. isConfirmed: false,
  1504. isDenied: false,
  1505. isDismissed: true
  1506. };
  1507. }
  1508. return Object.assign({
  1509. isConfirmed: false,
  1510. isDenied: false,
  1511. isDismissed: false
  1512. }, resolveValue);
  1513. };
  1514. const handlePopupAnimation = (instance, popup, innerParams) => {
  1515. const container = getContainer(); // If animation is supported, animate
  1516. const animationIsSupported = animationEndEvent && hasCssAnimation(popup);
  1517. if (typeof innerParams.willClose === 'function') {
  1518. innerParams.willClose(popup);
  1519. }
  1520. if (animationIsSupported) {
  1521. animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
  1522. } else {
  1523. // Otherwise, remove immediately
  1524. removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
  1525. }
  1526. };
  1527. const animatePopup = (instance, popup, container, returnFocus, didClose) => {
  1528. globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
  1529. popup.addEventListener(animationEndEvent, function (e) {
  1530. if (e.target === popup) {
  1531. globalState.swalCloseEventFinishedCallback();
  1532. delete globalState.swalCloseEventFinishedCallback;
  1533. }
  1534. });
  1535. };
  1536. const triggerDidCloseAndDispose = (instance, didClose) => {
  1537. setTimeout(() => {
  1538. if (typeof didClose === 'function') {
  1539. didClose.bind(instance.params)();
  1540. }
  1541. instance._destroy();
  1542. });
  1543. };
  1544. function setButtonsDisabled(instance, buttons, disabled) {
  1545. const domCache = privateProps.domCache.get(instance);
  1546. buttons.forEach(button => {
  1547. domCache[button].disabled = disabled;
  1548. });
  1549. }
  1550. function setInputDisabled(input, disabled) {
  1551. if (!input) {
  1552. return false;
  1553. }
  1554. if (input.type === 'radio') {
  1555. const radiosContainer = input.parentNode.parentNode;
  1556. const radios = radiosContainer.querySelectorAll('input');
  1557. for (let i = 0; i < radios.length; i++) {
  1558. radios[i].disabled = disabled;
  1559. }
  1560. } else {
  1561. input.disabled = disabled;
  1562. }
  1563. }
  1564. function enableButtons() {
  1565. setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
  1566. }
  1567. function disableButtons() {
  1568. setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
  1569. }
  1570. function enableInput() {
  1571. return setInputDisabled(this.getInput(), false);
  1572. }
  1573. function disableInput() {
  1574. return setInputDisabled(this.getInput(), true);
  1575. }
  1576. function showValidationMessage(error) {
  1577. const domCache = privateProps.domCache.get(this);
  1578. const params = privateProps.innerParams.get(this);
  1579. setInnerHtml(domCache.validationMessage, error);
  1580. domCache.validationMessage.className = swalClasses['validation-message'];
  1581. if (params.customClass && params.customClass.validationMessage) {
  1582. addClass(domCache.validationMessage, params.customClass.validationMessage);
  1583. }
  1584. show(domCache.validationMessage);
  1585. const input = this.getInput();
  1586. if (input) {
  1587. input.setAttribute('aria-invalid', true);
  1588. input.setAttribute('aria-describedby', swalClasses['validation-message']);
  1589. focusInput(input);
  1590. addClass(input, swalClasses.inputerror);
  1591. }
  1592. } // Hide block with validation message
  1593. function resetValidationMessage$1() {
  1594. const domCache = privateProps.domCache.get(this);
  1595. if (domCache.validationMessage) {
  1596. hide(domCache.validationMessage);
  1597. }
  1598. const input = this.getInput();
  1599. if (input) {
  1600. input.removeAttribute('aria-invalid');
  1601. input.removeAttribute('aria-describedby');
  1602. removeClass(input, swalClasses.inputerror);
  1603. }
  1604. }
  1605. function getProgressSteps$1() {
  1606. const domCache = privateProps.domCache.get(this);
  1607. return domCache.progressSteps;
  1608. }
  1609. class Timer {
  1610. constructor(callback, delay) {
  1611. this.callback = callback;
  1612. this.remaining = delay;
  1613. this.running = false;
  1614. this.start();
  1615. }
  1616. start() {
  1617. if (!this.running) {
  1618. this.running = true;
  1619. this.started = new Date();
  1620. this.id = setTimeout(this.callback, this.remaining);
  1621. }
  1622. return this.remaining;
  1623. }
  1624. stop() {
  1625. if (this.running) {
  1626. this.running = false;
  1627. clearTimeout(this.id);
  1628. this.remaining -= new Date() - this.started;
  1629. }
  1630. return this.remaining;
  1631. }
  1632. increase(n) {
  1633. const running = this.running;
  1634. if (running) {
  1635. this.stop();
  1636. }
  1637. this.remaining += n;
  1638. if (running) {
  1639. this.start();
  1640. }
  1641. return this.remaining;
  1642. }
  1643. getTimerLeft() {
  1644. if (this.running) {
  1645. this.stop();
  1646. this.start();
  1647. }
  1648. return this.remaining;
  1649. }
  1650. isRunning() {
  1651. return this.running;
  1652. }
  1653. }
  1654. var defaultInputValidators = {
  1655. email: (string, validationMessage) => {
  1656. return /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
  1657. },
  1658. url: (string, validationMessage) => {
  1659. // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
  1660. return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL');
  1661. }
  1662. };
  1663. function setDefaultInputValidators(params) {
  1664. // Use default `inputValidator` for supported input types if not provided
  1665. if (!params.inputValidator) {
  1666. Object.keys(defaultInputValidators).forEach(key => {
  1667. if (params.input === key) {
  1668. params.inputValidator = defaultInputValidators[key];
  1669. }
  1670. });
  1671. }
  1672. }
  1673. function validateCustomTargetElement(params) {
  1674. // Determine if the custom target element is valid
  1675. if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
  1676. warn('Target parameter is not valid, defaulting to "body"');
  1677. params.target = 'body';
  1678. }
  1679. }
  1680. /**
  1681. * Set type, text and actions on popup
  1682. *
  1683. * @param params
  1684. * @returns {boolean}
  1685. */
  1686. function setParameters(params) {
  1687. setDefaultInputValidators(params); // showLoaderOnConfirm && preConfirm
  1688. if (params.showLoaderOnConfirm && !params.preConfirm) {
  1689. warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request');
  1690. }
  1691. validateCustomTargetElement(params); // Replace newlines with <br> in title
  1692. if (typeof params.title === 'string') {
  1693. params.title = params.title.split('\n').join('<br />');
  1694. }
  1695. init(params);
  1696. }
  1697. const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
  1698. const getTemplateParams = params => {
  1699. const template = typeof params.template === 'string' ? document.querySelector(params.template) : params.template;
  1700. if (!template) {
  1701. return {};
  1702. }
  1703. const templateContent = template.content;
  1704. showWarningsForElements(templateContent);
  1705. const result = Object.assign(getSwalParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
  1706. return result;
  1707. };
  1708. const getSwalParams = templateContent => {
  1709. const result = {};
  1710. toArray(templateContent.querySelectorAll('swal-param')).forEach(param => {
  1711. showWarningsForAttributes(param, ['name', 'value']);
  1712. const paramName = param.getAttribute('name');
  1713. let value = param.getAttribute('value');
  1714. if (typeof defaultParams[paramName] === 'boolean' && value === 'false') {
  1715. value = false;
  1716. }
  1717. if (typeof defaultParams[paramName] === 'object') {
  1718. value = JSON.parse(value);
  1719. }
  1720. result[paramName] = value;
  1721. });
  1722. return result;
  1723. };
  1724. const getSwalButtons = templateContent => {
  1725. const result = {};
  1726. toArray(templateContent.querySelectorAll('swal-button')).forEach(button => {
  1727. showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
  1728. const type = button.getAttribute('type');
  1729. result["".concat(type, "ButtonText")] = button.innerHTML;
  1730. result["show".concat(capitalizeFirstLetter(type), "Button")] = true;
  1731. if (button.hasAttribute('color')) {
  1732. result["".concat(type, "ButtonColor")] = button.getAttribute('color');
  1733. }
  1734. if (button.hasAttribute('aria-label')) {
  1735. result["".concat(type, "ButtonAriaLabel")] = button.getAttribute('aria-label');
  1736. }
  1737. });
  1738. return result;
  1739. };
  1740. const getSwalImage = templateContent => {
  1741. const result = {};
  1742. const image = templateContent.querySelector('swal-image');
  1743. if (image) {
  1744. showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
  1745. if (image.hasAttribute('src')) {
  1746. result.imageUrl = image.getAttribute('src');
  1747. }
  1748. if (image.hasAttribute('width')) {
  1749. result.imageWidth = image.getAttribute('width');
  1750. }
  1751. if (image.hasAttribute('height')) {
  1752. result.imageHeight = image.getAttribute('height');
  1753. }
  1754. if (image.hasAttribute('alt')) {
  1755. result.imageAlt = image.getAttribute('alt');
  1756. }
  1757. }
  1758. return result;
  1759. };
  1760. const getSwalIcon = templateContent => {
  1761. const result = {};
  1762. const icon = templateContent.querySelector('swal-icon');
  1763. if (icon) {
  1764. showWarningsForAttributes(icon, ['type', 'color']);
  1765. if (icon.hasAttribute('type')) {
  1766. result.icon = icon.getAttribute('type');
  1767. }
  1768. if (icon.hasAttribute('color')) {
  1769. result.iconColor = icon.getAttribute('color');
  1770. }
  1771. result.iconHtml = icon.innerHTML;
  1772. }
  1773. return result;
  1774. };
  1775. const getSwalInput = templateContent => {
  1776. const result = {};
  1777. const input = templateContent.querySelector('swal-input');
  1778. if (input) {
  1779. showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
  1780. result.input = input.getAttribute('type') || 'text';
  1781. if (input.hasAttribute('label')) {
  1782. result.inputLabel = input.getAttribute('label');
  1783. }
  1784. if (input.hasAttribute('placeholder')) {
  1785. result.inputPlaceholder = input.getAttribute('placeholder');
  1786. }
  1787. if (input.hasAttribute('value')) {
  1788. result.inputValue = input.getAttribute('value');
  1789. }
  1790. }
  1791. const inputOptions = templateContent.querySelectorAll('swal-input-option');
  1792. if (inputOptions.length) {
  1793. result.inputOptions = {};
  1794. toArray(inputOptions).forEach(option => {
  1795. showWarningsForAttributes(option, ['value']);
  1796. const optionValue = option.getAttribute('value');
  1797. const optionName = option.innerHTML;
  1798. result.inputOptions[optionValue] = optionName;
  1799. });
  1800. }
  1801. return result;
  1802. };
  1803. const getSwalStringParams = (templateContent, paramNames) => {
  1804. const result = {};
  1805. for (const i in paramNames) {
  1806. const paramName = paramNames[i];
  1807. const tag = templateContent.querySelector(paramName);
  1808. if (tag) {
  1809. showWarningsForAttributes(tag, []);
  1810. result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
  1811. }
  1812. }
  1813. return result;
  1814. };
  1815. const showWarningsForElements = template => {
  1816. const allowedElements = swalStringParams.concat(['swal-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
  1817. toArray(template.children).forEach(el => {
  1818. const tagName = el.tagName.toLowerCase();
  1819. if (allowedElements.indexOf(tagName) === -1) {
  1820. warn("Unrecognized element <".concat(tagName, ">"));
  1821. }
  1822. });
  1823. };
  1824. const showWarningsForAttributes = (el, allowedAttributes) => {
  1825. toArray(el.attributes).forEach(attribute => {
  1826. if (allowedAttributes.indexOf(attribute.name) === -1) {
  1827. warn(["Unrecognized attribute \"".concat(attribute.name, "\" on <").concat(el.tagName.toLowerCase(), ">."), "".concat(allowedAttributes.length ? "Allowed attributes are: ".concat(allowedAttributes.join(', ')) : 'To set the value, use HTML within the element.')]);
  1828. }
  1829. });
  1830. };
  1831. const SHOW_CLASS_TIMEOUT = 10;
  1832. /**
  1833. * Open popup, add necessary classes and styles, fix scrollbar
  1834. *
  1835. * @param params
  1836. */
  1837. const openPopup = params => {
  1838. const container = getContainer();
  1839. const popup = getPopup();
  1840. if (typeof params.willOpen === 'function') {
  1841. params.willOpen(popup);
  1842. }
  1843. const bodyStyles = window.getComputedStyle(document.body);
  1844. const initialBodyOverflow = bodyStyles.overflowY;
  1845. addClasses$1(container, popup, params); // scrolling is 'hidden' until animation is done, after that 'auto'
  1846. setTimeout(() => {
  1847. setScrollingVisibility(container, popup);
  1848. }, SHOW_CLASS_TIMEOUT);
  1849. if (isModal()) {
  1850. fixScrollContainer(container, params.scrollbarPadding, initialBodyOverflow);
  1851. setAriaHidden();
  1852. }
  1853. if (!isToast() && !globalState.previousActiveElement) {
  1854. globalState.previousActiveElement = document.activeElement;
  1855. }
  1856. if (typeof params.didOpen === 'function') {
  1857. setTimeout(() => params.didOpen(popup));
  1858. }
  1859. removeClass(container, swalClasses['no-transition']);
  1860. };
  1861. const swalOpenAnimationFinished = event => {
  1862. const popup = getPopup();
  1863. if (event.target !== popup) {
  1864. return;
  1865. }
  1866. const container = getContainer();
  1867. popup.removeEventListener(animationEndEvent, swalOpenAnimationFinished);
  1868. container.style.overflowY = 'auto';
  1869. };
  1870. const setScrollingVisibility = (container, popup) => {
  1871. if (animationEndEvent && hasCssAnimation(popup)) {
  1872. container.style.overflowY = 'hidden';
  1873. popup.addEventListener(animationEndEvent, swalOpenAnimationFinished);
  1874. } else {
  1875. container.style.overflowY = 'auto';
  1876. }
  1877. };
  1878. const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
  1879. iOSfix();
  1880. if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
  1881. fixScrollbar();
  1882. } // sweetalert2/issues/1247
  1883. setTimeout(() => {
  1884. container.scrollTop = 0;
  1885. });
  1886. };
  1887. const addClasses$1 = (container, popup, params) => {
  1888. addClass(container, params.showClass.backdrop); // the workaround with setting/unsetting opacity is needed for #2019 and 2059
  1889. popup.style.setProperty('opacity', '0', 'important');
  1890. show(popup, 'grid');
  1891. setTimeout(() => {
  1892. // Animate popup right after showing it
  1893. addClass(popup, params.showClass.popup); // and remove the opacity workaround
  1894. popup.style.removeProperty('opacity');
  1895. }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
  1896. addClass([document.documentElement, document.body], swalClasses.shown);
  1897. if (params.heightAuto && params.backdrop && !params.toast) {
  1898. addClass([document.documentElement, document.body], swalClasses['height-auto']);
  1899. }
  1900. };
  1901. const handleInputOptionsAndValue = (instance, params) => {
  1902. if (params.input === 'select' || params.input === 'radio') {
  1903. handleInputOptions(instance, params);
  1904. } else if (['text', 'email', 'number', 'tel', 'textarea'].includes(params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
  1905. showLoading(getConfirmButton());
  1906. handleInputValue(instance, params);
  1907. }
  1908. };
  1909. const getInputValue = (instance, innerParams) => {
  1910. const input = instance.getInput();
  1911. if (!input) {
  1912. return null;
  1913. }
  1914. switch (innerParams.input) {
  1915. case 'checkbox':
  1916. return getCheckboxValue(input);
  1917. case 'radio':
  1918. return getRadioValue(input);
  1919. case 'file':
  1920. return getFileValue(input);
  1921. default:
  1922. return innerParams.inputAutoTrim ? input.value.trim() : input.value;
  1923. }
  1924. };
  1925. const getCheckboxValue = input => input.checked ? 1 : 0;
  1926. const getRadioValue = input => input.checked ? input.value : null;
  1927. const getFileValue = input => input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
  1928. const handleInputOptions = (instance, params) => {
  1929. const popup = getPopup();
  1930. const processInputOptions = inputOptions => populateInputOptions[params.input](popup, formatInputOptions(inputOptions), params);
  1931. if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
  1932. showLoading(getConfirmButton());
  1933. asPromise(params.inputOptions).then(inputOptions => {
  1934. instance.hideLoading();
  1935. processInputOptions(inputOptions);
  1936. });
  1937. } else if (typeof params.inputOptions === 'object') {
  1938. processInputOptions(params.inputOptions);
  1939. } else {
  1940. error("Unexpected type of inputOptions! Expected object, Map or Promise, got ".concat(typeof params.inputOptions));
  1941. }
  1942. };
  1943. const handleInputValue = (instance, params) => {
  1944. const input = instance.getInput();
  1945. hide(input);
  1946. asPromise(params.inputValue).then(inputValue => {
  1947. input.value = params.input === 'number' ? parseFloat(inputValue) || 0 : "".concat(inputValue);
  1948. show(input);
  1949. input.focus();
  1950. instance.hideLoading();
  1951. }).catch(err => {
  1952. error("Error in inputValue promise: ".concat(err));
  1953. input.value = '';
  1954. show(input);
  1955. input.focus();
  1956. instance.hideLoading();
  1957. });
  1958. };
  1959. const populateInputOptions = {
  1960. select: (popup, inputOptions, params) => {
  1961. const select = getChildByClass(popup, swalClasses.select);
  1962. const renderOption = (parent, optionLabel, optionValue) => {
  1963. const option = document.createElement('option');
  1964. option.value = optionValue;
  1965. setInnerHtml(option, optionLabel);
  1966. option.selected = isSelected(optionValue, params.inputValue);
  1967. parent.appendChild(option);
  1968. };
  1969. inputOptions.forEach(inputOption => {
  1970. const optionValue = inputOption[0];
  1971. const optionLabel = inputOption[1]; // <optgroup> spec:
  1972. // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
  1973. // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
  1974. // check whether this is a <optgroup>
  1975. if (Array.isArray(optionLabel)) {
  1976. // if it is an array, then it is an <optgroup>
  1977. const optgroup = document.createElement('optgroup');
  1978. optgroup.label = optionValue;
  1979. optgroup.disabled = false; // not configurable for now
  1980. select.appendChild(optgroup);
  1981. optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
  1982. } else {
  1983. // case of <option>
  1984. renderOption(select, optionLabel, optionValue);
  1985. }
  1986. });
  1987. select.focus();
  1988. },
  1989. radio: (popup, inputOptions, params) => {
  1990. const radio = getChildByClass(popup, swalClasses.radio);
  1991. inputOptions.forEach(inputOption => {
  1992. const radioValue = inputOption[0];
  1993. const radioLabel = inputOption[1];
  1994. const radioInput = document.createElement('input');
  1995. const radioLabelElement = document.createElement('label');
  1996. radioInput.type = 'radio';
  1997. radioInput.name = swalClasses.radio;
  1998. radioInput.value = radioValue;
  1999. if (isSelected(radioValue, params.inputValue)) {
  2000. radioInput.checked = true;
  2001. }
  2002. const label = document.createElement('span');
  2003. setInnerHtml(label, radioLabel);
  2004. label.className = swalClasses.label;
  2005. radioLabelElement.appendChild(radioInput);
  2006. radioLabelElement.appendChild(label);
  2007. radio.appendChild(radioLabelElement);
  2008. });
  2009. const radios = radio.querySelectorAll('input');
  2010. if (radios.length) {
  2011. radios[0].focus();
  2012. }
  2013. }
  2014. };
  2015. /**
  2016. * Converts `inputOptions` into an array of `[value, label]`s
  2017. * @param inputOptions
  2018. */
  2019. const formatInputOptions = inputOptions => {
  2020. const result = [];
  2021. if (typeof Map !== 'undefined' && inputOptions instanceof Map) {
  2022. inputOptions.forEach((value, key) => {
  2023. let valueFormatted = value;
  2024. if (typeof valueFormatted === 'object') {
  2025. // case of <optgroup>
  2026. valueFormatted = formatInputOptions(valueFormatted);
  2027. }
  2028. result.push([key, valueFormatted]);
  2029. });
  2030. } else {
  2031. Object.keys(inputOptions).forEach(key => {
  2032. let valueFormatted = inputOptions[key];
  2033. if (typeof valueFormatted === 'object') {
  2034. // case of <optgroup>
  2035. valueFormatted = formatInputOptions(valueFormatted);
  2036. }
  2037. result.push([key, valueFormatted]);
  2038. });
  2039. }
  2040. return result;
  2041. };
  2042. const isSelected = (optionValue, inputValue) => {
  2043. return inputValue && inputValue.toString() === optionValue.toString();
  2044. };
  2045. const handleConfirmButtonClick = instance => {
  2046. const innerParams = privateProps.innerParams.get(instance);
  2047. instance.disableButtons();
  2048. if (innerParams.input) {
  2049. handleConfirmOrDenyWithInput(instance, 'confirm');
  2050. } else {
  2051. confirm(instance, true);
  2052. }
  2053. };
  2054. const handleDenyButtonClick = instance => {
  2055. const innerParams = privateProps.innerParams.get(instance);
  2056. instance.disableButtons();
  2057. if (innerParams.returnInputValueOnDeny) {
  2058. handleConfirmOrDenyWithInput(instance, 'deny');
  2059. } else {
  2060. deny(instance, false);
  2061. }
  2062. };
  2063. const handleCancelButtonClick = (instance, dismissWith) => {
  2064. instance.disableButtons();
  2065. dismissWith(DismissReason.cancel);
  2066. };
  2067. const handleConfirmOrDenyWithInput = (instance, type
  2068. /* 'confirm' | 'deny' */
  2069. ) => {
  2070. const innerParams = privateProps.innerParams.get(instance);
  2071. const inputValue = getInputValue(instance, innerParams);
  2072. if (innerParams.inputValidator) {
  2073. handleInputValidator(instance, inputValue, type);
  2074. } else if (!instance.getInput().checkValidity()) {
  2075. instance.enableButtons();
  2076. instance.showValidationMessage(innerParams.validationMessage);
  2077. } else if (type === 'deny') {
  2078. deny(instance, inputValue);
  2079. } else {
  2080. confirm(instance, inputValue);
  2081. }
  2082. };
  2083. const handleInputValidator = (instance, inputValue, type
  2084. /* 'confirm' | 'deny' */
  2085. ) => {
  2086. const innerParams = privateProps.innerParams.get(instance);
  2087. instance.disableInput();
  2088. const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
  2089. validationPromise.then(validationMessage => {
  2090. instance.enableButtons();
  2091. instance.enableInput();
  2092. if (validationMessage) {
  2093. instance.showValidationMessage(validationMessage);
  2094. } else if (type === 'deny') {
  2095. deny(instance, inputValue);
  2096. } else {
  2097. confirm(instance, inputValue);
  2098. }
  2099. });
  2100. };
  2101. const deny = (instance, value) => {
  2102. const innerParams = privateProps.innerParams.get(instance || undefined);
  2103. if (innerParams.showLoaderOnDeny) {
  2104. showLoading(getDenyButton());
  2105. }
  2106. if (innerParams.preDeny) {
  2107. const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
  2108. preDenyPromise.then(preDenyValue => {
  2109. if (preDenyValue === false) {
  2110. instance.hideLoading();
  2111. } else {
  2112. instance.closePopup({
  2113. isDenied: true,
  2114. value: typeof preDenyValue === 'undefined' ? value : preDenyValue
  2115. });
  2116. }
  2117. });
  2118. } else {
  2119. instance.closePopup({
  2120. isDenied: true,
  2121. value
  2122. });
  2123. }
  2124. };
  2125. const succeedWith = (instance, value) => {
  2126. instance.closePopup({
  2127. isConfirmed: true,
  2128. value
  2129. });
  2130. };
  2131. const confirm = (instance, value) => {
  2132. const innerParams = privateProps.innerParams.get(instance || undefined);
  2133. if (innerParams.showLoaderOnConfirm) {
  2134. showLoading(); // TODO: make showLoading an *instance* method
  2135. }
  2136. if (innerParams.preConfirm) {
  2137. instance.resetValidationMessage();
  2138. const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
  2139. preConfirmPromise.then(preConfirmValue => {
  2140. if (isVisible(getValidationMessage()) || preConfirmValue === false) {
  2141. instance.hideLoading();
  2142. } else {
  2143. succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
  2144. }
  2145. });
  2146. } else {
  2147. succeedWith(instance, value);
  2148. }
  2149. };
  2150. const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
  2151. if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
  2152. globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
  2153. capture: globalState.keydownListenerCapture
  2154. });
  2155. globalState.keydownHandlerAdded = false;
  2156. }
  2157. if (!innerParams.toast) {
  2158. globalState.keydownHandler = e => keydownHandler(instance, e, dismissWith);
  2159. globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
  2160. globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
  2161. globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
  2162. capture: globalState.keydownListenerCapture
  2163. });
  2164. globalState.keydownHandlerAdded = true;
  2165. }
  2166. }; // Focus handling
  2167. const setFocus = (innerParams, index, increment) => {
  2168. const focusableElements = getFocusableElements(); // search for visible elements and select the next possible match
  2169. if (focusableElements.length) {
  2170. index = index + increment; // rollover to first item
  2171. if (index === focusableElements.length) {
  2172. index = 0; // go to last item
  2173. } else if (index === -1) {
  2174. index = focusableElements.length - 1;
  2175. }
  2176. return focusableElements[index].focus();
  2177. } // no visible focusable elements, focus the popup
  2178. getPopup().focus();
  2179. };
  2180. const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
  2181. const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
  2182. const keydownHandler = (instance, e, dismissWith) => {
  2183. const innerParams = privateProps.innerParams.get(instance);
  2184. if (!innerParams) {
  2185. return; // This instance has already been destroyed
  2186. }
  2187. if (innerParams.stopKeydownPropagation) {
  2188. e.stopPropagation();
  2189. } // ENTER
  2190. if (e.key === 'Enter') {
  2191. handleEnter(instance, e, innerParams); // TAB
  2192. } else if (e.key === 'Tab') {
  2193. handleTab(e, innerParams); // ARROWS - switch focus between buttons
  2194. } else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)) {
  2195. handleArrows(e.key); // ESC
  2196. } else if (e.key === 'Escape') {
  2197. handleEsc(e, innerParams, dismissWith);
  2198. }
  2199. };
  2200. const handleEnter = (instance, e, innerParams) => {
  2201. // #720 #721
  2202. if (e.isComposing) {
  2203. return;
  2204. }
  2205. if (e.target && instance.getInput() && e.target.outerHTML === instance.getInput().outerHTML) {
  2206. if (['textarea', 'file'].includes(innerParams.input)) {
  2207. return; // do not submit
  2208. }
  2209. clickConfirm();
  2210. e.preventDefault();
  2211. }
  2212. };
  2213. const handleTab = (e, innerParams) => {
  2214. const targetElement = e.target;
  2215. const focusableElements = getFocusableElements();
  2216. let btnIndex = -1;
  2217. for (let i = 0; i < focusableElements.length; i++) {
  2218. if (targetElement === focusableElements[i]) {
  2219. btnIndex = i;
  2220. break;
  2221. }
  2222. }
  2223. if (!e.shiftKey) {
  2224. // Cycle to the next button
  2225. setFocus(innerParams, btnIndex, 1);
  2226. } else {
  2227. // Cycle to the prev button
  2228. setFocus(innerParams, btnIndex, -1);
  2229. }
  2230. e.stopPropagation();
  2231. e.preventDefault();
  2232. };
  2233. const handleArrows = key => {
  2234. const confirmButton = getConfirmButton();
  2235. const denyButton = getDenyButton();
  2236. const cancelButton = getCancelButton();
  2237. if (![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
  2238. return;
  2239. }
  2240. const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
  2241. const buttonToFocus = document.activeElement[sibling];
  2242. if (buttonToFocus) {
  2243. buttonToFocus.focus();
  2244. }
  2245. };
  2246. const handleEsc = (e, innerParams, dismissWith) => {
  2247. if (callIfFunction(innerParams.allowEscapeKey)) {
  2248. e.preventDefault();
  2249. dismissWith(DismissReason.esc);
  2250. }
  2251. };
  2252. const handlePopupClick = (instance, domCache, dismissWith) => {
  2253. const innerParams = privateProps.innerParams.get(instance);
  2254. if (innerParams.toast) {
  2255. handleToastClick(instance, domCache, dismissWith);
  2256. } else {
  2257. // Ignore click events that had mousedown on the popup but mouseup on the container
  2258. // This can happen when the user drags a slider
  2259. handleModalMousedown(domCache); // Ignore click events that had mousedown on the container but mouseup on the popup
  2260. handleContainerMousedown(domCache);
  2261. handleModalClick(instance, domCache, dismissWith);
  2262. }
  2263. };
  2264. const handleToastClick = (instance, domCache, dismissWith) => {
  2265. // Closing toast by internal click
  2266. domCache.popup.onclick = () => {
  2267. const innerParams = privateProps.innerParams.get(instance);
  2268. if (innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton || innerParams.timer || innerParams.input) {
  2269. return;
  2270. }
  2271. dismissWith(DismissReason.close);
  2272. };
  2273. };
  2274. let ignoreOutsideClick = false;
  2275. const handleModalMousedown = domCache => {
  2276. domCache.popup.onmousedown = () => {
  2277. domCache.container.onmouseup = function (e) {
  2278. domCache.container.onmouseup = undefined; // We only check if the mouseup target is the container because usually it doesn't
  2279. // have any other direct children aside of the popup
  2280. if (e.target === domCache.container) {
  2281. ignoreOutsideClick = true;
  2282. }
  2283. };
  2284. };
  2285. };
  2286. const handleContainerMousedown = domCache => {
  2287. domCache.container.onmousedown = () => {
  2288. domCache.popup.onmouseup = function (e) {
  2289. domCache.popup.onmouseup = undefined; // We also need to check if the mouseup target is a child of the popup
  2290. if (e.target === domCache.popup || domCache.popup.contains(e.target)) {
  2291. ignoreOutsideClick = true;
  2292. }
  2293. };
  2294. };
  2295. };
  2296. const handleModalClick = (instance, domCache, dismissWith) => {
  2297. domCache.container.onclick = e => {
  2298. const innerParams = privateProps.innerParams.get(instance);
  2299. if (ignoreOutsideClick) {
  2300. ignoreOutsideClick = false;
  2301. return;
  2302. }
  2303. if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
  2304. dismissWith(DismissReason.backdrop);
  2305. }
  2306. };
  2307. };
  2308. function _main(userParams, mixinParams = {}) {
  2309. showWarningsForParams(Object.assign({}, mixinParams, userParams));
  2310. if (globalState.currentInstance) {
  2311. globalState.currentInstance._destroy();
  2312. if (isModal()) {
  2313. unsetAriaHidden();
  2314. }
  2315. }
  2316. globalState.currentInstance = this;
  2317. const innerParams = prepareParams(userParams, mixinParams);
  2318. setParameters(innerParams);
  2319. Object.freeze(innerParams); // clear the previous timer
  2320. if (globalState.timeout) {
  2321. globalState.timeout.stop();
  2322. delete globalState.timeout;
  2323. } // clear the restore focus timeout
  2324. clearTimeout(globalState.restoreFocusTimeout);
  2325. const domCache = populateDomCache(this);
  2326. render(this, innerParams);
  2327. privateProps.innerParams.set(this, innerParams);
  2328. return swalPromise(this, domCache, innerParams);
  2329. }
  2330. const prepareParams = (userParams, mixinParams) => {
  2331. const templateParams = getTemplateParams(userParams);
  2332. const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
  2333. params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
  2334. params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
  2335. return params;
  2336. };
  2337. const swalPromise = (instance, domCache, innerParams) => {
  2338. return new Promise(resolve => {
  2339. // functions to handle all closings/dismissals
  2340. const dismissWith = dismiss => {
  2341. instance.closePopup({
  2342. isDismissed: true,
  2343. dismiss
  2344. });
  2345. };
  2346. privateMethods.swalPromiseResolve.set(instance, resolve);
  2347. domCache.confirmButton.onclick = () => handleConfirmButtonClick(instance);
  2348. domCache.denyButton.onclick = () => handleDenyButtonClick(instance);
  2349. domCache.cancelButton.onclick = () => handleCancelButtonClick(instance, dismissWith);
  2350. domCache.closeButton.onclick = () => dismissWith(DismissReason.close);
  2351. handlePopupClick(instance, domCache, dismissWith);
  2352. addKeydownHandler(instance, globalState, innerParams, dismissWith);
  2353. handleInputOptionsAndValue(instance, innerParams);
  2354. openPopup(innerParams);
  2355. setupTimer(globalState, innerParams, dismissWith);
  2356. initFocus(domCache, innerParams); // Scroll container to top on open (#1247, #1946)
  2357. setTimeout(() => {
  2358. domCache.container.scrollTop = 0;
  2359. });
  2360. });
  2361. };
  2362. const populateDomCache = instance => {
  2363. const domCache = {
  2364. popup: getPopup(),
  2365. container: getContainer(),
  2366. actions: getActions(),
  2367. confirmButton: getConfirmButton(),
  2368. denyButton: getDenyButton(),
  2369. cancelButton: getCancelButton(),
  2370. loader: getLoader(),
  2371. closeButton: getCloseButton(),
  2372. validationMessage: getValidationMessage(),
  2373. progressSteps: getProgressSteps()
  2374. };
  2375. privateProps.domCache.set(instance, domCache);
  2376. return domCache;
  2377. };
  2378. const setupTimer = (globalState$$1, innerParams, dismissWith) => {
  2379. const timerProgressBar = getTimerProgressBar();
  2380. hide(timerProgressBar);
  2381. if (innerParams.timer) {
  2382. globalState$$1.timeout = new Timer(() => {
  2383. dismissWith('timer');
  2384. delete globalState$$1.timeout;
  2385. }, innerParams.timer);
  2386. if (innerParams.timerProgressBar) {
  2387. show(timerProgressBar);
  2388. setTimeout(() => {
  2389. if (globalState$$1.timeout && globalState$$1.timeout.running) {
  2390. // timer can be already stopped or unset at this point
  2391. animateTimerProgressBar(innerParams.timer);
  2392. }
  2393. });
  2394. }
  2395. }
  2396. };
  2397. const initFocus = (domCache, innerParams) => {
  2398. if (innerParams.toast) {
  2399. return;
  2400. }
  2401. if (!callIfFunction(innerParams.allowEnterKey)) {
  2402. return blurActiveElement();
  2403. }
  2404. if (!focusButton(domCache, innerParams)) {
  2405. setFocus(innerParams, -1, 1);
  2406. }
  2407. };
  2408. const focusButton = (domCache, innerParams) => {
  2409. if (innerParams.focusDeny && isVisible(domCache.denyButton)) {
  2410. domCache.denyButton.focus();
  2411. return true;
  2412. }
  2413. if (innerParams.focusCancel && isVisible(domCache.cancelButton)) {
  2414. domCache.cancelButton.focus();
  2415. return true;
  2416. }
  2417. if (innerParams.focusConfirm && isVisible(domCache.confirmButton)) {
  2418. domCache.confirmButton.focus();
  2419. return true;
  2420. }
  2421. return false;
  2422. };
  2423. const blurActiveElement = () => {
  2424. if (document.activeElement && typeof document.activeElement.blur === 'function') {
  2425. document.activeElement.blur();
  2426. }
  2427. };
  2428. /**
  2429. * Updates popup parameters.
  2430. */
  2431. function update(params) {
  2432. const popup = getPopup();
  2433. const innerParams = privateProps.innerParams.get(this);
  2434. if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
  2435. return warn("You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.");
  2436. }
  2437. const validUpdatableParams = {}; // assign valid params from `params` to `defaults`
  2438. Object.keys(params).forEach(param => {
  2439. if (Swal.isUpdatableParameter(param)) {
  2440. validUpdatableParams[param] = params[param];
  2441. } else {
  2442. warn("Invalid parameter to update: \"".concat(param, "\". Updatable params are listed here: https://github.com/sweetalert2/sweetalert2/blob/master/src/utils/params.js\n\nIf you think this parameter should be updatable, request it here: https://github.com/sweetalert2/sweetalert2/issues/new?template=02_feature_request.md"));
  2443. }
  2444. });
  2445. const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
  2446. render(this, updatedParams);
  2447. privateProps.innerParams.set(this, updatedParams);
  2448. Object.defineProperties(this, {
  2449. params: {
  2450. value: Object.assign({}, this.params, params),
  2451. writable: false,
  2452. enumerable: true
  2453. }
  2454. });
  2455. }
  2456. function _destroy() {
  2457. const domCache = privateProps.domCache.get(this);
  2458. const innerParams = privateProps.innerParams.get(this);
  2459. if (!innerParams) {
  2460. return; // This instance has already been destroyed
  2461. } // Check if there is another Swal closing
  2462. if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
  2463. globalState.swalCloseEventFinishedCallback();
  2464. delete globalState.swalCloseEventFinishedCallback;
  2465. } // Check if there is a swal disposal defer timer
  2466. if (globalState.deferDisposalTimer) {
  2467. clearTimeout(globalState.deferDisposalTimer);
  2468. delete globalState.deferDisposalTimer;
  2469. }
  2470. if (typeof innerParams.didDestroy === 'function') {
  2471. innerParams.didDestroy();
  2472. }
  2473. disposeSwal(this);
  2474. }
  2475. const disposeSwal = instance => {
  2476. // Unset this.params so GC will dispose it (#1569)
  2477. delete instance.params; // Unset globalState props so GC will dispose globalState (#1569)
  2478. delete globalState.keydownHandler;
  2479. delete globalState.keydownTarget; // Unset WeakMaps so GC will be able to dispose them (#1569)
  2480. unsetWeakMaps(privateProps);
  2481. unsetWeakMaps(privateMethods); // Unset currentInstance
  2482. delete globalState.currentInstance;
  2483. };
  2484. const unsetWeakMaps = obj => {
  2485. for (const i in obj) {
  2486. obj[i] = new WeakMap();
  2487. }
  2488. };
  2489. var instanceMethods = /*#__PURE__*/Object.freeze({
  2490. hideLoading: hideLoading,
  2491. disableLoading: hideLoading,
  2492. getInput: getInput$1,
  2493. close: close,
  2494. closePopup: close,
  2495. closeModal: close,
  2496. closeToast: close,
  2497. enableButtons: enableButtons,
  2498. disableButtons: disableButtons,
  2499. enableInput: enableInput,
  2500. disableInput: disableInput,
  2501. showValidationMessage: showValidationMessage,
  2502. resetValidationMessage: resetValidationMessage$1,
  2503. getProgressSteps: getProgressSteps$1,
  2504. _main: _main,
  2505. update: update,
  2506. _destroy: _destroy
  2507. });
  2508. let currentInstance;
  2509. class SweetAlert {
  2510. constructor(...args) {
  2511. // Prevent run in Node env
  2512. if (typeof window === 'undefined') {
  2513. return;
  2514. }
  2515. currentInstance = this;
  2516. const outerParams = Object.freeze(this.constructor.argsToParams(args));
  2517. Object.defineProperties(this, {
  2518. params: {
  2519. value: outerParams,
  2520. writable: false,
  2521. enumerable: true,
  2522. configurable: true
  2523. }
  2524. });
  2525. const promise = this._main(this.params);
  2526. privateProps.promise.set(this, promise);
  2527. } // `catch` cannot be the name of a module export, so we define our thenable methods here instead
  2528. then(onFulfilled) {
  2529. const promise = privateProps.promise.get(this);
  2530. return promise.then(onFulfilled);
  2531. }
  2532. finally(onFinally) {
  2533. const promise = privateProps.promise.get(this);
  2534. return promise.finally(onFinally);
  2535. }
  2536. } // Assign instance methods from src/instanceMethods/*.js to prototype
  2537. Object.assign(SweetAlert.prototype, instanceMethods); // Assign static methods from src/staticMethods/*.js to constructor
  2538. Object.assign(SweetAlert, staticMethods); // Proxy to instance methods to constructor, for now, for backwards compatibility
  2539. Object.keys(instanceMethods).forEach(key => {
  2540. SweetAlert[key] = function (...args) {
  2541. if (currentInstance) {
  2542. return currentInstance[key](...args);
  2543. }
  2544. };
  2545. });
  2546. SweetAlert.DismissReason = DismissReason;
  2547. SweetAlert.version = '11.1.5';
  2548. const Swal = SweetAlert;
  2549. Swal.default = Swal;
  2550. return Swal;
  2551. }));
  2552. if (typeof this !== 'undefined' && this.Sweetalert2){ this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
  2553. "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,".swal2-popup.swal2-toast{box-sizing:border-box;grid-column:1/4!important;grid-row:1/4!important;grid-template-columns:1fr 99fr 1fr;padding:1em;overflow-y:hidden;background:#fff;box-shadow:0 0 .625em #d9d9d9;pointer-events:all}.swal2-popup.swal2-toast>*{grid-column:2}.swal2-popup.swal2-toast .swal2-title{margin:1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-loading{justify-content:center}.swal2-popup.swal2-toast .swal2-input{height:2em;margin:.5em;font-size:1em}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em}.swal2-popup.swal2-toast .swal2-footer{margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-popup.swal2-toast .swal2-close{grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-popup.swal2-toast .swal2-html-container{margin:1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0}.swal2-popup.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-popup.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:700}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-popup.swal2-toast .swal2-actions{justify-content:flex-start;height:auto;margin:0;margin-top:.3125em;padding:0}.swal2-popup.swal2-toast .swal2-styled{margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-popup.swal2-toast .swal2-styled:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px rgba(100,150,200,.5)}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;transform:rotate(45deg);border-radius:50%}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.8em;left:-.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{-webkit-animation:swal2-toast-animate-success-line-tip .75s;animation:swal2-toast-animate-success-line-tip .75s}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{-webkit-animation:swal2-toast-animate-success-line-long .75s;animation:swal2-toast-animate-success-line-long .75s}.swal2-popup.swal2-toast.swal2-show{-webkit-animation:swal2-toast-show .5s;animation:swal2-toast-show .5s}.swal2-popup.swal2-toast.swal2-hide{-webkit-animation:swal2-toast-hide .1s forwards;animation:swal2-toast-hide .1s forwards}.swal2-container{display:grid;position:fixed;z-index:1060;top:0;right:0;bottom:0;left:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(-webkit-min-content,auto) minmax(-webkit-min-content,auto) minmax(-webkit-min-content,auto);grid-template-rows:minmax(min-content,auto) minmax(min-content,auto) minmax(min-content,auto);height:100%;padding:.625em;overflow-x:hidden;transition:background-color .1s;-webkit-overflow-scrolling:touch}.swal2-container.swal2-backdrop-show,.swal2-container.swal2-noanimation{background:rgba(0,0,0,.4)}.swal2-container.swal2-backdrop-hide{background:0 0!important}.swal2-container.swal2-bottom-start,.swal2-container.swal2-center-start,.swal2-container.swal2-top-start{grid-template-columns:minmax(0,1fr) auto auto}.swal2-container.swal2-bottom,.swal2-container.swal2-center,.swal2-container.swal2-top{grid-template-columns:auto minmax(0,1fr) auto}.swal2-container.swal2-bottom-end,.swal2-container.swal2-center-end,.swal2-container.swal2-top-end{grid-template-columns:auto auto minmax(0,1fr)}.swal2-container.swal2-top-start>.swal2-popup{align-self:start}.swal2-container.swal2-top>.swal2-popup{grid-column:2;align-self:start;justify-self:center}.swal2-container.swal2-top-end>.swal2-popup,.swal2-container.swal2-top-right>.swal2-popup{grid-column:3;align-self:start;justify-self:end}.swal2-container.swal2-center-left>.swal2-popup,.swal2-container.swal2-center-start>.swal2-popup{grid-row:2;align-self:center}.swal2-container.swal2-center>.swal2-popup{grid-column:2;grid-row:2;align-self:center;justify-self:center}.swal2-container.swal2-center-end>.swal2-popup,.swal2-container.swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;align-self:center;justify-self:end}.swal2-container.swal2-bottom-left>.swal2-popup,.swal2-container.swal2-bottom-start>.swal2-popup{grid-column:1;grid-row:3;align-self:end}.swal2-container.swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;justify-self:center;align-self:end}.swal2-container.swal2-bottom-end>.swal2-popup,.swal2-container.swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;align-self:end;justify-self:end}.swal2-container.swal2-grow-fullscreen>.swal2-popup,.swal2-container.swal2-grow-row>.swal2-popup{grid-column:1/4;width:100%}.swal2-container.swal2-grow-column>.swal2-popup,.swal2-container.swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}.swal2-container.swal2-no-transition{transition:none!important}.swal2-popup{display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0,100%);width:32em;max-width:100%;padding:0 0 1.25em;border:none;border-radius:5px;background:#fff;color:#545454;font-family:inherit;font-size:1rem}.swal2-popup:focus{outline:0}.swal2-popup.swal2-loading{overflow-y:hidden}.swal2-title{position:relative;max-width:100%;margin:0;padding:.8em 1em 0;color:#595959;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-wrap:break-word}.swal2-actions{display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:center;width:auto;margin:1.25em auto 0;padding:0}.swal2-actions:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}.swal2-actions:not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1))}.swal2-actions:not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0,0,0,.2),rgba(0,0,0,.2))}.swal2-loader{display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;-webkit-animation:swal2-rotate-loading 1.5s linear 0s infinite normal;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 transparent #2778c4 transparent}.swal2-styled{margin:.3125em;padding:.625em 1.1em;transition:box-shadow .1s;box-shadow:0 0 0 3px transparent;font-weight:500}.swal2-styled:not([disabled]){cursor:pointer}.swal2-styled.swal2-confirm{border:0;border-radius:.25em;background:initial;background-color:#7367f0;color:#fff;font-size:1em}.swal2-styled.swal2-confirm:focus{box-shadow:0 0 0 3px rgba(115,103,240,.5)}.swal2-styled.swal2-deny{border:0;border-radius:.25em;background:initial;background-color:#ea5455;color:#fff;font-size:1em}.swal2-styled.swal2-deny:focus{box-shadow:0 0 0 3px rgba(234,84,85,.5)}.swal2-styled.swal2-cancel{border:0;border-radius:.25em;background:initial;background-color:#6e7d88;color:#fff;font-size:1em}.swal2-styled.swal2-cancel:focus{box-shadow:0 0 0 3px rgba(110,125,136,.5)}.swal2-styled.swal2-default-outline:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5)}.swal2-styled:focus{outline:0}.swal2-styled::-moz-focus-inner{border:0}.swal2-footer{justify-content:center;margin:1em 0 0;padding:1em 1em 0;border-top:1px solid #eee;color:#545454;font-size:1em}.swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto!important;height:.25em;overflow:hidden;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.swal2-timer-progress-bar{width:100%;height:.25em;background:rgba(0,0,0,.2)}.swal2-image{max-width:100%;margin:2em auto 1em}.swal2-close{z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:color .1s,box-shadow .1s;border:none;border-radius:5px;background:0 0;color:#ccc;font-family:serif;font-family:monospace;font-size:2.5em;cursor:pointer;justify-self:end}.swal2-close:hover{transform:none;background:0 0;color:#f27474}.swal2-close:focus{outline:0;box-shadow:inset 0 0 0 3px rgba(100,150,200,.5)}.swal2-close::-moz-focus-inner{border:0}.swal2-html-container{z-index:1;justify-content:center;margin:1em 1.6em .3em;padding:0;overflow:auto;color:#545454;font-size:1.125em;font-weight:400;line-height:normal;text-align:center;word-wrap:break-word;word-break:break-word}.swal2-checkbox,.swal2-file,.swal2-input,.swal2-radio,.swal2-select,.swal2-textarea{margin:1em 2em 0}.swal2-file,.swal2-input,.swal2-textarea{box-sizing:border-box;width:auto;transition:border-color .1s,box-shadow .1s;border:1px solid #d9d9d9;border-radius:.1875em;background:inherit;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px transparent;color:inherit;font-size:1.125em}.swal2-file.swal2-inputerror,.swal2-input.swal2-inputerror,.swal2-textarea.swal2-inputerror{border-color:#f27474!important;box-shadow:0 0 2px #f27474!important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{border:1px solid #b4dbed;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px rgba(100,150,200,.5)}.swal2-file::-moz-placeholder,.swal2-input::-moz-placeholder,.swal2-textarea::-moz-placeholder{color:#ccc}.swal2-file:-ms-input-placeholder,.swal2-input:-ms-input-placeholder,.swal2-textarea:-ms-input-placeholder{color:#ccc}.swal2-file::placeholder,.swal2-input::placeholder,.swal2-textarea::placeholder{color:#ccc}.swal2-range{margin:1em 2em 0;background:#fff}.swal2-range input{width:80%}.swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}.swal2-range input,.swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}.swal2-input{height:2.625em;padding:0 .75em}.swal2-file{width:75%;margin-right:auto;margin-left:auto;background:inherit;font-size:1.125em}.swal2-textarea{height:6.75em;padding:.75em}.swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:inherit;color:inherit;font-size:1.125em}.swal2-checkbox,.swal2-radio{align-items:center;justify-content:center;background:#fff;color:inherit}.swal2-checkbox label,.swal2-radio label{margin:0 .6em;font-size:1.125em}.swal2-checkbox input,.swal2-radio input{flex-shrink:0;margin:0 .4em}.swal2-input-label{display:flex;justify-content:center;margin:1em auto 0}.swal2-validation-message{align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:#f0f0f0;color:#666;font-size:1em;font-weight:300}.swal2-validation-message::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}.swal2-icon{position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;border:.25em solid transparent;border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}.swal2-icon.swal2-error{border-color:#f27474;color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{position:relative;flex-grow:1}.swal2-icon.swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}.swal2-icon.swal2-error.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-error.swal2-icon-show .swal2-x-mark{-webkit-animation:swal2-animate-error-x-mark .5s;animation:swal2-animate-error-x-mark .5s}.swal2-icon.swal2-warning{border-color:#facea8;color:#f8bb86}.swal2-icon.swal2-info{border-color:#9de0f6;color:#3fc3ee}.swal2-icon.swal2-question{border-color:#c9dae1;color:#87adbd}.swal2-icon.swal2-success{border-color:#a5dc86;color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;transform:rotate(45deg);border-radius:50%}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}.swal2-icon.swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-.25em;left:-.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}.swal2-icon.swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}.swal2-icon.swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-tip{-webkit-animation:swal2-animate-success-line-tip .75s;animation:swal2-animate-success-line-tip .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-long{-webkit-animation:swal2-animate-success-line-long .75s;animation:swal2-animate-success-line-long .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-circular-line-right{-webkit-animation:swal2-rotate-success-circular-line 4.25s ease-in;animation:swal2-rotate-success-circular-line 4.25s ease-in}.swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:inherit;font-weight:600}.swal2-progress-steps li{display:inline-block;position:relative}.swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:#add8e6;color:#fff}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:#add8e6}.swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}[class^=swal2]{-webkit-tap-highlight-color:transparent}.swal2-show{-webkit-animation:swal2-show .3s;animation:swal2-show .3s}.swal2-hide{-webkit-animation:swal2-hide .15s forwards;animation:swal2-hide .15s forwards}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}@-webkit-keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0)}}@keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0)}}@-webkit-keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@-webkit-keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@-webkit-keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}@-webkit-keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@-webkit-keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@-webkit-keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@-webkit-keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@-webkit-keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@-webkit-keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@-webkit-keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@-webkit-keyframes swal2-rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes swal2-rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px rgba(0,0,0,.4)}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static!important}}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:transparent;pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{top:0;right:auto;bottom:auto;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{top:0;right:0;bottom:auto;left:auto}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{top:0;right:auto;bottom:auto;left:0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{top:50%;right:auto;bottom:auto;left:0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{top:50%;right:auto;bottom:auto;left:50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{top:50%;right:0;bottom:auto;left:auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{top:auto;right:auto;bottom:0;left:0}body.swal2-toast-shown .swal2-container.swal2-bottom{top:auto;right:auto;bottom:0;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{top:auto;right:0;bottom:0;left:auto}");