PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.2
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 / js / dist / admin / admin-order.js

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

13,495 lines 470.9 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/order/add-courses-to-order.js"
5 /*!***********************************************************!*\
6 !*** ./assets/src/js/admin/order/add-courses-to-order.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 */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
14 /* harmony export */ });
15 /* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
16 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
17
18
19 const addCoursesToOrder = () => {
20 let elModalSearchCourses;
21 let elSearchCoursesResult;
22 let elOrderDetails, modalSearchItemsTemplate, modalContainer;
23 let elOrderModalFooter, elOrderModalBtnAdd;
24 let elListOrderItems;
25 let timeOutSearch;
26 const idModalSearchItems = '#modal-search-items';
27 const idOrderDetails = '#learn-press-order';
28 let dataSend = {
29 search: '',
30 id_not_in: '',
31 paged: 1
32 };
33 const courseIdsNewSelected = [];
34 let courseIdsAdded = [];
35 const getAllElements = () => {
36 elOrderDetails = document.querySelector('#learn-press-order');
37 modalSearchItemsTemplate = document.querySelector('#learn-press-modal-search-items');
38 modalContainer = document.querySelector('#container-modal-search-items');
39 };
40
41 /**
42 * Fetch courses from API.
43 *
44 * @param keySearch
45 * @param course_ids_exclude
46 * @param paged
47 */
48 const fetchCoursesAPI = (keySearch = '', course_ids_exclude = [], paged = 1) => {
49 let id_not_in = '';
50 if (course_ids_exclude.length > 0) {
51 id_not_in = course_ids_exclude.join(',');
52 }
53 dataSend = {
54 search: keySearch,
55 id_not_in,
56 paged
57 };
58 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.fetchCourses(keySearch, dataSend, {
59 before() {
60 elModalSearchCourses.classList.add('loading');
61 },
62 success(response) {
63 const {
64 data,
65 status,
66 message
67 } = response;
68 const {
69 courses,
70 total_pages
71 } = data;
72 if ('success' !== status) {
73 console.error(message);
74 } else {
75 if (!courses.length) {
76 elSearchCoursesResult.innerHTML = '<li class="lp-result-item">No courses found</li>';
77 return;
78 }
79 elSearchCoursesResult.innerHTML = renderSearchResult(courses);
80 const paginationHtml = renderPagination(paged, total_pages);
81 const searchNav = elModalSearchCourses.querySelector('.search-nav');
82 searchNav.innerHTML = paginationHtml;
83 }
84 },
85 error(err) {
86 console.error(err);
87 },
88 completed() {
89 elModalSearchCourses.classList.remove('loading');
90 }
91 });
92 };
93
94 /**
95 * Get list course ids added.
96 */
97 const getCoursesAdded = () => {
98 courseIdsAdded = [];
99 const orderItems = document.querySelectorAll('#learn-press-order .list-order-items tbody .order-item-row');
100 orderItems.forEach(orderItem => {
101 const orderItemId = parseInt(orderItem.getAttribute('data-id'));
102 courseIdsAdded.push(orderItemId);
103 });
104 };
105
106 /**
107 * Add courses to order.
108 * @param e
109 * @param target
110 */
111 const addCourses = (e, target) => {
112 if (!target.classList.contains('add')) {
113 return;
114 }
115 if (!target.closest(idModalSearchItems)) {
116 return;
117 }
118 elListOrderItems = elOrderDetails.querySelector('.list-order-items');
119 e.preventDefault();
120 target.disabled = true;
121 const dataSend = {
122 'lp-ajax': 'add_items_to_order',
123 order_id: document.querySelector('#post_ID').value,
124 items: courseIdsNewSelected,
125 nonce: lpDataAdmin.nonce
126 };
127 const callBack = {
128 success(response) {
129 const {
130 data,
131 messages,
132 status
133 } = response;
134 if ('error' === status) {
135 console.error(messages);
136 return;
137 }
138 const {
139 item_html,
140 order_data
141 } = data;
142 const elNoItem = elListOrderItems.querySelector('.no-order-items');
143 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpShowHideEl(elNoItem, 0);
144 elNoItem.insertAdjacentHTML('beforebegin', item_html);
145 elOrderDetails.querySelector('.order-subtotal').innerHTML = order_data.subtotal_html;
146 elOrderDetails.querySelector('.order-total').innerHTML = order_data.total_html;
147 //courseIdsAdded.push( ...courseIdsNewSelected );
148 courseIdsNewSelected.splice(0, courseIdsNewSelected.length);
149 },
150 error(err) {
151 console.error(err);
152 },
153 completed() {
154 target.disabled = false;
155 modalContainer.style.display = 'none';
156 }
157 };
158 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpAddQueryArgs(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpGetCurrentURLNoParam(), dataSend), {}, callBack);
159 };
160
161 /**
162 * Remove course from order.
163 *
164 * @param e
165 * @param target
166 */
167 const removeCourse = (e, target) => {
168 if (target.tagName !== 'SPAN') {
169 return;
170 }
171 if (!target.closest('.remove-order-item')) {
172 return;
173 }
174 e.preventDefault();
175 if (!confirm('Are you sure you want to remove this item?')) {
176 return;
177 }
178 target.disabled = true;
179 target.classList.add('dashicons-update');
180 const elItemRow = target.closest('.order-item-row');
181 const elListOrderItems = target.closest('.list-order-items');
182 const orderItemId = parseInt(elItemRow.getAttribute('data-item_id'));
183 const courseId = parseInt(elItemRow.getAttribute('data-id'));
184 const dataSend = {
185 'lp-ajax': 'remove_items_from_order',
186 order_id: document.querySelector('#post_ID').value,
187 items: orderItemId,
188 nonce: lpDataAdmin.nonce
189 };
190 const callBack = {
191 success(response) {
192 const {
193 data,
194 messages,
195 status
196 } = response;
197 if ('error' === status) {
198 console.error(messages);
199 return;
200 }
201 const {
202 item_html,
203 order_data
204 } = data;
205 const elNoItem = elListOrderItems.querySelector('.no-order-items');
206 const orderItems = elListOrderItems.querySelectorAll('.order-item-row');
207 orderItems.forEach(orderItem => {
208 orderItem.remove();
209 });
210 if (item_html.length) {
211 elNoItem.insertAdjacentHTML('beforebegin', item_html);
212 } else {
213 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpShowHideEl(elNoItem, 1);
214 }
215 courseIdsNewSelected.splice(courseIdsNewSelected.indexOf(courseId), 1);
216 //courseIdsAdded.splice( courseIdsNewSelected.indexOf( courseId ), 1 );
217 elOrderDetails.querySelector('.order-subtotal').innerHTML = order_data.subtotal_html;
218 elOrderDetails.querySelector('.order-total').innerHTML = order_data.total_html;
219 },
220 error(err) {
221 console.error(err);
222 },
223 completed() {}
224 };
225 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpAddQueryArgs(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpGetCurrentURLNoParam(), dataSend), {}, callBack);
226 };
227
228 /**
229 * Search courses before add Order.
230 *
231 * @param e
232 * @param target
233 */
234 const searchCourse = (e, target) => {
235 if ('search' !== target.name) {
236 return;
237 }
238 const elLPTarget = target.closest(idModalSearchItems);
239 if (!elLPTarget) {
240 return;
241 }
242 e.preventDefault();
243 const keyword = target.value;
244 if (!keyword || keyword && keyword.length > 2) {
245 if (undefined !== timeOutSearch) {
246 clearTimeout(timeOutSearch);
247 }
248 timeOutSearch = setTimeout(function () {
249 fetchCoursesAPI(keyword, courseIdsAdded, 1);
250 }, 800);
251 }
252 };
253
254 /**
255 * Display list courses when search done.
256 *
257 * @param courses
258 */
259 const renderSearchResult = courses => {
260 let html = '';
261 courses.forEach(course => {
262 const courseId = parseInt(course.ID);
263 const checked = courseIdsNewSelected.includes(courseId) ? 'checked' : '';
264 html += `
265 <li class="lp-result-item" data-id="${courseId}" data-type="lp_course" data-text="${course.post_title}">
266 <label>
267 <input type="checkbox" value="${courseId}" name="selectedItems[]" ${checked}>
268 <span class="lp-item-text">${course.post_title} (#${courseId})</span>
269 </label>
270 </li>`;
271 });
272 return html;
273 };
274
275 /**
276 * Render pagination.
277 *
278 * @param currentPage
279 * @param maxPage
280 */
281 const renderPagination = (currentPage, maxPage) => {
282 currentPage = parseInt(currentPage);
283 maxPage = parseInt(maxPage);
284 let html = '';
285 if (maxPage <= 1) {
286 return html;
287 }
288 const nextPage = currentPage + 1;
289 const prevPage = currentPage - 1;
290 let pages = [];
291 if (maxPage <= 9) {
292 for (let i = 1; i <= maxPage; i++) {
293 pages.push(i);
294 }
295 } else if (currentPage <= 3) {
296 // x is ...
297 pages = [1, 2, 3, 4, 5, 'x', maxPage];
298 } else if (currentPage <= 5) {
299 for (let i = 1; i <= currentPage; i++) {
300 pages.push(i);
301 }
302 for (let j = 1; j <= 2; j++) {
303 const tempPage = currentPage + j;
304 pages.push(tempPage);
305 }
306 pages.push('x');
307 pages.push(maxPage);
308 } else {
309 pages = [1, 'x'];
310 for (let k = 2; k >= 0; k--) {
311 const tempPage = currentPage - k;
312 pages.push(tempPage);
313 }
314 const currentToLast = maxPage - currentPage;
315 if (currentToLast <= 5) {
316 for (let m = currentPage + 1; m <= maxPage; m++) {
317 pages.push(m);
318 }
319 } else {
320 for (let n = 1; n <= 2; n++) {
321 const tempPage = currentPage + n;
322 pages.push(tempPage);
323 }
324 pages.push('x');
325 pages.push(maxPage);
326 }
327 }
328 const maximum = pages.length;
329 if (currentPage !== 1) {
330 html += `<a class="prev page-numbers button" href="#" data-page="${prevPage}"><</a>`;
331 }
332 for (let i = 0; i < maximum; i++) {
333 if (currentPage === parseInt(pages[i])) {
334 html += `<a aria-current="page" class="page-numbers current button disabled" data-page="${pages[i]}">
335 ${pages[i]}
336 </a>`;
337 } else if (pages[i] === 'x') {
338 html += `<span class="page-numbers dots button disabled">...</span>`;
339 } else {
340 html += `<a class="page-numbers button" href="#" data-page="${pages[i]}">${pages[i]} </a>`;
341 }
342 }
343 if (currentPage !== maxPage) {
344 html += `<a class="next page-numbers button" href="#" data-page="${nextPage}">></a>`;
345 }
346 return html;
347 };
348 const showPopupSearchCourses = () => {
349 getCoursesAdded();
350 modalContainer.style.display = 'block';
351 elOrderModalBtnAdd.style.display = 'none';
352 elSearchCoursesResult.innerHTML = '';
353 fetchCoursesAPI(dataSend.search, courseIdsAdded, dataSend.paged);
354 };
355
356 // Events.
357 document.addEventListener('click', e => {
358 const target = e.target;
359 //console.dir( target );
360 if (target.id === 'learn-press-add-order-item') {
361 e.preventDefault();
362 showPopupSearchCourses();
363 }
364 if (target.classList.contains('close') && target.closest(idModalSearchItems)) {
365 e.preventDefault();
366 elModalSearchCourses.querySelector('input[name="search"]').value = '';
367 dataSend.search = '';
368 dataSend.paged = 1;
369 modalContainer.style.display = 'none';
370 }
371 if (target.classList.contains('page-numbers')) {
372 if (target.closest(idModalSearchItems)) {
373 e.preventDefault();
374 const paged = target.getAttribute('data-page');
375 fetchCoursesAPI(dataSend.search, dataSend.id_not_in, paged);
376 }
377 }
378 if (target.name === 'selectedItems[]') {
379 if (target.closest(idModalSearchItems)) {
380 const courseId = parseInt(target.value);
381 if (target.checked) {
382 courseIdsNewSelected.push(courseId);
383 } else {
384 const index = courseIdsNewSelected.indexOf(courseId);
385 if (index > -1) {
386 courseIdsNewSelected.splice(index, 1);
387 }
388 }
389 elOrderModalBtnAdd.style.display = courseIdsNewSelected.length > 0 ? 'block' : 'none';
390 }
391 }
392 addCourses(e, target);
393 removeCourse(e, target);
394 });
395 document.addEventListener('keyup', function (e) {
396 const target = e.target;
397 searchCourse(e, target);
398 });
399 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpOnElementReady('.lp-order-detail-items', el => {
400 getAllElements();
401 if (!elOrderDetails) {
402 return;
403 }
404 modalContainer.innerHTML = modalSearchItemsTemplate.innerHTML;
405 elModalSearchCourses = modalContainer.querySelector(idModalSearchItems);
406 elSearchCoursesResult = elModalSearchCourses.querySelector('.search-results');
407 elOrderModalFooter = elModalSearchCourses.querySelector('footer');
408 elOrderModalBtnAdd = elOrderModalFooter.querySelector('.add');
409 modalContainer.style.display = 'none';
410 });
411 };
412 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (addCoursesToOrder);
413
414 /***/ },
415
416 /***/ "./assets/src/js/admin/order/export_invoice.js"
417 /*!*****************************************************!*\
418 !*** ./assets/src/js/admin/order/export_invoice.js ***!
419 \*****************************************************/
420 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
421
422 "use strict";
423 __webpack_require__.r(__webpack_exports__);
424 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
425 /* harmony export */ "default": () => (/* binding */ export_invoice)
426 /* harmony export */ });
427 /**
428 * Export invoice to PDF
429 */
430 function export_invoice() {
431 let html2pdf_obj, modal;
432 document.addEventListener('click', e => {
433 const target = e.target;
434 if (target.id === 'lp-invoice__export') {
435 html2pdf_obj.save();
436 } else if (target.id === 'lp-invoice__update') {
437 const elOption = document.querySelector('.export-options__content');
438 const fields = elOption.querySelectorAll('input');
439 const fieldNameUnChecked = [];
440 fields.forEach(field => {
441 if (!field.checked) {
442 fieldNameUnChecked.push(field.name);
443 }
444 });
445 window.localStorage.setItem('lp_invoice_un_fields', JSON.stringify(fieldNameUnChecked));
446 window.localStorage.setItem('lp_invoice_show', 1);
447 window.location.reload();
448 }
449 });
450 const exportPDF = () => {
451 const pdfOptions = {
452 margin: [0, 0, 0, 5],
453 filename: document.title,
454 image: {
455 type: 'webp'
456 },
457 html2canvas: {
458 scale: 2.5
459 },
460 jsPDF: {
461 format: 'a4',
462 orientation: 'p'
463 }
464 };
465 const html = document.querySelector('#lp-invoice__content');
466 html2pdf_obj = html2pdf().set(pdfOptions).from(html);
467 };
468 const showInfoFields = () => {
469 // Get fields name checked
470 const fieldsChecked = window.localStorage.getItem('lp_invoice_un_fields');
471 const elOptions = document.querySelector('.export-options__content');
472 const elInvoiceFields = document.querySelectorAll('.invoice-field');
473 elInvoiceFields.forEach(field => {
474 const nameClass = field.classList[1];
475 if (fieldsChecked && fieldsChecked.includes(nameClass)) {
476 field.remove();
477 const elOption = elOptions.querySelector(`[name=${nameClass}]`);
478 if (elOption) {
479 elOption.checked = false;
480 }
481 }
482 });
483 const showInvoice = parseInt(window.localStorage.getItem('lp_invoice_show'));
484 if (showInvoice === 1) {
485 modal.style.display = 'block';
486 }
487 };
488 document.addEventListener('DOMContentLoaded', () => {
489 const elExportSection = document.querySelector('#order-export__section');
490 if (!elExportSection.length) {
491 const tabs = document.querySelectorAll('.tabs');
492 const tab = document.querySelectorAll('.tab');
493 const panel = document.querySelectorAll('.panel');
494 function onTabClick(event) {
495 // deactivate existing active tabs and panel
496
497 for (let i = 0; i < tab.length; i++) {
498 tab[i].classList.remove('active');
499 }
500 for (let i = 0; i < panel.length; i++) {
501 panel[i].classList.remove('active');
502 }
503
504 // activate new tabs and panel
505 event.target.classList.add('active');
506 const classString = event.target.getAttribute('data-target');
507 document.getElementById('panels').getElementsByClassName(classString)[0].classList.add('active');
508 }
509 for (let i = 0; i < tab.length; i++) {
510 tab[i].addEventListener('click', onTabClick, false);
511 }
512
513 // Get the modal
514 modal = document.getElementById('myModal');
515 // Get the button that opens the modal
516 const btn = document.getElementById('order-export__button');
517 // Get the <span> element that closes the modal
518 const span = document.getElementsByClassName('close')[0];
519 // When the user clicks on the button, open the modal
520 btn.onclick = function () {
521 modal.style.display = 'block';
522 };
523
524 // When the user clicks on <span> (x), close the modal
525 span.onclick = function () {
526 modal.style.display = 'none';
527 window.localStorage.setItem('lp_invoice_show', 0);
528 };
529
530 // When the user clicks anywhere outside the modal, close it
531 window.onclick = function (event) {
532 if (event.target === modal) {
533 modal.style.display = 'none';
534 window.localStorage.setItem('lp_invoice_show', 0);
535 }
536 };
537 showInfoFields();
538 exportPDF();
539 }
540 });
541 }
542
543 /***/ },
544
545 /***/ "./assets/src/js/admin/order/refund-order.js"
546 /*!***************************************************!*\
547 !*** ./assets/src/js/admin/order/refund-order.js ***!
548 \***************************************************/
549 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
550
551 "use strict";
552 __webpack_require__.r(__webpack_exports__);
553 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
554 /* harmony export */ RefundOrder: () => (/* binding */ RefundOrder),
555 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
556 /* harmony export */ });
557 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
558 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_0__);
559 /* harmony import */ var lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify */ "./assets/src/js/lpToastify.js");
560 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
561
562
563
564
565 /**
566 * Handle admin approve/deny refund actions.
567 *
568 * @since 4.3.9
569 * @version 1.0.0
570 */
571 class RefundOrder {
572 constructor() {
573 this.isRequesting = false;
574 this.isReloading = false;
575 }
576 static selectors = {
577 panel: '.order-data-refund-request',
578 action: '.lp-admin-refund-order-action'
579 };
580 init() {
581 this.events();
582 }
583 events() {
584 if (RefundOrder._loadedEvents) {
585 return;
586 }
587 RefundOrder._loadedEvents = this;
588 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.eventHandlers('click', [{
589 selector: RefundOrder.selectors.action,
590 class: this,
591 callBack: this.handleAction.name
592 }]);
593 }
594 getPanelData(panel) {
595 const orderTotal = parseFloat(panel.dataset.orderTotal || '0');
596 return {
597 orderId: parseInt(panel.dataset.orderId || '0', 10),
598 orderTotal: Number.isNaN(orderTotal) ? 0 : orderTotal,
599 orderTotalFormatted: panel.dataset.orderTotalFormatted || '',
600 confirmTitle: panel.dataset.confirmTitle || 'Approve refund?',
601 confirmText: panel.dataset.confirmText || '',
602 messageLabel: panel.dataset.messageLabel || 'Message to payer',
603 messagePlaceholder: panel.dataset.messagePlaceholder || '',
604 amountLabel: panel.dataset.amountLabel || 'Refund amount',
605 amountInvalid: panel.dataset.amountInvalid || 'Invalid refund amount.',
606 confirmButton: panel.dataset.confirmButton || 'Approve Refund',
607 cancelButton: panel.dataset.cancelButton || 'Cancel'
608 };
609 }
610 setLoadingState(panel, isLoading) {
611 panel.querySelectorAll(RefundOrder.selectors.action).forEach(button => {
612 button.disabled = isLoading;
613 });
614 }
615 openApproveModal(data) {
616 const content = document.createElement('div');
617 const messageLabel = document.createElement('label');
618 const message = document.createElement('textarea');
619 const amountLabel = document.createElement('label');
620 const amount = document.createElement('input');
621 content.className = 'lp-admin-refund-modal__form';
622 if (data.confirmText) {
623 const confirmText = document.createElement('p');
624 confirmText.className = 'lp-admin-refund-modal__description';
625 confirmText.textContent = data.confirmText;
626 content.append(confirmText);
627 }
628 messageLabel.textContent = data.messageLabel;
629 messageLabel.htmlFor = 'lp-admin-refund-message';
630 messageLabel.className = 'swal2-input-label';
631 message.id = 'lp-admin-refund-message';
632 message.className = 'swal2-textarea';
633 message.placeholder = data.messagePlaceholder;
634 amountLabel.textContent = `${data.amountLabel} (${data.orderTotalFormatted})`;
635 amountLabel.htmlFor = 'lp-admin-refund-amount';
636 amountLabel.className = 'swal2-input-label';
637 amount.id = 'lp-admin-refund-amount';
638 amount.className = 'swal2-input';
639 amount.type = 'number';
640 amount.min = '0.01';
641 amount.max = data.orderTotal.toString();
642 amount.step = '0.01';
643 amount.value = data.orderTotal.toFixed(2);
644 content.append(messageLabel, message, amountLabel, amount);
645 return sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().fire({
646 icon: 'warning',
647 title: data.confirmTitle,
648 html: content,
649 showCancelButton: true,
650 confirmButtonText: data.confirmButton,
651 cancelButtonText: data.cancelButton,
652 focusConfirm: false,
653 customClass: {
654 popup: 'lp-admin-refund-modal',
655 htmlContainer: 'lp-admin-refund-modal__content',
656 actions: 'lp-admin-refund-modal__actions'
657 },
658 preConfirm: () => {
659 const refundAmount = parseFloat(amount.value);
660 if (Number.isNaN(refundAmount) || refundAmount <= 0 || refundAmount > data.orderTotal) {
661 sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().showValidationMessage(data.amountInvalid);
662 return false;
663 }
664 return {
665 note: message.value.trim(),
666 refundAmount
667 };
668 }
669 });
670 }
671 sendAction(actionButton, panel, refundAction, refundAmount = 0, note = '') {
672 const data = this.getPanelData(panel);
673 if (!data.orderId) {
674 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show('Invalid order.', 'error');
675 return;
676 }
677 this.isRequesting = true;
678 this.setLoadingState(panel, true);
679 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(actionButton, 1);
680 window.lpAJAXG.fetchAJAX({
681 action: 'admin_handle_request_refund',
682 order_id: data.orderId,
683 refund_action: refundAction,
684 refund_amount: refundAmount,
685 note
686 }, {
687 success: response => {
688 const {
689 status,
690 message,
691 data
692 } = response;
693 if (status !== 'success') {
694 throw new Error(message);
695 }
696 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, 'success');
697 this.isReloading = true;
698 window.setTimeout(() => window.location.reload(), 1200);
699 },
700 error: error => {
701 const messageResponse = error?.message || error || 'Refund action failed.';
702 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(messageResponse, 'error');
703 },
704 completed: () => {
705 if (this.isReloading) {
706 return;
707 }
708 this.isRequesting = false;
709 this.setLoadingState(panel, false);
710 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(actionButton, 0);
711 }
712 });
713 }
714 async handleAction(args) {
715 const {
716 e,
717 target
718 } = args;
719 e.preventDefault();
720 const actionButton = target.closest(RefundOrder.selectors.action);
721 const panel = actionButton?.closest(RefundOrder.selectors.panel);
722 if (!actionButton || !panel || this.isRequesting) {
723 return;
724 }
725 const refundAction = actionButton.dataset.refundAction || '';
726 let amount = '';
727 let note = '';
728 if ('reject' === refundAction) {
729 return this.sendAction(actionButton, panel, refundAction);
730 }
731 const result = await this.openApproveModal(this.getPanelData(panel));
732 if (result.isConfirmed && result.value) {
733 amount = result.value.refundAmount;
734 note = result.value.note;
735 this.sendAction(actionButton, panel, refundAction, amount, note);
736 }
737 }
738 }
739 const refundOrder = () => {
740 const refundOrderHandle = new RefundOrder();
741 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.lpOnElementReady(RefundOrder.selectors.action, () => {
742 refundOrderHandle.init();
743 });
744 };
745 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (refundOrder);
746
747 /***/ },
748
749 /***/ "./assets/src/js/admin/utils-admin.js"
750 /*!********************************************!*\
751 !*** ./assets/src/js/admin/utils-admin.js ***!
752 \********************************************/
753 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
754
755 "use strict";
756 __webpack_require__.r(__webpack_exports__);
757 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
758 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
759 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
760 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
761 /* harmony export */ });
762 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
763 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
764 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
765 /**
766 * Library run on Admin
767 *
768 * @since 4.2.6.9
769 * @version 1.0.1
770 */
771
772
773
774 const AdminUtilsFunctions = {
775 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
776 if (!elTomSelect) {
777 return;
778 }
779 const optionDefault = {
780 plugins: {
781 remove_button: {
782 title: 'Remove this item'
783 },
784 dropdown_input: {}
785 },
786 onInitialize() {},
787 onItemAdd(e) {
788 // Get list without current item.
789 if (fetchAPI) {
790 const selectedOptions = Array.from(elTomSelect.selectedOptions);
791 const selectedValues = selectedOptions.map(option => option.value);
792 selectedValues.push(e);
793 dataSend.id_not_in = selectedValues.join(',');
794 fetchAPI('', dataSend, callBackHandleData);
795 }
796 }
797 };
798 if (fetchAPI) {
799 optionDefault.load = (keySearch, callbackTom) => {
800 const selectedOptions = Array.from(elTomSelect.selectedOptions);
801 const selectedValues = selectedOptions.map(option => option.value);
802 dataSend.id_not_in = selectedValues.join(',');
803 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
804 };
805 }
806 options = {
807 ...optionDefault,
808 ...options
809 };
810 const items_selected = options.options;
811 /*if ( options?.options?.length > 20 ) {
812 const chunkSize = 20;
813 const length = options.options.length;
814 let i = 0;
815 const chunkedOptions = { ...options };
816 chunkedOptions.options = items_selected.slice( i, chunkSize );
817 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
818 i += chunkSize;
819 const interval = setInterval( () => {
820 if ( i > ( length - 1 ) ) {
821 clearInterval( interval );
822 }
823 const optionsSlice = items_selected.slice( i, i + chunkSize );
824 i += chunkSize;
825 tomSelect.addOptions( optionsSlice );
826 tomSelect.setValue( options.items );
827 }, 200 );
828 return tomSelect;
829 }*/
830
831 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
832 },
833 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
834 return {
835 success: response => {
836 const options = callBackHandleData.success(response);
837 callbackTom(options);
838 }
839 };
840 },
841 fetchCourses(keySearch = '', dataSend = {}, callback) {
842 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
843 dataSend.search = keySearch;
844 const params = {
845 headers: {
846 'Content-Type': 'application/json',
847 'X-WP-Nonce': lpDataAdmin.nonce
848 },
849 method: 'POST',
850 body: JSON.stringify(dataSend)
851 };
852 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
853 },
854 fetchUsers(keySearch = '', dataSend = {}, callback) {
855 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
856 dataSend.search = keySearch;
857 const params = {
858 headers: {
859 'Content-Type': 'application/json',
860 'X-WP-Nonce': lpDataAdmin.nonce
861 },
862 method: 'POST',
863 body: JSON.stringify(dataSend)
864 };
865 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
866 }
867 };
868
869
870 /***/ },
871
872 /***/ "./assets/src/js/api.js"
873 /*!******************************!*\
874 !*** ./assets/src/js/api.js ***!
875 \******************************/
876 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
877
878 "use strict";
879 __webpack_require__.r(__webpack_exports__);
880 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
881 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
882 /* harmony export */ });
883 /**
884 * List API on backend
885 *
886 * @since 4.2.6
887 * @version 1.0.2
888 */
889
890 const lplistAPI = {};
891 let lp_rest_url;
892 if ('undefined' !== typeof lpDataAdmin) {
893 lp_rest_url = lpDataAdmin.lp_rest_url;
894 lplistAPI.admin = {
895 apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
896 apiAddons: lp_rest_url + 'lp/v1/addon/all',
897 apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
898 apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
899 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
900 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
901 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
902 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
903 };
904 }
905 if ('undefined' !== typeof lpData) {
906 lp_rest_url = lpData.lp_rest_url;
907 lplistAPI.frontend = {
908 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
909 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
910 // Deprecated API, don't load from v4.3.7
911 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
912 // Deprecated since 4.3.0
913 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
914 };
915 }
916 if (lp_rest_url) {
917 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
918 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
919 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
920 }
921 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
922
923 /***/ },
924
925 /***/ "./assets/src/js/lpToastify.js"
926 /*!*************************************!*\
927 !*** ./assets/src/js/lpToastify.js ***!
928 \*************************************/
929 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
930
931 "use strict";
932 __webpack_require__.r(__webpack_exports__);
933 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
934 /* harmony export */ show: () => (/* binding */ show)
935 /* harmony export */ });
936 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
937 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
938 /* 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");
939 /**
940 * Utils functions
941 *
942 * @param url
943 * @param data
944 * @param functions
945 * @since 4.3.0
946 * @version 1.0.0
947 */
948
949
950 const argsToastify = {
951 text: '',
952 gravity: lpData.toast.gravity,
953 // `top` or `bottom`
954 position: lpData.toast.position,
955 // `left`, `center` or `right`
956 className: `${lpData.toast.classPrefix}`,
957 close: lpData.toast.close == 1,
958 stopOnFocus: lpData.toast.stopOnFocus == 1,
959 duration: lpData.toast.duration
960 };
961 const show = (message, status = 'success', argsCustom) => {
962 let args = argsToastify;
963 if (argsCustom) {
964 args = {
965 ...args,
966 ...argsCustom
967 };
968 }
969 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
970 ...args,
971 text: message,
972 className: `${lpData.toast.classPrefix} ${status}`
973 });
974 toastify.showToast();
975 };
976
977 /***/ },
978
979 /***/ "./assets/src/js/utils.js"
980 /*!********************************!*\
981 !*** ./assets/src/js/utils.js ***!
982 \********************************/
983 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
984
985 "use strict";
986 __webpack_require__.r(__webpack_exports__);
987 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
988 /* harmony export */ debounce: () => (/* binding */ debounce),
989 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
990 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
991 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
992 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
993 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
994 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
995 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
996 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
997 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
998 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
999 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1000 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1001 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1002 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1003 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
1004 /* harmony export */ });
1005 /**
1006 * Utils functions
1007 *
1008 * @param url
1009 * @param data
1010 * @param functions
1011 * @since 4.2.5.1
1012 * @version 1.0.6
1013 */
1014 const lpClassName = {
1015 hidden: 'lp-hidden',
1016 loading: 'loading',
1017 elCollapse: 'lp-collapse',
1018 elSectionToggle: '.lp-section-toggle',
1019 elTriggerToggle: '.lp-trigger-toggle'
1020 };
1021 const lpFetchAPI = (url, data = {}, functions = {}) => {
1022 if ('function' === typeof functions.before) {
1023 functions.before();
1024 }
1025 fetch(url, {
1026 method: 'GET',
1027 ...data
1028 }).then(response => response.json()).then(response => {
1029 if ('function' === typeof functions.success) {
1030 functions.success(response);
1031 }
1032 }).catch(err => {
1033 if ('function' === typeof functions.error) {
1034 functions.error(err);
1035 }
1036 }).finally(() => {
1037 if ('function' === typeof functions.completed) {
1038 functions.completed();
1039 }
1040 });
1041 };
1042
1043 /**
1044 * Get current URL without params.
1045 *
1046 * @since 4.2.5.1
1047 */
1048 const lpGetCurrentURLNoParam = () => {
1049 let currentUrl = window.location.href;
1050 const hasParams = currentUrl.includes('?');
1051 if (hasParams) {
1052 currentUrl = currentUrl.split('?')[0];
1053 }
1054 return currentUrl;
1055 };
1056 const lpAddQueryArgs = (endpoint, args) => {
1057 const url = new URL(endpoint);
1058 Object.keys(args).forEach(arg => {
1059 url.searchParams.set(arg, args[arg]);
1060 });
1061 return url;
1062 };
1063
1064 /**
1065 * Listen element viewed.
1066 *
1067 * @param el
1068 * @param callback
1069 * @since 4.2.5.8
1070 */
1071 const listenElementViewed = (el, callback) => {
1072 const observerSeeItem = new IntersectionObserver(function (entries) {
1073 for (const entry of entries) {
1074 if (entry.isIntersecting) {
1075 callback(entry);
1076 }
1077 }
1078 });
1079 observerSeeItem.observe(el);
1080 };
1081
1082 /**
1083 * Listen element created.
1084 *
1085 * @param callback
1086 * @since 4.2.5.8
1087 */
1088 const listenElementCreated = callback => {
1089 const observerCreateItem = new MutationObserver(function (mutations) {
1090 mutations.forEach(function (mutation) {
1091 if (mutation.addedNodes) {
1092 mutation.addedNodes.forEach(function (node) {
1093 if (node.nodeType === 1) {
1094 callback(node);
1095 }
1096 });
1097 }
1098 });
1099 });
1100 observerCreateItem.observe(document, {
1101 childList: true,
1102 subtree: true
1103 });
1104 // End.
1105 };
1106
1107 /**
1108 * Listen element created.
1109 *
1110 * @param selector
1111 * @param callback
1112 * @since 4.2.7.1
1113 */
1114 const lpOnElementReady = (selector, callback) => {
1115 const element = document.querySelector(selector);
1116 if (element) {
1117 callback(element);
1118 return;
1119 }
1120 const observer = new MutationObserver((mutations, obs) => {
1121 const element = document.querySelector(selector);
1122 if (element) {
1123 obs.disconnect();
1124 callback(element);
1125 }
1126 });
1127 observer.observe(document.documentElement, {
1128 childList: true,
1129 subtree: true
1130 });
1131 };
1132
1133 // Parse JSON from string with content include LP_AJAX_START.
1134 const lpAjaxParseJsonOld = data => {
1135 if (typeof data !== 'string') {
1136 return data;
1137 }
1138 const m = String.raw({
1139 raw: data
1140 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1141 try {
1142 if (m) {
1143 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1144 } else {
1145 data = JSON.parse(data);
1146 }
1147 } catch (e) {
1148 data = {};
1149 }
1150 return data;
1151 };
1152
1153 // status 0: hide, 1: show
1154 const lpShowHideEl = (el, status = 0) => {
1155 if (!el) {
1156 return;
1157 }
1158 if (!status) {
1159 el.classList.add(lpClassName.hidden);
1160 } else {
1161 el.classList.remove(lpClassName.hidden);
1162 }
1163 };
1164
1165 // status 0: hide, 1: show
1166 const lpSetLoadingEl = (el, status) => {
1167 if (!el) {
1168 return;
1169 }
1170 if (!status) {
1171 el.classList.remove(lpClassName.loading);
1172 } else {
1173 el.classList.add(lpClassName.loading);
1174 }
1175 };
1176
1177 // Toggle collapse section
1178 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1179 if (!elTriggerClassName) {
1180 elTriggerClassName = lpClassName.elTriggerToggle;
1181 }
1182
1183 // Exclude elements, which should not trigger the collapse toggle
1184 if (elsExclude && elsExclude.length > 0) {
1185 for (const elExclude of elsExclude) {
1186 if (target.closest(elExclude)) {
1187 return;
1188 }
1189 }
1190 }
1191 const elTrigger = target.closest(elTriggerClassName);
1192 if (!elTrigger) {
1193 return;
1194 }
1195
1196 //console.log( 'elTrigger', elTrigger );
1197
1198 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1199 if (!elSectionToggle) {
1200 return;
1201 }
1202 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1203 if ('function' === typeof callback) {
1204 callback(elSectionToggle);
1205 }
1206 };
1207
1208 // Get data of form
1209 const getDataOfForm = form => {
1210 const dataSend = {};
1211 const formData = new FormData(form);
1212 for (const pair of formData.entries()) {
1213 const key = pair[0];
1214 const value = formData.getAll(key);
1215 if (!dataSend.hasOwnProperty(key)) {
1216 // Convert value array to string.
1217 dataSend[key] = value.join(',');
1218 }
1219 }
1220 return dataSend;
1221 };
1222
1223 // Get field keys of form
1224 const getFieldKeysOfForm = form => {
1225 const keys = [];
1226 const elements = form.elements;
1227 for (let i = 0; i < elements.length; i++) {
1228 const name = elements[i].name;
1229 if (name && !keys.includes(name)) {
1230 keys.push(name);
1231 }
1232 }
1233 return keys;
1234 };
1235
1236 // Merge data handle with data form.
1237 const mergeDataWithDatForm = (elForm, dataHandle) => {
1238 const dataForm = getDataOfForm(elForm);
1239 const keys = getFieldKeysOfForm(elForm);
1240 keys.forEach(key => {
1241 if (!dataForm.hasOwnProperty(key)) {
1242 delete dataHandle[key];
1243 } else if (dataForm[key][0] === '') {
1244 delete dataForm[key];
1245 delete dataHandle[key];
1246 }
1247 });
1248 dataHandle = {
1249 ...dataHandle,
1250 ...dataForm
1251 };
1252 return dataHandle;
1253 };
1254
1255 /**
1256 * Event trigger
1257 * For each list of event handlers, listen event on document.
1258 *
1259 * eventName: 'click', 'change', ...
1260 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1261 *
1262 * @param eventName
1263 * @param eventHandlers
1264 */
1265 const eventHandlers = (eventName, eventHandlers) => {
1266 document.addEventListener(eventName, e => {
1267 const target = e.target;
1268 let args = {
1269 e,
1270 target
1271 };
1272 eventHandlers.forEach(eventHandler => {
1273 args = {
1274 ...args,
1275 ...eventHandler
1276 };
1277
1278 //console.log( args );
1279
1280 // Check condition before call back
1281 if (eventHandler.conditionBeforeCallBack) {
1282 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1283 return;
1284 }
1285 }
1286
1287 // Special check for keydown event with checkIsEventEnter = true
1288 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1289 if (e.key !== 'Enter') {
1290 return;
1291 }
1292 }
1293 if (target.closest(eventHandler.selector)) {
1294 if (eventHandler.class) {
1295 // Call method of class, function callBack will understand exactly {this} is class object.
1296 eventHandler.class[eventHandler.callBack](args);
1297 } else {
1298 // For send args is objected, {this} is eventHandler object, not class object.
1299 eventHandler.callBack(args);
1300 }
1301 }
1302 });
1303 });
1304 };
1305
1306 /**
1307 * Debounce - delays function execution until after `wait` ms of inactivity.
1308 *
1309 * Each call resets the timer. Only the last call in a burst executes.
1310 *
1311 * USE CASES:
1312 * - Search inputs, form validation, window resize
1313 * - Multiple elements need independent timers
1314 * - When you need to call with different arguments
1315 *
1316 * EXAMPLES:
1317 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1318 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1319 *
1320 * const debouncedResize = debounce( recalculateLayout, 250 );
1321 * window.addEventListener('resize', debouncedResize);
1322 *
1323 * ⚠️ Create ONCE outside event handlers, not inside.
1324 *
1325 * @param {Function} func - Function to debounce (can be anonymous)
1326 * @param {number} wait - Milliseconds to wait (default: 500)
1327 * @return {Function} Debounced wrapper function
1328 * @since 4.3.7
1329 * @version 1.0.0
1330 */
1331 const debounce = (func, wait = 500) => {
1332 let timer;
1333 return args => {
1334 clearTimeout(timer);
1335 timer = setTimeout(() => func(args), wait);
1336 };
1337 };
1338
1339 /***/ },
1340
1341 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1342 /*!*****************************************************************************************!*\
1343 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1344 \*****************************************************************************************/
1345 (module, __webpack_exports__, __webpack_require__) {
1346
1347 "use strict";
1348 __webpack_require__.r(__webpack_exports__);
1349 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1350 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1351 /* harmony export */ });
1352 /* 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");
1353 /* 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__);
1354 /* 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");
1355 /* 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__);
1356 // Imports
1357
1358
1359 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()));
1360 // Module
1361 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1362 * Toastify js 1.12.0
1363 * https://github.com/apvarun/toastify-js
1364 * @license MIT licensed
1365 *
1366 * Copyright (C) 2018 Varun A P
1367 */
1368
1369 .toastify {
1370 padding: 12px 20px;
1371 color: #ffffff;
1372 display: inline-block;
1373 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1374 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1375 background: linear-gradient(135deg, #73a5ff, #5477f5);
1376 position: fixed;
1377 opacity: 0;
1378 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1379 border-radius: 2px;
1380 cursor: pointer;
1381 text-decoration: none;
1382 max-width: calc(50% - 20px);
1383 z-index: 2147483647;
1384 }
1385
1386 .toastify.on {
1387 opacity: 1;
1388 }
1389
1390 .toast-close {
1391 background: transparent;
1392 border: 0;
1393 color: white;
1394 cursor: pointer;
1395 font-family: inherit;
1396 font-size: 1em;
1397 opacity: 0.4;
1398 padding: 0 5px;
1399 }
1400
1401 .toastify-right {
1402 right: 15px;
1403 }
1404
1405 .toastify-left {
1406 left: 15px;
1407 }
1408
1409 .toastify-top {
1410 top: -150px;
1411 }
1412
1413 .toastify-bottom {
1414 bottom: -150px;
1415 }
1416
1417 .toastify-rounded {
1418 border-radius: 25px;
1419 }
1420
1421 .toastify-avatar {
1422 width: 1.5em;
1423 height: 1.5em;
1424 margin: -7px 5px;
1425 border-radius: 2px;
1426 }
1427
1428 .toastify-center {
1429 margin-left: auto;
1430 margin-right: auto;
1431 left: 0;
1432 right: 0;
1433 max-width: fit-content;
1434 max-width: -moz-fit-content;
1435 }
1436
1437 @media only screen and (max-width: 360px) {
1438 .toastify-right, .toastify-left {
1439 margin-left: auto;
1440 margin-right: auto;
1441 left: 0;
1442 right: 0;
1443 max-width: fit-content;
1444 }
1445 }
1446 `, "",{"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":""}]);
1447 // Exports
1448 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1449
1450
1451 /***/ },
1452
1453 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1454 /*!*****************************************************!*\
1455 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1456 \*****************************************************/
1457 (module) {
1458
1459 "use strict";
1460
1461
1462 /*
1463 MIT License http://www.opensource.org/licenses/mit-license.php
1464 Author Tobias Koppers @sokra
1465 */
1466 module.exports = function (cssWithMappingToString) {
1467 var list = [];
1468
1469 // return the list of modules as css string
1470 list.toString = function toString() {
1471 return this.map(function (item) {
1472 var content = "";
1473 var needLayer = typeof item[5] !== "undefined";
1474 if (item[4]) {
1475 content += "@supports (".concat(item[4], ") {");
1476 }
1477 if (item[2]) {
1478 content += "@media ".concat(item[2], " {");
1479 }
1480 if (needLayer) {
1481 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1482 }
1483 content += cssWithMappingToString(item);
1484 if (needLayer) {
1485 content += "}";
1486 }
1487 if (item[2]) {
1488 content += "}";
1489 }
1490 if (item[4]) {
1491 content += "}";
1492 }
1493 return content;
1494 }).join("");
1495 };
1496
1497 // import a list of modules into the list
1498 list.i = function i(modules, media, dedupe, supports, layer) {
1499 if (typeof modules === "string") {
1500 modules = [[null, modules, undefined]];
1501 }
1502 var alreadyImportedModules = {};
1503 if (dedupe) {
1504 for (var k = 0; k < this.length; k++) {
1505 var id = this[k][0];
1506 if (id != null) {
1507 alreadyImportedModules[id] = true;
1508 }
1509 }
1510 }
1511 for (var _k = 0; _k < modules.length; _k++) {
1512 var item = [].concat(modules[_k]);
1513 if (dedupe && alreadyImportedModules[item[0]]) {
1514 continue;
1515 }
1516 if (typeof layer !== "undefined") {
1517 if (typeof item[5] === "undefined") {
1518 item[5] = layer;
1519 } else {
1520 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1521 item[5] = layer;
1522 }
1523 }
1524 if (media) {
1525 if (!item[2]) {
1526 item[2] = media;
1527 } else {
1528 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1529 item[2] = media;
1530 }
1531 }
1532 if (supports) {
1533 if (!item[4]) {
1534 item[4] = "".concat(supports);
1535 } else {
1536 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1537 item[4] = supports;
1538 }
1539 }
1540 list.push(item);
1541 }
1542 };
1543 return list;
1544 };
1545
1546 /***/ },
1547
1548 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1549 /*!************************************************************!*\
1550 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1551 \************************************************************/
1552 (module) {
1553
1554 "use strict";
1555
1556
1557 module.exports = function (item) {
1558 var content = item[1];
1559 var cssMapping = item[3];
1560 if (!cssMapping) {
1561 return content;
1562 }
1563 if (typeof btoa === "function") {
1564 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1565 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1566 var sourceMapping = "/*# ".concat(data, " */");
1567 return [content].concat([sourceMapping]).join("\n");
1568 }
1569 return [content].join("\n");
1570 };
1571
1572 /***/ },
1573
1574 /***/ "./node_modules/toastify-js/src/toastify.css"
1575 /*!***************************************************!*\
1576 !*** ./node_modules/toastify-js/src/toastify.css ***!
1577 \***************************************************/
1578 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1579
1580 "use strict";
1581 __webpack_require__.r(__webpack_exports__);
1582 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1583 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1584 /* harmony export */ });
1585 /* 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");
1586 /* 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__);
1587 /* 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");
1588 /* 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__);
1589 /* 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");
1590 /* 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__);
1591 /* 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");
1592 /* 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__);
1593 /* 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");
1594 /* 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__);
1595 /* 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");
1596 /* 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__);
1597 /* 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");
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609 var options = {};
1610
1611 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1612 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1613
1614 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1615
1616 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1617 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1618
1619 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);
1620
1621
1622
1623
1624 /* 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);
1625
1626
1627 /***/ },
1628
1629 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1630 /*!****************************************************************************!*\
1631 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1632 \****************************************************************************/
1633 (module) {
1634
1635 "use strict";
1636
1637
1638 var stylesInDOM = [];
1639 function getIndexByIdentifier(identifier) {
1640 var result = -1;
1641 for (var i = 0; i < stylesInDOM.length; i++) {
1642 if (stylesInDOM[i].identifier === identifier) {
1643 result = i;
1644 break;
1645 }
1646 }
1647 return result;
1648 }
1649 function modulesToDom(list, options) {
1650 var idCountMap = {};
1651 var identifiers = [];
1652 for (var i = 0; i < list.length; i++) {
1653 var item = list[i];
1654 var id = options.base ? item[0] + options.base : item[0];
1655 var count = idCountMap[id] || 0;
1656 var identifier = "".concat(id, " ").concat(count);
1657 idCountMap[id] = count + 1;
1658 var indexByIdentifier = getIndexByIdentifier(identifier);
1659 var obj = {
1660 css: item[1],
1661 media: item[2],
1662 sourceMap: item[3],
1663 supports: item[4],
1664 layer: item[5]
1665 };
1666 if (indexByIdentifier !== -1) {
1667 stylesInDOM[indexByIdentifier].references++;
1668 stylesInDOM[indexByIdentifier].updater(obj);
1669 } else {
1670 var updater = addElementStyle(obj, options);
1671 options.byIndex = i;
1672 stylesInDOM.splice(i, 0, {
1673 identifier: identifier,
1674 updater: updater,
1675 references: 1
1676 });
1677 }
1678 identifiers.push(identifier);
1679 }
1680 return identifiers;
1681 }
1682 function addElementStyle(obj, options) {
1683 var api = options.domAPI(options);
1684 api.update(obj);
1685 var updater = function updater(newObj) {
1686 if (newObj) {
1687 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1688 return;
1689 }
1690 api.update(obj = newObj);
1691 } else {
1692 api.remove();
1693 }
1694 };
1695 return updater;
1696 }
1697 module.exports = function (list, options) {
1698 options = options || {};
1699 list = list || [];
1700 var lastIdentifiers = modulesToDom(list, options);
1701 return function update(newList) {
1702 newList = newList || [];
1703 for (var i = 0; i < lastIdentifiers.length; i++) {
1704 var identifier = lastIdentifiers[i];
1705 var index = getIndexByIdentifier(identifier);
1706 stylesInDOM[index].references--;
1707 }
1708 var newLastIdentifiers = modulesToDom(newList, options);
1709 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1710 var _identifier = lastIdentifiers[_i];
1711 var _index = getIndexByIdentifier(_identifier);
1712 if (stylesInDOM[_index].references === 0) {
1713 stylesInDOM[_index].updater();
1714 stylesInDOM.splice(_index, 1);
1715 }
1716 }
1717 lastIdentifiers = newLastIdentifiers;
1718 };
1719 };
1720
1721 /***/ },
1722
1723 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1724 /*!********************************************************************!*\
1725 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1726 \********************************************************************/
1727 (module) {
1728
1729 "use strict";
1730
1731
1732 var memo = {};
1733
1734 /* istanbul ignore next */
1735 function getTarget(target) {
1736 if (typeof memo[target] === "undefined") {
1737 var styleTarget = document.querySelector(target);
1738
1739 // Special case to return head of iframe instead of iframe itself
1740 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1741 try {
1742 // This will throw an exception if access to iframe is blocked
1743 // due to cross-origin restrictions
1744 styleTarget = styleTarget.contentDocument.head;
1745 } catch (e) {
1746 // istanbul ignore next
1747 styleTarget = null;
1748 }
1749 }
1750 memo[target] = styleTarget;
1751 }
1752 return memo[target];
1753 }
1754
1755 /* istanbul ignore next */
1756 function insertBySelector(insert, style) {
1757 var target = getTarget(insert);
1758 if (!target) {
1759 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1760 }
1761 target.appendChild(style);
1762 }
1763 module.exports = insertBySelector;
1764
1765 /***/ },
1766
1767 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1768 /*!**********************************************************************!*\
1769 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1770 \**********************************************************************/
1771 (module) {
1772
1773 "use strict";
1774
1775
1776 /* istanbul ignore next */
1777 function insertStyleElement(options) {
1778 var element = document.createElement("style");
1779 options.setAttributes(element, options.attributes);
1780 options.insert(element, options.options);
1781 return element;
1782 }
1783 module.exports = insertStyleElement;
1784
1785 /***/ },
1786
1787 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1788 /*!**********************************************************************************!*\
1789 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1790 \**********************************************************************************/
1791 (module, __unused_webpack_exports, __webpack_require__) {
1792
1793 "use strict";
1794
1795
1796 /* istanbul ignore next */
1797 function setAttributesWithoutAttributes(styleElement) {
1798 var nonce = true ? __webpack_require__.nc : 0;
1799 if (nonce) {
1800 styleElement.setAttribute("nonce", nonce);
1801 }
1802 }
1803 module.exports = setAttributesWithoutAttributes;
1804
1805 /***/ },
1806
1807 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1808 /*!***************************************************************!*\
1809 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1810 \***************************************************************/
1811 (module) {
1812
1813 "use strict";
1814
1815
1816 /* istanbul ignore next */
1817 function apply(styleElement, options, obj) {
1818 var css = "";
1819 if (obj.supports) {
1820 css += "@supports (".concat(obj.supports, ") {");
1821 }
1822 if (obj.media) {
1823 css += "@media ".concat(obj.media, " {");
1824 }
1825 var needLayer = typeof obj.layer !== "undefined";
1826 if (needLayer) {
1827 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1828 }
1829 css += obj.css;
1830 if (needLayer) {
1831 css += "}";
1832 }
1833 if (obj.media) {
1834 css += "}";
1835 }
1836 if (obj.supports) {
1837 css += "}";
1838 }
1839 var sourceMap = obj.sourceMap;
1840 if (sourceMap && typeof btoa !== "undefined") {
1841 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1842 }
1843
1844 // For old IE
1845 /* istanbul ignore if */
1846 options.styleTagTransform(css, styleElement, options.options);
1847 }
1848 function removeStyleElement(styleElement) {
1849 // istanbul ignore if
1850 if (styleElement.parentNode === null) {
1851 return false;
1852 }
1853 styleElement.parentNode.removeChild(styleElement);
1854 }
1855
1856 /* istanbul ignore next */
1857 function domAPI(options) {
1858 if (typeof document === "undefined") {
1859 return {
1860 update: function update() {},
1861 remove: function remove() {}
1862 };
1863 }
1864 var styleElement = options.insertStyleElement(options);
1865 return {
1866 update: function update(obj) {
1867 apply(styleElement, options, obj);
1868 },
1869 remove: function remove() {
1870 removeStyleElement(styleElement);
1871 }
1872 };
1873 }
1874 module.exports = domAPI;
1875
1876 /***/ },
1877
1878 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1879 /*!*********************************************************************!*\
1880 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1881 \*********************************************************************/
1882 (module) {
1883
1884 "use strict";
1885
1886
1887 /* istanbul ignore next */
1888 function styleTagTransform(css, styleElement) {
1889 if (styleElement.styleSheet) {
1890 styleElement.styleSheet.cssText = css;
1891 } else {
1892 while (styleElement.firstChild) {
1893 styleElement.removeChild(styleElement.firstChild);
1894 }
1895 styleElement.appendChild(document.createTextNode(css));
1896 }
1897 }
1898 module.exports = styleTagTransform;
1899
1900 /***/ },
1901
1902 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
1903 /*!**********************************************************!*\
1904 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
1905 \**********************************************************/
1906 (module) {
1907
1908 /*!
1909 * sweetalert2 v11.26.17
1910 * Released under the MIT License.
1911 */
1912 (function (global, factory) {
1913 true ? module.exports = factory() :
1914 0;
1915 })(this, (function () { 'use strict';
1916
1917 function _assertClassBrand(e, t, n) {
1918 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
1919 throw new TypeError("Private element is not present on this object");
1920 }
1921 function _checkPrivateRedeclaration(e, t) {
1922 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1923 }
1924 function _classPrivateFieldGet2(s, a) {
1925 return s.get(_assertClassBrand(s, a));
1926 }
1927 function _classPrivateFieldInitSpec(e, t, a) {
1928 _checkPrivateRedeclaration(e, t), t.set(e, a);
1929 }
1930 function _classPrivateFieldSet2(s, a, r) {
1931 return s.set(_assertClassBrand(s, a), r), r;
1932 }
1933
1934 const RESTORE_FOCUS_TIMEOUT = 100;
1935
1936 /** @type {GlobalState} */
1937 const globalState = {};
1938 const focusPreviousActiveElement = () => {
1939 if (globalState.previousActiveElement instanceof HTMLElement) {
1940 globalState.previousActiveElement.focus();
1941 globalState.previousActiveElement = null;
1942 } else if (document.body) {
1943 document.body.focus();
1944 }
1945 };
1946
1947 /**
1948 * Restore previous active (focused) element
1949 *
1950 * @param {boolean} returnFocus
1951 * @returns {Promise<void>}
1952 */
1953 const restoreActiveElement = returnFocus => {
1954 return new Promise(resolve => {
1955 if (!returnFocus) {
1956 return resolve();
1957 }
1958 const x = window.scrollX;
1959 const y = window.scrollY;
1960 globalState.restoreFocusTimeout = setTimeout(() => {
1961 focusPreviousActiveElement();
1962 resolve();
1963 }, RESTORE_FOCUS_TIMEOUT); // issues/900
1964
1965 window.scrollTo(x, y);
1966 });
1967 };
1968
1969 const swalPrefix = 'swal2-';
1970
1971 /**
1972 * @typedef {Record<SwalClass, string>} SwalClasses
1973 */
1974
1975 /**
1976 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
1977 * @typedef {Record<SwalIcon, string>} SwalIcons
1978 */
1979
1980 /** @type {SwalClass[]} */
1981 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'];
1982 const swalClasses = classNames.reduce((acc, className) => {
1983 acc[className] = swalPrefix + className;
1984 return acc;
1985 }, /** @type {SwalClasses} */{});
1986
1987 /** @type {SwalIcon[]} */
1988 const icons = ['success', 'warning', 'info', 'question', 'error'];
1989 const iconTypes = icons.reduce((acc, icon) => {
1990 acc[icon] = swalPrefix + icon;
1991 return acc;
1992 }, /** @type {SwalIcons} */{});
1993
1994 const consolePrefix = 'SweetAlert2:';
1995
1996 /**
1997 * Capitalize the first letter of a string
1998 *
1999 * @param {string} str
2000 * @returns {string}
2001 */
2002 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2003
2004 /**
2005 * Standardize console warnings
2006 *
2007 * @param {string | string[]} message
2008 */
2009 const warn = message => {
2010 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2011 };
2012
2013 /**
2014 * Standardize console errors
2015 *
2016 * @param {string} message
2017 */
2018 const error = message => {
2019 console.error(`${consolePrefix} ${message}`);
2020 };
2021
2022 /**
2023 * Private global state for `warnOnce`
2024 *
2025 * @type {string[]}
2026 * @private
2027 */
2028 const previousWarnOnceMessages = [];
2029
2030 /**
2031 * Show a console warning, but only if it hasn't already been shown
2032 *
2033 * @param {string} message
2034 */
2035 const warnOnce = message => {
2036 if (!previousWarnOnceMessages.includes(message)) {
2037 previousWarnOnceMessages.push(message);
2038 warn(message);
2039 }
2040 };
2041
2042 /**
2043 * Show a one-time console warning about deprecated params/methods
2044 *
2045 * @param {string} deprecatedParam
2046 * @param {string?} useInstead
2047 */
2048 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2049 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2050 };
2051
2052 /**
2053 * If `arg` is a function, call it (with no arguments or context) and return the result.
2054 * Otherwise, just pass the value through
2055 *
2056 * @param {(() => *) | *} arg
2057 * @returns {*}
2058 */
2059 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2060
2061 /**
2062 * @param {*} arg
2063 * @returns {boolean}
2064 */
2065 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2066
2067 /**
2068 * @param {*} arg
2069 * @returns {Promise<*>}
2070 */
2071 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2072
2073 /**
2074 * @param {*} arg
2075 * @returns {boolean}
2076 */
2077 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2078
2079 /**
2080 * Gets the popup container which contains the backdrop and the popup itself.
2081 *
2082 * @returns {HTMLElement | null}
2083 */
2084 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2085
2086 /**
2087 * @param {string} selectorString
2088 * @returns {HTMLElement | null}
2089 */
2090 const elementBySelector = selectorString => {
2091 const container = getContainer();
2092 return container ? container.querySelector(selectorString) : null;
2093 };
2094
2095 /**
2096 * @param {string} className
2097 * @returns {HTMLElement | null}
2098 */
2099 const elementByClass = className => {
2100 return elementBySelector(`.${className}`);
2101 };
2102
2103 /**
2104 * @returns {HTMLElement | null}
2105 */
2106 const getPopup = () => elementByClass(swalClasses.popup);
2107
2108 /**
2109 * @returns {HTMLElement | null}
2110 */
2111 const getIcon = () => elementByClass(swalClasses.icon);
2112
2113 /**
2114 * @returns {HTMLElement | null}
2115 */
2116 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2117
2118 /**
2119 * @returns {HTMLElement | null}
2120 */
2121 const getTitle = () => elementByClass(swalClasses.title);
2122
2123 /**
2124 * @returns {HTMLElement | null}
2125 */
2126 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2127
2128 /**
2129 * @returns {HTMLElement | null}
2130 */
2131 const getImage = () => elementByClass(swalClasses.image);
2132
2133 /**
2134 * @returns {HTMLElement | null}
2135 */
2136 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2137
2138 /**
2139 * @returns {HTMLElement | null}
2140 */
2141 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2142
2143 /**
2144 * @returns {HTMLButtonElement | null}
2145 */
2146 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2147
2148 /**
2149 * @returns {HTMLButtonElement | null}
2150 */
2151 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2152
2153 /**
2154 * @returns {HTMLButtonElement | null}
2155 */
2156 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2157
2158 /**
2159 * @returns {HTMLElement | null}
2160 */
2161 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2162
2163 /**
2164 * @returns {HTMLElement | null}
2165 */
2166 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2167
2168 /**
2169 * @returns {HTMLElement | null}
2170 */
2171 const getActions = () => elementByClass(swalClasses.actions);
2172
2173 /**
2174 * @returns {HTMLElement | null}
2175 */
2176 const getFooter = () => elementByClass(swalClasses.footer);
2177
2178 /**
2179 * @returns {HTMLElement | null}
2180 */
2181 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2182
2183 /**
2184 * @returns {HTMLElement | null}
2185 */
2186 const getCloseButton = () => elementByClass(swalClasses.close);
2187
2188 // https://github.com/jkup/focusable/blob/master/index.js
2189 const focusable = `
2190 a[href],
2191 area[href],
2192 input:not([disabled]),
2193 select:not([disabled]),
2194 textarea:not([disabled]),
2195 button:not([disabled]),
2196 iframe,
2197 object,
2198 embed,
2199 [tabindex="0"],
2200 [contenteditable],
2201 audio[controls],
2202 video[controls],
2203 summary
2204 `;
2205 /**
2206 * @returns {HTMLElement[]}
2207 */
2208 const getFocusableElements = () => {
2209 const popup = getPopup();
2210 if (!popup) {
2211 return [];
2212 }
2213 /** @type {NodeListOf<HTMLElement>} */
2214 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2215 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2216 // sort according to tabindex
2217 .sort((a, b) => {
2218 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2219 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2220 if (tabindexA > tabindexB) {
2221 return 1;
2222 } else if (tabindexA < tabindexB) {
2223 return -1;
2224 }
2225 return 0;
2226 });
2227
2228 /** @type {NodeListOf<HTMLElement>} */
2229 const otherFocusableElements = popup.querySelectorAll(focusable);
2230 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2231 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2232 };
2233
2234 /**
2235 * @returns {boolean}
2236 */
2237 const isModal = () => {
2238 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2239 };
2240
2241 /**
2242 * @returns {boolean}
2243 */
2244 const isToast = () => {
2245 const popup = getPopup();
2246 if (!popup) {
2247 return false;
2248 }
2249 return hasClass(popup, swalClasses.toast);
2250 };
2251
2252 /**
2253 * @returns {boolean}
2254 */
2255 const isLoading = () => {
2256 const popup = getPopup();
2257 if (!popup) {
2258 return false;
2259 }
2260 return popup.hasAttribute('data-loading');
2261 };
2262
2263 /**
2264 * Securely set innerHTML of an element
2265 * https://github.com/sweetalert2/sweetalert2/issues/1926
2266 *
2267 * @param {HTMLElement} elem
2268 * @param {string} html
2269 */
2270 const setInnerHtml = (elem, html) => {
2271 elem.textContent = '';
2272 if (html) {
2273 const parser = new DOMParser();
2274 const parsed = parser.parseFromString(html, `text/html`);
2275 const head = parsed.querySelector('head');
2276 if (head) {
2277 Array.from(head.childNodes).forEach(child => {
2278 elem.appendChild(child);
2279 });
2280 }
2281 const body = parsed.querySelector('body');
2282 if (body) {
2283 Array.from(body.childNodes).forEach(child => {
2284 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2285 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2286 } else {
2287 elem.appendChild(child);
2288 }
2289 });
2290 }
2291 }
2292 };
2293
2294 /**
2295 * @param {HTMLElement} elem
2296 * @param {string} className
2297 * @returns {boolean}
2298 */
2299 const hasClass = (elem, className) => {
2300 if (!className) {
2301 return false;
2302 }
2303 const classList = className.split(/\s+/);
2304 for (let i = 0; i < classList.length; i++) {
2305 if (!elem.classList.contains(classList[i])) {
2306 return false;
2307 }
2308 }
2309 return true;
2310 };
2311
2312 /**
2313 * @param {HTMLElement} elem
2314 * @param {SweetAlertOptions} params
2315 */
2316 const removeCustomClasses = (elem, params) => {
2317 Array.from(elem.classList).forEach(className => {
2318 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2319 elem.classList.remove(className);
2320 }
2321 });
2322 };
2323
2324 /**
2325 * @param {HTMLElement} elem
2326 * @param {SweetAlertOptions} params
2327 * @param {string} className
2328 */
2329 const applyCustomClass = (elem, params, className) => {
2330 removeCustomClasses(elem, params);
2331 if (!params.customClass) {
2332 return;
2333 }
2334 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2335 if (!customClass) {
2336 return;
2337 }
2338 if (typeof customClass !== 'string' && !customClass.forEach) {
2339 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2340 return;
2341 }
2342 addClass(elem, customClass);
2343 };
2344
2345 /**
2346 * @param {HTMLElement} popup
2347 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2348 * @returns {HTMLInputElement | null}
2349 */
2350 const getInput$1 = (popup, inputClass) => {
2351 if (!inputClass) {
2352 return null;
2353 }
2354 switch (inputClass) {
2355 case 'select':
2356 case 'textarea':
2357 case 'file':
2358 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2359 case 'checkbox':
2360 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2361 case 'radio':
2362 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2363 case 'range':
2364 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2365 default:
2366 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2367 }
2368 };
2369
2370 /**
2371 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2372 */
2373 const focusInput = input => {
2374 input.focus();
2375
2376 // place cursor at end of text in text input
2377 if (input.type !== 'file') {
2378 // http://stackoverflow.com/a/2345915
2379 const val = input.value;
2380 input.value = '';
2381 input.value = val;
2382 }
2383 };
2384
2385 /**
2386 * @param {HTMLElement | HTMLElement[] | null} target
2387 * @param {string | string[] | readonly string[] | undefined} classList
2388 * @param {boolean} condition
2389 */
2390 const toggleClass = (target, classList, condition) => {
2391 if (!target || !classList) {
2392 return;
2393 }
2394 if (typeof classList === 'string') {
2395 classList = classList.split(/\s+/).filter(Boolean);
2396 }
2397 classList.forEach(className => {
2398 if (Array.isArray(target)) {
2399 target.forEach(elem => {
2400 if (condition) {
2401 elem.classList.add(className);
2402 } else {
2403 elem.classList.remove(className);
2404 }
2405 });
2406 } else {
2407 if (condition) {
2408 target.classList.add(className);
2409 } else {
2410 target.classList.remove(className);
2411 }
2412 }
2413 });
2414 };
2415
2416 /**
2417 * @param {HTMLElement | HTMLElement[] | null} target
2418 * @param {string | string[] | readonly string[] | undefined} classList
2419 */
2420 const addClass = (target, classList) => {
2421 toggleClass(target, classList, true);
2422 };
2423
2424 /**
2425 * @param {HTMLElement | HTMLElement[] | null} target
2426 * @param {string | string[] | readonly string[] | undefined} classList
2427 */
2428 const removeClass = (target, classList) => {
2429 toggleClass(target, classList, false);
2430 };
2431
2432 /**
2433 * Get direct child of an element by class name
2434 *
2435 * @param {HTMLElement} elem
2436 * @param {string} className
2437 * @returns {HTMLElement | undefined}
2438 */
2439 const getDirectChildByClass = (elem, className) => {
2440 const children = Array.from(elem.children);
2441 for (let i = 0; i < children.length; i++) {
2442 const child = children[i];
2443 if (child instanceof HTMLElement && hasClass(child, className)) {
2444 return child;
2445 }
2446 }
2447 };
2448
2449 /**
2450 * @param {HTMLElement} elem
2451 * @param {string} property
2452 * @param {string | number | null | undefined} value
2453 */
2454 const applyNumericalStyle = (elem, property, value) => {
2455 if (value === `${parseInt(`${value}`)}`) {
2456 value = parseInt(value);
2457 }
2458 if (value || parseInt(`${value}`) === 0) {
2459 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2460 } else {
2461 elem.style.removeProperty(property);
2462 }
2463 };
2464
2465 /**
2466 * @param {HTMLElement | null} elem
2467 * @param {string} display
2468 */
2469 const show = (elem, display = 'flex') => {
2470 if (!elem) {
2471 return;
2472 }
2473 elem.style.display = display;
2474 };
2475
2476 /**
2477 * @param {HTMLElement | null} elem
2478 */
2479 const hide = elem => {
2480 if (!elem) {
2481 return;
2482 }
2483 elem.style.display = 'none';
2484 };
2485
2486 /**
2487 * @param {HTMLElement | null} elem
2488 * @param {string} display
2489 */
2490 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2491 if (!elem) {
2492 return;
2493 }
2494 new MutationObserver(() => {
2495 toggle(elem, elem.innerHTML, display);
2496 }).observe(elem, {
2497 childList: true,
2498 subtree: true
2499 });
2500 };
2501
2502 /**
2503 * @param {HTMLElement} parent
2504 * @param {string} selector
2505 * @param {string} property
2506 * @param {string} value
2507 */
2508 const setStyle = (parent, selector, property, value) => {
2509 /** @type {HTMLElement | null} */
2510 const el = parent.querySelector(selector);
2511 if (el) {
2512 el.style.setProperty(property, value);
2513 }
2514 };
2515
2516 /**
2517 * @param {HTMLElement} elem
2518 * @param {boolean | string | null | undefined} condition
2519 * @param {string} display
2520 */
2521 const toggle = (elem, condition, display = 'flex') => {
2522 if (condition) {
2523 show(elem, display);
2524 } else {
2525 hide(elem);
2526 }
2527 };
2528
2529 /**
2530 * borrowed from jquery $(elem).is(':visible') implementation
2531 *
2532 * @param {HTMLElement | null} elem
2533 * @returns {boolean}
2534 */
2535 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2536
2537 /**
2538 * @returns {boolean}
2539 */
2540 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2541
2542 /**
2543 * @param {HTMLElement} elem
2544 * @returns {boolean}
2545 */
2546 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2547
2548 /**
2549 * @param {HTMLElement} element
2550 * @param {HTMLElement} stopElement
2551 * @returns {boolean}
2552 */
2553 const selfOrParentIsScrollable = (element, stopElement) => {
2554 let parent = /** @type {HTMLElement | null} */element;
2555 while (parent && parent !== stopElement) {
2556 if (isScrollable(parent)) {
2557 return true;
2558 }
2559 parent = parent.parentElement;
2560 }
2561 return false;
2562 };
2563
2564 /**
2565 * borrowed from https://stackoverflow.com/a/46352119
2566 *
2567 * @param {HTMLElement} elem
2568 * @returns {boolean}
2569 */
2570 const hasCssAnimation = elem => {
2571 const style = window.getComputedStyle(elem);
2572 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2573 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2574 return animDuration > 0 || transDuration > 0;
2575 };
2576
2577 /**
2578 * @param {number} timer
2579 * @param {boolean} reset
2580 */
2581 const animateTimerProgressBar = (timer, reset = false) => {
2582 const timerProgressBar = getTimerProgressBar();
2583 if (!timerProgressBar) {
2584 return;
2585 }
2586 if (isVisible$1(timerProgressBar)) {
2587 if (reset) {
2588 timerProgressBar.style.transition = 'none';
2589 timerProgressBar.style.width = '100%';
2590 }
2591 setTimeout(() => {
2592 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2593 timerProgressBar.style.width = '0%';
2594 }, 10);
2595 }
2596 };
2597 const stopTimerProgressBar = () => {
2598 const timerProgressBar = getTimerProgressBar();
2599 if (!timerProgressBar) {
2600 return;
2601 }
2602 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2603 timerProgressBar.style.removeProperty('transition');
2604 timerProgressBar.style.width = '100%';
2605 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2606 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2607 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2608 };
2609
2610 /**
2611 * Detect Node env
2612 *
2613 * @returns {boolean}
2614 */
2615 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2616
2617 const sweetHTML = `
2618 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2619 <button type="button" class="${swalClasses.close}"></button>
2620 <ul class="${swalClasses['progress-steps']}"></ul>
2621 <div class="${swalClasses.icon}"></div>
2622 <img class="${swalClasses.image}" />
2623 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2624 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2625 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2626 <input type="file" class="${swalClasses.file}" />
2627 <div class="${swalClasses.range}">
2628 <input type="range" />
2629 <output></output>
2630 </div>
2631 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2632 <div class="${swalClasses.radio}"></div>
2633 <label class="${swalClasses.checkbox}">
2634 <input type="checkbox" id="${swalClasses.checkbox}" />
2635 <span class="${swalClasses.label}"></span>
2636 </label>
2637 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2638 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2639 <div class="${swalClasses.actions}">
2640 <div class="${swalClasses.loader}"></div>
2641 <button type="button" class="${swalClasses.confirm}"></button>
2642 <button type="button" class="${swalClasses.deny}"></button>
2643 <button type="button" class="${swalClasses.cancel}"></button>
2644 </div>
2645 <div class="${swalClasses.footer}"></div>
2646 <div class="${swalClasses['timer-progress-bar-container']}">
2647 <div class="${swalClasses['timer-progress-bar']}"></div>
2648 </div>
2649 </div>
2650 `.replace(/(^|\n)\s*/g, '');
2651
2652 /**
2653 * @returns {boolean}
2654 */
2655 const resetOldContainer = () => {
2656 const oldContainer = getContainer();
2657 if (!oldContainer) {
2658 return false;
2659 }
2660 oldContainer.remove();
2661 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2662 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2663 swalClasses['has-column']]);
2664 return true;
2665 };
2666 const resetValidationMessage$1 = () => {
2667 if (globalState.currentInstance) {
2668 globalState.currentInstance.resetValidationMessage();
2669 }
2670 };
2671 const addInputChangeListeners = () => {
2672 const popup = getPopup();
2673 if (!popup) {
2674 return;
2675 }
2676 const input = getDirectChildByClass(popup, swalClasses.input);
2677 const file = getDirectChildByClass(popup, swalClasses.file);
2678 /** @type {HTMLInputElement | null} */
2679 const range = popup.querySelector(`.${swalClasses.range} input`);
2680 /** @type {HTMLOutputElement | null} */
2681 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2682 const select = getDirectChildByClass(popup, swalClasses.select);
2683 /** @type {HTMLInputElement | null} */
2684 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2685 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2686 if (input) {
2687 input.oninput = resetValidationMessage$1;
2688 }
2689 if (file) {
2690 file.onchange = resetValidationMessage$1;
2691 }
2692 if (select) {
2693 select.onchange = resetValidationMessage$1;
2694 }
2695 if (checkbox) {
2696 checkbox.onchange = resetValidationMessage$1;
2697 }
2698 if (textarea) {
2699 textarea.oninput = resetValidationMessage$1;
2700 }
2701 if (range && rangeOutput) {
2702 range.oninput = () => {
2703 resetValidationMessage$1();
2704 rangeOutput.value = range.value;
2705 };
2706 range.onchange = () => {
2707 resetValidationMessage$1();
2708 rangeOutput.value = range.value;
2709 };
2710 }
2711 };
2712
2713 /**
2714 * @param {string | HTMLElement} target
2715 * @returns {HTMLElement}
2716 */
2717 const getTarget = target => {
2718 if (typeof target === 'string') {
2719 const element = document.querySelector(target);
2720 if (!element) {
2721 throw new Error(`Target element "${target}" not found`);
2722 }
2723 return /** @type {HTMLElement} */element;
2724 }
2725 return target;
2726 };
2727
2728 /**
2729 * @param {SweetAlertOptions} params
2730 */
2731 const setupAccessibility = params => {
2732 const popup = getPopup();
2733 if (!popup) {
2734 return;
2735 }
2736 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2737 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2738 if (!params.toast) {
2739 popup.setAttribute('aria-modal', 'true');
2740 }
2741 };
2742
2743 /**
2744 * @param {HTMLElement} targetElement
2745 */
2746 const setupRTL = targetElement => {
2747 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2748 addClass(getContainer(), swalClasses.rtl);
2749 globalState.isRTL = true;
2750 }
2751 };
2752
2753 /**
2754 * Add modal + backdrop to DOM
2755 *
2756 * @param {SweetAlertOptions} params
2757 */
2758 const init = params => {
2759 // Clean up the old popup container if it exists
2760 const oldContainerExisted = resetOldContainer();
2761 if (isNodeEnv()) {
2762 error('SweetAlert2 requires document to initialize');
2763 return;
2764 }
2765 const container = document.createElement('div');
2766 container.className = swalClasses.container;
2767 if (oldContainerExisted) {
2768 addClass(container, swalClasses['no-transition']);
2769 }
2770 setInnerHtml(container, sweetHTML);
2771 container.dataset['swal2Theme'] = params.theme;
2772 const targetElement = getTarget(params.target || 'body');
2773 targetElement.appendChild(container);
2774 if (params.topLayer) {
2775 container.setAttribute('popover', '');
2776 container.showPopover();
2777 }
2778 setupAccessibility(params);
2779 setupRTL(targetElement);
2780 addInputChangeListeners();
2781 };
2782
2783 /**
2784 * @param {HTMLElement | object | string} param
2785 * @param {HTMLElement} target
2786 */
2787 const parseHtmlToContainer = (param, target) => {
2788 // DOM element
2789 if (param instanceof HTMLElement) {
2790 target.appendChild(param);
2791 }
2792
2793 // Object
2794 else if (typeof param === 'object') {
2795 handleObject(param, target);
2796 }
2797
2798 // Plain string
2799 else if (param) {
2800 setInnerHtml(target, param);
2801 }
2802 };
2803
2804 /**
2805 * @param {object} param
2806 * @param {HTMLElement} target
2807 */
2808 const handleObject = (param, target) => {
2809 // JQuery element(s)
2810 if ('jquery' in param) {
2811 handleJqueryElem(target, param);
2812 }
2813
2814 // For other objects use their string representation
2815 else {
2816 setInnerHtml(target, param.toString());
2817 }
2818 };
2819
2820 /**
2821 * @param {HTMLElement} target
2822 * @param {any} elem
2823 */
2824 const handleJqueryElem = (target, elem) => {
2825 target.textContent = '';
2826 if (0 in elem) {
2827 for (let i = 0; i in elem; i++) {
2828 target.appendChild(elem[i].cloneNode(true));
2829 }
2830 } else {
2831 target.appendChild(elem.cloneNode(true));
2832 }
2833 };
2834
2835 /**
2836 * @param {SweetAlert} instance
2837 * @param {SweetAlertOptions} params
2838 */
2839 const renderActions = (instance, params) => {
2840 const actions = getActions();
2841 const loader = getLoader();
2842 if (!actions || !loader) {
2843 return;
2844 }
2845
2846 // Actions (buttons) wrapper
2847 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2848 hide(actions);
2849 } else {
2850 show(actions);
2851 }
2852
2853 // Custom class
2854 applyCustomClass(actions, params, 'actions');
2855
2856 // Render all the buttons
2857 renderButtons(actions, loader, params);
2858
2859 // Loader
2860 setInnerHtml(loader, params.loaderHtml || '');
2861 applyCustomClass(loader, params, 'loader');
2862 };
2863
2864 /**
2865 * @param {HTMLElement} actions
2866 * @param {HTMLElement} loader
2867 * @param {SweetAlertOptions} params
2868 */
2869 function renderButtons(actions, loader, params) {
2870 const confirmButton = getConfirmButton();
2871 const denyButton = getDenyButton();
2872 const cancelButton = getCancelButton();
2873 if (!confirmButton || !denyButton || !cancelButton) {
2874 return;
2875 }
2876
2877 // Render buttons
2878 renderButton(confirmButton, 'confirm', params);
2879 renderButton(denyButton, 'deny', params);
2880 renderButton(cancelButton, 'cancel', params);
2881 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
2882 if (params.reverseButtons) {
2883 if (params.toast) {
2884 actions.insertBefore(cancelButton, confirmButton);
2885 actions.insertBefore(denyButton, confirmButton);
2886 } else {
2887 actions.insertBefore(cancelButton, loader);
2888 actions.insertBefore(denyButton, loader);
2889 actions.insertBefore(confirmButton, loader);
2890 }
2891 }
2892 }
2893
2894 /**
2895 * @param {HTMLElement} confirmButton
2896 * @param {HTMLElement} denyButton
2897 * @param {HTMLElement} cancelButton
2898 * @param {SweetAlertOptions} params
2899 */
2900 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
2901 if (!params.buttonsStyling) {
2902 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2903 return;
2904 }
2905 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2906
2907 // Apply custom background colors to action buttons
2908 if (params.confirmButtonColor) {
2909 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
2910 }
2911 if (params.denyButtonColor) {
2912 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
2913 }
2914 if (params.cancelButtonColor) {
2915 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
2916 }
2917
2918 // Apply the outline color to action buttons
2919 applyOutlineColor(confirmButton);
2920 applyOutlineColor(denyButton);
2921 applyOutlineColor(cancelButton);
2922 }
2923
2924 /**
2925 * @param {HTMLElement} button
2926 */
2927 function applyOutlineColor(button) {
2928 const buttonStyle = window.getComputedStyle(button);
2929 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
2930 // If the button already has a custom outline color, no need to change it
2931 return;
2932 }
2933 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
2934 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
2935 }
2936
2937 /**
2938 * @param {HTMLElement} button
2939 * @param {'confirm' | 'deny' | 'cancel'} buttonType
2940 * @param {SweetAlertOptions} params
2941 */
2942 function renderButton(button, buttonType, params) {
2943 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
2944 toggle(button, params[`show${buttonName}Button`], 'inline-block');
2945 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
2946 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
2947
2948 // Add buttons custom classes
2949 button.className = swalClasses[buttonType];
2950 applyCustomClass(button, params, `${buttonType}Button`);
2951 }
2952
2953 /**
2954 * @param {SweetAlert} instance
2955 * @param {SweetAlertOptions} params
2956 */
2957 const renderCloseButton = (instance, params) => {
2958 const closeButton = getCloseButton();
2959 if (!closeButton) {
2960 return;
2961 }
2962 setInnerHtml(closeButton, params.closeButtonHtml || '');
2963
2964 // Custom class
2965 applyCustomClass(closeButton, params, 'closeButton');
2966 toggle(closeButton, params.showCloseButton);
2967 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
2968 };
2969
2970 /**
2971 * @param {SweetAlert} instance
2972 * @param {SweetAlertOptions} params
2973 */
2974 const renderContainer = (instance, params) => {
2975 const container = getContainer();
2976 if (!container) {
2977 return;
2978 }
2979 handleBackdropParam(container, params.backdrop);
2980 handlePositionParam(container, params.position);
2981 handleGrowParam(container, params.grow);
2982
2983 // Custom class
2984 applyCustomClass(container, params, 'container');
2985 };
2986
2987 /**
2988 * @param {HTMLElement} container
2989 * @param {SweetAlertOptions['backdrop']} backdrop
2990 */
2991 function handleBackdropParam(container, backdrop) {
2992 if (typeof backdrop === 'string') {
2993 container.style.background = backdrop;
2994 } else if (!backdrop) {
2995 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
2996 }
2997 }
2998
2999 /**
3000 * @param {HTMLElement} container
3001 * @param {SweetAlertOptions['position']} position
3002 */
3003 function handlePositionParam(container, position) {
3004 if (!position) {
3005 return;
3006 }
3007 if (position in swalClasses) {
3008 addClass(container, swalClasses[position]);
3009 } else {
3010 warn('The "position" parameter is not valid, defaulting to "center"');
3011 addClass(container, swalClasses.center);
3012 }
3013 }
3014
3015 /**
3016 * @param {HTMLElement} container
3017 * @param {SweetAlertOptions['grow']} grow
3018 */
3019 function handleGrowParam(container, grow) {
3020 if (!grow) {
3021 return;
3022 }
3023 addClass(container, swalClasses[`grow-${grow}`]);
3024 }
3025
3026 /**
3027 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3028 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3029 * This is the approach that Babel will probably take to implement private methods/fields
3030 * https://github.com/tc39/proposal-private-methods
3031 * https://github.com/babel/babel/pull/7555
3032 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3033 * then we can use that language feature.
3034 */
3035
3036 var privateProps = {
3037 innerParams: new WeakMap(),
3038 domCache: new WeakMap()
3039 };
3040
3041 /// <reference path="../../../../sweetalert2.d.ts"/>
3042
3043
3044 /** @type {InputClass[]} */
3045 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3046
3047 /**
3048 * @param {SweetAlert} instance
3049 * @param {SweetAlertOptions} params
3050 */
3051 const renderInput = (instance, params) => {
3052 const popup = getPopup();
3053 if (!popup) {
3054 return;
3055 }
3056 const innerParams = privateProps.innerParams.get(instance);
3057 const rerender = !innerParams || params.input !== innerParams.input;
3058 inputClasses.forEach(inputClass => {
3059 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3060 if (!inputContainer) {
3061 return;
3062 }
3063
3064 // set attributes
3065 setAttributes(inputClass, params.inputAttributes);
3066
3067 // set class
3068 inputContainer.className = swalClasses[inputClass];
3069 if (rerender) {
3070 hide(inputContainer);
3071 }
3072 });
3073 if (params.input) {
3074 if (rerender) {
3075 showInput(params);
3076 }
3077 // set custom class
3078 setCustomClass(params);
3079 }
3080 };
3081
3082 /**
3083 * @param {SweetAlertOptions} params
3084 */
3085 const showInput = params => {
3086 if (!params.input) {
3087 return;
3088 }
3089 if (!renderInputType[params.input]) {
3090 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3091 return;
3092 }
3093 const inputContainer = getInputContainer(params.input);
3094 if (!inputContainer) {
3095 return;
3096 }
3097 const input = renderInputType[params.input](inputContainer, params);
3098 show(inputContainer);
3099
3100 // input autofocus
3101 if (params.inputAutoFocus) {
3102 setTimeout(() => {
3103 focusInput(input);
3104 });
3105 }
3106 };
3107
3108 /**
3109 * @param {HTMLInputElement} input
3110 */
3111 const removeAttributes = input => {
3112 for (let i = 0; i < input.attributes.length; i++) {
3113 const attrName = input.attributes[i].name;
3114 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
3115 input.removeAttribute(attrName);
3116 }
3117 }
3118 };
3119
3120 /**
3121 * @param {InputClass} inputClass
3122 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3123 */
3124 const setAttributes = (inputClass, inputAttributes) => {
3125 const popup = getPopup();
3126 if (!popup) {
3127 return;
3128 }
3129 const input = getInput$1(popup, inputClass);
3130 if (!input) {
3131 return;
3132 }
3133 removeAttributes(input);
3134 for (const attr in inputAttributes) {
3135 input.setAttribute(attr, inputAttributes[attr]);
3136 }
3137 };
3138
3139 /**
3140 * @param {SweetAlertOptions} params
3141 */
3142 const setCustomClass = params => {
3143 if (!params.input) {
3144 return;
3145 }
3146 const inputContainer = getInputContainer(params.input);
3147 if (inputContainer) {
3148 applyCustomClass(inputContainer, params, 'input');
3149 }
3150 };
3151
3152 /**
3153 * @param {HTMLInputElement | HTMLTextAreaElement} input
3154 * @param {SweetAlertOptions} params
3155 */
3156 const setInputPlaceholder = (input, params) => {
3157 if (!input.placeholder && params.inputPlaceholder) {
3158 input.placeholder = params.inputPlaceholder;
3159 }
3160 };
3161
3162 /**
3163 * @param {Input} input
3164 * @param {Input} prependTo
3165 * @param {SweetAlertOptions} params
3166 */
3167 const setInputLabel = (input, prependTo, params) => {
3168 if (params.inputLabel) {
3169 const label = document.createElement('label');
3170 const labelClass = swalClasses['input-label'];
3171 label.setAttribute('for', input.id);
3172 label.className = labelClass;
3173 if (typeof params.customClass === 'object') {
3174 addClass(label, params.customClass.inputLabel);
3175 }
3176 label.innerText = params.inputLabel;
3177 prependTo.insertAdjacentElement('beforebegin', label);
3178 }
3179 };
3180
3181 /**
3182 * @param {SweetAlertInput} inputType
3183 * @returns {HTMLElement | undefined}
3184 */
3185 const getInputContainer = inputType => {
3186 const popup = getPopup();
3187 if (!popup) {
3188 return;
3189 }
3190 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3191 };
3192
3193 /**
3194 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3195 * @param {SweetAlertOptions['inputValue']} inputValue
3196 */
3197 const checkAndSetInputValue = (input, inputValue) => {
3198 if (['string', 'number'].includes(typeof inputValue)) {
3199 input.value = `${inputValue}`;
3200 } else if (!isPromise(inputValue)) {
3201 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3202 }
3203 };
3204
3205 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3206 const renderInputType = {};
3207
3208 /**
3209 * @param {Input | HTMLElement} input
3210 * @param {SweetAlertOptions} params
3211 * @returns {Input}
3212 */
3213 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} */
3214 (input, params) => {
3215 const inputElement = /** @type {HTMLInputElement} */input;
3216 checkAndSetInputValue(inputElement, params.inputValue);
3217 setInputLabel(inputElement, inputElement, params);
3218 setInputPlaceholder(inputElement, params);
3219 inputElement.type = /** @type {string} */params.input;
3220 return inputElement;
3221 };
3222
3223 /**
3224 * @param {Input | HTMLElement} input
3225 * @param {SweetAlertOptions} params
3226 * @returns {Input}
3227 */
3228 renderInputType.file = (input, params) => {
3229 const inputElement = /** @type {HTMLInputElement} */input;
3230 setInputLabel(inputElement, inputElement, params);
3231 setInputPlaceholder(inputElement, params);
3232 return inputElement;
3233 };
3234
3235 /**
3236 * @param {Input | HTMLElement} range
3237 * @param {SweetAlertOptions} params
3238 * @returns {Input}
3239 */
3240 renderInputType.range = (range, params) => {
3241 const rangeContainer = /** @type {HTMLElement} */range;
3242 const rangeInput = rangeContainer.querySelector('input');
3243 const rangeOutput = rangeContainer.querySelector('output');
3244 if (rangeInput) {
3245 checkAndSetInputValue(rangeInput, params.inputValue);
3246 rangeInput.type = /** @type {string} */params.input;
3247 setInputLabel(rangeInput, /** @type {Input} */range, params);
3248 }
3249 if (rangeOutput) {
3250 checkAndSetInputValue(rangeOutput, params.inputValue);
3251 }
3252 return /** @type {Input} */range;
3253 };
3254
3255 /**
3256 * @param {Input | HTMLElement} select
3257 * @param {SweetAlertOptions} params
3258 * @returns {Input}
3259 */
3260 renderInputType.select = (select, params) => {
3261 const selectElement = /** @type {HTMLSelectElement} */select;
3262 selectElement.textContent = '';
3263 if (params.inputPlaceholder) {
3264 const placeholder = document.createElement('option');
3265 setInnerHtml(placeholder, params.inputPlaceholder);
3266 placeholder.value = '';
3267 placeholder.disabled = true;
3268 placeholder.selected = true;
3269 selectElement.appendChild(placeholder);
3270 }
3271 setInputLabel(selectElement, selectElement, params);
3272 return selectElement;
3273 };
3274
3275 /**
3276 * @param {Input | HTMLElement} radio
3277 * @returns {Input}
3278 */
3279 renderInputType.radio = radio => {
3280 const radioElement = /** @type {HTMLElement} */radio;
3281 radioElement.textContent = '';
3282 return /** @type {Input} */radio;
3283 };
3284
3285 /**
3286 * @param {Input | HTMLElement} checkboxContainer
3287 * @param {SweetAlertOptions} params
3288 * @returns {Input}
3289 */
3290 renderInputType.checkbox = (checkboxContainer, params) => {
3291 const popup = getPopup();
3292 if (!popup) {
3293 throw new Error('Popup not found');
3294 }
3295 const checkbox = getInput$1(popup, 'checkbox');
3296 if (!checkbox) {
3297 throw new Error('Checkbox input not found');
3298 }
3299 checkbox.value = '1';
3300 checkbox.checked = Boolean(params.inputValue);
3301 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3302 const label = containerElement.querySelector('span');
3303 if (label) {
3304 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3305 if (placeholderOrLabel) {
3306 setInnerHtml(label, placeholderOrLabel);
3307 }
3308 }
3309 return checkbox;
3310 };
3311
3312 /**
3313 * @param {Input | HTMLElement} textarea
3314 * @param {SweetAlertOptions} params
3315 * @returns {Input}
3316 */
3317 renderInputType.textarea = (textarea, params) => {
3318 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3319 checkAndSetInputValue(textareaElement, params.inputValue);
3320 setInputPlaceholder(textareaElement, params);
3321 setInputLabel(textareaElement, textareaElement, params);
3322
3323 /**
3324 * @param {HTMLElement} el
3325 * @returns {number}
3326 */
3327 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3328
3329 // https://github.com/sweetalert2/sweetalert2/issues/2291
3330 setTimeout(() => {
3331 // https://github.com/sweetalert2/sweetalert2/issues/1699
3332 if ('MutationObserver' in window) {
3333 const popup = getPopup();
3334 if (!popup) {
3335 return;
3336 }
3337 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3338 const textareaResizeHandler = () => {
3339 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3340 if (!document.body.contains(textareaElement)) {
3341 return;
3342 }
3343 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3344 const popupElement = getPopup();
3345 if (popupElement) {
3346 if (textareaWidth > initialPopupWidth) {
3347 popupElement.style.width = `${textareaWidth}px`;
3348 } else {
3349 applyNumericalStyle(popupElement, 'width', params.width);
3350 }
3351 }
3352 };
3353 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3354 attributes: true,
3355 attributeFilter: ['style']
3356 });
3357 }
3358 });
3359 return textareaElement;
3360 };
3361
3362 /**
3363 * @param {SweetAlert} instance
3364 * @param {SweetAlertOptions} params
3365 */
3366 const renderContent = (instance, params) => {
3367 const htmlContainer = getHtmlContainer();
3368 if (!htmlContainer) {
3369 return;
3370 }
3371 showWhenInnerHtmlPresent(htmlContainer);
3372 applyCustomClass(htmlContainer, params, 'htmlContainer');
3373
3374 // Content as HTML
3375 if (params.html) {
3376 parseHtmlToContainer(params.html, htmlContainer);
3377 show(htmlContainer, 'block');
3378 }
3379
3380 // Content as plain text
3381 else if (params.text) {
3382 htmlContainer.textContent = params.text;
3383 show(htmlContainer, 'block');
3384 }
3385
3386 // No content
3387 else {
3388 hide(htmlContainer);
3389 }
3390 renderInput(instance, params);
3391 };
3392
3393 /**
3394 * @param {SweetAlert} instance
3395 * @param {SweetAlertOptions} params
3396 */
3397 const renderFooter = (instance, params) => {
3398 const footer = getFooter();
3399 if (!footer) {
3400 return;
3401 }
3402 showWhenInnerHtmlPresent(footer);
3403 toggle(footer, Boolean(params.footer), 'block');
3404 if (params.footer) {
3405 parseHtmlToContainer(params.footer, footer);
3406 }
3407
3408 // Custom class
3409 applyCustomClass(footer, params, 'footer');
3410 };
3411
3412 /**
3413 * @param {SweetAlert} instance
3414 * @param {SweetAlertOptions} params
3415 */
3416 const renderIcon = (instance, params) => {
3417 const innerParams = privateProps.innerParams.get(instance);
3418 const icon = getIcon();
3419 if (!icon) {
3420 return;
3421 }
3422
3423 // if the given icon already rendered, apply the styling without re-rendering the icon
3424 if (innerParams && params.icon === innerParams.icon) {
3425 // Custom or default content
3426 setContent(icon, params);
3427 applyStyles(icon, params);
3428 return;
3429 }
3430 if (!params.icon && !params.iconHtml) {
3431 hide(icon);
3432 return;
3433 }
3434 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3435 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3436 hide(icon);
3437 return;
3438 }
3439 show(icon);
3440
3441 // Custom or default content
3442 setContent(icon, params);
3443 applyStyles(icon, params);
3444
3445 // Animate icon
3446 addClass(icon, params.showClass && params.showClass.icon);
3447
3448 // Re-adjust the success icon on system theme change
3449 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3450 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3451 };
3452
3453 /**
3454 * @param {HTMLElement} icon
3455 * @param {SweetAlertOptions} params
3456 */
3457 const applyStyles = (icon, params) => {
3458 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3459 if (params.icon !== iconType) {
3460 removeClass(icon, iconClassName);
3461 }
3462 }
3463 addClass(icon, params.icon && iconTypes[params.icon]);
3464
3465 // Icon color
3466 setColor(icon, params);
3467
3468 // Success icon background color
3469 adjustSuccessIconBackgroundColor();
3470
3471 // Custom class
3472 applyCustomClass(icon, params, 'icon');
3473 };
3474
3475 // Adjust success icon background color to match the popup background color
3476 const adjustSuccessIconBackgroundColor = () => {
3477 const popup = getPopup();
3478 if (!popup) {
3479 return;
3480 }
3481 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3482 /** @type {NodeListOf<HTMLElement>} */
3483 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3484 for (let i = 0; i < successIconParts.length; i++) {
3485 successIconParts[i].style.backgroundColor = popupBackgroundColor;
3486 }
3487 };
3488
3489 /**
3490 *
3491 * @param {SweetAlertOptions} params
3492 * @returns {string}
3493 */
3494 const successIconHtml = params => `
3495 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3496 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3497 <div class="swal2-success-ring"></div>
3498 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3499 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3500 `;
3501 const errorIconHtml = `
3502 <span class="swal2-x-mark">
3503 <span class="swal2-x-mark-line-left"></span>
3504 <span class="swal2-x-mark-line-right"></span>
3505 </span>
3506 `;
3507
3508 /**
3509 * @param {HTMLElement} icon
3510 * @param {SweetAlertOptions} params
3511 */
3512 const setContent = (icon, params) => {
3513 if (!params.icon && !params.iconHtml) {
3514 return;
3515 }
3516 let oldContent = icon.innerHTML;
3517 let newContent = '';
3518 if (params.iconHtml) {
3519 newContent = iconContent(params.iconHtml);
3520 } else if (params.icon === 'success') {
3521 newContent = successIconHtml(params);
3522 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3523 } else if (params.icon === 'error') {
3524 newContent = errorIconHtml;
3525 } else if (params.icon) {
3526 const defaultIconHtml = {
3527 question: '?',
3528 warning: '!',
3529 info: 'i'
3530 };
3531 newContent = iconContent(defaultIconHtml[params.icon]);
3532 }
3533 if (oldContent.trim() !== newContent.trim()) {
3534 setInnerHtml(icon, newContent);
3535 }
3536 };
3537
3538 /**
3539 * @param {HTMLElement} icon
3540 * @param {SweetAlertOptions} params
3541 */
3542 const setColor = (icon, params) => {
3543 if (!params.iconColor) {
3544 return;
3545 }
3546 icon.style.color = params.iconColor;
3547 icon.style.borderColor = params.iconColor;
3548 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3549 setStyle(icon, sel, 'background-color', params.iconColor);
3550 }
3551 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3552 };
3553
3554 /**
3555 * @param {string} content
3556 * @returns {string}
3557 */
3558 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3559
3560 /**
3561 * @param {SweetAlert} instance
3562 * @param {SweetAlertOptions} params
3563 */
3564 const renderImage = (instance, params) => {
3565 const image = getImage();
3566 if (!image) {
3567 return;
3568 }
3569 if (!params.imageUrl) {
3570 hide(image);
3571 return;
3572 }
3573 show(image, '');
3574
3575 // Src, alt
3576 image.setAttribute('src', params.imageUrl);
3577 image.setAttribute('alt', params.imageAlt || '');
3578
3579 // Width, height
3580 applyNumericalStyle(image, 'width', params.imageWidth);
3581 applyNumericalStyle(image, 'height', params.imageHeight);
3582
3583 // Class
3584 image.className = swalClasses.image;
3585 applyCustomClass(image, params, 'image');
3586 };
3587
3588 let dragging = false;
3589 let mousedownX = 0;
3590 let mousedownY = 0;
3591 let initialX = 0;
3592 let initialY = 0;
3593
3594 /**
3595 * @param {HTMLElement} popup
3596 */
3597 const addDraggableListeners = popup => {
3598 popup.addEventListener('mousedown', down);
3599 document.body.addEventListener('mousemove', move);
3600 popup.addEventListener('mouseup', up);
3601 popup.addEventListener('touchstart', down);
3602 document.body.addEventListener('touchmove', move);
3603 popup.addEventListener('touchend', up);
3604 };
3605
3606 /**
3607 * @param {HTMLElement} popup
3608 */
3609 const removeDraggableListeners = popup => {
3610 popup.removeEventListener('mousedown', down);
3611 document.body.removeEventListener('mousemove', move);
3612 popup.removeEventListener('mouseup', up);
3613 popup.removeEventListener('touchstart', down);
3614 document.body.removeEventListener('touchmove', move);
3615 popup.removeEventListener('touchend', up);
3616 };
3617
3618 /**
3619 * @param {MouseEvent | TouchEvent} event
3620 */
3621 const down = event => {
3622 const popup = getPopup();
3623 if (!popup) {
3624 return;
3625 }
3626 const icon = getIcon();
3627 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3628 dragging = true;
3629 const clientXY = getClientXY(event);
3630 mousedownX = clientXY.clientX;
3631 mousedownY = clientXY.clientY;
3632 initialX = parseInt(popup.style.insetInlineStart) || 0;
3633 initialY = parseInt(popup.style.insetBlockStart) || 0;
3634 addClass(popup, 'swal2-dragging');
3635 }
3636 };
3637
3638 /**
3639 * @param {MouseEvent | TouchEvent} event
3640 */
3641 const move = event => {
3642 const popup = getPopup();
3643 if (!popup) {
3644 return;
3645 }
3646 if (dragging) {
3647 let {
3648 clientX,
3649 clientY
3650 } = getClientXY(event);
3651 const deltaX = clientX - mousedownX;
3652 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3653 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3654 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3655 }
3656 };
3657 const up = () => {
3658 const popup = getPopup();
3659 dragging = false;
3660 removeClass(popup, 'swal2-dragging');
3661 };
3662
3663 /**
3664 * @param {MouseEvent | TouchEvent} event
3665 * @returns {{ clientX: number, clientY: number }}
3666 */
3667 const getClientXY = event => {
3668 let clientX = 0,
3669 clientY = 0;
3670 if (event.type.startsWith('mouse')) {
3671 clientX = /** @type {MouseEvent} */event.clientX;
3672 clientY = /** @type {MouseEvent} */event.clientY;
3673 } else if (event.type.startsWith('touch')) {
3674 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
3675 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
3676 }
3677 return {
3678 clientX,
3679 clientY
3680 };
3681 };
3682
3683 /**
3684 * @param {SweetAlert} instance
3685 * @param {SweetAlertOptions} params
3686 */
3687 const renderPopup = (instance, params) => {
3688 const container = getContainer();
3689 const popup = getPopup();
3690 if (!container || !popup) {
3691 return;
3692 }
3693
3694 // Width
3695 // https://github.com/sweetalert2/sweetalert2/issues/2170
3696 if (params.toast) {
3697 applyNumericalStyle(container, 'width', params.width);
3698 popup.style.width = '100%';
3699 const loader = getLoader();
3700 if (loader) {
3701 popup.insertBefore(loader, getIcon());
3702 }
3703 } else {
3704 applyNumericalStyle(popup, 'width', params.width);
3705 }
3706
3707 // Padding
3708 applyNumericalStyle(popup, 'padding', params.padding);
3709
3710 // Color
3711 if (params.color) {
3712 popup.style.color = params.color;
3713 }
3714
3715 // Background
3716 if (params.background) {
3717 popup.style.background = params.background;
3718 }
3719 hide(getValidationMessage());
3720
3721 // Classes
3722 addClasses$1(popup, params);
3723 if (params.draggable && !params.toast) {
3724 addClass(popup, swalClasses.draggable);
3725 addDraggableListeners(popup);
3726 } else {
3727 removeClass(popup, swalClasses.draggable);
3728 removeDraggableListeners(popup);
3729 }
3730 };
3731
3732 /**
3733 * @param {HTMLElement} popup
3734 * @param {SweetAlertOptions} params
3735 */
3736 const addClasses$1 = (popup, params) => {
3737 const showClass = params.showClass || {};
3738 // Default Class + showClass when updating Swal.update({})
3739 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3740 if (params.toast) {
3741 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3742 addClass(popup, swalClasses.toast);
3743 } else {
3744 addClass(popup, swalClasses.modal);
3745 }
3746
3747 // Custom class
3748 applyCustomClass(popup, params, 'popup');
3749 // TODO: remove in the next major
3750 if (typeof params.customClass === 'string') {
3751 addClass(popup, params.customClass);
3752 }
3753
3754 // Icon class (#1842)
3755 if (params.icon) {
3756 addClass(popup, swalClasses[`icon-${params.icon}`]);
3757 }
3758 };
3759
3760 /**
3761 * @param {SweetAlert} instance
3762 * @param {SweetAlertOptions} params
3763 */
3764 const renderProgressSteps = (instance, params) => {
3765 const progressStepsContainer = getProgressSteps();
3766 if (!progressStepsContainer) {
3767 return;
3768 }
3769 const {
3770 progressSteps,
3771 currentProgressStep
3772 } = params;
3773 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3774 hide(progressStepsContainer);
3775 return;
3776 }
3777 show(progressStepsContainer);
3778 progressStepsContainer.textContent = '';
3779 if (currentProgressStep >= progressSteps.length) {
3780 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3781 }
3782 progressSteps.forEach((step, index) => {
3783 const stepEl = createStepElement(step);
3784 progressStepsContainer.appendChild(stepEl);
3785 if (index === currentProgressStep) {
3786 addClass(stepEl, swalClasses['active-progress-step']);
3787 }
3788 if (index !== progressSteps.length - 1) {
3789 const lineEl = createLineElement(params);
3790 progressStepsContainer.appendChild(lineEl);
3791 }
3792 });
3793 };
3794
3795 /**
3796 * @param {string} step
3797 * @returns {HTMLLIElement}
3798 */
3799 const createStepElement = step => {
3800 const stepEl = document.createElement('li');
3801 addClass(stepEl, swalClasses['progress-step']);
3802 setInnerHtml(stepEl, step);
3803 return stepEl;
3804 };
3805
3806 /**
3807 * @param {SweetAlertOptions} params
3808 * @returns {HTMLLIElement}
3809 */
3810 const createLineElement = params => {
3811 const lineEl = document.createElement('li');
3812 addClass(lineEl, swalClasses['progress-step-line']);
3813 if (params.progressStepsDistance) {
3814 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3815 }
3816 return lineEl;
3817 };
3818
3819 /**
3820 * @param {SweetAlert} instance
3821 * @param {SweetAlertOptions} params
3822 */
3823 const renderTitle = (instance, params) => {
3824 const title = getTitle();
3825 if (!title) {
3826 return;
3827 }
3828 showWhenInnerHtmlPresent(title);
3829 toggle(title, Boolean(params.title || params.titleText), 'block');
3830 if (params.title) {
3831 parseHtmlToContainer(params.title, title);
3832 }
3833 if (params.titleText) {
3834 title.innerText = params.titleText;
3835 }
3836
3837 // Custom class
3838 applyCustomClass(title, params, 'title');
3839 };
3840
3841 /**
3842 * @param {SweetAlert} instance
3843 * @param {SweetAlertOptions} params
3844 */
3845 const render = (instance, params) => {
3846 var _globalState$eventEmi;
3847 renderPopup(instance, params);
3848 renderContainer(instance, params);
3849 renderProgressSteps(instance, params);
3850 renderIcon(instance, params);
3851 renderImage(instance, params);
3852 renderTitle(instance, params);
3853 renderCloseButton(instance, params);
3854 renderContent(instance, params);
3855 renderActions(instance, params);
3856 renderFooter(instance, params);
3857 const popup = getPopup();
3858 if (typeof params.didRender === 'function' && popup) {
3859 params.didRender(popup);
3860 }
3861 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3862 };
3863
3864 /*
3865 * Global function to determine if SweetAlert2 popup is shown
3866 */
3867 const isVisible = () => {
3868 return isVisible$1(getPopup());
3869 };
3870
3871 /*
3872 * Global function to click 'Confirm' button
3873 */
3874 const clickConfirm = () => {
3875 var _dom$getConfirmButton;
3876 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
3877 };
3878
3879 /*
3880 * Global function to click 'Deny' button
3881 */
3882 const clickDeny = () => {
3883 var _dom$getDenyButton;
3884 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
3885 };
3886
3887 /*
3888 * Global function to click 'Cancel' button
3889 */
3890 const clickCancel = () => {
3891 var _dom$getCancelButton;
3892 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
3893 };
3894
3895 /** @type {Record<DismissReason, DismissReason>} */
3896 const DismissReason = Object.freeze({
3897 cancel: 'cancel',
3898 backdrop: 'backdrop',
3899 close: 'close',
3900 esc: 'esc',
3901 timer: 'timer'
3902 });
3903
3904 /**
3905 * @param {GlobalState} globalState
3906 */
3907 const removeKeydownHandler = globalState => {
3908 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
3909 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
3910 globalState.keydownTarget.removeEventListener('keydown', handler, {
3911 capture: globalState.keydownListenerCapture
3912 });
3913 globalState.keydownHandlerAdded = false;
3914 }
3915 };
3916
3917 /**
3918 * @param {GlobalState} globalState
3919 * @param {SweetAlertOptions} innerParams
3920 * @param {(dismiss: DismissReason) => void} dismissWith
3921 */
3922 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
3923 removeKeydownHandler(globalState);
3924 if (!innerParams.toast) {
3925 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
3926 const handler = e => keydownHandler(innerParams, e, dismissWith);
3927 globalState.keydownHandler = handler;
3928 const target = innerParams.keydownListenerCapture ? window : getPopup();
3929 if (target) {
3930 globalState.keydownTarget = target;
3931 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
3932 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
3933 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
3934 capture: globalState.keydownListenerCapture
3935 });
3936 globalState.keydownHandlerAdded = true;
3937 }
3938 }
3939 };
3940
3941 /**
3942 * @param {number} index
3943 * @param {number} increment
3944 */
3945 const setFocus = (index, increment) => {
3946 var _dom$getPopup;
3947 const focusableElements = getFocusableElements();
3948 // search for visible elements and select the next possible match
3949 if (focusableElements.length) {
3950 index = index + increment;
3951
3952 // shift + tab when .swal2-popup is focused
3953 if (index === -2) {
3954 index = focusableElements.length - 1;
3955 }
3956
3957 // rollover to first item
3958 if (index === focusableElements.length) {
3959 index = 0;
3960
3961 // go to last item
3962 } else if (index === -1) {
3963 index = focusableElements.length - 1;
3964 }
3965 focusableElements[index].focus();
3966 return;
3967 }
3968 // no visible focusable elements, focus the popup
3969 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
3970 };
3971 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
3972 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
3973
3974 /**
3975 * @param {SweetAlertOptions} innerParams
3976 * @param {KeyboardEvent} event
3977 * @param {(dismiss: DismissReason) => void} dismissWith
3978 */
3979 const keydownHandler = (innerParams, event, dismissWith) => {
3980 if (!innerParams) {
3981 return; // This instance has already been destroyed
3982 }
3983
3984 // Ignore keydown during IME composition
3985 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
3986 // https://github.com/sweetalert2/sweetalert2/issues/720
3987 // https://github.com/sweetalert2/sweetalert2/issues/2406
3988 if (event.isComposing || event.keyCode === 229) {
3989 return;
3990 }
3991 if (innerParams.stopKeydownPropagation) {
3992 event.stopPropagation();
3993 }
3994
3995 // ENTER
3996 if (event.key === 'Enter') {
3997 handleEnter(event, innerParams);
3998 }
3999
4000 // TAB
4001 else if (event.key === 'Tab') {
4002 handleTab(event);
4003 }
4004
4005 // ARROWS - switch focus between buttons
4006 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4007 handleArrows(event.key);
4008 }
4009
4010 // ESC
4011 else if (event.key === 'Escape') {
4012 handleEsc(event, innerParams, dismissWith);
4013 }
4014 };
4015
4016 /**
4017 * @param {KeyboardEvent} event
4018 * @param {SweetAlertOptions} innerParams
4019 */
4020 const handleEnter = (event, innerParams) => {
4021 // https://github.com/sweetalert2/sweetalert2/issues/2386
4022 if (!callIfFunction(innerParams.allowEnterKey)) {
4023 return;
4024 }
4025 const popup = getPopup();
4026 if (!popup || !innerParams.input) {
4027 return;
4028 }
4029 const input = getInput$1(popup, innerParams.input);
4030 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4031 if (['textarea', 'file'].includes(innerParams.input)) {
4032 return; // do not submit
4033 }
4034 clickConfirm();
4035 event.preventDefault();
4036 }
4037 };
4038
4039 /**
4040 * @param {KeyboardEvent} event
4041 */
4042 const handleTab = event => {
4043 const targetElement = event.target;
4044 const focusableElements = getFocusableElements();
4045 let btnIndex = -1;
4046 for (let i = 0; i < focusableElements.length; i++) {
4047 if (targetElement === focusableElements[i]) {
4048 btnIndex = i;
4049 break;
4050 }
4051 }
4052
4053 // Cycle to the next button
4054 if (!event.shiftKey) {
4055 setFocus(btnIndex, 1);
4056 }
4057
4058 // Cycle to the prev button
4059 else {
4060 setFocus(btnIndex, -1);
4061 }
4062 event.stopPropagation();
4063 event.preventDefault();
4064 };
4065
4066 /**
4067 * @param {string} key
4068 */
4069 const handleArrows = key => {
4070 const actions = getActions();
4071 const confirmButton = getConfirmButton();
4072 const denyButton = getDenyButton();
4073 const cancelButton = getCancelButton();
4074 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4075 return;
4076 }
4077 /** @type HTMLElement[] */
4078 const buttons = [confirmButton, denyButton, cancelButton];
4079 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4080 return;
4081 }
4082 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4083 let buttonToFocus = document.activeElement;
4084 if (!buttonToFocus) {
4085 return;
4086 }
4087 for (let i = 0; i < actions.children.length; i++) {
4088 buttonToFocus = buttonToFocus[sibling];
4089 if (!buttonToFocus) {
4090 return;
4091 }
4092 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4093 break;
4094 }
4095 }
4096 if (buttonToFocus instanceof HTMLButtonElement) {
4097 buttonToFocus.focus();
4098 }
4099 };
4100
4101 /**
4102 * @param {KeyboardEvent} event
4103 * @param {SweetAlertOptions} innerParams
4104 * @param {(dismiss: DismissReason) => void} dismissWith
4105 */
4106 const handleEsc = (event, innerParams, dismissWith) => {
4107 event.preventDefault();
4108 if (callIfFunction(innerParams.allowEscapeKey)) {
4109 dismissWith(DismissReason.esc);
4110 }
4111 };
4112
4113 /**
4114 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4115 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4116 * This is the approach that Babel will probably take to implement private methods/fields
4117 * https://github.com/tc39/proposal-private-methods
4118 * https://github.com/babel/babel/pull/7555
4119 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4120 * then we can use that language feature.
4121 */
4122
4123 var privateMethods = {
4124 swalPromiseResolve: new WeakMap(),
4125 swalPromiseReject: new WeakMap()
4126 };
4127
4128 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4129 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4130 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4131 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4132
4133 const setAriaHidden = () => {
4134 const container = getContainer();
4135 const bodyChildren = Array.from(document.body.children);
4136 bodyChildren.forEach(el => {
4137 if (el.contains(container)) {
4138 return;
4139 }
4140 if (el.hasAttribute('aria-hidden')) {
4141 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4142 }
4143 el.setAttribute('aria-hidden', 'true');
4144 });
4145 };
4146 const unsetAriaHidden = () => {
4147 const bodyChildren = Array.from(document.body.children);
4148 bodyChildren.forEach(el => {
4149 if (el.hasAttribute('data-previous-aria-hidden')) {
4150 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4151 el.removeAttribute('data-previous-aria-hidden');
4152 } else {
4153 el.removeAttribute('aria-hidden');
4154 }
4155 });
4156 };
4157
4158 // @ts-ignore
4159 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4160
4161 /**
4162 * Fix iOS scrolling
4163 * http://stackoverflow.com/q/39626302
4164 */
4165 const iOSfix = () => {
4166 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4167 const offset = document.body.scrollTop;
4168 document.body.style.top = `${offset * -1}px`;
4169 addClass(document.body, swalClasses.iosfix);
4170 lockBodyScroll();
4171 }
4172 };
4173
4174 /**
4175 * https://github.com/sweetalert2/sweetalert2/issues/1246
4176 */
4177 const lockBodyScroll = () => {
4178 const container = getContainer();
4179 if (!container) {
4180 return;
4181 }
4182 /** @type {boolean} */
4183 let preventTouchMove;
4184 /**
4185 * @param {TouchEvent} event
4186 */
4187 container.ontouchstart = event => {
4188 preventTouchMove = shouldPreventTouchMove(event);
4189 };
4190 /**
4191 * @param {TouchEvent} event
4192 */
4193 container.ontouchmove = event => {
4194 if (preventTouchMove) {
4195 event.preventDefault();
4196 event.stopPropagation();
4197 }
4198 };
4199 };
4200
4201 /**
4202 * @param {TouchEvent} event
4203 * @returns {boolean}
4204 */
4205 const shouldPreventTouchMove = event => {
4206 const target = event.target;
4207 const container = getContainer();
4208 const htmlContainer = getHtmlContainer();
4209 if (!container || !htmlContainer) {
4210 return false;
4211 }
4212 if (isStylus(event) || isZoom(event)) {
4213 return false;
4214 }
4215 if (target === container) {
4216 return true;
4217 }
4218 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4219 // #2823
4220 target.tagName !== 'INPUT' &&
4221 // #1603
4222 target.tagName !== 'TEXTAREA' &&
4223 // #2266
4224 !(isScrollable(htmlContainer) &&
4225 // #1944
4226 htmlContainer.contains(target))) {
4227 return true;
4228 }
4229 return false;
4230 };
4231
4232 /**
4233 * https://github.com/sweetalert2/sweetalert2/issues/1786
4234 *
4235 * @param {TouchEvent} event
4236 * @returns {boolean}
4237 */
4238 const isStylus = event => {
4239 return Boolean(event.touches && event.touches.length &&
4240 // @ts-ignore - touchType is not a standard property
4241 event.touches[0].touchType === 'stylus');
4242 };
4243
4244 /**
4245 * https://github.com/sweetalert2/sweetalert2/issues/1891
4246 *
4247 * @param {TouchEvent} event
4248 * @returns {boolean}
4249 */
4250 const isZoom = event => {
4251 return event.touches && event.touches.length > 1;
4252 };
4253 const undoIOSfix = () => {
4254 if (hasClass(document.body, swalClasses.iosfix)) {
4255 const offset = parseInt(document.body.style.top, 10);
4256 removeClass(document.body, swalClasses.iosfix);
4257 document.body.style.top = '';
4258 document.body.scrollTop = offset * -1;
4259 }
4260 };
4261
4262 /**
4263 * Measure scrollbar width for padding body during modal show/hide
4264 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4265 *
4266 * @returns {number}
4267 */
4268 const measureScrollbar = () => {
4269 const scrollDiv = document.createElement('div');
4270 scrollDiv.className = swalClasses['scrollbar-measure'];
4271 document.body.appendChild(scrollDiv);
4272 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4273 document.body.removeChild(scrollDiv);
4274 return scrollbarWidth;
4275 };
4276
4277 /**
4278 * Remember state in cases where opening and handling a modal will fiddle with it.
4279 * @type {number | null}
4280 */
4281 let previousBodyPadding = null;
4282
4283 /**
4284 * @param {string} initialBodyOverflow
4285 */
4286 const replaceScrollbarWithPadding = initialBodyOverflow => {
4287 // for queues, do not do this more than once
4288 if (previousBodyPadding !== null) {
4289 return;
4290 }
4291 // if the body has overflow
4292 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4293 ) {
4294 // add padding so the content doesn't shift after removal of scrollbar
4295 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4296 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4297 }
4298 };
4299 const undoReplaceScrollbarWithPadding = () => {
4300 if (previousBodyPadding !== null) {
4301 document.body.style.paddingRight = `${previousBodyPadding}px`;
4302 previousBodyPadding = null;
4303 }
4304 };
4305
4306 /**
4307 * @param {SweetAlert} instance
4308 * @param {HTMLElement} container
4309 * @param {boolean} returnFocus
4310 * @param {(() => void) | undefined} didClose
4311 */
4312 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4313 if (isToast()) {
4314 triggerDidCloseAndDispose(instance, didClose);
4315 } else {
4316 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4317 removeKeydownHandler(globalState);
4318 }
4319
4320 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4321 // for some reason removing the container in Safari will scroll the document to bottom
4322 if (isSafariOrIOS) {
4323 container.setAttribute('style', 'display:none !important');
4324 container.removeAttribute('class');
4325 container.innerHTML = '';
4326 } else {
4327 container.remove();
4328 }
4329 if (isModal()) {
4330 undoReplaceScrollbarWithPadding();
4331 undoIOSfix();
4332 unsetAriaHidden();
4333 }
4334 removeBodyClasses();
4335 }
4336
4337 /**
4338 * Remove SweetAlert2 classes from body
4339 */
4340 function removeBodyClasses() {
4341 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4342 }
4343
4344 /**
4345 * Instance method to close sweetAlert
4346 *
4347 * @param {SweetAlertResult | undefined} resolveValue
4348 * @this {SweetAlert}
4349 */
4350 function close(resolveValue) {
4351 resolveValue = prepareResolveValue(resolveValue);
4352 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4353 const didClose = triggerClosePopup(this);
4354 if (this.isAwaitingPromise) {
4355 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4356 if (!resolveValue.isDismissed) {
4357 handleAwaitingPromise(this);
4358 swalPromiseResolve(resolveValue);
4359 }
4360 } else if (didClose) {
4361 // Resolve Swal promise
4362 swalPromiseResolve(resolveValue);
4363 }
4364 }
4365
4366 /**
4367 * @param {SweetAlert} instance
4368 * @returns {boolean}
4369 */
4370 const triggerClosePopup = instance => {
4371 const popup = getPopup();
4372 if (!popup) {
4373 return false;
4374 }
4375 const innerParams = privateProps.innerParams.get(instance);
4376 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4377 return false;
4378 }
4379 removeClass(popup, innerParams.showClass.popup);
4380 addClass(popup, innerParams.hideClass.popup);
4381 const backdrop = getContainer();
4382 removeClass(backdrop, innerParams.showClass.backdrop);
4383 addClass(backdrop, innerParams.hideClass.backdrop);
4384 handlePopupAnimation(instance, popup, innerParams);
4385 return true;
4386 };
4387
4388 /**
4389 * @param {Error | string} error
4390 * @this {SweetAlert}
4391 */
4392 function rejectPromise(error) {
4393 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4394 handleAwaitingPromise(this);
4395 if (rejectPromise) {
4396 // Reject Swal promise
4397 rejectPromise(error);
4398 }
4399 }
4400
4401 /**
4402 * @param {SweetAlert} instance
4403 */
4404 const handleAwaitingPromise = instance => {
4405 if (instance.isAwaitingPromise) {
4406 // @ts-ignore
4407 delete instance.isAwaitingPromise;
4408 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4409 if (!privateProps.innerParams.get(instance)) {
4410 instance._destroy();
4411 }
4412 }
4413 };
4414
4415 /**
4416 * @param {SweetAlertResult | undefined} resolveValue
4417 * @returns {SweetAlertResult}
4418 */
4419 const prepareResolveValue = resolveValue => {
4420 // When user calls Swal.close()
4421 if (typeof resolveValue === 'undefined') {
4422 return {
4423 isConfirmed: false,
4424 isDenied: false,
4425 isDismissed: true
4426 };
4427 }
4428 return Object.assign({
4429 isConfirmed: false,
4430 isDenied: false,
4431 isDismissed: false
4432 }, resolveValue);
4433 };
4434
4435 /**
4436 * @param {SweetAlert} instance
4437 * @param {HTMLElement} popup
4438 * @param {SweetAlertOptions} innerParams
4439 */
4440 const handlePopupAnimation = (instance, popup, innerParams) => {
4441 var _globalState$eventEmi;
4442 const container = getContainer();
4443 // If animation is supported, animate
4444 const animationIsSupported = hasCssAnimation(popup);
4445 if (typeof innerParams.willClose === 'function') {
4446 innerParams.willClose(popup);
4447 }
4448 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4449 if (animationIsSupported && container) {
4450 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4451 } else if (container) {
4452 // Otherwise, remove immediately
4453 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4454 }
4455 };
4456
4457 /**
4458 * @param {SweetAlert} instance
4459 * @param {HTMLElement} popup
4460 * @param {HTMLElement} container
4461 * @param {boolean} returnFocus
4462 * @param {(() => void) | undefined} didClose
4463 */
4464 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4465 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4466 /**
4467 * @param {AnimationEvent | TransitionEvent} e
4468 */
4469 const swalCloseAnimationFinished = function (e) {
4470 if (e.target === popup) {
4471 var _globalState$swalClos;
4472 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4473 delete globalState.swalCloseEventFinishedCallback;
4474 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4475 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4476 }
4477 };
4478 popup.addEventListener('animationend', swalCloseAnimationFinished);
4479 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4480 };
4481
4482 /**
4483 * @param {SweetAlert} instance
4484 * @param {(() => void) | undefined} didClose
4485 */
4486 const triggerDidCloseAndDispose = (instance, didClose) => {
4487 setTimeout(() => {
4488 var _globalState$eventEmi2;
4489 if (typeof didClose === 'function') {
4490 didClose.bind(instance.params)();
4491 }
4492 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4493 // instance might have been destroyed already
4494 if (instance._destroy) {
4495 instance._destroy();
4496 }
4497 });
4498 };
4499
4500 /**
4501 * Shows loader (spinner), this is useful with AJAX requests.
4502 * By default the loader be shown instead of the "Confirm" button.
4503 *
4504 * @param {HTMLButtonElement | null} [buttonToReplace]
4505 */
4506 const showLoading = buttonToReplace => {
4507 let popup = getPopup();
4508 if (!popup) {
4509 new Swal();
4510 }
4511 popup = getPopup();
4512 if (!popup) {
4513 return;
4514 }
4515 const loader = getLoader();
4516 if (isToast()) {
4517 hide(getIcon());
4518 } else {
4519 replaceButton(popup, buttonToReplace);
4520 }
4521 show(loader);
4522 popup.setAttribute('data-loading', 'true');
4523 popup.setAttribute('aria-busy', 'true');
4524 popup.focus();
4525 };
4526
4527 /**
4528 * @param {HTMLElement} popup
4529 * @param {HTMLButtonElement | null} [buttonToReplace]
4530 */
4531 const replaceButton = (popup, buttonToReplace) => {
4532 const actions = getActions();
4533 const loader = getLoader();
4534 if (!actions || !loader) {
4535 return;
4536 }
4537 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4538 buttonToReplace = getConfirmButton();
4539 }
4540 show(actions);
4541 if (buttonToReplace) {
4542 hide(buttonToReplace);
4543 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4544 actions.insertBefore(loader, buttonToReplace);
4545 }
4546 addClass([popup, actions], swalClasses.loading);
4547 };
4548
4549 /**
4550 * @param {SweetAlert} instance
4551 * @param {SweetAlertOptions} params
4552 */
4553 const handleInputOptionsAndValue = (instance, params) => {
4554 if (params.input === 'select' || params.input === 'radio') {
4555 handleInputOptions(instance, params);
4556 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4557 showLoading(getConfirmButton());
4558 handleInputValue(instance, params);
4559 }
4560 };
4561
4562 /**
4563 * @param {SweetAlert} instance
4564 * @param {SweetAlertOptions} innerParams
4565 * @returns {SweetAlertInputValue}
4566 */
4567 const getInputValue = (instance, innerParams) => {
4568 const input = instance.getInput();
4569 if (!input) {
4570 return null;
4571 }
4572 switch (innerParams.input) {
4573 case 'checkbox':
4574 return getCheckboxValue(input);
4575 case 'radio':
4576 return getRadioValue(input);
4577 case 'file':
4578 return getFileValue(input);
4579 default:
4580 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4581 }
4582 };
4583
4584 /**
4585 * @param {HTMLInputElement} input
4586 * @returns {number}
4587 */
4588 const getCheckboxValue = input => input.checked ? 1 : 0;
4589
4590 /**
4591 * @param {HTMLInputElement} input
4592 * @returns {string | null}
4593 */
4594 const getRadioValue = input => input.checked ? input.value : null;
4595
4596 /**
4597 * @param {HTMLInputElement} input
4598 * @returns {FileList | File | null}
4599 */
4600 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4601
4602 /**
4603 * @param {SweetAlert} instance
4604 * @param {SweetAlertOptions} params
4605 */
4606 const handleInputOptions = (instance, params) => {
4607 const popup = getPopup();
4608 if (!popup) {
4609 return;
4610 }
4611 /**
4612 * @param {*} inputOptions
4613 */
4614 const processInputOptions = inputOptions => {
4615 if (params.input === 'select') {
4616 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4617 } else if (params.input === 'radio') {
4618 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4619 }
4620 };
4621 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4622 showLoading(getConfirmButton());
4623 asPromise(params.inputOptions).then(inputOptions => {
4624 instance.hideLoading();
4625 processInputOptions(inputOptions);
4626 });
4627 } else if (typeof params.inputOptions === 'object') {
4628 processInputOptions(params.inputOptions);
4629 } else {
4630 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4631 }
4632 };
4633
4634 /**
4635 * @param {SweetAlert} instance
4636 * @param {SweetAlertOptions} params
4637 */
4638 const handleInputValue = (instance, params) => {
4639 const input = instance.getInput();
4640 if (!input) {
4641 return;
4642 }
4643 hide(input);
4644 asPromise(params.inputValue).then(inputValue => {
4645 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4646 show(input);
4647 input.focus();
4648 instance.hideLoading();
4649 }).catch(err => {
4650 error(`Error in inputValue promise: ${err}`);
4651 input.value = '';
4652 show(input);
4653 input.focus();
4654 instance.hideLoading();
4655 });
4656 };
4657
4658 /**
4659 * @param {HTMLElement} popup
4660 * @param {InputOptionFlattened[]} inputOptions
4661 * @param {SweetAlertOptions} params
4662 */
4663 function populateSelectOptions(popup, inputOptions, params) {
4664 const select = getDirectChildByClass(popup, swalClasses.select);
4665 if (!select) {
4666 return;
4667 }
4668 /**
4669 * @param {HTMLElement} parent
4670 * @param {string} optionLabel
4671 * @param {string} optionValue
4672 */
4673 const renderOption = (parent, optionLabel, optionValue) => {
4674 const option = document.createElement('option');
4675 option.value = optionValue;
4676 setInnerHtml(option, optionLabel);
4677 option.selected = isSelected(optionValue, params.inputValue);
4678 parent.appendChild(option);
4679 };
4680 inputOptions.forEach(inputOption => {
4681 const optionValue = inputOption[0];
4682 const optionLabel = inputOption[1];
4683 // <optgroup> spec:
4684 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4685 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4686 // check whether this is a <optgroup>
4687 if (Array.isArray(optionLabel)) {
4688 // if it is an array, then it is an <optgroup>
4689 const optgroup = document.createElement('optgroup');
4690 optgroup.label = optionValue;
4691 optgroup.disabled = false; // not configurable for now
4692 select.appendChild(optgroup);
4693 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4694 } else {
4695 // case of <option>
4696 renderOption(select, optionLabel, optionValue);
4697 }
4698 });
4699 select.focus();
4700 }
4701
4702 /**
4703 * @param {HTMLElement} popup
4704 * @param {InputOptionFlattened[]} inputOptions
4705 * @param {SweetAlertOptions} params
4706 */
4707 function populateRadioOptions(popup, inputOptions, params) {
4708 const radio = getDirectChildByClass(popup, swalClasses.radio);
4709 if (!radio) {
4710 return;
4711 }
4712 inputOptions.forEach(inputOption => {
4713 const radioValue = inputOption[0];
4714 const radioLabel = inputOption[1];
4715 const radioInput = document.createElement('input');
4716 const radioLabelElement = document.createElement('label');
4717 radioInput.type = 'radio';
4718 radioInput.name = swalClasses.radio;
4719 radioInput.value = radioValue;
4720 if (isSelected(radioValue, params.inputValue)) {
4721 radioInput.checked = true;
4722 }
4723 const label = document.createElement('span');
4724 setInnerHtml(label, radioLabel);
4725 label.className = swalClasses.label;
4726 radioLabelElement.appendChild(radioInput);
4727 radioLabelElement.appendChild(label);
4728 radio.appendChild(radioLabelElement);
4729 });
4730 const radios = radio.querySelectorAll('input');
4731 if (radios.length) {
4732 radios[0].focus();
4733 }
4734 }
4735
4736 /**
4737 * Converts `inputOptions` into an array of `[value, label]`s
4738 *
4739 * @param {*} inputOptions
4740 * @typedef {string[]} InputOptionFlattened
4741 * @returns {InputOptionFlattened[]}
4742 */
4743 const formatInputOptions = inputOptions => {
4744 /** @type {InputOptionFlattened[]} */
4745 const result = [];
4746 if (inputOptions instanceof Map) {
4747 inputOptions.forEach((value, key) => {
4748 let valueFormatted = value;
4749 if (typeof valueFormatted === 'object') {
4750 // case of <optgroup>
4751 valueFormatted = formatInputOptions(valueFormatted);
4752 }
4753 result.push([key, valueFormatted]);
4754 });
4755 } else {
4756 Object.keys(inputOptions).forEach(key => {
4757 let valueFormatted = inputOptions[key];
4758 if (typeof valueFormatted === 'object') {
4759 // case of <optgroup>
4760 valueFormatted = formatInputOptions(valueFormatted);
4761 }
4762 result.push([key, valueFormatted]);
4763 });
4764 }
4765 return result;
4766 };
4767
4768 /**
4769 * @param {string} optionValue
4770 * @param {SweetAlertInputValue} inputValue
4771 * @returns {boolean}
4772 */
4773 const isSelected = (optionValue, inputValue) => {
4774 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
4775 };
4776
4777 /**
4778 * @param {SweetAlert} instance
4779 */
4780 const handleConfirmButtonClick = instance => {
4781 const innerParams = privateProps.innerParams.get(instance);
4782 instance.disableButtons();
4783 if (innerParams.input) {
4784 handleConfirmOrDenyWithInput(instance, 'confirm');
4785 } else {
4786 confirm(instance, true);
4787 }
4788 };
4789
4790 /**
4791 * @param {SweetAlert} instance
4792 */
4793 const handleDenyButtonClick = instance => {
4794 const innerParams = privateProps.innerParams.get(instance);
4795 instance.disableButtons();
4796 if (innerParams.returnInputValueOnDeny) {
4797 handleConfirmOrDenyWithInput(instance, 'deny');
4798 } else {
4799 deny(instance, false);
4800 }
4801 };
4802
4803 /**
4804 * @param {SweetAlert} instance
4805 * @param {(dismiss: DismissReason) => void} dismissWith
4806 */
4807 const handleCancelButtonClick = (instance, dismissWith) => {
4808 instance.disableButtons();
4809 dismissWith(DismissReason.cancel);
4810 };
4811
4812 /**
4813 * @param {SweetAlert} instance
4814 * @param {'confirm' | 'deny'} type
4815 */
4816 const handleConfirmOrDenyWithInput = (instance, type) => {
4817 const innerParams = privateProps.innerParams.get(instance);
4818 if (!innerParams.input) {
4819 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4820 return;
4821 }
4822 const input = instance.getInput();
4823 const inputValue = getInputValue(instance, innerParams);
4824 if (innerParams.inputValidator) {
4825 handleInputValidator(instance, inputValue, type);
4826 } else if (input && !input.checkValidity()) {
4827 instance.enableButtons();
4828 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4829 } else if (type === 'deny') {
4830 deny(instance, inputValue);
4831 } else {
4832 confirm(instance, inputValue);
4833 }
4834 };
4835
4836 /**
4837 * @param {SweetAlert} instance
4838 * @param {SweetAlertInputValue} inputValue
4839 * @param {'confirm' | 'deny'} type
4840 */
4841 const handleInputValidator = (instance, inputValue, type) => {
4842 const innerParams = privateProps.innerParams.get(instance);
4843 instance.disableInput();
4844 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4845 validationPromise.then(validationMessage => {
4846 instance.enableButtons();
4847 instance.enableInput();
4848 if (validationMessage) {
4849 instance.showValidationMessage(validationMessage);
4850 } else if (type === 'deny') {
4851 deny(instance, inputValue);
4852 } else {
4853 confirm(instance, inputValue);
4854 }
4855 });
4856 };
4857
4858 /**
4859 * @param {SweetAlert} instance
4860 * @param {*} value
4861 */
4862 const deny = (instance, value) => {
4863 const innerParams = privateProps.innerParams.get(instance);
4864 if (innerParams.showLoaderOnDeny) {
4865 showLoading(getDenyButton());
4866 }
4867 if (innerParams.preDeny) {
4868 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
4869 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
4870 preDenyPromise.then(preDenyValue => {
4871 if (preDenyValue === false) {
4872 instance.hideLoading();
4873 handleAwaitingPromise(instance);
4874 } else {
4875 instance.close(/** @type SweetAlertResult */{
4876 isDenied: true,
4877 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
4878 });
4879 }
4880 }).catch(error => rejectWith(instance, error));
4881 } else {
4882 instance.close(/** @type SweetAlertResult */{
4883 isDenied: true,
4884 value
4885 });
4886 }
4887 };
4888
4889 /**
4890 * @param {SweetAlert} instance
4891 * @param {*} value
4892 */
4893 const succeedWith = (instance, value) => {
4894 instance.close(/** @type SweetAlertResult */{
4895 isConfirmed: true,
4896 value
4897 });
4898 };
4899
4900 /**
4901 *
4902 * @param {SweetAlert} instance
4903 * @param {string} error
4904 */
4905 const rejectWith = (instance, error) => {
4906 instance.rejectPromise(error);
4907 };
4908
4909 /**
4910 *
4911 * @param {SweetAlert} instance
4912 * @param {*} value
4913 */
4914 const confirm = (instance, value) => {
4915 const innerParams = privateProps.innerParams.get(instance);
4916 if (innerParams.showLoaderOnConfirm) {
4917 showLoading();
4918 }
4919 if (innerParams.preConfirm) {
4920 instance.resetValidationMessage();
4921 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
4922 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
4923 preConfirmPromise.then(preConfirmValue => {
4924 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
4925 instance.hideLoading();
4926 handleAwaitingPromise(instance);
4927 } else {
4928 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
4929 }
4930 }).catch(error => rejectWith(instance, error));
4931 } else {
4932 succeedWith(instance, value);
4933 }
4934 };
4935
4936 /**
4937 * Hides loader and shows back the button which was hidden by .showLoading()
4938 * @this {SweetAlert}
4939 */
4940 function hideLoading() {
4941 // do nothing if popup is closed
4942 const innerParams = privateProps.innerParams.get(this);
4943 if (!innerParams) {
4944 return;
4945 }
4946 const domCache = privateProps.domCache.get(this);
4947 hide(domCache.loader);
4948 if (isToast()) {
4949 if (innerParams.icon) {
4950 show(getIcon());
4951 }
4952 } else {
4953 showRelatedButton(domCache);
4954 }
4955 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
4956 domCache.popup.removeAttribute('aria-busy');
4957 domCache.popup.removeAttribute('data-loading');
4958 domCache.confirmButton.disabled = false;
4959 domCache.denyButton.disabled = false;
4960 domCache.cancelButton.disabled = false;
4961 }
4962
4963 /**
4964 * @param {DomCache} domCache
4965 */
4966 const showRelatedButton = domCache => {
4967 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
4968 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
4969 if (buttonToReplace.length) {
4970 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
4971 } else if (allButtonsAreHidden()) {
4972 hide(domCache.actions);
4973 }
4974 };
4975
4976 /**
4977 * Gets the input DOM node, this method works with input parameter.
4978 *
4979 * @returns {HTMLInputElement | null}
4980 * @this {SweetAlert}
4981 */
4982 function getInput() {
4983 const innerParams = privateProps.innerParams.get(this);
4984 const domCache = privateProps.domCache.get(this);
4985 if (!domCache) {
4986 return null;
4987 }
4988 return getInput$1(domCache.popup, innerParams.input);
4989 }
4990
4991 /**
4992 * @param {SweetAlert} instance
4993 * @param {string[]} buttons
4994 * @param {boolean} disabled
4995 */
4996 function setButtonsDisabled(instance, buttons, disabled) {
4997 const domCache = privateProps.domCache.get(instance);
4998 buttons.forEach(button => {
4999 domCache[button].disabled = disabled;
5000 });
5001 }
5002
5003 /**
5004 * @param {HTMLInputElement | null} input
5005 * @param {boolean} disabled
5006 */
5007 function setInputDisabled(input, disabled) {
5008 const popup = getPopup();
5009 if (!popup || !input) {
5010 return;
5011 }
5012 if (input.type === 'radio') {
5013 /** @type {NodeListOf<HTMLInputElement>} */
5014 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5015 for (let i = 0; i < radios.length; i++) {
5016 radios[i].disabled = disabled;
5017 }
5018 } else {
5019 input.disabled = disabled;
5020 }
5021 }
5022
5023 /**
5024 * Enable all the buttons
5025 * @this {SweetAlert}
5026 */
5027 function enableButtons() {
5028 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5029 }
5030
5031 /**
5032 * Disable all the buttons
5033 * @this {SweetAlert}
5034 */
5035 function disableButtons() {
5036 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5037 }
5038
5039 /**
5040 * Enable the input field
5041 * @this {SweetAlert}
5042 */
5043 function enableInput() {
5044 setInputDisabled(this.getInput(), false);
5045 }
5046
5047 /**
5048 * Disable the input field
5049 * @this {SweetAlert}
5050 */
5051 function disableInput() {
5052 setInputDisabled(this.getInput(), true);
5053 }
5054
5055 /**
5056 * Show block with validation message
5057 *
5058 * @param {string} error
5059 * @this {SweetAlert}
5060 */
5061 function showValidationMessage(error) {
5062 const domCache = privateProps.domCache.get(this);
5063 const params = privateProps.innerParams.get(this);
5064 setInnerHtml(domCache.validationMessage, error);
5065 domCache.validationMessage.className = swalClasses['validation-message'];
5066 if (params.customClass && params.customClass.validationMessage) {
5067 addClass(domCache.validationMessage, params.customClass.validationMessage);
5068 }
5069 show(domCache.validationMessage);
5070 const input = this.getInput();
5071 if (input) {
5072 input.setAttribute('aria-invalid', 'true');
5073 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5074 focusInput(input);
5075 addClass(input, swalClasses.inputerror);
5076 }
5077 }
5078
5079 /**
5080 * Hide block with validation message
5081 *
5082 * @this {SweetAlert}
5083 */
5084 function resetValidationMessage() {
5085 const domCache = privateProps.domCache.get(this);
5086 if (domCache.validationMessage) {
5087 hide(domCache.validationMessage);
5088 }
5089 const input = this.getInput();
5090 if (input) {
5091 input.removeAttribute('aria-invalid');
5092 input.removeAttribute('aria-describedby');
5093 removeClass(input, swalClasses.inputerror);
5094 }
5095 }
5096
5097 const defaultParams = {
5098 title: '',
5099 titleText: '',
5100 text: '',
5101 html: '',
5102 footer: '',
5103 icon: undefined,
5104 iconColor: undefined,
5105 iconHtml: undefined,
5106 template: undefined,
5107 toast: false,
5108 draggable: false,
5109 animation: true,
5110 theme: 'light',
5111 showClass: {
5112 popup: 'swal2-show',
5113 backdrop: 'swal2-backdrop-show',
5114 icon: 'swal2-icon-show'
5115 },
5116 hideClass: {
5117 popup: 'swal2-hide',
5118 backdrop: 'swal2-backdrop-hide',
5119 icon: 'swal2-icon-hide'
5120 },
5121 customClass: {},
5122 target: 'body',
5123 color: undefined,
5124 backdrop: true,
5125 heightAuto: true,
5126 allowOutsideClick: true,
5127 allowEscapeKey: true,
5128 allowEnterKey: true,
5129 stopKeydownPropagation: true,
5130 keydownListenerCapture: false,
5131 showConfirmButton: true,
5132 showDenyButton: false,
5133 showCancelButton: false,
5134 preConfirm: undefined,
5135 preDeny: undefined,
5136 confirmButtonText: 'OK',
5137 confirmButtonAriaLabel: '',
5138 confirmButtonColor: undefined,
5139 denyButtonText: 'No',
5140 denyButtonAriaLabel: '',
5141 denyButtonColor: undefined,
5142 cancelButtonText: 'Cancel',
5143 cancelButtonAriaLabel: '',
5144 cancelButtonColor: undefined,
5145 buttonsStyling: true,
5146 reverseButtons: false,
5147 focusConfirm: true,
5148 focusDeny: false,
5149 focusCancel: false,
5150 returnFocus: true,
5151 showCloseButton: false,
5152 closeButtonHtml: '&times;',
5153 closeButtonAriaLabel: 'Close this dialog',
5154 loaderHtml: '',
5155 showLoaderOnConfirm: false,
5156 showLoaderOnDeny: false,
5157 imageUrl: undefined,
5158 imageWidth: undefined,
5159 imageHeight: undefined,
5160 imageAlt: '',
5161 timer: undefined,
5162 timerProgressBar: false,
5163 width: undefined,
5164 padding: undefined,
5165 background: undefined,
5166 input: undefined,
5167 inputPlaceholder: '',
5168 inputLabel: '',
5169 inputValue: '',
5170 inputOptions: {},
5171 inputAutoFocus: true,
5172 inputAutoTrim: true,
5173 inputAttributes: {},
5174 inputValidator: undefined,
5175 returnInputValueOnDeny: false,
5176 validationMessage: undefined,
5177 grow: false,
5178 position: 'center',
5179 progressSteps: [],
5180 currentProgressStep: undefined,
5181 progressStepsDistance: undefined,
5182 willOpen: undefined,
5183 didOpen: undefined,
5184 didRender: undefined,
5185 willClose: undefined,
5186 didClose: undefined,
5187 didDestroy: undefined,
5188 scrollbarPadding: true,
5189 topLayer: false
5190 };
5191 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'];
5192
5193 /** @type {Record<string, string | undefined>} */
5194 const deprecatedParams = {
5195 allowEnterKey: undefined
5196 };
5197 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5198
5199 /**
5200 * Is valid parameter
5201 *
5202 * @param {string} paramName
5203 * @returns {boolean}
5204 */
5205 const isValidParameter = paramName => {
5206 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5207 };
5208
5209 /**
5210 * Is valid parameter for Swal.update() method
5211 *
5212 * @param {string} paramName
5213 * @returns {boolean}
5214 */
5215 const isUpdatableParameter = paramName => {
5216 return updatableParams.indexOf(paramName) !== -1;
5217 };
5218
5219 /**
5220 * Is deprecated parameter
5221 *
5222 * @param {string} paramName
5223 * @returns {string | undefined}
5224 */
5225 const isDeprecatedParameter = paramName => {
5226 return deprecatedParams[paramName];
5227 };
5228
5229 /**
5230 * @param {string} param
5231 */
5232 const checkIfParamIsValid = param => {
5233 if (!isValidParameter(param)) {
5234 warn(`Unknown parameter "${param}"`);
5235 }
5236 };
5237
5238 /**
5239 * @param {string} param
5240 */
5241 const checkIfToastParamIsValid = param => {
5242 if (toastIncompatibleParams.includes(param)) {
5243 warn(`The parameter "${param}" is incompatible with toasts`);
5244 }
5245 };
5246
5247 /**
5248 * @param {string} param
5249 */
5250 const checkIfParamIsDeprecated = param => {
5251 const isDeprecated = isDeprecatedParameter(param);
5252 if (isDeprecated) {
5253 warnAboutDeprecation(param, isDeprecated);
5254 }
5255 };
5256
5257 /**
5258 * Show relevant warnings for given params
5259 *
5260 * @param {SweetAlertOptions} params
5261 */
5262 const showWarningsForParams = params => {
5263 if (params.backdrop === false && params.allowOutsideClick) {
5264 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5265 }
5266 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)) {
5267 warn(`Invalid theme "${params.theme}"`);
5268 }
5269 for (const param in params) {
5270 checkIfParamIsValid(param);
5271 if (params.toast) {
5272 checkIfToastParamIsValid(param);
5273 }
5274 checkIfParamIsDeprecated(param);
5275 }
5276 };
5277
5278 /**
5279 * Updates popup parameters.
5280 *
5281 * @this {any}
5282 * @param {SweetAlertOptions} params
5283 */
5284 function update(params) {
5285 const container = getContainer();
5286 const popup = getPopup();
5287 const innerParams = privateProps.innerParams.get(this);
5288 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5289 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.`);
5290 return;
5291 }
5292 const validUpdatableParams = filterValidParams(params);
5293 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5294 showWarningsForParams(updatedParams);
5295 if (container) {
5296 container.dataset['swal2Theme'] = updatedParams.theme;
5297 }
5298 render(this, updatedParams);
5299 privateProps.innerParams.set(this, updatedParams);
5300 Object.defineProperties(this, {
5301 params: {
5302 value: Object.assign({}, this.params, params),
5303 writable: false,
5304 enumerable: true
5305 }
5306 });
5307 }
5308
5309 /**
5310 * @param {SweetAlertOptions} params
5311 * @returns {SweetAlertOptions}
5312 */
5313 const filterValidParams = params => {
5314 /** @type {Record<string, any>} */
5315 const validUpdatableParams = {};
5316 Object.keys(params).forEach(param => {
5317 if (isUpdatableParameter(param)) {
5318 const typedParams = /** @type {Record<string, any>} */params;
5319 validUpdatableParams[param] = typedParams[param];
5320 } else {
5321 warn(`Invalid parameter to update: ${param}`);
5322 }
5323 });
5324 return validUpdatableParams;
5325 };
5326
5327 /**
5328 * Dispose the current SweetAlert2 instance
5329 * @this {SweetAlert}
5330 */
5331 function _destroy() {
5332 var _globalState$eventEmi;
5333 const domCache = privateProps.domCache.get(this);
5334 const innerParams = privateProps.innerParams.get(this);
5335 if (!innerParams) {
5336 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5337 return; // This instance has already been destroyed
5338 }
5339
5340 // Check if there is another Swal closing
5341 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5342 globalState.swalCloseEventFinishedCallback();
5343 delete globalState.swalCloseEventFinishedCallback;
5344 }
5345 if (typeof innerParams.didDestroy === 'function') {
5346 innerParams.didDestroy();
5347 }
5348 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5349 disposeSwal(this);
5350 }
5351
5352 /**
5353 * @param {SweetAlert} instance
5354 */
5355 const disposeSwal = instance => {
5356 disposeWeakMaps(instance);
5357 // Unset this.params so GC will dispose it (#1569)
5358 // @ts-ignore
5359 delete instance.params;
5360 // Unset globalState props so GC will dispose globalState (#1569)
5361 delete globalState.keydownHandler;
5362 delete globalState.keydownTarget;
5363 // Unset currentInstance
5364 delete globalState.currentInstance;
5365 };
5366
5367 /**
5368 * @param {SweetAlert} instance
5369 */
5370 const disposeWeakMaps = instance => {
5371 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5372 if (instance.isAwaitingPromise) {
5373 unsetWeakMaps(privateProps, instance);
5374 instance.isAwaitingPromise = true;
5375 } else {
5376 unsetWeakMaps(privateMethods, instance);
5377 unsetWeakMaps(privateProps, instance);
5378
5379 // @ts-ignore
5380 delete instance.isAwaitingPromise;
5381 // Unset instance methods
5382 // @ts-ignore
5383 delete instance.disableButtons;
5384 // @ts-ignore
5385 delete instance.enableButtons;
5386 // @ts-ignore
5387 delete instance.getInput;
5388 // @ts-ignore
5389 delete instance.disableInput;
5390 // @ts-ignore
5391 delete instance.enableInput;
5392 // @ts-ignore
5393 delete instance.hideLoading;
5394 // @ts-ignore
5395 delete instance.disableLoading;
5396 // @ts-ignore
5397 delete instance.showValidationMessage;
5398 // @ts-ignore
5399 delete instance.resetValidationMessage;
5400 // @ts-ignore
5401 delete instance.close;
5402 // @ts-ignore
5403 delete instance.closePopup;
5404 // @ts-ignore
5405 delete instance.closeModal;
5406 // @ts-ignore
5407 delete instance.closeToast;
5408 // @ts-ignore
5409 delete instance.rejectPromise;
5410 // @ts-ignore
5411 delete instance.update;
5412 // @ts-ignore
5413 delete instance._destroy;
5414 }
5415 };
5416
5417 /**
5418 * @param {Record<string, WeakMap<any, any>>} obj
5419 * @param {SweetAlert} instance
5420 */
5421 const unsetWeakMaps = (obj, instance) => {
5422 for (const i in obj) {
5423 obj[i].delete(instance);
5424 }
5425 };
5426
5427 var instanceMethods = /*#__PURE__*/Object.freeze({
5428 __proto__: null,
5429 _destroy: _destroy,
5430 close: close,
5431 closeModal: close,
5432 closePopup: close,
5433 closeToast: close,
5434 disableButtons: disableButtons,
5435 disableInput: disableInput,
5436 disableLoading: hideLoading,
5437 enableButtons: enableButtons,
5438 enableInput: enableInput,
5439 getInput: getInput,
5440 handleAwaitingPromise: handleAwaitingPromise,
5441 hideLoading: hideLoading,
5442 rejectPromise: rejectPromise,
5443 resetValidationMessage: resetValidationMessage,
5444 showValidationMessage: showValidationMessage,
5445 update: update
5446 });
5447
5448 /**
5449 * @param {SweetAlertOptions} innerParams
5450 * @param {DomCache} domCache
5451 * @param {(dismiss: DismissReason) => void} dismissWith
5452 */
5453 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5454 if (innerParams.toast) {
5455 handleToastClick(innerParams, domCache, dismissWith);
5456 } else {
5457 // Ignore click events that had mousedown on the popup but mouseup on the container
5458 // This can happen when the user drags a slider
5459 handleModalMousedown(domCache);
5460
5461 // Ignore click events that had mousedown on the container but mouseup on the popup
5462 handleContainerMousedown(domCache);
5463 handleModalClick(innerParams, domCache, dismissWith);
5464 }
5465 };
5466
5467 /**
5468 * @param {SweetAlertOptions} innerParams
5469 * @param {DomCache} domCache
5470 * @param {(dismiss: DismissReason) => void} dismissWith
5471 */
5472 const handleToastClick = (innerParams, domCache, dismissWith) => {
5473 // Closing toast by internal click
5474 domCache.popup.onclick = () => {
5475 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5476 return;
5477 }
5478 dismissWith(DismissReason.close);
5479 };
5480 };
5481
5482 /**
5483 * @param {SweetAlertOptions} innerParams
5484 * @returns {boolean}
5485 */
5486 const isAnyButtonShown = innerParams => {
5487 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5488 };
5489 let ignoreOutsideClick = false;
5490
5491 /**
5492 * @param {DomCache} domCache
5493 */
5494 const handleModalMousedown = domCache => {
5495 domCache.popup.onmousedown = () => {
5496 domCache.container.onmouseup = function (e) {
5497 domCache.container.onmouseup = () => {};
5498 // We only check if the mouseup target is the container because usually it doesn't
5499 // have any other direct children aside of the popup
5500 if (e.target === domCache.container) {
5501 ignoreOutsideClick = true;
5502 }
5503 };
5504 };
5505 };
5506
5507 /**
5508 * @param {DomCache} domCache
5509 */
5510 const handleContainerMousedown = domCache => {
5511 domCache.container.onmousedown = e => {
5512 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5513 if (e.target === domCache.container) {
5514 e.preventDefault();
5515 }
5516 domCache.popup.onmouseup = function (e) {
5517 domCache.popup.onmouseup = () => {};
5518 // We also need to check if the mouseup target is a child of the popup
5519 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5520 ignoreOutsideClick = true;
5521 }
5522 };
5523 };
5524 };
5525
5526 /**
5527 * @param {SweetAlertOptions} innerParams
5528 * @param {DomCache} domCache
5529 * @param {(dismiss: DismissReason) => void} dismissWith
5530 */
5531 const handleModalClick = (innerParams, domCache, dismissWith) => {
5532 domCache.container.onclick = e => {
5533 if (ignoreOutsideClick) {
5534 ignoreOutsideClick = false;
5535 return;
5536 }
5537 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5538 dismissWith(DismissReason.backdrop);
5539 }
5540 };
5541 };
5542
5543 /**
5544 * @param {any} elem
5545 * @returns {boolean}
5546 */
5547 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
5548
5549 /**
5550 * @param {any} elem
5551 * @returns {boolean}
5552 */
5553 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5554
5555 /**
5556 * @param {any[]} args
5557 * @returns {SweetAlertOptions}
5558 */
5559 const argsToParams = args => {
5560 /** @type {Record<string, any>} */
5561 const params = {};
5562 if (typeof args[0] === 'object' && !isElement(args[0])) {
5563 Object.assign(params, args[0]);
5564 } else {
5565 ['title', 'html', 'icon'].forEach((name, index) => {
5566 const arg = args[index];
5567 if (typeof arg === 'string' || isElement(arg)) {
5568 params[name] = arg;
5569 } else if (arg !== undefined) {
5570 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5571 }
5572 });
5573 }
5574 return params;
5575 };
5576
5577 /**
5578 * Main method to create a new SweetAlert2 popup
5579 *
5580 * @this {new (...args: any[]) => any}
5581 * @param {...SweetAlertOptions} args
5582 * @returns {Promise<SweetAlertResult>}
5583 */
5584 function fire(...args) {
5585 return new this(...args);
5586 }
5587
5588 /**
5589 * Returns an extended version of `Swal` containing `params` as defaults.
5590 * Useful for reusing Swal configuration.
5591 *
5592 * For example:
5593 *
5594 * Before:
5595 * const textPromptOptions = { input: 'text', showCancelButton: true }
5596 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5597 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5598 *
5599 * After:
5600 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5601 * const {value: firstName} = await TextPrompt('What is your first name?')
5602 * const {value: lastName} = await TextPrompt('What is your last name?')
5603 *
5604 * @param {SweetAlertOptions} mixinParams
5605 * @returns {SweetAlert}
5606 * @this {typeof import('../SweetAlert.js').SweetAlert}
5607 */
5608 function mixin(mixinParams) {
5609 // @ts-ignore: 'this' refers to the SweetAlert constructor
5610 class MixinSwal extends this {
5611 /**
5612 * @param {any} params
5613 * @param {any} priorityMixinParams
5614 */
5615 _main(params, priorityMixinParams) {
5616 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5617 }
5618 }
5619 // @ts-ignore
5620 return MixinSwal;
5621 }
5622
5623 /**
5624 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5625 * Otherwise, returns undefined.
5626 *
5627 * @returns {number | undefined}
5628 */
5629 const getTimerLeft = () => {
5630 return globalState.timeout && globalState.timeout.getTimerLeft();
5631 };
5632
5633 /**
5634 * Stop timer. Returns number of milliseconds of timer remained.
5635 * If `timer` parameter isn't set, returns undefined.
5636 *
5637 * @returns {number | undefined}
5638 */
5639 const stopTimer = () => {
5640 if (globalState.timeout) {
5641 stopTimerProgressBar();
5642 return globalState.timeout.stop();
5643 }
5644 };
5645
5646 /**
5647 * Resume timer. Returns number of milliseconds of timer remained.
5648 * If `timer` parameter isn't set, returns undefined.
5649 *
5650 * @returns {number | undefined}
5651 */
5652 const resumeTimer = () => {
5653 if (globalState.timeout) {
5654 const remaining = globalState.timeout.start();
5655 animateTimerProgressBar(remaining);
5656 return remaining;
5657 }
5658 };
5659
5660 /**
5661 * Resume timer. Returns number of milliseconds of timer remained.
5662 * If `timer` parameter isn't set, returns undefined.
5663 *
5664 * @returns {number | undefined}
5665 */
5666 const toggleTimer = () => {
5667 const timer = globalState.timeout;
5668 return timer && (timer.running ? stopTimer() : resumeTimer());
5669 };
5670
5671 /**
5672 * Increase timer. Returns number of milliseconds of an updated timer.
5673 * If `timer` parameter isn't set, returns undefined.
5674 *
5675 * @param {number} ms
5676 * @returns {number | undefined}
5677 */
5678 const increaseTimer = ms => {
5679 if (globalState.timeout) {
5680 const remaining = globalState.timeout.increase(ms);
5681 animateTimerProgressBar(remaining, true);
5682 return remaining;
5683 }
5684 };
5685
5686 /**
5687 * Check if timer is running. Returns true if timer is running
5688 * or false if timer is paused or stopped.
5689 * If `timer` parameter isn't set, returns undefined
5690 *
5691 * @returns {boolean}
5692 */
5693 const isTimerRunning = () => {
5694 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5695 };
5696
5697 let bodyClickListenerAdded = false;
5698 /** @type {Record<string, any>} */
5699 const clickHandlers = {};
5700
5701 /**
5702 * @this {any}
5703 * @param {string} attr
5704 */
5705 function bindClickHandler(attr = 'data-swal-template') {
5706 clickHandlers[attr] = this;
5707 if (!bodyClickListenerAdded) {
5708 document.body.addEventListener('click', bodyClickListener);
5709 bodyClickListenerAdded = true;
5710 }
5711 }
5712
5713 /**
5714 * @param {MouseEvent} event
5715 */
5716 const bodyClickListener = event => {
5717 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5718 for (const attr in clickHandlers) {
5719 const template = el.getAttribute && el.getAttribute(attr);
5720 if (template) {
5721 clickHandlers[attr].fire({
5722 template
5723 });
5724 return;
5725 }
5726 }
5727 }
5728 };
5729
5730 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5731
5732 class EventEmitter {
5733 constructor() {
5734 /** @type {Events} */
5735 this.events = {};
5736 }
5737
5738 /**
5739 * @param {string} eventName
5740 * @returns {EventHandlers}
5741 */
5742 _getHandlersByEventName(eventName) {
5743 if (typeof this.events[eventName] === 'undefined') {
5744 // not Set because we need to keep the FIFO order
5745 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5746 this.events[eventName] = [];
5747 }
5748 return this.events[eventName];
5749 }
5750
5751 /**
5752 * @param {string} eventName
5753 * @param {EventHandler} eventHandler
5754 */
5755 on(eventName, eventHandler) {
5756 const currentHandlers = this._getHandlersByEventName(eventName);
5757 if (!currentHandlers.includes(eventHandler)) {
5758 currentHandlers.push(eventHandler);
5759 }
5760 }
5761
5762 /**
5763 * @param {string} eventName
5764 * @param {EventHandler} eventHandler
5765 */
5766 once(eventName, eventHandler) {
5767 /**
5768 * @param {...any} args
5769 */
5770 const onceFn = (...args) => {
5771 this.removeListener(eventName, onceFn);
5772 // @ts-ignore
5773 eventHandler.apply(this, args);
5774 };
5775 this.on(eventName, onceFn);
5776 }
5777
5778 /**
5779 * @param {string} eventName
5780 * @param {...any} args
5781 */
5782 emit(eventName, ...args) {
5783 this._getHandlersByEventName(eventName).forEach(
5784 /**
5785 * @param {EventHandler} eventHandler
5786 */
5787 eventHandler => {
5788 try {
5789 // @ts-ignore
5790 eventHandler.apply(this, args);
5791 } catch (error) {
5792 console.error(error);
5793 }
5794 });
5795 }
5796
5797 /**
5798 * @param {string} eventName
5799 * @param {EventHandler} eventHandler
5800 */
5801 removeListener(eventName, eventHandler) {
5802 const currentHandlers = this._getHandlersByEventName(eventName);
5803 const index = currentHandlers.indexOf(eventHandler);
5804 if (index > -1) {
5805 currentHandlers.splice(index, 1);
5806 }
5807 }
5808
5809 /**
5810 * @param {string} eventName
5811 */
5812 removeAllListeners(eventName) {
5813 if (this.events[eventName] !== undefined) {
5814 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5815 this.events[eventName].length = 0;
5816 }
5817 }
5818 reset() {
5819 this.events = {};
5820 }
5821 }
5822
5823 globalState.eventEmitter = new EventEmitter();
5824
5825 /**
5826 * @param {string} eventName
5827 * @param {EventHandler} eventHandler
5828 */
5829 const on = (eventName, eventHandler) => {
5830 if (globalState.eventEmitter) {
5831 globalState.eventEmitter.on(eventName, eventHandler);
5832 }
5833 };
5834
5835 /**
5836 * @param {string} eventName
5837 * @param {EventHandler} eventHandler
5838 */
5839 const once = (eventName, eventHandler) => {
5840 if (globalState.eventEmitter) {
5841 globalState.eventEmitter.once(eventName, eventHandler);
5842 }
5843 };
5844
5845 /**
5846 * @param {string} [eventName]
5847 * @param {EventHandler} [eventHandler]
5848 */
5849 const off = (eventName, eventHandler) => {
5850 if (!globalState.eventEmitter) {
5851 return;
5852 }
5853
5854 // Remove all handlers for all events
5855 if (!eventName) {
5856 globalState.eventEmitter.reset();
5857 return;
5858 }
5859 if (eventHandler) {
5860 // Remove a specific handler
5861 globalState.eventEmitter.removeListener(eventName, eventHandler);
5862 } else {
5863 // Remove all handlers for a specific event
5864 globalState.eventEmitter.removeAllListeners(eventName);
5865 }
5866 };
5867
5868 var staticMethods = /*#__PURE__*/Object.freeze({
5869 __proto__: null,
5870 argsToParams: argsToParams,
5871 bindClickHandler: bindClickHandler,
5872 clickCancel: clickCancel,
5873 clickConfirm: clickConfirm,
5874 clickDeny: clickDeny,
5875 enableLoading: showLoading,
5876 fire: fire,
5877 getActions: getActions,
5878 getCancelButton: getCancelButton,
5879 getCloseButton: getCloseButton,
5880 getConfirmButton: getConfirmButton,
5881 getContainer: getContainer,
5882 getDenyButton: getDenyButton,
5883 getFocusableElements: getFocusableElements,
5884 getFooter: getFooter,
5885 getHtmlContainer: getHtmlContainer,
5886 getIcon: getIcon,
5887 getIconContent: getIconContent,
5888 getImage: getImage,
5889 getInputLabel: getInputLabel,
5890 getLoader: getLoader,
5891 getPopup: getPopup,
5892 getProgressSteps: getProgressSteps,
5893 getTimerLeft: getTimerLeft,
5894 getTimerProgressBar: getTimerProgressBar,
5895 getTitle: getTitle,
5896 getValidationMessage: getValidationMessage,
5897 increaseTimer: increaseTimer,
5898 isDeprecatedParameter: isDeprecatedParameter,
5899 isLoading: isLoading,
5900 isTimerRunning: isTimerRunning,
5901 isUpdatableParameter: isUpdatableParameter,
5902 isValidParameter: isValidParameter,
5903 isVisible: isVisible,
5904 mixin: mixin,
5905 off: off,
5906 on: on,
5907 once: once,
5908 resumeTimer: resumeTimer,
5909 showLoading: showLoading,
5910 stopTimer: stopTimer,
5911 toggleTimer: toggleTimer
5912 });
5913
5914 class Timer {
5915 /**
5916 * @param {() => void} callback
5917 * @param {number} delay
5918 */
5919 constructor(callback, delay) {
5920 this.callback = callback;
5921 this.remaining = delay;
5922 this.running = false;
5923 this.start();
5924 }
5925
5926 /**
5927 * @returns {number}
5928 */
5929 start() {
5930 if (!this.running) {
5931 this.running = true;
5932 this.started = new Date();
5933 this.id = setTimeout(this.callback, this.remaining);
5934 }
5935 return this.remaining;
5936 }
5937
5938 /**
5939 * @returns {number}
5940 */
5941 stop() {
5942 if (this.started && this.running) {
5943 this.running = false;
5944 clearTimeout(this.id);
5945 this.remaining -= new Date().getTime() - this.started.getTime();
5946 }
5947 return this.remaining;
5948 }
5949
5950 /**
5951 * @param {number} n
5952 * @returns {number}
5953 */
5954 increase(n) {
5955 const running = this.running;
5956 if (running) {
5957 this.stop();
5958 }
5959 this.remaining += n;
5960 if (running) {
5961 this.start();
5962 }
5963 return this.remaining;
5964 }
5965
5966 /**
5967 * @returns {number}
5968 */
5969 getTimerLeft() {
5970 if (this.running) {
5971 this.stop();
5972 this.start();
5973 }
5974 return this.remaining;
5975 }
5976
5977 /**
5978 * @returns {boolean}
5979 */
5980 isRunning() {
5981 return this.running;
5982 }
5983 }
5984
5985 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
5986
5987 /**
5988 * @param {SweetAlertOptions} params
5989 * @returns {SweetAlertOptions}
5990 */
5991 const getTemplateParams = params => {
5992 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
5993 if (!template) {
5994 return {};
5995 }
5996 /** @type {DocumentFragment} */
5997 const templateContent = template.content;
5998 showWarningsForElements(templateContent);
5999 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6000 return result;
6001 };
6002
6003 /**
6004 * @param {DocumentFragment} templateContent
6005 * @returns {Record<string, string | boolean | number>}
6006 */
6007 const getSwalParams = templateContent => {
6008 /** @type {Record<string, string | boolean | number>} */
6009 const result = {};
6010 /** @type {HTMLElement[]} */
6011 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6012 swalParams.forEach(param => {
6013 showWarningsForAttributes(param, ['name', 'value']);
6014 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6015 const value = param.getAttribute('value');
6016 if (!paramName || !value) {
6017 return;
6018 }
6019 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6020 result[paramName] = value !== 'false';
6021 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6022 result[paramName] = JSON.parse(value);
6023 } else {
6024 result[paramName] = value;
6025 }
6026 });
6027 return result;
6028 };
6029
6030 /**
6031 * @param {DocumentFragment} templateContent
6032 * @returns {Record<string, () => void>}
6033 */
6034 const getSwalFunctionParams = templateContent => {
6035 /** @type {Record<string, () => void>} */
6036 const result = {};
6037 /** @type {HTMLElement[]} */
6038 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6039 swalFunctions.forEach(param => {
6040 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6041 const value = param.getAttribute('value');
6042 if (!paramName || !value) {
6043 return;
6044 }
6045 result[paramName] = new Function(`return ${value}`)();
6046 });
6047 return result;
6048 };
6049
6050 /**
6051 * @param {DocumentFragment} templateContent
6052 * @returns {Record<string, string | boolean>}
6053 */
6054 const getSwalButtons = templateContent => {
6055 /** @type {Record<string, string | boolean>} */
6056 const result = {};
6057 /** @type {HTMLElement[]} */
6058 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6059 swalButtons.forEach(button => {
6060 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6061 const type = button.getAttribute('type');
6062 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6063 return;
6064 }
6065 result[`${type}ButtonText`] = button.innerHTML;
6066 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6067 if (button.hasAttribute('color')) {
6068 const color = button.getAttribute('color');
6069 if (color !== null) {
6070 result[`${type}ButtonColor`] = color;
6071 }
6072 }
6073 if (button.hasAttribute('aria-label')) {
6074 const ariaLabel = button.getAttribute('aria-label');
6075 if (ariaLabel !== null) {
6076 result[`${type}ButtonAriaLabel`] = ariaLabel;
6077 }
6078 }
6079 });
6080 return result;
6081 };
6082
6083 /**
6084 * @param {DocumentFragment} templateContent
6085 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6086 */
6087 const getSwalImage = templateContent => {
6088 const result = {};
6089 /** @type {HTMLElement | null} */
6090 const image = templateContent.querySelector('swal-image');
6091 if (image) {
6092 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6093 if (image.hasAttribute('src')) {
6094 result.imageUrl = image.getAttribute('src') || undefined;
6095 }
6096 if (image.hasAttribute('width')) {
6097 result.imageWidth = image.getAttribute('width') || undefined;
6098 }
6099 if (image.hasAttribute('height')) {
6100 result.imageHeight = image.getAttribute('height') || undefined;
6101 }
6102 if (image.hasAttribute('alt')) {
6103 result.imageAlt = image.getAttribute('alt') || undefined;
6104 }
6105 }
6106 return result;
6107 };
6108
6109 /**
6110 * @param {DocumentFragment} templateContent
6111 * @returns {object}
6112 */
6113 const getSwalIcon = templateContent => {
6114 const result = {};
6115 /** @type {HTMLElement | null} */
6116 const icon = templateContent.querySelector('swal-icon');
6117 if (icon) {
6118 showWarningsForAttributes(icon, ['type', 'color']);
6119 if (icon.hasAttribute('type')) {
6120 result.icon = icon.getAttribute('type');
6121 }
6122 if (icon.hasAttribute('color')) {
6123 result.iconColor = icon.getAttribute('color');
6124 }
6125 result.iconHtml = icon.innerHTML;
6126 }
6127 return result;
6128 };
6129
6130 /**
6131 * @param {DocumentFragment} templateContent
6132 * @returns {object}
6133 */
6134 const getSwalInput = templateContent => {
6135 /** @type {Record<string, any>} */
6136 const result = {};
6137 /** @type {HTMLElement | null} */
6138 const input = templateContent.querySelector('swal-input');
6139 if (input) {
6140 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6141 result.input = input.getAttribute('type') || 'text';
6142 if (input.hasAttribute('label')) {
6143 result.inputLabel = input.getAttribute('label');
6144 }
6145 if (input.hasAttribute('placeholder')) {
6146 result.inputPlaceholder = input.getAttribute('placeholder');
6147 }
6148 if (input.hasAttribute('value')) {
6149 result.inputValue = input.getAttribute('value');
6150 }
6151 }
6152 /** @type {HTMLElement[]} */
6153 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6154 if (inputOptions.length) {
6155 result.inputOptions = {};
6156 inputOptions.forEach(option => {
6157 showWarningsForAttributes(option, ['value']);
6158 const optionValue = option.getAttribute('value');
6159 if (!optionValue) {
6160 return;
6161 }
6162 const optionName = option.innerHTML;
6163 result.inputOptions[optionValue] = optionName;
6164 });
6165 }
6166 return result;
6167 };
6168
6169 /**
6170 * @param {DocumentFragment} templateContent
6171 * @param {string[]} paramNames
6172 * @returns {Record<string, string>}
6173 */
6174 const getSwalStringParams = (templateContent, paramNames) => {
6175 /** @type {Record<string, string>} */
6176 const result = {};
6177 for (const i in paramNames) {
6178 const paramName = paramNames[i];
6179 /** @type {HTMLElement | null} */
6180 const tag = templateContent.querySelector(paramName);
6181 if (tag) {
6182 showWarningsForAttributes(tag, []);
6183 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6184 }
6185 }
6186 return result;
6187 };
6188
6189 /**
6190 * @param {DocumentFragment} templateContent
6191 */
6192 const showWarningsForElements = templateContent => {
6193 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6194 Array.from(templateContent.children).forEach(el => {
6195 const tagName = el.tagName.toLowerCase();
6196 if (!allowedElements.includes(tagName)) {
6197 warn(`Unrecognized element <${tagName}>`);
6198 }
6199 });
6200 };
6201
6202 /**
6203 * @param {HTMLElement} el
6204 * @param {string[]} allowedAttributes
6205 */
6206 const showWarningsForAttributes = (el, allowedAttributes) => {
6207 Array.from(el.attributes).forEach(attribute => {
6208 if (allowedAttributes.indexOf(attribute.name) === -1) {
6209 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.'}`]);
6210 }
6211 });
6212 };
6213
6214 const SHOW_CLASS_TIMEOUT = 10;
6215
6216 /**
6217 * Open popup, add necessary classes and styles, fix scrollbar
6218 *
6219 * @param {SweetAlertOptions} params
6220 */
6221 const openPopup = params => {
6222 var _globalState$eventEmi, _globalState$eventEmi2;
6223 const container = getContainer();
6224 const popup = getPopup();
6225 if (!container || !popup) {
6226 return;
6227 }
6228 if (typeof params.willOpen === 'function') {
6229 params.willOpen(popup);
6230 }
6231 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6232 const bodyStyles = window.getComputedStyle(document.body);
6233 const initialBodyOverflow = bodyStyles.overflowY;
6234 addClasses(container, popup, params);
6235
6236 // scrolling is 'hidden' until animation is done, after that 'auto'
6237 setTimeout(() => {
6238 setScrollingVisibility(container, popup);
6239 }, SHOW_CLASS_TIMEOUT);
6240 if (isModal()) {
6241 // Using ternary instead of ?? operator for Webpack 4 compatibility
6242 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6243 setAriaHidden();
6244 }
6245 if (!isToast() && !globalState.previousActiveElement) {
6246 globalState.previousActiveElement = document.activeElement;
6247 }
6248 if (typeof params.didOpen === 'function') {
6249 const didOpen = params.didOpen;
6250 setTimeout(() => didOpen(popup));
6251 }
6252 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6253 };
6254
6255 /**
6256 * @param {Event} event
6257 */
6258 const swalOpenAnimationFinished = event => {
6259 const popup = getPopup();
6260 if (!popup || event.target !== popup) {
6261 return;
6262 }
6263 const container = getContainer();
6264 if (!container) {
6265 return;
6266 }
6267 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6268 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6269 container.style.overflowY = 'auto';
6270
6271 // no-transition is added in init() in case one swal is opened right after another
6272 removeClass(container, swalClasses['no-transition']);
6273 };
6274
6275 /**
6276 * @param {HTMLElement} container
6277 * @param {HTMLElement} popup
6278 */
6279 const setScrollingVisibility = (container, popup) => {
6280 if (hasCssAnimation(popup)) {
6281 container.style.overflowY = 'hidden';
6282 popup.addEventListener('animationend', swalOpenAnimationFinished);
6283 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6284 } else {
6285 container.style.overflowY = 'auto';
6286 }
6287 };
6288
6289 /**
6290 * @param {HTMLElement} container
6291 * @param {boolean} scrollbarPadding
6292 * @param {string} initialBodyOverflow
6293 */
6294 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6295 iOSfix();
6296 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6297 replaceScrollbarWithPadding(initialBodyOverflow);
6298 }
6299
6300 // sweetalert2/issues/1247
6301 setTimeout(() => {
6302 container.scrollTop = 0;
6303 });
6304 };
6305
6306 /**
6307 * @param {HTMLElement} container
6308 * @param {HTMLElement} popup
6309 * @param {SweetAlertOptions} params
6310 */
6311 const addClasses = (container, popup, params) => {
6312 var _params$showClass;
6313 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6314 addClass(container, params.showClass.backdrop);
6315 }
6316 if (params.animation) {
6317 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6318 popup.style.setProperty('opacity', '0', 'important');
6319 show(popup, 'grid');
6320 setTimeout(() => {
6321 var _params$showClass2;
6322 // Animate popup right after showing it
6323 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6324 addClass(popup, params.showClass.popup);
6325 }
6326 // and remove the opacity workaround
6327 popup.style.removeProperty('opacity');
6328 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6329 } else {
6330 show(popup, 'grid');
6331 }
6332 addClass([document.documentElement, document.body], swalClasses.shown);
6333 if (params.heightAuto && params.backdrop && !params.toast) {
6334 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6335 }
6336 };
6337
6338 var defaultInputValidators = {
6339 /**
6340 * @param {string} string
6341 * @param {string} [validationMessage]
6342 * @returns {Promise<string | void>}
6343 */
6344 email: (string, validationMessage) => {
6345 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6346 },
6347 /**
6348 * @param {string} string
6349 * @param {string} [validationMessage]
6350 * @returns {Promise<string | void>}
6351 */
6352 url: (string, validationMessage) => {
6353 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6354 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');
6355 }
6356 };
6357
6358 /**
6359 * @param {SweetAlertOptions} params
6360 */
6361 function setDefaultInputValidators(params) {
6362 // Use default `inputValidator` for supported input types if not provided
6363 if (params.inputValidator) {
6364 return;
6365 }
6366 if (params.input === 'email') {
6367 params.inputValidator = defaultInputValidators['email'];
6368 }
6369 if (params.input === 'url') {
6370 params.inputValidator = defaultInputValidators['url'];
6371 }
6372 }
6373
6374 /**
6375 * @param {SweetAlertOptions} params
6376 */
6377 function validateCustomTargetElement(params) {
6378 // Determine if the custom target element is valid
6379 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6380 warn('Target parameter is not valid, defaulting to "body"');
6381 params.target = 'body';
6382 }
6383 }
6384
6385 /**
6386 * Set type, text and actions on popup
6387 *
6388 * @param {SweetAlertOptions} params
6389 */
6390 function setParameters(params) {
6391 setDefaultInputValidators(params);
6392
6393 // showLoaderOnConfirm && preConfirm
6394 if (params.showLoaderOnConfirm && !params.preConfirm) {
6395 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');
6396 }
6397 validateCustomTargetElement(params);
6398
6399 // Replace newlines with <br> in title
6400 if (typeof params.title === 'string') {
6401 params.title = params.title.split('\n').join('<br />');
6402 }
6403 init(params);
6404 }
6405
6406 /** @type {SweetAlert} */
6407 let currentInstance;
6408 var _promise = /*#__PURE__*/new WeakMap();
6409 class SweetAlert {
6410 /**
6411 * @param {...(SweetAlertOptions | string)} args
6412 * @this {SweetAlert}
6413 */
6414 constructor(...args) {
6415 /**
6416 * @type {Promise<SweetAlertResult>}
6417 */
6418 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
6419 isConfirmed: false,
6420 isDenied: false,
6421 isDismissed: true
6422 }));
6423 // Prevent run in Node env
6424 if (typeof window === 'undefined') {
6425 return;
6426 }
6427 currentInstance = this;
6428
6429 // @ts-ignore
6430 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6431
6432 /** @type {Readonly<SweetAlertOptions>} */
6433 this.params = outerParams;
6434
6435 /** @type {boolean} */
6436 this.isAwaitingPromise = false;
6437 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6438 }
6439
6440 /**
6441 * @param {any} userParams
6442 * @param {any} mixinParams
6443 */
6444 _main(userParams, mixinParams = {}) {
6445 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6446 if (globalState.currentInstance) {
6447 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6448 const {
6449 isAwaitingPromise
6450 } = globalState.currentInstance;
6451 globalState.currentInstance._destroy();
6452 if (!isAwaitingPromise) {
6453 swalPromiseResolve({
6454 isDismissed: true
6455 });
6456 }
6457 if (isModal()) {
6458 unsetAriaHidden();
6459 }
6460 }
6461 globalState.currentInstance = currentInstance;
6462 const innerParams = prepareParams(userParams, mixinParams);
6463 setParameters(innerParams);
6464 Object.freeze(innerParams);
6465
6466 // clear the previous timer
6467 if (globalState.timeout) {
6468 globalState.timeout.stop();
6469 delete globalState.timeout;
6470 }
6471
6472 // clear the restore focus timeout
6473 clearTimeout(globalState.restoreFocusTimeout);
6474 const domCache = populateDomCache(currentInstance);
6475 render(currentInstance, innerParams);
6476 privateProps.innerParams.set(currentInstance, innerParams);
6477 return swalPromise(currentInstance, domCache, innerParams);
6478 }
6479
6480 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6481 /**
6482 * @param {any} onFulfilled
6483 */
6484 then(onFulfilled) {
6485 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6486 }
6487
6488 /**
6489 * @param {any} onFinally
6490 */
6491 finally(onFinally) {
6492 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6493 }
6494 }
6495
6496 /**
6497 * @param {SweetAlert} instance
6498 * @param {DomCache} domCache
6499 * @param {SweetAlertOptions} innerParams
6500 * @returns {Promise<SweetAlertResult>}
6501 */
6502 const swalPromise = (instance, domCache, innerParams) => {
6503 return new Promise((resolve, reject) => {
6504 // functions to handle all closings/dismissals
6505 /**
6506 * @param {DismissReason} dismiss
6507 */
6508 const dismissWith = dismiss => {
6509 instance.close({
6510 isDismissed: true,
6511 dismiss,
6512 isConfirmed: false,
6513 isDenied: false
6514 });
6515 };
6516 privateMethods.swalPromiseResolve.set(instance, resolve);
6517 privateMethods.swalPromiseReject.set(instance, reject);
6518 domCache.confirmButton.onclick = () => {
6519 handleConfirmButtonClick(instance);
6520 };
6521 domCache.denyButton.onclick = () => {
6522 handleDenyButtonClick(instance);
6523 };
6524 domCache.cancelButton.onclick = () => {
6525 handleCancelButtonClick(instance, dismissWith);
6526 };
6527 domCache.closeButton.onclick = () => {
6528 dismissWith(DismissReason.close);
6529 };
6530 handlePopupClick(innerParams, domCache, dismissWith);
6531 addKeydownHandler(globalState, innerParams, dismissWith);
6532 handleInputOptionsAndValue(instance, innerParams);
6533 openPopup(innerParams);
6534 setupTimer(globalState, innerParams, dismissWith);
6535 initFocus(domCache, innerParams);
6536
6537 // Scroll container to top on open (#1247, #1946)
6538 setTimeout(() => {
6539 domCache.container.scrollTop = 0;
6540 });
6541 });
6542 };
6543
6544 /**
6545 * @param {SweetAlertOptions} userParams
6546 * @param {SweetAlertOptions} mixinParams
6547 * @returns {SweetAlertOptions}
6548 */
6549 const prepareParams = (userParams, mixinParams) => {
6550 const templateParams = getTemplateParams(userParams);
6551 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6552 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6553 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6554 if (params.animation === false) {
6555 params.showClass = {
6556 backdrop: 'swal2-noanimation'
6557 };
6558 params.hideClass = {};
6559 }
6560 return params;
6561 };
6562
6563 /**
6564 * @param {SweetAlert} instance
6565 * @returns {DomCache}
6566 */
6567 const populateDomCache = instance => {
6568 const domCache = /** @type {DomCache} */{
6569 popup: (/** @type {HTMLElement} */getPopup()),
6570 container: (/** @type {HTMLElement} */getContainer()),
6571 actions: (/** @type {HTMLElement} */getActions()),
6572 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6573 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6574 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6575 loader: (/** @type {HTMLElement} */getLoader()),
6576 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6577 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6578 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6579 };
6580 privateProps.domCache.set(instance, domCache);
6581 return domCache;
6582 };
6583
6584 /**
6585 * @param {GlobalState} globalState
6586 * @param {SweetAlertOptions} innerParams
6587 * @param {(dismiss: DismissReason) => void} dismissWith
6588 */
6589 const setupTimer = (globalState, innerParams, dismissWith) => {
6590 const timerProgressBar = getTimerProgressBar();
6591 hide(timerProgressBar);
6592 if (innerParams.timer) {
6593 globalState.timeout = new Timer(() => {
6594 dismissWith('timer');
6595 delete globalState.timeout;
6596 }, innerParams.timer);
6597 if (innerParams.timerProgressBar && timerProgressBar) {
6598 show(timerProgressBar);
6599 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6600 setTimeout(() => {
6601 if (globalState.timeout && globalState.timeout.running) {
6602 // timer can be already stopped or unset at this point
6603 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6604 }
6605 });
6606 }
6607 }
6608 };
6609
6610 /**
6611 * Initialize focus in the popup:
6612 *
6613 * 1. If `toast` is `true`, don't steal focus from the document.
6614 * 2. Else if there is an [autofocus] element, focus it.
6615 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6616 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6617 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6618 * 6. Else focus the first focusable element in a popup (if any).
6619 *
6620 * @param {DomCache} domCache
6621 * @param {SweetAlertOptions} innerParams
6622 */
6623 const initFocus = (domCache, innerParams) => {
6624 if (innerParams.toast) {
6625 return;
6626 }
6627 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6628 if (!callIfFunction(innerParams.allowEnterKey)) {
6629 warnAboutDeprecation('allowEnterKey');
6630 blurActiveElement();
6631 return;
6632 }
6633 if (focusAutofocus(domCache)) {
6634 return;
6635 }
6636 if (focusButton(domCache, innerParams)) {
6637 return;
6638 }
6639 setFocus(-1, 1);
6640 };
6641
6642 /**
6643 * @param {DomCache} domCache
6644 * @returns {boolean}
6645 */
6646 const focusAutofocus = domCache => {
6647 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6648 for (const autofocusElement of autofocusElements) {
6649 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6650 autofocusElement.focus();
6651 return true;
6652 }
6653 }
6654 return false;
6655 };
6656
6657 /**
6658 * @param {DomCache} domCache
6659 * @param {SweetAlertOptions} innerParams
6660 * @returns {boolean}
6661 */
6662 const focusButton = (domCache, innerParams) => {
6663 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6664 domCache.denyButton.focus();
6665 return true;
6666 }
6667 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6668 domCache.cancelButton.focus();
6669 return true;
6670 }
6671 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6672 domCache.confirmButton.focus();
6673 return true;
6674 }
6675 return false;
6676 };
6677 const blurActiveElement = () => {
6678 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
6679 document.activeElement.blur();
6680 }
6681 };
6682
6683 // Assign instance methods from src/instanceMethods/*.js to prototype
6684 SweetAlert.prototype.disableButtons = disableButtons;
6685 SweetAlert.prototype.enableButtons = enableButtons;
6686 SweetAlert.prototype.getInput = getInput;
6687 SweetAlert.prototype.disableInput = disableInput;
6688 SweetAlert.prototype.enableInput = enableInput;
6689 SweetAlert.prototype.hideLoading = hideLoading;
6690 SweetAlert.prototype.disableLoading = hideLoading;
6691 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6692 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6693 SweetAlert.prototype.close = close;
6694 SweetAlert.prototype.closePopup = close;
6695 SweetAlert.prototype.closeModal = close;
6696 SweetAlert.prototype.closeToast = close;
6697 SweetAlert.prototype.rejectPromise = rejectPromise;
6698 SweetAlert.prototype.update = update;
6699 SweetAlert.prototype._destroy = _destroy;
6700
6701 // Assign static methods from src/staticMethods/*.js to constructor
6702 Object.assign(SweetAlert, staticMethods);
6703
6704 // Proxy to instance methods to constructor, for now, for backwards compatibility
6705 Object.keys(instanceMethods).forEach(key => {
6706 /**
6707 * @param {...(SweetAlertOptions | string | undefined)} args
6708 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6709 */
6710 // @ts-ignore: Dynamic property assignment for backwards compatibility
6711 SweetAlert[key] = function (...args) {
6712 // @ts-ignore
6713 if (currentInstance && currentInstance[key]) {
6714 // @ts-ignore
6715 return currentInstance[key](...args);
6716 }
6717 return undefined;
6718 };
6719 });
6720 SweetAlert.DismissReason = DismissReason;
6721 SweetAlert.version = '11.26.17';
6722
6723 const Swal = SweetAlert;
6724 // @ts-ignore
6725 Swal.default = Swal;
6726
6727 return Swal;
6728
6729 }));
6730 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6731 "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}}");
6732
6733 /***/ },
6734
6735 /***/ "./node_modules/toastify-js/src/toastify.js"
6736 /*!**************************************************!*\
6737 !*** ./node_modules/toastify-js/src/toastify.js ***!
6738 \**************************************************/
6739 (module) {
6740
6741 /*!
6742 * Toastify js 1.12.0
6743 * https://github.com/apvarun/toastify-js
6744 * @license MIT licensed
6745 *
6746 * Copyright (C) 2018 Varun A P
6747 */
6748 (function(root, factory) {
6749 if ( true && module.exports) {
6750 module.exports = factory();
6751 } else {
6752 root.Toastify = factory();
6753 }
6754 })(this, function(global) {
6755 // Object initialization
6756 var Toastify = function(options) {
6757 // Returning a new init object
6758 return new Toastify.lib.init(options);
6759 },
6760 // Library version
6761 version = "1.12.0";
6762
6763 // Set the default global options
6764 Toastify.defaults = {
6765 oldestFirst: true,
6766 text: "Toastify is awesome!",
6767 node: undefined,
6768 duration: 3000,
6769 selector: undefined,
6770 callback: function () {
6771 },
6772 destination: undefined,
6773 newWindow: false,
6774 close: false,
6775 gravity: "toastify-top",
6776 positionLeft: false,
6777 position: '',
6778 backgroundColor: '',
6779 avatar: "",
6780 className: "",
6781 stopOnFocus: true,
6782 onClick: function () {
6783 },
6784 offset: {x: 0, y: 0},
6785 escapeMarkup: true,
6786 ariaLive: 'polite',
6787 style: {background: ''}
6788 };
6789
6790 // Defining the prototype of the object
6791 Toastify.lib = Toastify.prototype = {
6792 toastify: version,
6793
6794 constructor: Toastify,
6795
6796 // Initializing the object with required parameters
6797 init: function(options) {
6798 // Verifying and validating the input object
6799 if (!options) {
6800 options = {};
6801 }
6802
6803 // Creating the options object
6804 this.options = {};
6805
6806 this.toastElement = null;
6807
6808 // Validating the options
6809 this.options.text = options.text || Toastify.defaults.text; // Display message
6810 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6811 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6812 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6813 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6814 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6815 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6816 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6817 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6818 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6819 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6820 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6821 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6822 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6823 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6824 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6825 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6826 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6827 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6828 this.options.style = options.style || Toastify.defaults.style;
6829 if(options.backgroundColor) {
6830 this.options.style.background = options.backgroundColor;
6831 }
6832
6833 // Returning the current object for chaining functions
6834 return this;
6835 },
6836
6837 // Building the DOM element
6838 buildToast: function() {
6839 // Validating if the options are defined
6840 if (!this.options) {
6841 throw "Toastify is not initialized";
6842 }
6843
6844 // Creating the DOM object
6845 var divElement = document.createElement("div");
6846 divElement.className = "toastify on " + this.options.className;
6847
6848 // Positioning toast to left or right or center
6849 if (!!this.options.position) {
6850 divElement.className += " toastify-" + this.options.position;
6851 } else {
6852 // To be depreciated in further versions
6853 if (this.options.positionLeft === true) {
6854 divElement.className += " toastify-left";
6855 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6856 } else {
6857 // Default position
6858 divElement.className += " toastify-right";
6859 }
6860 }
6861
6862 // Assigning gravity of element
6863 divElement.className += " " + this.options.gravity;
6864
6865 if (this.options.backgroundColor) {
6866 // This is being deprecated in favor of using the style HTML DOM property
6867 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
6868 }
6869
6870 // Loop through our style object and apply styles to divElement
6871 for (var property in this.options.style) {
6872 divElement.style[property] = this.options.style[property];
6873 }
6874
6875 // Announce the toast to screen readers
6876 if (this.options.ariaLive) {
6877 divElement.setAttribute('aria-live', this.options.ariaLive)
6878 }
6879
6880 // Adding the toast message/node
6881 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
6882 // If we have a valid node, we insert it
6883 divElement.appendChild(this.options.node)
6884 } else {
6885 if (this.options.escapeMarkup) {
6886 divElement.innerText = this.options.text;
6887 } else {
6888 divElement.innerHTML = this.options.text;
6889 }
6890
6891 if (this.options.avatar !== "") {
6892 var avatarElement = document.createElement("img");
6893 avatarElement.src = this.options.avatar;
6894
6895 avatarElement.className = "toastify-avatar";
6896
6897 if (this.options.position == "left" || this.options.positionLeft === true) {
6898 // Adding close icon on the left of content
6899 divElement.appendChild(avatarElement);
6900 } else {
6901 // Adding close icon on the right of content
6902 divElement.insertAdjacentElement("afterbegin", avatarElement);
6903 }
6904 }
6905 }
6906
6907 // Adding a close icon to the toast
6908 if (this.options.close === true) {
6909 // Create a span for close element
6910 var closeElement = document.createElement("button");
6911 closeElement.type = "button";
6912 closeElement.setAttribute("aria-label", "Close");
6913 closeElement.className = "toast-close";
6914 closeElement.innerHTML = "&#10006;";
6915
6916 // Triggering the removal of toast from DOM on close click
6917 closeElement.addEventListener(
6918 "click",
6919 function(event) {
6920 event.stopPropagation();
6921 this.removeElement(this.toastElement);
6922 window.clearTimeout(this.toastElement.timeOutValue);
6923 }.bind(this)
6924 );
6925
6926 //Calculating screen width
6927 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
6928
6929 // Adding the close icon to the toast element
6930 // Display on the right if screen width is less than or equal to 360px
6931 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
6932 // Adding close icon on the left of content
6933 divElement.insertAdjacentElement("afterbegin", closeElement);
6934 } else {
6935 // Adding close icon on the right of content
6936 divElement.appendChild(closeElement);
6937 }
6938 }
6939
6940 // Clear timeout while toast is focused
6941 if (this.options.stopOnFocus && this.options.duration > 0) {
6942 var self = this;
6943 // stop countdown
6944 divElement.addEventListener(
6945 "mouseover",
6946 function(event) {
6947 window.clearTimeout(divElement.timeOutValue);
6948 }
6949 )
6950 // add back the timeout
6951 divElement.addEventListener(
6952 "mouseleave",
6953 function() {
6954 divElement.timeOutValue = window.setTimeout(
6955 function() {
6956 // Remove the toast from DOM
6957 self.removeElement(divElement);
6958 },
6959 self.options.duration
6960 )
6961 }
6962 )
6963 }
6964
6965 // Adding an on-click destination path
6966 if (typeof this.options.destination !== "undefined") {
6967 divElement.addEventListener(
6968 "click",
6969 function(event) {
6970 event.stopPropagation();
6971 if (this.options.newWindow === true) {
6972 window.open(this.options.destination, "_blank");
6973 } else {
6974 window.location = this.options.destination;
6975 }
6976 }.bind(this)
6977 );
6978 }
6979
6980 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
6981 divElement.addEventListener(
6982 "click",
6983 function(event) {
6984 event.stopPropagation();
6985 this.options.onClick();
6986 }.bind(this)
6987 );
6988 }
6989
6990 // Adding offset
6991 if(typeof this.options.offset === "object") {
6992
6993 var x = getAxisOffsetAValue("x", this.options);
6994 var y = getAxisOffsetAValue("y", this.options);
6995
6996 var xOffset = this.options.position == "left" ? x : "-" + x;
6997 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
6998
6999 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7000
7001 }
7002
7003 // Returning the generated element
7004 return divElement;
7005 },
7006
7007 // Displaying the toast
7008 showToast: function() {
7009 // Creating the DOM object for the toast
7010 this.toastElement = this.buildToast();
7011
7012 // Getting the root element to with the toast needs to be added
7013 var rootElement;
7014 if (typeof this.options.selector === "string") {
7015 rootElement = document.getElementById(this.options.selector);
7016 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7017 rootElement = this.options.selector;
7018 } else {
7019 rootElement = document.body;
7020 }
7021
7022 // Validating if root element is present in DOM
7023 if (!rootElement) {
7024 throw "Root element is not defined";
7025 }
7026
7027 // Adding the DOM element
7028 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7029 rootElement.insertBefore(this.toastElement, elementToInsert);
7030
7031 // Repositioning the toasts in case multiple toasts are present
7032 Toastify.reposition();
7033
7034 if (this.options.duration > 0) {
7035 this.toastElement.timeOutValue = window.setTimeout(
7036 function() {
7037 // Remove the toast from DOM
7038 this.removeElement(this.toastElement);
7039 }.bind(this),
7040 this.options.duration
7041 ); // Binding `this` for function invocation
7042 }
7043
7044 // Supporting function chaining
7045 return this;
7046 },
7047
7048 hideToast: function() {
7049 if (this.toastElement.timeOutValue) {
7050 clearTimeout(this.toastElement.timeOutValue);
7051 }
7052 this.removeElement(this.toastElement);
7053 },
7054
7055 // Removing the element from the DOM
7056 removeElement: function(toastElement) {
7057 // Hiding the element
7058 // toastElement.classList.remove("on");
7059 toastElement.className = toastElement.className.replace(" on", "");
7060
7061 // Removing the element from DOM after transition end
7062 window.setTimeout(
7063 function() {
7064 // remove options node if any
7065 if (this.options.node && this.options.node.parentNode) {
7066 this.options.node.parentNode.removeChild(this.options.node);
7067 }
7068
7069 // Remove the element from the DOM, only when the parent node was not removed before.
7070 if (toastElement.parentNode) {
7071 toastElement.parentNode.removeChild(toastElement);
7072 }
7073
7074 // Calling the callback function
7075 this.options.callback.call(toastElement);
7076
7077 // Repositioning the toasts again
7078 Toastify.reposition();
7079 }.bind(this),
7080 400
7081 ); // Binding `this` for function invocation
7082 },
7083 };
7084
7085 // Positioning the toasts on the DOM
7086 Toastify.reposition = function() {
7087
7088 // Top margins with gravity
7089 var topLeftOffsetSize = {
7090 top: 15,
7091 bottom: 15,
7092 };
7093 var topRightOffsetSize = {
7094 top: 15,
7095 bottom: 15,
7096 };
7097 var offsetSize = {
7098 top: 15,
7099 bottom: 15,
7100 };
7101
7102 // Get all toast messages on the DOM
7103 var allToasts = document.getElementsByClassName("toastify");
7104
7105 var classUsed;
7106
7107 // Modifying the position of each toast element
7108 for (var i = 0; i < allToasts.length; i++) {
7109 // Getting the applied gravity
7110 if (containsClass(allToasts[i], "toastify-top") === true) {
7111 classUsed = "toastify-top";
7112 } else {
7113 classUsed = "toastify-bottom";
7114 }
7115
7116 var height = allToasts[i].offsetHeight;
7117 classUsed = classUsed.substr(9, classUsed.length-1)
7118 // Spacing between toasts
7119 var offset = 15;
7120
7121 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7122
7123 // Show toast in center if screen with less than or equal to 360px
7124 if (width <= 360) {
7125 // Setting the position
7126 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7127
7128 offsetSize[classUsed] += height + offset;
7129 } else {
7130 if (containsClass(allToasts[i], "toastify-left") === true) {
7131 // Setting the position
7132 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7133
7134 topLeftOffsetSize[classUsed] += height + offset;
7135 } else {
7136 // Setting the position
7137 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7138
7139 topRightOffsetSize[classUsed] += height + offset;
7140 }
7141 }
7142 }
7143
7144 // Supporting function chaining
7145 return this;
7146 };
7147
7148 // Helper function to get offset.
7149 function getAxisOffsetAValue(axis, options) {
7150
7151 if(options.offset[axis]) {
7152 if(isNaN(options.offset[axis])) {
7153 return options.offset[axis];
7154 }
7155 else {
7156 return options.offset[axis] + 'px';
7157 }
7158 }
7159
7160 return '0px';
7161
7162 }
7163
7164 function containsClass(elem, yourClass) {
7165 if (!elem || typeof yourClass !== "string") {
7166 return false;
7167 } else if (
7168 elem.className &&
7169 elem.className
7170 .trim()
7171 .split(/\s+/gi)
7172 .indexOf(yourClass) > -1
7173 ) {
7174 return true;
7175 } else {
7176 return false;
7177 }
7178 }
7179
7180 // Setting up the prototype for the init object
7181 Toastify.lib.init.prototype = Toastify.lib;
7182
7183 // Returning the Toastify function to be assigned to the window object/module
7184 return Toastify;
7185 });
7186
7187
7188 /***/ },
7189
7190 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7191 /*!**********************************************************!*\
7192 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7193 \**********************************************************/
7194 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7195
7196 "use strict";
7197 __webpack_require__.r(__webpack_exports__);
7198 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7199 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7200 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7201 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7202 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7203 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7204 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7205 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7206 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7207 /* harmony export */ });
7208 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7209 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7210 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7211 /**
7212 * sifter.js
7213 * Copyright (c) 2013–2020 Brian Reavis & contributors
7214 *
7215 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7216 * file except in compliance with the License. You may obtain a copy of the License at:
7217 * http://www.apache.org/licenses/LICENSE-2.0
7218 *
7219 * Unless required by applicable law or agreed to in writing, software distributed under
7220 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7221 * ANY KIND, either express or implied. See the License for the specific language
7222 * governing permissions and limitations under the License.
7223 *
7224 * @author Brian Reavis <brian@thirdroute.com>
7225 */
7226
7227
7228 class Sifter {
7229 items; // []|{};
7230 settings;
7231 /**
7232 * Textually searches arrays and hashes of objects
7233 * by property (or multiple properties). Designed
7234 * specifically for autocomplete.
7235 *
7236 */
7237 constructor(items, settings) {
7238 this.items = items;
7239 this.settings = settings || { diacritics: true };
7240 }
7241 ;
7242 /**
7243 * Splits a search string into an array of individual
7244 * regexps to be used to match results.
7245 *
7246 */
7247 tokenize(query, respect_word_boundaries, weights) {
7248 if (!query || !query.length)
7249 return [];
7250 const tokens = [];
7251 const words = query.split(/\s+/);
7252 var field_regex;
7253 if (weights) {
7254 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7255 }
7256 words.forEach((word) => {
7257 let field_match;
7258 let field = null;
7259 let regex = null;
7260 // look for "field:query" tokens
7261 if (field_regex && (field_match = word.match(field_regex))) {
7262 field = field_match[1];
7263 word = field_match[2];
7264 }
7265 if (word.length > 0) {
7266 if (this.settings.diacritics) {
7267 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7268 }
7269 else {
7270 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7271 }
7272 if (regex && respect_word_boundaries)
7273 regex = "\\b" + regex;
7274 }
7275 tokens.push({
7276 string: word,
7277 regex: regex ? new RegExp(regex, 'iu') : null,
7278 field: field,
7279 });
7280 });
7281 return tokens;
7282 }
7283 ;
7284 /**
7285 * Returns a function to be used to score individual results.
7286 *
7287 * Good matches will have a higher score than poor matches.
7288 * If an item is not a match, 0 will be returned by the function.
7289 *
7290 * @returns {T.ScoreFn}
7291 */
7292 getScoreFunction(query, options) {
7293 var search = this.prepareSearch(query, options);
7294 return this._getScoreFunction(search);
7295 }
7296 /**
7297 * @returns {T.ScoreFn}
7298 *
7299 */
7300 _getScoreFunction(search) {
7301 const tokens = search.tokens, token_count = tokens.length;
7302 if (!token_count) {
7303 return function () { return 0; };
7304 }
7305 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7306 if (!field_count) {
7307 return function () { return 1; };
7308 }
7309 /**
7310 * Calculates the score of an object
7311 * against the search query.
7312 *
7313 */
7314 const scoreObject = (function () {
7315 if (field_count === 1) {
7316 return function (token, data) {
7317 const field = fields[0].field;
7318 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7319 };
7320 }
7321 return function (token, data) {
7322 var sum = 0;
7323 // is the token specific to a field?
7324 if (token.field) {
7325 const value = getAttrFn(data, token.field);
7326 if (!token.regex && value) {
7327 sum += (1 / field_count);
7328 }
7329 else {
7330 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7331 }
7332 }
7333 else {
7334 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7335 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7336 });
7337 }
7338 return sum / field_count;
7339 };
7340 })();
7341 if (token_count === 1) {
7342 return function (data) {
7343 return scoreObject(tokens[0], data);
7344 };
7345 }
7346 if (search.options.conjunction === 'and') {
7347 return function (data) {
7348 var score, sum = 0;
7349 for (let token of tokens) {
7350 score = scoreObject(token, data);
7351 if (score <= 0)
7352 return 0;
7353 sum += score;
7354 }
7355 return sum / token_count;
7356 };
7357 }
7358 else {
7359 return function (data) {
7360 var sum = 0;
7361 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7362 sum += scoreObject(token, data);
7363 });
7364 return sum / token_count;
7365 };
7366 }
7367 }
7368 ;
7369 /**
7370 * Returns a function that can be used to compare two
7371 * results, for sorting purposes. If no sorting should
7372 * be performed, `null` will be returned.
7373 *
7374 * @return function(a,b)
7375 */
7376 getSortFunction(query, options) {
7377 var search = this.prepareSearch(query, options);
7378 return this._getSortFunction(search);
7379 }
7380 _getSortFunction(search) {
7381 var implicit_score, sort_flds = [];
7382 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
7383 if (typeof sort == 'function') {
7384 return sort.bind(this);
7385 }
7386 /**
7387 * Fetches the specified sort field value
7388 * from a search result item.
7389 *
7390 */
7391 const get_field = function (name, result) {
7392 if (name === '$score')
7393 return result.score;
7394 return search.getAttrFn(self.items[result.id], name);
7395 };
7396 // parse options
7397 if (sort) {
7398 for (let s of sort) {
7399 if (search.query || s.field !== '$score') {
7400 sort_flds.push(s);
7401 }
7402 }
7403 }
7404 // the "$score" field is implied to be the primary
7405 // sort field, unless it's manually specified
7406 if (search.query) {
7407 implicit_score = true;
7408 for (let fld of sort_flds) {
7409 if (fld.field === '$score') {
7410 implicit_score = false;
7411 break;
7412 }
7413 }
7414 if (implicit_score) {
7415 sort_flds.unshift({ field: '$score', direction: 'desc' });
7416 }
7417 // without a search.query, all items will have the same score
7418 }
7419 else {
7420 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
7421 }
7422 // build function
7423 const sort_flds_count = sort_flds.length;
7424 if (!sort_flds_count) {
7425 return null;
7426 }
7427 return function (a, b) {
7428 var result, field;
7429 for (let sort_fld of sort_flds) {
7430 field = sort_fld.field;
7431 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
7432 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
7433 if (result)
7434 return result;
7435 }
7436 return 0;
7437 };
7438 }
7439 ;
7440 /**
7441 * Parses a search query and returns an object
7442 * with tokens and fields ready to be populated
7443 * with results.
7444 *
7445 */
7446 prepareSearch(query, optsUser) {
7447 const weights = {};
7448 var options = Object.assign({}, optsUser);
7449 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
7450 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
7451 // convert fields to new format
7452 if (options.fields) {
7453 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
7454 const fields = [];
7455 options.fields.forEach((field) => {
7456 if (typeof field == 'string') {
7457 field = { field: field, weight: 1 };
7458 }
7459 fields.push(field);
7460 weights[field.field] = ('weight' in field) ? field.weight : 1;
7461 });
7462 options.fields = fields;
7463 }
7464 return {
7465 options: options,
7466 query: query.toLowerCase().trim(),
7467 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
7468 total: 0,
7469 items: [],
7470 weights: weights,
7471 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
7472 };
7473 }
7474 ;
7475 /**
7476 * Searches through all items and returns a sorted array of matches.
7477 *
7478 */
7479 search(query, options) {
7480 var self = this, score, search;
7481 search = this.prepareSearch(query, options);
7482 options = search.options;
7483 query = search.query;
7484 // generate result scoring function
7485 const fn_score = options.score || self._getScoreFunction(search);
7486 // perform search and sort
7487 if (query.length) {
7488 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
7489 score = fn_score(item);
7490 if (options.filter === false || score > 0) {
7491 search.items.push({ 'score': score, 'id': id });
7492 }
7493 });
7494 }
7495 else {
7496 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
7497 search.items.push({ 'score': 1, 'id': id });
7498 });
7499 }
7500 const fn_sort = self._getSortFunction(search);
7501 if (fn_sort)
7502 search.items.sort(fn_sort);
7503 // apply limits
7504 search.total = search.items.length;
7505 if (typeof options.limit === 'number') {
7506 search.items = search.items.slice(0, options.limit);
7507 }
7508 return search;
7509 }
7510 ;
7511 }
7512
7513
7514 //# sourceMappingURL=sifter.js.map
7515
7516 /***/ },
7517
7518 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
7519 /*!*********************************************************!*\
7520 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
7521 \*********************************************************/
7522 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7523
7524 "use strict";
7525 __webpack_require__.r(__webpack_exports__);
7526
7527 //# sourceMappingURL=types.js.map
7528
7529 /***/ },
7530
7531 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
7532 /*!*********************************************************!*\
7533 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
7534 \*********************************************************/
7535 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7536
7537 "use strict";
7538 __webpack_require__.r(__webpack_exports__);
7539 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7540 /* harmony export */ cmp: () => (/* binding */ cmp),
7541 /* harmony export */ getAttr: () => (/* binding */ getAttr),
7542 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
7543 /* harmony export */ iterate: () => (/* binding */ iterate),
7544 /* harmony export */ propToArray: () => (/* binding */ propToArray),
7545 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
7546 /* harmony export */ });
7547 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7548
7549 /**
7550 * A property getter resolving dot-notation
7551 * @param {Object} obj The root object to fetch property on
7552 * @param {String} name The optionally dotted property name to fetch
7553 * @return {Object} The resolved property value
7554 */
7555 const getAttr = (obj, name) => {
7556 if (!obj)
7557 return;
7558 return obj[name];
7559 };
7560 /**
7561 * A property getter resolving dot-notation
7562 * @param {Object} obj The root object to fetch property on
7563 * @param {String} name The optionally dotted property name to fetch
7564 * @return {Object} The resolved property value
7565 */
7566 const getAttrNesting = (obj, name) => {
7567 if (!obj)
7568 return;
7569 var part, names = name.split(".");
7570 while ((part = names.shift()) && (obj = obj[part]))
7571 ;
7572 return obj;
7573 };
7574 /**
7575 * Calculates how close of a match the
7576 * given value is against a search token.
7577 *
7578 */
7579 const scoreValue = (value, token, weight) => {
7580 var score, pos;
7581 if (!value)
7582 return 0;
7583 value = value + '';
7584 if (token.regex == null)
7585 return 0;
7586 pos = value.search(token.regex);
7587 if (pos === -1)
7588 return 0;
7589 score = token.string.length / value.length;
7590 if (pos === 0)
7591 score += 0.5;
7592 return score * weight;
7593 };
7594 /**
7595 * Cast object property to an array if it exists and has a value
7596 *
7597 */
7598 const propToArray = (obj, key) => {
7599 var value = obj[key];
7600 if (typeof value == 'function')
7601 return value;
7602 if (value && !Array.isArray(value)) {
7603 obj[key] = [value];
7604 }
7605 };
7606 /**
7607 * Iterates over arrays and hashes.
7608 *
7609 * ```
7610 * iterate(this.items, function(item, id) {
7611 * // invoked for each item
7612 * });
7613 * ```
7614 *
7615 */
7616 const iterate = (object, callback) => {
7617 if (Array.isArray(object)) {
7618 object.forEach(callback);
7619 }
7620 else {
7621 for (var key in object) {
7622 if (object.hasOwnProperty(key)) {
7623 callback(object[key], key);
7624 }
7625 }
7626 }
7627 };
7628 const cmp = (a, b) => {
7629 if (typeof a === 'number' && typeof b === 'number') {
7630 return a > b ? 1 : (a < b ? -1 : 0);
7631 }
7632 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
7633 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
7634 if (a > b)
7635 return 1;
7636 if (b > a)
7637 return -1;
7638 return 0;
7639 };
7640 //# sourceMappingURL=utils.js.map
7641
7642 /***/ },
7643
7644 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
7645 /*!*******************************************************************!*\
7646 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
7647 \*******************************************************************/
7648 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7649
7650 "use strict";
7651 __webpack_require__.r(__webpack_exports__);
7652 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7653 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
7654 /* harmony export */ asciifold: () => (/* binding */ asciifold),
7655 /* harmony export */ code_points: () => (/* binding */ code_points),
7656 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
7657 /* harmony export */ generateMap: () => (/* binding */ generateMap),
7658 /* harmony export */ generateSets: () => (/* binding */ generateSets),
7659 /* harmony export */ generator: () => (/* binding */ generator),
7660 /* harmony export */ getPattern: () => (/* binding */ getPattern),
7661 /* harmony export */ initialize: () => (/* binding */ initialize),
7662 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
7663 /* harmony export */ normalize: () => (/* binding */ normalize),
7664 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
7665 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
7666 /* harmony export */ });
7667 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
7668 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
7669
7670
7671 const code_points = [[0, 65535]];
7672 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
7673 let unicode_map;
7674 let multi_char_reg;
7675 const max_char_length = 3;
7676 const latin_convert = {};
7677 const latin_condensed = {
7678 '/': '⁄∕',
7679 '0': '߀',
7680 "a": "ⱥɐɑ",
7681 "aa": "ꜳ",
7682 "ae": "æǽǣ",
7683 "ao": "ꜵ",
7684 "au": "ꜷ",
7685 "av": "ꜹꜻ",
7686 "ay": "ꜽ",
7687 "b": "ƀɓƃ",
7688 "c": "ꜿƈȼↄ",
7689 "d": "đɗɖᴅƌꮷԁɦ",
7690 "e": "ɛǝᴇɇ",
7691 "f": "ꝼƒ",
7692 "g": "ǥɠꞡᵹꝿɢ",
7693 "h": "ħⱨⱶɥ",
7694 "i": "ɨı",
7695 "j": "ɉȷ",
7696 "k": "ƙⱪꝁꝃꝅꞣ",
7697 "l": "łƚɫⱡꝉꝇꞁɭ",
7698 "m": "ɱɯϻ",
7699 "n": "ꞥƞɲꞑᴎлԉ",
7700 "o": "øǿɔɵꝋꝍᴑ",
7701 "oe": "œ",
7702 "oi": "ƣ",
7703 "oo": "ꝏ",
7704 "ou": "ȣ",
7705 "p": "ƥᵽꝑꝓꝕρ",
7706 "q": "ꝗꝙɋ",
7707 "r": "ɍɽꝛꞧꞃ",
7708 "s": "ßȿꞩꞅʂ",
7709 "t": "ŧƭʈⱦꞇ",
7710 "th": "þ",
7711 "tz": "ꜩ",
7712 "u": "ʉ",
7713 "v": "ʋꝟʌ",
7714 "vy": "ꝡ",
7715 "w": "ⱳ",
7716 "y": "ƴɏỿ",
7717 "z": "ƶȥɀⱬꝣ",
7718 "hv": "ƕ"
7719 };
7720 for (let latin in latin_condensed) {
7721 let unicode = latin_condensed[latin] || '';
7722 for (let i = 0; i < unicode.length; i++) {
7723 let char = unicode.substring(i, i + 1);
7724 latin_convert[char] = latin;
7725 }
7726 }
7727 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
7728 /**
7729 * Initialize the unicode_map from the give code point ranges
7730 */
7731 const initialize = (_code_points) => {
7732 if (unicode_map !== undefined)
7733 return;
7734 unicode_map = generateMap(_code_points || code_points);
7735 };
7736 /**
7737 * Helper method for normalize a string
7738 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
7739 */
7740 const normalize = (str, form = 'NFKD') => str.normalize(form);
7741 /**
7742 * Remove accents without reordering string
7743 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
7744 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
7745 */
7746 const asciifold = (str) => {
7747 return Array.from(str).reduce(
7748 /**
7749 * @param {string} result
7750 * @param {string} char
7751 */
7752 (result, char) => {
7753 return result + _asciifold(char);
7754 }, '');
7755 };
7756 const _asciifold = (str) => {
7757 str = normalize(str)
7758 .toLowerCase()
7759 .replace(convert_pat, (/** @type {string} */ char) => {
7760 return latin_convert[char] || '';
7761 });
7762 //return str;
7763 return normalize(str, 'NFC');
7764 };
7765 /**
7766 * Generate a list of unicode variants from the list of code points
7767 */
7768 function* generator(code_points) {
7769 for (const [code_point_min, code_point_max] of code_points) {
7770 for (let i = code_point_min; i <= code_point_max; i++) {
7771 let composed = String.fromCharCode(i);
7772 let folded = asciifold(composed);
7773 if (folded == composed.toLowerCase()) {
7774 continue;
7775 }
7776 // skip when folded is a string longer than 3 characters long
7777 // bc the resulting regex patterns will be long
7778 // eg:
7779 // folded صلى الله عليه وسلم length 18 code point 65018
7780 // folded جل جلاله length 8 code point 65019
7781 if (folded.length > max_char_length) {
7782 continue;
7783 }
7784 if (folded.length == 0) {
7785 continue;
7786 }
7787 yield { folded: folded, composed: composed, code_point: i };
7788 }
7789 }
7790 }
7791 /**
7792 * Generate a unicode map from the list of code points
7793 */
7794 const generateSets = (code_points) => {
7795 const unicode_sets = {};
7796 const addMatching = (folded, to_add) => {
7797 /** @type {Set<string>} */
7798 const folded_set = unicode_sets[folded] || new Set();
7799 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
7800 if (to_add.match(patt)) {
7801 return;
7802 }
7803 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
7804 unicode_sets[folded] = folded_set;
7805 };
7806 for (let value of generator(code_points)) {
7807 addMatching(value.folded, value.folded);
7808 addMatching(value.folded, value.composed);
7809 }
7810 return unicode_sets;
7811 };
7812 /**
7813 * Generate a unicode map from the list of code points
7814 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
7815 */
7816 const generateMap = (code_points) => {
7817 const unicode_sets = generateSets(code_points);
7818 const unicode_map = {};
7819 let multi_char = [];
7820 for (let folded in unicode_sets) {
7821 let set = unicode_sets[folded];
7822 if (set) {
7823 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
7824 }
7825 if (folded.length > 1) {
7826 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
7827 }
7828 }
7829 multi_char.sort((a, b) => b.length - a.length);
7830 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
7831 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
7832 return unicode_map;
7833 };
7834 /**
7835 * Map each element of an array from its folded value to all possible unicode matches
7836 */
7837 const mapSequence = (strings, min_replacement = 1) => {
7838 let chars_replaced = 0;
7839 strings = strings.map((str) => {
7840 if (unicode_map[str]) {
7841 chars_replaced += str.length;
7842 }
7843 return unicode_map[str] || str;
7844 });
7845 if (chars_replaced >= min_replacement) {
7846 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
7847 }
7848 return '';
7849 };
7850 /**
7851 * Convert a short string and split it into all possible patterns
7852 * Keep a pattern only if min_replacement is met
7853 *
7854 * 'abc'
7855 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
7856 * => ['abc-pattern','ab-c-pattern'...]
7857 */
7858 const substringsToPattern = (str, min_replacement = 1) => {
7859 min_replacement = Math.max(min_replacement, str.length - 1);
7860 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
7861 return mapSequence(sub_pat, min_replacement);
7862 }));
7863 };
7864 /**
7865 * Convert an array of sequences into a pattern
7866 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
7867 */
7868 const sequencesToPattern = (sequences, all = true) => {
7869 let min_replacement = sequences.length > 1 ? 1 : 0;
7870 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
7871 let seq = [];
7872 const len = all ? sequence.length() : sequence.length() - 1;
7873 for (let j = 0; j < len; j++) {
7874 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
7875 }
7876 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
7877 }));
7878 };
7879 /**
7880 * Return true if the sequence is already in the sequences
7881 */
7882 const inSequences = (needle_seq, sequences) => {
7883 for (const seq of sequences) {
7884 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
7885 continue;
7886 }
7887 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
7888 continue;
7889 }
7890 let needle_parts = needle_seq.parts;
7891 const filter = (part) => {
7892 for (const needle_part of needle_parts) {
7893 if (needle_part.start === part.start && needle_part.substr === part.substr) {
7894 return false;
7895 }
7896 if (part.length == 1 || needle_part.length == 1) {
7897 continue;
7898 }
7899 // check for overlapping parts
7900 // a = ['::=','==']
7901 // b = ['::','===']
7902 // a = ['r','sm']
7903 // b = ['rs','m']
7904 if (part.start < needle_part.start && part.end > needle_part.start) {
7905 return true;
7906 }
7907 if (needle_part.start < part.start && needle_part.end > part.start) {
7908 return true;
7909 }
7910 }
7911 return false;
7912 };
7913 let filtered = seq.parts.filter(filter);
7914 if (filtered.length > 0) {
7915 continue;
7916 }
7917 return true;
7918 }
7919 return false;
7920 };
7921 class Sequence {
7922 parts;
7923 substrs;
7924 start;
7925 end;
7926 constructor() {
7927 this.parts = [];
7928 this.substrs = [];
7929 this.start = 0;
7930 this.end = 0;
7931 }
7932 add(part) {
7933 if (part) {
7934 this.parts.push(part);
7935 this.substrs.push(part.substr);
7936 this.start = Math.min(part.start, this.start);
7937 this.end = Math.max(part.end, this.end);
7938 }
7939 }
7940 last() {
7941 return this.parts[this.parts.length - 1];
7942 }
7943 length() {
7944 return this.parts.length;
7945 }
7946 clone(position, last_piece) {
7947 let clone = new Sequence();
7948 let parts = JSON.parse(JSON.stringify(this.parts));
7949 let last_part = parts.pop();
7950 for (const part of parts) {
7951 clone.add(part);
7952 }
7953 let last_substr = last_piece.substr.substring(0, position - last_part.start);
7954 let clone_last_len = last_substr.length;
7955 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
7956 return clone;
7957 }
7958 }
7959 /**
7960 * Expand a regular expression pattern to include unicode variants
7961 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
7962 *
7963 * Issue:
7964 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
7965 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
7966 *
7967 * İIJ = IIJ = ⅡJ
7968 *
7969 * 1/2/4
7970 */
7971 const getPattern = (str) => {
7972 initialize();
7973 str = asciifold(str);
7974 let pattern = '';
7975 let sequences = [new Sequence()];
7976 for (let i = 0; i < str.length; i++) {
7977 let substr = str.substring(i);
7978 let match = substr.match(multi_char_reg);
7979 const char = str.substring(i, i + 1);
7980 const match_str = match ? match[0] : null;
7981 // loop through sequences
7982 // add either the char or multi_match
7983 let overlapping = [];
7984 let added_types = new Set();
7985 for (const sequence of sequences) {
7986 const last_piece = sequence.last();
7987 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
7988 // if we have a multi match
7989 if (match_str) {
7990 const len = match_str.length;
7991 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
7992 added_types.add('1');
7993 }
7994 else {
7995 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
7996 added_types.add('2');
7997 }
7998 }
7999 else if (match_str) {
8000 let clone = sequence.clone(i, last_piece);
8001 const len = match_str.length;
8002 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8003 overlapping.push(clone);
8004 }
8005 else {
8006 // don't add char
8007 // adding would create invalid patterns: 234 => [2,34,4]
8008 added_types.add('3');
8009 }
8010 }
8011 // if we have overlapping
8012 if (overlapping.length > 0) {
8013 // ['ii','iii'] before ['i','i','iii']
8014 overlapping = overlapping.sort((a, b) => {
8015 return a.length() - b.length();
8016 });
8017 for (let clone of overlapping) {
8018 // don't add if we already have an equivalent sequence
8019 if (inSequences(clone, sequences)) {
8020 continue;
8021 }
8022 sequences.push(clone);
8023 }
8024 continue;
8025 }
8026 // if we haven't done anything unique
8027 // clean up the patterns
8028 // helps keep patterns smaller
8029 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8030 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8031 pattern += sequencesToPattern(sequences, false);
8032 let new_seq = new Sequence();
8033 const old_seq = sequences[0];
8034 if (old_seq) {
8035 new_seq.add(old_seq.last());
8036 }
8037 sequences = [new_seq];
8038 }
8039 }
8040 pattern += sequencesToPattern(sequences, true);
8041 return pattern;
8042 };
8043
8044 //# sourceMappingURL=index.js.map
8045
8046 /***/ },
8047
8048 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8049 /*!*******************************************************************!*\
8050 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8051 \*******************************************************************/
8052 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8053
8054 "use strict";
8055 __webpack_require__.r(__webpack_exports__);
8056 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8057 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8058 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8059 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8060 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8061 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8062 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8063 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8064 /* harmony export */ });
8065 /**
8066 * Convert array of strings to a regular expression
8067 * ex ['ab','a'] => (?:ab|a)
8068 * ex ['a','b'] => [ab]
8069 */
8070 const arrayToPattern = (chars) => {
8071 chars = chars.filter(Boolean);
8072 if (chars.length < 2) {
8073 return chars[0] || '';
8074 }
8075 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8076 };
8077 const sequencePattern = (array) => {
8078 if (!hasDuplicates(array)) {
8079 return array.join('');
8080 }
8081 let pattern = '';
8082 let prev_char_count = 0;
8083 const prev_pattern = () => {
8084 if (prev_char_count > 1) {
8085 pattern += '{' + prev_char_count + '}';
8086 }
8087 };
8088 array.forEach((char, i) => {
8089 if (char === array[i - 1]) {
8090 prev_char_count++;
8091 return;
8092 }
8093 prev_pattern();
8094 pattern += char;
8095 prev_char_count = 1;
8096 });
8097 prev_pattern();
8098 return pattern;
8099 };
8100 /**
8101 * Convert array of strings to a regular expression
8102 * ex ['ab','a'] => (?:ab|a)
8103 * ex ['a','b'] => [ab]
8104 */
8105 const setToPattern = (chars) => {
8106 let array = Array.from(chars);
8107 return arrayToPattern(array);
8108 };
8109 /**
8110 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8111 */
8112 const hasDuplicates = (array) => {
8113 return (new Set(array)).size !== array.length;
8114 };
8115 /**
8116 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8117 */
8118 const escape_regex = (str) => {
8119 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8120 };
8121 /**
8122 * Return the max length of array values
8123 */
8124 const maxValueLength = (array) => {
8125 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8126 };
8127 const unicodeLength = (str) => {
8128 return Array.from(str).length;
8129 };
8130 //# sourceMappingURL=regex.js.map
8131
8132 /***/ },
8133
8134 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8135 /*!*********************************************************************!*\
8136 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8137 \*********************************************************************/
8138 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8139
8140 "use strict";
8141 __webpack_require__.r(__webpack_exports__);
8142 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8143 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8144 /* harmony export */ });
8145 /**
8146 * Get all possible combinations of substrings that add up to the given string
8147 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8148 */
8149 const allSubstrings = (input) => {
8150 if (input.length === 1)
8151 return [[input]];
8152 let result = [];
8153 const start = input.substring(1);
8154 const suba = allSubstrings(start);
8155 suba.forEach(function (subresult) {
8156 let tmp = subresult.slice(0);
8157 tmp[0] = input.charAt(0) + tmp[0];
8158 result.push(tmp);
8159 tmp = subresult.slice(0);
8160 tmp.unshift(input.charAt(0));
8161 result.push(tmp);
8162 });
8163 return result;
8164 };
8165 //# sourceMappingURL=strings.js.map
8166
8167 /***/ },
8168
8169 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8170 /*!*******************************************************!*\
8171 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8172 \*******************************************************/
8173 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8174
8175 "use strict";
8176 __webpack_require__.r(__webpack_exports__);
8177 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8178 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8179 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8180 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8181 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8182 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8183 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8184 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8185 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8186 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8187 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8188 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8189 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8190 /* harmony export */ });
8191 const KEY_A = 65;
8192 const KEY_RETURN = 13;
8193 const KEY_ESC = 27;
8194 const KEY_LEFT = 37;
8195 const KEY_UP = 38;
8196 const KEY_RIGHT = 39;
8197 const KEY_DOWN = 40;
8198 const KEY_BACKSPACE = 8;
8199 const KEY_DELETE = 46;
8200 const KEY_TAB = 9;
8201 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8202 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8203 //# sourceMappingURL=constants.js.map
8204
8205 /***/ },
8206
8207 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8208 /*!***************************************************************!*\
8209 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8210 \***************************************************************/
8211 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8212
8213 "use strict";
8214 __webpack_require__.r(__webpack_exports__);
8215 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8216 /* harmony export */ highlight: () => (/* binding */ highlight),
8217 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8218 /* harmony export */ });
8219 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8220 /**
8221 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
8222 * Highlights arbitrary terms in a node.
8223 *
8224 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
8225 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
8226 */
8227
8228 const highlight = (element, regex) => {
8229 if (regex === null)
8230 return;
8231 // convet string to regex
8232 if (typeof regex === 'string') {
8233 if (!regex.length)
8234 return;
8235 regex = new RegExp(regex, 'i');
8236 }
8237 // Wrap matching part of text node with highlighting <span>, e.g.
8238 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8239 const highlightText = (node) => {
8240 var match = node.data.match(regex);
8241 if (match && node.data.length > 0) {
8242 var spannode = document.createElement('span');
8243 spannode.className = 'highlight';
8244 var middlebit = node.splitText(match.index);
8245 middlebit.splitText(match[0].length);
8246 var middleclone = middlebit.cloneNode(true);
8247 spannode.appendChild(middleclone);
8248 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8249 return 1;
8250 }
8251 return 0;
8252 };
8253 // Recurse element node, looking for child text nodes to highlight, unless element
8254 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8255 const highlightChildren = (node) => {
8256 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8257 Array.from(node.childNodes).forEach(element => {
8258 highlightRecursive(element);
8259 });
8260 }
8261 };
8262 const highlightRecursive = (node) => {
8263 if (node.nodeType === 3) {
8264 return highlightText(node);
8265 }
8266 highlightChildren(node);
8267 return 0;
8268 };
8269 highlightRecursive(element);
8270 };
8271 /**
8272 * removeHighlight fn copied from highlight v5 and
8273 * edited to remove with(), pass js strict mode, and use without jquery
8274 */
8275 const removeHighlight = (el) => {
8276 var elements = el.querySelectorAll("span.highlight");
8277 Array.prototype.forEach.call(elements, function (el) {
8278 var parent = el.parentNode;
8279 parent.replaceChild(el.firstChild, el);
8280 parent.normalize();
8281 });
8282 };
8283 //# sourceMappingURL=highlight.js.map
8284
8285 /***/ },
8286
8287 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8288 /*!****************************************************************!*\
8289 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8290 \****************************************************************/
8291 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8292
8293 "use strict";
8294 __webpack_require__.r(__webpack_exports__);
8295 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8296 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8297 /* harmony export */ });
8298 /**
8299 * MicroEvent - to make any js object an event emitter
8300 *
8301 * - pure javascript - server compatible, browser compatible
8302 * - dont rely on the browser doms
8303 * - super simple - you get it immediatly, no mistery, no magic involved
8304 *
8305 * @author Jerome Etienne (https://github.com/jeromeetienne)
8306 */
8307 /**
8308 * Execute callback for each event in space separated list of event names
8309 *
8310 */
8311 function forEvents(events, callback) {
8312 events.split(/\s+/).forEach((event) => {
8313 callback(event);
8314 });
8315 }
8316 class MicroEvent {
8317 constructor() {
8318 this._events = {};
8319 }
8320 on(events, fct) {
8321 forEvents(events, (event) => {
8322 const event_array = this._events[event] || [];
8323 event_array.push(fct);
8324 this._events[event] = event_array;
8325 });
8326 }
8327 off(events, fct) {
8328 var n = arguments.length;
8329 if (n === 0) {
8330 this._events = {};
8331 return;
8332 }
8333 forEvents(events, (event) => {
8334 if (n === 1) {
8335 delete this._events[event];
8336 return;
8337 }
8338 const event_array = this._events[event];
8339 if (event_array === undefined)
8340 return;
8341 event_array.splice(event_array.indexOf(fct), 1);
8342 this._events[event] = event_array;
8343 });
8344 }
8345 trigger(events, ...args) {
8346 var self = this;
8347 forEvents(events, (event) => {
8348 const event_array = self._events[event];
8349 if (event_array === undefined)
8350 return;
8351 event_array.forEach(fct => {
8352 fct.apply(self, args);
8353 });
8354 });
8355 }
8356 }
8357 ;
8358 //# sourceMappingURL=microevent.js.map
8359
8360 /***/ },
8361
8362 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
8363 /*!*****************************************************************!*\
8364 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
8365 \*****************************************************************/
8366 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8367
8368 "use strict";
8369 __webpack_require__.r(__webpack_exports__);
8370 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8371 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
8372 /* harmony export */ });
8373 /**
8374 * microplugin.js
8375 * Copyright (c) 2013 Brian Reavis & contributors
8376 *
8377 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8378 * file except in compliance with the License. You may obtain a copy of the License at:
8379 * http://www.apache.org/licenses/LICENSE-2.0
8380 *
8381 * Unless required by applicable law or agreed to in writing, software distributed under
8382 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8383 * ANY KIND, either express or implied. See the License for the specific language
8384 * governing permissions and limitations under the License.
8385 *
8386 * @author Brian Reavis <brian@thirdroute.com>
8387 */
8388 function MicroPlugin(Interface) {
8389 Interface.plugins = {};
8390 return class extends Interface {
8391 constructor() {
8392 super(...arguments);
8393 this.plugins = {
8394 names: [],
8395 settings: {},
8396 requested: {},
8397 loaded: {}
8398 };
8399 }
8400 /**
8401 * Registers a plugin.
8402 *
8403 * @param {function} fn
8404 */
8405 static define(name, fn) {
8406 Interface.plugins[name] = {
8407 'name': name,
8408 'fn': fn
8409 };
8410 }
8411 /**
8412 * Initializes the listed plugins (with options).
8413 * Acceptable formats:
8414 *
8415 * List (without options):
8416 * ['a', 'b', 'c']
8417 *
8418 * List (with options):
8419 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
8420 *
8421 * Hash (with options):
8422 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
8423 *
8424 * @param {array|object} plugins
8425 */
8426 initializePlugins(plugins) {
8427 var key, name;
8428 const self = this;
8429 const queue = [];
8430 if (Array.isArray(plugins)) {
8431 plugins.forEach((plugin) => {
8432 if (typeof plugin === 'string') {
8433 queue.push(plugin);
8434 }
8435 else {
8436 self.plugins.settings[plugin.name] = plugin.options;
8437 queue.push(plugin.name);
8438 }
8439 });
8440 }
8441 else if (plugins) {
8442 for (key in plugins) {
8443 if (plugins.hasOwnProperty(key)) {
8444 self.plugins.settings[key] = plugins[key];
8445 queue.push(key);
8446 }
8447 }
8448 }
8449 while (name = queue.shift()) {
8450 self.require(name);
8451 }
8452 }
8453 loadPlugin(name) {
8454 var self = this;
8455 var plugins = self.plugins;
8456 var plugin = Interface.plugins[name];
8457 if (!Interface.plugins.hasOwnProperty(name)) {
8458 throw new Error('Unable to find "' + name + '" plugin');
8459 }
8460 plugins.requested[name] = true;
8461 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
8462 plugins.names.push(name);
8463 }
8464 /**
8465 * Initializes a plugin.
8466 *
8467 */
8468 require(name) {
8469 var self = this;
8470 var plugins = self.plugins;
8471 if (!self.plugins.loaded.hasOwnProperty(name)) {
8472 if (plugins.requested[name]) {
8473 throw new Error('Plugin has circular dependency ("' + name + '")');
8474 }
8475 self.loadPlugin(name);
8476 }
8477 return plugins.loaded[name];
8478 }
8479 };
8480 }
8481 //# sourceMappingURL=microplugin.js.map
8482
8483 /***/ },
8484
8485 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
8486 /*!******************************************************!*\
8487 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
8488 \******************************************************/
8489 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8490
8491 "use strict";
8492 __webpack_require__.r(__webpack_exports__);
8493 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8494 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8495 /* harmony export */ });
8496 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
8497 options: [],
8498 optgroups: [],
8499 plugins: [],
8500 delimiter: ',',
8501 splitOn: null, // regexp or string for splitting up values from a paste command
8502 persist: true,
8503 diacritics: true,
8504 create: null,
8505 createOnBlur: false,
8506 createFilter: null,
8507 highlight: true,
8508 openOnFocus: true,
8509 shouldOpen: null,
8510 maxOptions: 50,
8511 maxItems: null,
8512 hideSelected: null,
8513 duplicates: false,
8514 addPrecedence: false,
8515 selectOnTab: false,
8516 preload: null,
8517 allowEmptyOption: false,
8518 //closeAfterSelect: false,
8519 refreshThrottle: 300,
8520 loadThrottle: 300,
8521 loadingClass: 'loading',
8522 dataAttr: null, //'data-data',
8523 optgroupField: 'optgroup',
8524 valueField: 'value',
8525 labelField: 'text',
8526 disabledField: 'disabled',
8527 optgroupLabelField: 'label',
8528 optgroupValueField: 'value',
8529 lockOptgroupOrder: false,
8530 sortField: '$order',
8531 searchField: ['text'],
8532 searchConjunction: 'and',
8533 mode: null,
8534 wrapperClass: 'ts-wrapper',
8535 controlClass: 'ts-control',
8536 dropdownClass: 'ts-dropdown',
8537 dropdownContentClass: 'ts-dropdown-content',
8538 itemClass: 'item',
8539 optionClass: 'option',
8540 dropdownParent: null,
8541 controlInput: '<input type="text" autocomplete="off" size="1" />',
8542 copyClassesToDropdown: false,
8543 placeholder: null,
8544 hidePlaceholder: null,
8545 shouldLoad: function (query) {
8546 return query.length > 0;
8547 },
8548 /*
8549 load : null, // function(query, callback) { ... }
8550 score : null, // function(search) { ... }
8551 onInitialize : null, // function() { ... }
8552 onChange : null, // function(value) { ... }
8553 onItemAdd : null, // function(value, $item) { ... }
8554 onItemRemove : null, // function(value) { ... }
8555 onClear : null, // function() { ... }
8556 onOptionAdd : null, // function(value, data) { ... }
8557 onOptionRemove : null, // function(value) { ... }
8558 onOptionClear : null, // function() { ... }
8559 onOptionGroupAdd : null, // function(id, data) { ... }
8560 onOptionGroupRemove : null, // function(id) { ... }
8561 onOptionGroupClear : null, // function() { ... }
8562 onDropdownOpen : null, // function(dropdown) { ... }
8563 onDropdownClose : null, // function(dropdown) { ... }
8564 onType : null, // function(str) { ... }
8565 onDelete : null, // function(values) { ... }
8566 */
8567 render: {
8568 /*
8569 item: null,
8570 optgroup: null,
8571 optgroup_header: null,
8572 option: null,
8573 option_create: null
8574 */
8575 }
8576 });
8577 //# sourceMappingURL=defaults.js.map
8578
8579 /***/ },
8580
8581 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
8582 /*!*********************************************************!*\
8583 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
8584 \*********************************************************/
8585 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8586
8587 "use strict";
8588 __webpack_require__.r(__webpack_exports__);
8589 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8590 /* harmony export */ "default": () => (/* binding */ getSettings)
8591 /* harmony export */ });
8592 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
8593 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8594
8595
8596 function getSettings(input, settings_user) {
8597 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
8598 var attr_data = settings.dataAttr;
8599 var field_label = settings.labelField;
8600 var field_value = settings.valueField;
8601 var field_disabled = settings.disabledField;
8602 var field_optgroup = settings.optgroupField;
8603 var field_optgroup_label = settings.optgroupLabelField;
8604 var field_optgroup_value = settings.optgroupValueField;
8605 var tag_name = input.tagName.toLowerCase();
8606 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
8607 if (!placeholder && !settings.allowEmptyOption) {
8608 let option = input.querySelector('option[value=""]');
8609 if (option) {
8610 placeholder = option.textContent;
8611 }
8612 }
8613 var settings_element = {
8614 placeholder: placeholder,
8615 options: [],
8616 optgroups: [],
8617 items: [],
8618 maxItems: null,
8619 };
8620 /**
8621 * Initialize from a <select> element.
8622 *
8623 */
8624 var init_select = () => {
8625 var tagName;
8626 var options = settings_element.options;
8627 var optionsMap = {};
8628 var group_count = 1;
8629 let $order = 0;
8630 var readData = (el) => {
8631 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
8632 var json = attr_data && data[attr_data];
8633 if (typeof json === 'string' && json.length) {
8634 data = Object.assign(data, JSON.parse(json));
8635 }
8636 return data;
8637 };
8638 var addOption = (option, group) => {
8639 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
8640 if (value == null)
8641 return;
8642 if (!value && !settings.allowEmptyOption)
8643 return;
8644 // if the option already exists, it's probably been
8645 // duplicated in another optgroup. in this case, push
8646 // the current group to the "optgroup" property on the
8647 // existing option so that it's rendered in both places.
8648 if (optionsMap.hasOwnProperty(value)) {
8649 if (group) {
8650 var arr = optionsMap[value][field_optgroup];
8651 if (!arr) {
8652 optionsMap[value][field_optgroup] = group;
8653 }
8654 else if (!Array.isArray(arr)) {
8655 optionsMap[value][field_optgroup] = [arr, group];
8656 }
8657 else {
8658 arr.push(group);
8659 }
8660 }
8661 }
8662 else {
8663 var option_data = readData(option);
8664 option_data[field_label] = option_data[field_label] || option.textContent;
8665 option_data[field_value] = option_data[field_value] || value;
8666 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
8667 option_data[field_optgroup] = option_data[field_optgroup] || group;
8668 option_data.$option = option;
8669 option_data.$order = option_data.$order || ++$order;
8670 optionsMap[value] = option_data;
8671 options.push(option_data);
8672 }
8673 if (option.selected) {
8674 settings_element.items.push(value);
8675 }
8676 };
8677 var addGroup = (optgroup) => {
8678 var id, optgroup_data;
8679 optgroup_data = readData(optgroup);
8680 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
8681 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
8682 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
8683 optgroup_data.$order = optgroup_data.$order || ++$order;
8684 settings_element.optgroups.push(optgroup_data);
8685 id = optgroup_data[field_optgroup_value];
8686 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
8687 addOption(option, id);
8688 });
8689 };
8690 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
8691 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
8692 tagName = child.tagName.toLowerCase();
8693 if (tagName === 'optgroup') {
8694 addGroup(child);
8695 }
8696 else if (tagName === 'option') {
8697 addOption(child);
8698 }
8699 });
8700 };
8701 /**
8702 * Initialize from a <input type="text"> element.
8703 *
8704 */
8705 var init_textbox = () => {
8706 const data_raw = input.getAttribute(attr_data);
8707 if (!data_raw) {
8708 var value = input.value.trim() || '';
8709 if (!settings.allowEmptyOption && !value.length)
8710 return;
8711 const values = value.split(settings.delimiter);
8712 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
8713 const option = {};
8714 option[field_label] = value;
8715 option[field_value] = value;
8716 settings_element.options.push(option);
8717 });
8718 settings_element.items = values;
8719 }
8720 else {
8721 settings_element.options = JSON.parse(data_raw);
8722 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
8723 settings_element.items.push(opt[field_value]);
8724 });
8725 }
8726 };
8727 if (tag_name === 'select') {
8728 init_select();
8729 }
8730 else {
8731 init_textbox();
8732 }
8733 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
8734 }
8735 ;
8736 //# sourceMappingURL=getSettings.js.map
8737
8738 /***/ },
8739
8740 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
8741 /*!***************************************************************************!*\
8742 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
8743 \***************************************************************************/
8744 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8745
8746 "use strict";
8747 __webpack_require__.r(__webpack_exports__);
8748 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8749 /* harmony export */ "default": () => (/* binding */ plugin)
8750 /* harmony export */ });
8751 /**
8752 * Tom Select v2.4.3
8753 * Licensed under the Apache License, Version 2.0 (the "License");
8754 */
8755
8756 /**
8757 * Converts a scalar to its best string representation
8758 * for hash keys and HTML attribute values.
8759 *
8760 * Transformations:
8761 * 'str' -> 'str'
8762 * null -> ''
8763 * undefined -> ''
8764 * true -> '1'
8765 * false -> '0'
8766 * 0 -> '0'
8767 * 1 -> '1'
8768 *
8769 */
8770
8771 /**
8772 * Iterates over arrays and hashes.
8773 *
8774 * ```
8775 * iterate(this.items, function(item, id) {
8776 * // invoked for each item
8777 * });
8778 * ```
8779 *
8780 */
8781 const iterate = (object, callback) => {
8782 if (Array.isArray(object)) {
8783 object.forEach(callback);
8784 } else {
8785 for (var key in object) {
8786 if (object.hasOwnProperty(key)) {
8787 callback(object[key], key);
8788 }
8789 }
8790 }
8791 };
8792
8793 /**
8794 * Remove css classes
8795 *
8796 */
8797 const removeClasses = (elmts, ...classes) => {
8798 var norm_classes = classesArray(classes);
8799 elmts = castAsArray(elmts);
8800 elmts.map(el => {
8801 norm_classes.map(cls => {
8802 el.classList.remove(cls);
8803 });
8804 });
8805 };
8806
8807 /**
8808 * Return arguments
8809 *
8810 */
8811 const classesArray = args => {
8812 var classes = [];
8813 iterate(args, _classes => {
8814 if (typeof _classes === 'string') {
8815 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8816 }
8817 if (Array.isArray(_classes)) {
8818 classes = classes.concat(_classes);
8819 }
8820 });
8821 return classes.filter(Boolean);
8822 };
8823
8824 /**
8825 * Create an array from arg if it's not already an array
8826 *
8827 */
8828 const castAsArray = arg => {
8829 if (!Array.isArray(arg)) {
8830 arg = [arg];
8831 }
8832 return arg;
8833 };
8834
8835 /**
8836 * Get the index of an element amongst sibling nodes of the same type
8837 *
8838 */
8839 const nodeIndex = (el, amongst) => {
8840 if (!el) return -1;
8841 amongst = amongst || el.nodeName;
8842 var i = 0;
8843 while (el = el.previousElementSibling) {
8844 if (el.matches(amongst)) {
8845 i++;
8846 }
8847 }
8848 return i;
8849 };
8850
8851 /**
8852 * Plugin: "dropdown_input" (Tom Select)
8853 * Copyright (c) contributors
8854 *
8855 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8856 * file except in compliance with the License. You may obtain a copy of the License at:
8857 * http://www.apache.org/licenses/LICENSE-2.0
8858 *
8859 * Unless required by applicable law or agreed to in writing, software distributed under
8860 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8861 * ANY KIND, either express or implied. See the License for the specific language
8862 * governing permissions and limitations under the License.
8863 *
8864 */
8865
8866 function plugin () {
8867 var self = this;
8868
8869 /**
8870 * Moves the caret to the specified index.
8871 *
8872 * The input must be moved by leaving it in place and moving the
8873 * siblings, due to the fact that focus cannot be restored once lost
8874 * on mobile webkit devices
8875 *
8876 */
8877 self.hook('instead', 'setCaret', new_pos => {
8878 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
8879 new_pos = self.items.length;
8880 } else {
8881 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
8882 if (new_pos != self.caretPos && !self.isPending) {
8883 self.controlChildren().forEach((child, j) => {
8884 if (j < new_pos) {
8885 self.control_input.insertAdjacentElement('beforebegin', child);
8886 } else {
8887 self.control.appendChild(child);
8888 }
8889 });
8890 }
8891 }
8892 self.caretPos = new_pos;
8893 });
8894 self.hook('instead', 'moveCaret', direction => {
8895 if (!self.isFocused) return;
8896
8897 // move caret before or after selected items
8898 const last_active = self.getLastActive(direction);
8899 if (last_active) {
8900 const idx = nodeIndex(last_active);
8901 self.setCaret(direction > 0 ? idx + 1 : idx);
8902 self.setActiveItem();
8903 removeClasses(last_active, 'last-active');
8904
8905 // move caret left or right of current position
8906 } else {
8907 self.setCaret(self.caretPos + direction);
8908 }
8909 });
8910 }
8911
8912
8913 //# sourceMappingURL=plugin.js.map
8914
8915
8916 /***/ },
8917
8918 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
8919 /*!****************************************************************************!*\
8920 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
8921 \****************************************************************************/
8922 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8923
8924 "use strict";
8925 __webpack_require__.r(__webpack_exports__);
8926 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8927 /* harmony export */ "default": () => (/* binding */ plugin)
8928 /* harmony export */ });
8929 /**
8930 * Tom Select v2.4.3
8931 * Licensed under the Apache License, Version 2.0 (the "License");
8932 */
8933
8934 /**
8935 * Converts a scalar to its best string representation
8936 * for hash keys and HTML attribute values.
8937 *
8938 * Transformations:
8939 * 'str' -> 'str'
8940 * null -> ''
8941 * undefined -> ''
8942 * true -> '1'
8943 * false -> '0'
8944 * 0 -> '0'
8945 * 1 -> '1'
8946 *
8947 */
8948
8949 /**
8950 * Add event helper
8951 *
8952 */
8953 const addEvent = (target, type, callback, options) => {
8954 target.addEventListener(type, callback, options);
8955 };
8956
8957 /**
8958 * Plugin: "change_listener" (Tom Select)
8959 * Copyright (c) contributors
8960 *
8961 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8962 * file except in compliance with the License. You may obtain a copy of the License at:
8963 * http://www.apache.org/licenses/LICENSE-2.0
8964 *
8965 * Unless required by applicable law or agreed to in writing, software distributed under
8966 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8967 * ANY KIND, either express or implied. See the License for the specific language
8968 * governing permissions and limitations under the License.
8969 *
8970 */
8971
8972 function plugin () {
8973 addEvent(this.input, 'change', () => {
8974 this.sync();
8975 });
8976 }
8977
8978
8979 //# sourceMappingURL=plugin.js.map
8980
8981
8982 /***/ },
8983
8984 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
8985 /*!*****************************************************************************!*\
8986 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
8987 \*****************************************************************************/
8988 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8989
8990 "use strict";
8991 __webpack_require__.r(__webpack_exports__);
8992 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8993 /* harmony export */ "default": () => (/* binding */ plugin)
8994 /* harmony export */ });
8995 /**
8996 * Tom Select v2.4.3
8997 * Licensed under the Apache License, Version 2.0 (the "License");
8998 */
8999
9000 /**
9001 * Converts a scalar to its best string representation
9002 * for hash keys and HTML attribute values.
9003 *
9004 * Transformations:
9005 * 'str' -> 'str'
9006 * null -> ''
9007 * undefined -> ''
9008 * true -> '1'
9009 * false -> '0'
9010 * 0 -> '0'
9011 * 1 -> '1'
9012 *
9013 */
9014 const hash_key = value => {
9015 if (typeof value === 'undefined' || value === null) return null;
9016 return get_hash(value);
9017 };
9018 const get_hash = value => {
9019 if (typeof value === 'boolean') return value ? '1' : '0';
9020 return value + '';
9021 };
9022
9023 /**
9024 * Prevent default
9025 *
9026 */
9027 const preventDefault = (evt, stop = false) => {
9028 if (evt) {
9029 evt.preventDefault();
9030 if (stop) {
9031 evt.stopPropagation();
9032 }
9033 }
9034 };
9035
9036 /**
9037 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9038 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9039 *
9040 * param query should be {}
9041 */
9042 const getDom = query => {
9043 if (query.jquery) {
9044 return query[0];
9045 }
9046 if (query instanceof HTMLElement) {
9047 return query;
9048 }
9049 if (isHtmlString(query)) {
9050 var tpl = document.createElement('template');
9051 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9052 return tpl.content.firstChild;
9053 }
9054 return document.querySelector(query);
9055 };
9056 const isHtmlString = arg => {
9057 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9058 return true;
9059 }
9060 return false;
9061 };
9062
9063 /**
9064 * Plugin: "checkbox_options" (Tom Select)
9065 * Copyright (c) contributors
9066 *
9067 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9068 * file except in compliance with the License. You may obtain a copy of the License at:
9069 * http://www.apache.org/licenses/LICENSE-2.0
9070 *
9071 * Unless required by applicable law or agreed to in writing, software distributed under
9072 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9073 * ANY KIND, either express or implied. See the License for the specific language
9074 * governing permissions and limitations under the License.
9075 *
9076 */
9077
9078 function plugin (userOptions) {
9079 var self = this;
9080 var orig_onOptionSelect = self.onOptionSelect;
9081 self.settings.hideSelected = false;
9082 const cbOptions = Object.assign({
9083 // so that the user may add different ones as well
9084 className: "tomselect-checkbox",
9085 // the following default to the historic plugin's values
9086 checkedClassNames: undefined,
9087 uncheckedClassNames: undefined
9088 }, userOptions);
9089 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9090 if (toCheck) {
9091 checkbox.checked = true;
9092 if (cbOptions.uncheckedClassNames) {
9093 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9094 }
9095 if (cbOptions.checkedClassNames) {
9096 checkbox.classList.add(...cbOptions.checkedClassNames);
9097 }
9098 } else {
9099 checkbox.checked = false;
9100 if (cbOptions.checkedClassNames) {
9101 checkbox.classList.remove(...cbOptions.checkedClassNames);
9102 }
9103 if (cbOptions.uncheckedClassNames) {
9104 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9105 }
9106 }
9107 };
9108
9109 // update the checkbox for an option
9110 var UpdateCheckbox = function UpdateCheckbox(option) {
9111 setTimeout(() => {
9112 var checkbox = option.querySelector('input.' + cbOptions.className);
9113 if (checkbox instanceof HTMLInputElement) {
9114 UpdateChecked(checkbox, option.classList.contains('selected'));
9115 }
9116 }, 1);
9117 };
9118
9119 // add checkbox to option template
9120 self.hook('after', 'setupTemplates', () => {
9121 var orig_render_option = self.settings.render.option;
9122 self.settings.render.option = (data, escape_html) => {
9123 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9124 var checkbox = document.createElement('input');
9125 if (cbOptions.className) {
9126 checkbox.classList.add(cbOptions.className);
9127 }
9128 checkbox.addEventListener('click', function (evt) {
9129 preventDefault(evt);
9130 });
9131 checkbox.type = 'checkbox';
9132 const hashed = hash_key(data[self.settings.valueField]);
9133 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9134 rendered.prepend(checkbox);
9135 return rendered;
9136 };
9137 });
9138
9139 // uncheck when item removed
9140 self.on('item_remove', value => {
9141 var option = self.getOption(value);
9142 if (option) {
9143 // if dropdown hasn't been opened yet, the option won't exist
9144 option.classList.remove('selected'); // selected class won't be removed yet
9145 UpdateCheckbox(option);
9146 }
9147 });
9148
9149 // check when item added
9150 self.on('item_add', value => {
9151 var option = self.getOption(value);
9152 if (option) {
9153 // if dropdown hasn't been opened yet, the option won't exist
9154 UpdateCheckbox(option);
9155 }
9156 });
9157
9158 // remove items when selected option is clicked
9159 self.hook('instead', 'onOptionSelect', (evt, option) => {
9160 if (option.classList.contains('selected')) {
9161 option.classList.remove('selected');
9162 self.removeItem(option.dataset.value);
9163 self.refreshOptions();
9164 preventDefault(evt, true);
9165 return;
9166 }
9167 orig_onOptionSelect.call(self, evt, option);
9168 UpdateCheckbox(option);
9169 });
9170 }
9171
9172
9173 //# sourceMappingURL=plugin.js.map
9174
9175
9176 /***/ },
9177
9178 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9179 /*!*************************************************************************!*\
9180 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9181 \*************************************************************************/
9182 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9183
9184 "use strict";
9185 __webpack_require__.r(__webpack_exports__);
9186 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9187 /* harmony export */ "default": () => (/* binding */ plugin)
9188 /* harmony export */ });
9189 /**
9190 * Tom Select v2.4.3
9191 * Licensed under the Apache License, Version 2.0 (the "License");
9192 */
9193
9194 /**
9195 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9196 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9197 *
9198 * param query should be {}
9199 */
9200 const getDom = query => {
9201 if (query.jquery) {
9202 return query[0];
9203 }
9204 if (query instanceof HTMLElement) {
9205 return query;
9206 }
9207 if (isHtmlString(query)) {
9208 var tpl = document.createElement('template');
9209 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9210 return tpl.content.firstChild;
9211 }
9212 return document.querySelector(query);
9213 };
9214 const isHtmlString = arg => {
9215 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9216 return true;
9217 }
9218 return false;
9219 };
9220
9221 /**
9222 * Plugin: "dropdown_header" (Tom Select)
9223 * Copyright (c) contributors
9224 *
9225 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9226 * file except in compliance with the License. You may obtain a copy of the License at:
9227 * http://www.apache.org/licenses/LICENSE-2.0
9228 *
9229 * Unless required by applicable law or agreed to in writing, software distributed under
9230 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9231 * ANY KIND, either express or implied. See the License for the specific language
9232 * governing permissions and limitations under the License.
9233 *
9234 */
9235
9236 function plugin (userOptions) {
9237 const self = this;
9238 const options = Object.assign({
9239 className: 'clear-button',
9240 title: 'Clear All',
9241 html: data => {
9242 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
9243 }
9244 }, userOptions);
9245 self.on('initialize', () => {
9246 var button = getDom(options.html(options));
9247 button.addEventListener('click', evt => {
9248 if (self.isLocked) return;
9249 self.clear();
9250 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9251 self.addItem('');
9252 }
9253 evt.preventDefault();
9254 evt.stopPropagation();
9255 });
9256 self.control.appendChild(button);
9257 });
9258 }
9259
9260
9261 //# sourceMappingURL=plugin.js.map
9262
9263
9264 /***/ },
9265
9266 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9267 /*!**********************************************************************!*\
9268 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9269 \**********************************************************************/
9270 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9271
9272 "use strict";
9273 __webpack_require__.r(__webpack_exports__);
9274 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9275 /* harmony export */ "default": () => (/* binding */ plugin)
9276 /* harmony export */ });
9277 /**
9278 * Tom Select v2.4.3
9279 * Licensed under the Apache License, Version 2.0 (the "License");
9280 */
9281
9282 /**
9283 * Converts a scalar to its best string representation
9284 * for hash keys and HTML attribute values.
9285 *
9286 * Transformations:
9287 * 'str' -> 'str'
9288 * null -> ''
9289 * undefined -> ''
9290 * true -> '1'
9291 * false -> '0'
9292 * 0 -> '0'
9293 * 1 -> '1'
9294 *
9295 */
9296
9297 /**
9298 * Prevent default
9299 *
9300 */
9301 const preventDefault = (evt, stop = false) => {
9302 if (evt) {
9303 evt.preventDefault();
9304 if (stop) {
9305 evt.stopPropagation();
9306 }
9307 }
9308 };
9309
9310 /**
9311 * Add event helper
9312 *
9313 */
9314 const addEvent = (target, type, callback, options) => {
9315 target.addEventListener(type, callback, options);
9316 };
9317
9318 /**
9319 * Iterates over arrays and hashes.
9320 *
9321 * ```
9322 * iterate(this.items, function(item, id) {
9323 * // invoked for each item
9324 * });
9325 * ```
9326 *
9327 */
9328 const iterate = (object, callback) => {
9329 if (Array.isArray(object)) {
9330 object.forEach(callback);
9331 } else {
9332 for (var key in object) {
9333 if (object.hasOwnProperty(key)) {
9334 callback(object[key], key);
9335 }
9336 }
9337 }
9338 };
9339
9340 /**
9341 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9342 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9343 *
9344 * param query should be {}
9345 */
9346 const getDom = query => {
9347 if (query.jquery) {
9348 return query[0];
9349 }
9350 if (query instanceof HTMLElement) {
9351 return query;
9352 }
9353 if (isHtmlString(query)) {
9354 var tpl = document.createElement('template');
9355 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9356 return tpl.content.firstChild;
9357 }
9358 return document.querySelector(query);
9359 };
9360 const isHtmlString = arg => {
9361 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9362 return true;
9363 }
9364 return false;
9365 };
9366
9367 /**
9368 * Set attributes of an element
9369 *
9370 */
9371 const setAttr = (el, attrs) => {
9372 iterate(attrs, (val, attr) => {
9373 if (val == null) {
9374 el.removeAttribute(attr);
9375 } else {
9376 el.setAttribute(attr, '' + val);
9377 }
9378 });
9379 };
9380
9381 /**
9382 * Plugin: "drag_drop" (Tom Select)
9383 * Copyright (c) contributors
9384 *
9385 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9386 * file except in compliance with the License. You may obtain a copy of the License at:
9387 * http://www.apache.org/licenses/LICENSE-2.0
9388 *
9389 * Unless required by applicable law or agreed to in writing, software distributed under
9390 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9391 * ANY KIND, either express or implied. See the License for the specific language
9392 * governing permissions and limitations under the License.
9393 *
9394 */
9395
9396 const insertAfter = (referenceNode, newNode) => {
9397 var _referenceNode$parent;
9398 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
9399 };
9400 const insertBefore = (referenceNode, newNode) => {
9401 var _referenceNode$parent2;
9402 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
9403 };
9404 const isBefore = (referenceNode, newNode) => {
9405 do {
9406 var _newNode;
9407 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
9408 if (referenceNode == newNode) {
9409 return true;
9410 }
9411 } while (newNode && newNode.previousElementSibling);
9412 return false;
9413 };
9414 function plugin () {
9415 var self = this;
9416 if (self.settings.mode !== 'multi') return;
9417 var orig_lock = self.lock;
9418 var orig_unlock = self.unlock;
9419 let sortable = true;
9420 let drag_item;
9421
9422 /**
9423 * Add draggable attribute to item
9424 */
9425 self.hook('after', 'setupTemplates', () => {
9426 var orig_render_item = self.settings.render.item;
9427 self.settings.render.item = (data, escape) => {
9428 const item = getDom(orig_render_item.call(self, data, escape));
9429 setAttr(item, {
9430 'draggable': 'true'
9431 });
9432
9433 // prevent doc_mousedown (see tom-select.ts)
9434 const mousedown = evt => {
9435 if (!sortable) preventDefault(evt);
9436 evt.stopPropagation();
9437 };
9438 const dragStart = evt => {
9439 drag_item = item;
9440 setTimeout(() => {
9441 item.classList.add('ts-dragging');
9442 }, 0);
9443 };
9444 const dragOver = evt => {
9445 evt.preventDefault();
9446 item.classList.add('ts-drag-over');
9447 moveitem(item, drag_item);
9448 };
9449 const dragLeave = () => {
9450 item.classList.remove('ts-drag-over');
9451 };
9452 const moveitem = (targetitem, dragitem) => {
9453 if (dragitem === undefined) return;
9454 if (isBefore(dragitem, item)) {
9455 insertAfter(targetitem, dragitem);
9456 } else {
9457 insertBefore(targetitem, dragitem);
9458 }
9459 };
9460 const dragend = () => {
9461 var _drag_item;
9462 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
9463 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
9464 drag_item = undefined;
9465 var values = [];
9466 self.control.querySelectorAll(`[data-value]`).forEach(el => {
9467 if (el.dataset.value) {
9468 let value = el.dataset.value;
9469 if (value) {
9470 values.push(value);
9471 }
9472 }
9473 });
9474 self.setValue(values);
9475 };
9476 addEvent(item, 'mousedown', mousedown);
9477 addEvent(item, 'dragstart', dragStart);
9478 addEvent(item, 'dragenter', dragOver);
9479 addEvent(item, 'dragover', dragOver);
9480 addEvent(item, 'dragleave', dragLeave);
9481 addEvent(item, 'dragend', dragend);
9482 return item;
9483 };
9484 });
9485 self.hook('instead', 'lock', () => {
9486 sortable = false;
9487 return orig_lock.call(self);
9488 });
9489 self.hook('instead', 'unlock', () => {
9490 sortable = true;
9491 return orig_unlock.call(self);
9492 });
9493 }
9494
9495
9496 //# sourceMappingURL=plugin.js.map
9497
9498
9499 /***/ },
9500
9501 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
9502 /*!****************************************************************************!*\
9503 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
9504 \****************************************************************************/
9505 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9506
9507 "use strict";
9508 __webpack_require__.r(__webpack_exports__);
9509 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9510 /* harmony export */ "default": () => (/* binding */ plugin)
9511 /* harmony export */ });
9512 /**
9513 * Tom Select v2.4.3
9514 * Licensed under the Apache License, Version 2.0 (the "License");
9515 */
9516
9517 /**
9518 * Converts a scalar to its best string representation
9519 * for hash keys and HTML attribute values.
9520 *
9521 * Transformations:
9522 * 'str' -> 'str'
9523 * null -> ''
9524 * undefined -> ''
9525 * true -> '1'
9526 * false -> '0'
9527 * 0 -> '0'
9528 * 1 -> '1'
9529 *
9530 */
9531
9532 /**
9533 * Prevent default
9534 *
9535 */
9536 const preventDefault = (evt, stop = false) => {
9537 if (evt) {
9538 evt.preventDefault();
9539 if (stop) {
9540 evt.stopPropagation();
9541 }
9542 }
9543 };
9544
9545 /**
9546 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9547 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9548 *
9549 * param query should be {}
9550 */
9551 const getDom = query => {
9552 if (query.jquery) {
9553 return query[0];
9554 }
9555 if (query instanceof HTMLElement) {
9556 return query;
9557 }
9558 if (isHtmlString(query)) {
9559 var tpl = document.createElement('template');
9560 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9561 return tpl.content.firstChild;
9562 }
9563 return document.querySelector(query);
9564 };
9565 const isHtmlString = arg => {
9566 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9567 return true;
9568 }
9569 return false;
9570 };
9571
9572 /**
9573 * Plugin: "dropdown_header" (Tom Select)
9574 * Copyright (c) contributors
9575 *
9576 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9577 * file except in compliance with the License. You may obtain a copy of the License at:
9578 * http://www.apache.org/licenses/LICENSE-2.0
9579 *
9580 * Unless required by applicable law or agreed to in writing, software distributed under
9581 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9582 * ANY KIND, either express or implied. See the License for the specific language
9583 * governing permissions and limitations under the License.
9584 *
9585 */
9586
9587 function plugin (userOptions) {
9588 const self = this;
9589 const options = Object.assign({
9590 title: 'Untitled',
9591 headerClass: 'dropdown-header',
9592 titleRowClass: 'dropdown-header-title',
9593 labelClass: 'dropdown-header-label',
9594 closeClass: 'dropdown-header-close',
9595 html: data => {
9596 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
9597 }
9598 }, userOptions);
9599 self.on('initialize', () => {
9600 var header = getDom(options.html(options));
9601 var close_link = header.querySelector('.' + options.closeClass);
9602 if (close_link) {
9603 close_link.addEventListener('click', evt => {
9604 preventDefault(evt, true);
9605 self.close();
9606 });
9607 }
9608 self.dropdown.insertBefore(header, self.dropdown.firstChild);
9609 });
9610 }
9611
9612
9613 //# sourceMappingURL=plugin.js.map
9614
9615
9616 /***/ },
9617
9618 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
9619 /*!***************************************************************************!*\
9620 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
9621 \***************************************************************************/
9622 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9623
9624 "use strict";
9625 __webpack_require__.r(__webpack_exports__);
9626 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9627 /* harmony export */ "default": () => (/* binding */ plugin)
9628 /* harmony export */ });
9629 /**
9630 * Tom Select v2.4.3
9631 * Licensed under the Apache License, Version 2.0 (the "License");
9632 */
9633
9634 const KEY_ESC = 27;
9635 const KEY_TAB = 9;
9636 // ctrl key or apple key for ma
9637
9638 /**
9639 * Converts a scalar to its best string representation
9640 * for hash keys and HTML attribute values.
9641 *
9642 * Transformations:
9643 * 'str' -> 'str'
9644 * null -> ''
9645 * undefined -> ''
9646 * true -> '1'
9647 * false -> '0'
9648 * 0 -> '0'
9649 * 1 -> '1'
9650 *
9651 */
9652
9653 /**
9654 * Prevent default
9655 *
9656 */
9657 const preventDefault = (evt, stop = false) => {
9658 if (evt) {
9659 evt.preventDefault();
9660 if (stop) {
9661 evt.stopPropagation();
9662 }
9663 }
9664 };
9665
9666 /**
9667 * Add event helper
9668 *
9669 */
9670 const addEvent = (target, type, callback, options) => {
9671 target.addEventListener(type, callback, options);
9672 };
9673
9674 /**
9675 * Iterates over arrays and hashes.
9676 *
9677 * ```
9678 * iterate(this.items, function(item, id) {
9679 * // invoked for each item
9680 * });
9681 * ```
9682 *
9683 */
9684 const iterate = (object, callback) => {
9685 if (Array.isArray(object)) {
9686 object.forEach(callback);
9687 } else {
9688 for (var key in object) {
9689 if (object.hasOwnProperty(key)) {
9690 callback(object[key], key);
9691 }
9692 }
9693 }
9694 };
9695
9696 /**
9697 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9698 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9699 *
9700 * param query should be {}
9701 */
9702 const getDom = query => {
9703 if (query.jquery) {
9704 return query[0];
9705 }
9706 if (query instanceof HTMLElement) {
9707 return query;
9708 }
9709 if (isHtmlString(query)) {
9710 var tpl = document.createElement('template');
9711 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9712 return tpl.content.firstChild;
9713 }
9714 return document.querySelector(query);
9715 };
9716 const isHtmlString = arg => {
9717 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9718 return true;
9719 }
9720 return false;
9721 };
9722
9723 /**
9724 * Add css classes
9725 *
9726 */
9727 const addClasses = (elmts, ...classes) => {
9728 var norm_classes = classesArray(classes);
9729 elmts = castAsArray(elmts);
9730 elmts.map(el => {
9731 norm_classes.map(cls => {
9732 el.classList.add(cls);
9733 });
9734 });
9735 };
9736
9737 /**
9738 * Return arguments
9739 *
9740 */
9741 const classesArray = args => {
9742 var classes = [];
9743 iterate(args, _classes => {
9744 if (typeof _classes === 'string') {
9745 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9746 }
9747 if (Array.isArray(_classes)) {
9748 classes = classes.concat(_classes);
9749 }
9750 });
9751 return classes.filter(Boolean);
9752 };
9753
9754 /**
9755 * Create an array from arg if it's not already an array
9756 *
9757 */
9758 const castAsArray = arg => {
9759 if (!Array.isArray(arg)) {
9760 arg = [arg];
9761 }
9762 return arg;
9763 };
9764
9765 /**
9766 * Plugin: "dropdown_input" (Tom Select)
9767 * Copyright (c) contributors
9768 *
9769 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9770 * file except in compliance with the License. You may obtain a copy of the License at:
9771 * http://www.apache.org/licenses/LICENSE-2.0
9772 *
9773 * Unless required by applicable law or agreed to in writing, software distributed under
9774 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9775 * ANY KIND, either express or implied. See the License for the specific language
9776 * governing permissions and limitations under the License.
9777 *
9778 */
9779
9780 function plugin () {
9781 const self = this;
9782 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
9783
9784 self.hook('before', 'setup', () => {
9785 self.focus_node = self.control;
9786 addClasses(self.control_input, 'dropdown-input');
9787 const div = getDom('<div class="dropdown-input-wrap">');
9788 div.append(self.control_input);
9789 self.dropdown.insertBefore(div, self.dropdown.firstChild);
9790
9791 // set a placeholder in the select control
9792 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
9793 placeholder.placeholder = self.settings.placeholder || '';
9794 self.control.append(placeholder);
9795 });
9796 self.on('initialize', () => {
9797 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
9798 self.control_input.addEventListener('keydown', evt => {
9799 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
9800 switch (evt.keyCode) {
9801 case KEY_ESC:
9802 if (self.isOpen) {
9803 preventDefault(evt, true);
9804 self.close();
9805 }
9806 self.clearActiveItems();
9807 return;
9808 case KEY_TAB:
9809 self.focus_node.tabIndex = -1;
9810 break;
9811 }
9812 return self.onKeyDown.call(self, evt);
9813 });
9814 self.on('blur', () => {
9815 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
9816 });
9817
9818 // give the control_input focus when the dropdown is open
9819 self.on('dropdown_open', () => {
9820 self.control_input.focus();
9821 });
9822
9823 // prevent onBlur from closing when focus is on the control_input
9824 const orig_onBlur = self.onBlur;
9825 self.hook('instead', 'onBlur', evt => {
9826 if (evt && evt.relatedTarget == self.control_input) return;
9827 return orig_onBlur.call(self);
9828 });
9829 addEvent(self.control_input, 'blur', () => self.onBlur());
9830
9831 // return focus to control to allow further keyboard input
9832 self.hook('before', 'close', () => {
9833 if (!self.isOpen) return;
9834 self.focus_node.focus({
9835 preventScroll: true
9836 });
9837 });
9838 });
9839 }
9840
9841
9842 //# sourceMappingURL=plugin.js.map
9843
9844
9845 /***/ },
9846
9847 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
9848 /*!***************************************************************************!*\
9849 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
9850 \***************************************************************************/
9851 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9852
9853 "use strict";
9854 __webpack_require__.r(__webpack_exports__);
9855 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9856 /* harmony export */ "default": () => (/* binding */ plugin)
9857 /* harmony export */ });
9858 /**
9859 * Tom Select v2.4.3
9860 * Licensed under the Apache License, Version 2.0 (the "License");
9861 */
9862
9863 /**
9864 * Converts a scalar to its best string representation
9865 * for hash keys and HTML attribute values.
9866 *
9867 * Transformations:
9868 * 'str' -> 'str'
9869 * null -> ''
9870 * undefined -> ''
9871 * true -> '1'
9872 * false -> '0'
9873 * 0 -> '0'
9874 * 1 -> '1'
9875 *
9876 */
9877
9878 /**
9879 * Add event helper
9880 *
9881 */
9882 const addEvent = (target, type, callback, options) => {
9883 target.addEventListener(type, callback, options);
9884 };
9885
9886 /**
9887 * Plugin: "input_autogrow" (Tom Select)
9888 *
9889 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9890 * file except in compliance with the License. You may obtain a copy of the License at:
9891 * http://www.apache.org/licenses/LICENSE-2.0
9892 *
9893 * Unless required by applicable law or agreed to in writing, software distributed under
9894 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9895 * ANY KIND, either express or implied. See the License for the specific language
9896 * governing permissions and limitations under the License.
9897 *
9898 */
9899
9900 function plugin () {
9901 var self = this;
9902 self.on('initialize', () => {
9903 var test_input = document.createElement('span');
9904 var control = self.control_input;
9905 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
9906 self.wrapper.appendChild(test_input);
9907 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
9908 for (const style_name of transfer_styles) {
9909 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
9910 test_input.style[style_name] = control.style[style_name];
9911 }
9912
9913 /**
9914 * Set the control width
9915 *
9916 */
9917 var resize = () => {
9918 test_input.textContent = control.value;
9919 control.style.width = test_input.clientWidth + 'px';
9920 };
9921 resize();
9922 self.on('update item_add item_remove', resize);
9923 addEvent(control, 'input', resize);
9924 addEvent(control, 'keyup', resize);
9925 addEvent(control, 'blur', resize);
9926 addEvent(control, 'update', resize);
9927 });
9928 }
9929
9930
9931 //# sourceMappingURL=plugin.js.map
9932
9933
9934 /***/ },
9935
9936 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
9937 /*!****************************************************************************!*\
9938 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
9939 \****************************************************************************/
9940 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9941
9942 "use strict";
9943 __webpack_require__.r(__webpack_exports__);
9944 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9945 /* harmony export */ "default": () => (/* binding */ plugin)
9946 /* harmony export */ });
9947 /**
9948 * Tom Select v2.4.3
9949 * Licensed under the Apache License, Version 2.0 (the "License");
9950 */
9951
9952 /**
9953 * Plugin: "no_active_items" (Tom Select)
9954 *
9955 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9956 * file except in compliance with the License. You may obtain a copy of the License at:
9957 * http://www.apache.org/licenses/LICENSE-2.0
9958 *
9959 * Unless required by applicable law or agreed to in writing, software distributed under
9960 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9961 * ANY KIND, either express or implied. See the License for the specific language
9962 * governing permissions and limitations under the License.
9963 *
9964 */
9965
9966 function plugin () {
9967 this.hook('instead', 'setActiveItem', () => {});
9968 this.hook('instead', 'selectAll', () => {});
9969 }
9970
9971
9972 //# sourceMappingURL=plugin.js.map
9973
9974
9975 /***/ },
9976
9977 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
9978 /*!********************************************************************************!*\
9979 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
9980 \********************************************************************************/
9981 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9982
9983 "use strict";
9984 __webpack_require__.r(__webpack_exports__);
9985 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9986 /* harmony export */ "default": () => (/* binding */ plugin)
9987 /* harmony export */ });
9988 /**
9989 * Tom Select v2.4.3
9990 * Licensed under the Apache License, Version 2.0 (the "License");
9991 */
9992
9993 /**
9994 * Plugin: "input_autogrow" (Tom Select)
9995 *
9996 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9997 * file except in compliance with the License. You may obtain a copy of the License at:
9998 * http://www.apache.org/licenses/LICENSE-2.0
9999 *
10000 * Unless required by applicable law or agreed to in writing, software distributed under
10001 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10002 * ANY KIND, either express or implied. See the License for the specific language
10003 * governing permissions and limitations under the License.
10004 *
10005 */
10006
10007 function plugin () {
10008 var self = this;
10009 var orig_deleteSelection = self.deleteSelection;
10010 this.hook('instead', 'deleteSelection', evt => {
10011 if (self.activeItems.length) {
10012 return orig_deleteSelection.call(self, evt);
10013 }
10014 return false;
10015 });
10016 }
10017
10018
10019 //# sourceMappingURL=plugin.js.map
10020
10021
10022 /***/ },
10023
10024 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10025 /*!*****************************************************************************!*\
10026 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10027 \*****************************************************************************/
10028 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10029
10030 "use strict";
10031 __webpack_require__.r(__webpack_exports__);
10032 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10033 /* harmony export */ "default": () => (/* binding */ plugin)
10034 /* harmony export */ });
10035 /**
10036 * Tom Select v2.4.3
10037 * Licensed under the Apache License, Version 2.0 (the "License");
10038 */
10039
10040 const KEY_LEFT = 37;
10041 const KEY_RIGHT = 39;
10042 // ctrl key or apple key for ma
10043
10044 /**
10045 * Get the closest node to the evt.target matching the selector
10046 * Stops at wrapper
10047 *
10048 */
10049 const parentMatch = (target, selector, wrapper) => {
10050 while (target && target.matches) {
10051 if (target.matches(selector)) {
10052 return target;
10053 }
10054 target = target.parentNode;
10055 }
10056 };
10057
10058 /**
10059 * Get the index of an element amongst sibling nodes of the same type
10060 *
10061 */
10062 const nodeIndex = (el, amongst) => {
10063 if (!el) return -1;
10064 amongst = amongst || el.nodeName;
10065 var i = 0;
10066 while (el = el.previousElementSibling) {
10067 if (el.matches(amongst)) {
10068 i++;
10069 }
10070 }
10071 return i;
10072 };
10073
10074 /**
10075 * Plugin: "optgroup_columns" (Tom Select.js)
10076 * Copyright (c) contributors
10077 *
10078 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10079 * file except in compliance with the License. You may obtain a copy of the License at:
10080 * http://www.apache.org/licenses/LICENSE-2.0
10081 *
10082 * Unless required by applicable law or agreed to in writing, software distributed under
10083 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10084 * ANY KIND, either express or implied. See the License for the specific language
10085 * governing permissions and limitations under the License.
10086 *
10087 */
10088
10089 function plugin () {
10090 var self = this;
10091 var orig_keydown = self.onKeyDown;
10092 self.hook('instead', 'onKeyDown', evt => {
10093 var index, option, options, optgroup;
10094 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10095 return orig_keydown.call(self, evt);
10096 }
10097 self.ignoreHover = true;
10098 optgroup = parentMatch(self.activeOption, '[data-group]');
10099 index = nodeIndex(self.activeOption, '[data-selectable]');
10100 if (!optgroup) {
10101 return;
10102 }
10103 if (evt.keyCode === KEY_LEFT) {
10104 optgroup = optgroup.previousSibling;
10105 } else {
10106 optgroup = optgroup.nextSibling;
10107 }
10108 if (!optgroup) {
10109 return;
10110 }
10111 options = optgroup.querySelectorAll('[data-selectable]');
10112 option = options[Math.min(options.length - 1, index)];
10113 if (option) {
10114 self.setActiveOption(option);
10115 }
10116 });
10117 }
10118
10119
10120 //# sourceMappingURL=plugin.js.map
10121
10122
10123 /***/ },
10124
10125 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10126 /*!**************************************************************************!*\
10127 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10128 \**************************************************************************/
10129 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10130
10131 "use strict";
10132 __webpack_require__.r(__webpack_exports__);
10133 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10134 /* harmony export */ "default": () => (/* binding */ plugin)
10135 /* harmony export */ });
10136 /**
10137 * Tom Select v2.4.3
10138 * Licensed under the Apache License, Version 2.0 (the "License");
10139 */
10140
10141 /**
10142 * Converts a scalar to its best string representation
10143 * for hash keys and HTML attribute values.
10144 *
10145 * Transformations:
10146 * 'str' -> 'str'
10147 * null -> ''
10148 * undefined -> ''
10149 * true -> '1'
10150 * false -> '0'
10151 * 0 -> '0'
10152 * 1 -> '1'
10153 *
10154 */
10155
10156 /**
10157 * Escapes a string for use within HTML.
10158 *
10159 */
10160 const escape_html = str => {
10161 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
10162 };
10163
10164 /**
10165 * Prevent default
10166 *
10167 */
10168 const preventDefault = (evt, stop = false) => {
10169 if (evt) {
10170 evt.preventDefault();
10171 if (stop) {
10172 evt.stopPropagation();
10173 }
10174 }
10175 };
10176
10177 /**
10178 * Add event helper
10179 *
10180 */
10181 const addEvent = (target, type, callback, options) => {
10182 target.addEventListener(type, callback, options);
10183 };
10184
10185 /**
10186 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10187 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10188 *
10189 * param query should be {}
10190 */
10191 const getDom = query => {
10192 if (query.jquery) {
10193 return query[0];
10194 }
10195 if (query instanceof HTMLElement) {
10196 return query;
10197 }
10198 if (isHtmlString(query)) {
10199 var tpl = document.createElement('template');
10200 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10201 return tpl.content.firstChild;
10202 }
10203 return document.querySelector(query);
10204 };
10205 const isHtmlString = arg => {
10206 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10207 return true;
10208 }
10209 return false;
10210 };
10211
10212 /**
10213 * Plugin: "remove_button" (Tom Select)
10214 * Copyright (c) contributors
10215 *
10216 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10217 * file except in compliance with the License. You may obtain a copy of the License at:
10218 * http://www.apache.org/licenses/LICENSE-2.0
10219 *
10220 * Unless required by applicable law or agreed to in writing, software distributed under
10221 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10222 * ANY KIND, either express or implied. See the License for the specific language
10223 * governing permissions and limitations under the License.
10224 *
10225 */
10226
10227 function plugin (userOptions) {
10228 const options = Object.assign({
10229 label: '&times;',
10230 title: 'Remove',
10231 className: 'remove',
10232 append: true
10233 }, userOptions);
10234
10235 //options.className = 'remove-single';
10236 var self = this;
10237
10238 // override the render method to add remove button to each item
10239 if (!options.append) {
10240 return;
10241 }
10242 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
10243 self.hook('after', 'setupTemplates', () => {
10244 var orig_render_item = self.settings.render.item;
10245 self.settings.render.item = (data, escape) => {
10246 var item = getDom(orig_render_item.call(self, data, escape));
10247 var close_button = getDom(html);
10248 item.appendChild(close_button);
10249 addEvent(close_button, 'mousedown', evt => {
10250 preventDefault(evt, true);
10251 });
10252 addEvent(close_button, 'click', evt => {
10253 if (self.isLocked) return;
10254
10255 // propagating will trigger the dropdown to show for single mode
10256 preventDefault(evt, true);
10257 if (self.isLocked) return;
10258 if (!self.shouldDelete([item], evt)) return;
10259 self.removeItem(item);
10260 self.refreshOptions(false);
10261 self.inputState();
10262 });
10263 return item;
10264 };
10265 });
10266 }
10267
10268
10269 //# sourceMappingURL=plugin.js.map
10270
10271
10272 /***/ },
10273
10274 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10275 /*!*********************************************************************************!*\
10276 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10277 \*********************************************************************************/
10278 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10279
10280 "use strict";
10281 __webpack_require__.r(__webpack_exports__);
10282 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10283 /* harmony export */ "default": () => (/* binding */ plugin)
10284 /* harmony export */ });
10285 /**
10286 * Tom Select v2.4.3
10287 * Licensed under the Apache License, Version 2.0 (the "License");
10288 */
10289
10290 /**
10291 * Plugin: "restore_on_backspace" (Tom Select)
10292 * Copyright (c) contributors
10293 *
10294 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10295 * file except in compliance with the License. You may obtain a copy of the License at:
10296 * http://www.apache.org/licenses/LICENSE-2.0
10297 *
10298 * Unless required by applicable law or agreed to in writing, software distributed under
10299 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10300 * ANY KIND, either express or implied. See the License for the specific language
10301 * governing permissions and limitations under the License.
10302 *
10303 */
10304
10305 function plugin (userOptions) {
10306 const self = this;
10307 const options = Object.assign({
10308 text: option => {
10309 return option[self.settings.labelField];
10310 }
10311 }, userOptions);
10312 self.on('item_remove', function (value) {
10313 if (!self.isFocused) {
10314 return;
10315 }
10316 if (self.control_input.value.trim() === '') {
10317 var option = self.options[value];
10318 if (option) {
10319 self.setTextboxValue(options.text.call(self, option));
10320 }
10321 }
10322 });
10323 }
10324
10325
10326 //# sourceMappingURL=plugin.js.map
10327
10328
10329 /***/ },
10330
10331 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10332 /*!***************************************************************************!*\
10333 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10334 \***************************************************************************/
10335 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10336
10337 "use strict";
10338 __webpack_require__.r(__webpack_exports__);
10339 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10340 /* harmony export */ "default": () => (/* binding */ plugin)
10341 /* harmony export */ });
10342 /**
10343 * Tom Select v2.4.3
10344 * Licensed under the Apache License, Version 2.0 (the "License");
10345 */
10346
10347 /**
10348 * Converts a scalar to its best string representation
10349 * for hash keys and HTML attribute values.
10350 *
10351 * Transformations:
10352 * 'str' -> 'str'
10353 * null -> ''
10354 * undefined -> ''
10355 * true -> '1'
10356 * false -> '0'
10357 * 0 -> '0'
10358 * 1 -> '1'
10359 *
10360 */
10361
10362 /**
10363 * Iterates over arrays and hashes.
10364 *
10365 * ```
10366 * iterate(this.items, function(item, id) {
10367 * // invoked for each item
10368 * });
10369 * ```
10370 *
10371 */
10372 const iterate = (object, callback) => {
10373 if (Array.isArray(object)) {
10374 object.forEach(callback);
10375 } else {
10376 for (var key in object) {
10377 if (object.hasOwnProperty(key)) {
10378 callback(object[key], key);
10379 }
10380 }
10381 }
10382 };
10383
10384 /**
10385 * Add css classes
10386 *
10387 */
10388 const addClasses = (elmts, ...classes) => {
10389 var norm_classes = classesArray(classes);
10390 elmts = castAsArray(elmts);
10391 elmts.map(el => {
10392 norm_classes.map(cls => {
10393 el.classList.add(cls);
10394 });
10395 });
10396 };
10397
10398 /**
10399 * Return arguments
10400 *
10401 */
10402 const classesArray = args => {
10403 var classes = [];
10404 iterate(args, _classes => {
10405 if (typeof _classes === 'string') {
10406 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10407 }
10408 if (Array.isArray(_classes)) {
10409 classes = classes.concat(_classes);
10410 }
10411 });
10412 return classes.filter(Boolean);
10413 };
10414
10415 /**
10416 * Create an array from arg if it's not already an array
10417 *
10418 */
10419 const castAsArray = arg => {
10420 if (!Array.isArray(arg)) {
10421 arg = [arg];
10422 }
10423 return arg;
10424 };
10425
10426 /**
10427 * Plugin: "restore_on_backspace" (Tom Select)
10428 * Copyright (c) contributors
10429 *
10430 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10431 * file except in compliance with the License. You may obtain a copy of the License at:
10432 * http://www.apache.org/licenses/LICENSE-2.0
10433 *
10434 * Unless required by applicable law or agreed to in writing, software distributed under
10435 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10436 * ANY KIND, either express or implied. See the License for the specific language
10437 * governing permissions and limitations under the License.
10438 *
10439 */
10440
10441 function plugin () {
10442 const self = this;
10443 const orig_canLoad = self.canLoad;
10444 const orig_clearActiveOption = self.clearActiveOption;
10445 const orig_loadCallback = self.loadCallback;
10446 var pagination = {};
10447 var dropdown_content;
10448 var loading_more = false;
10449 var load_more_opt;
10450 var default_values = [];
10451 if (!self.settings.shouldLoadMore) {
10452 // return true if additional results should be loaded
10453 self.settings.shouldLoadMore = () => {
10454 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
10455 if (scroll_percent > 0.9) {
10456 return true;
10457 }
10458 if (self.activeOption) {
10459 var selectable = self.selectable();
10460 var index = Array.from(selectable).indexOf(self.activeOption);
10461 if (index >= selectable.length - 2) {
10462 return true;
10463 }
10464 }
10465 return false;
10466 };
10467 }
10468 if (!self.settings.firstUrl) {
10469 throw 'virtual_scroll plugin requires a firstUrl() method';
10470 }
10471
10472 // in order for virtual scrolling to work,
10473 // options need to be ordered the same way they're returned from the remote data source
10474 self.settings.sortField = [{
10475 field: '$order'
10476 }, {
10477 field: '$score'
10478 }];
10479
10480 // can we load more results for given query?
10481 const canLoadMore = query => {
10482 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
10483 return false;
10484 }
10485 if (query in pagination && pagination[query]) {
10486 return true;
10487 }
10488 return false;
10489 };
10490 const clearFilter = (option, value) => {
10491 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
10492 return true;
10493 }
10494 return false;
10495 };
10496
10497 // set the next url that will be
10498 self.setNextUrl = (value, next_url) => {
10499 pagination[value] = next_url;
10500 };
10501
10502 // getUrl() to be used in settings.load()
10503 self.getUrl = query => {
10504 if (query in pagination) {
10505 const next_url = pagination[query];
10506 pagination[query] = false;
10507 return next_url;
10508 }
10509
10510 // if the user goes back to a previous query
10511 // we need to load the first page again
10512 self.clearPagination();
10513 return self.settings.firstUrl.call(self, query);
10514 };
10515
10516 // clear pagination
10517 self.clearPagination = () => {
10518 pagination = {};
10519 };
10520
10521 // don't clear the active option (and cause unwanted dropdown scroll)
10522 // while loading more results
10523 self.hook('instead', 'clearActiveOption', () => {
10524 if (loading_more) {
10525 return;
10526 }
10527 return orig_clearActiveOption.call(self);
10528 });
10529
10530 // override the canLoad method
10531 self.hook('instead', 'canLoad', query => {
10532 // first time the query has been seen
10533 if (!(query in pagination)) {
10534 return orig_canLoad.call(self, query);
10535 }
10536 return canLoadMore(query);
10537 });
10538
10539 // wrap the load
10540 self.hook('instead', 'loadCallback', (options, optgroups) => {
10541 if (!loading_more) {
10542 self.clearOptions(clearFilter);
10543 } else if (load_more_opt) {
10544 const first_option = options[0];
10545 if (first_option !== undefined) {
10546 load_more_opt.dataset.value = first_option[self.settings.valueField];
10547 }
10548 }
10549 orig_loadCallback.call(self, options, optgroups);
10550 loading_more = false;
10551 });
10552
10553 // add templates to dropdown
10554 // loading_more if we have another url in the queue
10555 // no_more_results if we don't have another url in the queue
10556 self.hook('after', 'refreshOptions', () => {
10557 const query = self.lastValue;
10558 var option;
10559 if (canLoadMore(query)) {
10560 option = self.render('loading_more', {
10561 query: query
10562 });
10563 if (option) {
10564 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
10565 load_more_opt = option;
10566 }
10567 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
10568 option = self.render('no_more_results', {
10569 query: query
10570 });
10571 }
10572 if (option) {
10573 addClasses(option, self.settings.optionClass);
10574 dropdown_content.append(option);
10575 }
10576 });
10577
10578 // add scroll listener and default templates
10579 self.on('initialize', () => {
10580 default_values = Object.keys(self.options);
10581 dropdown_content = self.dropdown_content;
10582
10583 // default templates
10584 self.settings.render = Object.assign({}, {
10585 loading_more: () => {
10586 return `<div class="loading-more-results">Loading more results ... </div>`;
10587 },
10588 no_more_results: () => {
10589 return `<div class="no-more-results">No more results</div>`;
10590 }
10591 }, self.settings.render);
10592
10593 // watch dropdown content scroll position
10594 dropdown_content.addEventListener('scroll', () => {
10595 if (!self.settings.shouldLoadMore.call(self)) {
10596 return;
10597 }
10598
10599 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
10600 if (!canLoadMore(self.lastValue)) {
10601 return;
10602 }
10603
10604 // don't call load() too much
10605 if (loading_more) return;
10606 loading_more = true;
10607 self.load.call(self, self.lastValue);
10608 });
10609 });
10610 }
10611
10612
10613 //# sourceMappingURL=plugin.js.map
10614
10615
10616 /***/ },
10617
10618 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
10619 /*!*****************************************************************!*\
10620 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
10621 \*****************************************************************/
10622 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10623
10624 "use strict";
10625 __webpack_require__.r(__webpack_exports__);
10626 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10627 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10628 /* harmony export */ });
10629 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
10630 /* harmony import */ var _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./plugins/change_listener/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js");
10631 /* harmony import */ var _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./plugins/checkbox_options/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js");
10632 /* harmony import */ var _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./plugins/clear_button/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js");
10633 /* harmony import */ var _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./plugins/drag_drop/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js");
10634 /* harmony import */ var _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./plugins/dropdown_header/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js");
10635 /* harmony import */ var _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./plugins/caret_position/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js");
10636 /* harmony import */ var _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./plugins/dropdown_input/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js");
10637 /* harmony import */ var _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./plugins/input_autogrow/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js");
10638 /* harmony import */ var _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./plugins/no_backspace_delete/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js");
10639 /* harmony import */ var _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./plugins/no_active_items/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js");
10640 /* harmony import */ var _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./plugins/optgroup_columns/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js");
10641 /* harmony import */ var _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./plugins/remove_button/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js");
10642 /* harmony import */ var _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./plugins/restore_on_backspace/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js");
10643 /* harmony import */ var _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./plugins/virtual_scroll/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js");
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
10660 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
10661 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
10662 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
10663 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
10664 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
10665 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
10666 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
10667 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
10668 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
10669 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
10670 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
10671 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
10672 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
10673 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
10674 //# sourceMappingURL=tom-select.complete.js.map
10675
10676 /***/ },
10677
10678 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
10679 /*!********************************************************!*\
10680 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
10681 \********************************************************/
10682 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10683
10684 "use strict";
10685 __webpack_require__.r(__webpack_exports__);
10686 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10687 /* harmony export */ "default": () => (/* binding */ TomSelect)
10688 /* harmony export */ });
10689 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
10690 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
10691 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
10692 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10693 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
10694 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
10695 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
10696 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
10697 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707 var instance_i = 0;
10708 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
10709 constructor(input_arg, user_settings) {
10710 super();
10711 this.order = 0;
10712 this.isOpen = false;
10713 this.isDisabled = false;
10714 this.isReadOnly = false;
10715 this.isInvalid = false; // @deprecated 1.8
10716 this.isValid = true;
10717 this.isLocked = false;
10718 this.isFocused = false;
10719 this.isInputHidden = false;
10720 this.isSetup = false;
10721 this.ignoreFocus = false;
10722 this.ignoreHover = false;
10723 this.hasOptions = false;
10724 this.lastValue = '';
10725 this.caretPos = 0;
10726 this.loading = 0;
10727 this.loadedSearches = {};
10728 this.activeOption = null;
10729 this.activeItems = [];
10730 this.optgroups = {};
10731 this.options = {};
10732 this.userOptions = {};
10733 this.items = [];
10734 this.refreshTimeout = null;
10735 instance_i++;
10736 var dir;
10737 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
10738 if (input.tomselect) {
10739 throw new Error('Tom Select already initialized on this element');
10740 }
10741 input.tomselect = this;
10742 // detect rtl environment
10743 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
10744 dir = computedStyle.getPropertyValue('direction');
10745 // setup default state
10746 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
10747 this.settings = settings;
10748 this.input = input;
10749 this.tabIndex = input.tabIndex || 0;
10750 this.is_select_tag = input.tagName.toLowerCase() === 'select';
10751 this.rtl = /rtl/i.test(dir);
10752 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
10753 this.isRequired = input.required;
10754 // search system
10755 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
10756 // option-dependent defaults
10757 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
10758 if (typeof settings.hideSelected !== 'boolean') {
10759 settings.hideSelected = settings.mode === 'multi';
10760 }
10761 if (typeof settings.hidePlaceholder !== 'boolean') {
10762 settings.hidePlaceholder = settings.mode !== 'multi';
10763 }
10764 // set up createFilter callback
10765 var filter = settings.createFilter;
10766 if (typeof filter !== 'function') {
10767 if (typeof filter === 'string') {
10768 filter = new RegExp(filter);
10769 }
10770 if (filter instanceof RegExp) {
10771 settings.createFilter = (input) => filter.test(input);
10772 }
10773 else {
10774 settings.createFilter = (value) => {
10775 return this.settings.duplicates || !this.options[value];
10776 };
10777 }
10778 }
10779 this.initializePlugins(settings.plugins);
10780 this.setupCallbacks();
10781 this.setupTemplates();
10782 // Create all elements
10783 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10784 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10785 const dropdown = this._render('dropdown');
10786 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
10787 const classes = this.input.getAttribute('class') || '';
10788 const inputMode = settings.mode;
10789 var control_input;
10790 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
10791 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
10792 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
10793 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
10794 if (settings.copyClassesToDropdown) {
10795 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
10796 }
10797 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
10798 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
10799 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
10800 // default controlInput
10801 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
10802 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10803 // set attributes
10804 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
10805 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
10806 if (input.getAttribute(attr)) {
10807 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
10808 }
10809 });
10810 control_input.tabIndex = -1;
10811 control.appendChild(control_input);
10812 this.focus_node = control_input;
10813 // dom element
10814 }
10815 else if (settings.controlInput) {
10816 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10817 this.focus_node = control_input;
10818 }
10819 else {
10820 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
10821 this.focus_node = control;
10822 }
10823 this.wrapper = wrapper;
10824 this.dropdown = dropdown;
10825 this.dropdown_content = dropdown_content;
10826 this.control = control;
10827 this.control_input = control_input;
10828 this.setup();
10829 }
10830 /**
10831 * set up event bindings.
10832 *
10833 */
10834 setup() {
10835 const self = this;
10836 const settings = self.settings;
10837 const control_input = self.control_input;
10838 const dropdown = self.dropdown;
10839 const dropdown_content = self.dropdown_content;
10840 const wrapper = self.wrapper;
10841 const control = self.control;
10842 const input = self.input;
10843 const focus_node = self.focus_node;
10844 const passive_event = { passive: true };
10845 const listboxId = self.inputId + '-ts-dropdown';
10846 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
10847 id: listboxId
10848 });
10849 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
10850 role: 'combobox',
10851 'aria-haspopup': 'listbox',
10852 'aria-expanded': 'false',
10853 'aria-controls': listboxId
10854 });
10855 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
10856 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
10857 const label = document.querySelector(query);
10858 const label_click = self.focus.bind(self);
10859 if (label) {
10860 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
10861 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
10862 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
10863 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
10864 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
10865 }
10866 wrapper.style.width = input.style.width;
10867 if (self.plugins.names.length) {
10868 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
10869 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
10870 }
10871 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
10872 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
10873 }
10874 if (settings.placeholder) {
10875 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
10876 }
10877 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
10878 if (!settings.splitOn && settings.delimiter) {
10879 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
10880 }
10881 // debounce user defined load() if loadThrottle > 0
10882 // after initializePlugins() so plugins can create/modify user defined loaders
10883 if (settings.load && settings.loadThrottle) {
10884 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
10885 }
10886 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
10887 self.ignoreHover = false;
10888 });
10889 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
10890 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
10891 if (target_match)
10892 self.onOptionHover(e, target_match);
10893 }, { capture: true });
10894 // clicking on an option should select it
10895 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
10896 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
10897 if (option) {
10898 self.onOptionSelect(evt, option);
10899 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10900 }
10901 });
10902 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
10903 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
10904 if (target_match && self.onItemSelect(evt, target_match)) {
10905 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10906 return;
10907 }
10908 // retain focus (see control_input mousedown)
10909 if (control_input.value != '') {
10910 return;
10911 }
10912 self.onClick();
10913 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10914 });
10915 // keydown on focus_node for arrow_down/arrow_up
10916 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
10917 // keypress and input/keyup
10918 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
10919 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
10920 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
10921 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
10922 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
10923 const doc_mousedown = (evt) => {
10924 // blur if target is outside of this instance
10925 // dropdown is not always inside wrapper
10926 const target = evt.composedPath()[0];
10927 if (!wrapper.contains(target) && !dropdown.contains(target)) {
10928 if (self.isFocused) {
10929 self.blur();
10930 }
10931 self.inputState();
10932 return;
10933 }
10934 // retain focus by preventing native handling. if the
10935 // event target is the input it should not be modified.
10936 // otherwise, text selection within the input won't work.
10937 // Fixes bug #212 which is no covered by tests
10938 if (target == control_input && self.isOpen) {
10939 evt.stopPropagation();
10940 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
10941 }
10942 else {
10943 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10944 }
10945 };
10946 const win_scroll = () => {
10947 if (self.isOpen) {
10948 self.positionDropdown();
10949 }
10950 };
10951 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
10952 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
10953 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
10954 this._destroy = () => {
10955 document.removeEventListener('mousedown', doc_mousedown);
10956 window.removeEventListener('scroll', win_scroll);
10957 window.removeEventListener('resize', win_scroll);
10958 if (label)
10959 label.removeEventListener('click', label_click);
10960 };
10961 // store original html and tab index so that they can be
10962 // restored when the destroy() method is called.
10963 this.revertSettings = {
10964 innerHTML: input.innerHTML,
10965 tabIndex: input.tabIndex
10966 };
10967 input.tabIndex = -1;
10968 input.insertAdjacentElement('afterend', self.wrapper);
10969 self.sync(false);
10970 settings.items = [];
10971 delete settings.optgroups;
10972 delete settings.options;
10973 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
10974 if (self.isValid) {
10975 self.isValid = false;
10976 self.isInvalid = true;
10977 self.refreshState();
10978 }
10979 });
10980 self.updateOriginalInput();
10981 self.refreshItems();
10982 self.close(false);
10983 self.inputState();
10984 self.isSetup = true;
10985 if (input.disabled) {
10986 self.disable();
10987 }
10988 else if (input.readOnly) {
10989 self.setReadOnly(true);
10990 }
10991 else {
10992 self.enable(); //sets tabIndex
10993 }
10994 self.on('change', this.onChange);
10995 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
10996 self.trigger('initialize');
10997 // preload options
10998 if (settings.preload === true) {
10999 self.preload();
11000 }
11001 }
11002 /**
11003 * Register options and optgroups
11004 *
11005 */
11006 setupOptions(options = [], optgroups = []) {
11007 // build options table
11008 this.addOptions(options);
11009 // build optgroup table
11010 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11011 this.registerOptionGroup(optgroup);
11012 });
11013 }
11014 /**
11015 * Sets up default rendering functions.
11016 */
11017 setupTemplates() {
11018 var self = this;
11019 var field_label = self.settings.labelField;
11020 var field_optgroup = self.settings.optgroupLabelField;
11021 var templates = {
11022 'optgroup': (data) => {
11023 let optgroup = document.createElement('div');
11024 optgroup.className = 'optgroup';
11025 optgroup.appendChild(data.options);
11026 return optgroup;
11027 },
11028 'optgroup_header': (data, escape) => {
11029 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11030 },
11031 'option': (data, escape) => {
11032 return '<div>' + escape(data[field_label]) + '</div>';
11033 },
11034 'item': (data, escape) => {
11035 return '<div>' + escape(data[field_label]) + '</div>';
11036 },
11037 'option_create': (data, escape) => {
11038 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11039 },
11040 'no_results': () => {
11041 return '<div class="no-results">No results found</div>';
11042 },
11043 'loading': () => {
11044 return '<div class="spinner"></div>';
11045 },
11046 'not_loading': () => { },
11047 'dropdown': () => {
11048 return '<div></div>';
11049 }
11050 };
11051 self.settings.render = Object.assign({}, templates, self.settings.render);
11052 }
11053 /**
11054 * Maps fired events to callbacks provided
11055 * in the settings used when creating the control.
11056 */
11057 setupCallbacks() {
11058 var key, fn;
11059 var callbacks = {
11060 'initialize': 'onInitialize',
11061 'change': 'onChange',
11062 'item_add': 'onItemAdd',
11063 'item_remove': 'onItemRemove',
11064 'item_select': 'onItemSelect',
11065 'clear': 'onClear',
11066 'option_add': 'onOptionAdd',
11067 'option_remove': 'onOptionRemove',
11068 'option_clear': 'onOptionClear',
11069 'optgroup_add': 'onOptionGroupAdd',
11070 'optgroup_remove': 'onOptionGroupRemove',
11071 'optgroup_clear': 'onOptionGroupClear',
11072 'dropdown_open': 'onDropdownOpen',
11073 'dropdown_close': 'onDropdownClose',
11074 'type': 'onType',
11075 'load': 'onLoad',
11076 'focus': 'onFocus',
11077 'blur': 'onBlur'
11078 };
11079 for (key in callbacks) {
11080 fn = this.settings[callbacks[key]];
11081 if (fn)
11082 this.on(key, fn);
11083 }
11084 }
11085 /**
11086 * Sync the Tom Select instance with the original input or select
11087 *
11088 */
11089 sync(get_settings = true) {
11090 const self = this;
11091 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
11092 self.setupOptions(settings.options, settings.optgroups);
11093 self.setValue(settings.items || [], true); // silent prevents recursion
11094 self.lastQuery = null; // so updated options will be displayed in dropdown
11095 }
11096 /**
11097 * Triggered when the main control element
11098 * has a click event.
11099 *
11100 */
11101 onClick() {
11102 var self = this;
11103 if (self.activeItems.length > 0) {
11104 self.clearActiveItems();
11105 self.focus();
11106 return;
11107 }
11108 if (self.isFocused && self.isOpen) {
11109 self.blur();
11110 }
11111 else {
11112 self.focus();
11113 }
11114 }
11115 /**
11116 * @deprecated v1.7
11117 *
11118 */
11119 onMouseDown() { }
11120 /**
11121 * Triggered when the value of the control has been changed.
11122 * This should propagate the event to the original DOM
11123 * input / select element.
11124 */
11125 onChange() {
11126 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11127 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11128 }
11129 /**
11130 * Triggered on <input> paste.
11131 *
11132 */
11133 onPaste(e) {
11134 var self = this;
11135 if (self.isInputHidden || self.isLocked) {
11136 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11137 return;
11138 }
11139 // If a regex or string is included, this will split the pasted
11140 // input and create Items for each separate value
11141 if (!self.settings.splitOn) {
11142 return;
11143 }
11144 // Wait for pasted text to be recognized in value
11145 setTimeout(() => {
11146 var pastedText = self.inputValue();
11147 if (!pastedText.match(self.settings.splitOn)) {
11148 return;
11149 }
11150 var splitInput = pastedText.trim().split(self.settings.splitOn);
11151 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11152 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11153 if (hash) {
11154 if (this.options[piece]) {
11155 self.addItem(piece);
11156 }
11157 else {
11158 self.createItem(piece);
11159 }
11160 }
11161 });
11162 }, 0);
11163 }
11164 /**
11165 * Triggered on <input> keypress.
11166 *
11167 */
11168 onKeyPress(e) {
11169 var self = this;
11170 if (self.isLocked) {
11171 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11172 return;
11173 }
11174 var character = String.fromCharCode(e.keyCode || e.which);
11175 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11176 self.createItem();
11177 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11178 return;
11179 }
11180 }
11181 /**
11182 * Triggered on <input> keydown.
11183 *
11184 */
11185 onKeyDown(e) {
11186 var self = this;
11187 self.ignoreHover = true;
11188 if (self.isLocked) {
11189 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11190 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11191 }
11192 return;
11193 }
11194 switch (e.keyCode) {
11195 // ctrl+A: select all
11196 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11197 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11198 if (self.control_input.value == '') {
11199 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11200 self.selectAll();
11201 return;
11202 }
11203 }
11204 break;
11205 // esc: close dropdown
11206 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11207 if (self.isOpen) {
11208 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11209 self.close();
11210 }
11211 self.clearActiveItems();
11212 return;
11213 // down: open dropdown or move selection down
11214 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11215 if (!self.isOpen && self.hasOptions) {
11216 self.open();
11217 }
11218 else if (self.activeOption) {
11219 let next = self.getAdjacent(self.activeOption, 1);
11220 if (next)
11221 self.setActiveOption(next);
11222 }
11223 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11224 return;
11225 // up: move selection up
11226 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11227 if (self.activeOption) {
11228 let prev = self.getAdjacent(self.activeOption, -1);
11229 if (prev)
11230 self.setActiveOption(prev);
11231 }
11232 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11233 return;
11234 // return: select active option
11235 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11236 if (self.canSelect(self.activeOption)) {
11237 self.onOptionSelect(e, self.activeOption);
11238 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11239 // if the option_create=null, the dropdown might be closed
11240 }
11241 else if (self.settings.create && self.createItem()) {
11242 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11243 // don't submit form when searching for a value
11244 }
11245 else if (document.activeElement == self.control_input && self.isOpen) {
11246 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11247 }
11248 return;
11249 // left: modifiy item selection to the left
11250 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11251 self.advanceSelection(-1, e);
11252 return;
11253 // right: modifiy item selection to the right
11254 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11255 self.advanceSelection(1, e);
11256 return;
11257 // tab: select active option and/or create item
11258 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11259 if (self.settings.selectOnTab) {
11260 if (self.canSelect(self.activeOption)) {
11261 self.onOptionSelect(e, self.activeOption);
11262 // prevent default [tab] behaviour of jump to the next field
11263 // if select isFull, then the dropdown won't be open and [tab] will work normally
11264 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11265 }
11266 if (self.settings.create && self.createItem()) {
11267 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11268 }
11269 }
11270 return;
11271 // delete|backspace: delete items
11272 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11273 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11274 self.deleteSelection(e);
11275 return;
11276 }
11277 // don't enter text in the control_input when active items are selected
11278 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11279 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11280 }
11281 }
11282 /**
11283 * Triggered on <input> keyup.
11284 *
11285 */
11286 onInput(e) {
11287 if (this.isLocked) {
11288 return;
11289 }
11290 const value = this.inputValue();
11291 if (this.lastValue === value)
11292 return;
11293 this.lastValue = value;
11294 if (value == '') {
11295 this._onInput();
11296 return;
11297 }
11298 if (this.refreshTimeout) {
11299 window.clearTimeout(this.refreshTimeout);
11300 }
11301 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11302 this.refreshTimeout = null;
11303 this._onInput();
11304 }, this.settings.refreshThrottle);
11305 }
11306 _onInput() {
11307 const value = this.lastValue;
11308 if (this.settings.shouldLoad.call(this, value)) {
11309 this.load(value);
11310 }
11311 this.refreshOptions();
11312 this.trigger('type', value);
11313 }
11314 /**
11315 * Triggered when the user rolls over
11316 * an option in the autocomplete dropdown menu.
11317 *
11318 */
11319 onOptionHover(evt, option) {
11320 if (this.ignoreHover)
11321 return;
11322 this.setActiveOption(option, false);
11323 }
11324 /**
11325 * Triggered on <input> focus.
11326 *
11327 */
11328 onFocus(e) {
11329 var self = this;
11330 var wasFocused = self.isFocused;
11331 if (self.isDisabled || self.isReadOnly) {
11332 self.blur();
11333 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11334 return;
11335 }
11336 if (self.ignoreFocus)
11337 return;
11338 self.isFocused = true;
11339 if (self.settings.preload === 'focus')
11340 self.preload();
11341 if (!wasFocused)
11342 self.trigger('focus');
11343 if (!self.activeItems.length) {
11344 self.inputState();
11345 self.refreshOptions(!!self.settings.openOnFocus);
11346 }
11347 self.refreshState();
11348 }
11349 /**
11350 * Triggered on <input> blur.
11351 *
11352 */
11353 onBlur(e) {
11354 if (document.hasFocus() === false)
11355 return;
11356 var self = this;
11357 if (!self.isFocused)
11358 return;
11359 self.isFocused = false;
11360 self.ignoreFocus = false;
11361 var deactivate = () => {
11362 self.close();
11363 self.setActiveItem();
11364 self.setCaret(self.items.length);
11365 self.trigger('blur');
11366 };
11367 if (self.settings.create && self.settings.createOnBlur) {
11368 self.createItem(null, deactivate);
11369 }
11370 else {
11371 deactivate();
11372 }
11373 }
11374 /**
11375 * Triggered when the user clicks on an option
11376 * in the autocomplete dropdown menu.
11377 *
11378 */
11379 onOptionSelect(evt, option) {
11380 var value, self = this;
11381 // should not be possible to trigger a option under a disabled optgroup
11382 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
11383 return;
11384 }
11385 if (option.classList.contains('create')) {
11386 self.createItem(null, () => {
11387 if (self.settings.closeAfterSelect) {
11388 self.close();
11389 }
11390 });
11391 }
11392 else {
11393 value = option.dataset.value;
11394 if (typeof value !== 'undefined') {
11395 self.lastQuery = null;
11396 self.addItem(value);
11397 if (self.settings.closeAfterSelect) {
11398 self.close();
11399 }
11400 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
11401 self.setActiveOption(option);
11402 }
11403 }
11404 }
11405 }
11406 /**
11407 * Return true if the given option can be selected
11408 *
11409 */
11410 canSelect(option) {
11411 if (this.isOpen && option && this.dropdown_content.contains(option)) {
11412 return true;
11413 }
11414 return false;
11415 }
11416 /**
11417 * Triggered when the user clicks on an item
11418 * that has been selected.
11419 *
11420 */
11421 onItemSelect(evt, item) {
11422 var self = this;
11423 if (!self.isLocked && self.settings.mode === 'multi') {
11424 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
11425 self.setActiveItem(item, evt);
11426 return true;
11427 }
11428 return false;
11429 }
11430 /**
11431 * Determines whether or not to invoke
11432 * the user-provided option provider / loader
11433 *
11434 * Note, there is a subtle difference between
11435 * this.canLoad() and this.settings.shouldLoad();
11436 *
11437 * - settings.shouldLoad() is a user-input validator.
11438 * When false is returned, the not_loading template
11439 * will be added to the dropdown
11440 *
11441 * - canLoad() is lower level validator that checks
11442 * the Tom Select instance. There is no inherent user
11443 * feedback when canLoad returns false
11444 *
11445 */
11446 canLoad(value) {
11447 if (!this.settings.load)
11448 return false;
11449 if (this.loadedSearches.hasOwnProperty(value))
11450 return false;
11451 return true;
11452 }
11453 /**
11454 * Invokes the user-provided option provider / loader.
11455 *
11456 */
11457 load(value) {
11458 const self = this;
11459 if (!self.canLoad(value))
11460 return;
11461 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
11462 self.loading++;
11463 const callback = self.loadCallback.bind(self);
11464 self.settings.load.call(self, value, callback);
11465 }
11466 /**
11467 * Invoked by the user-provided option provider
11468 *
11469 */
11470 loadCallback(options, optgroups) {
11471 const self = this;
11472 self.loading = Math.max(self.loading - 1, 0);
11473 self.lastQuery = null;
11474 self.clearActiveOption(); // when new results load, focus should be on first option
11475 self.setupOptions(options, optgroups);
11476 self.refreshOptions(self.isFocused && !self.isInputHidden);
11477 if (!self.loading) {
11478 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
11479 }
11480 self.trigger('load', options, optgroups);
11481 }
11482 preload() {
11483 var classList = this.wrapper.classList;
11484 if (classList.contains('preloaded'))
11485 return;
11486 classList.add('preloaded');
11487 this.load('');
11488 }
11489 /**
11490 * Sets the input field of the control to the specified value.
11491 *
11492 */
11493 setTextboxValue(value = '') {
11494 var input = this.control_input;
11495 var changed = input.value !== value;
11496 if (changed) {
11497 input.value = value;
11498 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
11499 this.lastValue = value;
11500 }
11501 }
11502 /**
11503 * Returns the value of the control. If multiple items
11504 * can be selected (e.g. <select multiple>), this returns
11505 * an array. If only one item can be selected, this
11506 * returns a string.
11507 *
11508 */
11509 getValue() {
11510 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
11511 return this.items;
11512 }
11513 return this.items.join(this.settings.delimiter);
11514 }
11515 /**
11516 * Resets the selected items to the given value.
11517 *
11518 */
11519 setValue(value, silent) {
11520 var events = silent ? [] : ['change'];
11521 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
11522 this.clear(silent);
11523 this.addItems(value, silent);
11524 });
11525 }
11526 /**
11527 * Resets the number of max items to the given value
11528 *
11529 */
11530 setMaxItems(value) {
11531 if (value === 0)
11532 value = null; //reset to unlimited items.
11533 this.settings.maxItems = value;
11534 this.refreshState();
11535 }
11536 /**
11537 * Sets the selected item.
11538 *
11539 */
11540 setActiveItem(item, e) {
11541 var self = this;
11542 var eventName;
11543 var i, begin, end, swap;
11544 var last;
11545 if (self.settings.mode === 'single')
11546 return;
11547 // clear the active selection
11548 if (!item) {
11549 self.clearActiveItems();
11550 if (self.isFocused) {
11551 self.inputState();
11552 }
11553 return;
11554 }
11555 // modify selection
11556 eventName = e && e.type.toLowerCase();
11557 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
11558 last = self.getLastActive();
11559 begin = Array.prototype.indexOf.call(self.control.children, last);
11560 end = Array.prototype.indexOf.call(self.control.children, item);
11561 if (begin > end) {
11562 swap = begin;
11563 begin = end;
11564 end = swap;
11565 }
11566 for (i = begin; i <= end; i++) {
11567 item = self.control.children[i];
11568 if (self.activeItems.indexOf(item) === -1) {
11569 self.setActiveItemClass(item);
11570 }
11571 }
11572 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11573 }
11574 else if ((eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) || (eventName === 'keydown' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e))) {
11575 if (item.classList.contains('active')) {
11576 self.removeActiveItem(item);
11577 }
11578 else {
11579 self.setActiveItemClass(item);
11580 }
11581 }
11582 else {
11583 self.clearActiveItems();
11584 self.setActiveItemClass(item);
11585 }
11586 // ensure control has focus
11587 self.inputState();
11588 if (!self.isFocused) {
11589 self.focus();
11590 }
11591 }
11592 /**
11593 * Set the active and last-active classes
11594 *
11595 */
11596 setActiveItemClass(item) {
11597 const self = this;
11598 const last_active = self.control.querySelector('.last-active');
11599 if (last_active)
11600 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
11601 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
11602 self.trigger('item_select', item);
11603 if (self.activeItems.indexOf(item) == -1) {
11604 self.activeItems.push(item);
11605 }
11606 }
11607 /**
11608 * Remove active item
11609 *
11610 */
11611 removeActiveItem(item) {
11612 var idx = this.activeItems.indexOf(item);
11613 this.activeItems.splice(idx, 1);
11614 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
11615 }
11616 /**
11617 * Clears all the active items
11618 *
11619 */
11620 clearActiveItems() {
11621 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
11622 this.activeItems = [];
11623 }
11624 /**
11625 * Sets the selected item in the dropdown menu
11626 * of available options.
11627 *
11628 */
11629 setActiveOption(option, scroll = true) {
11630 if (option === this.activeOption) {
11631 return;
11632 }
11633 this.clearActiveOption();
11634 if (!option)
11635 return;
11636 this.activeOption = option;
11637 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
11638 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
11639 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
11640 if (scroll)
11641 this.scrollToOption(option);
11642 }
11643 /**
11644 * Sets the dropdown_content scrollTop to display the option
11645 *
11646 */
11647 scrollToOption(option, behavior) {
11648 if (!option)
11649 return;
11650 const content = this.dropdown_content;
11651 const height_menu = content.clientHeight;
11652 const scrollTop = content.scrollTop || 0;
11653 const height_item = option.offsetHeight;
11654 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
11655 if (y + height_item > height_menu + scrollTop) {
11656 this.scroll(y - height_menu + height_item, behavior);
11657 }
11658 else if (y < scrollTop) {
11659 this.scroll(y, behavior);
11660 }
11661 }
11662 /**
11663 * Scroll the dropdown to the given position
11664 *
11665 */
11666 scroll(scrollTop, behavior) {
11667 const content = this.dropdown_content;
11668 if (behavior) {
11669 content.style.scrollBehavior = behavior;
11670 }
11671 content.scrollTop = scrollTop;
11672 content.style.scrollBehavior = '';
11673 }
11674 /**
11675 * Clears the active option
11676 *
11677 */
11678 clearActiveOption() {
11679 if (this.activeOption) {
11680 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
11681 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
11682 }
11683 this.activeOption = null;
11684 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
11685 }
11686 /**
11687 * Selects all items (CTRL + A).
11688 */
11689 selectAll() {
11690 const self = this;
11691 if (self.settings.mode === 'single')
11692 return;
11693 const activeItems = self.controlChildren();
11694 if (!activeItems.length)
11695 return;
11696 self.inputState();
11697 self.close();
11698 self.activeItems = activeItems;
11699 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
11700 self.setActiveItemClass(item);
11701 });
11702 }
11703 /**
11704 * Determines if the control_input should be in a hidden or visible state
11705 *
11706 */
11707 inputState() {
11708 var self = this;
11709 if (!self.control.contains(self.control_input))
11710 return;
11711 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
11712 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
11713 self.setTextboxValue();
11714 self.isInputHidden = true;
11715 }
11716 else {
11717 if (self.settings.hidePlaceholder && self.items.length > 0) {
11718 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
11719 }
11720 self.isInputHidden = false;
11721 }
11722 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
11723 }
11724 /**
11725 * Get the input value
11726 */
11727 inputValue() {
11728 return this.control_input.value.trim();
11729 }
11730 /**
11731 * Gives the control focus.
11732 */
11733 focus() {
11734 var self = this;
11735 if (self.isDisabled || self.isReadOnly)
11736 return;
11737 self.ignoreFocus = true;
11738 if (self.control_input.offsetWidth) {
11739 self.control_input.focus();
11740 }
11741 else {
11742 self.focus_node.focus();
11743 }
11744 setTimeout(() => {
11745 self.ignoreFocus = false;
11746 self.onFocus();
11747 }, 0);
11748 }
11749 /**
11750 * Forces the control out of focus.
11751 *
11752 */
11753 blur() {
11754 this.focus_node.blur();
11755 this.onBlur();
11756 }
11757 /**
11758 * Returns a function that scores an object
11759 * to show how good of a match it is to the
11760 * provided query.
11761 *
11762 * @return {function}
11763 */
11764 getScoreFunction(query) {
11765 return this.sifter.getScoreFunction(query, this.getSearchOptions());
11766 }
11767 /**
11768 * Returns search options for sifter (the system
11769 * for scoring and sorting results).
11770 *
11771 * @see https://github.com/orchidjs/sifter.js
11772 * @return {object}
11773 */
11774 getSearchOptions() {
11775 var settings = this.settings;
11776 var sort = settings.sortField;
11777 if (typeof settings.sortField === 'string') {
11778 sort = [{ field: settings.sortField }];
11779 }
11780 return {
11781 fields: settings.searchField,
11782 conjunction: settings.searchConjunction,
11783 sort: sort,
11784 nesting: settings.nesting
11785 };
11786 }
11787 /**
11788 * Searches through available options and returns
11789 * a sorted array of matches.
11790 *
11791 */
11792 search(query) {
11793 var result, calculateScore;
11794 var self = this;
11795 var options = this.getSearchOptions();
11796 // validate user-provided result scoring function
11797 if (self.settings.score) {
11798 calculateScore = self.settings.score.call(self, query);
11799 if (typeof calculateScore !== 'function') {
11800 throw new Error('Tom Select "score" setting must be a function that returns a function');
11801 }
11802 }
11803 // perform search
11804 if (query !== self.lastQuery) {
11805 self.lastQuery = query;
11806 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
11807 self.currentResults = result;
11808 }
11809 else {
11810 result = Object.assign({}, self.currentResults);
11811 }
11812 // filter out selected items
11813 if (self.settings.hideSelected) {
11814 result.items = result.items.filter((item) => {
11815 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
11816 return !(hashed && self.items.indexOf(hashed) !== -1);
11817 });
11818 }
11819 return result;
11820 }
11821 /**
11822 * Refreshes the list of available options shown
11823 * in the autocomplete dropdown menu.
11824 *
11825 */
11826 refreshOptions(triggerDropdown = true) {
11827 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
11828 var create;
11829 const groups = {};
11830 const groups_order = [];
11831 var self = this;
11832 var query = self.inputValue();
11833 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
11834 var results = self.search(query);
11835 var active_option = null;
11836 var show_dropdown = self.settings.shouldOpen || false;
11837 var dropdown_content = self.dropdown_content;
11838 if (same_query) {
11839 active_option = self.activeOption;
11840 if (active_option) {
11841 active_group = active_option.closest('[data-group]');
11842 }
11843 }
11844 // build markup
11845 n = results.items.length;
11846 if (typeof self.settings.maxOptions === 'number') {
11847 n = Math.min(n, self.settings.maxOptions);
11848 }
11849 if (n > 0) {
11850 show_dropdown = true;
11851 }
11852 // get fragment for group and the position of the group in group_order
11853 const getGroupFragment = (optgroup, order) => {
11854 let group_order_i = groups[optgroup];
11855 if (group_order_i !== undefined) {
11856 let order_group = groups_order[group_order_i];
11857 if (order_group !== undefined) {
11858 return [group_order_i, order_group.fragment];
11859 }
11860 }
11861 let group_fragment = document.createDocumentFragment();
11862 group_order_i = groups_order.length;
11863 groups_order.push({ fragment: group_fragment, order, optgroup });
11864 return [group_order_i, group_fragment];
11865 };
11866 // render and group available options individually
11867 for (i = 0; i < n; i++) {
11868 // get option dom element
11869 let item = results.items[i];
11870 if (!item)
11871 continue;
11872 let opt_value = item.id;
11873 let option = self.options[opt_value];
11874 if (option === undefined)
11875 continue;
11876 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
11877 let option_el = self.getOption(opt_hash, true);
11878 // toggle 'selected' class
11879 if (!self.settings.hideSelected) {
11880 option_el.classList.toggle('selected', self.items.includes(opt_hash));
11881 }
11882 optgroup = option[self.settings.optgroupField] || '';
11883 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
11884 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
11885 optgroup = optgroups[j];
11886 let order = option.$order;
11887 let self_optgroup = self.optgroups[optgroup];
11888 if (self_optgroup === undefined) {
11889 optgroup = '';
11890 }
11891 else {
11892 order = self_optgroup.$order;
11893 }
11894 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
11895 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
11896 if (j > 0) {
11897 option_el = option_el.cloneNode(true);
11898 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
11899 option_el.classList.add('ts-cloned');
11900 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
11901 // make sure we keep the activeOption in the same group
11902 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
11903 if (active_group && active_group.dataset.group === optgroup.toString()) {
11904 active_option = option_el;
11905 }
11906 }
11907 }
11908 group_fragment.appendChild(option_el);
11909 if (optgroup != '') {
11910 groups[optgroup] = group_order_i;
11911 }
11912 }
11913 }
11914 // sort optgroups
11915 if (self.settings.lockOptgroupOrder) {
11916 groups_order.sort((a, b) => {
11917 return a.order - b.order;
11918 });
11919 }
11920 // render optgroup headers & join groups
11921 html = document.createDocumentFragment();
11922 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
11923 let group_fragment = group_order.fragment;
11924 let optgroup = group_order.optgroup;
11925 if (!group_fragment || !group_fragment.children.length)
11926 return;
11927 let group_heading = self.optgroups[optgroup];
11928 if (group_heading !== undefined) {
11929 let group_options = document.createDocumentFragment();
11930 let header = self.render('optgroup_header', group_heading);
11931 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
11932 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
11933 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
11934 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
11935 }
11936 else {
11937 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
11938 }
11939 });
11940 dropdown_content.innerHTML = '';
11941 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
11942 // highlight matching terms inline
11943 if (self.settings.highlight) {
11944 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
11945 if (results.query.length && results.tokens.length) {
11946 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
11947 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
11948 });
11949 }
11950 }
11951 // helper method for adding templates to dropdown
11952 var add_template = (template) => {
11953 let content = self.render(template, { input: query });
11954 if (content) {
11955 show_dropdown = true;
11956 dropdown_content.insertBefore(content, dropdown_content.firstChild);
11957 }
11958 return content;
11959 };
11960 // add loading message
11961 if (self.loading) {
11962 add_template('loading');
11963 // invalid query
11964 }
11965 else if (!self.settings.shouldLoad.call(self, query)) {
11966 add_template('not_loading');
11967 // add no_results message
11968 }
11969 else if (results.items.length === 0) {
11970 add_template('no_results');
11971 }
11972 // add create option
11973 has_create_option = self.canCreate(query);
11974 if (has_create_option) {
11975 create = add_template('option_create');
11976 }
11977 // activate
11978 self.hasOptions = results.items.length > 0 || has_create_option;
11979 if (show_dropdown) {
11980 if (results.items.length > 0) {
11981 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
11982 active_option = self.getOption(self.items[0]);
11983 }
11984 if (!dropdown_content.contains(active_option)) {
11985 let active_index = 0;
11986 if (create && !self.settings.addPrecedence) {
11987 active_index = 1;
11988 }
11989 active_option = self.selectable()[active_index];
11990 }
11991 }
11992 else if (create) {
11993 active_option = create;
11994 }
11995 if (triggerDropdown && !self.isOpen) {
11996 self.open();
11997 self.scrollToOption(active_option, 'auto');
11998 }
11999 self.setActiveOption(active_option);
12000 }
12001 else {
12002 self.clearActiveOption();
12003 if (triggerDropdown && self.isOpen) {
12004 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12005 }
12006 }
12007 }
12008 /**
12009 * Return list of selectable options
12010 *
12011 */
12012 selectable() {
12013 return this.dropdown_content.querySelectorAll('[data-selectable]');
12014 }
12015 /**
12016 * Adds an available option. If it already exists,
12017 * nothing will happen. Note: this does not refresh
12018 * the options list dropdown (use `refreshOptions`
12019 * for that).
12020 *
12021 * Usage:
12022 *
12023 * this.addOption(data)
12024 *
12025 */
12026 addOption(data, user_created = false) {
12027 const self = this;
12028 // @deprecated 1.7.7
12029 // use addOptions( array, user_created ) for adding multiple options
12030 if (Array.isArray(data)) {
12031 self.addOptions(data, user_created);
12032 return false;
12033 }
12034 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12035 if (key === null || self.options.hasOwnProperty(key)) {
12036 return false;
12037 }
12038 data.$order = data.$order || ++self.order;
12039 data.$id = self.inputId + '-opt-' + data.$order;
12040 self.options[key] = data;
12041 self.lastQuery = null;
12042 if (user_created) {
12043 self.userOptions[key] = user_created;
12044 self.trigger('option_add', key, data);
12045 }
12046 return key;
12047 }
12048 /**
12049 * Add multiple options
12050 *
12051 */
12052 addOptions(data, user_created = false) {
12053 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12054 this.addOption(dat, user_created);
12055 });
12056 }
12057 /**
12058 * @deprecated 1.7.7
12059 */
12060 registerOption(data) {
12061 return this.addOption(data);
12062 }
12063 /**
12064 * Registers an option group to the pool of option groups.
12065 *
12066 * @return {boolean|string}
12067 */
12068 registerOptionGroup(data) {
12069 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12070 if (key === null)
12071 return false;
12072 data.$order = data.$order || ++this.order;
12073 this.optgroups[key] = data;
12074 return key;
12075 }
12076 /**
12077 * Registers a new optgroup for options
12078 * to be bucketed into.
12079 *
12080 */
12081 addOptionGroup(id, data) {
12082 var hashed_id;
12083 data[this.settings.optgroupValueField] = id;
12084 if (hashed_id = this.registerOptionGroup(data)) {
12085 this.trigger('optgroup_add', hashed_id, data);
12086 }
12087 }
12088 /**
12089 * Removes an existing option group.
12090 *
12091 */
12092 removeOptionGroup(id) {
12093 if (this.optgroups.hasOwnProperty(id)) {
12094 delete this.optgroups[id];
12095 this.clearCache();
12096 this.trigger('optgroup_remove', id);
12097 }
12098 }
12099 /**
12100 * Clears all existing option groups.
12101 */
12102 clearOptionGroups() {
12103 this.optgroups = {};
12104 this.clearCache();
12105 this.trigger('optgroup_clear');
12106 }
12107 /**
12108 * Updates an option available for selection. If
12109 * it is visible in the selected items or options
12110 * dropdown, it will be re-rendered automatically.
12111 *
12112 */
12113 updateOption(value, data) {
12114 const self = this;
12115 var item_new;
12116 var index_item;
12117 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12118 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12119 // sanity checks
12120 if (value_old === null)
12121 return;
12122 const data_old = self.options[value_old];
12123 if (data_old == undefined)
12124 return;
12125 if (typeof value_new !== 'string')
12126 throw new Error('Value must be set in option data');
12127 const option = self.getOption(value_old);
12128 const item = self.getItem(value_old);
12129 data.$order = data.$order || data_old.$order;
12130 delete self.options[value_old];
12131 // invalidate render cache
12132 // don't remove existing node yet, we'll remove it after replacing it
12133 self.uncacheValue(value_new);
12134 self.options[value_new] = data;
12135 // update the option if it's in the dropdown
12136 if (option) {
12137 if (self.dropdown_content.contains(option)) {
12138 const option_new = self._render('option', data);
12139 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12140 if (self.activeOption === option) {
12141 self.setActiveOption(option_new);
12142 }
12143 }
12144 option.remove();
12145 }
12146 // update the item if we have one
12147 if (item) {
12148 index_item = self.items.indexOf(value_old);
12149 if (index_item !== -1) {
12150 self.items.splice(index_item, 1, value_new);
12151 }
12152 item_new = self._render('item', data);
12153 if (item.classList.contains('active'))
12154 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12155 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12156 }
12157 // invalidate last query because we might have updated the sortField
12158 self.lastQuery = null;
12159 }
12160 /**
12161 * Removes a single option.
12162 *
12163 */
12164 removeOption(value, silent) {
12165 const self = this;
12166 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12167 self.uncacheValue(value);
12168 delete self.userOptions[value];
12169 delete self.options[value];
12170 self.lastQuery = null;
12171 self.trigger('option_remove', value);
12172 self.removeItem(value, silent);
12173 }
12174 /**
12175 * Clears all options.
12176 */
12177 clearOptions(filter) {
12178 const boundFilter = (filter || this.clearFilter).bind(this);
12179 this.loadedSearches = {};
12180 this.userOptions = {};
12181 this.clearCache();
12182 const selected = {};
12183 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12184 if (boundFilter(option, key)) {
12185 selected[key] = option;
12186 }
12187 });
12188 this.options = this.sifter.items = selected;
12189 this.lastQuery = null;
12190 this.trigger('option_clear');
12191 }
12192 /**
12193 * Used by clearOptions() to decide whether or not an option should be removed
12194 * Return true to keep an option, false to remove
12195 *
12196 */
12197 clearFilter(option, value) {
12198 if (this.items.indexOf(value) >= 0) {
12199 return true;
12200 }
12201 return false;
12202 }
12203 /**
12204 * Returns the dom element of the option
12205 * matching the given value.
12206 *
12207 */
12208 getOption(value, create = false) {
12209 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12210 if (hashed === null)
12211 return null;
12212 const option = this.options[hashed];
12213 if (option != undefined) {
12214 if (option.$div) {
12215 return option.$div;
12216 }
12217 if (create) {
12218 return this._render('option', option);
12219 }
12220 }
12221 return null;
12222 }
12223 /**
12224 * Returns the dom element of the next or previous dom element of the same type
12225 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12226 *
12227 */
12228 getAdjacent(option, direction, type = 'option') {
12229 var self = this, all;
12230 if (!option) {
12231 return null;
12232 }
12233 if (type == 'item') {
12234 all = self.controlChildren();
12235 }
12236 else {
12237 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12238 }
12239 for (let i = 0; i < all.length; i++) {
12240 if (all[i] != option) {
12241 continue;
12242 }
12243 if (direction > 0) {
12244 return all[i + 1];
12245 }
12246 return all[i - 1];
12247 }
12248 return null;
12249 }
12250 /**
12251 * Returns the dom element of the item
12252 * matching the given value.
12253 *
12254 */
12255 getItem(item) {
12256 if (typeof item == 'object') {
12257 return item;
12258 }
12259 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12260 return value !== null
12261 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12262 : null;
12263 }
12264 /**
12265 * "Selects" multiple items at once. Adds them to the list
12266 * at the current caret position.
12267 *
12268 */
12269 addItems(values, silent) {
12270 var self = this;
12271 var items = Array.isArray(values) ? values : [values];
12272 items = items.filter(x => self.items.indexOf(x) === -1);
12273 const last_item = items[items.length - 1];
12274 items.forEach(item => {
12275 self.isPending = (item !== last_item);
12276 self.addItem(item, silent);
12277 });
12278 }
12279 /**
12280 * "Selects" an item. Adds it to the list
12281 * at the current caret position.
12282 *
12283 */
12284 addItem(value, silent) {
12285 var events = silent ? [] : ['change', 'dropdown_close'];
12286 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12287 var item, wasFull;
12288 const self = this;
12289 const inputMode = self.settings.mode;
12290 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12291 if (hashed && self.items.indexOf(hashed) !== -1) {
12292 if (inputMode === 'single') {
12293 self.close();
12294 }
12295 if (inputMode === 'single' || !self.settings.duplicates) {
12296 return;
12297 }
12298 }
12299 if (hashed === null || !self.options.hasOwnProperty(hashed))
12300 return;
12301 if (inputMode === 'single')
12302 self.clear(silent);
12303 if (inputMode === 'multi' && self.isFull())
12304 return;
12305 item = self._render('item', self.options[hashed]);
12306 if (self.control.contains(item)) { // duplicates
12307 item = item.cloneNode(true);
12308 }
12309 wasFull = self.isFull();
12310 self.items.splice(self.caretPos, 0, hashed);
12311 self.insertAtCaret(item);
12312 if (self.isSetup) {
12313 // update menu / remove the option (if this is not one item being added as part of series)
12314 if (!self.isPending && self.settings.hideSelected) {
12315 let option = self.getOption(hashed);
12316 let next = self.getAdjacent(option, 1);
12317 if (next) {
12318 self.setActiveOption(next);
12319 }
12320 }
12321 // refreshOptions after setActiveOption(),
12322 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12323 if (!self.isPending && !self.settings.closeAfterSelect) {
12324 self.refreshOptions(self.isFocused && inputMode !== 'single');
12325 }
12326 // hide the menu if the maximum number of items have been selected or no options are left
12327 if (self.settings.closeAfterSelect != false && self.isFull()) {
12328 self.close();
12329 }
12330 else if (!self.isPending) {
12331 self.positionDropdown();
12332 }
12333 self.trigger('item_add', hashed, item);
12334 if (!self.isPending) {
12335 self.updateOriginalInput({ silent: silent });
12336 }
12337 }
12338 if (!self.isPending || (!wasFull && self.isFull())) {
12339 self.inputState();
12340 self.refreshState();
12341 }
12342 });
12343 }
12344 /**
12345 * Removes the selected item matching
12346 * the provided value.
12347 *
12348 */
12349 removeItem(item = null, silent) {
12350 const self = this;
12351 item = self.getItem(item);
12352 if (!item)
12353 return;
12354 var i, idx;
12355 const value = item.dataset.value;
12356 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
12357 item.remove();
12358 if (item.classList.contains('active')) {
12359 idx = self.activeItems.indexOf(item);
12360 self.activeItems.splice(idx, 1);
12361 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12362 }
12363 self.items.splice(i, 1);
12364 self.lastQuery = null;
12365 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
12366 self.removeOption(value, silent);
12367 }
12368 if (i < self.caretPos) {
12369 self.setCaret(self.caretPos - 1);
12370 }
12371 self.updateOriginalInput({ silent: silent });
12372 self.refreshState();
12373 self.positionDropdown();
12374 self.trigger('item_remove', value, item);
12375 }
12376 /**
12377 * Invokes the `create` method provided in the
12378 * TomSelect options that should provide the data
12379 * for the new item, given the user input.
12380 *
12381 * Once this completes, it will be added
12382 * to the item list.
12383 *
12384 */
12385 createItem(input = null, callback = () => { }) {
12386 // triggerDropdown parameter @deprecated 2.1.1
12387 if (arguments.length === 3) {
12388 callback = arguments[2];
12389 }
12390 if (typeof callback != 'function') {
12391 callback = () => { };
12392 }
12393 var self = this;
12394 var caret = self.caretPos;
12395 var output;
12396 input = input || self.inputValue();
12397 if (!self.canCreate(input)) {
12398 callback();
12399 return false;
12400 }
12401 self.lock();
12402 var created = false;
12403 var create = (data) => {
12404 self.unlock();
12405 if (!data || typeof data !== 'object')
12406 return callback();
12407 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12408 if (typeof value !== 'string') {
12409 return callback();
12410 }
12411 self.setTextboxValue();
12412 self.addOption(data, true);
12413 self.setCaret(caret);
12414 self.addItem(value);
12415 callback(data);
12416 created = true;
12417 };
12418 if (typeof self.settings.create === 'function') {
12419 output = self.settings.create.call(this, input, create);
12420 }
12421 else {
12422 output = {
12423 [self.settings.labelField]: input,
12424 [self.settings.valueField]: input,
12425 };
12426 }
12427 if (!created) {
12428 create(output);
12429 }
12430 return true;
12431 }
12432 /**
12433 * Re-renders the selected item lists.
12434 */
12435 refreshItems() {
12436 var self = this;
12437 self.lastQuery = null;
12438 if (self.isSetup) {
12439 self.addItems(self.items);
12440 }
12441 self.updateOriginalInput();
12442 self.refreshState();
12443 }
12444 /**
12445 * Updates all state-dependent attributes
12446 * and CSS classes.
12447 */
12448 refreshState() {
12449 const self = this;
12450 self.refreshValidityState();
12451 const isFull = self.isFull();
12452 const isLocked = self.isLocked;
12453 self.wrapper.classList.toggle('rtl', self.rtl);
12454 const wrap_classList = self.wrapper.classList;
12455 wrap_classList.toggle('focus', self.isFocused);
12456 wrap_classList.toggle('disabled', self.isDisabled);
12457 wrap_classList.toggle('readonly', self.isReadOnly);
12458 wrap_classList.toggle('required', self.isRequired);
12459 wrap_classList.toggle('invalid', !self.isValid);
12460 wrap_classList.toggle('locked', isLocked);
12461 wrap_classList.toggle('full', isFull);
12462 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
12463 wrap_classList.toggle('dropdown-active', self.isOpen);
12464 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
12465 wrap_classList.toggle('has-items', self.items.length > 0);
12466 }
12467 /**
12468 * Update the `required` attribute of both input and control input.
12469 *
12470 * The `required` property needs to be activated on the control input
12471 * for the error to be displayed at the right place. `required` also
12472 * needs to be temporarily deactivated on the input since the input is
12473 * hidden and can't show errors.
12474 */
12475 refreshValidityState() {
12476 var self = this;
12477 if (!self.input.validity) {
12478 return;
12479 }
12480 self.isValid = self.input.validity.valid;
12481 self.isInvalid = !self.isValid;
12482 }
12483 /**
12484 * Determines whether or not more items can be added
12485 * to the control without exceeding the user-defined maximum.
12486 *
12487 * @returns {boolean}
12488 */
12489 isFull() {
12490 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
12491 }
12492 /**
12493 * Refreshes the original <select> or <input>
12494 * element to reflect the current state.
12495 *
12496 */
12497 updateOriginalInput(opts = {}) {
12498 const self = this;
12499 var option, label;
12500 const empty_option = self.input.querySelector('option[value=""]');
12501 if (self.is_select_tag) {
12502 const selected = [];
12503 const has_selected = self.input.querySelectorAll('option:checked').length;
12504 function AddSelected(option_el, value, label) {
12505 if (!option_el) {
12506 option_el = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<option value="' + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html)(value) + '">' + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html)(label) + '</option>');
12507 }
12508 // don't move empty option from top of list
12509 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
12510 if (option_el != empty_option) {
12511 self.input.append(option_el);
12512 }
12513 selected.push(option_el);
12514 // marking empty option as selected can break validation
12515 // fixes https://github.com/orchidjs/tom-select/issues/303
12516 if (option_el != empty_option || has_selected > 0) {
12517 option_el.selected = true;
12518 }
12519 return option_el;
12520 }
12521 // unselect all selected options
12522 self.input.querySelectorAll('option:checked').forEach((option_el) => {
12523 option_el.selected = false;
12524 });
12525 // nothing selected?
12526 if (self.items.length == 0 && self.settings.mode == 'single') {
12527 AddSelected(empty_option, "", "");
12528 // order selected <option> tags for values in self.items
12529 }
12530 else {
12531 self.items.forEach((value) => {
12532 option = self.options[value];
12533 label = option[self.settings.labelField] || '';
12534 if (selected.includes(option.$option)) {
12535 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
12536 AddSelected(reuse_opt, value, label);
12537 }
12538 else {
12539 option.$option = AddSelected(option.$option, value, label);
12540 }
12541 });
12542 }
12543 }
12544 else {
12545 self.input.value = self.getValue();
12546 }
12547 if (self.isSetup) {
12548 if (!opts.silent) {
12549 self.trigger('change', self.getValue());
12550 }
12551 }
12552 }
12553 /**
12554 * Shows the autocomplete dropdown containing
12555 * the available options.
12556 */
12557 open() {
12558 var self = this;
12559 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
12560 return;
12561 self.isOpen = true;
12562 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
12563 self.refreshState();
12564 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
12565 self.positionDropdown();
12566 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
12567 self.focus();
12568 self.trigger('dropdown_open', self.dropdown);
12569 }
12570 /**
12571 * Closes the autocomplete dropdown menu.
12572 */
12573 close(setTextboxValue = true) {
12574 var self = this;
12575 var trigger = self.isOpen;
12576 if (setTextboxValue) {
12577 // before blur() to prevent form onchange event
12578 self.setTextboxValue();
12579 if (self.settings.mode === 'single' && self.items.length) {
12580 self.inputState();
12581 }
12582 }
12583 self.isOpen = false;
12584 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
12585 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
12586 if (self.settings.hideSelected) {
12587 self.clearActiveOption();
12588 }
12589 self.refreshState();
12590 if (trigger)
12591 self.trigger('dropdown_close', self.dropdown);
12592 }
12593 /**
12594 * Calculates and applies the appropriate
12595 * position of the dropdown if dropdownParent = 'body'.
12596 * Otherwise, position is determined by css
12597 */
12598 positionDropdown() {
12599 if (this.settings.dropdownParent !== 'body') {
12600 return;
12601 }
12602 var context = this.control;
12603 var rect = context.getBoundingClientRect();
12604 var top = context.offsetHeight + rect.top + window.scrollY;
12605 var left = rect.left + window.scrollX;
12606 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
12607 width: rect.width + 'px',
12608 top: top + 'px',
12609 left: left + 'px'
12610 });
12611 }
12612 /**
12613 * Resets / clears all selected items
12614 * from the control.
12615 *
12616 */
12617 clear(silent) {
12618 var self = this;
12619 if (!self.items.length)
12620 return;
12621 var items = self.controlChildren();
12622 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
12623 self.removeItem(item, true);
12624 });
12625 self.inputState();
12626 if (!silent)
12627 self.updateOriginalInput();
12628 self.trigger('clear');
12629 }
12630 /**
12631 * A helper method for inserting an element
12632 * at the current caret position.
12633 *
12634 */
12635 insertAtCaret(el) {
12636 const self = this;
12637 const caret = self.caretPos;
12638 const target = self.control;
12639 target.insertBefore(el, target.children[caret] || null);
12640 self.setCaret(caret + 1);
12641 }
12642 /**
12643 * Removes the current selected item(s).
12644 *
12645 */
12646 deleteSelection(e) {
12647 var direction, selection, caret, tail;
12648 var self = this;
12649 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
12650 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
12651 // determine items that will be removed
12652 const rm_items = [];
12653 if (self.activeItems.length) {
12654 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
12655 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
12656 if (direction > 0) {
12657 caret++;
12658 }
12659 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
12660 }
12661 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
12662 const items = self.controlChildren();
12663 let rm_item;
12664 if (direction < 0 && selection.start === 0 && selection.length === 0) {
12665 rm_item = items[self.caretPos - 1];
12666 }
12667 else if (direction > 0 && selection.start === self.inputValue().length) {
12668 rm_item = items[self.caretPos];
12669 }
12670 if (rm_item !== undefined) {
12671 rm_items.push(rm_item);
12672 }
12673 }
12674 if (!self.shouldDelete(rm_items, e)) {
12675 return false;
12676 }
12677 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
12678 // perform removal
12679 if (typeof caret !== 'undefined') {
12680 self.setCaret(caret);
12681 }
12682 while (rm_items.length) {
12683 self.removeItem(rm_items.pop());
12684 }
12685 self.inputState();
12686 self.positionDropdown();
12687 self.refreshOptions(false);
12688 return true;
12689 }
12690 /**
12691 * Return true if the items should be deleted
12692 */
12693 shouldDelete(items, evt) {
12694 const values = items.map(item => item.dataset.value);
12695 // allow the callback to abort
12696 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
12697 return false;
12698 }
12699 return true;
12700 }
12701 /**
12702 * Selects the previous / next item (depending on the `direction` argument).
12703 *
12704 * > 0 - right
12705 * < 0 - left
12706 *
12707 */
12708 advanceSelection(direction, e) {
12709 var last_active, adjacent, self = this;
12710 if (self.rtl)
12711 direction *= -1;
12712 if (self.inputValue().length)
12713 return;
12714 // add or remove to active items
12715 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e)) {
12716 last_active = self.getLastActive(direction);
12717 if (last_active) {
12718 if (!last_active.classList.contains('active')) {
12719 adjacent = last_active;
12720 }
12721 else {
12722 adjacent = self.getAdjacent(last_active, direction, 'item');
12723 }
12724 // if no active item, get items adjacent to the control input
12725 }
12726 else if (direction > 0) {
12727 adjacent = self.control_input.nextElementSibling;
12728 }
12729 else {
12730 adjacent = self.control_input.previousElementSibling;
12731 }
12732 if (adjacent) {
12733 if (adjacent.classList.contains('active')) {
12734 self.removeActiveItem(last_active);
12735 }
12736 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
12737 }
12738 // move caret to the left or right
12739 }
12740 else {
12741 self.moveCaret(direction);
12742 }
12743 }
12744 moveCaret(direction) { }
12745 /**
12746 * Get the last active item
12747 *
12748 */
12749 getLastActive(direction) {
12750 let last_active = this.control.querySelector('.last-active');
12751 if (last_active) {
12752 return last_active;
12753 }
12754 var result = this.control.querySelectorAll('.active');
12755 if (result) {
12756 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
12757 }
12758 }
12759 /**
12760 * Moves the caret to the specified index.
12761 *
12762 * The input must be moved by leaving it in place and moving the
12763 * siblings, due to the fact that focus cannot be restored once lost
12764 * on mobile webkit devices
12765 *
12766 */
12767 setCaret(new_pos) {
12768 this.caretPos = this.items.length;
12769 }
12770 /**
12771 * Return list of item dom elements
12772 *
12773 */
12774 controlChildren() {
12775 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
12776 }
12777 /**
12778 * Disables user input on the control. Used while
12779 * items are being asynchronously created.
12780 */
12781 lock() {
12782 this.setLocked(true);
12783 }
12784 /**
12785 * Re-enables user input on the control.
12786 */
12787 unlock() {
12788 this.setLocked(false);
12789 }
12790 /**
12791 * Disable or enable user input on the control
12792 */
12793 setLocked(lock = this.isReadOnly || this.isDisabled) {
12794 this.isLocked = lock;
12795 this.refreshState();
12796 }
12797 /**
12798 * Disables user input on the control completely.
12799 * While disabled, it cannot receive focus.
12800 */
12801 disable() {
12802 this.setDisabled(true);
12803 this.close();
12804 }
12805 /**
12806 * Enables the control so that it can respond
12807 * to focus and user input.
12808 */
12809 enable() {
12810 this.setDisabled(false);
12811 }
12812 setDisabled(disabled) {
12813 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
12814 this.isDisabled = disabled;
12815 this.input.disabled = disabled;
12816 this.control_input.disabled = disabled;
12817 this.setLocked();
12818 }
12819 setReadOnly(isReadOnly) {
12820 this.isReadOnly = isReadOnly;
12821 this.input.readOnly = isReadOnly;
12822 this.control_input.readOnly = isReadOnly;
12823 this.setLocked();
12824 }
12825 /**
12826 * Completely destroys the control and
12827 * unbinds all event listeners so that it can
12828 * be garbage collected.
12829 */
12830 destroy() {
12831 var self = this;
12832 var revertSettings = self.revertSettings;
12833 self.trigger('destroy');
12834 self.off();
12835 self.wrapper.remove();
12836 self.dropdown.remove();
12837 self.input.innerHTML = revertSettings.innerHTML;
12838 self.input.tabIndex = revertSettings.tabIndex;
12839 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
12840 self._destroy();
12841 delete self.input.tomselect;
12842 }
12843 /**
12844 * A helper method for rendering "item" and
12845 * "option" templates, given the data.
12846 *
12847 */
12848 render(templateName, data) {
12849 var id, html;
12850 const self = this;
12851 if (typeof this.settings.render[templateName] !== 'function') {
12852 return null;
12853 }
12854 // render markup
12855 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
12856 if (!html) {
12857 return null;
12858 }
12859 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
12860 // add mandatory attributes
12861 if (templateName === 'option' || templateName === 'option_create') {
12862 if (data[self.settings.disabledField]) {
12863 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
12864 }
12865 else {
12866 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
12867 }
12868 }
12869 else if (templateName === 'optgroup') {
12870 id = data.group[self.settings.optgroupValueField];
12871 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
12872 if (data.group[self.settings.disabledField]) {
12873 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
12874 }
12875 }
12876 if (templateName === 'option' || templateName === 'item') {
12877 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
12878 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
12879 // make sure we have some classes if a template is overwritten
12880 if (templateName === 'item') {
12881 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
12882 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
12883 }
12884 else {
12885 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
12886 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
12887 role: 'option',
12888 id: data.$id
12889 });
12890 // update cache
12891 data.$div = html;
12892 self.options[value] = data;
12893 }
12894 }
12895 return html;
12896 }
12897 /**
12898 * Type guarded rendering
12899 *
12900 */
12901 _render(templateName, data) {
12902 const html = this.render(templateName, data);
12903 if (html == null) {
12904 throw 'HTMLElement expected';
12905 }
12906 return html;
12907 }
12908 /**
12909 * Clears the render cache for a template. If
12910 * no template is given, clears all render
12911 * caches.
12912 *
12913 */
12914 clearCache() {
12915 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
12916 if (option.$div) {
12917 option.$div.remove();
12918 delete option.$div;
12919 }
12920 });
12921 }
12922 /**
12923 * Removes a value from item and option caches
12924 *
12925 */
12926 uncacheValue(value) {
12927 const option_el = this.getOption(value);
12928 if (option_el)
12929 option_el.remove();
12930 }
12931 /**
12932 * Determines whether or not to display the
12933 * create item prompt, given a user input.
12934 *
12935 */
12936 canCreate(input) {
12937 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
12938 }
12939 /**
12940 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
12941 *
12942 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
12943 *
12944 * });
12945 */
12946 hook(when, method, new_fn) {
12947 var self = this;
12948 var orig_method = self[method];
12949 self[method] = function () {
12950 var result, result_new;
12951 if (when === 'after') {
12952 result = orig_method.apply(self, arguments);
12953 }
12954 result_new = new_fn.apply(self, arguments);
12955 if (when === 'instead') {
12956 return result_new;
12957 }
12958 if (when === 'before') {
12959 result = orig_method.apply(self, arguments);
12960 }
12961 return result;
12962 };
12963 }
12964 }
12965 ;
12966 //# sourceMappingURL=tom-select.js.map
12967
12968 /***/ },
12969
12970 /***/ "./node_modules/tom-select/dist/esm/utils.js"
12971 /*!***************************************************!*\
12972 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
12973 \***************************************************/
12974 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
12975
12976 "use strict";
12977 __webpack_require__.r(__webpack_exports__);
12978 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12979 /* harmony export */ addEvent: () => (/* binding */ addEvent),
12980 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
12981 /* harmony export */ append: () => (/* binding */ append),
12982 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
12983 /* harmony export */ escape_html: () => (/* binding */ escape_html),
12984 /* harmony export */ getId: () => (/* binding */ getId),
12985 /* harmony export */ getSelection: () => (/* binding */ getSelection),
12986 /* harmony export */ get_hash: () => (/* binding */ get_hash),
12987 /* harmony export */ hash_key: () => (/* binding */ hash_key),
12988 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
12989 /* harmony export */ iterate: () => (/* binding */ iterate),
12990 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
12991 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
12992 /* harmony export */ timeout: () => (/* binding */ timeout)
12993 /* harmony export */ });
12994 /**
12995 * Converts a scalar to its best string representation
12996 * for hash keys and HTML attribute values.
12997 *
12998 * Transformations:
12999 * 'str' -> 'str'
13000 * null -> ''
13001 * undefined -> ''
13002 * true -> '1'
13003 * false -> '0'
13004 * 0 -> '0'
13005 * 1 -> '1'
13006 *
13007 */
13008 const hash_key = (value) => {
13009 if (typeof value === 'undefined' || value === null)
13010 return null;
13011 return get_hash(value);
13012 };
13013 const get_hash = (value) => {
13014 if (typeof value === 'boolean')
13015 return value ? '1' : '0';
13016 return value + '';
13017 };
13018 /**
13019 * Escapes a string for use within HTML.
13020 *
13021 */
13022 const escape_html = (str) => {
13023 return (str + '')
13024 .replace(/&/g, '&amp;')
13025 .replace(/</g, '&lt;')
13026 .replace(/>/g, '&gt;')
13027 .replace(/"/g, '&quot;');
13028 };
13029 /**
13030 * use setTimeout if timeout > 0
13031 */
13032 const timeout = (fn, timeout) => {
13033 if (timeout > 0) {
13034 return window.setTimeout(fn, timeout);
13035 }
13036 fn.call(null);
13037 return null;
13038 };
13039 /**
13040 * Debounce the user provided load function
13041 *
13042 */
13043 const loadDebounce = (fn, delay) => {
13044 var timeout;
13045 return function (value, callback) {
13046 var self = this;
13047 if (timeout) {
13048 self.loading = Math.max(self.loading - 1, 0);
13049 clearTimeout(timeout);
13050 }
13051 timeout = setTimeout(function () {
13052 timeout = null;
13053 self.loadedSearches[value] = true;
13054 fn.call(self, value, callback);
13055 }, delay);
13056 };
13057 };
13058 /**
13059 * Debounce all fired events types listed in `types`
13060 * while executing the provided `fn`.
13061 *
13062 */
13063 const debounce_events = (self, types, fn) => {
13064 var type;
13065 var trigger = self.trigger;
13066 var event_args = {};
13067 // override trigger method
13068 self.trigger = function () {
13069 var type = arguments[0];
13070 if (types.indexOf(type) !== -1) {
13071 event_args[type] = arguments;
13072 }
13073 else {
13074 return trigger.apply(self, arguments);
13075 }
13076 };
13077 // invoke provided function
13078 fn.apply(self, []);
13079 self.trigger = trigger;
13080 // trigger queued events
13081 for (type of types) {
13082 if (type in event_args) {
13083 trigger.apply(self, event_args[type]);
13084 }
13085 }
13086 };
13087 /**
13088 * Determines the current selection within a text input control.
13089 * Returns an object containing:
13090 * - start
13091 * - length
13092 *
13093 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13094 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13095 */
13096 const getSelection = (input) => {
13097 return {
13098 start: input.selectionStart || 0,
13099 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13100 };
13101 };
13102 /**
13103 * Prevent default
13104 *
13105 */
13106 const preventDefault = (evt, stop = false) => {
13107 if (evt) {
13108 evt.preventDefault();
13109 if (stop) {
13110 evt.stopPropagation();
13111 }
13112 }
13113 };
13114 /**
13115 * Add event helper
13116 *
13117 */
13118 const addEvent = (target, type, callback, options) => {
13119 target.addEventListener(type, callback, options);
13120 };
13121 /**
13122 * Return true if the requested key is down
13123 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13124 * The current evt may not always set ( eg calling advanceSelection() )
13125 *
13126 */
13127 const isKeyDown = (key_name, evt) => {
13128 if (!evt) {
13129 return false;
13130 }
13131 if (!evt[key_name]) {
13132 return false;
13133 }
13134 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13135 if (count === 1) {
13136 return true;
13137 }
13138 return false;
13139 };
13140 /**
13141 * Get the id of an element
13142 * If the id attribute is not set, set the attribute with the given id
13143 *
13144 */
13145 const getId = (el, id) => {
13146 const existing_id = el.getAttribute('id');
13147 if (existing_id) {
13148 return existing_id;
13149 }
13150 el.setAttribute('id', id);
13151 return id;
13152 };
13153 /**
13154 * Returns a string with backslashes added before characters that need to be escaped.
13155 */
13156 const addSlashes = (str) => {
13157 return str.replace(/[\\"']/g, '\\$&');
13158 };
13159 /**
13160 *
13161 */
13162 const append = (parent, node) => {
13163 if (node)
13164 parent.append(node);
13165 };
13166 /**
13167 * Iterates over arrays and hashes.
13168 *
13169 * ```
13170 * iterate(this.items, function(item, id) {
13171 * // invoked for each item
13172 * });
13173 * ```
13174 *
13175 */
13176 const iterate = (object, callback) => {
13177 if (Array.isArray(object)) {
13178 object.forEach(callback);
13179 }
13180 else {
13181 for (var key in object) {
13182 if (object.hasOwnProperty(key)) {
13183 callback(object[key], key);
13184 }
13185 }
13186 }
13187 };
13188 //# sourceMappingURL=utils.js.map
13189
13190 /***/ },
13191
13192 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13193 /*!*****************************************************!*\
13194 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13195 \*****************************************************/
13196 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13197
13198 "use strict";
13199 __webpack_require__.r(__webpack_exports__);
13200 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13201 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13202 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13203 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13204 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13205 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13206 /* harmony export */ getDom: () => (/* binding */ getDom),
13207 /* harmony export */ getTail: () => (/* binding */ getTail),
13208 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13209 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13210 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13211 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13212 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13213 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13214 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13215 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13216 /* harmony export */ });
13217 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13218
13219 /**
13220 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13221 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13222 *
13223 * param query should be {}
13224 */
13225 const getDom = (query) => {
13226 if (query.jquery) {
13227 return query[0];
13228 }
13229 if (query instanceof HTMLElement) {
13230 return query;
13231 }
13232 if (isHtmlString(query)) {
13233 var tpl = document.createElement('template');
13234 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13235 return tpl.content.firstChild;
13236 }
13237 return document.querySelector(query);
13238 };
13239 const isHtmlString = (arg) => {
13240 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13241 return true;
13242 }
13243 return false;
13244 };
13245 const escapeQuery = (query) => {
13246 return query.replace(/['"\\]/g, '\\$&');
13247 };
13248 /**
13249 * Dispatch an event
13250 *
13251 */
13252 const triggerEvent = (dom_el, event_name) => {
13253 var event = document.createEvent('HTMLEvents');
13254 event.initEvent(event_name, true, false);
13255 dom_el.dispatchEvent(event);
13256 };
13257 /**
13258 * Apply CSS rules to a dom element
13259 *
13260 */
13261 const applyCSS = (dom_el, css) => {
13262 Object.assign(dom_el.style, css);
13263 };
13264 /**
13265 * Add css classes
13266 *
13267 */
13268 const addClasses = (elmts, ...classes) => {
13269 var norm_classes = classesArray(classes);
13270 elmts = castAsArray(elmts);
13271 elmts.map(el => {
13272 norm_classes.map(cls => {
13273 el.classList.add(cls);
13274 });
13275 });
13276 };
13277 /**
13278 * Remove css classes
13279 *
13280 */
13281 const removeClasses = (elmts, ...classes) => {
13282 var norm_classes = classesArray(classes);
13283 elmts = castAsArray(elmts);
13284 elmts.map(el => {
13285 norm_classes.map(cls => {
13286 el.classList.remove(cls);
13287 });
13288 });
13289 };
13290 /**
13291 * Return arguments
13292 *
13293 */
13294 const classesArray = (args) => {
13295 var classes = [];
13296 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13297 if (typeof _classes === 'string') {
13298 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13299 }
13300 if (Array.isArray(_classes)) {
13301 classes = classes.concat(_classes);
13302 }
13303 });
13304 return classes.filter(Boolean);
13305 };
13306 /**
13307 * Create an array from arg if it's not already an array
13308 *
13309 */
13310 const castAsArray = (arg) => {
13311 if (!Array.isArray(arg)) {
13312 arg = [arg];
13313 }
13314 return arg;
13315 };
13316 /**
13317 * Get the closest node to the evt.target matching the selector
13318 * Stops at wrapper
13319 *
13320 */
13321 const parentMatch = (target, selector, wrapper) => {
13322 if (wrapper && !wrapper.contains(target)) {
13323 return;
13324 }
13325 while (target && target.matches) {
13326 if (target.matches(selector)) {
13327 return target;
13328 }
13329 target = target.parentNode;
13330 }
13331 };
13332 /**
13333 * Get the first or last item from an array
13334 *
13335 * > 0 - right (last)
13336 * <= 0 - left (first)
13337 *
13338 */
13339 const getTail = (list, direction = 0) => {
13340 if (direction > 0) {
13341 return list[list.length - 1];
13342 }
13343 return list[0];
13344 };
13345 /**
13346 * Return true if an object is empty
13347 *
13348 */
13349 const isEmptyObject = (obj) => {
13350 return (Object.keys(obj).length === 0);
13351 };
13352 /**
13353 * Get the index of an element amongst sibling nodes of the same type
13354 *
13355 */
13356 const nodeIndex = (el, amongst) => {
13357 if (!el)
13358 return -1;
13359 amongst = amongst || el.nodeName;
13360 var i = 0;
13361 while (el = el.previousElementSibling) {
13362 if (el.matches(amongst)) {
13363 i++;
13364 }
13365 }
13366 return i;
13367 };
13368 /**
13369 * Set attributes of an element
13370 *
13371 */
13372 const setAttr = (el, attrs) => {
13373 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
13374 if (val == null) {
13375 el.removeAttribute(attr);
13376 }
13377 else {
13378 el.setAttribute(attr, '' + val);
13379 }
13380 });
13381 };
13382 /**
13383 * Replace a node
13384 */
13385 const replaceNode = (existing, replacement) => {
13386 if (existing.parentNode)
13387 existing.parentNode.replaceChild(replacement, existing);
13388 };
13389 //# sourceMappingURL=vanilla.js.map
13390
13391 /***/ }
13392
13393 /******/ });
13394 /************************************************************************/
13395 /******/ // The module cache
13396 /******/ var __webpack_module_cache__ = {};
13397 /******/
13398 /******/ // The require function
13399 /******/ function __webpack_require__(moduleId) {
13400 /******/ // Check if module is in cache
13401 /******/ var cachedModule = __webpack_module_cache__[moduleId];
13402 /******/ if (cachedModule !== undefined) {
13403 /******/ return cachedModule.exports;
13404 /******/ }
13405 /******/ // Create a new module (and put it into the cache)
13406 /******/ var module = __webpack_module_cache__[moduleId] = {
13407 /******/ id: moduleId,
13408 /******/ // no module.loaded needed
13409 /******/ exports: {}
13410 /******/ };
13411 /******/
13412 /******/ // Execute the module function
13413 /******/ if (!(moduleId in __webpack_modules__)) {
13414 /******/ delete __webpack_module_cache__[moduleId];
13415 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
13416 /******/ e.code = 'MODULE_NOT_FOUND';
13417 /******/ throw e;
13418 /******/ }
13419 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
13420 /******/
13421 /******/ // Return the exports of the module
13422 /******/ return module.exports;
13423 /******/ }
13424 /******/
13425 /************************************************************************/
13426 /******/ /* webpack/runtime/compat get default export */
13427 /******/ (() => {
13428 /******/ // getDefaultExport function for compatibility with non-harmony modules
13429 /******/ __webpack_require__.n = (module) => {
13430 /******/ var getter = module && module.__esModule ?
13431 /******/ () => (module['default']) :
13432 /******/ () => (module);
13433 /******/ __webpack_require__.d(getter, { a: getter });
13434 /******/ return getter;
13435 /******/ };
13436 /******/ })();
13437 /******/
13438 /******/ /* webpack/runtime/define property getters */
13439 /******/ (() => {
13440 /******/ // define getter functions for harmony exports
13441 /******/ __webpack_require__.d = (exports, definition) => {
13442 /******/ for(var key in definition) {
13443 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13444 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
13445 /******/ }
13446 /******/ }
13447 /******/ };
13448 /******/ })();
13449 /******/
13450 /******/ /* webpack/runtime/hasOwnProperty shorthand */
13451 /******/ (() => {
13452 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
13453 /******/ })();
13454 /******/
13455 /******/ /* webpack/runtime/make namespace object */
13456 /******/ (() => {
13457 /******/ // define __esModule on exports
13458 /******/ __webpack_require__.r = (exports) => {
13459 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
13460 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13461 /******/ }
13462 /******/ Object.defineProperty(exports, '__esModule', { value: true });
13463 /******/ };
13464 /******/ })();
13465 /******/
13466 /******/ /* webpack/runtime/nonce */
13467 /******/ (() => {
13468 /******/ __webpack_require__.nc = undefined;
13469 /******/ })();
13470 /******/
13471 /************************************************************************/
13472 var __webpack_exports__ = {};
13473 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
13474 (() => {
13475 "use strict";
13476 /*!********************************************!*\
13477 !*** ./assets/src/js/admin/admin-order.js ***!
13478 \********************************************/
13479 __webpack_require__.r(__webpack_exports__);
13480 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
13481 /* harmony import */ var _order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./order/add-courses-to-order */ "./assets/src/js/admin/order/add-courses-to-order.js");
13482 /* harmony import */ var _order_refund_order__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./order/refund-order */ "./assets/src/js/admin/order/refund-order.js");
13483
13484
13485 //import modalSearchCourses from './order/modal-search-courses';
13486
13487
13488 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
13489 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
13490 (0,_order_refund_order__WEBPACK_IMPORTED_MODULE_2__["default"])();
13491 })();
13492
13493 /******/ })()
13494 ;
13495 //# sourceMappingURL=admin-order.js.map