PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.0
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.0
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / dist / js / admin / admin-courses.js

admin-courses.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.0, at assets/dist/js/admin/admin-courses.js

7,021 lines 250.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/admin/courses/generate-with-ai.js"
5 /*!*********************************************************!*\
6 !*** ./assets/src/js/admin/courses/generate-with-ai.js ***!
7 \*********************************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ CreateCourseViaAI: () => (/* binding */ CreateCourseViaAI)
14 /* harmony export */ });
15 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
16 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
17 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_1__);
18 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
19 /**
20 * Create course with AI
21 */
22
23
24
25
26 let lp_structure_course;
27 let lp_is_generating_course_data = false;
28 const lp_course_ai_setting = JSON.parse(localStorage.getItem('lp_course_ai_setting')) || {};
29 class CreateCourseViaAI {
30 constructor(options = {}) {
31 this.options = {
32 autoInsertButton: true,
33 isCourseBuilder: false,
34 redirectDelayMs: 2000,
35 ...options
36 };
37 this.init();
38 }
39 static selectors = {
40 elGenerateDataAiWrap: '.lp-generate-data-ai-wrap'
41 };
42 init() {
43 if (this.options.autoInsertButton) {
44 if (!lpData?.enable_open_ai) {
45 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady('.page-title-action', el => {
46 el.insertAdjacentHTML('afterend', `<button type="button" class="lp-btn-warning-enable-ai lp-btn-ai-style">
47 <i class="lp-ico-ai"></i>
48 <span>${lpData.i18n.generate_with_ai}</span>
49 </button>`);
50 });
51 } else {
52 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady('.page-title-action', el => {
53 el.insertAdjacentHTML('afterend', `<button type="button" class="lp-btn-generate-course-with-ai lp-btn-ai-style">
54 <i class="lp-ico-ai"></i>
55 <span>${lpData.i18n.generate_with_ai}</span>
56 </button>`);
57 });
58 }
59 }
60 this.events();
61 }
62 events() {
63 if (CreateCourseViaAI._loadedEvents) {
64 return;
65 }
66 CreateCourseViaAI._loadedEvents = true;
67 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
68 selector: '.lp-btn-warning-enable-ai',
69 class: this,
70 callBack: this.showPopupEnableAI.name
71 }, {
72 selector: '.lp-btn-generate-course-with-ai',
73 class: this,
74 callBack: this.showPopupCreateFullCourse.name
75 }, {
76 selector: '.lp-btn-step',
77 class: this,
78 callBack: this.showStep.name
79 }, {
80 selector: '.lp-btn-generate-prompt',
81 class: this,
82 callBack: this.generatePrompt.name
83 }, {
84 selector: '.lp-btn-call-open-ai',
85 class: this,
86 callBack: this.generateDataCourse.name
87 }, {
88 selector: '.lp-btn-create-course',
89 class: this,
90 callBack: this.createCourse.name
91 }, {
92 selector: '.lp-btn-close-ai-popup',
93 //class: this,
94 callBack: args => {
95 const {
96 e,
97 target
98 } = args;
99 const message = lpData?.i18n?.confirm_close_ai || 'Are you sure you want to close? Generate data will stop.';
100 if (!lp_is_generating_course_data) {
101 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().close();
102 } else if (confirm(message)) {
103 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().close();
104 }
105
106 // Testing custom confirm box
107 /*if ( confirm( message ) ) {
108 SweetAlert.close();
109 }*/
110 }
111 }]);
112 }
113
114 // Show popup warning enable AI before using.
115 showPopupEnableAI() {
116 const modalTemplate = document.querySelector('#lp-tmpl-must-enable-ai');
117 if (!modalTemplate) {
118 console.error('Enable OpenAI Modal Template not found!');
119 return;
120 }
121 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().fire({
122 html: modalTemplate.innerHTML,
123 width: '420px',
124 showCloseButton: false,
125 showConfirmButton: false
126 });
127 }
128 showPopupCreateFullCourse() {
129 const modalTemplate = document.querySelector('#lp-tmpl-create-course-ai');
130 if (!modalTemplate) {
131 console.error('AI Create Full Course Modal Template not found!');
132 return;
133 }
134 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().fire({
135 html: modalTemplate.innerHTML,
136 width: '60%',
137 showCloseButton: false,
138 showConfirmButton: false,
139 allowOutsideClick: false,
140 allowEscapeKey: false,
141 didOpen: () => {
142 const popup = sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().getPopup();
143 popup.click();
144 const targetAudience = popup.querySelector('select[name="target_audience"]');
145 if (targetAudience && lp_course_ai_setting?.target_audience) {
146 targetAudience.tomselect.setValue(lp_course_ai_setting.target_audience);
147 }
148 const tone = popup.querySelector('select[name="tone"]');
149 if (tone && lp_course_ai_setting?.tone) {
150 tone.tomselect.setValue(lp_course_ai_setting.tone);
151 }
152 const language = popup.querySelector('select[name="language"]');
153 if (language && lp_course_ai_setting?.language) {
154 language.tomselect.setValue(lp_course_ai_setting.language);
155 }
156 targetAudience.addEventListener('change', event => {
157 lp_course_ai_setting.target_audience = targetAudience.tomselect.getValue();
158 localStorage.setItem('lp_course_ai_setting', JSON.stringify(lp_course_ai_setting));
159 });
160 tone.addEventListener('change', event => {
161 lp_course_ai_setting.tone = tone.tomselect.getValue();
162 localStorage.setItem('lp_course_ai_setting', JSON.stringify(lp_course_ai_setting));
163 });
164 language.addEventListener('change', event => {
165 const value = language.tomselect.getValue();
166 lp_course_ai_setting.language = value ? [value] : [];
167 localStorage.setItem('lp_course_ai_setting', JSON.stringify(lp_course_ai_setting));
168 });
169 }
170 }).then(result => {
171 if (result.isDismissed) {
172 if (lp_is_generating_course_data) {
173 lp_is_generating_course_data = false;
174 }
175 }
176 });
177 }
178 showStep(args) {
179 const {
180 e,
181 target
182 } = args;
183 e.preventDefault();
184 const elBtnActions = target.closest('.button-actions');
185 const elCreateCourseAIWrap = elBtnActions.closest(CreateCourseViaAI.selectors.elGenerateDataAiWrap);
186 let step = parseInt(elBtnActions.dataset.step);
187 const stepAction = target.dataset.action;
188 if (stepAction === 'next') {
189 step++;
190 } else if (stepAction === 'prev') {
191 step--;
192 }
193 elBtnActions.dataset.step = step;
194 const elForm = target.closest('form');
195 const elContentStep = elForm.querySelector(`.step-content[data-step="${step}"]`);
196 const elItemStep = elCreateCourseAIWrap.querySelector(`.step-item[data-step="${step}"]`);
197 elForm.querySelectorAll('.step-content').forEach(el => el.classList.remove('active'));
198 elContentStep.classList.add('active');
199 elCreateCourseAIWrap.querySelectorAll('.step-item').forEach(el => el.classList.remove('active'));
200 elItemStep.classList.add('active');
201
202 // Get all buttons step to show/hide
203 const form = target.closest('form');
204 const elBtnSteps = form.querySelectorAll('button[data-step-show]');
205 elBtnSteps.forEach(el => {
206 const stepsShow = el.dataset.stepShow.split(',').map(s => parseInt(s.trim()));
207 if (stepsShow.includes(step)) {
208 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(el, 1);
209 } else {
210 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(el, 0);
211 }
212 });
213 }
214
215 /**
216 * Create prompt from data config
217 * @param args
218 */
219 generatePrompt(args) {
220 const {
221 e,
222 target
223 } = args;
224 e.preventDefault();
225 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, true);
226
227 // Get dataSend
228 const form = target.closest('form');
229 let dataSend = JSON.parse(target.dataset.send);
230 dataSend = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(form, dataSend);
231
232 // Ajax to generate prompt
233 const callBack = {
234 success: response => {
235 const {
236 message,
237 status,
238 data
239 } = response;
240 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(message, status);
241 if (status === 'success') {
242 const elBtnNext = form.querySelector('.lp-btn-step[data-action=next]');
243 elBtnNext.click();
244 const elPromptTextarea = form.querySelector('textarea[name=lp-openai-prompt-generated-field]');
245 elPromptTextarea.value = data;
246 }
247 },
248 error: error => {
249 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(error, 'error');
250 },
251 completed: () => {
252 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, false);
253 }
254 };
255 window.lpAJAXG.fetchAJAX(dataSend, callBack);
256 }
257
258 /**
259 * Submit prompt to OpenAI to generate course data
260 * @param args
261 */
262 generateDataCourse(args) {
263 const {
264 e,
265 target
266 } = args;
267 e.preventDefault();
268 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, true);
269
270 // Get dataSend
271 const form = target.closest('form');
272 let dataSend = JSON.parse(target.dataset.send);
273 dataSend = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(form, dataSend);
274 const btnPrev = form.querySelector('.lp-btn-step[data-action=prev]');
275 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(btnPrev, 0);
276
277 // Ajax to generate prompt
278 const callBack = {
279 success: response => {
280 const {
281 message,
282 status,
283 data
284 } = response;
285 if (lp_is_generating_course_data) {
286 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(message, status);
287 }
288 if (status === 'success') {
289 // Save structure data
290 lp_structure_course = data.lp_structure_course;
291
292 // Set preview HTML
293 const elResults = form.querySelector('.lp-ai-generated-results');
294 elResults.innerHTML = data.lp_html_preview;
295 const elBtnNext = form.querySelector('.lp-btn-step[data-action=next]');
296 elBtnNext.click();
297 }
298 },
299 error: error => {
300 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(error, 'error');
301 },
302 completed: () => {
303 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, false);
304 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(btnPrev, 1);
305 lp_is_generating_course_data = false;
306 }
307 };
308 lp_is_generating_course_data = true;
309 window.lpAJAXG.fetchAJAX(dataSend, callBack);
310 }
311
312 /**
313 * Create course with data of OpenAI
314 * @param args
315 */
316 createCourse(args) {
317 const {
318 e,
319 target
320 } = args;
321 e.preventDefault();
322 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, true);
323
324 // Get dataSend
325 const dataSend = JSON.parse(target.dataset.send);
326 dataSend.lp_structure_course = lp_structure_course;
327 if (this.options.isCourseBuilder) {
328 dataSend.is_course_builder = 1;
329 }
330 const form = target.closest('form');
331 const elBtnPrev = form.querySelector('.lp-btn-step[data-action=prev]');
332 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnPrev, 0);
333 const windowWidth = window.outerWidth;
334 let alertWidth;
335 if (windowWidth < 768) {
336 alertWidth = '90%';
337 } else {
338 alertWidth = '30%';
339 }
340 const creatingCourseAiModal = document.querySelector('#lp-tmpl-creating-course-ai');
341 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().fire({
342 html: creatingCourseAiModal.innerHTML,
343 showCloseButton: false,
344 showConfirmButton: false,
345 allowOutsideClick: false,
346 width: alertWidth
347 });
348
349 // Ajax to generate prompt
350 const callBack = {
351 success: response => {
352 const {
353 message,
354 status,
355 data
356 } = response;
357 sweetalert2__WEBPACK_IMPORTED_MODULE_1___default().close();
358 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(message, status);
359 if (status === 'success') {
360 setTimeout(() => {
361 window.location.href = data.edit_course_url;
362 }, this.options.redirectDelayMs);
363 } else {
364 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnPrev, 1);
365 }
366 },
367 error: error => {
368 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_2__.show(error, 'error');
369 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnPrev, 1);
370 },
371 completed: () => {
372 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(target, false);
373 }
374 };
375 window.lpAJAXG.fetchAJAX(dataSend, callBack);
376 }
377 }
378
379 /***/ },
380
381 /***/ "./assets/src/js/admin/courses/view-students-modal.js"
382 /*!************************************************************!*\
383 !*** ./assets/src/js/admin/courses/view-students-modal.js ***!
384 \************************************************************/
385 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
386
387 "use strict";
388 __webpack_require__.r(__webpack_exports__);
389 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
390 /* harmony export */ ViewStudentsModal: () => (/* binding */ ViewStudentsModal)
391 /* harmony export */ });
392 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
393 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_0__);
394 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
395
396
397 class ViewStudentsModal {
398 constructor() {
399 this.isRequesting = false;
400 this.activeCourseId = 0;
401 this.init();
402 }
403 static selectors = {
404 wrap: '#lp-modal-enrolled-wrap',
405 form: '#lp-modal-enrolled-form',
406 toolbarTemplate: '#lp-tmpl-enrolled-students-toolbar-modal',
407 targetTemplate: '#lp-tmpl-enrolled-students-target-modal',
408 toolbar: '.lp-enrolled-students-table-toolbar--modal',
409 courseTrigger: '.lp-btn-view-students',
410 searchInput: '#lp-modal-enrolled-search-input',
411 startDateInput: '#lp-modal-enrolled-filter-start-date',
412 endDateInput: '#lp-modal-enrolled-filter-end-date',
413 searchBtn: '.lp-enrolled-btn-search-modal',
414 clearBtn: '.lp-enrolled-btn-clear-modal',
415 modalSearchFields: '#lp-modal-enrolled-search-input, #lp-modal-enrolled-filter-start-date, #lp-modal-enrolled-filter-end-date'
416 };
417 setButtonLoadingState(btn, isLoading) {
418 if (!btn) {
419 return;
420 }
421 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(btn, isLoading ? 1 : 0);
422 btn.disabled = !!isLoading;
423 }
424 init() {
425 if (ViewStudentsModal._loadedEvents) {
426 return;
427 }
428 ViewStudentsModal._loadedEvents = true;
429 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('click', [{
430 selector: ViewStudentsModal.selectors.courseTrigger,
431 class: this,
432 callBack: this.handleOpenModal.name
433 }, {
434 selector: ViewStudentsModal.selectors.searchBtn,
435 class: this,
436 callBack: this.handleModalSearch.name
437 }, {
438 selector: ViewStudentsModal.selectors.clearBtn,
439 class: this,
440 callBack: this.handleModalClear.name
441 }]);
442 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('keydown', [{
443 selector: ViewStudentsModal.selectors.modalSearchFields,
444 class: this,
445 callBack: this.handleModalSearchOnEnter.name,
446 checkIsEventEnter: true
447 }]);
448 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('change', [{
449 selector: ViewStudentsModal.selectors.startDateInput,
450 class: this,
451 callBack: this.checkDatesRange.name
452 }, {
453 selector: ViewStudentsModal.selectors.endDateInput,
454 class: this,
455 callBack: this.checkDatesRange.name
456 }]);
457 }
458 handleOpenModal(args) {
459 const btn = args?.target?.closest(ViewStudentsModal.selectors.courseTrigger);
460 if (!btn || this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
461 return;
462 }
463 const courseId = parseInt(btn.dataset.courseId, 10) || 0;
464 if (!courseId) {
465 return;
466 }
467 const courseTitle = btn.dataset.courseTitle || '';
468 this.activeCourseId = courseId;
469 this.setButtonLoadingState(btn, true);
470 this.openModal(courseId, courseTitle, btn);
471 }
472 handleModalSearch(args) {
473 const btn = args?.target?.closest(ViewStudentsModal.selectors.searchBtn);
474 if (!btn || !this.activeCourseId) {
475 return;
476 }
477 if (args?.e) {
478 args.e.preventDefault();
479 }
480 if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
481 return;
482 }
483 this.setButtonLoadingState(btn, true);
484 this.loadEnrolledStudents(this.activeCourseId, 1, btn);
485 }
486 handleModalSearchOnEnter(args) {
487 if (args?.e) {
488 args.e.preventDefault();
489 }
490 const form = this.getModalForm();
491 if (!form) {
492 return;
493 }
494 const btn = form.querySelector(ViewStudentsModal.selectors.searchBtn);
495 if (!btn) {
496 return;
497 }
498 this.handleModalSearch({
499 ...args,
500 target: btn
501 });
502 }
503 handleModalClear(args) {
504 const btn = args?.target?.closest(ViewStudentsModal.selectors.clearBtn);
505 const form = this.getModalForm();
506 if (!btn || !form || !this.activeCourseId) {
507 return;
508 }
509 if (args?.e) {
510 args.e.preventDefault();
511 }
512 if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
513 return;
514 }
515 form.reset();
516 this.setButtonLoadingState(btn, true);
517 this.loadEnrolledStudents(this.activeCourseId, 1, btn);
518 }
519 getModalPopup() {
520 return (sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().getPopup) ? sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().getPopup() : null;
521 }
522 getModalToolbarHtml() {
523 const template = document.querySelector(ViewStudentsModal.selectors.toolbarTemplate);
524 return template ? template.innerHTML : '';
525 }
526 getModalTargetHtml() {
527 const template = document.querySelector(ViewStudentsModal.selectors.targetTemplate);
528 return template ? template.innerHTML : '';
529 }
530 getAjaxHandle() {
531 const ajaxHandle = window.lpAJAXG;
532 if (!ajaxHandle || typeof ajaxHandle.getDataSetCurrent !== 'function' || typeof ajaxHandle.setDataSetCurrent !== 'function' || typeof ajaxHandle.showHideLoading !== 'function' || typeof ajaxHandle.fetchAJAX !== 'function') {
533 return null;
534 }
535 return ajaxHandle;
536 }
537 getModalForm() {
538 const popup = this.getModalPopup();
539 if (!popup) {
540 return null;
541 }
542 return popup.querySelector(ViewStudentsModal.selectors.form);
543 }
544 getModalFilterArgs(dataArgs = {}) {
545 const form = this.getModalForm();
546 if (!form) {
547 return dataArgs;
548 }
549 return lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.mergeDataWithDatForm(form, dataArgs);
550 }
551 loadEnrolledStudents(courseId, paged, elLoading = null) {
552 const wrap = document.querySelector(ViewStudentsModal.selectors.wrap);
553 const elTarget = wrap?.querySelector('.lp-target');
554 const ajaxHandle = this.getAjaxHandle();
555 if (!wrap || !elTarget || !ajaxHandle || this.isRequesting) {
556 return;
557 }
558 this.isRequesting = true;
559 if (elLoading) {
560 this.setButtonLoadingState(elLoading, true);
561 }
562 const dataSend = ajaxHandle.getDataSetCurrent(elTarget);
563 dataSend.args = this.getModalFilterArgs(dataSend.args || {});
564 dataSend.args.course_id = parseInt(courseId, 10) || 0;
565 dataSend.args.paged = paged;
566 ajaxHandle.setDataSetCurrent(elTarget, dataSend);
567 ajaxHandle.showHideLoading(elTarget, 1);
568 const callBack = {
569 success: response => {
570 elTarget.innerHTML = response.data.content;
571 },
572 error: err => {
573 console.error(err);
574 },
575 completed: () => {
576 this.isRequesting = false;
577 ajaxHandle.showHideLoading(elTarget, 0);
578 if (elLoading) {
579 this.setButtonLoadingState(elLoading, false);
580 }
581 }
582 };
583 ajaxHandle.fetchAJAX(dataSend, callBack);
584 }
585 openModal(courseId, courseTitle, elTrigger = null) {
586 const modalToolbarHtml = this.getModalToolbarHtml();
587 const modalTargetHtml = this.getModalTargetHtml();
588 if (!modalToolbarHtml || !modalTargetHtml) {
589 if (elTrigger) {
590 this.setButtonLoadingState(elTrigger, false);
591 }
592 return;
593 }
594 this.activeCourseId = parseInt(courseId, 10) || 0;
595 sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().fire({
596 title: `${courseTitle}`,
597 html: modalToolbarHtml + modalTargetHtml,
598 width: '80%',
599 showConfirmButton: false,
600 showCloseButton: true,
601 didOpen: () => {
602 this.loadEnrolledStudents(this.activeCourseId, 1, elTrigger);
603 },
604 didClose: () => {
605 this.activeCourseId = 0;
606 if (elTrigger) {
607 this.setButtonLoadingState(elTrigger, false);
608 }
609 }
610 });
611 }
612
613 // Ensure start date is not after end date and vice versa. If invalid, adjust the other date to match.
614 checkDatesRange(args) {
615 const {
616 e
617 } = args;
618 const elInput = e?.target;
619 if (!elInput) {
620 return;
621 }
622 const elForm = elInput.closest(ViewStudentsModal.selectors.form);
623 if (!elForm) {
624 return;
625 }
626 const startDateInput = elForm.querySelector(ViewStudentsModal.selectors.startDateInput);
627 const endDateInput = elForm.querySelector(ViewStudentsModal.selectors.endDateInput);
628 if (elInput === startDateInput) {
629 if (startDateInput.value) {
630 endDateInput.min = startDateInput.value;
631 if (endDateInput.value && endDateInput.value < startDateInput.value) {
632 endDateInput.value = startDateInput.value;
633 }
634 } else {
635 endDateInput.min = '';
636 }
637 } else if (elInput === endDateInput) {
638 if (endDateInput.value) {
639 startDateInput.max = endDateInput.value;
640 if (startDateInput.value && startDateInput.value > endDateInput.value) {
641 startDateInput.value = endDateInput.value;
642 }
643 } else {
644 startDateInput.max = '';
645 }
646 }
647 }
648 }
649
650 /***/ },
651
652 /***/ "./assets/src/js/lpToastify.js"
653 /*!*************************************!*\
654 !*** ./assets/src/js/lpToastify.js ***!
655 \*************************************/
656 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
657
658 "use strict";
659 __webpack_require__.r(__webpack_exports__);
660 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
661 /* harmony export */ show: () => (/* binding */ show)
662 /* harmony export */ });
663 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
664 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
665 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
666 /**
667 * Utils functions
668 *
669 * @param url
670 * @param data
671 * @param functions
672 * @since 4.3.0
673 * @version 1.0.0
674 */
675
676
677 const argsToastify = {
678 text: '',
679 gravity: lpData.toast.gravity,
680 // `top` or `bottom`
681 position: lpData.toast.position,
682 // `left`, `center` or `right`
683 className: `${lpData.toast.classPrefix}`,
684 close: lpData.toast.close == 1,
685 stopOnFocus: lpData.toast.stopOnFocus == 1,
686 duration: lpData.toast.duration
687 };
688 const show = (message, status = 'success', argsCustom) => {
689 let args = argsToastify;
690 if (argsCustom) {
691 args = {
692 ...args,
693 ...argsCustom
694 };
695 }
696 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
697 ...args,
698 text: message,
699 className: `${lpData.toast.classPrefix} ${status}`
700 });
701 toastify.showToast();
702 };
703
704 /***/ },
705
706 /***/ "./assets/src/js/utils.js"
707 /*!********************************!*\
708 !*** ./assets/src/js/utils.js ***!
709 \********************************/
710 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
711
712 "use strict";
713 __webpack_require__.r(__webpack_exports__);
714 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
715 /* harmony export */ debounce: () => (/* binding */ debounce),
716 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
717 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
718 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
719 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
720 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
721 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
722 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
723 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
724 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
725 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
726 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
727 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
728 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
729 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
730 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
731 /* harmony export */ });
732 /**
733 * Utils functions
734 *
735 * @param url
736 * @param data
737 * @param functions
738 * @since 4.2.5.1
739 * @version 1.0.6
740 */
741 const lpClassName = {
742 hidden: 'lp-hidden',
743 loading: 'loading',
744 elCollapse: 'lp-collapse',
745 elSectionToggle: '.lp-section-toggle',
746 elTriggerToggle: '.lp-trigger-toggle'
747 };
748 const lpFetchAPI = (url, data = {}, functions = {}) => {
749 if ('function' === typeof functions.before) {
750 functions.before();
751 }
752 fetch(url, {
753 method: 'GET',
754 ...data
755 }).then(response => response.json()).then(response => {
756 if ('function' === typeof functions.success) {
757 functions.success(response);
758 }
759 }).catch(err => {
760 if ('function' === typeof functions.error) {
761 functions.error(err);
762 }
763 }).finally(() => {
764 if ('function' === typeof functions.completed) {
765 functions.completed();
766 }
767 });
768 };
769
770 /**
771 * Get current URL without params.
772 *
773 * @since 4.2.5.1
774 */
775 const lpGetCurrentURLNoParam = () => {
776 let currentUrl = window.location.href;
777 const hasParams = currentUrl.includes('?');
778 if (hasParams) {
779 currentUrl = currentUrl.split('?')[0];
780 }
781 return currentUrl;
782 };
783 const lpAddQueryArgs = (endpoint, args) => {
784 const url = new URL(endpoint);
785 Object.keys(args).forEach(arg => {
786 url.searchParams.set(arg, args[arg]);
787 });
788 return url;
789 };
790
791 /**
792 * Listen element viewed.
793 *
794 * @param el
795 * @param callback
796 * @since 4.2.5.8
797 */
798 const listenElementViewed = (el, callback) => {
799 const observerSeeItem = new IntersectionObserver(function (entries) {
800 for (const entry of entries) {
801 if (entry.isIntersecting) {
802 callback(entry);
803 }
804 }
805 });
806 observerSeeItem.observe(el);
807 };
808
809 /**
810 * Listen element created.
811 *
812 * @param callback
813 * @since 4.2.5.8
814 */
815 const listenElementCreated = callback => {
816 const observerCreateItem = new MutationObserver(function (mutations) {
817 mutations.forEach(function (mutation) {
818 if (mutation.addedNodes) {
819 mutation.addedNodes.forEach(function (node) {
820 if (node.nodeType === 1) {
821 callback(node);
822 }
823 });
824 }
825 });
826 });
827 observerCreateItem.observe(document, {
828 childList: true,
829 subtree: true
830 });
831 // End.
832 };
833
834 /**
835 * Listen element created.
836 *
837 * @param selector
838 * @param callback
839 * @since 4.2.7.1
840 */
841 const lpOnElementReady = (selector, callback) => {
842 const element = document.querySelector(selector);
843 if (element) {
844 callback(element);
845 return;
846 }
847 const observer = new MutationObserver((mutations, obs) => {
848 const element = document.querySelector(selector);
849 if (element) {
850 obs.disconnect();
851 callback(element);
852 }
853 });
854 observer.observe(document.documentElement, {
855 childList: true,
856 subtree: true
857 });
858 };
859
860 // Parse JSON from string with content include LP_AJAX_START.
861 const lpAjaxParseJsonOld = data => {
862 if (typeof data !== 'string') {
863 return data;
864 }
865 const m = String.raw({
866 raw: data
867 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
868 try {
869 if (m) {
870 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
871 } else {
872 data = JSON.parse(data);
873 }
874 } catch (e) {
875 data = {};
876 }
877 return data;
878 };
879
880 // status 0: hide, 1: show
881 const lpShowHideEl = (el, status = 0) => {
882 if (!el) {
883 return;
884 }
885 if (!status) {
886 el.classList.add(lpClassName.hidden);
887 } else {
888 el.classList.remove(lpClassName.hidden);
889 }
890 };
891
892 // status 0: hide, 1: show
893 const lpSetLoadingEl = (el, status) => {
894 if (!el) {
895 return;
896 }
897 if (!status) {
898 el.classList.remove(lpClassName.loading);
899 } else {
900 el.classList.add(lpClassName.loading);
901 }
902 };
903
904 // Toggle collapse section
905 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
906 if (!elTriggerClassName) {
907 elTriggerClassName = lpClassName.elTriggerToggle;
908 }
909
910 // Exclude elements, which should not trigger the collapse toggle
911 if (elsExclude && elsExclude.length > 0) {
912 for (const elExclude of elsExclude) {
913 if (target.closest(elExclude)) {
914 return;
915 }
916 }
917 }
918 const elTrigger = target.closest(elTriggerClassName);
919 if (!elTrigger) {
920 return;
921 }
922
923 //console.log( 'elTrigger', elTrigger );
924
925 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
926 if (!elSectionToggle) {
927 return;
928 }
929 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
930 if ('function' === typeof callback) {
931 callback(elSectionToggle);
932 }
933 };
934
935 // Get data of form
936 const getDataOfForm = form => {
937 const dataSend = {};
938 const formData = new FormData(form);
939 for (const pair of formData.entries()) {
940 const key = pair[0];
941 const value = formData.getAll(key);
942 if (!dataSend.hasOwnProperty(key)) {
943 // Convert value array to string.
944 dataSend[key] = value.join(',');
945 }
946 }
947 return dataSend;
948 };
949
950 // Get field keys of form
951 const getFieldKeysOfForm = form => {
952 const keys = [];
953 const elements = form.elements;
954 for (let i = 0; i < elements.length; i++) {
955 const name = elements[i].name;
956 if (name && !keys.includes(name)) {
957 keys.push(name);
958 }
959 }
960 return keys;
961 };
962
963 // Merge data handle with data form.
964 const mergeDataWithDatForm = (elForm, dataHandle) => {
965 const dataForm = getDataOfForm(elForm);
966 const keys = getFieldKeysOfForm(elForm);
967 keys.forEach(key => {
968 if (!dataForm.hasOwnProperty(key)) {
969 delete dataHandle[key];
970 } else if (dataForm[key][0] === '') {
971 delete dataForm[key];
972 delete dataHandle[key];
973 }
974 });
975 dataHandle = {
976 ...dataHandle,
977 ...dataForm
978 };
979 return dataHandle;
980 };
981
982 /**
983 * Event trigger
984 * For each list of event handlers, listen event on document.
985 *
986 * eventName: 'click', 'change', ...
987 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
988 *
989 * @param eventName
990 * @param eventHandlers
991 */
992 const eventHandlers = (eventName, eventHandlers) => {
993 document.addEventListener(eventName, e => {
994 const target = e.target;
995 let args = {
996 e,
997 target
998 };
999 eventHandlers.forEach(eventHandler => {
1000 args = {
1001 ...args,
1002 ...eventHandler
1003 };
1004
1005 //console.log( args );
1006
1007 // Check condition before call back
1008 if (eventHandler.conditionBeforeCallBack) {
1009 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1010 return;
1011 }
1012 }
1013
1014 // Special check for keydown event with checkIsEventEnter = true
1015 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1016 if (e.key !== 'Enter') {
1017 return;
1018 }
1019 }
1020 if (target.closest(eventHandler.selector)) {
1021 if (eventHandler.class) {
1022 // Call method of class, function callBack will understand exactly {this} is class object.
1023 eventHandler.class[eventHandler.callBack](args);
1024 } else {
1025 // For send args is objected, {this} is eventHandler object, not class object.
1026 eventHandler.callBack(args);
1027 }
1028 }
1029 });
1030 });
1031 };
1032
1033 /**
1034 * Debounce - delays function execution until after `wait` ms of inactivity.
1035 *
1036 * Each call resets the timer. Only the last call in a burst executes.
1037 *
1038 * USE CASES:
1039 * - Search inputs, form validation, window resize
1040 * - Multiple elements need independent timers
1041 * - When you need to call with different arguments
1042 *
1043 * EXAMPLES:
1044 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1045 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1046 *
1047 * const debouncedResize = debounce( recalculateLayout, 250 );
1048 * window.addEventListener('resize', debouncedResize);
1049 *
1050 * ⚠️ Create ONCE outside event handlers, not inside.
1051 *
1052 * @param {Function} func - Function to debounce (can be anonymous)
1053 * @param {number} wait - Milliseconds to wait (default: 500)
1054 * @return {Function} Debounced wrapper function
1055 * @since 4.3.7
1056 * @version 1.0.0
1057 */
1058 const debounce = (func, wait = 500) => {
1059 let timer;
1060 return args => {
1061 clearTimeout(timer);
1062 timer = setTimeout(() => func(args), wait);
1063 };
1064 };
1065
1066 /***/ },
1067
1068 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1069 /*!*****************************************************************************************!*\
1070 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1071 \*****************************************************************************************/
1072 (module, __webpack_exports__, __webpack_require__) {
1073
1074 "use strict";
1075 __webpack_require__.r(__webpack_exports__);
1076 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1077 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1078 /* harmony export */ });
1079 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
1080 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
1081 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
1082 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
1083 // Imports
1084
1085
1086 var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
1087 // Module
1088 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1089 * Toastify js 1.12.0
1090 * https://github.com/apvarun/toastify-js
1091 * @license MIT licensed
1092 *
1093 * Copyright (C) 2018 Varun A P
1094 */
1095
1096 .toastify {
1097 padding: 12px 20px;
1098 color: #ffffff;
1099 display: inline-block;
1100 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1101 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1102 background: linear-gradient(135deg, #73a5ff, #5477f5);
1103 position: fixed;
1104 opacity: 0;
1105 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1106 border-radius: 2px;
1107 cursor: pointer;
1108 text-decoration: none;
1109 max-width: calc(50% - 20px);
1110 z-index: 2147483647;
1111 }
1112
1113 .toastify.on {
1114 opacity: 1;
1115 }
1116
1117 .toast-close {
1118 background: transparent;
1119 border: 0;
1120 color: white;
1121 cursor: pointer;
1122 font-family: inherit;
1123 font-size: 1em;
1124 opacity: 0.4;
1125 padding: 0 5px;
1126 }
1127
1128 .toastify-right {
1129 right: 15px;
1130 }
1131
1132 .toastify-left {
1133 left: 15px;
1134 }
1135
1136 .toastify-top {
1137 top: -150px;
1138 }
1139
1140 .toastify-bottom {
1141 bottom: -150px;
1142 }
1143
1144 .toastify-rounded {
1145 border-radius: 25px;
1146 }
1147
1148 .toastify-avatar {
1149 width: 1.5em;
1150 height: 1.5em;
1151 margin: -7px 5px;
1152 border-radius: 2px;
1153 }
1154
1155 .toastify-center {
1156 margin-left: auto;
1157 margin-right: auto;
1158 left: 0;
1159 right: 0;
1160 max-width: fit-content;
1161 max-width: -moz-fit-content;
1162 }
1163
1164 @media only screen and (max-width: 360px) {
1165 .toastify-right, .toastify-left {
1166 margin-left: auto;
1167 margin-right: auto;
1168 left: 0;
1169 right: 0;
1170 max-width: fit-content;
1171 }
1172 }
1173 `, "",{"version":3,"sources":["webpack://./node_modules/toastify-js/src/toastify.css"],"names":[],"mappings":"AAAA;;;;;;EAME;;AAEF;IACI,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,uFAAuF;IACvF,6DAA6D;IAC7D,qDAAqD;IACrD,eAAe;IACf,UAAU;IACV,wDAAwD;IACxD,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,2BAA2B;IAC3B,mBAAmB;AACvB;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,uBAAuB;IACvB,SAAS;IACT,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,cAAc;AAClB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,sBAAsB;IACtB,2BAA2B;AAC/B;;AAEA;IACI;QACI,iBAAiB;QACjB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,sBAAsB;IAC1B;AACJ","sourcesContent":["/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n"],"sourceRoot":""}]);
1174 // Exports
1175 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1176
1177
1178 /***/ },
1179
1180 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1181 /*!*****************************************************!*\
1182 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1183 \*****************************************************/
1184 (module) {
1185
1186 "use strict";
1187
1188
1189 /*
1190 MIT License http://www.opensource.org/licenses/mit-license.php
1191 Author Tobias Koppers @sokra
1192 */
1193 module.exports = function (cssWithMappingToString) {
1194 var list = [];
1195
1196 // return the list of modules as css string
1197 list.toString = function toString() {
1198 return this.map(function (item) {
1199 var content = "";
1200 var needLayer = typeof item[5] !== "undefined";
1201 if (item[4]) {
1202 content += "@supports (".concat(item[4], ") {");
1203 }
1204 if (item[2]) {
1205 content += "@media ".concat(item[2], " {");
1206 }
1207 if (needLayer) {
1208 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1209 }
1210 content += cssWithMappingToString(item);
1211 if (needLayer) {
1212 content += "}";
1213 }
1214 if (item[2]) {
1215 content += "}";
1216 }
1217 if (item[4]) {
1218 content += "}";
1219 }
1220 return content;
1221 }).join("");
1222 };
1223
1224 // import a list of modules into the list
1225 list.i = function i(modules, media, dedupe, supports, layer) {
1226 if (typeof modules === "string") {
1227 modules = [[null, modules, undefined]];
1228 }
1229 var alreadyImportedModules = {};
1230 if (dedupe) {
1231 for (var k = 0; k < this.length; k++) {
1232 var id = this[k][0];
1233 if (id != null) {
1234 alreadyImportedModules[id] = true;
1235 }
1236 }
1237 }
1238 for (var _k = 0; _k < modules.length; _k++) {
1239 var item = [].concat(modules[_k]);
1240 if (dedupe && alreadyImportedModules[item[0]]) {
1241 continue;
1242 }
1243 if (typeof layer !== "undefined") {
1244 if (typeof item[5] === "undefined") {
1245 item[5] = layer;
1246 } else {
1247 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1248 item[5] = layer;
1249 }
1250 }
1251 if (media) {
1252 if (!item[2]) {
1253 item[2] = media;
1254 } else {
1255 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1256 item[2] = media;
1257 }
1258 }
1259 if (supports) {
1260 if (!item[4]) {
1261 item[4] = "".concat(supports);
1262 } else {
1263 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1264 item[4] = supports;
1265 }
1266 }
1267 list.push(item);
1268 }
1269 };
1270 return list;
1271 };
1272
1273 /***/ },
1274
1275 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1276 /*!************************************************************!*\
1277 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1278 \************************************************************/
1279 (module) {
1280
1281 "use strict";
1282
1283
1284 module.exports = function (item) {
1285 var content = item[1];
1286 var cssMapping = item[3];
1287 if (!cssMapping) {
1288 return content;
1289 }
1290 if (typeof btoa === "function") {
1291 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1292 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1293 var sourceMapping = "/*# ".concat(data, " */");
1294 return [content].concat([sourceMapping]).join("\n");
1295 }
1296 return [content].join("\n");
1297 };
1298
1299 /***/ },
1300
1301 /***/ "./node_modules/toastify-js/src/toastify.css"
1302 /*!***************************************************!*\
1303 !*** ./node_modules/toastify-js/src/toastify.css ***!
1304 \***************************************************/
1305 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1306
1307 "use strict";
1308 __webpack_require__.r(__webpack_exports__);
1309 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1310 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1311 /* harmony export */ });
1312 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
1313 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
1314 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");
1315 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);
1316 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");
1317 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);
1318 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");
1319 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);
1320 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");
1321 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);
1322 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");
1323 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);
1324 /* harmony import */ var _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./toastify.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css");
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336 var options = {};
1337
1338 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1339 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1340
1341 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1342
1343 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1344 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1345
1346 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
1347
1348
1349
1350
1351 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
1352
1353
1354 /***/ },
1355
1356 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1357 /*!****************************************************************************!*\
1358 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1359 \****************************************************************************/
1360 (module) {
1361
1362 "use strict";
1363
1364
1365 var stylesInDOM = [];
1366 function getIndexByIdentifier(identifier) {
1367 var result = -1;
1368 for (var i = 0; i < stylesInDOM.length; i++) {
1369 if (stylesInDOM[i].identifier === identifier) {
1370 result = i;
1371 break;
1372 }
1373 }
1374 return result;
1375 }
1376 function modulesToDom(list, options) {
1377 var idCountMap = {};
1378 var identifiers = [];
1379 for (var i = 0; i < list.length; i++) {
1380 var item = list[i];
1381 var id = options.base ? item[0] + options.base : item[0];
1382 var count = idCountMap[id] || 0;
1383 var identifier = "".concat(id, " ").concat(count);
1384 idCountMap[id] = count + 1;
1385 var indexByIdentifier = getIndexByIdentifier(identifier);
1386 var obj = {
1387 css: item[1],
1388 media: item[2],
1389 sourceMap: item[3],
1390 supports: item[4],
1391 layer: item[5]
1392 };
1393 if (indexByIdentifier !== -1) {
1394 stylesInDOM[indexByIdentifier].references++;
1395 stylesInDOM[indexByIdentifier].updater(obj);
1396 } else {
1397 var updater = addElementStyle(obj, options);
1398 options.byIndex = i;
1399 stylesInDOM.splice(i, 0, {
1400 identifier: identifier,
1401 updater: updater,
1402 references: 1
1403 });
1404 }
1405 identifiers.push(identifier);
1406 }
1407 return identifiers;
1408 }
1409 function addElementStyle(obj, options) {
1410 var api = options.domAPI(options);
1411 api.update(obj);
1412 var updater = function updater(newObj) {
1413 if (newObj) {
1414 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1415 return;
1416 }
1417 api.update(obj = newObj);
1418 } else {
1419 api.remove();
1420 }
1421 };
1422 return updater;
1423 }
1424 module.exports = function (list, options) {
1425 options = options || {};
1426 list = list || [];
1427 var lastIdentifiers = modulesToDom(list, options);
1428 return function update(newList) {
1429 newList = newList || [];
1430 for (var i = 0; i < lastIdentifiers.length; i++) {
1431 var identifier = lastIdentifiers[i];
1432 var index = getIndexByIdentifier(identifier);
1433 stylesInDOM[index].references--;
1434 }
1435 var newLastIdentifiers = modulesToDom(newList, options);
1436 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1437 var _identifier = lastIdentifiers[_i];
1438 var _index = getIndexByIdentifier(_identifier);
1439 if (stylesInDOM[_index].references === 0) {
1440 stylesInDOM[_index].updater();
1441 stylesInDOM.splice(_index, 1);
1442 }
1443 }
1444 lastIdentifiers = newLastIdentifiers;
1445 };
1446 };
1447
1448 /***/ },
1449
1450 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1451 /*!********************************************************************!*\
1452 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1453 \********************************************************************/
1454 (module) {
1455
1456 "use strict";
1457
1458
1459 var memo = {};
1460
1461 /* istanbul ignore next */
1462 function getTarget(target) {
1463 if (typeof memo[target] === "undefined") {
1464 var styleTarget = document.querySelector(target);
1465
1466 // Special case to return head of iframe instead of iframe itself
1467 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1468 try {
1469 // This will throw an exception if access to iframe is blocked
1470 // due to cross-origin restrictions
1471 styleTarget = styleTarget.contentDocument.head;
1472 } catch (e) {
1473 // istanbul ignore next
1474 styleTarget = null;
1475 }
1476 }
1477 memo[target] = styleTarget;
1478 }
1479 return memo[target];
1480 }
1481
1482 /* istanbul ignore next */
1483 function insertBySelector(insert, style) {
1484 var target = getTarget(insert);
1485 if (!target) {
1486 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1487 }
1488 target.appendChild(style);
1489 }
1490 module.exports = insertBySelector;
1491
1492 /***/ },
1493
1494 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1495 /*!**********************************************************************!*\
1496 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1497 \**********************************************************************/
1498 (module) {
1499
1500 "use strict";
1501
1502
1503 /* istanbul ignore next */
1504 function insertStyleElement(options) {
1505 var element = document.createElement("style");
1506 options.setAttributes(element, options.attributes);
1507 options.insert(element, options.options);
1508 return element;
1509 }
1510 module.exports = insertStyleElement;
1511
1512 /***/ },
1513
1514 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1515 /*!**********************************************************************************!*\
1516 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1517 \**********************************************************************************/
1518 (module, __unused_webpack_exports, __webpack_require__) {
1519
1520 "use strict";
1521
1522
1523 /* istanbul ignore next */
1524 function setAttributesWithoutAttributes(styleElement) {
1525 var nonce = true ? __webpack_require__.nc : 0;
1526 if (nonce) {
1527 styleElement.setAttribute("nonce", nonce);
1528 }
1529 }
1530 module.exports = setAttributesWithoutAttributes;
1531
1532 /***/ },
1533
1534 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1535 /*!***************************************************************!*\
1536 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1537 \***************************************************************/
1538 (module) {
1539
1540 "use strict";
1541
1542
1543 /* istanbul ignore next */
1544 function apply(styleElement, options, obj) {
1545 var css = "";
1546 if (obj.supports) {
1547 css += "@supports (".concat(obj.supports, ") {");
1548 }
1549 if (obj.media) {
1550 css += "@media ".concat(obj.media, " {");
1551 }
1552 var needLayer = typeof obj.layer !== "undefined";
1553 if (needLayer) {
1554 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1555 }
1556 css += obj.css;
1557 if (needLayer) {
1558 css += "}";
1559 }
1560 if (obj.media) {
1561 css += "}";
1562 }
1563 if (obj.supports) {
1564 css += "}";
1565 }
1566 var sourceMap = obj.sourceMap;
1567 if (sourceMap && typeof btoa !== "undefined") {
1568 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1569 }
1570
1571 // For old IE
1572 /* istanbul ignore if */
1573 options.styleTagTransform(css, styleElement, options.options);
1574 }
1575 function removeStyleElement(styleElement) {
1576 // istanbul ignore if
1577 if (styleElement.parentNode === null) {
1578 return false;
1579 }
1580 styleElement.parentNode.removeChild(styleElement);
1581 }
1582
1583 /* istanbul ignore next */
1584 function domAPI(options) {
1585 if (typeof document === "undefined") {
1586 return {
1587 update: function update() {},
1588 remove: function remove() {}
1589 };
1590 }
1591 var styleElement = options.insertStyleElement(options);
1592 return {
1593 update: function update(obj) {
1594 apply(styleElement, options, obj);
1595 },
1596 remove: function remove() {
1597 removeStyleElement(styleElement);
1598 }
1599 };
1600 }
1601 module.exports = domAPI;
1602
1603 /***/ },
1604
1605 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1606 /*!*********************************************************************!*\
1607 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1608 \*********************************************************************/
1609 (module) {
1610
1611 "use strict";
1612
1613
1614 /* istanbul ignore next */
1615 function styleTagTransform(css, styleElement) {
1616 if (styleElement.styleSheet) {
1617 styleElement.styleSheet.cssText = css;
1618 } else {
1619 while (styleElement.firstChild) {
1620 styleElement.removeChild(styleElement.firstChild);
1621 }
1622 styleElement.appendChild(document.createTextNode(css));
1623 }
1624 }
1625 module.exports = styleTagTransform;
1626
1627 /***/ },
1628
1629 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
1630 /*!**********************************************************!*\
1631 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
1632 \**********************************************************/
1633 (module) {
1634
1635 /*!
1636 * sweetalert2 v11.26.17
1637 * Released under the MIT License.
1638 */
1639 (function (global, factory) {
1640 true ? module.exports = factory() :
1641 0;
1642 })(this, (function () { 'use strict';
1643
1644 function _assertClassBrand(e, t, n) {
1645 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
1646 throw new TypeError("Private element is not present on this object");
1647 }
1648 function _checkPrivateRedeclaration(e, t) {
1649 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1650 }
1651 function _classPrivateFieldGet2(s, a) {
1652 return s.get(_assertClassBrand(s, a));
1653 }
1654 function _classPrivateFieldInitSpec(e, t, a) {
1655 _checkPrivateRedeclaration(e, t), t.set(e, a);
1656 }
1657 function _classPrivateFieldSet2(s, a, r) {
1658 return s.set(_assertClassBrand(s, a), r), r;
1659 }
1660
1661 const RESTORE_FOCUS_TIMEOUT = 100;
1662
1663 /** @type {GlobalState} */
1664 const globalState = {};
1665 const focusPreviousActiveElement = () => {
1666 if (globalState.previousActiveElement instanceof HTMLElement) {
1667 globalState.previousActiveElement.focus();
1668 globalState.previousActiveElement = null;
1669 } else if (document.body) {
1670 document.body.focus();
1671 }
1672 };
1673
1674 /**
1675 * Restore previous active (focused) element
1676 *
1677 * @param {boolean} returnFocus
1678 * @returns {Promise<void>}
1679 */
1680 const restoreActiveElement = returnFocus => {
1681 return new Promise(resolve => {
1682 if (!returnFocus) {
1683 return resolve();
1684 }
1685 const x = window.scrollX;
1686 const y = window.scrollY;
1687 globalState.restoreFocusTimeout = setTimeout(() => {
1688 focusPreviousActiveElement();
1689 resolve();
1690 }, RESTORE_FOCUS_TIMEOUT); // issues/900
1691
1692 window.scrollTo(x, y);
1693 });
1694 };
1695
1696 const swalPrefix = 'swal2-';
1697
1698 /**
1699 * @typedef {Record<SwalClass, string>} SwalClasses
1700 */
1701
1702 /**
1703 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
1704 * @typedef {Record<SwalIcon, string>} SwalIcons
1705 */
1706
1707 /** @type {SwalClass[]} */
1708 const classNames = ['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', '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', 'draggable', 'dragging'];
1709 const swalClasses = classNames.reduce((acc, className) => {
1710 acc[className] = swalPrefix + className;
1711 return acc;
1712 }, /** @type {SwalClasses} */{});
1713
1714 /** @type {SwalIcon[]} */
1715 const icons = ['success', 'warning', 'info', 'question', 'error'];
1716 const iconTypes = icons.reduce((acc, icon) => {
1717 acc[icon] = swalPrefix + icon;
1718 return acc;
1719 }, /** @type {SwalIcons} */{});
1720
1721 const consolePrefix = 'SweetAlert2:';
1722
1723 /**
1724 * Capitalize the first letter of a string
1725 *
1726 * @param {string} str
1727 * @returns {string}
1728 */
1729 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
1730
1731 /**
1732 * Standardize console warnings
1733 *
1734 * @param {string | string[]} message
1735 */
1736 const warn = message => {
1737 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
1738 };
1739
1740 /**
1741 * Standardize console errors
1742 *
1743 * @param {string} message
1744 */
1745 const error = message => {
1746 console.error(`${consolePrefix} ${message}`);
1747 };
1748
1749 /**
1750 * Private global state for `warnOnce`
1751 *
1752 * @type {string[]}
1753 * @private
1754 */
1755 const previousWarnOnceMessages = [];
1756
1757 /**
1758 * Show a console warning, but only if it hasn't already been shown
1759 *
1760 * @param {string} message
1761 */
1762 const warnOnce = message => {
1763 if (!previousWarnOnceMessages.includes(message)) {
1764 previousWarnOnceMessages.push(message);
1765 warn(message);
1766 }
1767 };
1768
1769 /**
1770 * Show a one-time console warning about deprecated params/methods
1771 *
1772 * @param {string} deprecatedParam
1773 * @param {string?} useInstead
1774 */
1775 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
1776 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
1777 };
1778
1779 /**
1780 * If `arg` is a function, call it (with no arguments or context) and return the result.
1781 * Otherwise, just pass the value through
1782 *
1783 * @param {(() => *) | *} arg
1784 * @returns {*}
1785 */
1786 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
1787
1788 /**
1789 * @param {*} arg
1790 * @returns {boolean}
1791 */
1792 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
1793
1794 /**
1795 * @param {*} arg
1796 * @returns {Promise<*>}
1797 */
1798 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
1799
1800 /**
1801 * @param {*} arg
1802 * @returns {boolean}
1803 */
1804 const isPromise = arg => arg && Promise.resolve(arg) === arg;
1805
1806 /**
1807 * Gets the popup container which contains the backdrop and the popup itself.
1808 *
1809 * @returns {HTMLElement | null}
1810 */
1811 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
1812
1813 /**
1814 * @param {string} selectorString
1815 * @returns {HTMLElement | null}
1816 */
1817 const elementBySelector = selectorString => {
1818 const container = getContainer();
1819 return container ? container.querySelector(selectorString) : null;
1820 };
1821
1822 /**
1823 * @param {string} className
1824 * @returns {HTMLElement | null}
1825 */
1826 const elementByClass = className => {
1827 return elementBySelector(`.${className}`);
1828 };
1829
1830 /**
1831 * @returns {HTMLElement | null}
1832 */
1833 const getPopup = () => elementByClass(swalClasses.popup);
1834
1835 /**
1836 * @returns {HTMLElement | null}
1837 */
1838 const getIcon = () => elementByClass(swalClasses.icon);
1839
1840 /**
1841 * @returns {HTMLElement | null}
1842 */
1843 const getIconContent = () => elementByClass(swalClasses['icon-content']);
1844
1845 /**
1846 * @returns {HTMLElement | null}
1847 */
1848 const getTitle = () => elementByClass(swalClasses.title);
1849
1850 /**
1851 * @returns {HTMLElement | null}
1852 */
1853 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
1854
1855 /**
1856 * @returns {HTMLElement | null}
1857 */
1858 const getImage = () => elementByClass(swalClasses.image);
1859
1860 /**
1861 * @returns {HTMLElement | null}
1862 */
1863 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
1864
1865 /**
1866 * @returns {HTMLElement | null}
1867 */
1868 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
1869
1870 /**
1871 * @returns {HTMLButtonElement | null}
1872 */
1873 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
1874
1875 /**
1876 * @returns {HTMLButtonElement | null}
1877 */
1878 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
1879
1880 /**
1881 * @returns {HTMLButtonElement | null}
1882 */
1883 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
1884
1885 /**
1886 * @returns {HTMLElement | null}
1887 */
1888 const getInputLabel = () => elementByClass(swalClasses['input-label']);
1889
1890 /**
1891 * @returns {HTMLElement | null}
1892 */
1893 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
1894
1895 /**
1896 * @returns {HTMLElement | null}
1897 */
1898 const getActions = () => elementByClass(swalClasses.actions);
1899
1900 /**
1901 * @returns {HTMLElement | null}
1902 */
1903 const getFooter = () => elementByClass(swalClasses.footer);
1904
1905 /**
1906 * @returns {HTMLElement | null}
1907 */
1908 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
1909
1910 /**
1911 * @returns {HTMLElement | null}
1912 */
1913 const getCloseButton = () => elementByClass(swalClasses.close);
1914
1915 // https://github.com/jkup/focusable/blob/master/index.js
1916 const focusable = `
1917 a[href],
1918 area[href],
1919 input:not([disabled]),
1920 select:not([disabled]),
1921 textarea:not([disabled]),
1922 button:not([disabled]),
1923 iframe,
1924 object,
1925 embed,
1926 [tabindex="0"],
1927 [contenteditable],
1928 audio[controls],
1929 video[controls],
1930 summary
1931 `;
1932 /**
1933 * @returns {HTMLElement[]}
1934 */
1935 const getFocusableElements = () => {
1936 const popup = getPopup();
1937 if (!popup) {
1938 return [];
1939 }
1940 /** @type {NodeListOf<HTMLElement>} */
1941 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
1942 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
1943 // sort according to tabindex
1944 .sort((a, b) => {
1945 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
1946 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
1947 if (tabindexA > tabindexB) {
1948 return 1;
1949 } else if (tabindexA < tabindexB) {
1950 return -1;
1951 }
1952 return 0;
1953 });
1954
1955 /** @type {NodeListOf<HTMLElement>} */
1956 const otherFocusableElements = popup.querySelectorAll(focusable);
1957 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
1958 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
1959 };
1960
1961 /**
1962 * @returns {boolean}
1963 */
1964 const isModal = () => {
1965 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
1966 };
1967
1968 /**
1969 * @returns {boolean}
1970 */
1971 const isToast = () => {
1972 const popup = getPopup();
1973 if (!popup) {
1974 return false;
1975 }
1976 return hasClass(popup, swalClasses.toast);
1977 };
1978
1979 /**
1980 * @returns {boolean}
1981 */
1982 const isLoading = () => {
1983 const popup = getPopup();
1984 if (!popup) {
1985 return false;
1986 }
1987 return popup.hasAttribute('data-loading');
1988 };
1989
1990 /**
1991 * Securely set innerHTML of an element
1992 * https://github.com/sweetalert2/sweetalert2/issues/1926
1993 *
1994 * @param {HTMLElement} elem
1995 * @param {string} html
1996 */
1997 const setInnerHtml = (elem, html) => {
1998 elem.textContent = '';
1999 if (html) {
2000 const parser = new DOMParser();
2001 const parsed = parser.parseFromString(html, `text/html`);
2002 const head = parsed.querySelector('head');
2003 if (head) {
2004 Array.from(head.childNodes).forEach(child => {
2005 elem.appendChild(child);
2006 });
2007 }
2008 const body = parsed.querySelector('body');
2009 if (body) {
2010 Array.from(body.childNodes).forEach(child => {
2011 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2012 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2013 } else {
2014 elem.appendChild(child);
2015 }
2016 });
2017 }
2018 }
2019 };
2020
2021 /**
2022 * @param {HTMLElement} elem
2023 * @param {string} className
2024 * @returns {boolean}
2025 */
2026 const hasClass = (elem, className) => {
2027 if (!className) {
2028 return false;
2029 }
2030 const classList = className.split(/\s+/);
2031 for (let i = 0; i < classList.length; i++) {
2032 if (!elem.classList.contains(classList[i])) {
2033 return false;
2034 }
2035 }
2036 return true;
2037 };
2038
2039 /**
2040 * @param {HTMLElement} elem
2041 * @param {SweetAlertOptions} params
2042 */
2043 const removeCustomClasses = (elem, params) => {
2044 Array.from(elem.classList).forEach(className => {
2045 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2046 elem.classList.remove(className);
2047 }
2048 });
2049 };
2050
2051 /**
2052 * @param {HTMLElement} elem
2053 * @param {SweetAlertOptions} params
2054 * @param {string} className
2055 */
2056 const applyCustomClass = (elem, params, className) => {
2057 removeCustomClasses(elem, params);
2058 if (!params.customClass) {
2059 return;
2060 }
2061 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2062 if (!customClass) {
2063 return;
2064 }
2065 if (typeof customClass !== 'string' && !customClass.forEach) {
2066 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2067 return;
2068 }
2069 addClass(elem, customClass);
2070 };
2071
2072 /**
2073 * @param {HTMLElement} popup
2074 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2075 * @returns {HTMLInputElement | null}
2076 */
2077 const getInput$1 = (popup, inputClass) => {
2078 if (!inputClass) {
2079 return null;
2080 }
2081 switch (inputClass) {
2082 case 'select':
2083 case 'textarea':
2084 case 'file':
2085 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2086 case 'checkbox':
2087 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2088 case 'radio':
2089 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2090 case 'range':
2091 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2092 default:
2093 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2094 }
2095 };
2096
2097 /**
2098 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2099 */
2100 const focusInput = input => {
2101 input.focus();
2102
2103 // place cursor at end of text in text input
2104 if (input.type !== 'file') {
2105 // http://stackoverflow.com/a/2345915
2106 const val = input.value;
2107 input.value = '';
2108 input.value = val;
2109 }
2110 };
2111
2112 /**
2113 * @param {HTMLElement | HTMLElement[] | null} target
2114 * @param {string | string[] | readonly string[] | undefined} classList
2115 * @param {boolean} condition
2116 */
2117 const toggleClass = (target, classList, condition) => {
2118 if (!target || !classList) {
2119 return;
2120 }
2121 if (typeof classList === 'string') {
2122 classList = classList.split(/\s+/).filter(Boolean);
2123 }
2124 classList.forEach(className => {
2125 if (Array.isArray(target)) {
2126 target.forEach(elem => {
2127 if (condition) {
2128 elem.classList.add(className);
2129 } else {
2130 elem.classList.remove(className);
2131 }
2132 });
2133 } else {
2134 if (condition) {
2135 target.classList.add(className);
2136 } else {
2137 target.classList.remove(className);
2138 }
2139 }
2140 });
2141 };
2142
2143 /**
2144 * @param {HTMLElement | HTMLElement[] | null} target
2145 * @param {string | string[] | readonly string[] | undefined} classList
2146 */
2147 const addClass = (target, classList) => {
2148 toggleClass(target, classList, true);
2149 };
2150
2151 /**
2152 * @param {HTMLElement | HTMLElement[] | null} target
2153 * @param {string | string[] | readonly string[] | undefined} classList
2154 */
2155 const removeClass = (target, classList) => {
2156 toggleClass(target, classList, false);
2157 };
2158
2159 /**
2160 * Get direct child of an element by class name
2161 *
2162 * @param {HTMLElement} elem
2163 * @param {string} className
2164 * @returns {HTMLElement | undefined}
2165 */
2166 const getDirectChildByClass = (elem, className) => {
2167 const children = Array.from(elem.children);
2168 for (let i = 0; i < children.length; i++) {
2169 const child = children[i];
2170 if (child instanceof HTMLElement && hasClass(child, className)) {
2171 return child;
2172 }
2173 }
2174 };
2175
2176 /**
2177 * @param {HTMLElement} elem
2178 * @param {string} property
2179 * @param {string | number | null | undefined} value
2180 */
2181 const applyNumericalStyle = (elem, property, value) => {
2182 if (value === `${parseInt(`${value}`)}`) {
2183 value = parseInt(value);
2184 }
2185 if (value || parseInt(`${value}`) === 0) {
2186 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2187 } else {
2188 elem.style.removeProperty(property);
2189 }
2190 };
2191
2192 /**
2193 * @param {HTMLElement | null} elem
2194 * @param {string} display
2195 */
2196 const show = (elem, display = 'flex') => {
2197 if (!elem) {
2198 return;
2199 }
2200 elem.style.display = display;
2201 };
2202
2203 /**
2204 * @param {HTMLElement | null} elem
2205 */
2206 const hide = elem => {
2207 if (!elem) {
2208 return;
2209 }
2210 elem.style.display = 'none';
2211 };
2212
2213 /**
2214 * @param {HTMLElement | null} elem
2215 * @param {string} display
2216 */
2217 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2218 if (!elem) {
2219 return;
2220 }
2221 new MutationObserver(() => {
2222 toggle(elem, elem.innerHTML, display);
2223 }).observe(elem, {
2224 childList: true,
2225 subtree: true
2226 });
2227 };
2228
2229 /**
2230 * @param {HTMLElement} parent
2231 * @param {string} selector
2232 * @param {string} property
2233 * @param {string} value
2234 */
2235 const setStyle = (parent, selector, property, value) => {
2236 /** @type {HTMLElement | null} */
2237 const el = parent.querySelector(selector);
2238 if (el) {
2239 el.style.setProperty(property, value);
2240 }
2241 };
2242
2243 /**
2244 * @param {HTMLElement} elem
2245 * @param {boolean | string | null | undefined} condition
2246 * @param {string} display
2247 */
2248 const toggle = (elem, condition, display = 'flex') => {
2249 if (condition) {
2250 show(elem, display);
2251 } else {
2252 hide(elem);
2253 }
2254 };
2255
2256 /**
2257 * borrowed from jquery $(elem).is(':visible') implementation
2258 *
2259 * @param {HTMLElement | null} elem
2260 * @returns {boolean}
2261 */
2262 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2263
2264 /**
2265 * @returns {boolean}
2266 */
2267 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2268
2269 /**
2270 * @param {HTMLElement} elem
2271 * @returns {boolean}
2272 */
2273 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2274
2275 /**
2276 * @param {HTMLElement} element
2277 * @param {HTMLElement} stopElement
2278 * @returns {boolean}
2279 */
2280 const selfOrParentIsScrollable = (element, stopElement) => {
2281 let parent = /** @type {HTMLElement | null} */element;
2282 while (parent && parent !== stopElement) {
2283 if (isScrollable(parent)) {
2284 return true;
2285 }
2286 parent = parent.parentElement;
2287 }
2288 return false;
2289 };
2290
2291 /**
2292 * borrowed from https://stackoverflow.com/a/46352119
2293 *
2294 * @param {HTMLElement} elem
2295 * @returns {boolean}
2296 */
2297 const hasCssAnimation = elem => {
2298 const style = window.getComputedStyle(elem);
2299 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2300 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2301 return animDuration > 0 || transDuration > 0;
2302 };
2303
2304 /**
2305 * @param {number} timer
2306 * @param {boolean} reset
2307 */
2308 const animateTimerProgressBar = (timer, reset = false) => {
2309 const timerProgressBar = getTimerProgressBar();
2310 if (!timerProgressBar) {
2311 return;
2312 }
2313 if (isVisible$1(timerProgressBar)) {
2314 if (reset) {
2315 timerProgressBar.style.transition = 'none';
2316 timerProgressBar.style.width = '100%';
2317 }
2318 setTimeout(() => {
2319 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2320 timerProgressBar.style.width = '0%';
2321 }, 10);
2322 }
2323 };
2324 const stopTimerProgressBar = () => {
2325 const timerProgressBar = getTimerProgressBar();
2326 if (!timerProgressBar) {
2327 return;
2328 }
2329 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2330 timerProgressBar.style.removeProperty('transition');
2331 timerProgressBar.style.width = '100%';
2332 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2333 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2334 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2335 };
2336
2337 /**
2338 * Detect Node env
2339 *
2340 * @returns {boolean}
2341 */
2342 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2343
2344 const sweetHTML = `
2345 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2346 <button type="button" class="${swalClasses.close}"></button>
2347 <ul class="${swalClasses['progress-steps']}"></ul>
2348 <div class="${swalClasses.icon}"></div>
2349 <img class="${swalClasses.image}" />
2350 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2351 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2352 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2353 <input type="file" class="${swalClasses.file}" />
2354 <div class="${swalClasses.range}">
2355 <input type="range" />
2356 <output></output>
2357 </div>
2358 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2359 <div class="${swalClasses.radio}"></div>
2360 <label class="${swalClasses.checkbox}">
2361 <input type="checkbox" id="${swalClasses.checkbox}" />
2362 <span class="${swalClasses.label}"></span>
2363 </label>
2364 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2365 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2366 <div class="${swalClasses.actions}">
2367 <div class="${swalClasses.loader}"></div>
2368 <button type="button" class="${swalClasses.confirm}"></button>
2369 <button type="button" class="${swalClasses.deny}"></button>
2370 <button type="button" class="${swalClasses.cancel}"></button>
2371 </div>
2372 <div class="${swalClasses.footer}"></div>
2373 <div class="${swalClasses['timer-progress-bar-container']}">
2374 <div class="${swalClasses['timer-progress-bar']}"></div>
2375 </div>
2376 </div>
2377 `.replace(/(^|\n)\s*/g, '');
2378
2379 /**
2380 * @returns {boolean}
2381 */
2382 const resetOldContainer = () => {
2383 const oldContainer = getContainer();
2384 if (!oldContainer) {
2385 return false;
2386 }
2387 oldContainer.remove();
2388 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2389 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2390 swalClasses['has-column']]);
2391 return true;
2392 };
2393 const resetValidationMessage$1 = () => {
2394 if (globalState.currentInstance) {
2395 globalState.currentInstance.resetValidationMessage();
2396 }
2397 };
2398 const addInputChangeListeners = () => {
2399 const popup = getPopup();
2400 if (!popup) {
2401 return;
2402 }
2403 const input = getDirectChildByClass(popup, swalClasses.input);
2404 const file = getDirectChildByClass(popup, swalClasses.file);
2405 /** @type {HTMLInputElement | null} */
2406 const range = popup.querySelector(`.${swalClasses.range} input`);
2407 /** @type {HTMLOutputElement | null} */
2408 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2409 const select = getDirectChildByClass(popup, swalClasses.select);
2410 /** @type {HTMLInputElement | null} */
2411 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2412 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2413 if (input) {
2414 input.oninput = resetValidationMessage$1;
2415 }
2416 if (file) {
2417 file.onchange = resetValidationMessage$1;
2418 }
2419 if (select) {
2420 select.onchange = resetValidationMessage$1;
2421 }
2422 if (checkbox) {
2423 checkbox.onchange = resetValidationMessage$1;
2424 }
2425 if (textarea) {
2426 textarea.oninput = resetValidationMessage$1;
2427 }
2428 if (range && rangeOutput) {
2429 range.oninput = () => {
2430 resetValidationMessage$1();
2431 rangeOutput.value = range.value;
2432 };
2433 range.onchange = () => {
2434 resetValidationMessage$1();
2435 rangeOutput.value = range.value;
2436 };
2437 }
2438 };
2439
2440 /**
2441 * @param {string | HTMLElement} target
2442 * @returns {HTMLElement}
2443 */
2444 const getTarget = target => {
2445 if (typeof target === 'string') {
2446 const element = document.querySelector(target);
2447 if (!element) {
2448 throw new Error(`Target element "${target}" not found`);
2449 }
2450 return /** @type {HTMLElement} */element;
2451 }
2452 return target;
2453 };
2454
2455 /**
2456 * @param {SweetAlertOptions} params
2457 */
2458 const setupAccessibility = params => {
2459 const popup = getPopup();
2460 if (!popup) {
2461 return;
2462 }
2463 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2464 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2465 if (!params.toast) {
2466 popup.setAttribute('aria-modal', 'true');
2467 }
2468 };
2469
2470 /**
2471 * @param {HTMLElement} targetElement
2472 */
2473 const setupRTL = targetElement => {
2474 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2475 addClass(getContainer(), swalClasses.rtl);
2476 globalState.isRTL = true;
2477 }
2478 };
2479
2480 /**
2481 * Add modal + backdrop to DOM
2482 *
2483 * @param {SweetAlertOptions} params
2484 */
2485 const init = params => {
2486 // Clean up the old popup container if it exists
2487 const oldContainerExisted = resetOldContainer();
2488 if (isNodeEnv()) {
2489 error('SweetAlert2 requires document to initialize');
2490 return;
2491 }
2492 const container = document.createElement('div');
2493 container.className = swalClasses.container;
2494 if (oldContainerExisted) {
2495 addClass(container, swalClasses['no-transition']);
2496 }
2497 setInnerHtml(container, sweetHTML);
2498 container.dataset['swal2Theme'] = params.theme;
2499 const targetElement = getTarget(params.target || 'body');
2500 targetElement.appendChild(container);
2501 if (params.topLayer) {
2502 container.setAttribute('popover', '');
2503 container.showPopover();
2504 }
2505 setupAccessibility(params);
2506 setupRTL(targetElement);
2507 addInputChangeListeners();
2508 };
2509
2510 /**
2511 * @param {HTMLElement | object | string} param
2512 * @param {HTMLElement} target
2513 */
2514 const parseHtmlToContainer = (param, target) => {
2515 // DOM element
2516 if (param instanceof HTMLElement) {
2517 target.appendChild(param);
2518 }
2519
2520 // Object
2521 else if (typeof param === 'object') {
2522 handleObject(param, target);
2523 }
2524
2525 // Plain string
2526 else if (param) {
2527 setInnerHtml(target, param);
2528 }
2529 };
2530
2531 /**
2532 * @param {object} param
2533 * @param {HTMLElement} target
2534 */
2535 const handleObject = (param, target) => {
2536 // JQuery element(s)
2537 if ('jquery' in param) {
2538 handleJqueryElem(target, param);
2539 }
2540
2541 // For other objects use their string representation
2542 else {
2543 setInnerHtml(target, param.toString());
2544 }
2545 };
2546
2547 /**
2548 * @param {HTMLElement} target
2549 * @param {any} elem
2550 */
2551 const handleJqueryElem = (target, elem) => {
2552 target.textContent = '';
2553 if (0 in elem) {
2554 for (let i = 0; i in elem; i++) {
2555 target.appendChild(elem[i].cloneNode(true));
2556 }
2557 } else {
2558 target.appendChild(elem.cloneNode(true));
2559 }
2560 };
2561
2562 /**
2563 * @param {SweetAlert} instance
2564 * @param {SweetAlertOptions} params
2565 */
2566 const renderActions = (instance, params) => {
2567 const actions = getActions();
2568 const loader = getLoader();
2569 if (!actions || !loader) {
2570 return;
2571 }
2572
2573 // Actions (buttons) wrapper
2574 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2575 hide(actions);
2576 } else {
2577 show(actions);
2578 }
2579
2580 // Custom class
2581 applyCustomClass(actions, params, 'actions');
2582
2583 // Render all the buttons
2584 renderButtons(actions, loader, params);
2585
2586 // Loader
2587 setInnerHtml(loader, params.loaderHtml || '');
2588 applyCustomClass(loader, params, 'loader');
2589 };
2590
2591 /**
2592 * @param {HTMLElement} actions
2593 * @param {HTMLElement} loader
2594 * @param {SweetAlertOptions} params
2595 */
2596 function renderButtons(actions, loader, params) {
2597 const confirmButton = getConfirmButton();
2598 const denyButton = getDenyButton();
2599 const cancelButton = getCancelButton();
2600 if (!confirmButton || !denyButton || !cancelButton) {
2601 return;
2602 }
2603
2604 // Render buttons
2605 renderButton(confirmButton, 'confirm', params);
2606 renderButton(denyButton, 'deny', params);
2607 renderButton(cancelButton, 'cancel', params);
2608 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
2609 if (params.reverseButtons) {
2610 if (params.toast) {
2611 actions.insertBefore(cancelButton, confirmButton);
2612 actions.insertBefore(denyButton, confirmButton);
2613 } else {
2614 actions.insertBefore(cancelButton, loader);
2615 actions.insertBefore(denyButton, loader);
2616 actions.insertBefore(confirmButton, loader);
2617 }
2618 }
2619 }
2620
2621 /**
2622 * @param {HTMLElement} confirmButton
2623 * @param {HTMLElement} denyButton
2624 * @param {HTMLElement} cancelButton
2625 * @param {SweetAlertOptions} params
2626 */
2627 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
2628 if (!params.buttonsStyling) {
2629 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2630 return;
2631 }
2632 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2633
2634 // Apply custom background colors to action buttons
2635 if (params.confirmButtonColor) {
2636 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
2637 }
2638 if (params.denyButtonColor) {
2639 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
2640 }
2641 if (params.cancelButtonColor) {
2642 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
2643 }
2644
2645 // Apply the outline color to action buttons
2646 applyOutlineColor(confirmButton);
2647 applyOutlineColor(denyButton);
2648 applyOutlineColor(cancelButton);
2649 }
2650
2651 /**
2652 * @param {HTMLElement} button
2653 */
2654 function applyOutlineColor(button) {
2655 const buttonStyle = window.getComputedStyle(button);
2656 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
2657 // If the button already has a custom outline color, no need to change it
2658 return;
2659 }
2660 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
2661 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
2662 }
2663
2664 /**
2665 * @param {HTMLElement} button
2666 * @param {'confirm' | 'deny' | 'cancel'} buttonType
2667 * @param {SweetAlertOptions} params
2668 */
2669 function renderButton(button, buttonType, params) {
2670 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
2671 toggle(button, params[`show${buttonName}Button`], 'inline-block');
2672 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
2673 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
2674
2675 // Add buttons custom classes
2676 button.className = swalClasses[buttonType];
2677 applyCustomClass(button, params, `${buttonType}Button`);
2678 }
2679
2680 /**
2681 * @param {SweetAlert} instance
2682 * @param {SweetAlertOptions} params
2683 */
2684 const renderCloseButton = (instance, params) => {
2685 const closeButton = getCloseButton();
2686 if (!closeButton) {
2687 return;
2688 }
2689 setInnerHtml(closeButton, params.closeButtonHtml || '');
2690
2691 // Custom class
2692 applyCustomClass(closeButton, params, 'closeButton');
2693 toggle(closeButton, params.showCloseButton);
2694 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
2695 };
2696
2697 /**
2698 * @param {SweetAlert} instance
2699 * @param {SweetAlertOptions} params
2700 */
2701 const renderContainer = (instance, params) => {
2702 const container = getContainer();
2703 if (!container) {
2704 return;
2705 }
2706 handleBackdropParam(container, params.backdrop);
2707 handlePositionParam(container, params.position);
2708 handleGrowParam(container, params.grow);
2709
2710 // Custom class
2711 applyCustomClass(container, params, 'container');
2712 };
2713
2714 /**
2715 * @param {HTMLElement} container
2716 * @param {SweetAlertOptions['backdrop']} backdrop
2717 */
2718 function handleBackdropParam(container, backdrop) {
2719 if (typeof backdrop === 'string') {
2720 container.style.background = backdrop;
2721 } else if (!backdrop) {
2722 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
2723 }
2724 }
2725
2726 /**
2727 * @param {HTMLElement} container
2728 * @param {SweetAlertOptions['position']} position
2729 */
2730 function handlePositionParam(container, position) {
2731 if (!position) {
2732 return;
2733 }
2734 if (position in swalClasses) {
2735 addClass(container, swalClasses[position]);
2736 } else {
2737 warn('The "position" parameter is not valid, defaulting to "center"');
2738 addClass(container, swalClasses.center);
2739 }
2740 }
2741
2742 /**
2743 * @param {HTMLElement} container
2744 * @param {SweetAlertOptions['grow']} grow
2745 */
2746 function handleGrowParam(container, grow) {
2747 if (!grow) {
2748 return;
2749 }
2750 addClass(container, swalClasses[`grow-${grow}`]);
2751 }
2752
2753 /**
2754 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
2755 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
2756 * This is the approach that Babel will probably take to implement private methods/fields
2757 * https://github.com/tc39/proposal-private-methods
2758 * https://github.com/babel/babel/pull/7555
2759 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
2760 * then we can use that language feature.
2761 */
2762
2763 var privateProps = {
2764 innerParams: new WeakMap(),
2765 domCache: new WeakMap()
2766 };
2767
2768 /// <reference path="../../../../sweetalert2.d.ts"/>
2769
2770
2771 /** @type {InputClass[]} */
2772 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
2773
2774 /**
2775 * @param {SweetAlert} instance
2776 * @param {SweetAlertOptions} params
2777 */
2778 const renderInput = (instance, params) => {
2779 const popup = getPopup();
2780 if (!popup) {
2781 return;
2782 }
2783 const innerParams = privateProps.innerParams.get(instance);
2784 const rerender = !innerParams || params.input !== innerParams.input;
2785 inputClasses.forEach(inputClass => {
2786 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
2787 if (!inputContainer) {
2788 return;
2789 }
2790
2791 // set attributes
2792 setAttributes(inputClass, params.inputAttributes);
2793
2794 // set class
2795 inputContainer.className = swalClasses[inputClass];
2796 if (rerender) {
2797 hide(inputContainer);
2798 }
2799 });
2800 if (params.input) {
2801 if (rerender) {
2802 showInput(params);
2803 }
2804 // set custom class
2805 setCustomClass(params);
2806 }
2807 };
2808
2809 /**
2810 * @param {SweetAlertOptions} params
2811 */
2812 const showInput = params => {
2813 if (!params.input) {
2814 return;
2815 }
2816 if (!renderInputType[params.input]) {
2817 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
2818 return;
2819 }
2820 const inputContainer = getInputContainer(params.input);
2821 if (!inputContainer) {
2822 return;
2823 }
2824 const input = renderInputType[params.input](inputContainer, params);
2825 show(inputContainer);
2826
2827 // input autofocus
2828 if (params.inputAutoFocus) {
2829 setTimeout(() => {
2830 focusInput(input);
2831 });
2832 }
2833 };
2834
2835 /**
2836 * @param {HTMLInputElement} input
2837 */
2838 const removeAttributes = input => {
2839 for (let i = 0; i < input.attributes.length; i++) {
2840 const attrName = input.attributes[i].name;
2841 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
2842 input.removeAttribute(attrName);
2843 }
2844 }
2845 };
2846
2847 /**
2848 * @param {InputClass} inputClass
2849 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
2850 */
2851 const setAttributes = (inputClass, inputAttributes) => {
2852 const popup = getPopup();
2853 if (!popup) {
2854 return;
2855 }
2856 const input = getInput$1(popup, inputClass);
2857 if (!input) {
2858 return;
2859 }
2860 removeAttributes(input);
2861 for (const attr in inputAttributes) {
2862 input.setAttribute(attr, inputAttributes[attr]);
2863 }
2864 };
2865
2866 /**
2867 * @param {SweetAlertOptions} params
2868 */
2869 const setCustomClass = params => {
2870 if (!params.input) {
2871 return;
2872 }
2873 const inputContainer = getInputContainer(params.input);
2874 if (inputContainer) {
2875 applyCustomClass(inputContainer, params, 'input');
2876 }
2877 };
2878
2879 /**
2880 * @param {HTMLInputElement | HTMLTextAreaElement} input
2881 * @param {SweetAlertOptions} params
2882 */
2883 const setInputPlaceholder = (input, params) => {
2884 if (!input.placeholder && params.inputPlaceholder) {
2885 input.placeholder = params.inputPlaceholder;
2886 }
2887 };
2888
2889 /**
2890 * @param {Input} input
2891 * @param {Input} prependTo
2892 * @param {SweetAlertOptions} params
2893 */
2894 const setInputLabel = (input, prependTo, params) => {
2895 if (params.inputLabel) {
2896 const label = document.createElement('label');
2897 const labelClass = swalClasses['input-label'];
2898 label.setAttribute('for', input.id);
2899 label.className = labelClass;
2900 if (typeof params.customClass === 'object') {
2901 addClass(label, params.customClass.inputLabel);
2902 }
2903 label.innerText = params.inputLabel;
2904 prependTo.insertAdjacentElement('beforebegin', label);
2905 }
2906 };
2907
2908 /**
2909 * @param {SweetAlertInput} inputType
2910 * @returns {HTMLElement | undefined}
2911 */
2912 const getInputContainer = inputType => {
2913 const popup = getPopup();
2914 if (!popup) {
2915 return;
2916 }
2917 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
2918 };
2919
2920 /**
2921 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
2922 * @param {SweetAlertOptions['inputValue']} inputValue
2923 */
2924 const checkAndSetInputValue = (input, inputValue) => {
2925 if (['string', 'number'].includes(typeof inputValue)) {
2926 input.value = `${inputValue}`;
2927 } else if (!isPromise(inputValue)) {
2928 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
2929 }
2930 };
2931
2932 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
2933 const renderInputType = {};
2934
2935 /**
2936 * @param {Input | HTMLElement} input
2937 * @param {SweetAlertOptions} params
2938 * @returns {Input}
2939 */
2940 renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType['datetime-local'] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
2941 (input, params) => {
2942 const inputElement = /** @type {HTMLInputElement} */input;
2943 checkAndSetInputValue(inputElement, params.inputValue);
2944 setInputLabel(inputElement, inputElement, params);
2945 setInputPlaceholder(inputElement, params);
2946 inputElement.type = /** @type {string} */params.input;
2947 return inputElement;
2948 };
2949
2950 /**
2951 * @param {Input | HTMLElement} input
2952 * @param {SweetAlertOptions} params
2953 * @returns {Input}
2954 */
2955 renderInputType.file = (input, params) => {
2956 const inputElement = /** @type {HTMLInputElement} */input;
2957 setInputLabel(inputElement, inputElement, params);
2958 setInputPlaceholder(inputElement, params);
2959 return inputElement;
2960 };
2961
2962 /**
2963 * @param {Input | HTMLElement} range
2964 * @param {SweetAlertOptions} params
2965 * @returns {Input}
2966 */
2967 renderInputType.range = (range, params) => {
2968 const rangeContainer = /** @type {HTMLElement} */range;
2969 const rangeInput = rangeContainer.querySelector('input');
2970 const rangeOutput = rangeContainer.querySelector('output');
2971 if (rangeInput) {
2972 checkAndSetInputValue(rangeInput, params.inputValue);
2973 rangeInput.type = /** @type {string} */params.input;
2974 setInputLabel(rangeInput, /** @type {Input} */range, params);
2975 }
2976 if (rangeOutput) {
2977 checkAndSetInputValue(rangeOutput, params.inputValue);
2978 }
2979 return /** @type {Input} */range;
2980 };
2981
2982 /**
2983 * @param {Input | HTMLElement} select
2984 * @param {SweetAlertOptions} params
2985 * @returns {Input}
2986 */
2987 renderInputType.select = (select, params) => {
2988 const selectElement = /** @type {HTMLSelectElement} */select;
2989 selectElement.textContent = '';
2990 if (params.inputPlaceholder) {
2991 const placeholder = document.createElement('option');
2992 setInnerHtml(placeholder, params.inputPlaceholder);
2993 placeholder.value = '';
2994 placeholder.disabled = true;
2995 placeholder.selected = true;
2996 selectElement.appendChild(placeholder);
2997 }
2998 setInputLabel(selectElement, selectElement, params);
2999 return selectElement;
3000 };
3001
3002 /**
3003 * @param {Input | HTMLElement} radio
3004 * @returns {Input}
3005 */
3006 renderInputType.radio = radio => {
3007 const radioElement = /** @type {HTMLElement} */radio;
3008 radioElement.textContent = '';
3009 return /** @type {Input} */radio;
3010 };
3011
3012 /**
3013 * @param {Input | HTMLElement} checkboxContainer
3014 * @param {SweetAlertOptions} params
3015 * @returns {Input}
3016 */
3017 renderInputType.checkbox = (checkboxContainer, params) => {
3018 const popup = getPopup();
3019 if (!popup) {
3020 throw new Error('Popup not found');
3021 }
3022 const checkbox = getInput$1(popup, 'checkbox');
3023 if (!checkbox) {
3024 throw new Error('Checkbox input not found');
3025 }
3026 checkbox.value = '1';
3027 checkbox.checked = Boolean(params.inputValue);
3028 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3029 const label = containerElement.querySelector('span');
3030 if (label) {
3031 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3032 if (placeholderOrLabel) {
3033 setInnerHtml(label, placeholderOrLabel);
3034 }
3035 }
3036 return checkbox;
3037 };
3038
3039 /**
3040 * @param {Input | HTMLElement} textarea
3041 * @param {SweetAlertOptions} params
3042 * @returns {Input}
3043 */
3044 renderInputType.textarea = (textarea, params) => {
3045 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3046 checkAndSetInputValue(textareaElement, params.inputValue);
3047 setInputPlaceholder(textareaElement, params);
3048 setInputLabel(textareaElement, textareaElement, params);
3049
3050 /**
3051 * @param {HTMLElement} el
3052 * @returns {number}
3053 */
3054 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3055
3056 // https://github.com/sweetalert2/sweetalert2/issues/2291
3057 setTimeout(() => {
3058 // https://github.com/sweetalert2/sweetalert2/issues/1699
3059 if ('MutationObserver' in window) {
3060 const popup = getPopup();
3061 if (!popup) {
3062 return;
3063 }
3064 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3065 const textareaResizeHandler = () => {
3066 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3067 if (!document.body.contains(textareaElement)) {
3068 return;
3069 }
3070 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3071 const popupElement = getPopup();
3072 if (popupElement) {
3073 if (textareaWidth > initialPopupWidth) {
3074 popupElement.style.width = `${textareaWidth}px`;
3075 } else {
3076 applyNumericalStyle(popupElement, 'width', params.width);
3077 }
3078 }
3079 };
3080 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3081 attributes: true,
3082 attributeFilter: ['style']
3083 });
3084 }
3085 });
3086 return textareaElement;
3087 };
3088
3089 /**
3090 * @param {SweetAlert} instance
3091 * @param {SweetAlertOptions} params
3092 */
3093 const renderContent = (instance, params) => {
3094 const htmlContainer = getHtmlContainer();
3095 if (!htmlContainer) {
3096 return;
3097 }
3098 showWhenInnerHtmlPresent(htmlContainer);
3099 applyCustomClass(htmlContainer, params, 'htmlContainer');
3100
3101 // Content as HTML
3102 if (params.html) {
3103 parseHtmlToContainer(params.html, htmlContainer);
3104 show(htmlContainer, 'block');
3105 }
3106
3107 // Content as plain text
3108 else if (params.text) {
3109 htmlContainer.textContent = params.text;
3110 show(htmlContainer, 'block');
3111 }
3112
3113 // No content
3114 else {
3115 hide(htmlContainer);
3116 }
3117 renderInput(instance, params);
3118 };
3119
3120 /**
3121 * @param {SweetAlert} instance
3122 * @param {SweetAlertOptions} params
3123 */
3124 const renderFooter = (instance, params) => {
3125 const footer = getFooter();
3126 if (!footer) {
3127 return;
3128 }
3129 showWhenInnerHtmlPresent(footer);
3130 toggle(footer, Boolean(params.footer), 'block');
3131 if (params.footer) {
3132 parseHtmlToContainer(params.footer, footer);
3133 }
3134
3135 // Custom class
3136 applyCustomClass(footer, params, 'footer');
3137 };
3138
3139 /**
3140 * @param {SweetAlert} instance
3141 * @param {SweetAlertOptions} params
3142 */
3143 const renderIcon = (instance, params) => {
3144 const innerParams = privateProps.innerParams.get(instance);
3145 const icon = getIcon();
3146 if (!icon) {
3147 return;
3148 }
3149
3150 // if the given icon already rendered, apply the styling without re-rendering the icon
3151 if (innerParams && params.icon === innerParams.icon) {
3152 // Custom or default content
3153 setContent(icon, params);
3154 applyStyles(icon, params);
3155 return;
3156 }
3157 if (!params.icon && !params.iconHtml) {
3158 hide(icon);
3159 return;
3160 }
3161 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3162 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3163 hide(icon);
3164 return;
3165 }
3166 show(icon);
3167
3168 // Custom or default content
3169 setContent(icon, params);
3170 applyStyles(icon, params);
3171
3172 // Animate icon
3173 addClass(icon, params.showClass && params.showClass.icon);
3174
3175 // Re-adjust the success icon on system theme change
3176 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3177 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3178 };
3179
3180 /**
3181 * @param {HTMLElement} icon
3182 * @param {SweetAlertOptions} params
3183 */
3184 const applyStyles = (icon, params) => {
3185 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3186 if (params.icon !== iconType) {
3187 removeClass(icon, iconClassName);
3188 }
3189 }
3190 addClass(icon, params.icon && iconTypes[params.icon]);
3191
3192 // Icon color
3193 setColor(icon, params);
3194
3195 // Success icon background color
3196 adjustSuccessIconBackgroundColor();
3197
3198 // Custom class
3199 applyCustomClass(icon, params, 'icon');
3200 };
3201
3202 // Adjust success icon background color to match the popup background color
3203 const adjustSuccessIconBackgroundColor = () => {
3204 const popup = getPopup();
3205 if (!popup) {
3206 return;
3207 }
3208 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3209 /** @type {NodeListOf<HTMLElement>} */
3210 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3211 for (let i = 0; i < successIconParts.length; i++) {
3212 successIconParts[i].style.backgroundColor = popupBackgroundColor;
3213 }
3214 };
3215
3216 /**
3217 *
3218 * @param {SweetAlertOptions} params
3219 * @returns {string}
3220 */
3221 const successIconHtml = params => `
3222 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3223 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3224 <div class="swal2-success-ring"></div>
3225 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3226 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3227 `;
3228 const errorIconHtml = `
3229 <span class="swal2-x-mark">
3230 <span class="swal2-x-mark-line-left"></span>
3231 <span class="swal2-x-mark-line-right"></span>
3232 </span>
3233 `;
3234
3235 /**
3236 * @param {HTMLElement} icon
3237 * @param {SweetAlertOptions} params
3238 */
3239 const setContent = (icon, params) => {
3240 if (!params.icon && !params.iconHtml) {
3241 return;
3242 }
3243 let oldContent = icon.innerHTML;
3244 let newContent = '';
3245 if (params.iconHtml) {
3246 newContent = iconContent(params.iconHtml);
3247 } else if (params.icon === 'success') {
3248 newContent = successIconHtml(params);
3249 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3250 } else if (params.icon === 'error') {
3251 newContent = errorIconHtml;
3252 } else if (params.icon) {
3253 const defaultIconHtml = {
3254 question: '?',
3255 warning: '!',
3256 info: 'i'
3257 };
3258 newContent = iconContent(defaultIconHtml[params.icon]);
3259 }
3260 if (oldContent.trim() !== newContent.trim()) {
3261 setInnerHtml(icon, newContent);
3262 }
3263 };
3264
3265 /**
3266 * @param {HTMLElement} icon
3267 * @param {SweetAlertOptions} params
3268 */
3269 const setColor = (icon, params) => {
3270 if (!params.iconColor) {
3271 return;
3272 }
3273 icon.style.color = params.iconColor;
3274 icon.style.borderColor = params.iconColor;
3275 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3276 setStyle(icon, sel, 'background-color', params.iconColor);
3277 }
3278 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3279 };
3280
3281 /**
3282 * @param {string} content
3283 * @returns {string}
3284 */
3285 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3286
3287 /**
3288 * @param {SweetAlert} instance
3289 * @param {SweetAlertOptions} params
3290 */
3291 const renderImage = (instance, params) => {
3292 const image = getImage();
3293 if (!image) {
3294 return;
3295 }
3296 if (!params.imageUrl) {
3297 hide(image);
3298 return;
3299 }
3300 show(image, '');
3301
3302 // Src, alt
3303 image.setAttribute('src', params.imageUrl);
3304 image.setAttribute('alt', params.imageAlt || '');
3305
3306 // Width, height
3307 applyNumericalStyle(image, 'width', params.imageWidth);
3308 applyNumericalStyle(image, 'height', params.imageHeight);
3309
3310 // Class
3311 image.className = swalClasses.image;
3312 applyCustomClass(image, params, 'image');
3313 };
3314
3315 let dragging = false;
3316 let mousedownX = 0;
3317 let mousedownY = 0;
3318 let initialX = 0;
3319 let initialY = 0;
3320
3321 /**
3322 * @param {HTMLElement} popup
3323 */
3324 const addDraggableListeners = popup => {
3325 popup.addEventListener('mousedown', down);
3326 document.body.addEventListener('mousemove', move);
3327 popup.addEventListener('mouseup', up);
3328 popup.addEventListener('touchstart', down);
3329 document.body.addEventListener('touchmove', move);
3330 popup.addEventListener('touchend', up);
3331 };
3332
3333 /**
3334 * @param {HTMLElement} popup
3335 */
3336 const removeDraggableListeners = popup => {
3337 popup.removeEventListener('mousedown', down);
3338 document.body.removeEventListener('mousemove', move);
3339 popup.removeEventListener('mouseup', up);
3340 popup.removeEventListener('touchstart', down);
3341 document.body.removeEventListener('touchmove', move);
3342 popup.removeEventListener('touchend', up);
3343 };
3344
3345 /**
3346 * @param {MouseEvent | TouchEvent} event
3347 */
3348 const down = event => {
3349 const popup = getPopup();
3350 if (!popup) {
3351 return;
3352 }
3353 const icon = getIcon();
3354 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3355 dragging = true;
3356 const clientXY = getClientXY(event);
3357 mousedownX = clientXY.clientX;
3358 mousedownY = clientXY.clientY;
3359 initialX = parseInt(popup.style.insetInlineStart) || 0;
3360 initialY = parseInt(popup.style.insetBlockStart) || 0;
3361 addClass(popup, 'swal2-dragging');
3362 }
3363 };
3364
3365 /**
3366 * @param {MouseEvent | TouchEvent} event
3367 */
3368 const move = event => {
3369 const popup = getPopup();
3370 if (!popup) {
3371 return;
3372 }
3373 if (dragging) {
3374 let {
3375 clientX,
3376 clientY
3377 } = getClientXY(event);
3378 const deltaX = clientX - mousedownX;
3379 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3380 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3381 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3382 }
3383 };
3384 const up = () => {
3385 const popup = getPopup();
3386 dragging = false;
3387 removeClass(popup, 'swal2-dragging');
3388 };
3389
3390 /**
3391 * @param {MouseEvent | TouchEvent} event
3392 * @returns {{ clientX: number, clientY: number }}
3393 */
3394 const getClientXY = event => {
3395 let clientX = 0,
3396 clientY = 0;
3397 if (event.type.startsWith('mouse')) {
3398 clientX = /** @type {MouseEvent} */event.clientX;
3399 clientY = /** @type {MouseEvent} */event.clientY;
3400 } else if (event.type.startsWith('touch')) {
3401 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
3402 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
3403 }
3404 return {
3405 clientX,
3406 clientY
3407 };
3408 };
3409
3410 /**
3411 * @param {SweetAlert} instance
3412 * @param {SweetAlertOptions} params
3413 */
3414 const renderPopup = (instance, params) => {
3415 const container = getContainer();
3416 const popup = getPopup();
3417 if (!container || !popup) {
3418 return;
3419 }
3420
3421 // Width
3422 // https://github.com/sweetalert2/sweetalert2/issues/2170
3423 if (params.toast) {
3424 applyNumericalStyle(container, 'width', params.width);
3425 popup.style.width = '100%';
3426 const loader = getLoader();
3427 if (loader) {
3428 popup.insertBefore(loader, getIcon());
3429 }
3430 } else {
3431 applyNumericalStyle(popup, 'width', params.width);
3432 }
3433
3434 // Padding
3435 applyNumericalStyle(popup, 'padding', params.padding);
3436
3437 // Color
3438 if (params.color) {
3439 popup.style.color = params.color;
3440 }
3441
3442 // Background
3443 if (params.background) {
3444 popup.style.background = params.background;
3445 }
3446 hide(getValidationMessage());
3447
3448 // Classes
3449 addClasses$1(popup, params);
3450 if (params.draggable && !params.toast) {
3451 addClass(popup, swalClasses.draggable);
3452 addDraggableListeners(popup);
3453 } else {
3454 removeClass(popup, swalClasses.draggable);
3455 removeDraggableListeners(popup);
3456 }
3457 };
3458
3459 /**
3460 * @param {HTMLElement} popup
3461 * @param {SweetAlertOptions} params
3462 */
3463 const addClasses$1 = (popup, params) => {
3464 const showClass = params.showClass || {};
3465 // Default Class + showClass when updating Swal.update({})
3466 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3467 if (params.toast) {
3468 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3469 addClass(popup, swalClasses.toast);
3470 } else {
3471 addClass(popup, swalClasses.modal);
3472 }
3473
3474 // Custom class
3475 applyCustomClass(popup, params, 'popup');
3476 // TODO: remove in the next major
3477 if (typeof params.customClass === 'string') {
3478 addClass(popup, params.customClass);
3479 }
3480
3481 // Icon class (#1842)
3482 if (params.icon) {
3483 addClass(popup, swalClasses[`icon-${params.icon}`]);
3484 }
3485 };
3486
3487 /**
3488 * @param {SweetAlert} instance
3489 * @param {SweetAlertOptions} params
3490 */
3491 const renderProgressSteps = (instance, params) => {
3492 const progressStepsContainer = getProgressSteps();
3493 if (!progressStepsContainer) {
3494 return;
3495 }
3496 const {
3497 progressSteps,
3498 currentProgressStep
3499 } = params;
3500 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3501 hide(progressStepsContainer);
3502 return;
3503 }
3504 show(progressStepsContainer);
3505 progressStepsContainer.textContent = '';
3506 if (currentProgressStep >= progressSteps.length) {
3507 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3508 }
3509 progressSteps.forEach((step, index) => {
3510 const stepEl = createStepElement(step);
3511 progressStepsContainer.appendChild(stepEl);
3512 if (index === currentProgressStep) {
3513 addClass(stepEl, swalClasses['active-progress-step']);
3514 }
3515 if (index !== progressSteps.length - 1) {
3516 const lineEl = createLineElement(params);
3517 progressStepsContainer.appendChild(lineEl);
3518 }
3519 });
3520 };
3521
3522 /**
3523 * @param {string} step
3524 * @returns {HTMLLIElement}
3525 */
3526 const createStepElement = step => {
3527 const stepEl = document.createElement('li');
3528 addClass(stepEl, swalClasses['progress-step']);
3529 setInnerHtml(stepEl, step);
3530 return stepEl;
3531 };
3532
3533 /**
3534 * @param {SweetAlertOptions} params
3535 * @returns {HTMLLIElement}
3536 */
3537 const createLineElement = params => {
3538 const lineEl = document.createElement('li');
3539 addClass(lineEl, swalClasses['progress-step-line']);
3540 if (params.progressStepsDistance) {
3541 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3542 }
3543 return lineEl;
3544 };
3545
3546 /**
3547 * @param {SweetAlert} instance
3548 * @param {SweetAlertOptions} params
3549 */
3550 const renderTitle = (instance, params) => {
3551 const title = getTitle();
3552 if (!title) {
3553 return;
3554 }
3555 showWhenInnerHtmlPresent(title);
3556 toggle(title, Boolean(params.title || params.titleText), 'block');
3557 if (params.title) {
3558 parseHtmlToContainer(params.title, title);
3559 }
3560 if (params.titleText) {
3561 title.innerText = params.titleText;
3562 }
3563
3564 // Custom class
3565 applyCustomClass(title, params, 'title');
3566 };
3567
3568 /**
3569 * @param {SweetAlert} instance
3570 * @param {SweetAlertOptions} params
3571 */
3572 const render = (instance, params) => {
3573 var _globalState$eventEmi;
3574 renderPopup(instance, params);
3575 renderContainer(instance, params);
3576 renderProgressSteps(instance, params);
3577 renderIcon(instance, params);
3578 renderImage(instance, params);
3579 renderTitle(instance, params);
3580 renderCloseButton(instance, params);
3581 renderContent(instance, params);
3582 renderActions(instance, params);
3583 renderFooter(instance, params);
3584 const popup = getPopup();
3585 if (typeof params.didRender === 'function' && popup) {
3586 params.didRender(popup);
3587 }
3588 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3589 };
3590
3591 /*
3592 * Global function to determine if SweetAlert2 popup is shown
3593 */
3594 const isVisible = () => {
3595 return isVisible$1(getPopup());
3596 };
3597
3598 /*
3599 * Global function to click 'Confirm' button
3600 */
3601 const clickConfirm = () => {
3602 var _dom$getConfirmButton;
3603 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
3604 };
3605
3606 /*
3607 * Global function to click 'Deny' button
3608 */
3609 const clickDeny = () => {
3610 var _dom$getDenyButton;
3611 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
3612 };
3613
3614 /*
3615 * Global function to click 'Cancel' button
3616 */
3617 const clickCancel = () => {
3618 var _dom$getCancelButton;
3619 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
3620 };
3621
3622 /** @type {Record<DismissReason, DismissReason>} */
3623 const DismissReason = Object.freeze({
3624 cancel: 'cancel',
3625 backdrop: 'backdrop',
3626 close: 'close',
3627 esc: 'esc',
3628 timer: 'timer'
3629 });
3630
3631 /**
3632 * @param {GlobalState} globalState
3633 */
3634 const removeKeydownHandler = globalState => {
3635 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
3636 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
3637 globalState.keydownTarget.removeEventListener('keydown', handler, {
3638 capture: globalState.keydownListenerCapture
3639 });
3640 globalState.keydownHandlerAdded = false;
3641 }
3642 };
3643
3644 /**
3645 * @param {GlobalState} globalState
3646 * @param {SweetAlertOptions} innerParams
3647 * @param {(dismiss: DismissReason) => void} dismissWith
3648 */
3649 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
3650 removeKeydownHandler(globalState);
3651 if (!innerParams.toast) {
3652 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
3653 const handler = e => keydownHandler(innerParams, e, dismissWith);
3654 globalState.keydownHandler = handler;
3655 const target = innerParams.keydownListenerCapture ? window : getPopup();
3656 if (target) {
3657 globalState.keydownTarget = target;
3658 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
3659 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
3660 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
3661 capture: globalState.keydownListenerCapture
3662 });
3663 globalState.keydownHandlerAdded = true;
3664 }
3665 }
3666 };
3667
3668 /**
3669 * @param {number} index
3670 * @param {number} increment
3671 */
3672 const setFocus = (index, increment) => {
3673 var _dom$getPopup;
3674 const focusableElements = getFocusableElements();
3675 // search for visible elements and select the next possible match
3676 if (focusableElements.length) {
3677 index = index + increment;
3678
3679 // shift + tab when .swal2-popup is focused
3680 if (index === -2) {
3681 index = focusableElements.length - 1;
3682 }
3683
3684 // rollover to first item
3685 if (index === focusableElements.length) {
3686 index = 0;
3687
3688 // go to last item
3689 } else if (index === -1) {
3690 index = focusableElements.length - 1;
3691 }
3692 focusableElements[index].focus();
3693 return;
3694 }
3695 // no visible focusable elements, focus the popup
3696 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
3697 };
3698 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
3699 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
3700
3701 /**
3702 * @param {SweetAlertOptions} innerParams
3703 * @param {KeyboardEvent} event
3704 * @param {(dismiss: DismissReason) => void} dismissWith
3705 */
3706 const keydownHandler = (innerParams, event, dismissWith) => {
3707 if (!innerParams) {
3708 return; // This instance has already been destroyed
3709 }
3710
3711 // Ignore keydown during IME composition
3712 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
3713 // https://github.com/sweetalert2/sweetalert2/issues/720
3714 // https://github.com/sweetalert2/sweetalert2/issues/2406
3715 if (event.isComposing || event.keyCode === 229) {
3716 return;
3717 }
3718 if (innerParams.stopKeydownPropagation) {
3719 event.stopPropagation();
3720 }
3721
3722 // ENTER
3723 if (event.key === 'Enter') {
3724 handleEnter(event, innerParams);
3725 }
3726
3727 // TAB
3728 else if (event.key === 'Tab') {
3729 handleTab(event);
3730 }
3731
3732 // ARROWS - switch focus between buttons
3733 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
3734 handleArrows(event.key);
3735 }
3736
3737 // ESC
3738 else if (event.key === 'Escape') {
3739 handleEsc(event, innerParams, dismissWith);
3740 }
3741 };
3742
3743 /**
3744 * @param {KeyboardEvent} event
3745 * @param {SweetAlertOptions} innerParams
3746 */
3747 const handleEnter = (event, innerParams) => {
3748 // https://github.com/sweetalert2/sweetalert2/issues/2386
3749 if (!callIfFunction(innerParams.allowEnterKey)) {
3750 return;
3751 }
3752 const popup = getPopup();
3753 if (!popup || !innerParams.input) {
3754 return;
3755 }
3756 const input = getInput$1(popup, innerParams.input);
3757 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
3758 if (['textarea', 'file'].includes(innerParams.input)) {
3759 return; // do not submit
3760 }
3761 clickConfirm();
3762 event.preventDefault();
3763 }
3764 };
3765
3766 /**
3767 * @param {KeyboardEvent} event
3768 */
3769 const handleTab = event => {
3770 const targetElement = event.target;
3771 const focusableElements = getFocusableElements();
3772 let btnIndex = -1;
3773 for (let i = 0; i < focusableElements.length; i++) {
3774 if (targetElement === focusableElements[i]) {
3775 btnIndex = i;
3776 break;
3777 }
3778 }
3779
3780 // Cycle to the next button
3781 if (!event.shiftKey) {
3782 setFocus(btnIndex, 1);
3783 }
3784
3785 // Cycle to the prev button
3786 else {
3787 setFocus(btnIndex, -1);
3788 }
3789 event.stopPropagation();
3790 event.preventDefault();
3791 };
3792
3793 /**
3794 * @param {string} key
3795 */
3796 const handleArrows = key => {
3797 const actions = getActions();
3798 const confirmButton = getConfirmButton();
3799 const denyButton = getDenyButton();
3800 const cancelButton = getCancelButton();
3801 if (!actions || !confirmButton || !denyButton || !cancelButton) {
3802 return;
3803 }
3804 /** @type HTMLElement[] */
3805 const buttons = [confirmButton, denyButton, cancelButton];
3806 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
3807 return;
3808 }
3809 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
3810 let buttonToFocus = document.activeElement;
3811 if (!buttonToFocus) {
3812 return;
3813 }
3814 for (let i = 0; i < actions.children.length; i++) {
3815 buttonToFocus = buttonToFocus[sibling];
3816 if (!buttonToFocus) {
3817 return;
3818 }
3819 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
3820 break;
3821 }
3822 }
3823 if (buttonToFocus instanceof HTMLButtonElement) {
3824 buttonToFocus.focus();
3825 }
3826 };
3827
3828 /**
3829 * @param {KeyboardEvent} event
3830 * @param {SweetAlertOptions} innerParams
3831 * @param {(dismiss: DismissReason) => void} dismissWith
3832 */
3833 const handleEsc = (event, innerParams, dismissWith) => {
3834 event.preventDefault();
3835 if (callIfFunction(innerParams.allowEscapeKey)) {
3836 dismissWith(DismissReason.esc);
3837 }
3838 };
3839
3840 /**
3841 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3842 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3843 * This is the approach that Babel will probably take to implement private methods/fields
3844 * https://github.com/tc39/proposal-private-methods
3845 * https://github.com/babel/babel/pull/7555
3846 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3847 * then we can use that language feature.
3848 */
3849
3850 var privateMethods = {
3851 swalPromiseResolve: new WeakMap(),
3852 swalPromiseReject: new WeakMap()
3853 };
3854
3855 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
3856 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
3857 // elements not within the active modal dialog will not be surfaced if a user opens a screen
3858 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
3859
3860 const setAriaHidden = () => {
3861 const container = getContainer();
3862 const bodyChildren = Array.from(document.body.children);
3863 bodyChildren.forEach(el => {
3864 if (el.contains(container)) {
3865 return;
3866 }
3867 if (el.hasAttribute('aria-hidden')) {
3868 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
3869 }
3870 el.setAttribute('aria-hidden', 'true');
3871 });
3872 };
3873 const unsetAriaHidden = () => {
3874 const bodyChildren = Array.from(document.body.children);
3875 bodyChildren.forEach(el => {
3876 if (el.hasAttribute('data-previous-aria-hidden')) {
3877 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
3878 el.removeAttribute('data-previous-aria-hidden');
3879 } else {
3880 el.removeAttribute('aria-hidden');
3881 }
3882 });
3883 };
3884
3885 // @ts-ignore
3886 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
3887
3888 /**
3889 * Fix iOS scrolling
3890 * http://stackoverflow.com/q/39626302
3891 */
3892 const iOSfix = () => {
3893 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
3894 const offset = document.body.scrollTop;
3895 document.body.style.top = `${offset * -1}px`;
3896 addClass(document.body, swalClasses.iosfix);
3897 lockBodyScroll();
3898 }
3899 };
3900
3901 /**
3902 * https://github.com/sweetalert2/sweetalert2/issues/1246
3903 */
3904 const lockBodyScroll = () => {
3905 const container = getContainer();
3906 if (!container) {
3907 return;
3908 }
3909 /** @type {boolean} */
3910 let preventTouchMove;
3911 /**
3912 * @param {TouchEvent} event
3913 */
3914 container.ontouchstart = event => {
3915 preventTouchMove = shouldPreventTouchMove(event);
3916 };
3917 /**
3918 * @param {TouchEvent} event
3919 */
3920 container.ontouchmove = event => {
3921 if (preventTouchMove) {
3922 event.preventDefault();
3923 event.stopPropagation();
3924 }
3925 };
3926 };
3927
3928 /**
3929 * @param {TouchEvent} event
3930 * @returns {boolean}
3931 */
3932 const shouldPreventTouchMove = event => {
3933 const target = event.target;
3934 const container = getContainer();
3935 const htmlContainer = getHtmlContainer();
3936 if (!container || !htmlContainer) {
3937 return false;
3938 }
3939 if (isStylus(event) || isZoom(event)) {
3940 return false;
3941 }
3942 if (target === container) {
3943 return true;
3944 }
3945 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
3946 // #2823
3947 target.tagName !== 'INPUT' &&
3948 // #1603
3949 target.tagName !== 'TEXTAREA' &&
3950 // #2266
3951 !(isScrollable(htmlContainer) &&
3952 // #1944
3953 htmlContainer.contains(target))) {
3954 return true;
3955 }
3956 return false;
3957 };
3958
3959 /**
3960 * https://github.com/sweetalert2/sweetalert2/issues/1786
3961 *
3962 * @param {TouchEvent} event
3963 * @returns {boolean}
3964 */
3965 const isStylus = event => {
3966 return Boolean(event.touches && event.touches.length &&
3967 // @ts-ignore - touchType is not a standard property
3968 event.touches[0].touchType === 'stylus');
3969 };
3970
3971 /**
3972 * https://github.com/sweetalert2/sweetalert2/issues/1891
3973 *
3974 * @param {TouchEvent} event
3975 * @returns {boolean}
3976 */
3977 const isZoom = event => {
3978 return event.touches && event.touches.length > 1;
3979 };
3980 const undoIOSfix = () => {
3981 if (hasClass(document.body, swalClasses.iosfix)) {
3982 const offset = parseInt(document.body.style.top, 10);
3983 removeClass(document.body, swalClasses.iosfix);
3984 document.body.style.top = '';
3985 document.body.scrollTop = offset * -1;
3986 }
3987 };
3988
3989 /**
3990 * Measure scrollbar width for padding body during modal show/hide
3991 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
3992 *
3993 * @returns {number}
3994 */
3995 const measureScrollbar = () => {
3996 const scrollDiv = document.createElement('div');
3997 scrollDiv.className = swalClasses['scrollbar-measure'];
3998 document.body.appendChild(scrollDiv);
3999 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4000 document.body.removeChild(scrollDiv);
4001 return scrollbarWidth;
4002 };
4003
4004 /**
4005 * Remember state in cases where opening and handling a modal will fiddle with it.
4006 * @type {number | null}
4007 */
4008 let previousBodyPadding = null;
4009
4010 /**
4011 * @param {string} initialBodyOverflow
4012 */
4013 const replaceScrollbarWithPadding = initialBodyOverflow => {
4014 // for queues, do not do this more than once
4015 if (previousBodyPadding !== null) {
4016 return;
4017 }
4018 // if the body has overflow
4019 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4020 ) {
4021 // add padding so the content doesn't shift after removal of scrollbar
4022 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4023 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4024 }
4025 };
4026 const undoReplaceScrollbarWithPadding = () => {
4027 if (previousBodyPadding !== null) {
4028 document.body.style.paddingRight = `${previousBodyPadding}px`;
4029 previousBodyPadding = null;
4030 }
4031 };
4032
4033 /**
4034 * @param {SweetAlert} instance
4035 * @param {HTMLElement} container
4036 * @param {boolean} returnFocus
4037 * @param {(() => void) | undefined} didClose
4038 */
4039 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4040 if (isToast()) {
4041 triggerDidCloseAndDispose(instance, didClose);
4042 } else {
4043 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4044 removeKeydownHandler(globalState);
4045 }
4046
4047 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4048 // for some reason removing the container in Safari will scroll the document to bottom
4049 if (isSafariOrIOS) {
4050 container.setAttribute('style', 'display:none !important');
4051 container.removeAttribute('class');
4052 container.innerHTML = '';
4053 } else {
4054 container.remove();
4055 }
4056 if (isModal()) {
4057 undoReplaceScrollbarWithPadding();
4058 undoIOSfix();
4059 unsetAriaHidden();
4060 }
4061 removeBodyClasses();
4062 }
4063
4064 /**
4065 * Remove SweetAlert2 classes from body
4066 */
4067 function removeBodyClasses() {
4068 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4069 }
4070
4071 /**
4072 * Instance method to close sweetAlert
4073 *
4074 * @param {SweetAlertResult | undefined} resolveValue
4075 * @this {SweetAlert}
4076 */
4077 function close(resolveValue) {
4078 resolveValue = prepareResolveValue(resolveValue);
4079 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4080 const didClose = triggerClosePopup(this);
4081 if (this.isAwaitingPromise) {
4082 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4083 if (!resolveValue.isDismissed) {
4084 handleAwaitingPromise(this);
4085 swalPromiseResolve(resolveValue);
4086 }
4087 } else if (didClose) {
4088 // Resolve Swal promise
4089 swalPromiseResolve(resolveValue);
4090 }
4091 }
4092
4093 /**
4094 * @param {SweetAlert} instance
4095 * @returns {boolean}
4096 */
4097 const triggerClosePopup = instance => {
4098 const popup = getPopup();
4099 if (!popup) {
4100 return false;
4101 }
4102 const innerParams = privateProps.innerParams.get(instance);
4103 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4104 return false;
4105 }
4106 removeClass(popup, innerParams.showClass.popup);
4107 addClass(popup, innerParams.hideClass.popup);
4108 const backdrop = getContainer();
4109 removeClass(backdrop, innerParams.showClass.backdrop);
4110 addClass(backdrop, innerParams.hideClass.backdrop);
4111 handlePopupAnimation(instance, popup, innerParams);
4112 return true;
4113 };
4114
4115 /**
4116 * @param {Error | string} error
4117 * @this {SweetAlert}
4118 */
4119 function rejectPromise(error) {
4120 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4121 handleAwaitingPromise(this);
4122 if (rejectPromise) {
4123 // Reject Swal promise
4124 rejectPromise(error);
4125 }
4126 }
4127
4128 /**
4129 * @param {SweetAlert} instance
4130 */
4131 const handleAwaitingPromise = instance => {
4132 if (instance.isAwaitingPromise) {
4133 // @ts-ignore
4134 delete instance.isAwaitingPromise;
4135 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4136 if (!privateProps.innerParams.get(instance)) {
4137 instance._destroy();
4138 }
4139 }
4140 };
4141
4142 /**
4143 * @param {SweetAlertResult | undefined} resolveValue
4144 * @returns {SweetAlertResult}
4145 */
4146 const prepareResolveValue = resolveValue => {
4147 // When user calls Swal.close()
4148 if (typeof resolveValue === 'undefined') {
4149 return {
4150 isConfirmed: false,
4151 isDenied: false,
4152 isDismissed: true
4153 };
4154 }
4155 return Object.assign({
4156 isConfirmed: false,
4157 isDenied: false,
4158 isDismissed: false
4159 }, resolveValue);
4160 };
4161
4162 /**
4163 * @param {SweetAlert} instance
4164 * @param {HTMLElement} popup
4165 * @param {SweetAlertOptions} innerParams
4166 */
4167 const handlePopupAnimation = (instance, popup, innerParams) => {
4168 var _globalState$eventEmi;
4169 const container = getContainer();
4170 // If animation is supported, animate
4171 const animationIsSupported = hasCssAnimation(popup);
4172 if (typeof innerParams.willClose === 'function') {
4173 innerParams.willClose(popup);
4174 }
4175 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4176 if (animationIsSupported && container) {
4177 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4178 } else if (container) {
4179 // Otherwise, remove immediately
4180 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4181 }
4182 };
4183
4184 /**
4185 * @param {SweetAlert} instance
4186 * @param {HTMLElement} popup
4187 * @param {HTMLElement} container
4188 * @param {boolean} returnFocus
4189 * @param {(() => void) | undefined} didClose
4190 */
4191 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4192 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4193 /**
4194 * @param {AnimationEvent | TransitionEvent} e
4195 */
4196 const swalCloseAnimationFinished = function (e) {
4197 if (e.target === popup) {
4198 var _globalState$swalClos;
4199 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4200 delete globalState.swalCloseEventFinishedCallback;
4201 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4202 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4203 }
4204 };
4205 popup.addEventListener('animationend', swalCloseAnimationFinished);
4206 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4207 };
4208
4209 /**
4210 * @param {SweetAlert} instance
4211 * @param {(() => void) | undefined} didClose
4212 */
4213 const triggerDidCloseAndDispose = (instance, didClose) => {
4214 setTimeout(() => {
4215 var _globalState$eventEmi2;
4216 if (typeof didClose === 'function') {
4217 didClose.bind(instance.params)();
4218 }
4219 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4220 // instance might have been destroyed already
4221 if (instance._destroy) {
4222 instance._destroy();
4223 }
4224 });
4225 };
4226
4227 /**
4228 * Shows loader (spinner), this is useful with AJAX requests.
4229 * By default the loader be shown instead of the "Confirm" button.
4230 *
4231 * @param {HTMLButtonElement | null} [buttonToReplace]
4232 */
4233 const showLoading = buttonToReplace => {
4234 let popup = getPopup();
4235 if (!popup) {
4236 new Swal();
4237 }
4238 popup = getPopup();
4239 if (!popup) {
4240 return;
4241 }
4242 const loader = getLoader();
4243 if (isToast()) {
4244 hide(getIcon());
4245 } else {
4246 replaceButton(popup, buttonToReplace);
4247 }
4248 show(loader);
4249 popup.setAttribute('data-loading', 'true');
4250 popup.setAttribute('aria-busy', 'true');
4251 popup.focus();
4252 };
4253
4254 /**
4255 * @param {HTMLElement} popup
4256 * @param {HTMLButtonElement | null} [buttonToReplace]
4257 */
4258 const replaceButton = (popup, buttonToReplace) => {
4259 const actions = getActions();
4260 const loader = getLoader();
4261 if (!actions || !loader) {
4262 return;
4263 }
4264 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4265 buttonToReplace = getConfirmButton();
4266 }
4267 show(actions);
4268 if (buttonToReplace) {
4269 hide(buttonToReplace);
4270 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4271 actions.insertBefore(loader, buttonToReplace);
4272 }
4273 addClass([popup, actions], swalClasses.loading);
4274 };
4275
4276 /**
4277 * @param {SweetAlert} instance
4278 * @param {SweetAlertOptions} params
4279 */
4280 const handleInputOptionsAndValue = (instance, params) => {
4281 if (params.input === 'select' || params.input === 'radio') {
4282 handleInputOptions(instance, params);
4283 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4284 showLoading(getConfirmButton());
4285 handleInputValue(instance, params);
4286 }
4287 };
4288
4289 /**
4290 * @param {SweetAlert} instance
4291 * @param {SweetAlertOptions} innerParams
4292 * @returns {SweetAlertInputValue}
4293 */
4294 const getInputValue = (instance, innerParams) => {
4295 const input = instance.getInput();
4296 if (!input) {
4297 return null;
4298 }
4299 switch (innerParams.input) {
4300 case 'checkbox':
4301 return getCheckboxValue(input);
4302 case 'radio':
4303 return getRadioValue(input);
4304 case 'file':
4305 return getFileValue(input);
4306 default:
4307 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4308 }
4309 };
4310
4311 /**
4312 * @param {HTMLInputElement} input
4313 * @returns {number}
4314 */
4315 const getCheckboxValue = input => input.checked ? 1 : 0;
4316
4317 /**
4318 * @param {HTMLInputElement} input
4319 * @returns {string | null}
4320 */
4321 const getRadioValue = input => input.checked ? input.value : null;
4322
4323 /**
4324 * @param {HTMLInputElement} input
4325 * @returns {FileList | File | null}
4326 */
4327 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4328
4329 /**
4330 * @param {SweetAlert} instance
4331 * @param {SweetAlertOptions} params
4332 */
4333 const handleInputOptions = (instance, params) => {
4334 const popup = getPopup();
4335 if (!popup) {
4336 return;
4337 }
4338 /**
4339 * @param {*} inputOptions
4340 */
4341 const processInputOptions = inputOptions => {
4342 if (params.input === 'select') {
4343 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4344 } else if (params.input === 'radio') {
4345 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4346 }
4347 };
4348 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4349 showLoading(getConfirmButton());
4350 asPromise(params.inputOptions).then(inputOptions => {
4351 instance.hideLoading();
4352 processInputOptions(inputOptions);
4353 });
4354 } else if (typeof params.inputOptions === 'object') {
4355 processInputOptions(params.inputOptions);
4356 } else {
4357 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4358 }
4359 };
4360
4361 /**
4362 * @param {SweetAlert} instance
4363 * @param {SweetAlertOptions} params
4364 */
4365 const handleInputValue = (instance, params) => {
4366 const input = instance.getInput();
4367 if (!input) {
4368 return;
4369 }
4370 hide(input);
4371 asPromise(params.inputValue).then(inputValue => {
4372 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4373 show(input);
4374 input.focus();
4375 instance.hideLoading();
4376 }).catch(err => {
4377 error(`Error in inputValue promise: ${err}`);
4378 input.value = '';
4379 show(input);
4380 input.focus();
4381 instance.hideLoading();
4382 });
4383 };
4384
4385 /**
4386 * @param {HTMLElement} popup
4387 * @param {InputOptionFlattened[]} inputOptions
4388 * @param {SweetAlertOptions} params
4389 */
4390 function populateSelectOptions(popup, inputOptions, params) {
4391 const select = getDirectChildByClass(popup, swalClasses.select);
4392 if (!select) {
4393 return;
4394 }
4395 /**
4396 * @param {HTMLElement} parent
4397 * @param {string} optionLabel
4398 * @param {string} optionValue
4399 */
4400 const renderOption = (parent, optionLabel, optionValue) => {
4401 const option = document.createElement('option');
4402 option.value = optionValue;
4403 setInnerHtml(option, optionLabel);
4404 option.selected = isSelected(optionValue, params.inputValue);
4405 parent.appendChild(option);
4406 };
4407 inputOptions.forEach(inputOption => {
4408 const optionValue = inputOption[0];
4409 const optionLabel = inputOption[1];
4410 // <optgroup> spec:
4411 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4412 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4413 // check whether this is a <optgroup>
4414 if (Array.isArray(optionLabel)) {
4415 // if it is an array, then it is an <optgroup>
4416 const optgroup = document.createElement('optgroup');
4417 optgroup.label = optionValue;
4418 optgroup.disabled = false; // not configurable for now
4419 select.appendChild(optgroup);
4420 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4421 } else {
4422 // case of <option>
4423 renderOption(select, optionLabel, optionValue);
4424 }
4425 });
4426 select.focus();
4427 }
4428
4429 /**
4430 * @param {HTMLElement} popup
4431 * @param {InputOptionFlattened[]} inputOptions
4432 * @param {SweetAlertOptions} params
4433 */
4434 function populateRadioOptions(popup, inputOptions, params) {
4435 const radio = getDirectChildByClass(popup, swalClasses.radio);
4436 if (!radio) {
4437 return;
4438 }
4439 inputOptions.forEach(inputOption => {
4440 const radioValue = inputOption[0];
4441 const radioLabel = inputOption[1];
4442 const radioInput = document.createElement('input');
4443 const radioLabelElement = document.createElement('label');
4444 radioInput.type = 'radio';
4445 radioInput.name = swalClasses.radio;
4446 radioInput.value = radioValue;
4447 if (isSelected(radioValue, params.inputValue)) {
4448 radioInput.checked = true;
4449 }
4450 const label = document.createElement('span');
4451 setInnerHtml(label, radioLabel);
4452 label.className = swalClasses.label;
4453 radioLabelElement.appendChild(radioInput);
4454 radioLabelElement.appendChild(label);
4455 radio.appendChild(radioLabelElement);
4456 });
4457 const radios = radio.querySelectorAll('input');
4458 if (radios.length) {
4459 radios[0].focus();
4460 }
4461 }
4462
4463 /**
4464 * Converts `inputOptions` into an array of `[value, label]`s
4465 *
4466 * @param {*} inputOptions
4467 * @typedef {string[]} InputOptionFlattened
4468 * @returns {InputOptionFlattened[]}
4469 */
4470 const formatInputOptions = inputOptions => {
4471 /** @type {InputOptionFlattened[]} */
4472 const result = [];
4473 if (inputOptions instanceof Map) {
4474 inputOptions.forEach((value, key) => {
4475 let valueFormatted = value;
4476 if (typeof valueFormatted === 'object') {
4477 // case of <optgroup>
4478 valueFormatted = formatInputOptions(valueFormatted);
4479 }
4480 result.push([key, valueFormatted]);
4481 });
4482 } else {
4483 Object.keys(inputOptions).forEach(key => {
4484 let valueFormatted = inputOptions[key];
4485 if (typeof valueFormatted === 'object') {
4486 // case of <optgroup>
4487 valueFormatted = formatInputOptions(valueFormatted);
4488 }
4489 result.push([key, valueFormatted]);
4490 });
4491 }
4492 return result;
4493 };
4494
4495 /**
4496 * @param {string} optionValue
4497 * @param {SweetAlertInputValue} inputValue
4498 * @returns {boolean}
4499 */
4500 const isSelected = (optionValue, inputValue) => {
4501 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
4502 };
4503
4504 /**
4505 * @param {SweetAlert} instance
4506 */
4507 const handleConfirmButtonClick = instance => {
4508 const innerParams = privateProps.innerParams.get(instance);
4509 instance.disableButtons();
4510 if (innerParams.input) {
4511 handleConfirmOrDenyWithInput(instance, 'confirm');
4512 } else {
4513 confirm(instance, true);
4514 }
4515 };
4516
4517 /**
4518 * @param {SweetAlert} instance
4519 */
4520 const handleDenyButtonClick = instance => {
4521 const innerParams = privateProps.innerParams.get(instance);
4522 instance.disableButtons();
4523 if (innerParams.returnInputValueOnDeny) {
4524 handleConfirmOrDenyWithInput(instance, 'deny');
4525 } else {
4526 deny(instance, false);
4527 }
4528 };
4529
4530 /**
4531 * @param {SweetAlert} instance
4532 * @param {(dismiss: DismissReason) => void} dismissWith
4533 */
4534 const handleCancelButtonClick = (instance, dismissWith) => {
4535 instance.disableButtons();
4536 dismissWith(DismissReason.cancel);
4537 };
4538
4539 /**
4540 * @param {SweetAlert} instance
4541 * @param {'confirm' | 'deny'} type
4542 */
4543 const handleConfirmOrDenyWithInput = (instance, type) => {
4544 const innerParams = privateProps.innerParams.get(instance);
4545 if (!innerParams.input) {
4546 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4547 return;
4548 }
4549 const input = instance.getInput();
4550 const inputValue = getInputValue(instance, innerParams);
4551 if (innerParams.inputValidator) {
4552 handleInputValidator(instance, inputValue, type);
4553 } else if (input && !input.checkValidity()) {
4554 instance.enableButtons();
4555 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4556 } else if (type === 'deny') {
4557 deny(instance, inputValue);
4558 } else {
4559 confirm(instance, inputValue);
4560 }
4561 };
4562
4563 /**
4564 * @param {SweetAlert} instance
4565 * @param {SweetAlertInputValue} inputValue
4566 * @param {'confirm' | 'deny'} type
4567 */
4568 const handleInputValidator = (instance, inputValue, type) => {
4569 const innerParams = privateProps.innerParams.get(instance);
4570 instance.disableInput();
4571 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4572 validationPromise.then(validationMessage => {
4573 instance.enableButtons();
4574 instance.enableInput();
4575 if (validationMessage) {
4576 instance.showValidationMessage(validationMessage);
4577 } else if (type === 'deny') {
4578 deny(instance, inputValue);
4579 } else {
4580 confirm(instance, inputValue);
4581 }
4582 });
4583 };
4584
4585 /**
4586 * @param {SweetAlert} instance
4587 * @param {*} value
4588 */
4589 const deny = (instance, value) => {
4590 const innerParams = privateProps.innerParams.get(instance);
4591 if (innerParams.showLoaderOnDeny) {
4592 showLoading(getDenyButton());
4593 }
4594 if (innerParams.preDeny) {
4595 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
4596 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
4597 preDenyPromise.then(preDenyValue => {
4598 if (preDenyValue === false) {
4599 instance.hideLoading();
4600 handleAwaitingPromise(instance);
4601 } else {
4602 instance.close(/** @type SweetAlertResult */{
4603 isDenied: true,
4604 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
4605 });
4606 }
4607 }).catch(error => rejectWith(instance, error));
4608 } else {
4609 instance.close(/** @type SweetAlertResult */{
4610 isDenied: true,
4611 value
4612 });
4613 }
4614 };
4615
4616 /**
4617 * @param {SweetAlert} instance
4618 * @param {*} value
4619 */
4620 const succeedWith = (instance, value) => {
4621 instance.close(/** @type SweetAlertResult */{
4622 isConfirmed: true,
4623 value
4624 });
4625 };
4626
4627 /**
4628 *
4629 * @param {SweetAlert} instance
4630 * @param {string} error
4631 */
4632 const rejectWith = (instance, error) => {
4633 instance.rejectPromise(error);
4634 };
4635
4636 /**
4637 *
4638 * @param {SweetAlert} instance
4639 * @param {*} value
4640 */
4641 const confirm = (instance, value) => {
4642 const innerParams = privateProps.innerParams.get(instance);
4643 if (innerParams.showLoaderOnConfirm) {
4644 showLoading();
4645 }
4646 if (innerParams.preConfirm) {
4647 instance.resetValidationMessage();
4648 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
4649 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
4650 preConfirmPromise.then(preConfirmValue => {
4651 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
4652 instance.hideLoading();
4653 handleAwaitingPromise(instance);
4654 } else {
4655 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
4656 }
4657 }).catch(error => rejectWith(instance, error));
4658 } else {
4659 succeedWith(instance, value);
4660 }
4661 };
4662
4663 /**
4664 * Hides loader and shows back the button which was hidden by .showLoading()
4665 * @this {SweetAlert}
4666 */
4667 function hideLoading() {
4668 // do nothing if popup is closed
4669 const innerParams = privateProps.innerParams.get(this);
4670 if (!innerParams) {
4671 return;
4672 }
4673 const domCache = privateProps.domCache.get(this);
4674 hide(domCache.loader);
4675 if (isToast()) {
4676 if (innerParams.icon) {
4677 show(getIcon());
4678 }
4679 } else {
4680 showRelatedButton(domCache);
4681 }
4682 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
4683 domCache.popup.removeAttribute('aria-busy');
4684 domCache.popup.removeAttribute('data-loading');
4685 domCache.confirmButton.disabled = false;
4686 domCache.denyButton.disabled = false;
4687 domCache.cancelButton.disabled = false;
4688 }
4689
4690 /**
4691 * @param {DomCache} domCache
4692 */
4693 const showRelatedButton = domCache => {
4694 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
4695 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
4696 if (buttonToReplace.length) {
4697 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
4698 } else if (allButtonsAreHidden()) {
4699 hide(domCache.actions);
4700 }
4701 };
4702
4703 /**
4704 * Gets the input DOM node, this method works with input parameter.
4705 *
4706 * @returns {HTMLInputElement | null}
4707 * @this {SweetAlert}
4708 */
4709 function getInput() {
4710 const innerParams = privateProps.innerParams.get(this);
4711 const domCache = privateProps.domCache.get(this);
4712 if (!domCache) {
4713 return null;
4714 }
4715 return getInput$1(domCache.popup, innerParams.input);
4716 }
4717
4718 /**
4719 * @param {SweetAlert} instance
4720 * @param {string[]} buttons
4721 * @param {boolean} disabled
4722 */
4723 function setButtonsDisabled(instance, buttons, disabled) {
4724 const domCache = privateProps.domCache.get(instance);
4725 buttons.forEach(button => {
4726 domCache[button].disabled = disabled;
4727 });
4728 }
4729
4730 /**
4731 * @param {HTMLInputElement | null} input
4732 * @param {boolean} disabled
4733 */
4734 function setInputDisabled(input, disabled) {
4735 const popup = getPopup();
4736 if (!popup || !input) {
4737 return;
4738 }
4739 if (input.type === 'radio') {
4740 /** @type {NodeListOf<HTMLInputElement>} */
4741 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
4742 for (let i = 0; i < radios.length; i++) {
4743 radios[i].disabled = disabled;
4744 }
4745 } else {
4746 input.disabled = disabled;
4747 }
4748 }
4749
4750 /**
4751 * Enable all the buttons
4752 * @this {SweetAlert}
4753 */
4754 function enableButtons() {
4755 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
4756 }
4757
4758 /**
4759 * Disable all the buttons
4760 * @this {SweetAlert}
4761 */
4762 function disableButtons() {
4763 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
4764 }
4765
4766 /**
4767 * Enable the input field
4768 * @this {SweetAlert}
4769 */
4770 function enableInput() {
4771 setInputDisabled(this.getInput(), false);
4772 }
4773
4774 /**
4775 * Disable the input field
4776 * @this {SweetAlert}
4777 */
4778 function disableInput() {
4779 setInputDisabled(this.getInput(), true);
4780 }
4781
4782 /**
4783 * Show block with validation message
4784 *
4785 * @param {string} error
4786 * @this {SweetAlert}
4787 */
4788 function showValidationMessage(error) {
4789 const domCache = privateProps.domCache.get(this);
4790 const params = privateProps.innerParams.get(this);
4791 setInnerHtml(domCache.validationMessage, error);
4792 domCache.validationMessage.className = swalClasses['validation-message'];
4793 if (params.customClass && params.customClass.validationMessage) {
4794 addClass(domCache.validationMessage, params.customClass.validationMessage);
4795 }
4796 show(domCache.validationMessage);
4797 const input = this.getInput();
4798 if (input) {
4799 input.setAttribute('aria-invalid', 'true');
4800 input.setAttribute('aria-describedby', swalClasses['validation-message']);
4801 focusInput(input);
4802 addClass(input, swalClasses.inputerror);
4803 }
4804 }
4805
4806 /**
4807 * Hide block with validation message
4808 *
4809 * @this {SweetAlert}
4810 */
4811 function resetValidationMessage() {
4812 const domCache = privateProps.domCache.get(this);
4813 if (domCache.validationMessage) {
4814 hide(domCache.validationMessage);
4815 }
4816 const input = this.getInput();
4817 if (input) {
4818 input.removeAttribute('aria-invalid');
4819 input.removeAttribute('aria-describedby');
4820 removeClass(input, swalClasses.inputerror);
4821 }
4822 }
4823
4824 const defaultParams = {
4825 title: '',
4826 titleText: '',
4827 text: '',
4828 html: '',
4829 footer: '',
4830 icon: undefined,
4831 iconColor: undefined,
4832 iconHtml: undefined,
4833 template: undefined,
4834 toast: false,
4835 draggable: false,
4836 animation: true,
4837 theme: 'light',
4838 showClass: {
4839 popup: 'swal2-show',
4840 backdrop: 'swal2-backdrop-show',
4841 icon: 'swal2-icon-show'
4842 },
4843 hideClass: {
4844 popup: 'swal2-hide',
4845 backdrop: 'swal2-backdrop-hide',
4846 icon: 'swal2-icon-hide'
4847 },
4848 customClass: {},
4849 target: 'body',
4850 color: undefined,
4851 backdrop: true,
4852 heightAuto: true,
4853 allowOutsideClick: true,
4854 allowEscapeKey: true,
4855 allowEnterKey: true,
4856 stopKeydownPropagation: true,
4857 keydownListenerCapture: false,
4858 showConfirmButton: true,
4859 showDenyButton: false,
4860 showCancelButton: false,
4861 preConfirm: undefined,
4862 preDeny: undefined,
4863 confirmButtonText: 'OK',
4864 confirmButtonAriaLabel: '',
4865 confirmButtonColor: undefined,
4866 denyButtonText: 'No',
4867 denyButtonAriaLabel: '',
4868 denyButtonColor: undefined,
4869 cancelButtonText: 'Cancel',
4870 cancelButtonAriaLabel: '',
4871 cancelButtonColor: undefined,
4872 buttonsStyling: true,
4873 reverseButtons: false,
4874 focusConfirm: true,
4875 focusDeny: false,
4876 focusCancel: false,
4877 returnFocus: true,
4878 showCloseButton: false,
4879 closeButtonHtml: '&times;',
4880 closeButtonAriaLabel: 'Close this dialog',
4881 loaderHtml: '',
4882 showLoaderOnConfirm: false,
4883 showLoaderOnDeny: false,
4884 imageUrl: undefined,
4885 imageWidth: undefined,
4886 imageHeight: undefined,
4887 imageAlt: '',
4888 timer: undefined,
4889 timerProgressBar: false,
4890 width: undefined,
4891 padding: undefined,
4892 background: undefined,
4893 input: undefined,
4894 inputPlaceholder: '',
4895 inputLabel: '',
4896 inputValue: '',
4897 inputOptions: {},
4898 inputAutoFocus: true,
4899 inputAutoTrim: true,
4900 inputAttributes: {},
4901 inputValidator: undefined,
4902 returnInputValueOnDeny: false,
4903 validationMessage: undefined,
4904 grow: false,
4905 position: 'center',
4906 progressSteps: [],
4907 currentProgressStep: undefined,
4908 progressStepsDistance: undefined,
4909 willOpen: undefined,
4910 didOpen: undefined,
4911 didRender: undefined,
4912 willClose: undefined,
4913 didClose: undefined,
4914 didDestroy: undefined,
4915 scrollbarPadding: true,
4916 topLayer: false
4917 };
4918 const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'draggable', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'theme', 'willClose'];
4919
4920 /** @type {Record<string, string | undefined>} */
4921 const deprecatedParams = {
4922 allowEnterKey: undefined
4923 };
4924 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
4925
4926 /**
4927 * Is valid parameter
4928 *
4929 * @param {string} paramName
4930 * @returns {boolean}
4931 */
4932 const isValidParameter = paramName => {
4933 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
4934 };
4935
4936 /**
4937 * Is valid parameter for Swal.update() method
4938 *
4939 * @param {string} paramName
4940 * @returns {boolean}
4941 */
4942 const isUpdatableParameter = paramName => {
4943 return updatableParams.indexOf(paramName) !== -1;
4944 };
4945
4946 /**
4947 * Is deprecated parameter
4948 *
4949 * @param {string} paramName
4950 * @returns {string | undefined}
4951 */
4952 const isDeprecatedParameter = paramName => {
4953 return deprecatedParams[paramName];
4954 };
4955
4956 /**
4957 * @param {string} param
4958 */
4959 const checkIfParamIsValid = param => {
4960 if (!isValidParameter(param)) {
4961 warn(`Unknown parameter "${param}"`);
4962 }
4963 };
4964
4965 /**
4966 * @param {string} param
4967 */
4968 const checkIfToastParamIsValid = param => {
4969 if (toastIncompatibleParams.includes(param)) {
4970 warn(`The parameter "${param}" is incompatible with toasts`);
4971 }
4972 };
4973
4974 /**
4975 * @param {string} param
4976 */
4977 const checkIfParamIsDeprecated = param => {
4978 const isDeprecated = isDeprecatedParameter(param);
4979 if (isDeprecated) {
4980 warnAboutDeprecation(param, isDeprecated);
4981 }
4982 };
4983
4984 /**
4985 * Show relevant warnings for given params
4986 *
4987 * @param {SweetAlertOptions} params
4988 */
4989 const showWarningsForParams = params => {
4990 if (params.backdrop === false && params.allowOutsideClick) {
4991 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
4992 }
4993 if (params.theme && !['light', 'dark', 'auto', 'minimal', 'borderless', 'bootstrap-4', 'bootstrap-4-light', 'bootstrap-4-dark', 'bootstrap-5', 'bootstrap-5-light', 'bootstrap-5-dark', 'material-ui', 'material-ui-light', 'material-ui-dark', 'embed-iframe', 'bulma', 'bulma-light', 'bulma-dark'].includes(params.theme)) {
4994 warn(`Invalid theme "${params.theme}"`);
4995 }
4996 for (const param in params) {
4997 checkIfParamIsValid(param);
4998 if (params.toast) {
4999 checkIfToastParamIsValid(param);
5000 }
5001 checkIfParamIsDeprecated(param);
5002 }
5003 };
5004
5005 /**
5006 * Updates popup parameters.
5007 *
5008 * @this {any}
5009 * @param {SweetAlertOptions} params
5010 */
5011 function update(params) {
5012 const container = getContainer();
5013 const popup = getPopup();
5014 const innerParams = privateProps.innerParams.get(this);
5015 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5016 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.`);
5017 return;
5018 }
5019 const validUpdatableParams = filterValidParams(params);
5020 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5021 showWarningsForParams(updatedParams);
5022 if (container) {
5023 container.dataset['swal2Theme'] = updatedParams.theme;
5024 }
5025 render(this, updatedParams);
5026 privateProps.innerParams.set(this, updatedParams);
5027 Object.defineProperties(this, {
5028 params: {
5029 value: Object.assign({}, this.params, params),
5030 writable: false,
5031 enumerable: true
5032 }
5033 });
5034 }
5035
5036 /**
5037 * @param {SweetAlertOptions} params
5038 * @returns {SweetAlertOptions}
5039 */
5040 const filterValidParams = params => {
5041 /** @type {Record<string, any>} */
5042 const validUpdatableParams = {};
5043 Object.keys(params).forEach(param => {
5044 if (isUpdatableParameter(param)) {
5045 const typedParams = /** @type {Record<string, any>} */params;
5046 validUpdatableParams[param] = typedParams[param];
5047 } else {
5048 warn(`Invalid parameter to update: ${param}`);
5049 }
5050 });
5051 return validUpdatableParams;
5052 };
5053
5054 /**
5055 * Dispose the current SweetAlert2 instance
5056 * @this {SweetAlert}
5057 */
5058 function _destroy() {
5059 var _globalState$eventEmi;
5060 const domCache = privateProps.domCache.get(this);
5061 const innerParams = privateProps.innerParams.get(this);
5062 if (!innerParams) {
5063 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5064 return; // This instance has already been destroyed
5065 }
5066
5067 // Check if there is another Swal closing
5068 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5069 globalState.swalCloseEventFinishedCallback();
5070 delete globalState.swalCloseEventFinishedCallback;
5071 }
5072 if (typeof innerParams.didDestroy === 'function') {
5073 innerParams.didDestroy();
5074 }
5075 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5076 disposeSwal(this);
5077 }
5078
5079 /**
5080 * @param {SweetAlert} instance
5081 */
5082 const disposeSwal = instance => {
5083 disposeWeakMaps(instance);
5084 // Unset this.params so GC will dispose it (#1569)
5085 // @ts-ignore
5086 delete instance.params;
5087 // Unset globalState props so GC will dispose globalState (#1569)
5088 delete globalState.keydownHandler;
5089 delete globalState.keydownTarget;
5090 // Unset currentInstance
5091 delete globalState.currentInstance;
5092 };
5093
5094 /**
5095 * @param {SweetAlert} instance
5096 */
5097 const disposeWeakMaps = instance => {
5098 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5099 if (instance.isAwaitingPromise) {
5100 unsetWeakMaps(privateProps, instance);
5101 instance.isAwaitingPromise = true;
5102 } else {
5103 unsetWeakMaps(privateMethods, instance);
5104 unsetWeakMaps(privateProps, instance);
5105
5106 // @ts-ignore
5107 delete instance.isAwaitingPromise;
5108 // Unset instance methods
5109 // @ts-ignore
5110 delete instance.disableButtons;
5111 // @ts-ignore
5112 delete instance.enableButtons;
5113 // @ts-ignore
5114 delete instance.getInput;
5115 // @ts-ignore
5116 delete instance.disableInput;
5117 // @ts-ignore
5118 delete instance.enableInput;
5119 // @ts-ignore
5120 delete instance.hideLoading;
5121 // @ts-ignore
5122 delete instance.disableLoading;
5123 // @ts-ignore
5124 delete instance.showValidationMessage;
5125 // @ts-ignore
5126 delete instance.resetValidationMessage;
5127 // @ts-ignore
5128 delete instance.close;
5129 // @ts-ignore
5130 delete instance.closePopup;
5131 // @ts-ignore
5132 delete instance.closeModal;
5133 // @ts-ignore
5134 delete instance.closeToast;
5135 // @ts-ignore
5136 delete instance.rejectPromise;
5137 // @ts-ignore
5138 delete instance.update;
5139 // @ts-ignore
5140 delete instance._destroy;
5141 }
5142 };
5143
5144 /**
5145 * @param {Record<string, WeakMap<any, any>>} obj
5146 * @param {SweetAlert} instance
5147 */
5148 const unsetWeakMaps = (obj, instance) => {
5149 for (const i in obj) {
5150 obj[i].delete(instance);
5151 }
5152 };
5153
5154 var instanceMethods = /*#__PURE__*/Object.freeze({
5155 __proto__: null,
5156 _destroy: _destroy,
5157 close: close,
5158 closeModal: close,
5159 closePopup: close,
5160 closeToast: close,
5161 disableButtons: disableButtons,
5162 disableInput: disableInput,
5163 disableLoading: hideLoading,
5164 enableButtons: enableButtons,
5165 enableInput: enableInput,
5166 getInput: getInput,
5167 handleAwaitingPromise: handleAwaitingPromise,
5168 hideLoading: hideLoading,
5169 rejectPromise: rejectPromise,
5170 resetValidationMessage: resetValidationMessage,
5171 showValidationMessage: showValidationMessage,
5172 update: update
5173 });
5174
5175 /**
5176 * @param {SweetAlertOptions} innerParams
5177 * @param {DomCache} domCache
5178 * @param {(dismiss: DismissReason) => void} dismissWith
5179 */
5180 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5181 if (innerParams.toast) {
5182 handleToastClick(innerParams, domCache, dismissWith);
5183 } else {
5184 // Ignore click events that had mousedown on the popup but mouseup on the container
5185 // This can happen when the user drags a slider
5186 handleModalMousedown(domCache);
5187
5188 // Ignore click events that had mousedown on the container but mouseup on the popup
5189 handleContainerMousedown(domCache);
5190 handleModalClick(innerParams, domCache, dismissWith);
5191 }
5192 };
5193
5194 /**
5195 * @param {SweetAlertOptions} innerParams
5196 * @param {DomCache} domCache
5197 * @param {(dismiss: DismissReason) => void} dismissWith
5198 */
5199 const handleToastClick = (innerParams, domCache, dismissWith) => {
5200 // Closing toast by internal click
5201 domCache.popup.onclick = () => {
5202 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5203 return;
5204 }
5205 dismissWith(DismissReason.close);
5206 };
5207 };
5208
5209 /**
5210 * @param {SweetAlertOptions} innerParams
5211 * @returns {boolean}
5212 */
5213 const isAnyButtonShown = innerParams => {
5214 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5215 };
5216 let ignoreOutsideClick = false;
5217
5218 /**
5219 * @param {DomCache} domCache
5220 */
5221 const handleModalMousedown = domCache => {
5222 domCache.popup.onmousedown = () => {
5223 domCache.container.onmouseup = function (e) {
5224 domCache.container.onmouseup = () => {};
5225 // We only check if the mouseup target is the container because usually it doesn't
5226 // have any other direct children aside of the popup
5227 if (e.target === domCache.container) {
5228 ignoreOutsideClick = true;
5229 }
5230 };
5231 };
5232 };
5233
5234 /**
5235 * @param {DomCache} domCache
5236 */
5237 const handleContainerMousedown = domCache => {
5238 domCache.container.onmousedown = e => {
5239 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5240 if (e.target === domCache.container) {
5241 e.preventDefault();
5242 }
5243 domCache.popup.onmouseup = function (e) {
5244 domCache.popup.onmouseup = () => {};
5245 // We also need to check if the mouseup target is a child of the popup
5246 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5247 ignoreOutsideClick = true;
5248 }
5249 };
5250 };
5251 };
5252
5253 /**
5254 * @param {SweetAlertOptions} innerParams
5255 * @param {DomCache} domCache
5256 * @param {(dismiss: DismissReason) => void} dismissWith
5257 */
5258 const handleModalClick = (innerParams, domCache, dismissWith) => {
5259 domCache.container.onclick = e => {
5260 if (ignoreOutsideClick) {
5261 ignoreOutsideClick = false;
5262 return;
5263 }
5264 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5265 dismissWith(DismissReason.backdrop);
5266 }
5267 };
5268 };
5269
5270 /**
5271 * @param {any} elem
5272 * @returns {boolean}
5273 */
5274 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
5275
5276 /**
5277 * @param {any} elem
5278 * @returns {boolean}
5279 */
5280 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5281
5282 /**
5283 * @param {any[]} args
5284 * @returns {SweetAlertOptions}
5285 */
5286 const argsToParams = args => {
5287 /** @type {Record<string, any>} */
5288 const params = {};
5289 if (typeof args[0] === 'object' && !isElement(args[0])) {
5290 Object.assign(params, args[0]);
5291 } else {
5292 ['title', 'html', 'icon'].forEach((name, index) => {
5293 const arg = args[index];
5294 if (typeof arg === 'string' || isElement(arg)) {
5295 params[name] = arg;
5296 } else if (arg !== undefined) {
5297 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5298 }
5299 });
5300 }
5301 return params;
5302 };
5303
5304 /**
5305 * Main method to create a new SweetAlert2 popup
5306 *
5307 * @this {new (...args: any[]) => any}
5308 * @param {...SweetAlertOptions} args
5309 * @returns {Promise<SweetAlertResult>}
5310 */
5311 function fire(...args) {
5312 return new this(...args);
5313 }
5314
5315 /**
5316 * Returns an extended version of `Swal` containing `params` as defaults.
5317 * Useful for reusing Swal configuration.
5318 *
5319 * For example:
5320 *
5321 * Before:
5322 * const textPromptOptions = { input: 'text', showCancelButton: true }
5323 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5324 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5325 *
5326 * After:
5327 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5328 * const {value: firstName} = await TextPrompt('What is your first name?')
5329 * const {value: lastName} = await TextPrompt('What is your last name?')
5330 *
5331 * @param {SweetAlertOptions} mixinParams
5332 * @returns {SweetAlert}
5333 * @this {typeof import('../SweetAlert.js').SweetAlert}
5334 */
5335 function mixin(mixinParams) {
5336 // @ts-ignore: 'this' refers to the SweetAlert constructor
5337 class MixinSwal extends this {
5338 /**
5339 * @param {any} params
5340 * @param {any} priorityMixinParams
5341 */
5342 _main(params, priorityMixinParams) {
5343 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5344 }
5345 }
5346 // @ts-ignore
5347 return MixinSwal;
5348 }
5349
5350 /**
5351 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5352 * Otherwise, returns undefined.
5353 *
5354 * @returns {number | undefined}
5355 */
5356 const getTimerLeft = () => {
5357 return globalState.timeout && globalState.timeout.getTimerLeft();
5358 };
5359
5360 /**
5361 * Stop timer. Returns number of milliseconds of timer remained.
5362 * If `timer` parameter isn't set, returns undefined.
5363 *
5364 * @returns {number | undefined}
5365 */
5366 const stopTimer = () => {
5367 if (globalState.timeout) {
5368 stopTimerProgressBar();
5369 return globalState.timeout.stop();
5370 }
5371 };
5372
5373 /**
5374 * Resume timer. Returns number of milliseconds of timer remained.
5375 * If `timer` parameter isn't set, returns undefined.
5376 *
5377 * @returns {number | undefined}
5378 */
5379 const resumeTimer = () => {
5380 if (globalState.timeout) {
5381 const remaining = globalState.timeout.start();
5382 animateTimerProgressBar(remaining);
5383 return remaining;
5384 }
5385 };
5386
5387 /**
5388 * Resume timer. Returns number of milliseconds of timer remained.
5389 * If `timer` parameter isn't set, returns undefined.
5390 *
5391 * @returns {number | undefined}
5392 */
5393 const toggleTimer = () => {
5394 const timer = globalState.timeout;
5395 return timer && (timer.running ? stopTimer() : resumeTimer());
5396 };
5397
5398 /**
5399 * Increase timer. Returns number of milliseconds of an updated timer.
5400 * If `timer` parameter isn't set, returns undefined.
5401 *
5402 * @param {number} ms
5403 * @returns {number | undefined}
5404 */
5405 const increaseTimer = ms => {
5406 if (globalState.timeout) {
5407 const remaining = globalState.timeout.increase(ms);
5408 animateTimerProgressBar(remaining, true);
5409 return remaining;
5410 }
5411 };
5412
5413 /**
5414 * Check if timer is running. Returns true if timer is running
5415 * or false if timer is paused or stopped.
5416 * If `timer` parameter isn't set, returns undefined
5417 *
5418 * @returns {boolean}
5419 */
5420 const isTimerRunning = () => {
5421 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5422 };
5423
5424 let bodyClickListenerAdded = false;
5425 /** @type {Record<string, any>} */
5426 const clickHandlers = {};
5427
5428 /**
5429 * @this {any}
5430 * @param {string} attr
5431 */
5432 function bindClickHandler(attr = 'data-swal-template') {
5433 clickHandlers[attr] = this;
5434 if (!bodyClickListenerAdded) {
5435 document.body.addEventListener('click', bodyClickListener);
5436 bodyClickListenerAdded = true;
5437 }
5438 }
5439
5440 /**
5441 * @param {MouseEvent} event
5442 */
5443 const bodyClickListener = event => {
5444 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5445 for (const attr in clickHandlers) {
5446 const template = el.getAttribute && el.getAttribute(attr);
5447 if (template) {
5448 clickHandlers[attr].fire({
5449 template
5450 });
5451 return;
5452 }
5453 }
5454 }
5455 };
5456
5457 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5458
5459 class EventEmitter {
5460 constructor() {
5461 /** @type {Events} */
5462 this.events = {};
5463 }
5464
5465 /**
5466 * @param {string} eventName
5467 * @returns {EventHandlers}
5468 */
5469 _getHandlersByEventName(eventName) {
5470 if (typeof this.events[eventName] === 'undefined') {
5471 // not Set because we need to keep the FIFO order
5472 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5473 this.events[eventName] = [];
5474 }
5475 return this.events[eventName];
5476 }
5477
5478 /**
5479 * @param {string} eventName
5480 * @param {EventHandler} eventHandler
5481 */
5482 on(eventName, eventHandler) {
5483 const currentHandlers = this._getHandlersByEventName(eventName);
5484 if (!currentHandlers.includes(eventHandler)) {
5485 currentHandlers.push(eventHandler);
5486 }
5487 }
5488
5489 /**
5490 * @param {string} eventName
5491 * @param {EventHandler} eventHandler
5492 */
5493 once(eventName, eventHandler) {
5494 /**
5495 * @param {...any} args
5496 */
5497 const onceFn = (...args) => {
5498 this.removeListener(eventName, onceFn);
5499 // @ts-ignore
5500 eventHandler.apply(this, args);
5501 };
5502 this.on(eventName, onceFn);
5503 }
5504
5505 /**
5506 * @param {string} eventName
5507 * @param {...any} args
5508 */
5509 emit(eventName, ...args) {
5510 this._getHandlersByEventName(eventName).forEach(
5511 /**
5512 * @param {EventHandler} eventHandler
5513 */
5514 eventHandler => {
5515 try {
5516 // @ts-ignore
5517 eventHandler.apply(this, args);
5518 } catch (error) {
5519 console.error(error);
5520 }
5521 });
5522 }
5523
5524 /**
5525 * @param {string} eventName
5526 * @param {EventHandler} eventHandler
5527 */
5528 removeListener(eventName, eventHandler) {
5529 const currentHandlers = this._getHandlersByEventName(eventName);
5530 const index = currentHandlers.indexOf(eventHandler);
5531 if (index > -1) {
5532 currentHandlers.splice(index, 1);
5533 }
5534 }
5535
5536 /**
5537 * @param {string} eventName
5538 */
5539 removeAllListeners(eventName) {
5540 if (this.events[eventName] !== undefined) {
5541 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5542 this.events[eventName].length = 0;
5543 }
5544 }
5545 reset() {
5546 this.events = {};
5547 }
5548 }
5549
5550 globalState.eventEmitter = new EventEmitter();
5551
5552 /**
5553 * @param {string} eventName
5554 * @param {EventHandler} eventHandler
5555 */
5556 const on = (eventName, eventHandler) => {
5557 if (globalState.eventEmitter) {
5558 globalState.eventEmitter.on(eventName, eventHandler);
5559 }
5560 };
5561
5562 /**
5563 * @param {string} eventName
5564 * @param {EventHandler} eventHandler
5565 */
5566 const once = (eventName, eventHandler) => {
5567 if (globalState.eventEmitter) {
5568 globalState.eventEmitter.once(eventName, eventHandler);
5569 }
5570 };
5571
5572 /**
5573 * @param {string} [eventName]
5574 * @param {EventHandler} [eventHandler]
5575 */
5576 const off = (eventName, eventHandler) => {
5577 if (!globalState.eventEmitter) {
5578 return;
5579 }
5580
5581 // Remove all handlers for all events
5582 if (!eventName) {
5583 globalState.eventEmitter.reset();
5584 return;
5585 }
5586 if (eventHandler) {
5587 // Remove a specific handler
5588 globalState.eventEmitter.removeListener(eventName, eventHandler);
5589 } else {
5590 // Remove all handlers for a specific event
5591 globalState.eventEmitter.removeAllListeners(eventName);
5592 }
5593 };
5594
5595 var staticMethods = /*#__PURE__*/Object.freeze({
5596 __proto__: null,
5597 argsToParams: argsToParams,
5598 bindClickHandler: bindClickHandler,
5599 clickCancel: clickCancel,
5600 clickConfirm: clickConfirm,
5601 clickDeny: clickDeny,
5602 enableLoading: showLoading,
5603 fire: fire,
5604 getActions: getActions,
5605 getCancelButton: getCancelButton,
5606 getCloseButton: getCloseButton,
5607 getConfirmButton: getConfirmButton,
5608 getContainer: getContainer,
5609 getDenyButton: getDenyButton,
5610 getFocusableElements: getFocusableElements,
5611 getFooter: getFooter,
5612 getHtmlContainer: getHtmlContainer,
5613 getIcon: getIcon,
5614 getIconContent: getIconContent,
5615 getImage: getImage,
5616 getInputLabel: getInputLabel,
5617 getLoader: getLoader,
5618 getPopup: getPopup,
5619 getProgressSteps: getProgressSteps,
5620 getTimerLeft: getTimerLeft,
5621 getTimerProgressBar: getTimerProgressBar,
5622 getTitle: getTitle,
5623 getValidationMessage: getValidationMessage,
5624 increaseTimer: increaseTimer,
5625 isDeprecatedParameter: isDeprecatedParameter,
5626 isLoading: isLoading,
5627 isTimerRunning: isTimerRunning,
5628 isUpdatableParameter: isUpdatableParameter,
5629 isValidParameter: isValidParameter,
5630 isVisible: isVisible,
5631 mixin: mixin,
5632 off: off,
5633 on: on,
5634 once: once,
5635 resumeTimer: resumeTimer,
5636 showLoading: showLoading,
5637 stopTimer: stopTimer,
5638 toggleTimer: toggleTimer
5639 });
5640
5641 class Timer {
5642 /**
5643 * @param {() => void} callback
5644 * @param {number} delay
5645 */
5646 constructor(callback, delay) {
5647 this.callback = callback;
5648 this.remaining = delay;
5649 this.running = false;
5650 this.start();
5651 }
5652
5653 /**
5654 * @returns {number}
5655 */
5656 start() {
5657 if (!this.running) {
5658 this.running = true;
5659 this.started = new Date();
5660 this.id = setTimeout(this.callback, this.remaining);
5661 }
5662 return this.remaining;
5663 }
5664
5665 /**
5666 * @returns {number}
5667 */
5668 stop() {
5669 if (this.started && this.running) {
5670 this.running = false;
5671 clearTimeout(this.id);
5672 this.remaining -= new Date().getTime() - this.started.getTime();
5673 }
5674 return this.remaining;
5675 }
5676
5677 /**
5678 * @param {number} n
5679 * @returns {number}
5680 */
5681 increase(n) {
5682 const running = this.running;
5683 if (running) {
5684 this.stop();
5685 }
5686 this.remaining += n;
5687 if (running) {
5688 this.start();
5689 }
5690 return this.remaining;
5691 }
5692
5693 /**
5694 * @returns {number}
5695 */
5696 getTimerLeft() {
5697 if (this.running) {
5698 this.stop();
5699 this.start();
5700 }
5701 return this.remaining;
5702 }
5703
5704 /**
5705 * @returns {boolean}
5706 */
5707 isRunning() {
5708 return this.running;
5709 }
5710 }
5711
5712 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
5713
5714 /**
5715 * @param {SweetAlertOptions} params
5716 * @returns {SweetAlertOptions}
5717 */
5718 const getTemplateParams = params => {
5719 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
5720 if (!template) {
5721 return {};
5722 }
5723 /** @type {DocumentFragment} */
5724 const templateContent = template.content;
5725 showWarningsForElements(templateContent);
5726 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
5727 return result;
5728 };
5729
5730 /**
5731 * @param {DocumentFragment} templateContent
5732 * @returns {Record<string, string | boolean | number>}
5733 */
5734 const getSwalParams = templateContent => {
5735 /** @type {Record<string, string | boolean | number>} */
5736 const result = {};
5737 /** @type {HTMLElement[]} */
5738 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
5739 swalParams.forEach(param => {
5740 showWarningsForAttributes(param, ['name', 'value']);
5741 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
5742 const value = param.getAttribute('value');
5743 if (!paramName || !value) {
5744 return;
5745 }
5746 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
5747 result[paramName] = value !== 'false';
5748 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
5749 result[paramName] = JSON.parse(value);
5750 } else {
5751 result[paramName] = value;
5752 }
5753 });
5754 return result;
5755 };
5756
5757 /**
5758 * @param {DocumentFragment} templateContent
5759 * @returns {Record<string, () => void>}
5760 */
5761 const getSwalFunctionParams = templateContent => {
5762 /** @type {Record<string, () => void>} */
5763 const result = {};
5764 /** @type {HTMLElement[]} */
5765 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
5766 swalFunctions.forEach(param => {
5767 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
5768 const value = param.getAttribute('value');
5769 if (!paramName || !value) {
5770 return;
5771 }
5772 result[paramName] = new Function(`return ${value}`)();
5773 });
5774 return result;
5775 };
5776
5777 /**
5778 * @param {DocumentFragment} templateContent
5779 * @returns {Record<string, string | boolean>}
5780 */
5781 const getSwalButtons = templateContent => {
5782 /** @type {Record<string, string | boolean>} */
5783 const result = {};
5784 /** @type {HTMLElement[]} */
5785 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
5786 swalButtons.forEach(button => {
5787 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
5788 const type = button.getAttribute('type');
5789 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
5790 return;
5791 }
5792 result[`${type}ButtonText`] = button.innerHTML;
5793 result[`show${capitalizeFirstLetter(type)}Button`] = true;
5794 if (button.hasAttribute('color')) {
5795 const color = button.getAttribute('color');
5796 if (color !== null) {
5797 result[`${type}ButtonColor`] = color;
5798 }
5799 }
5800 if (button.hasAttribute('aria-label')) {
5801 const ariaLabel = button.getAttribute('aria-label');
5802 if (ariaLabel !== null) {
5803 result[`${type}ButtonAriaLabel`] = ariaLabel;
5804 }
5805 }
5806 });
5807 return result;
5808 };
5809
5810 /**
5811 * @param {DocumentFragment} templateContent
5812 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
5813 */
5814 const getSwalImage = templateContent => {
5815 const result = {};
5816 /** @type {HTMLElement | null} */
5817 const image = templateContent.querySelector('swal-image');
5818 if (image) {
5819 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
5820 if (image.hasAttribute('src')) {
5821 result.imageUrl = image.getAttribute('src') || undefined;
5822 }
5823 if (image.hasAttribute('width')) {
5824 result.imageWidth = image.getAttribute('width') || undefined;
5825 }
5826 if (image.hasAttribute('height')) {
5827 result.imageHeight = image.getAttribute('height') || undefined;
5828 }
5829 if (image.hasAttribute('alt')) {
5830 result.imageAlt = image.getAttribute('alt') || undefined;
5831 }
5832 }
5833 return result;
5834 };
5835
5836 /**
5837 * @param {DocumentFragment} templateContent
5838 * @returns {object}
5839 */
5840 const getSwalIcon = templateContent => {
5841 const result = {};
5842 /** @type {HTMLElement | null} */
5843 const icon = templateContent.querySelector('swal-icon');
5844 if (icon) {
5845 showWarningsForAttributes(icon, ['type', 'color']);
5846 if (icon.hasAttribute('type')) {
5847 result.icon = icon.getAttribute('type');
5848 }
5849 if (icon.hasAttribute('color')) {
5850 result.iconColor = icon.getAttribute('color');
5851 }
5852 result.iconHtml = icon.innerHTML;
5853 }
5854 return result;
5855 };
5856
5857 /**
5858 * @param {DocumentFragment} templateContent
5859 * @returns {object}
5860 */
5861 const getSwalInput = templateContent => {
5862 /** @type {Record<string, any>} */
5863 const result = {};
5864 /** @type {HTMLElement | null} */
5865 const input = templateContent.querySelector('swal-input');
5866 if (input) {
5867 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
5868 result.input = input.getAttribute('type') || 'text';
5869 if (input.hasAttribute('label')) {
5870 result.inputLabel = input.getAttribute('label');
5871 }
5872 if (input.hasAttribute('placeholder')) {
5873 result.inputPlaceholder = input.getAttribute('placeholder');
5874 }
5875 if (input.hasAttribute('value')) {
5876 result.inputValue = input.getAttribute('value');
5877 }
5878 }
5879 /** @type {HTMLElement[]} */
5880 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
5881 if (inputOptions.length) {
5882 result.inputOptions = {};
5883 inputOptions.forEach(option => {
5884 showWarningsForAttributes(option, ['value']);
5885 const optionValue = option.getAttribute('value');
5886 if (!optionValue) {
5887 return;
5888 }
5889 const optionName = option.innerHTML;
5890 result.inputOptions[optionValue] = optionName;
5891 });
5892 }
5893 return result;
5894 };
5895
5896 /**
5897 * @param {DocumentFragment} templateContent
5898 * @param {string[]} paramNames
5899 * @returns {Record<string, string>}
5900 */
5901 const getSwalStringParams = (templateContent, paramNames) => {
5902 /** @type {Record<string, string>} */
5903 const result = {};
5904 for (const i in paramNames) {
5905 const paramName = paramNames[i];
5906 /** @type {HTMLElement | null} */
5907 const tag = templateContent.querySelector(paramName);
5908 if (tag) {
5909 showWarningsForAttributes(tag, []);
5910 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
5911 }
5912 }
5913 return result;
5914 };
5915
5916 /**
5917 * @param {DocumentFragment} templateContent
5918 */
5919 const showWarningsForElements = templateContent => {
5920 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
5921 Array.from(templateContent.children).forEach(el => {
5922 const tagName = el.tagName.toLowerCase();
5923 if (!allowedElements.includes(tagName)) {
5924 warn(`Unrecognized element <${tagName}>`);
5925 }
5926 });
5927 };
5928
5929 /**
5930 * @param {HTMLElement} el
5931 * @param {string[]} allowedAttributes
5932 */
5933 const showWarningsForAttributes = (el, allowedAttributes) => {
5934 Array.from(el.attributes).forEach(attribute => {
5935 if (allowedAttributes.indexOf(attribute.name) === -1) {
5936 warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(', ')}` : 'To set the value, use HTML within the element.'}`]);
5937 }
5938 });
5939 };
5940
5941 const SHOW_CLASS_TIMEOUT = 10;
5942
5943 /**
5944 * Open popup, add necessary classes and styles, fix scrollbar
5945 *
5946 * @param {SweetAlertOptions} params
5947 */
5948 const openPopup = params => {
5949 var _globalState$eventEmi, _globalState$eventEmi2;
5950 const container = getContainer();
5951 const popup = getPopup();
5952 if (!container || !popup) {
5953 return;
5954 }
5955 if (typeof params.willOpen === 'function') {
5956 params.willOpen(popup);
5957 }
5958 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
5959 const bodyStyles = window.getComputedStyle(document.body);
5960 const initialBodyOverflow = bodyStyles.overflowY;
5961 addClasses(container, popup, params);
5962
5963 // scrolling is 'hidden' until animation is done, after that 'auto'
5964 setTimeout(() => {
5965 setScrollingVisibility(container, popup);
5966 }, SHOW_CLASS_TIMEOUT);
5967 if (isModal()) {
5968 // Using ternary instead of ?? operator for Webpack 4 compatibility
5969 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
5970 setAriaHidden();
5971 }
5972 if (!isToast() && !globalState.previousActiveElement) {
5973 globalState.previousActiveElement = document.activeElement;
5974 }
5975 if (typeof params.didOpen === 'function') {
5976 const didOpen = params.didOpen;
5977 setTimeout(() => didOpen(popup));
5978 }
5979 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
5980 };
5981
5982 /**
5983 * @param {Event} event
5984 */
5985 const swalOpenAnimationFinished = event => {
5986 const popup = getPopup();
5987 if (!popup || event.target !== popup) {
5988 return;
5989 }
5990 const container = getContainer();
5991 if (!container) {
5992 return;
5993 }
5994 popup.removeEventListener('animationend', swalOpenAnimationFinished);
5995 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
5996 container.style.overflowY = 'auto';
5997
5998 // no-transition is added in init() in case one swal is opened right after another
5999 removeClass(container, swalClasses['no-transition']);
6000 };
6001
6002 /**
6003 * @param {HTMLElement} container
6004 * @param {HTMLElement} popup
6005 */
6006 const setScrollingVisibility = (container, popup) => {
6007 if (hasCssAnimation(popup)) {
6008 container.style.overflowY = 'hidden';
6009 popup.addEventListener('animationend', swalOpenAnimationFinished);
6010 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6011 } else {
6012 container.style.overflowY = 'auto';
6013 }
6014 };
6015
6016 /**
6017 * @param {HTMLElement} container
6018 * @param {boolean} scrollbarPadding
6019 * @param {string} initialBodyOverflow
6020 */
6021 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6022 iOSfix();
6023 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6024 replaceScrollbarWithPadding(initialBodyOverflow);
6025 }
6026
6027 // sweetalert2/issues/1247
6028 setTimeout(() => {
6029 container.scrollTop = 0;
6030 });
6031 };
6032
6033 /**
6034 * @param {HTMLElement} container
6035 * @param {HTMLElement} popup
6036 * @param {SweetAlertOptions} params
6037 */
6038 const addClasses = (container, popup, params) => {
6039 var _params$showClass;
6040 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6041 addClass(container, params.showClass.backdrop);
6042 }
6043 if (params.animation) {
6044 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6045 popup.style.setProperty('opacity', '0', 'important');
6046 show(popup, 'grid');
6047 setTimeout(() => {
6048 var _params$showClass2;
6049 // Animate popup right after showing it
6050 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6051 addClass(popup, params.showClass.popup);
6052 }
6053 // and remove the opacity workaround
6054 popup.style.removeProperty('opacity');
6055 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6056 } else {
6057 show(popup, 'grid');
6058 }
6059 addClass([document.documentElement, document.body], swalClasses.shown);
6060 if (params.heightAuto && params.backdrop && !params.toast) {
6061 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6062 }
6063 };
6064
6065 var defaultInputValidators = {
6066 /**
6067 * @param {string} string
6068 * @param {string} [validationMessage]
6069 * @returns {Promise<string | void>}
6070 */
6071 email: (string, validationMessage) => {
6072 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6073 },
6074 /**
6075 * @param {string} string
6076 * @param {string} [validationMessage]
6077 * @returns {Promise<string | void>}
6078 */
6079 url: (string, validationMessage) => {
6080 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6081 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');
6082 }
6083 };
6084
6085 /**
6086 * @param {SweetAlertOptions} params
6087 */
6088 function setDefaultInputValidators(params) {
6089 // Use default `inputValidator` for supported input types if not provided
6090 if (params.inputValidator) {
6091 return;
6092 }
6093 if (params.input === 'email') {
6094 params.inputValidator = defaultInputValidators['email'];
6095 }
6096 if (params.input === 'url') {
6097 params.inputValidator = defaultInputValidators['url'];
6098 }
6099 }
6100
6101 /**
6102 * @param {SweetAlertOptions} params
6103 */
6104 function validateCustomTargetElement(params) {
6105 // Determine if the custom target element is valid
6106 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6107 warn('Target parameter is not valid, defaulting to "body"');
6108 params.target = 'body';
6109 }
6110 }
6111
6112 /**
6113 * Set type, text and actions on popup
6114 *
6115 * @param {SweetAlertOptions} params
6116 */
6117 function setParameters(params) {
6118 setDefaultInputValidators(params);
6119
6120 // showLoaderOnConfirm && preConfirm
6121 if (params.showLoaderOnConfirm && !params.preConfirm) {
6122 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');
6123 }
6124 validateCustomTargetElement(params);
6125
6126 // Replace newlines with <br> in title
6127 if (typeof params.title === 'string') {
6128 params.title = params.title.split('\n').join('<br />');
6129 }
6130 init(params);
6131 }
6132
6133 /** @type {SweetAlert} */
6134 let currentInstance;
6135 var _promise = /*#__PURE__*/new WeakMap();
6136 class SweetAlert {
6137 /**
6138 * @param {...(SweetAlertOptions | string)} args
6139 * @this {SweetAlert}
6140 */
6141 constructor(...args) {
6142 /**
6143 * @type {Promise<SweetAlertResult>}
6144 */
6145 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
6146 isConfirmed: false,
6147 isDenied: false,
6148 isDismissed: true
6149 }));
6150 // Prevent run in Node env
6151 if (typeof window === 'undefined') {
6152 return;
6153 }
6154 currentInstance = this;
6155
6156 // @ts-ignore
6157 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6158
6159 /** @type {Readonly<SweetAlertOptions>} */
6160 this.params = outerParams;
6161
6162 /** @type {boolean} */
6163 this.isAwaitingPromise = false;
6164 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6165 }
6166
6167 /**
6168 * @param {any} userParams
6169 * @param {any} mixinParams
6170 */
6171 _main(userParams, mixinParams = {}) {
6172 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6173 if (globalState.currentInstance) {
6174 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6175 const {
6176 isAwaitingPromise
6177 } = globalState.currentInstance;
6178 globalState.currentInstance._destroy();
6179 if (!isAwaitingPromise) {
6180 swalPromiseResolve({
6181 isDismissed: true
6182 });
6183 }
6184 if (isModal()) {
6185 unsetAriaHidden();
6186 }
6187 }
6188 globalState.currentInstance = currentInstance;
6189 const innerParams = prepareParams(userParams, mixinParams);
6190 setParameters(innerParams);
6191 Object.freeze(innerParams);
6192
6193 // clear the previous timer
6194 if (globalState.timeout) {
6195 globalState.timeout.stop();
6196 delete globalState.timeout;
6197 }
6198
6199 // clear the restore focus timeout
6200 clearTimeout(globalState.restoreFocusTimeout);
6201 const domCache = populateDomCache(currentInstance);
6202 render(currentInstance, innerParams);
6203 privateProps.innerParams.set(currentInstance, innerParams);
6204 return swalPromise(currentInstance, domCache, innerParams);
6205 }
6206
6207 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6208 /**
6209 * @param {any} onFulfilled
6210 */
6211 then(onFulfilled) {
6212 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6213 }
6214
6215 /**
6216 * @param {any} onFinally
6217 */
6218 finally(onFinally) {
6219 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6220 }
6221 }
6222
6223 /**
6224 * @param {SweetAlert} instance
6225 * @param {DomCache} domCache
6226 * @param {SweetAlertOptions} innerParams
6227 * @returns {Promise<SweetAlertResult>}
6228 */
6229 const swalPromise = (instance, domCache, innerParams) => {
6230 return new Promise((resolve, reject) => {
6231 // functions to handle all closings/dismissals
6232 /**
6233 * @param {DismissReason} dismiss
6234 */
6235 const dismissWith = dismiss => {
6236 instance.close({
6237 isDismissed: true,
6238 dismiss,
6239 isConfirmed: false,
6240 isDenied: false
6241 });
6242 };
6243 privateMethods.swalPromiseResolve.set(instance, resolve);
6244 privateMethods.swalPromiseReject.set(instance, reject);
6245 domCache.confirmButton.onclick = () => {
6246 handleConfirmButtonClick(instance);
6247 };
6248 domCache.denyButton.onclick = () => {
6249 handleDenyButtonClick(instance);
6250 };
6251 domCache.cancelButton.onclick = () => {
6252 handleCancelButtonClick(instance, dismissWith);
6253 };
6254 domCache.closeButton.onclick = () => {
6255 dismissWith(DismissReason.close);
6256 };
6257 handlePopupClick(innerParams, domCache, dismissWith);
6258 addKeydownHandler(globalState, innerParams, dismissWith);
6259 handleInputOptionsAndValue(instance, innerParams);
6260 openPopup(innerParams);
6261 setupTimer(globalState, innerParams, dismissWith);
6262 initFocus(domCache, innerParams);
6263
6264 // Scroll container to top on open (#1247, #1946)
6265 setTimeout(() => {
6266 domCache.container.scrollTop = 0;
6267 });
6268 });
6269 };
6270
6271 /**
6272 * @param {SweetAlertOptions} userParams
6273 * @param {SweetAlertOptions} mixinParams
6274 * @returns {SweetAlertOptions}
6275 */
6276 const prepareParams = (userParams, mixinParams) => {
6277 const templateParams = getTemplateParams(userParams);
6278 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6279 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6280 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6281 if (params.animation === false) {
6282 params.showClass = {
6283 backdrop: 'swal2-noanimation'
6284 };
6285 params.hideClass = {};
6286 }
6287 return params;
6288 };
6289
6290 /**
6291 * @param {SweetAlert} instance
6292 * @returns {DomCache}
6293 */
6294 const populateDomCache = instance => {
6295 const domCache = /** @type {DomCache} */{
6296 popup: (/** @type {HTMLElement} */getPopup()),
6297 container: (/** @type {HTMLElement} */getContainer()),
6298 actions: (/** @type {HTMLElement} */getActions()),
6299 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6300 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6301 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6302 loader: (/** @type {HTMLElement} */getLoader()),
6303 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6304 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6305 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6306 };
6307 privateProps.domCache.set(instance, domCache);
6308 return domCache;
6309 };
6310
6311 /**
6312 * @param {GlobalState} globalState
6313 * @param {SweetAlertOptions} innerParams
6314 * @param {(dismiss: DismissReason) => void} dismissWith
6315 */
6316 const setupTimer = (globalState, innerParams, dismissWith) => {
6317 const timerProgressBar = getTimerProgressBar();
6318 hide(timerProgressBar);
6319 if (innerParams.timer) {
6320 globalState.timeout = new Timer(() => {
6321 dismissWith('timer');
6322 delete globalState.timeout;
6323 }, innerParams.timer);
6324 if (innerParams.timerProgressBar && timerProgressBar) {
6325 show(timerProgressBar);
6326 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6327 setTimeout(() => {
6328 if (globalState.timeout && globalState.timeout.running) {
6329 // timer can be already stopped or unset at this point
6330 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6331 }
6332 });
6333 }
6334 }
6335 };
6336
6337 /**
6338 * Initialize focus in the popup:
6339 *
6340 * 1. If `toast` is `true`, don't steal focus from the document.
6341 * 2. Else if there is an [autofocus] element, focus it.
6342 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6343 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6344 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6345 * 6. Else focus the first focusable element in a popup (if any).
6346 *
6347 * @param {DomCache} domCache
6348 * @param {SweetAlertOptions} innerParams
6349 */
6350 const initFocus = (domCache, innerParams) => {
6351 if (innerParams.toast) {
6352 return;
6353 }
6354 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6355 if (!callIfFunction(innerParams.allowEnterKey)) {
6356 warnAboutDeprecation('allowEnterKey');
6357 blurActiveElement();
6358 return;
6359 }
6360 if (focusAutofocus(domCache)) {
6361 return;
6362 }
6363 if (focusButton(domCache, innerParams)) {
6364 return;
6365 }
6366 setFocus(-1, 1);
6367 };
6368
6369 /**
6370 * @param {DomCache} domCache
6371 * @returns {boolean}
6372 */
6373 const focusAutofocus = domCache => {
6374 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6375 for (const autofocusElement of autofocusElements) {
6376 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6377 autofocusElement.focus();
6378 return true;
6379 }
6380 }
6381 return false;
6382 };
6383
6384 /**
6385 * @param {DomCache} domCache
6386 * @param {SweetAlertOptions} innerParams
6387 * @returns {boolean}
6388 */
6389 const focusButton = (domCache, innerParams) => {
6390 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6391 domCache.denyButton.focus();
6392 return true;
6393 }
6394 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6395 domCache.cancelButton.focus();
6396 return true;
6397 }
6398 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6399 domCache.confirmButton.focus();
6400 return true;
6401 }
6402 return false;
6403 };
6404 const blurActiveElement = () => {
6405 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
6406 document.activeElement.blur();
6407 }
6408 };
6409
6410 // Assign instance methods from src/instanceMethods/*.js to prototype
6411 SweetAlert.prototype.disableButtons = disableButtons;
6412 SweetAlert.prototype.enableButtons = enableButtons;
6413 SweetAlert.prototype.getInput = getInput;
6414 SweetAlert.prototype.disableInput = disableInput;
6415 SweetAlert.prototype.enableInput = enableInput;
6416 SweetAlert.prototype.hideLoading = hideLoading;
6417 SweetAlert.prototype.disableLoading = hideLoading;
6418 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6419 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6420 SweetAlert.prototype.close = close;
6421 SweetAlert.prototype.closePopup = close;
6422 SweetAlert.prototype.closeModal = close;
6423 SweetAlert.prototype.closeToast = close;
6424 SweetAlert.prototype.rejectPromise = rejectPromise;
6425 SweetAlert.prototype.update = update;
6426 SweetAlert.prototype._destroy = _destroy;
6427
6428 // Assign static methods from src/staticMethods/*.js to constructor
6429 Object.assign(SweetAlert, staticMethods);
6430
6431 // Proxy to instance methods to constructor, for now, for backwards compatibility
6432 Object.keys(instanceMethods).forEach(key => {
6433 /**
6434 * @param {...(SweetAlertOptions | string | undefined)} args
6435 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6436 */
6437 // @ts-ignore: Dynamic property assignment for backwards compatibility
6438 SweetAlert[key] = function (...args) {
6439 // @ts-ignore
6440 if (currentInstance && currentInstance[key]) {
6441 // @ts-ignore
6442 return currentInstance[key](...args);
6443 }
6444 return undefined;
6445 };
6446 });
6447 SweetAlert.DismissReason = DismissReason;
6448 SweetAlert.version = '11.26.17';
6449
6450 const Swal = SweetAlert;
6451 // @ts-ignore
6452 Swal.default = Swal;
6453
6454 return Swal;
6455
6456 }));
6457 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6458 "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,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !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 var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset: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(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);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:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.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}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .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}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.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}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.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)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.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}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.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-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@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:-0.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-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-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@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:-0.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-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}}");
6459
6460 /***/ },
6461
6462 /***/ "./node_modules/toastify-js/src/toastify.js"
6463 /*!**************************************************!*\
6464 !*** ./node_modules/toastify-js/src/toastify.js ***!
6465 \**************************************************/
6466 (module) {
6467
6468 /*!
6469 * Toastify js 1.12.0
6470 * https://github.com/apvarun/toastify-js
6471 * @license MIT licensed
6472 *
6473 * Copyright (C) 2018 Varun A P
6474 */
6475 (function(root, factory) {
6476 if ( true && module.exports) {
6477 module.exports = factory();
6478 } else {
6479 root.Toastify = factory();
6480 }
6481 })(this, function(global) {
6482 // Object initialization
6483 var Toastify = function(options) {
6484 // Returning a new init object
6485 return new Toastify.lib.init(options);
6486 },
6487 // Library version
6488 version = "1.12.0";
6489
6490 // Set the default global options
6491 Toastify.defaults = {
6492 oldestFirst: true,
6493 text: "Toastify is awesome!",
6494 node: undefined,
6495 duration: 3000,
6496 selector: undefined,
6497 callback: function () {
6498 },
6499 destination: undefined,
6500 newWindow: false,
6501 close: false,
6502 gravity: "toastify-top",
6503 positionLeft: false,
6504 position: '',
6505 backgroundColor: '',
6506 avatar: "",
6507 className: "",
6508 stopOnFocus: true,
6509 onClick: function () {
6510 },
6511 offset: {x: 0, y: 0},
6512 escapeMarkup: true,
6513 ariaLive: 'polite',
6514 style: {background: ''}
6515 };
6516
6517 // Defining the prototype of the object
6518 Toastify.lib = Toastify.prototype = {
6519 toastify: version,
6520
6521 constructor: Toastify,
6522
6523 // Initializing the object with required parameters
6524 init: function(options) {
6525 // Verifying and validating the input object
6526 if (!options) {
6527 options = {};
6528 }
6529
6530 // Creating the options object
6531 this.options = {};
6532
6533 this.toastElement = null;
6534
6535 // Validating the options
6536 this.options.text = options.text || Toastify.defaults.text; // Display message
6537 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6538 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6539 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6540 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6541 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6542 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6543 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6544 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6545 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6546 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6547 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6548 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6549 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6550 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6551 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6552 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6553 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6554 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6555 this.options.style = options.style || Toastify.defaults.style;
6556 if(options.backgroundColor) {
6557 this.options.style.background = options.backgroundColor;
6558 }
6559
6560 // Returning the current object for chaining functions
6561 return this;
6562 },
6563
6564 // Building the DOM element
6565 buildToast: function() {
6566 // Validating if the options are defined
6567 if (!this.options) {
6568 throw "Toastify is not initialized";
6569 }
6570
6571 // Creating the DOM object
6572 var divElement = document.createElement("div");
6573 divElement.className = "toastify on " + this.options.className;
6574
6575 // Positioning toast to left or right or center
6576 if (!!this.options.position) {
6577 divElement.className += " toastify-" + this.options.position;
6578 } else {
6579 // To be depreciated in further versions
6580 if (this.options.positionLeft === true) {
6581 divElement.className += " toastify-left";
6582 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6583 } else {
6584 // Default position
6585 divElement.className += " toastify-right";
6586 }
6587 }
6588
6589 // Assigning gravity of element
6590 divElement.className += " " + this.options.gravity;
6591
6592 if (this.options.backgroundColor) {
6593 // This is being deprecated in favor of using the style HTML DOM property
6594 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
6595 }
6596
6597 // Loop through our style object and apply styles to divElement
6598 for (var property in this.options.style) {
6599 divElement.style[property] = this.options.style[property];
6600 }
6601
6602 // Announce the toast to screen readers
6603 if (this.options.ariaLive) {
6604 divElement.setAttribute('aria-live', this.options.ariaLive)
6605 }
6606
6607 // Adding the toast message/node
6608 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
6609 // If we have a valid node, we insert it
6610 divElement.appendChild(this.options.node)
6611 } else {
6612 if (this.options.escapeMarkup) {
6613 divElement.innerText = this.options.text;
6614 } else {
6615 divElement.innerHTML = this.options.text;
6616 }
6617
6618 if (this.options.avatar !== "") {
6619 var avatarElement = document.createElement("img");
6620 avatarElement.src = this.options.avatar;
6621
6622 avatarElement.className = "toastify-avatar";
6623
6624 if (this.options.position == "left" || this.options.positionLeft === true) {
6625 // Adding close icon on the left of content
6626 divElement.appendChild(avatarElement);
6627 } else {
6628 // Adding close icon on the right of content
6629 divElement.insertAdjacentElement("afterbegin", avatarElement);
6630 }
6631 }
6632 }
6633
6634 // Adding a close icon to the toast
6635 if (this.options.close === true) {
6636 // Create a span for close element
6637 var closeElement = document.createElement("button");
6638 closeElement.type = "button";
6639 closeElement.setAttribute("aria-label", "Close");
6640 closeElement.className = "toast-close";
6641 closeElement.innerHTML = "&#10006;";
6642
6643 // Triggering the removal of toast from DOM on close click
6644 closeElement.addEventListener(
6645 "click",
6646 function(event) {
6647 event.stopPropagation();
6648 this.removeElement(this.toastElement);
6649 window.clearTimeout(this.toastElement.timeOutValue);
6650 }.bind(this)
6651 );
6652
6653 //Calculating screen width
6654 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
6655
6656 // Adding the close icon to the toast element
6657 // Display on the right if screen width is less than or equal to 360px
6658 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
6659 // Adding close icon on the left of content
6660 divElement.insertAdjacentElement("afterbegin", closeElement);
6661 } else {
6662 // Adding close icon on the right of content
6663 divElement.appendChild(closeElement);
6664 }
6665 }
6666
6667 // Clear timeout while toast is focused
6668 if (this.options.stopOnFocus && this.options.duration > 0) {
6669 var self = this;
6670 // stop countdown
6671 divElement.addEventListener(
6672 "mouseover",
6673 function(event) {
6674 window.clearTimeout(divElement.timeOutValue);
6675 }
6676 )
6677 // add back the timeout
6678 divElement.addEventListener(
6679 "mouseleave",
6680 function() {
6681 divElement.timeOutValue = window.setTimeout(
6682 function() {
6683 // Remove the toast from DOM
6684 self.removeElement(divElement);
6685 },
6686 self.options.duration
6687 )
6688 }
6689 )
6690 }
6691
6692 // Adding an on-click destination path
6693 if (typeof this.options.destination !== "undefined") {
6694 divElement.addEventListener(
6695 "click",
6696 function(event) {
6697 event.stopPropagation();
6698 if (this.options.newWindow === true) {
6699 window.open(this.options.destination, "_blank");
6700 } else {
6701 window.location = this.options.destination;
6702 }
6703 }.bind(this)
6704 );
6705 }
6706
6707 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
6708 divElement.addEventListener(
6709 "click",
6710 function(event) {
6711 event.stopPropagation();
6712 this.options.onClick();
6713 }.bind(this)
6714 );
6715 }
6716
6717 // Adding offset
6718 if(typeof this.options.offset === "object") {
6719
6720 var x = getAxisOffsetAValue("x", this.options);
6721 var y = getAxisOffsetAValue("y", this.options);
6722
6723 var xOffset = this.options.position == "left" ? x : "-" + x;
6724 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
6725
6726 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
6727
6728 }
6729
6730 // Returning the generated element
6731 return divElement;
6732 },
6733
6734 // Displaying the toast
6735 showToast: function() {
6736 // Creating the DOM object for the toast
6737 this.toastElement = this.buildToast();
6738
6739 // Getting the root element to with the toast needs to be added
6740 var rootElement;
6741 if (typeof this.options.selector === "string") {
6742 rootElement = document.getElementById(this.options.selector);
6743 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
6744 rootElement = this.options.selector;
6745 } else {
6746 rootElement = document.body;
6747 }
6748
6749 // Validating if root element is present in DOM
6750 if (!rootElement) {
6751 throw "Root element is not defined";
6752 }
6753
6754 // Adding the DOM element
6755 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
6756 rootElement.insertBefore(this.toastElement, elementToInsert);
6757
6758 // Repositioning the toasts in case multiple toasts are present
6759 Toastify.reposition();
6760
6761 if (this.options.duration > 0) {
6762 this.toastElement.timeOutValue = window.setTimeout(
6763 function() {
6764 // Remove the toast from DOM
6765 this.removeElement(this.toastElement);
6766 }.bind(this),
6767 this.options.duration
6768 ); // Binding `this` for function invocation
6769 }
6770
6771 // Supporting function chaining
6772 return this;
6773 },
6774
6775 hideToast: function() {
6776 if (this.toastElement.timeOutValue) {
6777 clearTimeout(this.toastElement.timeOutValue);
6778 }
6779 this.removeElement(this.toastElement);
6780 },
6781
6782 // Removing the element from the DOM
6783 removeElement: function(toastElement) {
6784 // Hiding the element
6785 // toastElement.classList.remove("on");
6786 toastElement.className = toastElement.className.replace(" on", "");
6787
6788 // Removing the element from DOM after transition end
6789 window.setTimeout(
6790 function() {
6791 // remove options node if any
6792 if (this.options.node && this.options.node.parentNode) {
6793 this.options.node.parentNode.removeChild(this.options.node);
6794 }
6795
6796 // Remove the element from the DOM, only when the parent node was not removed before.
6797 if (toastElement.parentNode) {
6798 toastElement.parentNode.removeChild(toastElement);
6799 }
6800
6801 // Calling the callback function
6802 this.options.callback.call(toastElement);
6803
6804 // Repositioning the toasts again
6805 Toastify.reposition();
6806 }.bind(this),
6807 400
6808 ); // Binding `this` for function invocation
6809 },
6810 };
6811
6812 // Positioning the toasts on the DOM
6813 Toastify.reposition = function() {
6814
6815 // Top margins with gravity
6816 var topLeftOffsetSize = {
6817 top: 15,
6818 bottom: 15,
6819 };
6820 var topRightOffsetSize = {
6821 top: 15,
6822 bottom: 15,
6823 };
6824 var offsetSize = {
6825 top: 15,
6826 bottom: 15,
6827 };
6828
6829 // Get all toast messages on the DOM
6830 var allToasts = document.getElementsByClassName("toastify");
6831
6832 var classUsed;
6833
6834 // Modifying the position of each toast element
6835 for (var i = 0; i < allToasts.length; i++) {
6836 // Getting the applied gravity
6837 if (containsClass(allToasts[i], "toastify-top") === true) {
6838 classUsed = "toastify-top";
6839 } else {
6840 classUsed = "toastify-bottom";
6841 }
6842
6843 var height = allToasts[i].offsetHeight;
6844 classUsed = classUsed.substr(9, classUsed.length-1)
6845 // Spacing between toasts
6846 var offset = 15;
6847
6848 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
6849
6850 // Show toast in center if screen with less than or equal to 360px
6851 if (width <= 360) {
6852 // Setting the position
6853 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
6854
6855 offsetSize[classUsed] += height + offset;
6856 } else {
6857 if (containsClass(allToasts[i], "toastify-left") === true) {
6858 // Setting the position
6859 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
6860
6861 topLeftOffsetSize[classUsed] += height + offset;
6862 } else {
6863 // Setting the position
6864 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
6865
6866 topRightOffsetSize[classUsed] += height + offset;
6867 }
6868 }
6869 }
6870
6871 // Supporting function chaining
6872 return this;
6873 };
6874
6875 // Helper function to get offset.
6876 function getAxisOffsetAValue(axis, options) {
6877
6878 if(options.offset[axis]) {
6879 if(isNaN(options.offset[axis])) {
6880 return options.offset[axis];
6881 }
6882 else {
6883 return options.offset[axis] + 'px';
6884 }
6885 }
6886
6887 return '0px';
6888
6889 }
6890
6891 function containsClass(elem, yourClass) {
6892 if (!elem || typeof yourClass !== "string") {
6893 return false;
6894 } else if (
6895 elem.className &&
6896 elem.className
6897 .trim()
6898 .split(/\s+/gi)
6899 .indexOf(yourClass) > -1
6900 ) {
6901 return true;
6902 } else {
6903 return false;
6904 }
6905 }
6906
6907 // Setting up the prototype for the init object
6908 Toastify.lib.init.prototype = Toastify.lib;
6909
6910 // Returning the Toastify function to be assigned to the window object/module
6911 return Toastify;
6912 });
6913
6914
6915 /***/ }
6916
6917 /******/ });
6918 /************************************************************************/
6919 /******/ // The module cache
6920 /******/ var __webpack_module_cache__ = {};
6921 /******/
6922 /******/ // The require function
6923 /******/ function __webpack_require__(moduleId) {
6924 /******/ // Check if module is in cache
6925 /******/ var cachedModule = __webpack_module_cache__[moduleId];
6926 /******/ if (cachedModule !== undefined) {
6927 /******/ return cachedModule.exports;
6928 /******/ }
6929 /******/ // Create a new module (and put it into the cache)
6930 /******/ var module = __webpack_module_cache__[moduleId] = {
6931 /******/ id: moduleId,
6932 /******/ // no module.loaded needed
6933 /******/ exports: {}
6934 /******/ };
6935 /******/
6936 /******/ // Execute the module function
6937 /******/ if (!(moduleId in __webpack_modules__)) {
6938 /******/ delete __webpack_module_cache__[moduleId];
6939 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
6940 /******/ e.code = 'MODULE_NOT_FOUND';
6941 /******/ throw e;
6942 /******/ }
6943 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
6944 /******/
6945 /******/ // Return the exports of the module
6946 /******/ return module.exports;
6947 /******/ }
6948 /******/
6949 /************************************************************************/
6950 /******/ /* webpack/runtime/compat get default export */
6951 /******/ (() => {
6952 /******/ // getDefaultExport function for compatibility with non-harmony modules
6953 /******/ __webpack_require__.n = (module) => {
6954 /******/ var getter = module && module.__esModule ?
6955 /******/ () => (module['default']) :
6956 /******/ () => (module);
6957 /******/ __webpack_require__.d(getter, { a: getter });
6958 /******/ return getter;
6959 /******/ };
6960 /******/ })();
6961 /******/
6962 /******/ /* webpack/runtime/define property getters */
6963 /******/ (() => {
6964 /******/ // define getter functions for harmony exports
6965 /******/ __webpack_require__.d = (exports, definition) => {
6966 /******/ for(var key in definition) {
6967 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
6968 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
6969 /******/ }
6970 /******/ }
6971 /******/ };
6972 /******/ })();
6973 /******/
6974 /******/ /* webpack/runtime/hasOwnProperty shorthand */
6975 /******/ (() => {
6976 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
6977 /******/ })();
6978 /******/
6979 /******/ /* webpack/runtime/make namespace object */
6980 /******/ (() => {
6981 /******/ // define __esModule on exports
6982 /******/ __webpack_require__.r = (exports) => {
6983 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
6984 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
6985 /******/ }
6986 /******/ Object.defineProperty(exports, '__esModule', { value: true });
6987 /******/ };
6988 /******/ })();
6989 /******/
6990 /******/ /* webpack/runtime/nonce */
6991 /******/ (() => {
6992 /******/ __webpack_require__.nc = undefined;
6993 /******/ })();
6994 /******/
6995 /************************************************************************/
6996 var __webpack_exports__ = {};
6997 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
6998 (() => {
6999 "use strict";
7000 /*!**********************************************!*\
7001 !*** ./assets/src/js/admin/admin-courses.js ***!
7002 \**********************************************/
7003 __webpack_require__.r(__webpack_exports__);
7004 /* harmony import */ var _courses_generate_with_ai_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./courses/generate-with-ai.js */ "./assets/src/js/admin/courses/generate-with-ai.js");
7005 /* harmony import */ var _courses_view_students_modal_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./courses/view-students-modal.js */ "./assets/src/js/admin/courses/view-students-modal.js");
7006 /**
7007 * Admin Courses JS
7008 *
7009 * @since 4.3.0
7010 * @version 1.0.1
7011 */
7012
7013
7014
7015 new _courses_generate_with_ai_js__WEBPACK_IMPORTED_MODULE_0__.CreateCourseViaAI();
7016 new _courses_view_students_modal_js__WEBPACK_IMPORTED_MODULE_1__.ViewStudentsModal();
7017 })();
7018
7019 /******/ })()
7020 ;
7021 //# sourceMappingURL=admin-courses.js.map