PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.6
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.6
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.6, at assets/js/dist/admin/admin-order.js

13,633 lines 475.4 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 */ fullScreenView: () => (/* binding */ fullScreenView),
991 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
992 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
993 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
994 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
995 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
996 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
997 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
998 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
999 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
1000 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1001 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1002 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1003 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1004 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
1005 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
1006 /* harmony export */ });
1007 /**
1008 * Utils functions
1009 *
1010 * @param url
1011 * @param data
1012 * @param functions
1013 * @since 4.2.5.1
1014 * @version 1.0.7
1015 */
1016 const lpClassName = {
1017 hidden: 'lp-hidden',
1018 loading: 'loading',
1019 elCollapse: 'lp-collapse',
1020 elSectionToggle: '.lp-section-toggle',
1021 elTriggerToggle: '.lp-trigger-toggle',
1022 elBtnFullScreen: '.lp-btn-full-screen-view',
1023 elFullScreen: 'lp-full-screen-view',
1024 elBtnFullScreenClose: 'lp-full-screen-view__close'
1025 };
1026 const lpFetchAPI = (url, data = {}, functions = {}) => {
1027 if ('function' === typeof functions.before) {
1028 functions.before();
1029 }
1030 fetch(url, {
1031 method: 'GET',
1032 ...data
1033 }).then(response => response.json()).then(response => {
1034 if ('function' === typeof functions.success) {
1035 functions.success(response);
1036 }
1037 }).catch(err => {
1038 if ('function' === typeof functions.error) {
1039 functions.error(err);
1040 }
1041 }).finally(() => {
1042 if ('function' === typeof functions.completed) {
1043 functions.completed();
1044 }
1045 });
1046 };
1047
1048 /**
1049 * Get current URL without params.
1050 *
1051 * @since 4.2.5.1
1052 */
1053 const lpGetCurrentURLNoParam = () => {
1054 let currentUrl = window.location.href;
1055 const hasParams = currentUrl.includes('?');
1056 if (hasParams) {
1057 currentUrl = currentUrl.split('?')[0];
1058 }
1059 return currentUrl;
1060 };
1061 const lpAddQueryArgs = (endpoint, args) => {
1062 const url = new URL(endpoint);
1063 Object.keys(args).forEach(arg => {
1064 url.searchParams.set(arg, args[arg]);
1065 });
1066 return url;
1067 };
1068
1069 /**
1070 * Listen element viewed.
1071 *
1072 * @param el
1073 * @param callback
1074 * @since 4.2.5.8
1075 */
1076 const listenElementViewed = (el, callback) => {
1077 const observerSeeItem = new IntersectionObserver(function (entries) {
1078 for (const entry of entries) {
1079 if (entry.isIntersecting) {
1080 callback(entry);
1081 }
1082 }
1083 });
1084 observerSeeItem.observe(el);
1085 };
1086
1087 /**
1088 * Listen element created.
1089 *
1090 * @param callback
1091 * @since 4.2.5.8
1092 */
1093 const listenElementCreated = callback => {
1094 const observerCreateItem = new MutationObserver(function (mutations) {
1095 mutations.forEach(function (mutation) {
1096 if (mutation.addedNodes) {
1097 mutation.addedNodes.forEach(function (node) {
1098 if (node.nodeType === 1) {
1099 callback(node);
1100 }
1101 });
1102 }
1103 });
1104 });
1105 observerCreateItem.observe(document, {
1106 childList: true,
1107 subtree: true
1108 });
1109 // End.
1110 };
1111
1112 /**
1113 * Listen element created.
1114 *
1115 * @param selector
1116 * @param callback
1117 * @since 4.2.7.1
1118 */
1119 const lpOnElementReady = (selector, callback) => {
1120 const element = document.querySelector(selector);
1121 if (element) {
1122 callback(element);
1123 return;
1124 }
1125 const observer = new MutationObserver((mutations, obs) => {
1126 const element = document.querySelector(selector);
1127 if (element) {
1128 obs.disconnect();
1129 callback(element);
1130 }
1131 });
1132 observer.observe(document.documentElement, {
1133 childList: true,
1134 subtree: true
1135 });
1136 };
1137
1138 // Parse JSON from string with content include LP_AJAX_START.
1139 const lpAjaxParseJsonOld = data => {
1140 if (typeof data !== 'string') {
1141 return data;
1142 }
1143 const m = String.raw({
1144 raw: data
1145 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1146 try {
1147 if (m) {
1148 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1149 } else {
1150 data = JSON.parse(data);
1151 }
1152 } catch (e) {
1153 data = {};
1154 }
1155 return data;
1156 };
1157
1158 // status 0: hide, 1: show
1159 const lpShowHideEl = (el, status = 0) => {
1160 if (!el) {
1161 return;
1162 }
1163 if (!status) {
1164 el.classList.add(lpClassName.hidden);
1165 } else {
1166 el.classList.remove(lpClassName.hidden);
1167 }
1168 };
1169
1170 // status 0: hide, 1: show
1171 const lpSetLoadingEl = (el, status) => {
1172 if (!el) {
1173 return;
1174 }
1175 if (!status) {
1176 el.classList.remove(lpClassName.loading);
1177 } else {
1178 el.classList.add(lpClassName.loading);
1179 }
1180 };
1181
1182 // Toggle collapse section
1183 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1184 if (!elTriggerClassName) {
1185 elTriggerClassName = lpClassName.elTriggerToggle;
1186 }
1187
1188 // Exclude elements, which should not trigger the collapse toggle
1189 if (elsExclude && elsExclude.length > 0) {
1190 for (const elExclude of elsExclude) {
1191 if (target.closest(elExclude)) {
1192 return;
1193 }
1194 }
1195 }
1196 const elTrigger = target.closest(elTriggerClassName);
1197 if (!elTrigger) {
1198 return;
1199 }
1200
1201 //console.log( 'elTrigger', elTrigger );
1202
1203 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1204 if (!elSectionToggle) {
1205 return;
1206 }
1207 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1208 if ('function' === typeof callback) {
1209 callback(elSectionToggle);
1210 }
1211 };
1212
1213 // Get data of form
1214 const getDataOfForm = form => {
1215 const dataSend = {};
1216 const formData = new FormData(form);
1217 for (const pair of formData.entries()) {
1218 const key = pair[0];
1219 const value = formData.getAll(key);
1220 if (!dataSend.hasOwnProperty(key)) {
1221 // Convert value array to string.
1222 dataSend[key] = value.join(',');
1223 }
1224 }
1225 return dataSend;
1226 };
1227
1228 // Get field keys of form
1229 const getFieldKeysOfForm = form => {
1230 const keys = [];
1231 const elements = form.elements;
1232 for (let i = 0; i < elements.length; i++) {
1233 const name = elements[i].name;
1234 if (name && !keys.includes(name)) {
1235 keys.push(name);
1236 }
1237 }
1238 return keys;
1239 };
1240
1241 // Merge data handle with data form.
1242 const mergeDataWithDatForm = (elForm, dataHandle) => {
1243 const dataForm = getDataOfForm(elForm);
1244 const keys = getFieldKeysOfForm(elForm);
1245 keys.forEach(key => {
1246 if (!dataForm.hasOwnProperty(key)) {
1247 delete dataHandle[key];
1248 } else if (dataForm[key][0] === '') {
1249 delete dataForm[key];
1250 delete dataHandle[key];
1251 }
1252 });
1253 dataHandle = {
1254 ...dataHandle,
1255 ...dataForm
1256 };
1257 return dataHandle;
1258 };
1259
1260 /**
1261 * Event trigger
1262 * For each list of event handlers, listen event on document.
1263 *
1264 * eventName: 'click', 'change', ...
1265 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1266 *
1267 * @param eventName
1268 * @param eventHandlers
1269 */
1270 const eventHandlers = (eventName, eventHandlers) => {
1271 document.addEventListener(eventName, e => {
1272 const target = e.target;
1273 let args = {
1274 e,
1275 target
1276 };
1277 eventHandlers.forEach(eventHandler => {
1278 args = {
1279 ...args,
1280 ...eventHandler
1281 };
1282
1283 //console.log( args );
1284
1285 // Check condition before call back
1286 if (eventHandler.conditionBeforeCallBack) {
1287 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1288 return;
1289 }
1290 }
1291
1292 // Special check for keydown event with checkIsEventEnter = true
1293 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1294 if (e.key !== 'Enter') {
1295 return;
1296 }
1297 }
1298 if (target.closest(eventHandler.selector)) {
1299 if (eventHandler.class) {
1300 // Call method of class, function callBack will understand exactly {this} is class object.
1301 eventHandler.class[eventHandler.callBack](args);
1302 } else {
1303 // For send args is objected, {this} is eventHandler object, not class object.
1304 eventHandler.callBack(args);
1305 }
1306 }
1307 });
1308 });
1309 };
1310
1311 /**
1312 * Debounce - delays function execution until after `wait` ms of inactivity.
1313 *
1314 * Each call resets the timer. Only the last call in a burst executes.
1315 *
1316 * USE CASES:
1317 * - Search inputs, form validation, window resize
1318 * - Multiple elements need independent timers
1319 * - When you need to call with different arguments
1320 *
1321 * EXAMPLES:
1322 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1323 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1324 *
1325 * const debouncedResize = debounce( recalculateLayout, 250 );
1326 * window.addEventListener('resize', debouncedResize);
1327 *
1328 * ⚠️ Create ONCE outside event handlers, not inside.
1329 *
1330 * @param {Function} func - Function to debounce (can be anonymous)
1331 * @param {number} wait - Milliseconds to wait (default: 500)
1332 * @return {Function} Debounced wrapper function
1333 * @since 4.3.7
1334 * @version 1.0.0
1335 */
1336 const debounce = (func, wait = 500) => {
1337 let timer;
1338 return args => {
1339 clearTimeout(timer);
1340 timer = setTimeout(() => func(args), wait);
1341 };
1342 };
1343
1344 /**
1345 * Initialize lp-toggle-enable components.
1346 *
1347 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1348 * Reads initial state from `data-enabled` attribute ("true"/"false").
1349 * Calls `data-on-toggle` callback (if provided via options) on state change.
1350 *
1351 * HTML structure:
1352 * <label class="lp-toggle-enable" data-enabled="true">
1353 * <input type="checkbox" class="lp-toggle-enable__input" />
1354 * <span class="lp-toggle-enable__track"></span>
1355 * </label>
1356 *
1357 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1358 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1359 * @since 4.4.5
1360 * @version 1.0.0
1361 */
1362 window.lpToggleEnableInit = 0;
1363 const toggleEnable = (onToggle = null) => {
1364 if (window.lpToggleEnableInit) {
1365 return;
1366 }
1367 window.lpToggleEnableInit = 1;
1368 const selector = '.lp-toggle-enable';
1369 const updateUI = (toggle, isEnabled) => {
1370 toggle.classList.toggle('is-enabled', isEnabled);
1371 const input = toggle.querySelector('.lp-toggle-enable__input');
1372 if (input) {
1373 input.checked = isEnabled;
1374 input.value = isEnabled ? '1' : '0';
1375 }
1376 };
1377
1378 // Delegate click handling via eventHandlers.
1379 eventHandlers('click', [{
1380 selector,
1381 callBack: args => {
1382 const {
1383 e,
1384 target
1385 } = args;
1386 const toggle = target.closest(selector);
1387 if (!toggle || toggle.classList.contains('is-disabled')) {
1388 return;
1389 }
1390 e.preventDefault();
1391 const isEnabled = !toggle.classList.contains('is-enabled');
1392 updateUI(toggle, isEnabled);
1393 if ('function' === typeof onToggle) {
1394 onToggle(toggle, isEnabled);
1395 }
1396 }
1397 }]);
1398 };
1399
1400 /**
1401 * Initialize custom fullscreen view buttons.
1402 *
1403 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1404 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1405 * target element. Falls back to the button's parent element when
1406 * `data-target` is not provided.
1407 *
1408 * @since 4.4.5
1409 * @version 1.0.0
1410 */
1411 window.lpFullScreenViewInit = 0;
1412 const fullScreenView = () => {
1413 if (window.lpFullScreenViewInit) {
1414 return;
1415 }
1416 window.lpFullScreenViewInit = 1;
1417 let lastScrollY = 0;
1418 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1419 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1420 if (isFullscreen) {
1421 elTarget.classList.remove(lpClassName.elFullScreen);
1422 document.documentElement.classList.remove('lp-full-screen-active');
1423 window.scrollTo(0, lastScrollY);
1424 } else {
1425 lastScrollY = window.scrollY;
1426 elTarget.classList.add(lpClassName.elFullScreen);
1427 document.documentElement.classList.add('lp-full-screen-active');
1428 }
1429 if (!isFullscreen) {
1430 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1431 const closeButton = document.createElement('button');
1432 closeButton.type = 'button';
1433 closeButton.className = lpClassName.elBtnFullScreenClose;
1434 closeButton.setAttribute('aria-label', 'Close');
1435 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1436 closeButton.addEventListener('click', e => {
1437 e.preventDefault();
1438 lpToggleFullscreenView(elTarget);
1439 });
1440 elTarget.appendChild(closeButton);
1441 }
1442 } else {
1443 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1444 if (closeButton) {
1445 closeButton.remove();
1446 }
1447 }
1448 };
1449 eventHandlers('click', [{
1450 selector: lpClassName.elBtnFullScreen,
1451 callBack: args => {
1452 const {
1453 e,
1454 target
1455 } = args;
1456 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1457 if (!elBtnFullScreen) {
1458 console.log('No full screen button found');
1459 return;
1460 }
1461 e.preventDefault();
1462 let elTarget = null;
1463 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
1464 console.log(targetSelector);
1465 if (targetSelector) {
1466 elTarget = document.querySelector(targetSelector);
1467 }
1468 if (!elTarget) {
1469 console.log('No target element found');
1470 return;
1471 }
1472 lpToggleFullscreenView(elTarget, elBtnFullScreen);
1473 }
1474 }]);
1475 };
1476
1477 /***/ },
1478
1479 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1480 /*!*****************************************************************************************!*\
1481 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1482 \*****************************************************************************************/
1483 (module, __webpack_exports__, __webpack_require__) {
1484
1485 "use strict";
1486 __webpack_require__.r(__webpack_exports__);
1487 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1488 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1489 /* harmony export */ });
1490 /* 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");
1491 /* 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__);
1492 /* 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");
1493 /* 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__);
1494 // Imports
1495
1496
1497 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()));
1498 // Module
1499 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1500 * Toastify js 1.12.0
1501 * https://github.com/apvarun/toastify-js
1502 * @license MIT licensed
1503 *
1504 * Copyright (C) 2018 Varun A P
1505 */
1506
1507 .toastify {
1508 padding: 12px 20px;
1509 color: #ffffff;
1510 display: inline-block;
1511 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1512 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1513 background: linear-gradient(135deg, #73a5ff, #5477f5);
1514 position: fixed;
1515 opacity: 0;
1516 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1517 border-radius: 2px;
1518 cursor: pointer;
1519 text-decoration: none;
1520 max-width: calc(50% - 20px);
1521 z-index: 2147483647;
1522 }
1523
1524 .toastify.on {
1525 opacity: 1;
1526 }
1527
1528 .toast-close {
1529 background: transparent;
1530 border: 0;
1531 color: white;
1532 cursor: pointer;
1533 font-family: inherit;
1534 font-size: 1em;
1535 opacity: 0.4;
1536 padding: 0 5px;
1537 }
1538
1539 .toastify-right {
1540 right: 15px;
1541 }
1542
1543 .toastify-left {
1544 left: 15px;
1545 }
1546
1547 .toastify-top {
1548 top: -150px;
1549 }
1550
1551 .toastify-bottom {
1552 bottom: -150px;
1553 }
1554
1555 .toastify-rounded {
1556 border-radius: 25px;
1557 }
1558
1559 .toastify-avatar {
1560 width: 1.5em;
1561 height: 1.5em;
1562 margin: -7px 5px;
1563 border-radius: 2px;
1564 }
1565
1566 .toastify-center {
1567 margin-left: auto;
1568 margin-right: auto;
1569 left: 0;
1570 right: 0;
1571 max-width: fit-content;
1572 max-width: -moz-fit-content;
1573 }
1574
1575 @media only screen and (max-width: 360px) {
1576 .toastify-right, .toastify-left {
1577 margin-left: auto;
1578 margin-right: auto;
1579 left: 0;
1580 right: 0;
1581 max-width: fit-content;
1582 }
1583 }
1584 `, "",{"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":""}]);
1585 // Exports
1586 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1587
1588
1589 /***/ },
1590
1591 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1592 /*!*****************************************************!*\
1593 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1594 \*****************************************************/
1595 (module) {
1596
1597 "use strict";
1598
1599
1600 /*
1601 MIT License http://www.opensource.org/licenses/mit-license.php
1602 Author Tobias Koppers @sokra
1603 */
1604 module.exports = function (cssWithMappingToString) {
1605 var list = [];
1606
1607 // return the list of modules as css string
1608 list.toString = function toString() {
1609 return this.map(function (item) {
1610 var content = "";
1611 var needLayer = typeof item[5] !== "undefined";
1612 if (item[4]) {
1613 content += "@supports (".concat(item[4], ") {");
1614 }
1615 if (item[2]) {
1616 content += "@media ".concat(item[2], " {");
1617 }
1618 if (needLayer) {
1619 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1620 }
1621 content += cssWithMappingToString(item);
1622 if (needLayer) {
1623 content += "}";
1624 }
1625 if (item[2]) {
1626 content += "}";
1627 }
1628 if (item[4]) {
1629 content += "}";
1630 }
1631 return content;
1632 }).join("");
1633 };
1634
1635 // import a list of modules into the list
1636 list.i = function i(modules, media, dedupe, supports, layer) {
1637 if (typeof modules === "string") {
1638 modules = [[null, modules, undefined]];
1639 }
1640 var alreadyImportedModules = {};
1641 if (dedupe) {
1642 for (var k = 0; k < this.length; k++) {
1643 var id = this[k][0];
1644 if (id != null) {
1645 alreadyImportedModules[id] = true;
1646 }
1647 }
1648 }
1649 for (var _k = 0; _k < modules.length; _k++) {
1650 var item = [].concat(modules[_k]);
1651 if (dedupe && alreadyImportedModules[item[0]]) {
1652 continue;
1653 }
1654 if (typeof layer !== "undefined") {
1655 if (typeof item[5] === "undefined") {
1656 item[5] = layer;
1657 } else {
1658 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1659 item[5] = layer;
1660 }
1661 }
1662 if (media) {
1663 if (!item[2]) {
1664 item[2] = media;
1665 } else {
1666 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1667 item[2] = media;
1668 }
1669 }
1670 if (supports) {
1671 if (!item[4]) {
1672 item[4] = "".concat(supports);
1673 } else {
1674 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1675 item[4] = supports;
1676 }
1677 }
1678 list.push(item);
1679 }
1680 };
1681 return list;
1682 };
1683
1684 /***/ },
1685
1686 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1687 /*!************************************************************!*\
1688 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1689 \************************************************************/
1690 (module) {
1691
1692 "use strict";
1693
1694
1695 module.exports = function (item) {
1696 var content = item[1];
1697 var cssMapping = item[3];
1698 if (!cssMapping) {
1699 return content;
1700 }
1701 if (typeof btoa === "function") {
1702 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1703 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1704 var sourceMapping = "/*# ".concat(data, " */");
1705 return [content].concat([sourceMapping]).join("\n");
1706 }
1707 return [content].join("\n");
1708 };
1709
1710 /***/ },
1711
1712 /***/ "./node_modules/toastify-js/src/toastify.css"
1713 /*!***************************************************!*\
1714 !*** ./node_modules/toastify-js/src/toastify.css ***!
1715 \***************************************************/
1716 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1717
1718 "use strict";
1719 __webpack_require__.r(__webpack_exports__);
1720 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1721 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1722 /* harmony export */ });
1723 /* 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");
1724 /* 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__);
1725 /* 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");
1726 /* 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__);
1727 /* 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");
1728 /* 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__);
1729 /* 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");
1730 /* 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__);
1731 /* 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");
1732 /* 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__);
1733 /* 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");
1734 /* 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__);
1735 /* 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");
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747 var options = {};
1748
1749 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1750 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1751
1752 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1753
1754 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1755 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1756
1757 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);
1758
1759
1760
1761
1762 /* 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);
1763
1764
1765 /***/ },
1766
1767 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1768 /*!****************************************************************************!*\
1769 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1770 \****************************************************************************/
1771 (module) {
1772
1773 "use strict";
1774
1775
1776 var stylesInDOM = [];
1777 function getIndexByIdentifier(identifier) {
1778 var result = -1;
1779 for (var i = 0; i < stylesInDOM.length; i++) {
1780 if (stylesInDOM[i].identifier === identifier) {
1781 result = i;
1782 break;
1783 }
1784 }
1785 return result;
1786 }
1787 function modulesToDom(list, options) {
1788 var idCountMap = {};
1789 var identifiers = [];
1790 for (var i = 0; i < list.length; i++) {
1791 var item = list[i];
1792 var id = options.base ? item[0] + options.base : item[0];
1793 var count = idCountMap[id] || 0;
1794 var identifier = "".concat(id, " ").concat(count);
1795 idCountMap[id] = count + 1;
1796 var indexByIdentifier = getIndexByIdentifier(identifier);
1797 var obj = {
1798 css: item[1],
1799 media: item[2],
1800 sourceMap: item[3],
1801 supports: item[4],
1802 layer: item[5]
1803 };
1804 if (indexByIdentifier !== -1) {
1805 stylesInDOM[indexByIdentifier].references++;
1806 stylesInDOM[indexByIdentifier].updater(obj);
1807 } else {
1808 var updater = addElementStyle(obj, options);
1809 options.byIndex = i;
1810 stylesInDOM.splice(i, 0, {
1811 identifier: identifier,
1812 updater: updater,
1813 references: 1
1814 });
1815 }
1816 identifiers.push(identifier);
1817 }
1818 return identifiers;
1819 }
1820 function addElementStyle(obj, options) {
1821 var api = options.domAPI(options);
1822 api.update(obj);
1823 var updater = function updater(newObj) {
1824 if (newObj) {
1825 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1826 return;
1827 }
1828 api.update(obj = newObj);
1829 } else {
1830 api.remove();
1831 }
1832 };
1833 return updater;
1834 }
1835 module.exports = function (list, options) {
1836 options = options || {};
1837 list = list || [];
1838 var lastIdentifiers = modulesToDom(list, options);
1839 return function update(newList) {
1840 newList = newList || [];
1841 for (var i = 0; i < lastIdentifiers.length; i++) {
1842 var identifier = lastIdentifiers[i];
1843 var index = getIndexByIdentifier(identifier);
1844 stylesInDOM[index].references--;
1845 }
1846 var newLastIdentifiers = modulesToDom(newList, options);
1847 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1848 var _identifier = lastIdentifiers[_i];
1849 var _index = getIndexByIdentifier(_identifier);
1850 if (stylesInDOM[_index].references === 0) {
1851 stylesInDOM[_index].updater();
1852 stylesInDOM.splice(_index, 1);
1853 }
1854 }
1855 lastIdentifiers = newLastIdentifiers;
1856 };
1857 };
1858
1859 /***/ },
1860
1861 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1862 /*!********************************************************************!*\
1863 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1864 \********************************************************************/
1865 (module) {
1866
1867 "use strict";
1868
1869
1870 var memo = {};
1871
1872 /* istanbul ignore next */
1873 function getTarget(target) {
1874 if (typeof memo[target] === "undefined") {
1875 var styleTarget = document.querySelector(target);
1876
1877 // Special case to return head of iframe instead of iframe itself
1878 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1879 try {
1880 // This will throw an exception if access to iframe is blocked
1881 // due to cross-origin restrictions
1882 styleTarget = styleTarget.contentDocument.head;
1883 } catch (e) {
1884 // istanbul ignore next
1885 styleTarget = null;
1886 }
1887 }
1888 memo[target] = styleTarget;
1889 }
1890 return memo[target];
1891 }
1892
1893 /* istanbul ignore next */
1894 function insertBySelector(insert, style) {
1895 var target = getTarget(insert);
1896 if (!target) {
1897 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1898 }
1899 target.appendChild(style);
1900 }
1901 module.exports = insertBySelector;
1902
1903 /***/ },
1904
1905 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1906 /*!**********************************************************************!*\
1907 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1908 \**********************************************************************/
1909 (module) {
1910
1911 "use strict";
1912
1913
1914 /* istanbul ignore next */
1915 function insertStyleElement(options) {
1916 var element = document.createElement("style");
1917 options.setAttributes(element, options.attributes);
1918 options.insert(element, options.options);
1919 return element;
1920 }
1921 module.exports = insertStyleElement;
1922
1923 /***/ },
1924
1925 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1926 /*!**********************************************************************************!*\
1927 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1928 \**********************************************************************************/
1929 (module, __unused_webpack_exports, __webpack_require__) {
1930
1931 "use strict";
1932
1933
1934 /* istanbul ignore next */
1935 function setAttributesWithoutAttributes(styleElement) {
1936 var nonce = true ? __webpack_require__.nc : 0;
1937 if (nonce) {
1938 styleElement.setAttribute("nonce", nonce);
1939 }
1940 }
1941 module.exports = setAttributesWithoutAttributes;
1942
1943 /***/ },
1944
1945 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1946 /*!***************************************************************!*\
1947 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1948 \***************************************************************/
1949 (module) {
1950
1951 "use strict";
1952
1953
1954 /* istanbul ignore next */
1955 function apply(styleElement, options, obj) {
1956 var css = "";
1957 if (obj.supports) {
1958 css += "@supports (".concat(obj.supports, ") {");
1959 }
1960 if (obj.media) {
1961 css += "@media ".concat(obj.media, " {");
1962 }
1963 var needLayer = typeof obj.layer !== "undefined";
1964 if (needLayer) {
1965 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1966 }
1967 css += obj.css;
1968 if (needLayer) {
1969 css += "}";
1970 }
1971 if (obj.media) {
1972 css += "}";
1973 }
1974 if (obj.supports) {
1975 css += "}";
1976 }
1977 var sourceMap = obj.sourceMap;
1978 if (sourceMap && typeof btoa !== "undefined") {
1979 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1980 }
1981
1982 // For old IE
1983 /* istanbul ignore if */
1984 options.styleTagTransform(css, styleElement, options.options);
1985 }
1986 function removeStyleElement(styleElement) {
1987 // istanbul ignore if
1988 if (styleElement.parentNode === null) {
1989 return false;
1990 }
1991 styleElement.parentNode.removeChild(styleElement);
1992 }
1993
1994 /* istanbul ignore next */
1995 function domAPI(options) {
1996 if (typeof document === "undefined") {
1997 return {
1998 update: function update() {},
1999 remove: function remove() {}
2000 };
2001 }
2002 var styleElement = options.insertStyleElement(options);
2003 return {
2004 update: function update(obj) {
2005 apply(styleElement, options, obj);
2006 },
2007 remove: function remove() {
2008 removeStyleElement(styleElement);
2009 }
2010 };
2011 }
2012 module.exports = domAPI;
2013
2014 /***/ },
2015
2016 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
2017 /*!*********************************************************************!*\
2018 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
2019 \*********************************************************************/
2020 (module) {
2021
2022 "use strict";
2023
2024
2025 /* istanbul ignore next */
2026 function styleTagTransform(css, styleElement) {
2027 if (styleElement.styleSheet) {
2028 styleElement.styleSheet.cssText = css;
2029 } else {
2030 while (styleElement.firstChild) {
2031 styleElement.removeChild(styleElement.firstChild);
2032 }
2033 styleElement.appendChild(document.createTextNode(css));
2034 }
2035 }
2036 module.exports = styleTagTransform;
2037
2038 /***/ },
2039
2040 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
2041 /*!**********************************************************!*\
2042 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
2043 \**********************************************************/
2044 (module) {
2045
2046 /*!
2047 * sweetalert2 v11.26.17
2048 * Released under the MIT License.
2049 */
2050 (function (global, factory) {
2051 true ? module.exports = factory() :
2052 0;
2053 })(this, (function () { 'use strict';
2054
2055 function _assertClassBrand(e, t, n) {
2056 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2057 throw new TypeError("Private element is not present on this object");
2058 }
2059 function _checkPrivateRedeclaration(e, t) {
2060 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2061 }
2062 function _classPrivateFieldGet2(s, a) {
2063 return s.get(_assertClassBrand(s, a));
2064 }
2065 function _classPrivateFieldInitSpec(e, t, a) {
2066 _checkPrivateRedeclaration(e, t), t.set(e, a);
2067 }
2068 function _classPrivateFieldSet2(s, a, r) {
2069 return s.set(_assertClassBrand(s, a), r), r;
2070 }
2071
2072 const RESTORE_FOCUS_TIMEOUT = 100;
2073
2074 /** @type {GlobalState} */
2075 const globalState = {};
2076 const focusPreviousActiveElement = () => {
2077 if (globalState.previousActiveElement instanceof HTMLElement) {
2078 globalState.previousActiveElement.focus();
2079 globalState.previousActiveElement = null;
2080 } else if (document.body) {
2081 document.body.focus();
2082 }
2083 };
2084
2085 /**
2086 * Restore previous active (focused) element
2087 *
2088 * @param {boolean} returnFocus
2089 * @returns {Promise<void>}
2090 */
2091 const restoreActiveElement = returnFocus => {
2092 return new Promise(resolve => {
2093 if (!returnFocus) {
2094 return resolve();
2095 }
2096 const x = window.scrollX;
2097 const y = window.scrollY;
2098 globalState.restoreFocusTimeout = setTimeout(() => {
2099 focusPreviousActiveElement();
2100 resolve();
2101 }, RESTORE_FOCUS_TIMEOUT); // issues/900
2102
2103 window.scrollTo(x, y);
2104 });
2105 };
2106
2107 const swalPrefix = 'swal2-';
2108
2109 /**
2110 * @typedef {Record<SwalClass, string>} SwalClasses
2111 */
2112
2113 /**
2114 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
2115 * @typedef {Record<SwalIcon, string>} SwalIcons
2116 */
2117
2118 /** @type {SwalClass[]} */
2119 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'];
2120 const swalClasses = classNames.reduce((acc, className) => {
2121 acc[className] = swalPrefix + className;
2122 return acc;
2123 }, /** @type {SwalClasses} */{});
2124
2125 /** @type {SwalIcon[]} */
2126 const icons = ['success', 'warning', 'info', 'question', 'error'];
2127 const iconTypes = icons.reduce((acc, icon) => {
2128 acc[icon] = swalPrefix + icon;
2129 return acc;
2130 }, /** @type {SwalIcons} */{});
2131
2132 const consolePrefix = 'SweetAlert2:';
2133
2134 /**
2135 * Capitalize the first letter of a string
2136 *
2137 * @param {string} str
2138 * @returns {string}
2139 */
2140 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2141
2142 /**
2143 * Standardize console warnings
2144 *
2145 * @param {string | string[]} message
2146 */
2147 const warn = message => {
2148 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2149 };
2150
2151 /**
2152 * Standardize console errors
2153 *
2154 * @param {string} message
2155 */
2156 const error = message => {
2157 console.error(`${consolePrefix} ${message}`);
2158 };
2159
2160 /**
2161 * Private global state for `warnOnce`
2162 *
2163 * @type {string[]}
2164 * @private
2165 */
2166 const previousWarnOnceMessages = [];
2167
2168 /**
2169 * Show a console warning, but only if it hasn't already been shown
2170 *
2171 * @param {string} message
2172 */
2173 const warnOnce = message => {
2174 if (!previousWarnOnceMessages.includes(message)) {
2175 previousWarnOnceMessages.push(message);
2176 warn(message);
2177 }
2178 };
2179
2180 /**
2181 * Show a one-time console warning about deprecated params/methods
2182 *
2183 * @param {string} deprecatedParam
2184 * @param {string?} useInstead
2185 */
2186 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2187 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2188 };
2189
2190 /**
2191 * If `arg` is a function, call it (with no arguments or context) and return the result.
2192 * Otherwise, just pass the value through
2193 *
2194 * @param {(() => *) | *} arg
2195 * @returns {*}
2196 */
2197 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2198
2199 /**
2200 * @param {*} arg
2201 * @returns {boolean}
2202 */
2203 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2204
2205 /**
2206 * @param {*} arg
2207 * @returns {Promise<*>}
2208 */
2209 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2210
2211 /**
2212 * @param {*} arg
2213 * @returns {boolean}
2214 */
2215 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2216
2217 /**
2218 * Gets the popup container which contains the backdrop and the popup itself.
2219 *
2220 * @returns {HTMLElement | null}
2221 */
2222 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2223
2224 /**
2225 * @param {string} selectorString
2226 * @returns {HTMLElement | null}
2227 */
2228 const elementBySelector = selectorString => {
2229 const container = getContainer();
2230 return container ? container.querySelector(selectorString) : null;
2231 };
2232
2233 /**
2234 * @param {string} className
2235 * @returns {HTMLElement | null}
2236 */
2237 const elementByClass = className => {
2238 return elementBySelector(`.${className}`);
2239 };
2240
2241 /**
2242 * @returns {HTMLElement | null}
2243 */
2244 const getPopup = () => elementByClass(swalClasses.popup);
2245
2246 /**
2247 * @returns {HTMLElement | null}
2248 */
2249 const getIcon = () => elementByClass(swalClasses.icon);
2250
2251 /**
2252 * @returns {HTMLElement | null}
2253 */
2254 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2255
2256 /**
2257 * @returns {HTMLElement | null}
2258 */
2259 const getTitle = () => elementByClass(swalClasses.title);
2260
2261 /**
2262 * @returns {HTMLElement | null}
2263 */
2264 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2265
2266 /**
2267 * @returns {HTMLElement | null}
2268 */
2269 const getImage = () => elementByClass(swalClasses.image);
2270
2271 /**
2272 * @returns {HTMLElement | null}
2273 */
2274 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2275
2276 /**
2277 * @returns {HTMLElement | null}
2278 */
2279 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2280
2281 /**
2282 * @returns {HTMLButtonElement | null}
2283 */
2284 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2285
2286 /**
2287 * @returns {HTMLButtonElement | null}
2288 */
2289 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2290
2291 /**
2292 * @returns {HTMLButtonElement | null}
2293 */
2294 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2295
2296 /**
2297 * @returns {HTMLElement | null}
2298 */
2299 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2300
2301 /**
2302 * @returns {HTMLElement | null}
2303 */
2304 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2305
2306 /**
2307 * @returns {HTMLElement | null}
2308 */
2309 const getActions = () => elementByClass(swalClasses.actions);
2310
2311 /**
2312 * @returns {HTMLElement | null}
2313 */
2314 const getFooter = () => elementByClass(swalClasses.footer);
2315
2316 /**
2317 * @returns {HTMLElement | null}
2318 */
2319 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2320
2321 /**
2322 * @returns {HTMLElement | null}
2323 */
2324 const getCloseButton = () => elementByClass(swalClasses.close);
2325
2326 // https://github.com/jkup/focusable/blob/master/index.js
2327 const focusable = `
2328 a[href],
2329 area[href],
2330 input:not([disabled]),
2331 select:not([disabled]),
2332 textarea:not([disabled]),
2333 button:not([disabled]),
2334 iframe,
2335 object,
2336 embed,
2337 [tabindex="0"],
2338 [contenteditable],
2339 audio[controls],
2340 video[controls],
2341 summary
2342 `;
2343 /**
2344 * @returns {HTMLElement[]}
2345 */
2346 const getFocusableElements = () => {
2347 const popup = getPopup();
2348 if (!popup) {
2349 return [];
2350 }
2351 /** @type {NodeListOf<HTMLElement>} */
2352 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2353 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2354 // sort according to tabindex
2355 .sort((a, b) => {
2356 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2357 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2358 if (tabindexA > tabindexB) {
2359 return 1;
2360 } else if (tabindexA < tabindexB) {
2361 return -1;
2362 }
2363 return 0;
2364 });
2365
2366 /** @type {NodeListOf<HTMLElement>} */
2367 const otherFocusableElements = popup.querySelectorAll(focusable);
2368 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2369 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2370 };
2371
2372 /**
2373 * @returns {boolean}
2374 */
2375 const isModal = () => {
2376 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2377 };
2378
2379 /**
2380 * @returns {boolean}
2381 */
2382 const isToast = () => {
2383 const popup = getPopup();
2384 if (!popup) {
2385 return false;
2386 }
2387 return hasClass(popup, swalClasses.toast);
2388 };
2389
2390 /**
2391 * @returns {boolean}
2392 */
2393 const isLoading = () => {
2394 const popup = getPopup();
2395 if (!popup) {
2396 return false;
2397 }
2398 return popup.hasAttribute('data-loading');
2399 };
2400
2401 /**
2402 * Securely set innerHTML of an element
2403 * https://github.com/sweetalert2/sweetalert2/issues/1926
2404 *
2405 * @param {HTMLElement} elem
2406 * @param {string} html
2407 */
2408 const setInnerHtml = (elem, html) => {
2409 elem.textContent = '';
2410 if (html) {
2411 const parser = new DOMParser();
2412 const parsed = parser.parseFromString(html, `text/html`);
2413 const head = parsed.querySelector('head');
2414 if (head) {
2415 Array.from(head.childNodes).forEach(child => {
2416 elem.appendChild(child);
2417 });
2418 }
2419 const body = parsed.querySelector('body');
2420 if (body) {
2421 Array.from(body.childNodes).forEach(child => {
2422 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2423 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2424 } else {
2425 elem.appendChild(child);
2426 }
2427 });
2428 }
2429 }
2430 };
2431
2432 /**
2433 * @param {HTMLElement} elem
2434 * @param {string} className
2435 * @returns {boolean}
2436 */
2437 const hasClass = (elem, className) => {
2438 if (!className) {
2439 return false;
2440 }
2441 const classList = className.split(/\s+/);
2442 for (let i = 0; i < classList.length; i++) {
2443 if (!elem.classList.contains(classList[i])) {
2444 return false;
2445 }
2446 }
2447 return true;
2448 };
2449
2450 /**
2451 * @param {HTMLElement} elem
2452 * @param {SweetAlertOptions} params
2453 */
2454 const removeCustomClasses = (elem, params) => {
2455 Array.from(elem.classList).forEach(className => {
2456 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2457 elem.classList.remove(className);
2458 }
2459 });
2460 };
2461
2462 /**
2463 * @param {HTMLElement} elem
2464 * @param {SweetAlertOptions} params
2465 * @param {string} className
2466 */
2467 const applyCustomClass = (elem, params, className) => {
2468 removeCustomClasses(elem, params);
2469 if (!params.customClass) {
2470 return;
2471 }
2472 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2473 if (!customClass) {
2474 return;
2475 }
2476 if (typeof customClass !== 'string' && !customClass.forEach) {
2477 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2478 return;
2479 }
2480 addClass(elem, customClass);
2481 };
2482
2483 /**
2484 * @param {HTMLElement} popup
2485 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2486 * @returns {HTMLInputElement | null}
2487 */
2488 const getInput$1 = (popup, inputClass) => {
2489 if (!inputClass) {
2490 return null;
2491 }
2492 switch (inputClass) {
2493 case 'select':
2494 case 'textarea':
2495 case 'file':
2496 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2497 case 'checkbox':
2498 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2499 case 'radio':
2500 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2501 case 'range':
2502 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2503 default:
2504 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2505 }
2506 };
2507
2508 /**
2509 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2510 */
2511 const focusInput = input => {
2512 input.focus();
2513
2514 // place cursor at end of text in text input
2515 if (input.type !== 'file') {
2516 // http://stackoverflow.com/a/2345915
2517 const val = input.value;
2518 input.value = '';
2519 input.value = val;
2520 }
2521 };
2522
2523 /**
2524 * @param {HTMLElement | HTMLElement[] | null} target
2525 * @param {string | string[] | readonly string[] | undefined} classList
2526 * @param {boolean} condition
2527 */
2528 const toggleClass = (target, classList, condition) => {
2529 if (!target || !classList) {
2530 return;
2531 }
2532 if (typeof classList === 'string') {
2533 classList = classList.split(/\s+/).filter(Boolean);
2534 }
2535 classList.forEach(className => {
2536 if (Array.isArray(target)) {
2537 target.forEach(elem => {
2538 if (condition) {
2539 elem.classList.add(className);
2540 } else {
2541 elem.classList.remove(className);
2542 }
2543 });
2544 } else {
2545 if (condition) {
2546 target.classList.add(className);
2547 } else {
2548 target.classList.remove(className);
2549 }
2550 }
2551 });
2552 };
2553
2554 /**
2555 * @param {HTMLElement | HTMLElement[] | null} target
2556 * @param {string | string[] | readonly string[] | undefined} classList
2557 */
2558 const addClass = (target, classList) => {
2559 toggleClass(target, classList, true);
2560 };
2561
2562 /**
2563 * @param {HTMLElement | HTMLElement[] | null} target
2564 * @param {string | string[] | readonly string[] | undefined} classList
2565 */
2566 const removeClass = (target, classList) => {
2567 toggleClass(target, classList, false);
2568 };
2569
2570 /**
2571 * Get direct child of an element by class name
2572 *
2573 * @param {HTMLElement} elem
2574 * @param {string} className
2575 * @returns {HTMLElement | undefined}
2576 */
2577 const getDirectChildByClass = (elem, className) => {
2578 const children = Array.from(elem.children);
2579 for (let i = 0; i < children.length; i++) {
2580 const child = children[i];
2581 if (child instanceof HTMLElement && hasClass(child, className)) {
2582 return child;
2583 }
2584 }
2585 };
2586
2587 /**
2588 * @param {HTMLElement} elem
2589 * @param {string} property
2590 * @param {string | number | null | undefined} value
2591 */
2592 const applyNumericalStyle = (elem, property, value) => {
2593 if (value === `${parseInt(`${value}`)}`) {
2594 value = parseInt(value);
2595 }
2596 if (value || parseInt(`${value}`) === 0) {
2597 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2598 } else {
2599 elem.style.removeProperty(property);
2600 }
2601 };
2602
2603 /**
2604 * @param {HTMLElement | null} elem
2605 * @param {string} display
2606 */
2607 const show = (elem, display = 'flex') => {
2608 if (!elem) {
2609 return;
2610 }
2611 elem.style.display = display;
2612 };
2613
2614 /**
2615 * @param {HTMLElement | null} elem
2616 */
2617 const hide = elem => {
2618 if (!elem) {
2619 return;
2620 }
2621 elem.style.display = 'none';
2622 };
2623
2624 /**
2625 * @param {HTMLElement | null} elem
2626 * @param {string} display
2627 */
2628 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2629 if (!elem) {
2630 return;
2631 }
2632 new MutationObserver(() => {
2633 toggle(elem, elem.innerHTML, display);
2634 }).observe(elem, {
2635 childList: true,
2636 subtree: true
2637 });
2638 };
2639
2640 /**
2641 * @param {HTMLElement} parent
2642 * @param {string} selector
2643 * @param {string} property
2644 * @param {string} value
2645 */
2646 const setStyle = (parent, selector, property, value) => {
2647 /** @type {HTMLElement | null} */
2648 const el = parent.querySelector(selector);
2649 if (el) {
2650 el.style.setProperty(property, value);
2651 }
2652 };
2653
2654 /**
2655 * @param {HTMLElement} elem
2656 * @param {boolean | string | null | undefined} condition
2657 * @param {string} display
2658 */
2659 const toggle = (elem, condition, display = 'flex') => {
2660 if (condition) {
2661 show(elem, display);
2662 } else {
2663 hide(elem);
2664 }
2665 };
2666
2667 /**
2668 * borrowed from jquery $(elem).is(':visible') implementation
2669 *
2670 * @param {HTMLElement | null} elem
2671 * @returns {boolean}
2672 */
2673 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2674
2675 /**
2676 * @returns {boolean}
2677 */
2678 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2679
2680 /**
2681 * @param {HTMLElement} elem
2682 * @returns {boolean}
2683 */
2684 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2685
2686 /**
2687 * @param {HTMLElement} element
2688 * @param {HTMLElement} stopElement
2689 * @returns {boolean}
2690 */
2691 const selfOrParentIsScrollable = (element, stopElement) => {
2692 let parent = /** @type {HTMLElement | null} */element;
2693 while (parent && parent !== stopElement) {
2694 if (isScrollable(parent)) {
2695 return true;
2696 }
2697 parent = parent.parentElement;
2698 }
2699 return false;
2700 };
2701
2702 /**
2703 * borrowed from https://stackoverflow.com/a/46352119
2704 *
2705 * @param {HTMLElement} elem
2706 * @returns {boolean}
2707 */
2708 const hasCssAnimation = elem => {
2709 const style = window.getComputedStyle(elem);
2710 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2711 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2712 return animDuration > 0 || transDuration > 0;
2713 };
2714
2715 /**
2716 * @param {number} timer
2717 * @param {boolean} reset
2718 */
2719 const animateTimerProgressBar = (timer, reset = false) => {
2720 const timerProgressBar = getTimerProgressBar();
2721 if (!timerProgressBar) {
2722 return;
2723 }
2724 if (isVisible$1(timerProgressBar)) {
2725 if (reset) {
2726 timerProgressBar.style.transition = 'none';
2727 timerProgressBar.style.width = '100%';
2728 }
2729 setTimeout(() => {
2730 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2731 timerProgressBar.style.width = '0%';
2732 }, 10);
2733 }
2734 };
2735 const stopTimerProgressBar = () => {
2736 const timerProgressBar = getTimerProgressBar();
2737 if (!timerProgressBar) {
2738 return;
2739 }
2740 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2741 timerProgressBar.style.removeProperty('transition');
2742 timerProgressBar.style.width = '100%';
2743 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2744 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2745 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2746 };
2747
2748 /**
2749 * Detect Node env
2750 *
2751 * @returns {boolean}
2752 */
2753 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2754
2755 const sweetHTML = `
2756 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2757 <button type="button" class="${swalClasses.close}"></button>
2758 <ul class="${swalClasses['progress-steps']}"></ul>
2759 <div class="${swalClasses.icon}"></div>
2760 <img class="${swalClasses.image}" />
2761 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2762 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2763 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2764 <input type="file" class="${swalClasses.file}" />
2765 <div class="${swalClasses.range}">
2766 <input type="range" />
2767 <output></output>
2768 </div>
2769 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2770 <div class="${swalClasses.radio}"></div>
2771 <label class="${swalClasses.checkbox}">
2772 <input type="checkbox" id="${swalClasses.checkbox}" />
2773 <span class="${swalClasses.label}"></span>
2774 </label>
2775 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2776 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2777 <div class="${swalClasses.actions}">
2778 <div class="${swalClasses.loader}"></div>
2779 <button type="button" class="${swalClasses.confirm}"></button>
2780 <button type="button" class="${swalClasses.deny}"></button>
2781 <button type="button" class="${swalClasses.cancel}"></button>
2782 </div>
2783 <div class="${swalClasses.footer}"></div>
2784 <div class="${swalClasses['timer-progress-bar-container']}">
2785 <div class="${swalClasses['timer-progress-bar']}"></div>
2786 </div>
2787 </div>
2788 `.replace(/(^|\n)\s*/g, '');
2789
2790 /**
2791 * @returns {boolean}
2792 */
2793 const resetOldContainer = () => {
2794 const oldContainer = getContainer();
2795 if (!oldContainer) {
2796 return false;
2797 }
2798 oldContainer.remove();
2799 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2800 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2801 swalClasses['has-column']]);
2802 return true;
2803 };
2804 const resetValidationMessage$1 = () => {
2805 if (globalState.currentInstance) {
2806 globalState.currentInstance.resetValidationMessage();
2807 }
2808 };
2809 const addInputChangeListeners = () => {
2810 const popup = getPopup();
2811 if (!popup) {
2812 return;
2813 }
2814 const input = getDirectChildByClass(popup, swalClasses.input);
2815 const file = getDirectChildByClass(popup, swalClasses.file);
2816 /** @type {HTMLInputElement | null} */
2817 const range = popup.querySelector(`.${swalClasses.range} input`);
2818 /** @type {HTMLOutputElement | null} */
2819 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2820 const select = getDirectChildByClass(popup, swalClasses.select);
2821 /** @type {HTMLInputElement | null} */
2822 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2823 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2824 if (input) {
2825 input.oninput = resetValidationMessage$1;
2826 }
2827 if (file) {
2828 file.onchange = resetValidationMessage$1;
2829 }
2830 if (select) {
2831 select.onchange = resetValidationMessage$1;
2832 }
2833 if (checkbox) {
2834 checkbox.onchange = resetValidationMessage$1;
2835 }
2836 if (textarea) {
2837 textarea.oninput = resetValidationMessage$1;
2838 }
2839 if (range && rangeOutput) {
2840 range.oninput = () => {
2841 resetValidationMessage$1();
2842 rangeOutput.value = range.value;
2843 };
2844 range.onchange = () => {
2845 resetValidationMessage$1();
2846 rangeOutput.value = range.value;
2847 };
2848 }
2849 };
2850
2851 /**
2852 * @param {string | HTMLElement} target
2853 * @returns {HTMLElement}
2854 */
2855 const getTarget = target => {
2856 if (typeof target === 'string') {
2857 const element = document.querySelector(target);
2858 if (!element) {
2859 throw new Error(`Target element "${target}" not found`);
2860 }
2861 return /** @type {HTMLElement} */element;
2862 }
2863 return target;
2864 };
2865
2866 /**
2867 * @param {SweetAlertOptions} params
2868 */
2869 const setupAccessibility = params => {
2870 const popup = getPopup();
2871 if (!popup) {
2872 return;
2873 }
2874 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2875 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2876 if (!params.toast) {
2877 popup.setAttribute('aria-modal', 'true');
2878 }
2879 };
2880
2881 /**
2882 * @param {HTMLElement} targetElement
2883 */
2884 const setupRTL = targetElement => {
2885 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2886 addClass(getContainer(), swalClasses.rtl);
2887 globalState.isRTL = true;
2888 }
2889 };
2890
2891 /**
2892 * Add modal + backdrop to DOM
2893 *
2894 * @param {SweetAlertOptions} params
2895 */
2896 const init = params => {
2897 // Clean up the old popup container if it exists
2898 const oldContainerExisted = resetOldContainer();
2899 if (isNodeEnv()) {
2900 error('SweetAlert2 requires document to initialize');
2901 return;
2902 }
2903 const container = document.createElement('div');
2904 container.className = swalClasses.container;
2905 if (oldContainerExisted) {
2906 addClass(container, swalClasses['no-transition']);
2907 }
2908 setInnerHtml(container, sweetHTML);
2909 container.dataset['swal2Theme'] = params.theme;
2910 const targetElement = getTarget(params.target || 'body');
2911 targetElement.appendChild(container);
2912 if (params.topLayer) {
2913 container.setAttribute('popover', '');
2914 container.showPopover();
2915 }
2916 setupAccessibility(params);
2917 setupRTL(targetElement);
2918 addInputChangeListeners();
2919 };
2920
2921 /**
2922 * @param {HTMLElement | object | string} param
2923 * @param {HTMLElement} target
2924 */
2925 const parseHtmlToContainer = (param, target) => {
2926 // DOM element
2927 if (param instanceof HTMLElement) {
2928 target.appendChild(param);
2929 }
2930
2931 // Object
2932 else if (typeof param === 'object') {
2933 handleObject(param, target);
2934 }
2935
2936 // Plain string
2937 else if (param) {
2938 setInnerHtml(target, param);
2939 }
2940 };
2941
2942 /**
2943 * @param {object} param
2944 * @param {HTMLElement} target
2945 */
2946 const handleObject = (param, target) => {
2947 // JQuery element(s)
2948 if ('jquery' in param) {
2949 handleJqueryElem(target, param);
2950 }
2951
2952 // For other objects use their string representation
2953 else {
2954 setInnerHtml(target, param.toString());
2955 }
2956 };
2957
2958 /**
2959 * @param {HTMLElement} target
2960 * @param {any} elem
2961 */
2962 const handleJqueryElem = (target, elem) => {
2963 target.textContent = '';
2964 if (0 in elem) {
2965 for (let i = 0; i in elem; i++) {
2966 target.appendChild(elem[i].cloneNode(true));
2967 }
2968 } else {
2969 target.appendChild(elem.cloneNode(true));
2970 }
2971 };
2972
2973 /**
2974 * @param {SweetAlert} instance
2975 * @param {SweetAlertOptions} params
2976 */
2977 const renderActions = (instance, params) => {
2978 const actions = getActions();
2979 const loader = getLoader();
2980 if (!actions || !loader) {
2981 return;
2982 }
2983
2984 // Actions (buttons) wrapper
2985 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2986 hide(actions);
2987 } else {
2988 show(actions);
2989 }
2990
2991 // Custom class
2992 applyCustomClass(actions, params, 'actions');
2993
2994 // Render all the buttons
2995 renderButtons(actions, loader, params);
2996
2997 // Loader
2998 setInnerHtml(loader, params.loaderHtml || '');
2999 applyCustomClass(loader, params, 'loader');
3000 };
3001
3002 /**
3003 * @param {HTMLElement} actions
3004 * @param {HTMLElement} loader
3005 * @param {SweetAlertOptions} params
3006 */
3007 function renderButtons(actions, loader, params) {
3008 const confirmButton = getConfirmButton();
3009 const denyButton = getDenyButton();
3010 const cancelButton = getCancelButton();
3011 if (!confirmButton || !denyButton || !cancelButton) {
3012 return;
3013 }
3014
3015 // Render buttons
3016 renderButton(confirmButton, 'confirm', params);
3017 renderButton(denyButton, 'deny', params);
3018 renderButton(cancelButton, 'cancel', params);
3019 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3020 if (params.reverseButtons) {
3021 if (params.toast) {
3022 actions.insertBefore(cancelButton, confirmButton);
3023 actions.insertBefore(denyButton, confirmButton);
3024 } else {
3025 actions.insertBefore(cancelButton, loader);
3026 actions.insertBefore(denyButton, loader);
3027 actions.insertBefore(confirmButton, loader);
3028 }
3029 }
3030 }
3031
3032 /**
3033 * @param {HTMLElement} confirmButton
3034 * @param {HTMLElement} denyButton
3035 * @param {HTMLElement} cancelButton
3036 * @param {SweetAlertOptions} params
3037 */
3038 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3039 if (!params.buttonsStyling) {
3040 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3041 return;
3042 }
3043 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3044
3045 // Apply custom background colors to action buttons
3046 if (params.confirmButtonColor) {
3047 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
3048 }
3049 if (params.denyButtonColor) {
3050 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
3051 }
3052 if (params.cancelButtonColor) {
3053 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
3054 }
3055
3056 // Apply the outline color to action buttons
3057 applyOutlineColor(confirmButton);
3058 applyOutlineColor(denyButton);
3059 applyOutlineColor(cancelButton);
3060 }
3061
3062 /**
3063 * @param {HTMLElement} button
3064 */
3065 function applyOutlineColor(button) {
3066 const buttonStyle = window.getComputedStyle(button);
3067 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3068 // If the button already has a custom outline color, no need to change it
3069 return;
3070 }
3071 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3072 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3073 }
3074
3075 /**
3076 * @param {HTMLElement} button
3077 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3078 * @param {SweetAlertOptions} params
3079 */
3080 function renderButton(button, buttonType, params) {
3081 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3082 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3083 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3084 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3085
3086 // Add buttons custom classes
3087 button.className = swalClasses[buttonType];
3088 applyCustomClass(button, params, `${buttonType}Button`);
3089 }
3090
3091 /**
3092 * @param {SweetAlert} instance
3093 * @param {SweetAlertOptions} params
3094 */
3095 const renderCloseButton = (instance, params) => {
3096 const closeButton = getCloseButton();
3097 if (!closeButton) {
3098 return;
3099 }
3100 setInnerHtml(closeButton, params.closeButtonHtml || '');
3101
3102 // Custom class
3103 applyCustomClass(closeButton, params, 'closeButton');
3104 toggle(closeButton, params.showCloseButton);
3105 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3106 };
3107
3108 /**
3109 * @param {SweetAlert} instance
3110 * @param {SweetAlertOptions} params
3111 */
3112 const renderContainer = (instance, params) => {
3113 const container = getContainer();
3114 if (!container) {
3115 return;
3116 }
3117 handleBackdropParam(container, params.backdrop);
3118 handlePositionParam(container, params.position);
3119 handleGrowParam(container, params.grow);
3120
3121 // Custom class
3122 applyCustomClass(container, params, 'container');
3123 };
3124
3125 /**
3126 * @param {HTMLElement} container
3127 * @param {SweetAlertOptions['backdrop']} backdrop
3128 */
3129 function handleBackdropParam(container, backdrop) {
3130 if (typeof backdrop === 'string') {
3131 container.style.background = backdrop;
3132 } else if (!backdrop) {
3133 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3134 }
3135 }
3136
3137 /**
3138 * @param {HTMLElement} container
3139 * @param {SweetAlertOptions['position']} position
3140 */
3141 function handlePositionParam(container, position) {
3142 if (!position) {
3143 return;
3144 }
3145 if (position in swalClasses) {
3146 addClass(container, swalClasses[position]);
3147 } else {
3148 warn('The "position" parameter is not valid, defaulting to "center"');
3149 addClass(container, swalClasses.center);
3150 }
3151 }
3152
3153 /**
3154 * @param {HTMLElement} container
3155 * @param {SweetAlertOptions['grow']} grow
3156 */
3157 function handleGrowParam(container, grow) {
3158 if (!grow) {
3159 return;
3160 }
3161 addClass(container, swalClasses[`grow-${grow}`]);
3162 }
3163
3164 /**
3165 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3166 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3167 * This is the approach that Babel will probably take to implement private methods/fields
3168 * https://github.com/tc39/proposal-private-methods
3169 * https://github.com/babel/babel/pull/7555
3170 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3171 * then we can use that language feature.
3172 */
3173
3174 var privateProps = {
3175 innerParams: new WeakMap(),
3176 domCache: new WeakMap()
3177 };
3178
3179 /// <reference path="../../../../sweetalert2.d.ts"/>
3180
3181
3182 /** @type {InputClass[]} */
3183 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3184
3185 /**
3186 * @param {SweetAlert} instance
3187 * @param {SweetAlertOptions} params
3188 */
3189 const renderInput = (instance, params) => {
3190 const popup = getPopup();
3191 if (!popup) {
3192 return;
3193 }
3194 const innerParams = privateProps.innerParams.get(instance);
3195 const rerender = !innerParams || params.input !== innerParams.input;
3196 inputClasses.forEach(inputClass => {
3197 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3198 if (!inputContainer) {
3199 return;
3200 }
3201
3202 // set attributes
3203 setAttributes(inputClass, params.inputAttributes);
3204
3205 // set class
3206 inputContainer.className = swalClasses[inputClass];
3207 if (rerender) {
3208 hide(inputContainer);
3209 }
3210 });
3211 if (params.input) {
3212 if (rerender) {
3213 showInput(params);
3214 }
3215 // set custom class
3216 setCustomClass(params);
3217 }
3218 };
3219
3220 /**
3221 * @param {SweetAlertOptions} params
3222 */
3223 const showInput = params => {
3224 if (!params.input) {
3225 return;
3226 }
3227 if (!renderInputType[params.input]) {
3228 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3229 return;
3230 }
3231 const inputContainer = getInputContainer(params.input);
3232 if (!inputContainer) {
3233 return;
3234 }
3235 const input = renderInputType[params.input](inputContainer, params);
3236 show(inputContainer);
3237
3238 // input autofocus
3239 if (params.inputAutoFocus) {
3240 setTimeout(() => {
3241 focusInput(input);
3242 });
3243 }
3244 };
3245
3246 /**
3247 * @param {HTMLInputElement} input
3248 */
3249 const removeAttributes = input => {
3250 for (let i = 0; i < input.attributes.length; i++) {
3251 const attrName = input.attributes[i].name;
3252 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
3253 input.removeAttribute(attrName);
3254 }
3255 }
3256 };
3257
3258 /**
3259 * @param {InputClass} inputClass
3260 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3261 */
3262 const setAttributes = (inputClass, inputAttributes) => {
3263 const popup = getPopup();
3264 if (!popup) {
3265 return;
3266 }
3267 const input = getInput$1(popup, inputClass);
3268 if (!input) {
3269 return;
3270 }
3271 removeAttributes(input);
3272 for (const attr in inputAttributes) {
3273 input.setAttribute(attr, inputAttributes[attr]);
3274 }
3275 };
3276
3277 /**
3278 * @param {SweetAlertOptions} params
3279 */
3280 const setCustomClass = params => {
3281 if (!params.input) {
3282 return;
3283 }
3284 const inputContainer = getInputContainer(params.input);
3285 if (inputContainer) {
3286 applyCustomClass(inputContainer, params, 'input');
3287 }
3288 };
3289
3290 /**
3291 * @param {HTMLInputElement | HTMLTextAreaElement} input
3292 * @param {SweetAlertOptions} params
3293 */
3294 const setInputPlaceholder = (input, params) => {
3295 if (!input.placeholder && params.inputPlaceholder) {
3296 input.placeholder = params.inputPlaceholder;
3297 }
3298 };
3299
3300 /**
3301 * @param {Input} input
3302 * @param {Input} prependTo
3303 * @param {SweetAlertOptions} params
3304 */
3305 const setInputLabel = (input, prependTo, params) => {
3306 if (params.inputLabel) {
3307 const label = document.createElement('label');
3308 const labelClass = swalClasses['input-label'];
3309 label.setAttribute('for', input.id);
3310 label.className = labelClass;
3311 if (typeof params.customClass === 'object') {
3312 addClass(label, params.customClass.inputLabel);
3313 }
3314 label.innerText = params.inputLabel;
3315 prependTo.insertAdjacentElement('beforebegin', label);
3316 }
3317 };
3318
3319 /**
3320 * @param {SweetAlertInput} inputType
3321 * @returns {HTMLElement | undefined}
3322 */
3323 const getInputContainer = inputType => {
3324 const popup = getPopup();
3325 if (!popup) {
3326 return;
3327 }
3328 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3329 };
3330
3331 /**
3332 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3333 * @param {SweetAlertOptions['inputValue']} inputValue
3334 */
3335 const checkAndSetInputValue = (input, inputValue) => {
3336 if (['string', 'number'].includes(typeof inputValue)) {
3337 input.value = `${inputValue}`;
3338 } else if (!isPromise(inputValue)) {
3339 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3340 }
3341 };
3342
3343 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3344 const renderInputType = {};
3345
3346 /**
3347 * @param {Input | HTMLElement} input
3348 * @param {SweetAlertOptions} params
3349 * @returns {Input}
3350 */
3351 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} */
3352 (input, params) => {
3353 const inputElement = /** @type {HTMLInputElement} */input;
3354 checkAndSetInputValue(inputElement, params.inputValue);
3355 setInputLabel(inputElement, inputElement, params);
3356 setInputPlaceholder(inputElement, params);
3357 inputElement.type = /** @type {string} */params.input;
3358 return inputElement;
3359 };
3360
3361 /**
3362 * @param {Input | HTMLElement} input
3363 * @param {SweetAlertOptions} params
3364 * @returns {Input}
3365 */
3366 renderInputType.file = (input, params) => {
3367 const inputElement = /** @type {HTMLInputElement} */input;
3368 setInputLabel(inputElement, inputElement, params);
3369 setInputPlaceholder(inputElement, params);
3370 return inputElement;
3371 };
3372
3373 /**
3374 * @param {Input | HTMLElement} range
3375 * @param {SweetAlertOptions} params
3376 * @returns {Input}
3377 */
3378 renderInputType.range = (range, params) => {
3379 const rangeContainer = /** @type {HTMLElement} */range;
3380 const rangeInput = rangeContainer.querySelector('input');
3381 const rangeOutput = rangeContainer.querySelector('output');
3382 if (rangeInput) {
3383 checkAndSetInputValue(rangeInput, params.inputValue);
3384 rangeInput.type = /** @type {string} */params.input;
3385 setInputLabel(rangeInput, /** @type {Input} */range, params);
3386 }
3387 if (rangeOutput) {
3388 checkAndSetInputValue(rangeOutput, params.inputValue);
3389 }
3390 return /** @type {Input} */range;
3391 };
3392
3393 /**
3394 * @param {Input | HTMLElement} select
3395 * @param {SweetAlertOptions} params
3396 * @returns {Input}
3397 */
3398 renderInputType.select = (select, params) => {
3399 const selectElement = /** @type {HTMLSelectElement} */select;
3400 selectElement.textContent = '';
3401 if (params.inputPlaceholder) {
3402 const placeholder = document.createElement('option');
3403 setInnerHtml(placeholder, params.inputPlaceholder);
3404 placeholder.value = '';
3405 placeholder.disabled = true;
3406 placeholder.selected = true;
3407 selectElement.appendChild(placeholder);
3408 }
3409 setInputLabel(selectElement, selectElement, params);
3410 return selectElement;
3411 };
3412
3413 /**
3414 * @param {Input | HTMLElement} radio
3415 * @returns {Input}
3416 */
3417 renderInputType.radio = radio => {
3418 const radioElement = /** @type {HTMLElement} */radio;
3419 radioElement.textContent = '';
3420 return /** @type {Input} */radio;
3421 };
3422
3423 /**
3424 * @param {Input | HTMLElement} checkboxContainer
3425 * @param {SweetAlertOptions} params
3426 * @returns {Input}
3427 */
3428 renderInputType.checkbox = (checkboxContainer, params) => {
3429 const popup = getPopup();
3430 if (!popup) {
3431 throw new Error('Popup not found');
3432 }
3433 const checkbox = getInput$1(popup, 'checkbox');
3434 if (!checkbox) {
3435 throw new Error('Checkbox input not found');
3436 }
3437 checkbox.value = '1';
3438 checkbox.checked = Boolean(params.inputValue);
3439 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3440 const label = containerElement.querySelector('span');
3441 if (label) {
3442 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3443 if (placeholderOrLabel) {
3444 setInnerHtml(label, placeholderOrLabel);
3445 }
3446 }
3447 return checkbox;
3448 };
3449
3450 /**
3451 * @param {Input | HTMLElement} textarea
3452 * @param {SweetAlertOptions} params
3453 * @returns {Input}
3454 */
3455 renderInputType.textarea = (textarea, params) => {
3456 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3457 checkAndSetInputValue(textareaElement, params.inputValue);
3458 setInputPlaceholder(textareaElement, params);
3459 setInputLabel(textareaElement, textareaElement, params);
3460
3461 /**
3462 * @param {HTMLElement} el
3463 * @returns {number}
3464 */
3465 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3466
3467 // https://github.com/sweetalert2/sweetalert2/issues/2291
3468 setTimeout(() => {
3469 // https://github.com/sweetalert2/sweetalert2/issues/1699
3470 if ('MutationObserver' in window) {
3471 const popup = getPopup();
3472 if (!popup) {
3473 return;
3474 }
3475 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3476 const textareaResizeHandler = () => {
3477 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3478 if (!document.body.contains(textareaElement)) {
3479 return;
3480 }
3481 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3482 const popupElement = getPopup();
3483 if (popupElement) {
3484 if (textareaWidth > initialPopupWidth) {
3485 popupElement.style.width = `${textareaWidth}px`;
3486 } else {
3487 applyNumericalStyle(popupElement, 'width', params.width);
3488 }
3489 }
3490 };
3491 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3492 attributes: true,
3493 attributeFilter: ['style']
3494 });
3495 }
3496 });
3497 return textareaElement;
3498 };
3499
3500 /**
3501 * @param {SweetAlert} instance
3502 * @param {SweetAlertOptions} params
3503 */
3504 const renderContent = (instance, params) => {
3505 const htmlContainer = getHtmlContainer();
3506 if (!htmlContainer) {
3507 return;
3508 }
3509 showWhenInnerHtmlPresent(htmlContainer);
3510 applyCustomClass(htmlContainer, params, 'htmlContainer');
3511
3512 // Content as HTML
3513 if (params.html) {
3514 parseHtmlToContainer(params.html, htmlContainer);
3515 show(htmlContainer, 'block');
3516 }
3517
3518 // Content as plain text
3519 else if (params.text) {
3520 htmlContainer.textContent = params.text;
3521 show(htmlContainer, 'block');
3522 }
3523
3524 // No content
3525 else {
3526 hide(htmlContainer);
3527 }
3528 renderInput(instance, params);
3529 };
3530
3531 /**
3532 * @param {SweetAlert} instance
3533 * @param {SweetAlertOptions} params
3534 */
3535 const renderFooter = (instance, params) => {
3536 const footer = getFooter();
3537 if (!footer) {
3538 return;
3539 }
3540 showWhenInnerHtmlPresent(footer);
3541 toggle(footer, Boolean(params.footer), 'block');
3542 if (params.footer) {
3543 parseHtmlToContainer(params.footer, footer);
3544 }
3545
3546 // Custom class
3547 applyCustomClass(footer, params, 'footer');
3548 };
3549
3550 /**
3551 * @param {SweetAlert} instance
3552 * @param {SweetAlertOptions} params
3553 */
3554 const renderIcon = (instance, params) => {
3555 const innerParams = privateProps.innerParams.get(instance);
3556 const icon = getIcon();
3557 if (!icon) {
3558 return;
3559 }
3560
3561 // if the given icon already rendered, apply the styling without re-rendering the icon
3562 if (innerParams && params.icon === innerParams.icon) {
3563 // Custom or default content
3564 setContent(icon, params);
3565 applyStyles(icon, params);
3566 return;
3567 }
3568 if (!params.icon && !params.iconHtml) {
3569 hide(icon);
3570 return;
3571 }
3572 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3573 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3574 hide(icon);
3575 return;
3576 }
3577 show(icon);
3578
3579 // Custom or default content
3580 setContent(icon, params);
3581 applyStyles(icon, params);
3582
3583 // Animate icon
3584 addClass(icon, params.showClass && params.showClass.icon);
3585
3586 // Re-adjust the success icon on system theme change
3587 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3588 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3589 };
3590
3591 /**
3592 * @param {HTMLElement} icon
3593 * @param {SweetAlertOptions} params
3594 */
3595 const applyStyles = (icon, params) => {
3596 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3597 if (params.icon !== iconType) {
3598 removeClass(icon, iconClassName);
3599 }
3600 }
3601 addClass(icon, params.icon && iconTypes[params.icon]);
3602
3603 // Icon color
3604 setColor(icon, params);
3605
3606 // Success icon background color
3607 adjustSuccessIconBackgroundColor();
3608
3609 // Custom class
3610 applyCustomClass(icon, params, 'icon');
3611 };
3612
3613 // Adjust success icon background color to match the popup background color
3614 const adjustSuccessIconBackgroundColor = () => {
3615 const popup = getPopup();
3616 if (!popup) {
3617 return;
3618 }
3619 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3620 /** @type {NodeListOf<HTMLElement>} */
3621 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3622 for (let i = 0; i < successIconParts.length; i++) {
3623 successIconParts[i].style.backgroundColor = popupBackgroundColor;
3624 }
3625 };
3626
3627 /**
3628 *
3629 * @param {SweetAlertOptions} params
3630 * @returns {string}
3631 */
3632 const successIconHtml = params => `
3633 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3634 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3635 <div class="swal2-success-ring"></div>
3636 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3637 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3638 `;
3639 const errorIconHtml = `
3640 <span class="swal2-x-mark">
3641 <span class="swal2-x-mark-line-left"></span>
3642 <span class="swal2-x-mark-line-right"></span>
3643 </span>
3644 `;
3645
3646 /**
3647 * @param {HTMLElement} icon
3648 * @param {SweetAlertOptions} params
3649 */
3650 const setContent = (icon, params) => {
3651 if (!params.icon && !params.iconHtml) {
3652 return;
3653 }
3654 let oldContent = icon.innerHTML;
3655 let newContent = '';
3656 if (params.iconHtml) {
3657 newContent = iconContent(params.iconHtml);
3658 } else if (params.icon === 'success') {
3659 newContent = successIconHtml(params);
3660 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3661 } else if (params.icon === 'error') {
3662 newContent = errorIconHtml;
3663 } else if (params.icon) {
3664 const defaultIconHtml = {
3665 question: '?',
3666 warning: '!',
3667 info: 'i'
3668 };
3669 newContent = iconContent(defaultIconHtml[params.icon]);
3670 }
3671 if (oldContent.trim() !== newContent.trim()) {
3672 setInnerHtml(icon, newContent);
3673 }
3674 };
3675
3676 /**
3677 * @param {HTMLElement} icon
3678 * @param {SweetAlertOptions} params
3679 */
3680 const setColor = (icon, params) => {
3681 if (!params.iconColor) {
3682 return;
3683 }
3684 icon.style.color = params.iconColor;
3685 icon.style.borderColor = params.iconColor;
3686 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3687 setStyle(icon, sel, 'background-color', params.iconColor);
3688 }
3689 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3690 };
3691
3692 /**
3693 * @param {string} content
3694 * @returns {string}
3695 */
3696 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3697
3698 /**
3699 * @param {SweetAlert} instance
3700 * @param {SweetAlertOptions} params
3701 */
3702 const renderImage = (instance, params) => {
3703 const image = getImage();
3704 if (!image) {
3705 return;
3706 }
3707 if (!params.imageUrl) {
3708 hide(image);
3709 return;
3710 }
3711 show(image, '');
3712
3713 // Src, alt
3714 image.setAttribute('src', params.imageUrl);
3715 image.setAttribute('alt', params.imageAlt || '');
3716
3717 // Width, height
3718 applyNumericalStyle(image, 'width', params.imageWidth);
3719 applyNumericalStyle(image, 'height', params.imageHeight);
3720
3721 // Class
3722 image.className = swalClasses.image;
3723 applyCustomClass(image, params, 'image');
3724 };
3725
3726 let dragging = false;
3727 let mousedownX = 0;
3728 let mousedownY = 0;
3729 let initialX = 0;
3730 let initialY = 0;
3731
3732 /**
3733 * @param {HTMLElement} popup
3734 */
3735 const addDraggableListeners = popup => {
3736 popup.addEventListener('mousedown', down);
3737 document.body.addEventListener('mousemove', move);
3738 popup.addEventListener('mouseup', up);
3739 popup.addEventListener('touchstart', down);
3740 document.body.addEventListener('touchmove', move);
3741 popup.addEventListener('touchend', up);
3742 };
3743
3744 /**
3745 * @param {HTMLElement} popup
3746 */
3747 const removeDraggableListeners = popup => {
3748 popup.removeEventListener('mousedown', down);
3749 document.body.removeEventListener('mousemove', move);
3750 popup.removeEventListener('mouseup', up);
3751 popup.removeEventListener('touchstart', down);
3752 document.body.removeEventListener('touchmove', move);
3753 popup.removeEventListener('touchend', up);
3754 };
3755
3756 /**
3757 * @param {MouseEvent | TouchEvent} event
3758 */
3759 const down = event => {
3760 const popup = getPopup();
3761 if (!popup) {
3762 return;
3763 }
3764 const icon = getIcon();
3765 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3766 dragging = true;
3767 const clientXY = getClientXY(event);
3768 mousedownX = clientXY.clientX;
3769 mousedownY = clientXY.clientY;
3770 initialX = parseInt(popup.style.insetInlineStart) || 0;
3771 initialY = parseInt(popup.style.insetBlockStart) || 0;
3772 addClass(popup, 'swal2-dragging');
3773 }
3774 };
3775
3776 /**
3777 * @param {MouseEvent | TouchEvent} event
3778 */
3779 const move = event => {
3780 const popup = getPopup();
3781 if (!popup) {
3782 return;
3783 }
3784 if (dragging) {
3785 let {
3786 clientX,
3787 clientY
3788 } = getClientXY(event);
3789 const deltaX = clientX - mousedownX;
3790 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3791 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3792 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3793 }
3794 };
3795 const up = () => {
3796 const popup = getPopup();
3797 dragging = false;
3798 removeClass(popup, 'swal2-dragging');
3799 };
3800
3801 /**
3802 * @param {MouseEvent | TouchEvent} event
3803 * @returns {{ clientX: number, clientY: number }}
3804 */
3805 const getClientXY = event => {
3806 let clientX = 0,
3807 clientY = 0;
3808 if (event.type.startsWith('mouse')) {
3809 clientX = /** @type {MouseEvent} */event.clientX;
3810 clientY = /** @type {MouseEvent} */event.clientY;
3811 } else if (event.type.startsWith('touch')) {
3812 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
3813 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
3814 }
3815 return {
3816 clientX,
3817 clientY
3818 };
3819 };
3820
3821 /**
3822 * @param {SweetAlert} instance
3823 * @param {SweetAlertOptions} params
3824 */
3825 const renderPopup = (instance, params) => {
3826 const container = getContainer();
3827 const popup = getPopup();
3828 if (!container || !popup) {
3829 return;
3830 }
3831
3832 // Width
3833 // https://github.com/sweetalert2/sweetalert2/issues/2170
3834 if (params.toast) {
3835 applyNumericalStyle(container, 'width', params.width);
3836 popup.style.width = '100%';
3837 const loader = getLoader();
3838 if (loader) {
3839 popup.insertBefore(loader, getIcon());
3840 }
3841 } else {
3842 applyNumericalStyle(popup, 'width', params.width);
3843 }
3844
3845 // Padding
3846 applyNumericalStyle(popup, 'padding', params.padding);
3847
3848 // Color
3849 if (params.color) {
3850 popup.style.color = params.color;
3851 }
3852
3853 // Background
3854 if (params.background) {
3855 popup.style.background = params.background;
3856 }
3857 hide(getValidationMessage());
3858
3859 // Classes
3860 addClasses$1(popup, params);
3861 if (params.draggable && !params.toast) {
3862 addClass(popup, swalClasses.draggable);
3863 addDraggableListeners(popup);
3864 } else {
3865 removeClass(popup, swalClasses.draggable);
3866 removeDraggableListeners(popup);
3867 }
3868 };
3869
3870 /**
3871 * @param {HTMLElement} popup
3872 * @param {SweetAlertOptions} params
3873 */
3874 const addClasses$1 = (popup, params) => {
3875 const showClass = params.showClass || {};
3876 // Default Class + showClass when updating Swal.update({})
3877 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3878 if (params.toast) {
3879 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3880 addClass(popup, swalClasses.toast);
3881 } else {
3882 addClass(popup, swalClasses.modal);
3883 }
3884
3885 // Custom class
3886 applyCustomClass(popup, params, 'popup');
3887 // TODO: remove in the next major
3888 if (typeof params.customClass === 'string') {
3889 addClass(popup, params.customClass);
3890 }
3891
3892 // Icon class (#1842)
3893 if (params.icon) {
3894 addClass(popup, swalClasses[`icon-${params.icon}`]);
3895 }
3896 };
3897
3898 /**
3899 * @param {SweetAlert} instance
3900 * @param {SweetAlertOptions} params
3901 */
3902 const renderProgressSteps = (instance, params) => {
3903 const progressStepsContainer = getProgressSteps();
3904 if (!progressStepsContainer) {
3905 return;
3906 }
3907 const {
3908 progressSteps,
3909 currentProgressStep
3910 } = params;
3911 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3912 hide(progressStepsContainer);
3913 return;
3914 }
3915 show(progressStepsContainer);
3916 progressStepsContainer.textContent = '';
3917 if (currentProgressStep >= progressSteps.length) {
3918 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3919 }
3920 progressSteps.forEach((step, index) => {
3921 const stepEl = createStepElement(step);
3922 progressStepsContainer.appendChild(stepEl);
3923 if (index === currentProgressStep) {
3924 addClass(stepEl, swalClasses['active-progress-step']);
3925 }
3926 if (index !== progressSteps.length - 1) {
3927 const lineEl = createLineElement(params);
3928 progressStepsContainer.appendChild(lineEl);
3929 }
3930 });
3931 };
3932
3933 /**
3934 * @param {string} step
3935 * @returns {HTMLLIElement}
3936 */
3937 const createStepElement = step => {
3938 const stepEl = document.createElement('li');
3939 addClass(stepEl, swalClasses['progress-step']);
3940 setInnerHtml(stepEl, step);
3941 return stepEl;
3942 };
3943
3944 /**
3945 * @param {SweetAlertOptions} params
3946 * @returns {HTMLLIElement}
3947 */
3948 const createLineElement = params => {
3949 const lineEl = document.createElement('li');
3950 addClass(lineEl, swalClasses['progress-step-line']);
3951 if (params.progressStepsDistance) {
3952 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3953 }
3954 return lineEl;
3955 };
3956
3957 /**
3958 * @param {SweetAlert} instance
3959 * @param {SweetAlertOptions} params
3960 */
3961 const renderTitle = (instance, params) => {
3962 const title = getTitle();
3963 if (!title) {
3964 return;
3965 }
3966 showWhenInnerHtmlPresent(title);
3967 toggle(title, Boolean(params.title || params.titleText), 'block');
3968 if (params.title) {
3969 parseHtmlToContainer(params.title, title);
3970 }
3971 if (params.titleText) {
3972 title.innerText = params.titleText;
3973 }
3974
3975 // Custom class
3976 applyCustomClass(title, params, 'title');
3977 };
3978
3979 /**
3980 * @param {SweetAlert} instance
3981 * @param {SweetAlertOptions} params
3982 */
3983 const render = (instance, params) => {
3984 var _globalState$eventEmi;
3985 renderPopup(instance, params);
3986 renderContainer(instance, params);
3987 renderProgressSteps(instance, params);
3988 renderIcon(instance, params);
3989 renderImage(instance, params);
3990 renderTitle(instance, params);
3991 renderCloseButton(instance, params);
3992 renderContent(instance, params);
3993 renderActions(instance, params);
3994 renderFooter(instance, params);
3995 const popup = getPopup();
3996 if (typeof params.didRender === 'function' && popup) {
3997 params.didRender(popup);
3998 }
3999 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
4000 };
4001
4002 /*
4003 * Global function to determine if SweetAlert2 popup is shown
4004 */
4005 const isVisible = () => {
4006 return isVisible$1(getPopup());
4007 };
4008
4009 /*
4010 * Global function to click 'Confirm' button
4011 */
4012 const clickConfirm = () => {
4013 var _dom$getConfirmButton;
4014 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
4015 };
4016
4017 /*
4018 * Global function to click 'Deny' button
4019 */
4020 const clickDeny = () => {
4021 var _dom$getDenyButton;
4022 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
4023 };
4024
4025 /*
4026 * Global function to click 'Cancel' button
4027 */
4028 const clickCancel = () => {
4029 var _dom$getCancelButton;
4030 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4031 };
4032
4033 /** @type {Record<DismissReason, DismissReason>} */
4034 const DismissReason = Object.freeze({
4035 cancel: 'cancel',
4036 backdrop: 'backdrop',
4037 close: 'close',
4038 esc: 'esc',
4039 timer: 'timer'
4040 });
4041
4042 /**
4043 * @param {GlobalState} globalState
4044 */
4045 const removeKeydownHandler = globalState => {
4046 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4047 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
4048 globalState.keydownTarget.removeEventListener('keydown', handler, {
4049 capture: globalState.keydownListenerCapture
4050 });
4051 globalState.keydownHandlerAdded = false;
4052 }
4053 };
4054
4055 /**
4056 * @param {GlobalState} globalState
4057 * @param {SweetAlertOptions} innerParams
4058 * @param {(dismiss: DismissReason) => void} dismissWith
4059 */
4060 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4061 removeKeydownHandler(globalState);
4062 if (!innerParams.toast) {
4063 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4064 const handler = e => keydownHandler(innerParams, e, dismissWith);
4065 globalState.keydownHandler = handler;
4066 const target = innerParams.keydownListenerCapture ? window : getPopup();
4067 if (target) {
4068 globalState.keydownTarget = target;
4069 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4070 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4071 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4072 capture: globalState.keydownListenerCapture
4073 });
4074 globalState.keydownHandlerAdded = true;
4075 }
4076 }
4077 };
4078
4079 /**
4080 * @param {number} index
4081 * @param {number} increment
4082 */
4083 const setFocus = (index, increment) => {
4084 var _dom$getPopup;
4085 const focusableElements = getFocusableElements();
4086 // search for visible elements and select the next possible match
4087 if (focusableElements.length) {
4088 index = index + increment;
4089
4090 // shift + tab when .swal2-popup is focused
4091 if (index === -2) {
4092 index = focusableElements.length - 1;
4093 }
4094
4095 // rollover to first item
4096 if (index === focusableElements.length) {
4097 index = 0;
4098
4099 // go to last item
4100 } else if (index === -1) {
4101 index = focusableElements.length - 1;
4102 }
4103 focusableElements[index].focus();
4104 return;
4105 }
4106 // no visible focusable elements, focus the popup
4107 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4108 };
4109 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4110 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4111
4112 /**
4113 * @param {SweetAlertOptions} innerParams
4114 * @param {KeyboardEvent} event
4115 * @param {(dismiss: DismissReason) => void} dismissWith
4116 */
4117 const keydownHandler = (innerParams, event, dismissWith) => {
4118 if (!innerParams) {
4119 return; // This instance has already been destroyed
4120 }
4121
4122 // Ignore keydown during IME composition
4123 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4124 // https://github.com/sweetalert2/sweetalert2/issues/720
4125 // https://github.com/sweetalert2/sweetalert2/issues/2406
4126 if (event.isComposing || event.keyCode === 229) {
4127 return;
4128 }
4129 if (innerParams.stopKeydownPropagation) {
4130 event.stopPropagation();
4131 }
4132
4133 // ENTER
4134 if (event.key === 'Enter') {
4135 handleEnter(event, innerParams);
4136 }
4137
4138 // TAB
4139 else if (event.key === 'Tab') {
4140 handleTab(event);
4141 }
4142
4143 // ARROWS - switch focus between buttons
4144 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4145 handleArrows(event.key);
4146 }
4147
4148 // ESC
4149 else if (event.key === 'Escape') {
4150 handleEsc(event, innerParams, dismissWith);
4151 }
4152 };
4153
4154 /**
4155 * @param {KeyboardEvent} event
4156 * @param {SweetAlertOptions} innerParams
4157 */
4158 const handleEnter = (event, innerParams) => {
4159 // https://github.com/sweetalert2/sweetalert2/issues/2386
4160 if (!callIfFunction(innerParams.allowEnterKey)) {
4161 return;
4162 }
4163 const popup = getPopup();
4164 if (!popup || !innerParams.input) {
4165 return;
4166 }
4167 const input = getInput$1(popup, innerParams.input);
4168 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4169 if (['textarea', 'file'].includes(innerParams.input)) {
4170 return; // do not submit
4171 }
4172 clickConfirm();
4173 event.preventDefault();
4174 }
4175 };
4176
4177 /**
4178 * @param {KeyboardEvent} event
4179 */
4180 const handleTab = event => {
4181 const targetElement = event.target;
4182 const focusableElements = getFocusableElements();
4183 let btnIndex = -1;
4184 for (let i = 0; i < focusableElements.length; i++) {
4185 if (targetElement === focusableElements[i]) {
4186 btnIndex = i;
4187 break;
4188 }
4189 }
4190
4191 // Cycle to the next button
4192 if (!event.shiftKey) {
4193 setFocus(btnIndex, 1);
4194 }
4195
4196 // Cycle to the prev button
4197 else {
4198 setFocus(btnIndex, -1);
4199 }
4200 event.stopPropagation();
4201 event.preventDefault();
4202 };
4203
4204 /**
4205 * @param {string} key
4206 */
4207 const handleArrows = key => {
4208 const actions = getActions();
4209 const confirmButton = getConfirmButton();
4210 const denyButton = getDenyButton();
4211 const cancelButton = getCancelButton();
4212 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4213 return;
4214 }
4215 /** @type HTMLElement[] */
4216 const buttons = [confirmButton, denyButton, cancelButton];
4217 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4218 return;
4219 }
4220 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4221 let buttonToFocus = document.activeElement;
4222 if (!buttonToFocus) {
4223 return;
4224 }
4225 for (let i = 0; i < actions.children.length; i++) {
4226 buttonToFocus = buttonToFocus[sibling];
4227 if (!buttonToFocus) {
4228 return;
4229 }
4230 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4231 break;
4232 }
4233 }
4234 if (buttonToFocus instanceof HTMLButtonElement) {
4235 buttonToFocus.focus();
4236 }
4237 };
4238
4239 /**
4240 * @param {KeyboardEvent} event
4241 * @param {SweetAlertOptions} innerParams
4242 * @param {(dismiss: DismissReason) => void} dismissWith
4243 */
4244 const handleEsc = (event, innerParams, dismissWith) => {
4245 event.preventDefault();
4246 if (callIfFunction(innerParams.allowEscapeKey)) {
4247 dismissWith(DismissReason.esc);
4248 }
4249 };
4250
4251 /**
4252 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4253 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4254 * This is the approach that Babel will probably take to implement private methods/fields
4255 * https://github.com/tc39/proposal-private-methods
4256 * https://github.com/babel/babel/pull/7555
4257 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4258 * then we can use that language feature.
4259 */
4260
4261 var privateMethods = {
4262 swalPromiseResolve: new WeakMap(),
4263 swalPromiseReject: new WeakMap()
4264 };
4265
4266 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4267 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4268 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4269 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4270
4271 const setAriaHidden = () => {
4272 const container = getContainer();
4273 const bodyChildren = Array.from(document.body.children);
4274 bodyChildren.forEach(el => {
4275 if (el.contains(container)) {
4276 return;
4277 }
4278 if (el.hasAttribute('aria-hidden')) {
4279 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4280 }
4281 el.setAttribute('aria-hidden', 'true');
4282 });
4283 };
4284 const unsetAriaHidden = () => {
4285 const bodyChildren = Array.from(document.body.children);
4286 bodyChildren.forEach(el => {
4287 if (el.hasAttribute('data-previous-aria-hidden')) {
4288 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4289 el.removeAttribute('data-previous-aria-hidden');
4290 } else {
4291 el.removeAttribute('aria-hidden');
4292 }
4293 });
4294 };
4295
4296 // @ts-ignore
4297 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4298
4299 /**
4300 * Fix iOS scrolling
4301 * http://stackoverflow.com/q/39626302
4302 */
4303 const iOSfix = () => {
4304 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4305 const offset = document.body.scrollTop;
4306 document.body.style.top = `${offset * -1}px`;
4307 addClass(document.body, swalClasses.iosfix);
4308 lockBodyScroll();
4309 }
4310 };
4311
4312 /**
4313 * https://github.com/sweetalert2/sweetalert2/issues/1246
4314 */
4315 const lockBodyScroll = () => {
4316 const container = getContainer();
4317 if (!container) {
4318 return;
4319 }
4320 /** @type {boolean} */
4321 let preventTouchMove;
4322 /**
4323 * @param {TouchEvent} event
4324 */
4325 container.ontouchstart = event => {
4326 preventTouchMove = shouldPreventTouchMove(event);
4327 };
4328 /**
4329 * @param {TouchEvent} event
4330 */
4331 container.ontouchmove = event => {
4332 if (preventTouchMove) {
4333 event.preventDefault();
4334 event.stopPropagation();
4335 }
4336 };
4337 };
4338
4339 /**
4340 * @param {TouchEvent} event
4341 * @returns {boolean}
4342 */
4343 const shouldPreventTouchMove = event => {
4344 const target = event.target;
4345 const container = getContainer();
4346 const htmlContainer = getHtmlContainer();
4347 if (!container || !htmlContainer) {
4348 return false;
4349 }
4350 if (isStylus(event) || isZoom(event)) {
4351 return false;
4352 }
4353 if (target === container) {
4354 return true;
4355 }
4356 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4357 // #2823
4358 target.tagName !== 'INPUT' &&
4359 // #1603
4360 target.tagName !== 'TEXTAREA' &&
4361 // #2266
4362 !(isScrollable(htmlContainer) &&
4363 // #1944
4364 htmlContainer.contains(target))) {
4365 return true;
4366 }
4367 return false;
4368 };
4369
4370 /**
4371 * https://github.com/sweetalert2/sweetalert2/issues/1786
4372 *
4373 * @param {TouchEvent} event
4374 * @returns {boolean}
4375 */
4376 const isStylus = event => {
4377 return Boolean(event.touches && event.touches.length &&
4378 // @ts-ignore - touchType is not a standard property
4379 event.touches[0].touchType === 'stylus');
4380 };
4381
4382 /**
4383 * https://github.com/sweetalert2/sweetalert2/issues/1891
4384 *
4385 * @param {TouchEvent} event
4386 * @returns {boolean}
4387 */
4388 const isZoom = event => {
4389 return event.touches && event.touches.length > 1;
4390 };
4391 const undoIOSfix = () => {
4392 if (hasClass(document.body, swalClasses.iosfix)) {
4393 const offset = parseInt(document.body.style.top, 10);
4394 removeClass(document.body, swalClasses.iosfix);
4395 document.body.style.top = '';
4396 document.body.scrollTop = offset * -1;
4397 }
4398 };
4399
4400 /**
4401 * Measure scrollbar width for padding body during modal show/hide
4402 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4403 *
4404 * @returns {number}
4405 */
4406 const measureScrollbar = () => {
4407 const scrollDiv = document.createElement('div');
4408 scrollDiv.className = swalClasses['scrollbar-measure'];
4409 document.body.appendChild(scrollDiv);
4410 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4411 document.body.removeChild(scrollDiv);
4412 return scrollbarWidth;
4413 };
4414
4415 /**
4416 * Remember state in cases where opening and handling a modal will fiddle with it.
4417 * @type {number | null}
4418 */
4419 let previousBodyPadding = null;
4420
4421 /**
4422 * @param {string} initialBodyOverflow
4423 */
4424 const replaceScrollbarWithPadding = initialBodyOverflow => {
4425 // for queues, do not do this more than once
4426 if (previousBodyPadding !== null) {
4427 return;
4428 }
4429 // if the body has overflow
4430 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4431 ) {
4432 // add padding so the content doesn't shift after removal of scrollbar
4433 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4434 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4435 }
4436 };
4437 const undoReplaceScrollbarWithPadding = () => {
4438 if (previousBodyPadding !== null) {
4439 document.body.style.paddingRight = `${previousBodyPadding}px`;
4440 previousBodyPadding = null;
4441 }
4442 };
4443
4444 /**
4445 * @param {SweetAlert} instance
4446 * @param {HTMLElement} container
4447 * @param {boolean} returnFocus
4448 * @param {(() => void) | undefined} didClose
4449 */
4450 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4451 if (isToast()) {
4452 triggerDidCloseAndDispose(instance, didClose);
4453 } else {
4454 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4455 removeKeydownHandler(globalState);
4456 }
4457
4458 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4459 // for some reason removing the container in Safari will scroll the document to bottom
4460 if (isSafariOrIOS) {
4461 container.setAttribute('style', 'display:none !important');
4462 container.removeAttribute('class');
4463 container.innerHTML = '';
4464 } else {
4465 container.remove();
4466 }
4467 if (isModal()) {
4468 undoReplaceScrollbarWithPadding();
4469 undoIOSfix();
4470 unsetAriaHidden();
4471 }
4472 removeBodyClasses();
4473 }
4474
4475 /**
4476 * Remove SweetAlert2 classes from body
4477 */
4478 function removeBodyClasses() {
4479 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4480 }
4481
4482 /**
4483 * Instance method to close sweetAlert
4484 *
4485 * @param {SweetAlertResult | undefined} resolveValue
4486 * @this {SweetAlert}
4487 */
4488 function close(resolveValue) {
4489 resolveValue = prepareResolveValue(resolveValue);
4490 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4491 const didClose = triggerClosePopup(this);
4492 if (this.isAwaitingPromise) {
4493 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4494 if (!resolveValue.isDismissed) {
4495 handleAwaitingPromise(this);
4496 swalPromiseResolve(resolveValue);
4497 }
4498 } else if (didClose) {
4499 // Resolve Swal promise
4500 swalPromiseResolve(resolveValue);
4501 }
4502 }
4503
4504 /**
4505 * @param {SweetAlert} instance
4506 * @returns {boolean}
4507 */
4508 const triggerClosePopup = instance => {
4509 const popup = getPopup();
4510 if (!popup) {
4511 return false;
4512 }
4513 const innerParams = privateProps.innerParams.get(instance);
4514 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4515 return false;
4516 }
4517 removeClass(popup, innerParams.showClass.popup);
4518 addClass(popup, innerParams.hideClass.popup);
4519 const backdrop = getContainer();
4520 removeClass(backdrop, innerParams.showClass.backdrop);
4521 addClass(backdrop, innerParams.hideClass.backdrop);
4522 handlePopupAnimation(instance, popup, innerParams);
4523 return true;
4524 };
4525
4526 /**
4527 * @param {Error | string} error
4528 * @this {SweetAlert}
4529 */
4530 function rejectPromise(error) {
4531 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4532 handleAwaitingPromise(this);
4533 if (rejectPromise) {
4534 // Reject Swal promise
4535 rejectPromise(error);
4536 }
4537 }
4538
4539 /**
4540 * @param {SweetAlert} instance
4541 */
4542 const handleAwaitingPromise = instance => {
4543 if (instance.isAwaitingPromise) {
4544 // @ts-ignore
4545 delete instance.isAwaitingPromise;
4546 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4547 if (!privateProps.innerParams.get(instance)) {
4548 instance._destroy();
4549 }
4550 }
4551 };
4552
4553 /**
4554 * @param {SweetAlertResult | undefined} resolveValue
4555 * @returns {SweetAlertResult}
4556 */
4557 const prepareResolveValue = resolveValue => {
4558 // When user calls Swal.close()
4559 if (typeof resolveValue === 'undefined') {
4560 return {
4561 isConfirmed: false,
4562 isDenied: false,
4563 isDismissed: true
4564 };
4565 }
4566 return Object.assign({
4567 isConfirmed: false,
4568 isDenied: false,
4569 isDismissed: false
4570 }, resolveValue);
4571 };
4572
4573 /**
4574 * @param {SweetAlert} instance
4575 * @param {HTMLElement} popup
4576 * @param {SweetAlertOptions} innerParams
4577 */
4578 const handlePopupAnimation = (instance, popup, innerParams) => {
4579 var _globalState$eventEmi;
4580 const container = getContainer();
4581 // If animation is supported, animate
4582 const animationIsSupported = hasCssAnimation(popup);
4583 if (typeof innerParams.willClose === 'function') {
4584 innerParams.willClose(popup);
4585 }
4586 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4587 if (animationIsSupported && container) {
4588 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4589 } else if (container) {
4590 // Otherwise, remove immediately
4591 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4592 }
4593 };
4594
4595 /**
4596 * @param {SweetAlert} instance
4597 * @param {HTMLElement} popup
4598 * @param {HTMLElement} container
4599 * @param {boolean} returnFocus
4600 * @param {(() => void) | undefined} didClose
4601 */
4602 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4603 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4604 /**
4605 * @param {AnimationEvent | TransitionEvent} e
4606 */
4607 const swalCloseAnimationFinished = function (e) {
4608 if (e.target === popup) {
4609 var _globalState$swalClos;
4610 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4611 delete globalState.swalCloseEventFinishedCallback;
4612 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4613 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4614 }
4615 };
4616 popup.addEventListener('animationend', swalCloseAnimationFinished);
4617 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4618 };
4619
4620 /**
4621 * @param {SweetAlert} instance
4622 * @param {(() => void) | undefined} didClose
4623 */
4624 const triggerDidCloseAndDispose = (instance, didClose) => {
4625 setTimeout(() => {
4626 var _globalState$eventEmi2;
4627 if (typeof didClose === 'function') {
4628 didClose.bind(instance.params)();
4629 }
4630 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4631 // instance might have been destroyed already
4632 if (instance._destroy) {
4633 instance._destroy();
4634 }
4635 });
4636 };
4637
4638 /**
4639 * Shows loader (spinner), this is useful with AJAX requests.
4640 * By default the loader be shown instead of the "Confirm" button.
4641 *
4642 * @param {HTMLButtonElement | null} [buttonToReplace]
4643 */
4644 const showLoading = buttonToReplace => {
4645 let popup = getPopup();
4646 if (!popup) {
4647 new Swal();
4648 }
4649 popup = getPopup();
4650 if (!popup) {
4651 return;
4652 }
4653 const loader = getLoader();
4654 if (isToast()) {
4655 hide(getIcon());
4656 } else {
4657 replaceButton(popup, buttonToReplace);
4658 }
4659 show(loader);
4660 popup.setAttribute('data-loading', 'true');
4661 popup.setAttribute('aria-busy', 'true');
4662 popup.focus();
4663 };
4664
4665 /**
4666 * @param {HTMLElement} popup
4667 * @param {HTMLButtonElement | null} [buttonToReplace]
4668 */
4669 const replaceButton = (popup, buttonToReplace) => {
4670 const actions = getActions();
4671 const loader = getLoader();
4672 if (!actions || !loader) {
4673 return;
4674 }
4675 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4676 buttonToReplace = getConfirmButton();
4677 }
4678 show(actions);
4679 if (buttonToReplace) {
4680 hide(buttonToReplace);
4681 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4682 actions.insertBefore(loader, buttonToReplace);
4683 }
4684 addClass([popup, actions], swalClasses.loading);
4685 };
4686
4687 /**
4688 * @param {SweetAlert} instance
4689 * @param {SweetAlertOptions} params
4690 */
4691 const handleInputOptionsAndValue = (instance, params) => {
4692 if (params.input === 'select' || params.input === 'radio') {
4693 handleInputOptions(instance, params);
4694 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4695 showLoading(getConfirmButton());
4696 handleInputValue(instance, params);
4697 }
4698 };
4699
4700 /**
4701 * @param {SweetAlert} instance
4702 * @param {SweetAlertOptions} innerParams
4703 * @returns {SweetAlertInputValue}
4704 */
4705 const getInputValue = (instance, innerParams) => {
4706 const input = instance.getInput();
4707 if (!input) {
4708 return null;
4709 }
4710 switch (innerParams.input) {
4711 case 'checkbox':
4712 return getCheckboxValue(input);
4713 case 'radio':
4714 return getRadioValue(input);
4715 case 'file':
4716 return getFileValue(input);
4717 default:
4718 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4719 }
4720 };
4721
4722 /**
4723 * @param {HTMLInputElement} input
4724 * @returns {number}
4725 */
4726 const getCheckboxValue = input => input.checked ? 1 : 0;
4727
4728 /**
4729 * @param {HTMLInputElement} input
4730 * @returns {string | null}
4731 */
4732 const getRadioValue = input => input.checked ? input.value : null;
4733
4734 /**
4735 * @param {HTMLInputElement} input
4736 * @returns {FileList | File | null}
4737 */
4738 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4739
4740 /**
4741 * @param {SweetAlert} instance
4742 * @param {SweetAlertOptions} params
4743 */
4744 const handleInputOptions = (instance, params) => {
4745 const popup = getPopup();
4746 if (!popup) {
4747 return;
4748 }
4749 /**
4750 * @param {*} inputOptions
4751 */
4752 const processInputOptions = inputOptions => {
4753 if (params.input === 'select') {
4754 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4755 } else if (params.input === 'radio') {
4756 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4757 }
4758 };
4759 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4760 showLoading(getConfirmButton());
4761 asPromise(params.inputOptions).then(inputOptions => {
4762 instance.hideLoading();
4763 processInputOptions(inputOptions);
4764 });
4765 } else if (typeof params.inputOptions === 'object') {
4766 processInputOptions(params.inputOptions);
4767 } else {
4768 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4769 }
4770 };
4771
4772 /**
4773 * @param {SweetAlert} instance
4774 * @param {SweetAlertOptions} params
4775 */
4776 const handleInputValue = (instance, params) => {
4777 const input = instance.getInput();
4778 if (!input) {
4779 return;
4780 }
4781 hide(input);
4782 asPromise(params.inputValue).then(inputValue => {
4783 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4784 show(input);
4785 input.focus();
4786 instance.hideLoading();
4787 }).catch(err => {
4788 error(`Error in inputValue promise: ${err}`);
4789 input.value = '';
4790 show(input);
4791 input.focus();
4792 instance.hideLoading();
4793 });
4794 };
4795
4796 /**
4797 * @param {HTMLElement} popup
4798 * @param {InputOptionFlattened[]} inputOptions
4799 * @param {SweetAlertOptions} params
4800 */
4801 function populateSelectOptions(popup, inputOptions, params) {
4802 const select = getDirectChildByClass(popup, swalClasses.select);
4803 if (!select) {
4804 return;
4805 }
4806 /**
4807 * @param {HTMLElement} parent
4808 * @param {string} optionLabel
4809 * @param {string} optionValue
4810 */
4811 const renderOption = (parent, optionLabel, optionValue) => {
4812 const option = document.createElement('option');
4813 option.value = optionValue;
4814 setInnerHtml(option, optionLabel);
4815 option.selected = isSelected(optionValue, params.inputValue);
4816 parent.appendChild(option);
4817 };
4818 inputOptions.forEach(inputOption => {
4819 const optionValue = inputOption[0];
4820 const optionLabel = inputOption[1];
4821 // <optgroup> spec:
4822 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4823 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4824 // check whether this is a <optgroup>
4825 if (Array.isArray(optionLabel)) {
4826 // if it is an array, then it is an <optgroup>
4827 const optgroup = document.createElement('optgroup');
4828 optgroup.label = optionValue;
4829 optgroup.disabled = false; // not configurable for now
4830 select.appendChild(optgroup);
4831 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4832 } else {
4833 // case of <option>
4834 renderOption(select, optionLabel, optionValue);
4835 }
4836 });
4837 select.focus();
4838 }
4839
4840 /**
4841 * @param {HTMLElement} popup
4842 * @param {InputOptionFlattened[]} inputOptions
4843 * @param {SweetAlertOptions} params
4844 */
4845 function populateRadioOptions(popup, inputOptions, params) {
4846 const radio = getDirectChildByClass(popup, swalClasses.radio);
4847 if (!radio) {
4848 return;
4849 }
4850 inputOptions.forEach(inputOption => {
4851 const radioValue = inputOption[0];
4852 const radioLabel = inputOption[1];
4853 const radioInput = document.createElement('input');
4854 const radioLabelElement = document.createElement('label');
4855 radioInput.type = 'radio';
4856 radioInput.name = swalClasses.radio;
4857 radioInput.value = radioValue;
4858 if (isSelected(radioValue, params.inputValue)) {
4859 radioInput.checked = true;
4860 }
4861 const label = document.createElement('span');
4862 setInnerHtml(label, radioLabel);
4863 label.className = swalClasses.label;
4864 radioLabelElement.appendChild(radioInput);
4865 radioLabelElement.appendChild(label);
4866 radio.appendChild(radioLabelElement);
4867 });
4868 const radios = radio.querySelectorAll('input');
4869 if (radios.length) {
4870 radios[0].focus();
4871 }
4872 }
4873
4874 /**
4875 * Converts `inputOptions` into an array of `[value, label]`s
4876 *
4877 * @param {*} inputOptions
4878 * @typedef {string[]} InputOptionFlattened
4879 * @returns {InputOptionFlattened[]}
4880 */
4881 const formatInputOptions = inputOptions => {
4882 /** @type {InputOptionFlattened[]} */
4883 const result = [];
4884 if (inputOptions instanceof Map) {
4885 inputOptions.forEach((value, key) => {
4886 let valueFormatted = value;
4887 if (typeof valueFormatted === 'object') {
4888 // case of <optgroup>
4889 valueFormatted = formatInputOptions(valueFormatted);
4890 }
4891 result.push([key, valueFormatted]);
4892 });
4893 } else {
4894 Object.keys(inputOptions).forEach(key => {
4895 let valueFormatted = inputOptions[key];
4896 if (typeof valueFormatted === 'object') {
4897 // case of <optgroup>
4898 valueFormatted = formatInputOptions(valueFormatted);
4899 }
4900 result.push([key, valueFormatted]);
4901 });
4902 }
4903 return result;
4904 };
4905
4906 /**
4907 * @param {string} optionValue
4908 * @param {SweetAlertInputValue} inputValue
4909 * @returns {boolean}
4910 */
4911 const isSelected = (optionValue, inputValue) => {
4912 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
4913 };
4914
4915 /**
4916 * @param {SweetAlert} instance
4917 */
4918 const handleConfirmButtonClick = instance => {
4919 const innerParams = privateProps.innerParams.get(instance);
4920 instance.disableButtons();
4921 if (innerParams.input) {
4922 handleConfirmOrDenyWithInput(instance, 'confirm');
4923 } else {
4924 confirm(instance, true);
4925 }
4926 };
4927
4928 /**
4929 * @param {SweetAlert} instance
4930 */
4931 const handleDenyButtonClick = instance => {
4932 const innerParams = privateProps.innerParams.get(instance);
4933 instance.disableButtons();
4934 if (innerParams.returnInputValueOnDeny) {
4935 handleConfirmOrDenyWithInput(instance, 'deny');
4936 } else {
4937 deny(instance, false);
4938 }
4939 };
4940
4941 /**
4942 * @param {SweetAlert} instance
4943 * @param {(dismiss: DismissReason) => void} dismissWith
4944 */
4945 const handleCancelButtonClick = (instance, dismissWith) => {
4946 instance.disableButtons();
4947 dismissWith(DismissReason.cancel);
4948 };
4949
4950 /**
4951 * @param {SweetAlert} instance
4952 * @param {'confirm' | 'deny'} type
4953 */
4954 const handleConfirmOrDenyWithInput = (instance, type) => {
4955 const innerParams = privateProps.innerParams.get(instance);
4956 if (!innerParams.input) {
4957 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4958 return;
4959 }
4960 const input = instance.getInput();
4961 const inputValue = getInputValue(instance, innerParams);
4962 if (innerParams.inputValidator) {
4963 handleInputValidator(instance, inputValue, type);
4964 } else if (input && !input.checkValidity()) {
4965 instance.enableButtons();
4966 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4967 } else if (type === 'deny') {
4968 deny(instance, inputValue);
4969 } else {
4970 confirm(instance, inputValue);
4971 }
4972 };
4973
4974 /**
4975 * @param {SweetAlert} instance
4976 * @param {SweetAlertInputValue} inputValue
4977 * @param {'confirm' | 'deny'} type
4978 */
4979 const handleInputValidator = (instance, inputValue, type) => {
4980 const innerParams = privateProps.innerParams.get(instance);
4981 instance.disableInput();
4982 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4983 validationPromise.then(validationMessage => {
4984 instance.enableButtons();
4985 instance.enableInput();
4986 if (validationMessage) {
4987 instance.showValidationMessage(validationMessage);
4988 } else if (type === 'deny') {
4989 deny(instance, inputValue);
4990 } else {
4991 confirm(instance, inputValue);
4992 }
4993 });
4994 };
4995
4996 /**
4997 * @param {SweetAlert} instance
4998 * @param {*} value
4999 */
5000 const deny = (instance, value) => {
5001 const innerParams = privateProps.innerParams.get(instance);
5002 if (innerParams.showLoaderOnDeny) {
5003 showLoading(getDenyButton());
5004 }
5005 if (innerParams.preDeny) {
5006 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
5007 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
5008 preDenyPromise.then(preDenyValue => {
5009 if (preDenyValue === false) {
5010 instance.hideLoading();
5011 handleAwaitingPromise(instance);
5012 } else {
5013 instance.close(/** @type SweetAlertResult */{
5014 isDenied: true,
5015 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
5016 });
5017 }
5018 }).catch(error => rejectWith(instance, error));
5019 } else {
5020 instance.close(/** @type SweetAlertResult */{
5021 isDenied: true,
5022 value
5023 });
5024 }
5025 };
5026
5027 /**
5028 * @param {SweetAlert} instance
5029 * @param {*} value
5030 */
5031 const succeedWith = (instance, value) => {
5032 instance.close(/** @type SweetAlertResult */{
5033 isConfirmed: true,
5034 value
5035 });
5036 };
5037
5038 /**
5039 *
5040 * @param {SweetAlert} instance
5041 * @param {string} error
5042 */
5043 const rejectWith = (instance, error) => {
5044 instance.rejectPromise(error);
5045 };
5046
5047 /**
5048 *
5049 * @param {SweetAlert} instance
5050 * @param {*} value
5051 */
5052 const confirm = (instance, value) => {
5053 const innerParams = privateProps.innerParams.get(instance);
5054 if (innerParams.showLoaderOnConfirm) {
5055 showLoading();
5056 }
5057 if (innerParams.preConfirm) {
5058 instance.resetValidationMessage();
5059 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
5060 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5061 preConfirmPromise.then(preConfirmValue => {
5062 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5063 instance.hideLoading();
5064 handleAwaitingPromise(instance);
5065 } else {
5066 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5067 }
5068 }).catch(error => rejectWith(instance, error));
5069 } else {
5070 succeedWith(instance, value);
5071 }
5072 };
5073
5074 /**
5075 * Hides loader and shows back the button which was hidden by .showLoading()
5076 * @this {SweetAlert}
5077 */
5078 function hideLoading() {
5079 // do nothing if popup is closed
5080 const innerParams = privateProps.innerParams.get(this);
5081 if (!innerParams) {
5082 return;
5083 }
5084 const domCache = privateProps.domCache.get(this);
5085 hide(domCache.loader);
5086 if (isToast()) {
5087 if (innerParams.icon) {
5088 show(getIcon());
5089 }
5090 } else {
5091 showRelatedButton(domCache);
5092 }
5093 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5094 domCache.popup.removeAttribute('aria-busy');
5095 domCache.popup.removeAttribute('data-loading');
5096 domCache.confirmButton.disabled = false;
5097 domCache.denyButton.disabled = false;
5098 domCache.cancelButton.disabled = false;
5099 }
5100
5101 /**
5102 * @param {DomCache} domCache
5103 */
5104 const showRelatedButton = domCache => {
5105 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5106 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5107 if (buttonToReplace.length) {
5108 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5109 } else if (allButtonsAreHidden()) {
5110 hide(domCache.actions);
5111 }
5112 };
5113
5114 /**
5115 * Gets the input DOM node, this method works with input parameter.
5116 *
5117 * @returns {HTMLInputElement | null}
5118 * @this {SweetAlert}
5119 */
5120 function getInput() {
5121 const innerParams = privateProps.innerParams.get(this);
5122 const domCache = privateProps.domCache.get(this);
5123 if (!domCache) {
5124 return null;
5125 }
5126 return getInput$1(domCache.popup, innerParams.input);
5127 }
5128
5129 /**
5130 * @param {SweetAlert} instance
5131 * @param {string[]} buttons
5132 * @param {boolean} disabled
5133 */
5134 function setButtonsDisabled(instance, buttons, disabled) {
5135 const domCache = privateProps.domCache.get(instance);
5136 buttons.forEach(button => {
5137 domCache[button].disabled = disabled;
5138 });
5139 }
5140
5141 /**
5142 * @param {HTMLInputElement | null} input
5143 * @param {boolean} disabled
5144 */
5145 function setInputDisabled(input, disabled) {
5146 const popup = getPopup();
5147 if (!popup || !input) {
5148 return;
5149 }
5150 if (input.type === 'radio') {
5151 /** @type {NodeListOf<HTMLInputElement>} */
5152 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5153 for (let i = 0; i < radios.length; i++) {
5154 radios[i].disabled = disabled;
5155 }
5156 } else {
5157 input.disabled = disabled;
5158 }
5159 }
5160
5161 /**
5162 * Enable all the buttons
5163 * @this {SweetAlert}
5164 */
5165 function enableButtons() {
5166 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5167 }
5168
5169 /**
5170 * Disable all the buttons
5171 * @this {SweetAlert}
5172 */
5173 function disableButtons() {
5174 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5175 }
5176
5177 /**
5178 * Enable the input field
5179 * @this {SweetAlert}
5180 */
5181 function enableInput() {
5182 setInputDisabled(this.getInput(), false);
5183 }
5184
5185 /**
5186 * Disable the input field
5187 * @this {SweetAlert}
5188 */
5189 function disableInput() {
5190 setInputDisabled(this.getInput(), true);
5191 }
5192
5193 /**
5194 * Show block with validation message
5195 *
5196 * @param {string} error
5197 * @this {SweetAlert}
5198 */
5199 function showValidationMessage(error) {
5200 const domCache = privateProps.domCache.get(this);
5201 const params = privateProps.innerParams.get(this);
5202 setInnerHtml(domCache.validationMessage, error);
5203 domCache.validationMessage.className = swalClasses['validation-message'];
5204 if (params.customClass && params.customClass.validationMessage) {
5205 addClass(domCache.validationMessage, params.customClass.validationMessage);
5206 }
5207 show(domCache.validationMessage);
5208 const input = this.getInput();
5209 if (input) {
5210 input.setAttribute('aria-invalid', 'true');
5211 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5212 focusInput(input);
5213 addClass(input, swalClasses.inputerror);
5214 }
5215 }
5216
5217 /**
5218 * Hide block with validation message
5219 *
5220 * @this {SweetAlert}
5221 */
5222 function resetValidationMessage() {
5223 const domCache = privateProps.domCache.get(this);
5224 if (domCache.validationMessage) {
5225 hide(domCache.validationMessage);
5226 }
5227 const input = this.getInput();
5228 if (input) {
5229 input.removeAttribute('aria-invalid');
5230 input.removeAttribute('aria-describedby');
5231 removeClass(input, swalClasses.inputerror);
5232 }
5233 }
5234
5235 const defaultParams = {
5236 title: '',
5237 titleText: '',
5238 text: '',
5239 html: '',
5240 footer: '',
5241 icon: undefined,
5242 iconColor: undefined,
5243 iconHtml: undefined,
5244 template: undefined,
5245 toast: false,
5246 draggable: false,
5247 animation: true,
5248 theme: 'light',
5249 showClass: {
5250 popup: 'swal2-show',
5251 backdrop: 'swal2-backdrop-show',
5252 icon: 'swal2-icon-show'
5253 },
5254 hideClass: {
5255 popup: 'swal2-hide',
5256 backdrop: 'swal2-backdrop-hide',
5257 icon: 'swal2-icon-hide'
5258 },
5259 customClass: {},
5260 target: 'body',
5261 color: undefined,
5262 backdrop: true,
5263 heightAuto: true,
5264 allowOutsideClick: true,
5265 allowEscapeKey: true,
5266 allowEnterKey: true,
5267 stopKeydownPropagation: true,
5268 keydownListenerCapture: false,
5269 showConfirmButton: true,
5270 showDenyButton: false,
5271 showCancelButton: false,
5272 preConfirm: undefined,
5273 preDeny: undefined,
5274 confirmButtonText: 'OK',
5275 confirmButtonAriaLabel: '',
5276 confirmButtonColor: undefined,
5277 denyButtonText: 'No',
5278 denyButtonAriaLabel: '',
5279 denyButtonColor: undefined,
5280 cancelButtonText: 'Cancel',
5281 cancelButtonAriaLabel: '',
5282 cancelButtonColor: undefined,
5283 buttonsStyling: true,
5284 reverseButtons: false,
5285 focusConfirm: true,
5286 focusDeny: false,
5287 focusCancel: false,
5288 returnFocus: true,
5289 showCloseButton: false,
5290 closeButtonHtml: '&times;',
5291 closeButtonAriaLabel: 'Close this dialog',
5292 loaderHtml: '',
5293 showLoaderOnConfirm: false,
5294 showLoaderOnDeny: false,
5295 imageUrl: undefined,
5296 imageWidth: undefined,
5297 imageHeight: undefined,
5298 imageAlt: '',
5299 timer: undefined,
5300 timerProgressBar: false,
5301 width: undefined,
5302 padding: undefined,
5303 background: undefined,
5304 input: undefined,
5305 inputPlaceholder: '',
5306 inputLabel: '',
5307 inputValue: '',
5308 inputOptions: {},
5309 inputAutoFocus: true,
5310 inputAutoTrim: true,
5311 inputAttributes: {},
5312 inputValidator: undefined,
5313 returnInputValueOnDeny: false,
5314 validationMessage: undefined,
5315 grow: false,
5316 position: 'center',
5317 progressSteps: [],
5318 currentProgressStep: undefined,
5319 progressStepsDistance: undefined,
5320 willOpen: undefined,
5321 didOpen: undefined,
5322 didRender: undefined,
5323 willClose: undefined,
5324 didClose: undefined,
5325 didDestroy: undefined,
5326 scrollbarPadding: true,
5327 topLayer: false
5328 };
5329 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'];
5330
5331 /** @type {Record<string, string | undefined>} */
5332 const deprecatedParams = {
5333 allowEnterKey: undefined
5334 };
5335 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5336
5337 /**
5338 * Is valid parameter
5339 *
5340 * @param {string} paramName
5341 * @returns {boolean}
5342 */
5343 const isValidParameter = paramName => {
5344 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5345 };
5346
5347 /**
5348 * Is valid parameter for Swal.update() method
5349 *
5350 * @param {string} paramName
5351 * @returns {boolean}
5352 */
5353 const isUpdatableParameter = paramName => {
5354 return updatableParams.indexOf(paramName) !== -1;
5355 };
5356
5357 /**
5358 * Is deprecated parameter
5359 *
5360 * @param {string} paramName
5361 * @returns {string | undefined}
5362 */
5363 const isDeprecatedParameter = paramName => {
5364 return deprecatedParams[paramName];
5365 };
5366
5367 /**
5368 * @param {string} param
5369 */
5370 const checkIfParamIsValid = param => {
5371 if (!isValidParameter(param)) {
5372 warn(`Unknown parameter "${param}"`);
5373 }
5374 };
5375
5376 /**
5377 * @param {string} param
5378 */
5379 const checkIfToastParamIsValid = param => {
5380 if (toastIncompatibleParams.includes(param)) {
5381 warn(`The parameter "${param}" is incompatible with toasts`);
5382 }
5383 };
5384
5385 /**
5386 * @param {string} param
5387 */
5388 const checkIfParamIsDeprecated = param => {
5389 const isDeprecated = isDeprecatedParameter(param);
5390 if (isDeprecated) {
5391 warnAboutDeprecation(param, isDeprecated);
5392 }
5393 };
5394
5395 /**
5396 * Show relevant warnings for given params
5397 *
5398 * @param {SweetAlertOptions} params
5399 */
5400 const showWarningsForParams = params => {
5401 if (params.backdrop === false && params.allowOutsideClick) {
5402 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5403 }
5404 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)) {
5405 warn(`Invalid theme "${params.theme}"`);
5406 }
5407 for (const param in params) {
5408 checkIfParamIsValid(param);
5409 if (params.toast) {
5410 checkIfToastParamIsValid(param);
5411 }
5412 checkIfParamIsDeprecated(param);
5413 }
5414 };
5415
5416 /**
5417 * Updates popup parameters.
5418 *
5419 * @this {any}
5420 * @param {SweetAlertOptions} params
5421 */
5422 function update(params) {
5423 const container = getContainer();
5424 const popup = getPopup();
5425 const innerParams = privateProps.innerParams.get(this);
5426 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5427 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.`);
5428 return;
5429 }
5430 const validUpdatableParams = filterValidParams(params);
5431 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5432 showWarningsForParams(updatedParams);
5433 if (container) {
5434 container.dataset['swal2Theme'] = updatedParams.theme;
5435 }
5436 render(this, updatedParams);
5437 privateProps.innerParams.set(this, updatedParams);
5438 Object.defineProperties(this, {
5439 params: {
5440 value: Object.assign({}, this.params, params),
5441 writable: false,
5442 enumerable: true
5443 }
5444 });
5445 }
5446
5447 /**
5448 * @param {SweetAlertOptions} params
5449 * @returns {SweetAlertOptions}
5450 */
5451 const filterValidParams = params => {
5452 /** @type {Record<string, any>} */
5453 const validUpdatableParams = {};
5454 Object.keys(params).forEach(param => {
5455 if (isUpdatableParameter(param)) {
5456 const typedParams = /** @type {Record<string, any>} */params;
5457 validUpdatableParams[param] = typedParams[param];
5458 } else {
5459 warn(`Invalid parameter to update: ${param}`);
5460 }
5461 });
5462 return validUpdatableParams;
5463 };
5464
5465 /**
5466 * Dispose the current SweetAlert2 instance
5467 * @this {SweetAlert}
5468 */
5469 function _destroy() {
5470 var _globalState$eventEmi;
5471 const domCache = privateProps.domCache.get(this);
5472 const innerParams = privateProps.innerParams.get(this);
5473 if (!innerParams) {
5474 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5475 return; // This instance has already been destroyed
5476 }
5477
5478 // Check if there is another Swal closing
5479 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5480 globalState.swalCloseEventFinishedCallback();
5481 delete globalState.swalCloseEventFinishedCallback;
5482 }
5483 if (typeof innerParams.didDestroy === 'function') {
5484 innerParams.didDestroy();
5485 }
5486 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5487 disposeSwal(this);
5488 }
5489
5490 /**
5491 * @param {SweetAlert} instance
5492 */
5493 const disposeSwal = instance => {
5494 disposeWeakMaps(instance);
5495 // Unset this.params so GC will dispose it (#1569)
5496 // @ts-ignore
5497 delete instance.params;
5498 // Unset globalState props so GC will dispose globalState (#1569)
5499 delete globalState.keydownHandler;
5500 delete globalState.keydownTarget;
5501 // Unset currentInstance
5502 delete globalState.currentInstance;
5503 };
5504
5505 /**
5506 * @param {SweetAlert} instance
5507 */
5508 const disposeWeakMaps = instance => {
5509 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5510 if (instance.isAwaitingPromise) {
5511 unsetWeakMaps(privateProps, instance);
5512 instance.isAwaitingPromise = true;
5513 } else {
5514 unsetWeakMaps(privateMethods, instance);
5515 unsetWeakMaps(privateProps, instance);
5516
5517 // @ts-ignore
5518 delete instance.isAwaitingPromise;
5519 // Unset instance methods
5520 // @ts-ignore
5521 delete instance.disableButtons;
5522 // @ts-ignore
5523 delete instance.enableButtons;
5524 // @ts-ignore
5525 delete instance.getInput;
5526 // @ts-ignore
5527 delete instance.disableInput;
5528 // @ts-ignore
5529 delete instance.enableInput;
5530 // @ts-ignore
5531 delete instance.hideLoading;
5532 // @ts-ignore
5533 delete instance.disableLoading;
5534 // @ts-ignore
5535 delete instance.showValidationMessage;
5536 // @ts-ignore
5537 delete instance.resetValidationMessage;
5538 // @ts-ignore
5539 delete instance.close;
5540 // @ts-ignore
5541 delete instance.closePopup;
5542 // @ts-ignore
5543 delete instance.closeModal;
5544 // @ts-ignore
5545 delete instance.closeToast;
5546 // @ts-ignore
5547 delete instance.rejectPromise;
5548 // @ts-ignore
5549 delete instance.update;
5550 // @ts-ignore
5551 delete instance._destroy;
5552 }
5553 };
5554
5555 /**
5556 * @param {Record<string, WeakMap<any, any>>} obj
5557 * @param {SweetAlert} instance
5558 */
5559 const unsetWeakMaps = (obj, instance) => {
5560 for (const i in obj) {
5561 obj[i].delete(instance);
5562 }
5563 };
5564
5565 var instanceMethods = /*#__PURE__*/Object.freeze({
5566 __proto__: null,
5567 _destroy: _destroy,
5568 close: close,
5569 closeModal: close,
5570 closePopup: close,
5571 closeToast: close,
5572 disableButtons: disableButtons,
5573 disableInput: disableInput,
5574 disableLoading: hideLoading,
5575 enableButtons: enableButtons,
5576 enableInput: enableInput,
5577 getInput: getInput,
5578 handleAwaitingPromise: handleAwaitingPromise,
5579 hideLoading: hideLoading,
5580 rejectPromise: rejectPromise,
5581 resetValidationMessage: resetValidationMessage,
5582 showValidationMessage: showValidationMessage,
5583 update: update
5584 });
5585
5586 /**
5587 * @param {SweetAlertOptions} innerParams
5588 * @param {DomCache} domCache
5589 * @param {(dismiss: DismissReason) => void} dismissWith
5590 */
5591 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5592 if (innerParams.toast) {
5593 handleToastClick(innerParams, domCache, dismissWith);
5594 } else {
5595 // Ignore click events that had mousedown on the popup but mouseup on the container
5596 // This can happen when the user drags a slider
5597 handleModalMousedown(domCache);
5598
5599 // Ignore click events that had mousedown on the container but mouseup on the popup
5600 handleContainerMousedown(domCache);
5601 handleModalClick(innerParams, domCache, dismissWith);
5602 }
5603 };
5604
5605 /**
5606 * @param {SweetAlertOptions} innerParams
5607 * @param {DomCache} domCache
5608 * @param {(dismiss: DismissReason) => void} dismissWith
5609 */
5610 const handleToastClick = (innerParams, domCache, dismissWith) => {
5611 // Closing toast by internal click
5612 domCache.popup.onclick = () => {
5613 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5614 return;
5615 }
5616 dismissWith(DismissReason.close);
5617 };
5618 };
5619
5620 /**
5621 * @param {SweetAlertOptions} innerParams
5622 * @returns {boolean}
5623 */
5624 const isAnyButtonShown = innerParams => {
5625 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5626 };
5627 let ignoreOutsideClick = false;
5628
5629 /**
5630 * @param {DomCache} domCache
5631 */
5632 const handleModalMousedown = domCache => {
5633 domCache.popup.onmousedown = () => {
5634 domCache.container.onmouseup = function (e) {
5635 domCache.container.onmouseup = () => {};
5636 // We only check if the mouseup target is the container because usually it doesn't
5637 // have any other direct children aside of the popup
5638 if (e.target === domCache.container) {
5639 ignoreOutsideClick = true;
5640 }
5641 };
5642 };
5643 };
5644
5645 /**
5646 * @param {DomCache} domCache
5647 */
5648 const handleContainerMousedown = domCache => {
5649 domCache.container.onmousedown = e => {
5650 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5651 if (e.target === domCache.container) {
5652 e.preventDefault();
5653 }
5654 domCache.popup.onmouseup = function (e) {
5655 domCache.popup.onmouseup = () => {};
5656 // We also need to check if the mouseup target is a child of the popup
5657 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5658 ignoreOutsideClick = true;
5659 }
5660 };
5661 };
5662 };
5663
5664 /**
5665 * @param {SweetAlertOptions} innerParams
5666 * @param {DomCache} domCache
5667 * @param {(dismiss: DismissReason) => void} dismissWith
5668 */
5669 const handleModalClick = (innerParams, domCache, dismissWith) => {
5670 domCache.container.onclick = e => {
5671 if (ignoreOutsideClick) {
5672 ignoreOutsideClick = false;
5673 return;
5674 }
5675 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5676 dismissWith(DismissReason.backdrop);
5677 }
5678 };
5679 };
5680
5681 /**
5682 * @param {any} elem
5683 * @returns {boolean}
5684 */
5685 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
5686
5687 /**
5688 * @param {any} elem
5689 * @returns {boolean}
5690 */
5691 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5692
5693 /**
5694 * @param {any[]} args
5695 * @returns {SweetAlertOptions}
5696 */
5697 const argsToParams = args => {
5698 /** @type {Record<string, any>} */
5699 const params = {};
5700 if (typeof args[0] === 'object' && !isElement(args[0])) {
5701 Object.assign(params, args[0]);
5702 } else {
5703 ['title', 'html', 'icon'].forEach((name, index) => {
5704 const arg = args[index];
5705 if (typeof arg === 'string' || isElement(arg)) {
5706 params[name] = arg;
5707 } else if (arg !== undefined) {
5708 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5709 }
5710 });
5711 }
5712 return params;
5713 };
5714
5715 /**
5716 * Main method to create a new SweetAlert2 popup
5717 *
5718 * @this {new (...args: any[]) => any}
5719 * @param {...SweetAlertOptions} args
5720 * @returns {Promise<SweetAlertResult>}
5721 */
5722 function fire(...args) {
5723 return new this(...args);
5724 }
5725
5726 /**
5727 * Returns an extended version of `Swal` containing `params` as defaults.
5728 * Useful for reusing Swal configuration.
5729 *
5730 * For example:
5731 *
5732 * Before:
5733 * const textPromptOptions = { input: 'text', showCancelButton: true }
5734 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5735 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5736 *
5737 * After:
5738 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5739 * const {value: firstName} = await TextPrompt('What is your first name?')
5740 * const {value: lastName} = await TextPrompt('What is your last name?')
5741 *
5742 * @param {SweetAlertOptions} mixinParams
5743 * @returns {SweetAlert}
5744 * @this {typeof import('../SweetAlert.js').SweetAlert}
5745 */
5746 function mixin(mixinParams) {
5747 // @ts-ignore: 'this' refers to the SweetAlert constructor
5748 class MixinSwal extends this {
5749 /**
5750 * @param {any} params
5751 * @param {any} priorityMixinParams
5752 */
5753 _main(params, priorityMixinParams) {
5754 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5755 }
5756 }
5757 // @ts-ignore
5758 return MixinSwal;
5759 }
5760
5761 /**
5762 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5763 * Otherwise, returns undefined.
5764 *
5765 * @returns {number | undefined}
5766 */
5767 const getTimerLeft = () => {
5768 return globalState.timeout && globalState.timeout.getTimerLeft();
5769 };
5770
5771 /**
5772 * Stop timer. Returns number of milliseconds of timer remained.
5773 * If `timer` parameter isn't set, returns undefined.
5774 *
5775 * @returns {number | undefined}
5776 */
5777 const stopTimer = () => {
5778 if (globalState.timeout) {
5779 stopTimerProgressBar();
5780 return globalState.timeout.stop();
5781 }
5782 };
5783
5784 /**
5785 * Resume timer. Returns number of milliseconds of timer remained.
5786 * If `timer` parameter isn't set, returns undefined.
5787 *
5788 * @returns {number | undefined}
5789 */
5790 const resumeTimer = () => {
5791 if (globalState.timeout) {
5792 const remaining = globalState.timeout.start();
5793 animateTimerProgressBar(remaining);
5794 return remaining;
5795 }
5796 };
5797
5798 /**
5799 * Resume timer. Returns number of milliseconds of timer remained.
5800 * If `timer` parameter isn't set, returns undefined.
5801 *
5802 * @returns {number | undefined}
5803 */
5804 const toggleTimer = () => {
5805 const timer = globalState.timeout;
5806 return timer && (timer.running ? stopTimer() : resumeTimer());
5807 };
5808
5809 /**
5810 * Increase timer. Returns number of milliseconds of an updated timer.
5811 * If `timer` parameter isn't set, returns undefined.
5812 *
5813 * @param {number} ms
5814 * @returns {number | undefined}
5815 */
5816 const increaseTimer = ms => {
5817 if (globalState.timeout) {
5818 const remaining = globalState.timeout.increase(ms);
5819 animateTimerProgressBar(remaining, true);
5820 return remaining;
5821 }
5822 };
5823
5824 /**
5825 * Check if timer is running. Returns true if timer is running
5826 * or false if timer is paused or stopped.
5827 * If `timer` parameter isn't set, returns undefined
5828 *
5829 * @returns {boolean}
5830 */
5831 const isTimerRunning = () => {
5832 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5833 };
5834
5835 let bodyClickListenerAdded = false;
5836 /** @type {Record<string, any>} */
5837 const clickHandlers = {};
5838
5839 /**
5840 * @this {any}
5841 * @param {string} attr
5842 */
5843 function bindClickHandler(attr = 'data-swal-template') {
5844 clickHandlers[attr] = this;
5845 if (!bodyClickListenerAdded) {
5846 document.body.addEventListener('click', bodyClickListener);
5847 bodyClickListenerAdded = true;
5848 }
5849 }
5850
5851 /**
5852 * @param {MouseEvent} event
5853 */
5854 const bodyClickListener = event => {
5855 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5856 for (const attr in clickHandlers) {
5857 const template = el.getAttribute && el.getAttribute(attr);
5858 if (template) {
5859 clickHandlers[attr].fire({
5860 template
5861 });
5862 return;
5863 }
5864 }
5865 }
5866 };
5867
5868 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5869
5870 class EventEmitter {
5871 constructor() {
5872 /** @type {Events} */
5873 this.events = {};
5874 }
5875
5876 /**
5877 * @param {string} eventName
5878 * @returns {EventHandlers}
5879 */
5880 _getHandlersByEventName(eventName) {
5881 if (typeof this.events[eventName] === 'undefined') {
5882 // not Set because we need to keep the FIFO order
5883 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5884 this.events[eventName] = [];
5885 }
5886 return this.events[eventName];
5887 }
5888
5889 /**
5890 * @param {string} eventName
5891 * @param {EventHandler} eventHandler
5892 */
5893 on(eventName, eventHandler) {
5894 const currentHandlers = this._getHandlersByEventName(eventName);
5895 if (!currentHandlers.includes(eventHandler)) {
5896 currentHandlers.push(eventHandler);
5897 }
5898 }
5899
5900 /**
5901 * @param {string} eventName
5902 * @param {EventHandler} eventHandler
5903 */
5904 once(eventName, eventHandler) {
5905 /**
5906 * @param {...any} args
5907 */
5908 const onceFn = (...args) => {
5909 this.removeListener(eventName, onceFn);
5910 // @ts-ignore
5911 eventHandler.apply(this, args);
5912 };
5913 this.on(eventName, onceFn);
5914 }
5915
5916 /**
5917 * @param {string} eventName
5918 * @param {...any} args
5919 */
5920 emit(eventName, ...args) {
5921 this._getHandlersByEventName(eventName).forEach(
5922 /**
5923 * @param {EventHandler} eventHandler
5924 */
5925 eventHandler => {
5926 try {
5927 // @ts-ignore
5928 eventHandler.apply(this, args);
5929 } catch (error) {
5930 console.error(error);
5931 }
5932 });
5933 }
5934
5935 /**
5936 * @param {string} eventName
5937 * @param {EventHandler} eventHandler
5938 */
5939 removeListener(eventName, eventHandler) {
5940 const currentHandlers = this._getHandlersByEventName(eventName);
5941 const index = currentHandlers.indexOf(eventHandler);
5942 if (index > -1) {
5943 currentHandlers.splice(index, 1);
5944 }
5945 }
5946
5947 /**
5948 * @param {string} eventName
5949 */
5950 removeAllListeners(eventName) {
5951 if (this.events[eventName] !== undefined) {
5952 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5953 this.events[eventName].length = 0;
5954 }
5955 }
5956 reset() {
5957 this.events = {};
5958 }
5959 }
5960
5961 globalState.eventEmitter = new EventEmitter();
5962
5963 /**
5964 * @param {string} eventName
5965 * @param {EventHandler} eventHandler
5966 */
5967 const on = (eventName, eventHandler) => {
5968 if (globalState.eventEmitter) {
5969 globalState.eventEmitter.on(eventName, eventHandler);
5970 }
5971 };
5972
5973 /**
5974 * @param {string} eventName
5975 * @param {EventHandler} eventHandler
5976 */
5977 const once = (eventName, eventHandler) => {
5978 if (globalState.eventEmitter) {
5979 globalState.eventEmitter.once(eventName, eventHandler);
5980 }
5981 };
5982
5983 /**
5984 * @param {string} [eventName]
5985 * @param {EventHandler} [eventHandler]
5986 */
5987 const off = (eventName, eventHandler) => {
5988 if (!globalState.eventEmitter) {
5989 return;
5990 }
5991
5992 // Remove all handlers for all events
5993 if (!eventName) {
5994 globalState.eventEmitter.reset();
5995 return;
5996 }
5997 if (eventHandler) {
5998 // Remove a specific handler
5999 globalState.eventEmitter.removeListener(eventName, eventHandler);
6000 } else {
6001 // Remove all handlers for a specific event
6002 globalState.eventEmitter.removeAllListeners(eventName);
6003 }
6004 };
6005
6006 var staticMethods = /*#__PURE__*/Object.freeze({
6007 __proto__: null,
6008 argsToParams: argsToParams,
6009 bindClickHandler: bindClickHandler,
6010 clickCancel: clickCancel,
6011 clickConfirm: clickConfirm,
6012 clickDeny: clickDeny,
6013 enableLoading: showLoading,
6014 fire: fire,
6015 getActions: getActions,
6016 getCancelButton: getCancelButton,
6017 getCloseButton: getCloseButton,
6018 getConfirmButton: getConfirmButton,
6019 getContainer: getContainer,
6020 getDenyButton: getDenyButton,
6021 getFocusableElements: getFocusableElements,
6022 getFooter: getFooter,
6023 getHtmlContainer: getHtmlContainer,
6024 getIcon: getIcon,
6025 getIconContent: getIconContent,
6026 getImage: getImage,
6027 getInputLabel: getInputLabel,
6028 getLoader: getLoader,
6029 getPopup: getPopup,
6030 getProgressSteps: getProgressSteps,
6031 getTimerLeft: getTimerLeft,
6032 getTimerProgressBar: getTimerProgressBar,
6033 getTitle: getTitle,
6034 getValidationMessage: getValidationMessage,
6035 increaseTimer: increaseTimer,
6036 isDeprecatedParameter: isDeprecatedParameter,
6037 isLoading: isLoading,
6038 isTimerRunning: isTimerRunning,
6039 isUpdatableParameter: isUpdatableParameter,
6040 isValidParameter: isValidParameter,
6041 isVisible: isVisible,
6042 mixin: mixin,
6043 off: off,
6044 on: on,
6045 once: once,
6046 resumeTimer: resumeTimer,
6047 showLoading: showLoading,
6048 stopTimer: stopTimer,
6049 toggleTimer: toggleTimer
6050 });
6051
6052 class Timer {
6053 /**
6054 * @param {() => void} callback
6055 * @param {number} delay
6056 */
6057 constructor(callback, delay) {
6058 this.callback = callback;
6059 this.remaining = delay;
6060 this.running = false;
6061 this.start();
6062 }
6063
6064 /**
6065 * @returns {number}
6066 */
6067 start() {
6068 if (!this.running) {
6069 this.running = true;
6070 this.started = new Date();
6071 this.id = setTimeout(this.callback, this.remaining);
6072 }
6073 return this.remaining;
6074 }
6075
6076 /**
6077 * @returns {number}
6078 */
6079 stop() {
6080 if (this.started && this.running) {
6081 this.running = false;
6082 clearTimeout(this.id);
6083 this.remaining -= new Date().getTime() - this.started.getTime();
6084 }
6085 return this.remaining;
6086 }
6087
6088 /**
6089 * @param {number} n
6090 * @returns {number}
6091 */
6092 increase(n) {
6093 const running = this.running;
6094 if (running) {
6095 this.stop();
6096 }
6097 this.remaining += n;
6098 if (running) {
6099 this.start();
6100 }
6101 return this.remaining;
6102 }
6103
6104 /**
6105 * @returns {number}
6106 */
6107 getTimerLeft() {
6108 if (this.running) {
6109 this.stop();
6110 this.start();
6111 }
6112 return this.remaining;
6113 }
6114
6115 /**
6116 * @returns {boolean}
6117 */
6118 isRunning() {
6119 return this.running;
6120 }
6121 }
6122
6123 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6124
6125 /**
6126 * @param {SweetAlertOptions} params
6127 * @returns {SweetAlertOptions}
6128 */
6129 const getTemplateParams = params => {
6130 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6131 if (!template) {
6132 return {};
6133 }
6134 /** @type {DocumentFragment} */
6135 const templateContent = template.content;
6136 showWarningsForElements(templateContent);
6137 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6138 return result;
6139 };
6140
6141 /**
6142 * @param {DocumentFragment} templateContent
6143 * @returns {Record<string, string | boolean | number>}
6144 */
6145 const getSwalParams = templateContent => {
6146 /** @type {Record<string, string | boolean | number>} */
6147 const result = {};
6148 /** @type {HTMLElement[]} */
6149 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6150 swalParams.forEach(param => {
6151 showWarningsForAttributes(param, ['name', 'value']);
6152 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6153 const value = param.getAttribute('value');
6154 if (!paramName || !value) {
6155 return;
6156 }
6157 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6158 result[paramName] = value !== 'false';
6159 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6160 result[paramName] = JSON.parse(value);
6161 } else {
6162 result[paramName] = value;
6163 }
6164 });
6165 return result;
6166 };
6167
6168 /**
6169 * @param {DocumentFragment} templateContent
6170 * @returns {Record<string, () => void>}
6171 */
6172 const getSwalFunctionParams = templateContent => {
6173 /** @type {Record<string, () => void>} */
6174 const result = {};
6175 /** @type {HTMLElement[]} */
6176 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6177 swalFunctions.forEach(param => {
6178 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6179 const value = param.getAttribute('value');
6180 if (!paramName || !value) {
6181 return;
6182 }
6183 result[paramName] = new Function(`return ${value}`)();
6184 });
6185 return result;
6186 };
6187
6188 /**
6189 * @param {DocumentFragment} templateContent
6190 * @returns {Record<string, string | boolean>}
6191 */
6192 const getSwalButtons = templateContent => {
6193 /** @type {Record<string, string | boolean>} */
6194 const result = {};
6195 /** @type {HTMLElement[]} */
6196 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6197 swalButtons.forEach(button => {
6198 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6199 const type = button.getAttribute('type');
6200 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6201 return;
6202 }
6203 result[`${type}ButtonText`] = button.innerHTML;
6204 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6205 if (button.hasAttribute('color')) {
6206 const color = button.getAttribute('color');
6207 if (color !== null) {
6208 result[`${type}ButtonColor`] = color;
6209 }
6210 }
6211 if (button.hasAttribute('aria-label')) {
6212 const ariaLabel = button.getAttribute('aria-label');
6213 if (ariaLabel !== null) {
6214 result[`${type}ButtonAriaLabel`] = ariaLabel;
6215 }
6216 }
6217 });
6218 return result;
6219 };
6220
6221 /**
6222 * @param {DocumentFragment} templateContent
6223 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6224 */
6225 const getSwalImage = templateContent => {
6226 const result = {};
6227 /** @type {HTMLElement | null} */
6228 const image = templateContent.querySelector('swal-image');
6229 if (image) {
6230 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6231 if (image.hasAttribute('src')) {
6232 result.imageUrl = image.getAttribute('src') || undefined;
6233 }
6234 if (image.hasAttribute('width')) {
6235 result.imageWidth = image.getAttribute('width') || undefined;
6236 }
6237 if (image.hasAttribute('height')) {
6238 result.imageHeight = image.getAttribute('height') || undefined;
6239 }
6240 if (image.hasAttribute('alt')) {
6241 result.imageAlt = image.getAttribute('alt') || undefined;
6242 }
6243 }
6244 return result;
6245 };
6246
6247 /**
6248 * @param {DocumentFragment} templateContent
6249 * @returns {object}
6250 */
6251 const getSwalIcon = templateContent => {
6252 const result = {};
6253 /** @type {HTMLElement | null} */
6254 const icon = templateContent.querySelector('swal-icon');
6255 if (icon) {
6256 showWarningsForAttributes(icon, ['type', 'color']);
6257 if (icon.hasAttribute('type')) {
6258 result.icon = icon.getAttribute('type');
6259 }
6260 if (icon.hasAttribute('color')) {
6261 result.iconColor = icon.getAttribute('color');
6262 }
6263 result.iconHtml = icon.innerHTML;
6264 }
6265 return result;
6266 };
6267
6268 /**
6269 * @param {DocumentFragment} templateContent
6270 * @returns {object}
6271 */
6272 const getSwalInput = templateContent => {
6273 /** @type {Record<string, any>} */
6274 const result = {};
6275 /** @type {HTMLElement | null} */
6276 const input = templateContent.querySelector('swal-input');
6277 if (input) {
6278 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6279 result.input = input.getAttribute('type') || 'text';
6280 if (input.hasAttribute('label')) {
6281 result.inputLabel = input.getAttribute('label');
6282 }
6283 if (input.hasAttribute('placeholder')) {
6284 result.inputPlaceholder = input.getAttribute('placeholder');
6285 }
6286 if (input.hasAttribute('value')) {
6287 result.inputValue = input.getAttribute('value');
6288 }
6289 }
6290 /** @type {HTMLElement[]} */
6291 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6292 if (inputOptions.length) {
6293 result.inputOptions = {};
6294 inputOptions.forEach(option => {
6295 showWarningsForAttributes(option, ['value']);
6296 const optionValue = option.getAttribute('value');
6297 if (!optionValue) {
6298 return;
6299 }
6300 const optionName = option.innerHTML;
6301 result.inputOptions[optionValue] = optionName;
6302 });
6303 }
6304 return result;
6305 };
6306
6307 /**
6308 * @param {DocumentFragment} templateContent
6309 * @param {string[]} paramNames
6310 * @returns {Record<string, string>}
6311 */
6312 const getSwalStringParams = (templateContent, paramNames) => {
6313 /** @type {Record<string, string>} */
6314 const result = {};
6315 for (const i in paramNames) {
6316 const paramName = paramNames[i];
6317 /** @type {HTMLElement | null} */
6318 const tag = templateContent.querySelector(paramName);
6319 if (tag) {
6320 showWarningsForAttributes(tag, []);
6321 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6322 }
6323 }
6324 return result;
6325 };
6326
6327 /**
6328 * @param {DocumentFragment} templateContent
6329 */
6330 const showWarningsForElements = templateContent => {
6331 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6332 Array.from(templateContent.children).forEach(el => {
6333 const tagName = el.tagName.toLowerCase();
6334 if (!allowedElements.includes(tagName)) {
6335 warn(`Unrecognized element <${tagName}>`);
6336 }
6337 });
6338 };
6339
6340 /**
6341 * @param {HTMLElement} el
6342 * @param {string[]} allowedAttributes
6343 */
6344 const showWarningsForAttributes = (el, allowedAttributes) => {
6345 Array.from(el.attributes).forEach(attribute => {
6346 if (allowedAttributes.indexOf(attribute.name) === -1) {
6347 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.'}`]);
6348 }
6349 });
6350 };
6351
6352 const SHOW_CLASS_TIMEOUT = 10;
6353
6354 /**
6355 * Open popup, add necessary classes and styles, fix scrollbar
6356 *
6357 * @param {SweetAlertOptions} params
6358 */
6359 const openPopup = params => {
6360 var _globalState$eventEmi, _globalState$eventEmi2;
6361 const container = getContainer();
6362 const popup = getPopup();
6363 if (!container || !popup) {
6364 return;
6365 }
6366 if (typeof params.willOpen === 'function') {
6367 params.willOpen(popup);
6368 }
6369 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6370 const bodyStyles = window.getComputedStyle(document.body);
6371 const initialBodyOverflow = bodyStyles.overflowY;
6372 addClasses(container, popup, params);
6373
6374 // scrolling is 'hidden' until animation is done, after that 'auto'
6375 setTimeout(() => {
6376 setScrollingVisibility(container, popup);
6377 }, SHOW_CLASS_TIMEOUT);
6378 if (isModal()) {
6379 // Using ternary instead of ?? operator for Webpack 4 compatibility
6380 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6381 setAriaHidden();
6382 }
6383 if (!isToast() && !globalState.previousActiveElement) {
6384 globalState.previousActiveElement = document.activeElement;
6385 }
6386 if (typeof params.didOpen === 'function') {
6387 const didOpen = params.didOpen;
6388 setTimeout(() => didOpen(popup));
6389 }
6390 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6391 };
6392
6393 /**
6394 * @param {Event} event
6395 */
6396 const swalOpenAnimationFinished = event => {
6397 const popup = getPopup();
6398 if (!popup || event.target !== popup) {
6399 return;
6400 }
6401 const container = getContainer();
6402 if (!container) {
6403 return;
6404 }
6405 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6406 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6407 container.style.overflowY = 'auto';
6408
6409 // no-transition is added in init() in case one swal is opened right after another
6410 removeClass(container, swalClasses['no-transition']);
6411 };
6412
6413 /**
6414 * @param {HTMLElement} container
6415 * @param {HTMLElement} popup
6416 */
6417 const setScrollingVisibility = (container, popup) => {
6418 if (hasCssAnimation(popup)) {
6419 container.style.overflowY = 'hidden';
6420 popup.addEventListener('animationend', swalOpenAnimationFinished);
6421 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6422 } else {
6423 container.style.overflowY = 'auto';
6424 }
6425 };
6426
6427 /**
6428 * @param {HTMLElement} container
6429 * @param {boolean} scrollbarPadding
6430 * @param {string} initialBodyOverflow
6431 */
6432 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6433 iOSfix();
6434 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6435 replaceScrollbarWithPadding(initialBodyOverflow);
6436 }
6437
6438 // sweetalert2/issues/1247
6439 setTimeout(() => {
6440 container.scrollTop = 0;
6441 });
6442 };
6443
6444 /**
6445 * @param {HTMLElement} container
6446 * @param {HTMLElement} popup
6447 * @param {SweetAlertOptions} params
6448 */
6449 const addClasses = (container, popup, params) => {
6450 var _params$showClass;
6451 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6452 addClass(container, params.showClass.backdrop);
6453 }
6454 if (params.animation) {
6455 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6456 popup.style.setProperty('opacity', '0', 'important');
6457 show(popup, 'grid');
6458 setTimeout(() => {
6459 var _params$showClass2;
6460 // Animate popup right after showing it
6461 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6462 addClass(popup, params.showClass.popup);
6463 }
6464 // and remove the opacity workaround
6465 popup.style.removeProperty('opacity');
6466 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6467 } else {
6468 show(popup, 'grid');
6469 }
6470 addClass([document.documentElement, document.body], swalClasses.shown);
6471 if (params.heightAuto && params.backdrop && !params.toast) {
6472 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6473 }
6474 };
6475
6476 var defaultInputValidators = {
6477 /**
6478 * @param {string} string
6479 * @param {string} [validationMessage]
6480 * @returns {Promise<string | void>}
6481 */
6482 email: (string, validationMessage) => {
6483 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6484 },
6485 /**
6486 * @param {string} string
6487 * @param {string} [validationMessage]
6488 * @returns {Promise<string | void>}
6489 */
6490 url: (string, validationMessage) => {
6491 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6492 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');
6493 }
6494 };
6495
6496 /**
6497 * @param {SweetAlertOptions} params
6498 */
6499 function setDefaultInputValidators(params) {
6500 // Use default `inputValidator` for supported input types if not provided
6501 if (params.inputValidator) {
6502 return;
6503 }
6504 if (params.input === 'email') {
6505 params.inputValidator = defaultInputValidators['email'];
6506 }
6507 if (params.input === 'url') {
6508 params.inputValidator = defaultInputValidators['url'];
6509 }
6510 }
6511
6512 /**
6513 * @param {SweetAlertOptions} params
6514 */
6515 function validateCustomTargetElement(params) {
6516 // Determine if the custom target element is valid
6517 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6518 warn('Target parameter is not valid, defaulting to "body"');
6519 params.target = 'body';
6520 }
6521 }
6522
6523 /**
6524 * Set type, text and actions on popup
6525 *
6526 * @param {SweetAlertOptions} params
6527 */
6528 function setParameters(params) {
6529 setDefaultInputValidators(params);
6530
6531 // showLoaderOnConfirm && preConfirm
6532 if (params.showLoaderOnConfirm && !params.preConfirm) {
6533 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');
6534 }
6535 validateCustomTargetElement(params);
6536
6537 // Replace newlines with <br> in title
6538 if (typeof params.title === 'string') {
6539 params.title = params.title.split('\n').join('<br />');
6540 }
6541 init(params);
6542 }
6543
6544 /** @type {SweetAlert} */
6545 let currentInstance;
6546 var _promise = /*#__PURE__*/new WeakMap();
6547 class SweetAlert {
6548 /**
6549 * @param {...(SweetAlertOptions | string)} args
6550 * @this {SweetAlert}
6551 */
6552 constructor(...args) {
6553 /**
6554 * @type {Promise<SweetAlertResult>}
6555 */
6556 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
6557 isConfirmed: false,
6558 isDenied: false,
6559 isDismissed: true
6560 }));
6561 // Prevent run in Node env
6562 if (typeof window === 'undefined') {
6563 return;
6564 }
6565 currentInstance = this;
6566
6567 // @ts-ignore
6568 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6569
6570 /** @type {Readonly<SweetAlertOptions>} */
6571 this.params = outerParams;
6572
6573 /** @type {boolean} */
6574 this.isAwaitingPromise = false;
6575 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6576 }
6577
6578 /**
6579 * @param {any} userParams
6580 * @param {any} mixinParams
6581 */
6582 _main(userParams, mixinParams = {}) {
6583 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6584 if (globalState.currentInstance) {
6585 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6586 const {
6587 isAwaitingPromise
6588 } = globalState.currentInstance;
6589 globalState.currentInstance._destroy();
6590 if (!isAwaitingPromise) {
6591 swalPromiseResolve({
6592 isDismissed: true
6593 });
6594 }
6595 if (isModal()) {
6596 unsetAriaHidden();
6597 }
6598 }
6599 globalState.currentInstance = currentInstance;
6600 const innerParams = prepareParams(userParams, mixinParams);
6601 setParameters(innerParams);
6602 Object.freeze(innerParams);
6603
6604 // clear the previous timer
6605 if (globalState.timeout) {
6606 globalState.timeout.stop();
6607 delete globalState.timeout;
6608 }
6609
6610 // clear the restore focus timeout
6611 clearTimeout(globalState.restoreFocusTimeout);
6612 const domCache = populateDomCache(currentInstance);
6613 render(currentInstance, innerParams);
6614 privateProps.innerParams.set(currentInstance, innerParams);
6615 return swalPromise(currentInstance, domCache, innerParams);
6616 }
6617
6618 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6619 /**
6620 * @param {any} onFulfilled
6621 */
6622 then(onFulfilled) {
6623 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6624 }
6625
6626 /**
6627 * @param {any} onFinally
6628 */
6629 finally(onFinally) {
6630 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6631 }
6632 }
6633
6634 /**
6635 * @param {SweetAlert} instance
6636 * @param {DomCache} domCache
6637 * @param {SweetAlertOptions} innerParams
6638 * @returns {Promise<SweetAlertResult>}
6639 */
6640 const swalPromise = (instance, domCache, innerParams) => {
6641 return new Promise((resolve, reject) => {
6642 // functions to handle all closings/dismissals
6643 /**
6644 * @param {DismissReason} dismiss
6645 */
6646 const dismissWith = dismiss => {
6647 instance.close({
6648 isDismissed: true,
6649 dismiss,
6650 isConfirmed: false,
6651 isDenied: false
6652 });
6653 };
6654 privateMethods.swalPromiseResolve.set(instance, resolve);
6655 privateMethods.swalPromiseReject.set(instance, reject);
6656 domCache.confirmButton.onclick = () => {
6657 handleConfirmButtonClick(instance);
6658 };
6659 domCache.denyButton.onclick = () => {
6660 handleDenyButtonClick(instance);
6661 };
6662 domCache.cancelButton.onclick = () => {
6663 handleCancelButtonClick(instance, dismissWith);
6664 };
6665 domCache.closeButton.onclick = () => {
6666 dismissWith(DismissReason.close);
6667 };
6668 handlePopupClick(innerParams, domCache, dismissWith);
6669 addKeydownHandler(globalState, innerParams, dismissWith);
6670 handleInputOptionsAndValue(instance, innerParams);
6671 openPopup(innerParams);
6672 setupTimer(globalState, innerParams, dismissWith);
6673 initFocus(domCache, innerParams);
6674
6675 // Scroll container to top on open (#1247, #1946)
6676 setTimeout(() => {
6677 domCache.container.scrollTop = 0;
6678 });
6679 });
6680 };
6681
6682 /**
6683 * @param {SweetAlertOptions} userParams
6684 * @param {SweetAlertOptions} mixinParams
6685 * @returns {SweetAlertOptions}
6686 */
6687 const prepareParams = (userParams, mixinParams) => {
6688 const templateParams = getTemplateParams(userParams);
6689 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6690 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6691 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6692 if (params.animation === false) {
6693 params.showClass = {
6694 backdrop: 'swal2-noanimation'
6695 };
6696 params.hideClass = {};
6697 }
6698 return params;
6699 };
6700
6701 /**
6702 * @param {SweetAlert} instance
6703 * @returns {DomCache}
6704 */
6705 const populateDomCache = instance => {
6706 const domCache = /** @type {DomCache} */{
6707 popup: (/** @type {HTMLElement} */getPopup()),
6708 container: (/** @type {HTMLElement} */getContainer()),
6709 actions: (/** @type {HTMLElement} */getActions()),
6710 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6711 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6712 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6713 loader: (/** @type {HTMLElement} */getLoader()),
6714 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6715 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6716 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6717 };
6718 privateProps.domCache.set(instance, domCache);
6719 return domCache;
6720 };
6721
6722 /**
6723 * @param {GlobalState} globalState
6724 * @param {SweetAlertOptions} innerParams
6725 * @param {(dismiss: DismissReason) => void} dismissWith
6726 */
6727 const setupTimer = (globalState, innerParams, dismissWith) => {
6728 const timerProgressBar = getTimerProgressBar();
6729 hide(timerProgressBar);
6730 if (innerParams.timer) {
6731 globalState.timeout = new Timer(() => {
6732 dismissWith('timer');
6733 delete globalState.timeout;
6734 }, innerParams.timer);
6735 if (innerParams.timerProgressBar && timerProgressBar) {
6736 show(timerProgressBar);
6737 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6738 setTimeout(() => {
6739 if (globalState.timeout && globalState.timeout.running) {
6740 // timer can be already stopped or unset at this point
6741 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6742 }
6743 });
6744 }
6745 }
6746 };
6747
6748 /**
6749 * Initialize focus in the popup:
6750 *
6751 * 1. If `toast` is `true`, don't steal focus from the document.
6752 * 2. Else if there is an [autofocus] element, focus it.
6753 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6754 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6755 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6756 * 6. Else focus the first focusable element in a popup (if any).
6757 *
6758 * @param {DomCache} domCache
6759 * @param {SweetAlertOptions} innerParams
6760 */
6761 const initFocus = (domCache, innerParams) => {
6762 if (innerParams.toast) {
6763 return;
6764 }
6765 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6766 if (!callIfFunction(innerParams.allowEnterKey)) {
6767 warnAboutDeprecation('allowEnterKey');
6768 blurActiveElement();
6769 return;
6770 }
6771 if (focusAutofocus(domCache)) {
6772 return;
6773 }
6774 if (focusButton(domCache, innerParams)) {
6775 return;
6776 }
6777 setFocus(-1, 1);
6778 };
6779
6780 /**
6781 * @param {DomCache} domCache
6782 * @returns {boolean}
6783 */
6784 const focusAutofocus = domCache => {
6785 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6786 for (const autofocusElement of autofocusElements) {
6787 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6788 autofocusElement.focus();
6789 return true;
6790 }
6791 }
6792 return false;
6793 };
6794
6795 /**
6796 * @param {DomCache} domCache
6797 * @param {SweetAlertOptions} innerParams
6798 * @returns {boolean}
6799 */
6800 const focusButton = (domCache, innerParams) => {
6801 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6802 domCache.denyButton.focus();
6803 return true;
6804 }
6805 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6806 domCache.cancelButton.focus();
6807 return true;
6808 }
6809 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6810 domCache.confirmButton.focus();
6811 return true;
6812 }
6813 return false;
6814 };
6815 const blurActiveElement = () => {
6816 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
6817 document.activeElement.blur();
6818 }
6819 };
6820
6821 // Assign instance methods from src/instanceMethods/*.js to prototype
6822 SweetAlert.prototype.disableButtons = disableButtons;
6823 SweetAlert.prototype.enableButtons = enableButtons;
6824 SweetAlert.prototype.getInput = getInput;
6825 SweetAlert.prototype.disableInput = disableInput;
6826 SweetAlert.prototype.enableInput = enableInput;
6827 SweetAlert.prototype.hideLoading = hideLoading;
6828 SweetAlert.prototype.disableLoading = hideLoading;
6829 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6830 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6831 SweetAlert.prototype.close = close;
6832 SweetAlert.prototype.closePopup = close;
6833 SweetAlert.prototype.closeModal = close;
6834 SweetAlert.prototype.closeToast = close;
6835 SweetAlert.prototype.rejectPromise = rejectPromise;
6836 SweetAlert.prototype.update = update;
6837 SweetAlert.prototype._destroy = _destroy;
6838
6839 // Assign static methods from src/staticMethods/*.js to constructor
6840 Object.assign(SweetAlert, staticMethods);
6841
6842 // Proxy to instance methods to constructor, for now, for backwards compatibility
6843 Object.keys(instanceMethods).forEach(key => {
6844 /**
6845 * @param {...(SweetAlertOptions | string | undefined)} args
6846 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6847 */
6848 // @ts-ignore: Dynamic property assignment for backwards compatibility
6849 SweetAlert[key] = function (...args) {
6850 // @ts-ignore
6851 if (currentInstance && currentInstance[key]) {
6852 // @ts-ignore
6853 return currentInstance[key](...args);
6854 }
6855 return undefined;
6856 };
6857 });
6858 SweetAlert.DismissReason = DismissReason;
6859 SweetAlert.version = '11.26.17';
6860
6861 const Swal = SweetAlert;
6862 // @ts-ignore
6863 Swal.default = Swal;
6864
6865 return Swal;
6866
6867 }));
6868 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6869 "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}}");
6870
6871 /***/ },
6872
6873 /***/ "./node_modules/toastify-js/src/toastify.js"
6874 /*!**************************************************!*\
6875 !*** ./node_modules/toastify-js/src/toastify.js ***!
6876 \**************************************************/
6877 (module) {
6878
6879 /*!
6880 * Toastify js 1.12.0
6881 * https://github.com/apvarun/toastify-js
6882 * @license MIT licensed
6883 *
6884 * Copyright (C) 2018 Varun A P
6885 */
6886 (function(root, factory) {
6887 if ( true && module.exports) {
6888 module.exports = factory();
6889 } else {
6890 root.Toastify = factory();
6891 }
6892 })(this, function(global) {
6893 // Object initialization
6894 var Toastify = function(options) {
6895 // Returning a new init object
6896 return new Toastify.lib.init(options);
6897 },
6898 // Library version
6899 version = "1.12.0";
6900
6901 // Set the default global options
6902 Toastify.defaults = {
6903 oldestFirst: true,
6904 text: "Toastify is awesome!",
6905 node: undefined,
6906 duration: 3000,
6907 selector: undefined,
6908 callback: function () {
6909 },
6910 destination: undefined,
6911 newWindow: false,
6912 close: false,
6913 gravity: "toastify-top",
6914 positionLeft: false,
6915 position: '',
6916 backgroundColor: '',
6917 avatar: "",
6918 className: "",
6919 stopOnFocus: true,
6920 onClick: function () {
6921 },
6922 offset: {x: 0, y: 0},
6923 escapeMarkup: true,
6924 ariaLive: 'polite',
6925 style: {background: ''}
6926 };
6927
6928 // Defining the prototype of the object
6929 Toastify.lib = Toastify.prototype = {
6930 toastify: version,
6931
6932 constructor: Toastify,
6933
6934 // Initializing the object with required parameters
6935 init: function(options) {
6936 // Verifying and validating the input object
6937 if (!options) {
6938 options = {};
6939 }
6940
6941 // Creating the options object
6942 this.options = {};
6943
6944 this.toastElement = null;
6945
6946 // Validating the options
6947 this.options.text = options.text || Toastify.defaults.text; // Display message
6948 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6949 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6950 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6951 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6952 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6953 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6954 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6955 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6956 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6957 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6958 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6959 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6960 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6961 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6962 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6963 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6964 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6965 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6966 this.options.style = options.style || Toastify.defaults.style;
6967 if(options.backgroundColor) {
6968 this.options.style.background = options.backgroundColor;
6969 }
6970
6971 // Returning the current object for chaining functions
6972 return this;
6973 },
6974
6975 // Building the DOM element
6976 buildToast: function() {
6977 // Validating if the options are defined
6978 if (!this.options) {
6979 throw "Toastify is not initialized";
6980 }
6981
6982 // Creating the DOM object
6983 var divElement = document.createElement("div");
6984 divElement.className = "toastify on " + this.options.className;
6985
6986 // Positioning toast to left or right or center
6987 if (!!this.options.position) {
6988 divElement.className += " toastify-" + this.options.position;
6989 } else {
6990 // To be depreciated in further versions
6991 if (this.options.positionLeft === true) {
6992 divElement.className += " toastify-left";
6993 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6994 } else {
6995 // Default position
6996 divElement.className += " toastify-right";
6997 }
6998 }
6999
7000 // Assigning gravity of element
7001 divElement.className += " " + this.options.gravity;
7002
7003 if (this.options.backgroundColor) {
7004 // This is being deprecated in favor of using the style HTML DOM property
7005 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
7006 }
7007
7008 // Loop through our style object and apply styles to divElement
7009 for (var property in this.options.style) {
7010 divElement.style[property] = this.options.style[property];
7011 }
7012
7013 // Announce the toast to screen readers
7014 if (this.options.ariaLive) {
7015 divElement.setAttribute('aria-live', this.options.ariaLive)
7016 }
7017
7018 // Adding the toast message/node
7019 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
7020 // If we have a valid node, we insert it
7021 divElement.appendChild(this.options.node)
7022 } else {
7023 if (this.options.escapeMarkup) {
7024 divElement.innerText = this.options.text;
7025 } else {
7026 divElement.innerHTML = this.options.text;
7027 }
7028
7029 if (this.options.avatar !== "") {
7030 var avatarElement = document.createElement("img");
7031 avatarElement.src = this.options.avatar;
7032
7033 avatarElement.className = "toastify-avatar";
7034
7035 if (this.options.position == "left" || this.options.positionLeft === true) {
7036 // Adding close icon on the left of content
7037 divElement.appendChild(avatarElement);
7038 } else {
7039 // Adding close icon on the right of content
7040 divElement.insertAdjacentElement("afterbegin", avatarElement);
7041 }
7042 }
7043 }
7044
7045 // Adding a close icon to the toast
7046 if (this.options.close === true) {
7047 // Create a span for close element
7048 var closeElement = document.createElement("button");
7049 closeElement.type = "button";
7050 closeElement.setAttribute("aria-label", "Close");
7051 closeElement.className = "toast-close";
7052 closeElement.innerHTML = "&#10006;";
7053
7054 // Triggering the removal of toast from DOM on close click
7055 closeElement.addEventListener(
7056 "click",
7057 function(event) {
7058 event.stopPropagation();
7059 this.removeElement(this.toastElement);
7060 window.clearTimeout(this.toastElement.timeOutValue);
7061 }.bind(this)
7062 );
7063
7064 //Calculating screen width
7065 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7066
7067 // Adding the close icon to the toast element
7068 // Display on the right if screen width is less than or equal to 360px
7069 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7070 // Adding close icon on the left of content
7071 divElement.insertAdjacentElement("afterbegin", closeElement);
7072 } else {
7073 // Adding close icon on the right of content
7074 divElement.appendChild(closeElement);
7075 }
7076 }
7077
7078 // Clear timeout while toast is focused
7079 if (this.options.stopOnFocus && this.options.duration > 0) {
7080 var self = this;
7081 // stop countdown
7082 divElement.addEventListener(
7083 "mouseover",
7084 function(event) {
7085 window.clearTimeout(divElement.timeOutValue);
7086 }
7087 )
7088 // add back the timeout
7089 divElement.addEventListener(
7090 "mouseleave",
7091 function() {
7092 divElement.timeOutValue = window.setTimeout(
7093 function() {
7094 // Remove the toast from DOM
7095 self.removeElement(divElement);
7096 },
7097 self.options.duration
7098 )
7099 }
7100 )
7101 }
7102
7103 // Adding an on-click destination path
7104 if (typeof this.options.destination !== "undefined") {
7105 divElement.addEventListener(
7106 "click",
7107 function(event) {
7108 event.stopPropagation();
7109 if (this.options.newWindow === true) {
7110 window.open(this.options.destination, "_blank");
7111 } else {
7112 window.location = this.options.destination;
7113 }
7114 }.bind(this)
7115 );
7116 }
7117
7118 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7119 divElement.addEventListener(
7120 "click",
7121 function(event) {
7122 event.stopPropagation();
7123 this.options.onClick();
7124 }.bind(this)
7125 );
7126 }
7127
7128 // Adding offset
7129 if(typeof this.options.offset === "object") {
7130
7131 var x = getAxisOffsetAValue("x", this.options);
7132 var y = getAxisOffsetAValue("y", this.options);
7133
7134 var xOffset = this.options.position == "left" ? x : "-" + x;
7135 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7136
7137 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7138
7139 }
7140
7141 // Returning the generated element
7142 return divElement;
7143 },
7144
7145 // Displaying the toast
7146 showToast: function() {
7147 // Creating the DOM object for the toast
7148 this.toastElement = this.buildToast();
7149
7150 // Getting the root element to with the toast needs to be added
7151 var rootElement;
7152 if (typeof this.options.selector === "string") {
7153 rootElement = document.getElementById(this.options.selector);
7154 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7155 rootElement = this.options.selector;
7156 } else {
7157 rootElement = document.body;
7158 }
7159
7160 // Validating if root element is present in DOM
7161 if (!rootElement) {
7162 throw "Root element is not defined";
7163 }
7164
7165 // Adding the DOM element
7166 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7167 rootElement.insertBefore(this.toastElement, elementToInsert);
7168
7169 // Repositioning the toasts in case multiple toasts are present
7170 Toastify.reposition();
7171
7172 if (this.options.duration > 0) {
7173 this.toastElement.timeOutValue = window.setTimeout(
7174 function() {
7175 // Remove the toast from DOM
7176 this.removeElement(this.toastElement);
7177 }.bind(this),
7178 this.options.duration
7179 ); // Binding `this` for function invocation
7180 }
7181
7182 // Supporting function chaining
7183 return this;
7184 },
7185
7186 hideToast: function() {
7187 if (this.toastElement.timeOutValue) {
7188 clearTimeout(this.toastElement.timeOutValue);
7189 }
7190 this.removeElement(this.toastElement);
7191 },
7192
7193 // Removing the element from the DOM
7194 removeElement: function(toastElement) {
7195 // Hiding the element
7196 // toastElement.classList.remove("on");
7197 toastElement.className = toastElement.className.replace(" on", "");
7198
7199 // Removing the element from DOM after transition end
7200 window.setTimeout(
7201 function() {
7202 // remove options node if any
7203 if (this.options.node && this.options.node.parentNode) {
7204 this.options.node.parentNode.removeChild(this.options.node);
7205 }
7206
7207 // Remove the element from the DOM, only when the parent node was not removed before.
7208 if (toastElement.parentNode) {
7209 toastElement.parentNode.removeChild(toastElement);
7210 }
7211
7212 // Calling the callback function
7213 this.options.callback.call(toastElement);
7214
7215 // Repositioning the toasts again
7216 Toastify.reposition();
7217 }.bind(this),
7218 400
7219 ); // Binding `this` for function invocation
7220 },
7221 };
7222
7223 // Positioning the toasts on the DOM
7224 Toastify.reposition = function() {
7225
7226 // Top margins with gravity
7227 var topLeftOffsetSize = {
7228 top: 15,
7229 bottom: 15,
7230 };
7231 var topRightOffsetSize = {
7232 top: 15,
7233 bottom: 15,
7234 };
7235 var offsetSize = {
7236 top: 15,
7237 bottom: 15,
7238 };
7239
7240 // Get all toast messages on the DOM
7241 var allToasts = document.getElementsByClassName("toastify");
7242
7243 var classUsed;
7244
7245 // Modifying the position of each toast element
7246 for (var i = 0; i < allToasts.length; i++) {
7247 // Getting the applied gravity
7248 if (containsClass(allToasts[i], "toastify-top") === true) {
7249 classUsed = "toastify-top";
7250 } else {
7251 classUsed = "toastify-bottom";
7252 }
7253
7254 var height = allToasts[i].offsetHeight;
7255 classUsed = classUsed.substr(9, classUsed.length-1)
7256 // Spacing between toasts
7257 var offset = 15;
7258
7259 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7260
7261 // Show toast in center if screen with less than or equal to 360px
7262 if (width <= 360) {
7263 // Setting the position
7264 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7265
7266 offsetSize[classUsed] += height + offset;
7267 } else {
7268 if (containsClass(allToasts[i], "toastify-left") === true) {
7269 // Setting the position
7270 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7271
7272 topLeftOffsetSize[classUsed] += height + offset;
7273 } else {
7274 // Setting the position
7275 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7276
7277 topRightOffsetSize[classUsed] += height + offset;
7278 }
7279 }
7280 }
7281
7282 // Supporting function chaining
7283 return this;
7284 };
7285
7286 // Helper function to get offset.
7287 function getAxisOffsetAValue(axis, options) {
7288
7289 if(options.offset[axis]) {
7290 if(isNaN(options.offset[axis])) {
7291 return options.offset[axis];
7292 }
7293 else {
7294 return options.offset[axis] + 'px';
7295 }
7296 }
7297
7298 return '0px';
7299
7300 }
7301
7302 function containsClass(elem, yourClass) {
7303 if (!elem || typeof yourClass !== "string") {
7304 return false;
7305 } else if (
7306 elem.className &&
7307 elem.className
7308 .trim()
7309 .split(/\s+/gi)
7310 .indexOf(yourClass) > -1
7311 ) {
7312 return true;
7313 } else {
7314 return false;
7315 }
7316 }
7317
7318 // Setting up the prototype for the init object
7319 Toastify.lib.init.prototype = Toastify.lib;
7320
7321 // Returning the Toastify function to be assigned to the window object/module
7322 return Toastify;
7323 });
7324
7325
7326 /***/ },
7327
7328 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7329 /*!**********************************************************!*\
7330 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7331 \**********************************************************/
7332 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7333
7334 "use strict";
7335 __webpack_require__.r(__webpack_exports__);
7336 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7337 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7338 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7339 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7340 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7341 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7342 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7343 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7344 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7345 /* harmony export */ });
7346 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7347 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7348 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7349 /**
7350 * sifter.js
7351 * Copyright (c) 2013–2020 Brian Reavis & contributors
7352 *
7353 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7354 * file except in compliance with the License. You may obtain a copy of the License at:
7355 * http://www.apache.org/licenses/LICENSE-2.0
7356 *
7357 * Unless required by applicable law or agreed to in writing, software distributed under
7358 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7359 * ANY KIND, either express or implied. See the License for the specific language
7360 * governing permissions and limitations under the License.
7361 *
7362 * @author Brian Reavis <brian@thirdroute.com>
7363 */
7364
7365
7366 class Sifter {
7367 items; // []|{};
7368 settings;
7369 /**
7370 * Textually searches arrays and hashes of objects
7371 * by property (or multiple properties). Designed
7372 * specifically for autocomplete.
7373 *
7374 */
7375 constructor(items, settings) {
7376 this.items = items;
7377 this.settings = settings || { diacritics: true };
7378 }
7379 ;
7380 /**
7381 * Splits a search string into an array of individual
7382 * regexps to be used to match results.
7383 *
7384 */
7385 tokenize(query, respect_word_boundaries, weights) {
7386 if (!query || !query.length)
7387 return [];
7388 const tokens = [];
7389 const words = query.split(/\s+/);
7390 var field_regex;
7391 if (weights) {
7392 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7393 }
7394 words.forEach((word) => {
7395 let field_match;
7396 let field = null;
7397 let regex = null;
7398 // look for "field:query" tokens
7399 if (field_regex && (field_match = word.match(field_regex))) {
7400 field = field_match[1];
7401 word = field_match[2];
7402 }
7403 if (word.length > 0) {
7404 if (this.settings.diacritics) {
7405 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7406 }
7407 else {
7408 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7409 }
7410 if (regex && respect_word_boundaries)
7411 regex = "\\b" + regex;
7412 }
7413 tokens.push({
7414 string: word,
7415 regex: regex ? new RegExp(regex, 'iu') : null,
7416 field: field,
7417 });
7418 });
7419 return tokens;
7420 }
7421 ;
7422 /**
7423 * Returns a function to be used to score individual results.
7424 *
7425 * Good matches will have a higher score than poor matches.
7426 * If an item is not a match, 0 will be returned by the function.
7427 *
7428 * @returns {T.ScoreFn}
7429 */
7430 getScoreFunction(query, options) {
7431 var search = this.prepareSearch(query, options);
7432 return this._getScoreFunction(search);
7433 }
7434 /**
7435 * @returns {T.ScoreFn}
7436 *
7437 */
7438 _getScoreFunction(search) {
7439 const tokens = search.tokens, token_count = tokens.length;
7440 if (!token_count) {
7441 return function () { return 0; };
7442 }
7443 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7444 if (!field_count) {
7445 return function () { return 1; };
7446 }
7447 /**
7448 * Calculates the score of an object
7449 * against the search query.
7450 *
7451 */
7452 const scoreObject = (function () {
7453 if (field_count === 1) {
7454 return function (token, data) {
7455 const field = fields[0].field;
7456 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7457 };
7458 }
7459 return function (token, data) {
7460 var sum = 0;
7461 // is the token specific to a field?
7462 if (token.field) {
7463 const value = getAttrFn(data, token.field);
7464 if (!token.regex && value) {
7465 sum += (1 / field_count);
7466 }
7467 else {
7468 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7469 }
7470 }
7471 else {
7472 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7473 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7474 });
7475 }
7476 return sum / field_count;
7477 };
7478 })();
7479 if (token_count === 1) {
7480 return function (data) {
7481 return scoreObject(tokens[0], data);
7482 };
7483 }
7484 if (search.options.conjunction === 'and') {
7485 return function (data) {
7486 var score, sum = 0;
7487 for (let token of tokens) {
7488 score = scoreObject(token, data);
7489 if (score <= 0)
7490 return 0;
7491 sum += score;
7492 }
7493 return sum / token_count;
7494 };
7495 }
7496 else {
7497 return function (data) {
7498 var sum = 0;
7499 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7500 sum += scoreObject(token, data);
7501 });
7502 return sum / token_count;
7503 };
7504 }
7505 }
7506 ;
7507 /**
7508 * Returns a function that can be used to compare two
7509 * results, for sorting purposes. If no sorting should
7510 * be performed, `null` will be returned.
7511 *
7512 * @return function(a,b)
7513 */
7514 getSortFunction(query, options) {
7515 var search = this.prepareSearch(query, options);
7516 return this._getSortFunction(search);
7517 }
7518 _getSortFunction(search) {
7519 var implicit_score, sort_flds = [];
7520 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
7521 if (typeof sort == 'function') {
7522 return sort.bind(this);
7523 }
7524 /**
7525 * Fetches the specified sort field value
7526 * from a search result item.
7527 *
7528 */
7529 const get_field = function (name, result) {
7530 if (name === '$score')
7531 return result.score;
7532 return search.getAttrFn(self.items[result.id], name);
7533 };
7534 // parse options
7535 if (sort) {
7536 for (let s of sort) {
7537 if (search.query || s.field !== '$score') {
7538 sort_flds.push(s);
7539 }
7540 }
7541 }
7542 // the "$score" field is implied to be the primary
7543 // sort field, unless it's manually specified
7544 if (search.query) {
7545 implicit_score = true;
7546 for (let fld of sort_flds) {
7547 if (fld.field === '$score') {
7548 implicit_score = false;
7549 break;
7550 }
7551 }
7552 if (implicit_score) {
7553 sort_flds.unshift({ field: '$score', direction: 'desc' });
7554 }
7555 // without a search.query, all items will have the same score
7556 }
7557 else {
7558 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
7559 }
7560 // build function
7561 const sort_flds_count = sort_flds.length;
7562 if (!sort_flds_count) {
7563 return null;
7564 }
7565 return function (a, b) {
7566 var result, field;
7567 for (let sort_fld of sort_flds) {
7568 field = sort_fld.field;
7569 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
7570 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
7571 if (result)
7572 return result;
7573 }
7574 return 0;
7575 };
7576 }
7577 ;
7578 /**
7579 * Parses a search query and returns an object
7580 * with tokens and fields ready to be populated
7581 * with results.
7582 *
7583 */
7584 prepareSearch(query, optsUser) {
7585 const weights = {};
7586 var options = Object.assign({}, optsUser);
7587 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
7588 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
7589 // convert fields to new format
7590 if (options.fields) {
7591 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
7592 const fields = [];
7593 options.fields.forEach((field) => {
7594 if (typeof field == 'string') {
7595 field = { field: field, weight: 1 };
7596 }
7597 fields.push(field);
7598 weights[field.field] = ('weight' in field) ? field.weight : 1;
7599 });
7600 options.fields = fields;
7601 }
7602 return {
7603 options: options,
7604 query: query.toLowerCase().trim(),
7605 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
7606 total: 0,
7607 items: [],
7608 weights: weights,
7609 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
7610 };
7611 }
7612 ;
7613 /**
7614 * Searches through all items and returns a sorted array of matches.
7615 *
7616 */
7617 search(query, options) {
7618 var self = this, score, search;
7619 search = this.prepareSearch(query, options);
7620 options = search.options;
7621 query = search.query;
7622 // generate result scoring function
7623 const fn_score = options.score || self._getScoreFunction(search);
7624 // perform search and sort
7625 if (query.length) {
7626 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
7627 score = fn_score(item);
7628 if (options.filter === false || score > 0) {
7629 search.items.push({ 'score': score, 'id': id });
7630 }
7631 });
7632 }
7633 else {
7634 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
7635 search.items.push({ 'score': 1, 'id': id });
7636 });
7637 }
7638 const fn_sort = self._getSortFunction(search);
7639 if (fn_sort)
7640 search.items.sort(fn_sort);
7641 // apply limits
7642 search.total = search.items.length;
7643 if (typeof options.limit === 'number') {
7644 search.items = search.items.slice(0, options.limit);
7645 }
7646 return search;
7647 }
7648 ;
7649 }
7650
7651
7652 //# sourceMappingURL=sifter.js.map
7653
7654 /***/ },
7655
7656 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
7657 /*!*********************************************************!*\
7658 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
7659 \*********************************************************/
7660 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7661
7662 "use strict";
7663 __webpack_require__.r(__webpack_exports__);
7664
7665 //# sourceMappingURL=types.js.map
7666
7667 /***/ },
7668
7669 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
7670 /*!*********************************************************!*\
7671 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
7672 \*********************************************************/
7673 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7674
7675 "use strict";
7676 __webpack_require__.r(__webpack_exports__);
7677 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7678 /* harmony export */ cmp: () => (/* binding */ cmp),
7679 /* harmony export */ getAttr: () => (/* binding */ getAttr),
7680 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
7681 /* harmony export */ iterate: () => (/* binding */ iterate),
7682 /* harmony export */ propToArray: () => (/* binding */ propToArray),
7683 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
7684 /* harmony export */ });
7685 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7686
7687 /**
7688 * A property getter resolving dot-notation
7689 * @param {Object} obj The root object to fetch property on
7690 * @param {String} name The optionally dotted property name to fetch
7691 * @return {Object} The resolved property value
7692 */
7693 const getAttr = (obj, name) => {
7694 if (!obj)
7695 return;
7696 return obj[name];
7697 };
7698 /**
7699 * A property getter resolving dot-notation
7700 * @param {Object} obj The root object to fetch property on
7701 * @param {String} name The optionally dotted property name to fetch
7702 * @return {Object} The resolved property value
7703 */
7704 const getAttrNesting = (obj, name) => {
7705 if (!obj)
7706 return;
7707 var part, names = name.split(".");
7708 while ((part = names.shift()) && (obj = obj[part]))
7709 ;
7710 return obj;
7711 };
7712 /**
7713 * Calculates how close of a match the
7714 * given value is against a search token.
7715 *
7716 */
7717 const scoreValue = (value, token, weight) => {
7718 var score, pos;
7719 if (!value)
7720 return 0;
7721 value = value + '';
7722 if (token.regex == null)
7723 return 0;
7724 pos = value.search(token.regex);
7725 if (pos === -1)
7726 return 0;
7727 score = token.string.length / value.length;
7728 if (pos === 0)
7729 score += 0.5;
7730 return score * weight;
7731 };
7732 /**
7733 * Cast object property to an array if it exists and has a value
7734 *
7735 */
7736 const propToArray = (obj, key) => {
7737 var value = obj[key];
7738 if (typeof value == 'function')
7739 return value;
7740 if (value && !Array.isArray(value)) {
7741 obj[key] = [value];
7742 }
7743 };
7744 /**
7745 * Iterates over arrays and hashes.
7746 *
7747 * ```
7748 * iterate(this.items, function(item, id) {
7749 * // invoked for each item
7750 * });
7751 * ```
7752 *
7753 */
7754 const iterate = (object, callback) => {
7755 if (Array.isArray(object)) {
7756 object.forEach(callback);
7757 }
7758 else {
7759 for (var key in object) {
7760 if (object.hasOwnProperty(key)) {
7761 callback(object[key], key);
7762 }
7763 }
7764 }
7765 };
7766 const cmp = (a, b) => {
7767 if (typeof a === 'number' && typeof b === 'number') {
7768 return a > b ? 1 : (a < b ? -1 : 0);
7769 }
7770 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
7771 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
7772 if (a > b)
7773 return 1;
7774 if (b > a)
7775 return -1;
7776 return 0;
7777 };
7778 //# sourceMappingURL=utils.js.map
7779
7780 /***/ },
7781
7782 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
7783 /*!*******************************************************************!*\
7784 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
7785 \*******************************************************************/
7786 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7787
7788 "use strict";
7789 __webpack_require__.r(__webpack_exports__);
7790 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7791 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
7792 /* harmony export */ asciifold: () => (/* binding */ asciifold),
7793 /* harmony export */ code_points: () => (/* binding */ code_points),
7794 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
7795 /* harmony export */ generateMap: () => (/* binding */ generateMap),
7796 /* harmony export */ generateSets: () => (/* binding */ generateSets),
7797 /* harmony export */ generator: () => (/* binding */ generator),
7798 /* harmony export */ getPattern: () => (/* binding */ getPattern),
7799 /* harmony export */ initialize: () => (/* binding */ initialize),
7800 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
7801 /* harmony export */ normalize: () => (/* binding */ normalize),
7802 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
7803 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
7804 /* harmony export */ });
7805 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
7806 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
7807
7808
7809 const code_points = [[0, 65535]];
7810 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
7811 let unicode_map;
7812 let multi_char_reg;
7813 const max_char_length = 3;
7814 const latin_convert = {};
7815 const latin_condensed = {
7816 '/': '⁄∕',
7817 '0': '߀',
7818 "a": "ⱥɐɑ",
7819 "aa": "ꜳ",
7820 "ae": "æǽǣ",
7821 "ao": "ꜵ",
7822 "au": "ꜷ",
7823 "av": "ꜹꜻ",
7824 "ay": "ꜽ",
7825 "b": "ƀɓƃ",
7826 "c": "ꜿƈȼↄ",
7827 "d": "đɗɖᴅƌꮷԁɦ",
7828 "e": "ɛǝᴇɇ",
7829 "f": "ꝼƒ",
7830 "g": "ǥɠꞡᵹꝿɢ",
7831 "h": "ħⱨⱶɥ",
7832 "i": "ɨı",
7833 "j": "ɉȷ",
7834 "k": "ƙⱪꝁꝃꝅꞣ",
7835 "l": "łƚɫⱡꝉꝇꞁɭ",
7836 "m": "ɱɯϻ",
7837 "n": "ꞥƞɲꞑᴎлԉ",
7838 "o": "øǿɔɵꝋꝍᴑ",
7839 "oe": "œ",
7840 "oi": "ƣ",
7841 "oo": "ꝏ",
7842 "ou": "ȣ",
7843 "p": "ƥᵽꝑꝓꝕρ",
7844 "q": "ꝗꝙɋ",
7845 "r": "ɍɽꝛꞧꞃ",
7846 "s": "ßȿꞩꞅʂ",
7847 "t": "ŧƭʈⱦꞇ",
7848 "th": "þ",
7849 "tz": "ꜩ",
7850 "u": "ʉ",
7851 "v": "ʋꝟʌ",
7852 "vy": "ꝡ",
7853 "w": "ⱳ",
7854 "y": "ƴɏỿ",
7855 "z": "ƶȥɀⱬꝣ",
7856 "hv": "ƕ"
7857 };
7858 for (let latin in latin_condensed) {
7859 let unicode = latin_condensed[latin] || '';
7860 for (let i = 0; i < unicode.length; i++) {
7861 let char = unicode.substring(i, i + 1);
7862 latin_convert[char] = latin;
7863 }
7864 }
7865 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
7866 /**
7867 * Initialize the unicode_map from the give code point ranges
7868 */
7869 const initialize = (_code_points) => {
7870 if (unicode_map !== undefined)
7871 return;
7872 unicode_map = generateMap(_code_points || code_points);
7873 };
7874 /**
7875 * Helper method for normalize a string
7876 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
7877 */
7878 const normalize = (str, form = 'NFKD') => str.normalize(form);
7879 /**
7880 * Remove accents without reordering string
7881 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
7882 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
7883 */
7884 const asciifold = (str) => {
7885 return Array.from(str).reduce(
7886 /**
7887 * @param {string} result
7888 * @param {string} char
7889 */
7890 (result, char) => {
7891 return result + _asciifold(char);
7892 }, '');
7893 };
7894 const _asciifold = (str) => {
7895 str = normalize(str)
7896 .toLowerCase()
7897 .replace(convert_pat, (/** @type {string} */ char) => {
7898 return latin_convert[char] || '';
7899 });
7900 //return str;
7901 return normalize(str, 'NFC');
7902 };
7903 /**
7904 * Generate a list of unicode variants from the list of code points
7905 */
7906 function* generator(code_points) {
7907 for (const [code_point_min, code_point_max] of code_points) {
7908 for (let i = code_point_min; i <= code_point_max; i++) {
7909 let composed = String.fromCharCode(i);
7910 let folded = asciifold(composed);
7911 if (folded == composed.toLowerCase()) {
7912 continue;
7913 }
7914 // skip when folded is a string longer than 3 characters long
7915 // bc the resulting regex patterns will be long
7916 // eg:
7917 // folded صلى الله عليه وسلم length 18 code point 65018
7918 // folded جل جلاله length 8 code point 65019
7919 if (folded.length > max_char_length) {
7920 continue;
7921 }
7922 if (folded.length == 0) {
7923 continue;
7924 }
7925 yield { folded: folded, composed: composed, code_point: i };
7926 }
7927 }
7928 }
7929 /**
7930 * Generate a unicode map from the list of code points
7931 */
7932 const generateSets = (code_points) => {
7933 const unicode_sets = {};
7934 const addMatching = (folded, to_add) => {
7935 /** @type {Set<string>} */
7936 const folded_set = unicode_sets[folded] || new Set();
7937 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
7938 if (to_add.match(patt)) {
7939 return;
7940 }
7941 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
7942 unicode_sets[folded] = folded_set;
7943 };
7944 for (let value of generator(code_points)) {
7945 addMatching(value.folded, value.folded);
7946 addMatching(value.folded, value.composed);
7947 }
7948 return unicode_sets;
7949 };
7950 /**
7951 * Generate a unicode map from the list of code points
7952 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
7953 */
7954 const generateMap = (code_points) => {
7955 const unicode_sets = generateSets(code_points);
7956 const unicode_map = {};
7957 let multi_char = [];
7958 for (let folded in unicode_sets) {
7959 let set = unicode_sets[folded];
7960 if (set) {
7961 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
7962 }
7963 if (folded.length > 1) {
7964 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
7965 }
7966 }
7967 multi_char.sort((a, b) => b.length - a.length);
7968 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
7969 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
7970 return unicode_map;
7971 };
7972 /**
7973 * Map each element of an array from its folded value to all possible unicode matches
7974 */
7975 const mapSequence = (strings, min_replacement = 1) => {
7976 let chars_replaced = 0;
7977 strings = strings.map((str) => {
7978 if (unicode_map[str]) {
7979 chars_replaced += str.length;
7980 }
7981 return unicode_map[str] || str;
7982 });
7983 if (chars_replaced >= min_replacement) {
7984 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
7985 }
7986 return '';
7987 };
7988 /**
7989 * Convert a short string and split it into all possible patterns
7990 * Keep a pattern only if min_replacement is met
7991 *
7992 * 'abc'
7993 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
7994 * => ['abc-pattern','ab-c-pattern'...]
7995 */
7996 const substringsToPattern = (str, min_replacement = 1) => {
7997 min_replacement = Math.max(min_replacement, str.length - 1);
7998 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
7999 return mapSequence(sub_pat, min_replacement);
8000 }));
8001 };
8002 /**
8003 * Convert an array of sequences into a pattern
8004 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
8005 */
8006 const sequencesToPattern = (sequences, all = true) => {
8007 let min_replacement = sequences.length > 1 ? 1 : 0;
8008 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
8009 let seq = [];
8010 const len = all ? sequence.length() : sequence.length() - 1;
8011 for (let j = 0; j < len; j++) {
8012 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
8013 }
8014 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
8015 }));
8016 };
8017 /**
8018 * Return true if the sequence is already in the sequences
8019 */
8020 const inSequences = (needle_seq, sequences) => {
8021 for (const seq of sequences) {
8022 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
8023 continue;
8024 }
8025 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
8026 continue;
8027 }
8028 let needle_parts = needle_seq.parts;
8029 const filter = (part) => {
8030 for (const needle_part of needle_parts) {
8031 if (needle_part.start === part.start && needle_part.substr === part.substr) {
8032 return false;
8033 }
8034 if (part.length == 1 || needle_part.length == 1) {
8035 continue;
8036 }
8037 // check for overlapping parts
8038 // a = ['::=','==']
8039 // b = ['::','===']
8040 // a = ['r','sm']
8041 // b = ['rs','m']
8042 if (part.start < needle_part.start && part.end > needle_part.start) {
8043 return true;
8044 }
8045 if (needle_part.start < part.start && needle_part.end > part.start) {
8046 return true;
8047 }
8048 }
8049 return false;
8050 };
8051 let filtered = seq.parts.filter(filter);
8052 if (filtered.length > 0) {
8053 continue;
8054 }
8055 return true;
8056 }
8057 return false;
8058 };
8059 class Sequence {
8060 parts;
8061 substrs;
8062 start;
8063 end;
8064 constructor() {
8065 this.parts = [];
8066 this.substrs = [];
8067 this.start = 0;
8068 this.end = 0;
8069 }
8070 add(part) {
8071 if (part) {
8072 this.parts.push(part);
8073 this.substrs.push(part.substr);
8074 this.start = Math.min(part.start, this.start);
8075 this.end = Math.max(part.end, this.end);
8076 }
8077 }
8078 last() {
8079 return this.parts[this.parts.length - 1];
8080 }
8081 length() {
8082 return this.parts.length;
8083 }
8084 clone(position, last_piece) {
8085 let clone = new Sequence();
8086 let parts = JSON.parse(JSON.stringify(this.parts));
8087 let last_part = parts.pop();
8088 for (const part of parts) {
8089 clone.add(part);
8090 }
8091 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8092 let clone_last_len = last_substr.length;
8093 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8094 return clone;
8095 }
8096 }
8097 /**
8098 * Expand a regular expression pattern to include unicode variants
8099 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8100 *
8101 * Issue:
8102 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8103 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8104 *
8105 * İIJ = IIJ = ⅡJ
8106 *
8107 * 1/2/4
8108 */
8109 const getPattern = (str) => {
8110 initialize();
8111 str = asciifold(str);
8112 let pattern = '';
8113 let sequences = [new Sequence()];
8114 for (let i = 0; i < str.length; i++) {
8115 let substr = str.substring(i);
8116 let match = substr.match(multi_char_reg);
8117 const char = str.substring(i, i + 1);
8118 const match_str = match ? match[0] : null;
8119 // loop through sequences
8120 // add either the char or multi_match
8121 let overlapping = [];
8122 let added_types = new Set();
8123 for (const sequence of sequences) {
8124 const last_piece = sequence.last();
8125 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8126 // if we have a multi match
8127 if (match_str) {
8128 const len = match_str.length;
8129 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8130 added_types.add('1');
8131 }
8132 else {
8133 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8134 added_types.add('2');
8135 }
8136 }
8137 else if (match_str) {
8138 let clone = sequence.clone(i, last_piece);
8139 const len = match_str.length;
8140 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8141 overlapping.push(clone);
8142 }
8143 else {
8144 // don't add char
8145 // adding would create invalid patterns: 234 => [2,34,4]
8146 added_types.add('3');
8147 }
8148 }
8149 // if we have overlapping
8150 if (overlapping.length > 0) {
8151 // ['ii','iii'] before ['i','i','iii']
8152 overlapping = overlapping.sort((a, b) => {
8153 return a.length() - b.length();
8154 });
8155 for (let clone of overlapping) {
8156 // don't add if we already have an equivalent sequence
8157 if (inSequences(clone, sequences)) {
8158 continue;
8159 }
8160 sequences.push(clone);
8161 }
8162 continue;
8163 }
8164 // if we haven't done anything unique
8165 // clean up the patterns
8166 // helps keep patterns smaller
8167 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8168 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8169 pattern += sequencesToPattern(sequences, false);
8170 let new_seq = new Sequence();
8171 const old_seq = sequences[0];
8172 if (old_seq) {
8173 new_seq.add(old_seq.last());
8174 }
8175 sequences = [new_seq];
8176 }
8177 }
8178 pattern += sequencesToPattern(sequences, true);
8179 return pattern;
8180 };
8181
8182 //# sourceMappingURL=index.js.map
8183
8184 /***/ },
8185
8186 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8187 /*!*******************************************************************!*\
8188 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8189 \*******************************************************************/
8190 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8191
8192 "use strict";
8193 __webpack_require__.r(__webpack_exports__);
8194 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8195 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8196 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8197 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8198 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8199 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8200 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8201 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8202 /* harmony export */ });
8203 /**
8204 * Convert array of strings to a regular expression
8205 * ex ['ab','a'] => (?:ab|a)
8206 * ex ['a','b'] => [ab]
8207 */
8208 const arrayToPattern = (chars) => {
8209 chars = chars.filter(Boolean);
8210 if (chars.length < 2) {
8211 return chars[0] || '';
8212 }
8213 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8214 };
8215 const sequencePattern = (array) => {
8216 if (!hasDuplicates(array)) {
8217 return array.join('');
8218 }
8219 let pattern = '';
8220 let prev_char_count = 0;
8221 const prev_pattern = () => {
8222 if (prev_char_count > 1) {
8223 pattern += '{' + prev_char_count + '}';
8224 }
8225 };
8226 array.forEach((char, i) => {
8227 if (char === array[i - 1]) {
8228 prev_char_count++;
8229 return;
8230 }
8231 prev_pattern();
8232 pattern += char;
8233 prev_char_count = 1;
8234 });
8235 prev_pattern();
8236 return pattern;
8237 };
8238 /**
8239 * Convert array of strings to a regular expression
8240 * ex ['ab','a'] => (?:ab|a)
8241 * ex ['a','b'] => [ab]
8242 */
8243 const setToPattern = (chars) => {
8244 let array = Array.from(chars);
8245 return arrayToPattern(array);
8246 };
8247 /**
8248 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8249 */
8250 const hasDuplicates = (array) => {
8251 return (new Set(array)).size !== array.length;
8252 };
8253 /**
8254 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8255 */
8256 const escape_regex = (str) => {
8257 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8258 };
8259 /**
8260 * Return the max length of array values
8261 */
8262 const maxValueLength = (array) => {
8263 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8264 };
8265 const unicodeLength = (str) => {
8266 return Array.from(str).length;
8267 };
8268 //# sourceMappingURL=regex.js.map
8269
8270 /***/ },
8271
8272 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8273 /*!*********************************************************************!*\
8274 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8275 \*********************************************************************/
8276 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8277
8278 "use strict";
8279 __webpack_require__.r(__webpack_exports__);
8280 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8281 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8282 /* harmony export */ });
8283 /**
8284 * Get all possible combinations of substrings that add up to the given string
8285 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8286 */
8287 const allSubstrings = (input) => {
8288 if (input.length === 1)
8289 return [[input]];
8290 let result = [];
8291 const start = input.substring(1);
8292 const suba = allSubstrings(start);
8293 suba.forEach(function (subresult) {
8294 let tmp = subresult.slice(0);
8295 tmp[0] = input.charAt(0) + tmp[0];
8296 result.push(tmp);
8297 tmp = subresult.slice(0);
8298 tmp.unshift(input.charAt(0));
8299 result.push(tmp);
8300 });
8301 return result;
8302 };
8303 //# sourceMappingURL=strings.js.map
8304
8305 /***/ },
8306
8307 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8308 /*!*******************************************************!*\
8309 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8310 \*******************************************************/
8311 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8312
8313 "use strict";
8314 __webpack_require__.r(__webpack_exports__);
8315 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8316 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8317 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8318 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8319 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8320 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8321 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8322 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8323 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8324 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8325 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8326 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8327 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8328 /* harmony export */ });
8329 const KEY_A = 65;
8330 const KEY_RETURN = 13;
8331 const KEY_ESC = 27;
8332 const KEY_LEFT = 37;
8333 const KEY_UP = 38;
8334 const KEY_RIGHT = 39;
8335 const KEY_DOWN = 40;
8336 const KEY_BACKSPACE = 8;
8337 const KEY_DELETE = 46;
8338 const KEY_TAB = 9;
8339 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8340 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8341 //# sourceMappingURL=constants.js.map
8342
8343 /***/ },
8344
8345 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8346 /*!***************************************************************!*\
8347 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8348 \***************************************************************/
8349 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8350
8351 "use strict";
8352 __webpack_require__.r(__webpack_exports__);
8353 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8354 /* harmony export */ highlight: () => (/* binding */ highlight),
8355 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8356 /* harmony export */ });
8357 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8358 /**
8359 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
8360 * Highlights arbitrary terms in a node.
8361 *
8362 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
8363 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
8364 */
8365
8366 const highlight = (element, regex) => {
8367 if (regex === null)
8368 return;
8369 // convet string to regex
8370 if (typeof regex === 'string') {
8371 if (!regex.length)
8372 return;
8373 regex = new RegExp(regex, 'i');
8374 }
8375 // Wrap matching part of text node with highlighting <span>, e.g.
8376 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8377 const highlightText = (node) => {
8378 var match = node.data.match(regex);
8379 if (match && node.data.length > 0) {
8380 var spannode = document.createElement('span');
8381 spannode.className = 'highlight';
8382 var middlebit = node.splitText(match.index);
8383 middlebit.splitText(match[0].length);
8384 var middleclone = middlebit.cloneNode(true);
8385 spannode.appendChild(middleclone);
8386 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8387 return 1;
8388 }
8389 return 0;
8390 };
8391 // Recurse element node, looking for child text nodes to highlight, unless element
8392 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8393 const highlightChildren = (node) => {
8394 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8395 Array.from(node.childNodes).forEach(element => {
8396 highlightRecursive(element);
8397 });
8398 }
8399 };
8400 const highlightRecursive = (node) => {
8401 if (node.nodeType === 3) {
8402 return highlightText(node);
8403 }
8404 highlightChildren(node);
8405 return 0;
8406 };
8407 highlightRecursive(element);
8408 };
8409 /**
8410 * removeHighlight fn copied from highlight v5 and
8411 * edited to remove with(), pass js strict mode, and use without jquery
8412 */
8413 const removeHighlight = (el) => {
8414 var elements = el.querySelectorAll("span.highlight");
8415 Array.prototype.forEach.call(elements, function (el) {
8416 var parent = el.parentNode;
8417 parent.replaceChild(el.firstChild, el);
8418 parent.normalize();
8419 });
8420 };
8421 //# sourceMappingURL=highlight.js.map
8422
8423 /***/ },
8424
8425 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8426 /*!****************************************************************!*\
8427 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8428 \****************************************************************/
8429 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8430
8431 "use strict";
8432 __webpack_require__.r(__webpack_exports__);
8433 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8434 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8435 /* harmony export */ });
8436 /**
8437 * MicroEvent - to make any js object an event emitter
8438 *
8439 * - pure javascript - server compatible, browser compatible
8440 * - dont rely on the browser doms
8441 * - super simple - you get it immediatly, no mistery, no magic involved
8442 *
8443 * @author Jerome Etienne (https://github.com/jeromeetienne)
8444 */
8445 /**
8446 * Execute callback for each event in space separated list of event names
8447 *
8448 */
8449 function forEvents(events, callback) {
8450 events.split(/\s+/).forEach((event) => {
8451 callback(event);
8452 });
8453 }
8454 class MicroEvent {
8455 constructor() {
8456 this._events = {};
8457 }
8458 on(events, fct) {
8459 forEvents(events, (event) => {
8460 const event_array = this._events[event] || [];
8461 event_array.push(fct);
8462 this._events[event] = event_array;
8463 });
8464 }
8465 off(events, fct) {
8466 var n = arguments.length;
8467 if (n === 0) {
8468 this._events = {};
8469 return;
8470 }
8471 forEvents(events, (event) => {
8472 if (n === 1) {
8473 delete this._events[event];
8474 return;
8475 }
8476 const event_array = this._events[event];
8477 if (event_array === undefined)
8478 return;
8479 event_array.splice(event_array.indexOf(fct), 1);
8480 this._events[event] = event_array;
8481 });
8482 }
8483 trigger(events, ...args) {
8484 var self = this;
8485 forEvents(events, (event) => {
8486 const event_array = self._events[event];
8487 if (event_array === undefined)
8488 return;
8489 event_array.forEach(fct => {
8490 fct.apply(self, args);
8491 });
8492 });
8493 }
8494 }
8495 ;
8496 //# sourceMappingURL=microevent.js.map
8497
8498 /***/ },
8499
8500 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
8501 /*!*****************************************************************!*\
8502 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
8503 \*****************************************************************/
8504 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8505
8506 "use strict";
8507 __webpack_require__.r(__webpack_exports__);
8508 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8509 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
8510 /* harmony export */ });
8511 /**
8512 * microplugin.js
8513 * Copyright (c) 2013 Brian Reavis & contributors
8514 *
8515 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8516 * file except in compliance with the License. You may obtain a copy of the License at:
8517 * http://www.apache.org/licenses/LICENSE-2.0
8518 *
8519 * Unless required by applicable law or agreed to in writing, software distributed under
8520 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8521 * ANY KIND, either express or implied. See the License for the specific language
8522 * governing permissions and limitations under the License.
8523 *
8524 * @author Brian Reavis <brian@thirdroute.com>
8525 */
8526 function MicroPlugin(Interface) {
8527 Interface.plugins = {};
8528 return class extends Interface {
8529 constructor() {
8530 super(...arguments);
8531 this.plugins = {
8532 names: [],
8533 settings: {},
8534 requested: {},
8535 loaded: {}
8536 };
8537 }
8538 /**
8539 * Registers a plugin.
8540 *
8541 * @param {function} fn
8542 */
8543 static define(name, fn) {
8544 Interface.plugins[name] = {
8545 'name': name,
8546 'fn': fn
8547 };
8548 }
8549 /**
8550 * Initializes the listed plugins (with options).
8551 * Acceptable formats:
8552 *
8553 * List (without options):
8554 * ['a', 'b', 'c']
8555 *
8556 * List (with options):
8557 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
8558 *
8559 * Hash (with options):
8560 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
8561 *
8562 * @param {array|object} plugins
8563 */
8564 initializePlugins(plugins) {
8565 var key, name;
8566 const self = this;
8567 const queue = [];
8568 if (Array.isArray(plugins)) {
8569 plugins.forEach((plugin) => {
8570 if (typeof plugin === 'string') {
8571 queue.push(plugin);
8572 }
8573 else {
8574 self.plugins.settings[plugin.name] = plugin.options;
8575 queue.push(plugin.name);
8576 }
8577 });
8578 }
8579 else if (plugins) {
8580 for (key in plugins) {
8581 if (plugins.hasOwnProperty(key)) {
8582 self.plugins.settings[key] = plugins[key];
8583 queue.push(key);
8584 }
8585 }
8586 }
8587 while (name = queue.shift()) {
8588 self.require(name);
8589 }
8590 }
8591 loadPlugin(name) {
8592 var self = this;
8593 var plugins = self.plugins;
8594 var plugin = Interface.plugins[name];
8595 if (!Interface.plugins.hasOwnProperty(name)) {
8596 throw new Error('Unable to find "' + name + '" plugin');
8597 }
8598 plugins.requested[name] = true;
8599 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
8600 plugins.names.push(name);
8601 }
8602 /**
8603 * Initializes a plugin.
8604 *
8605 */
8606 require(name) {
8607 var self = this;
8608 var plugins = self.plugins;
8609 if (!self.plugins.loaded.hasOwnProperty(name)) {
8610 if (plugins.requested[name]) {
8611 throw new Error('Plugin has circular dependency ("' + name + '")');
8612 }
8613 self.loadPlugin(name);
8614 }
8615 return plugins.loaded[name];
8616 }
8617 };
8618 }
8619 //# sourceMappingURL=microplugin.js.map
8620
8621 /***/ },
8622
8623 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
8624 /*!******************************************************!*\
8625 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
8626 \******************************************************/
8627 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8628
8629 "use strict";
8630 __webpack_require__.r(__webpack_exports__);
8631 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8632 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8633 /* harmony export */ });
8634 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
8635 options: [],
8636 optgroups: [],
8637 plugins: [],
8638 delimiter: ',',
8639 splitOn: null, // regexp or string for splitting up values from a paste command
8640 persist: true,
8641 diacritics: true,
8642 create: null,
8643 createOnBlur: false,
8644 createFilter: null,
8645 highlight: true,
8646 openOnFocus: true,
8647 shouldOpen: null,
8648 maxOptions: 50,
8649 maxItems: null,
8650 hideSelected: null,
8651 duplicates: false,
8652 addPrecedence: false,
8653 selectOnTab: false,
8654 preload: null,
8655 allowEmptyOption: false,
8656 //closeAfterSelect: false,
8657 refreshThrottle: 300,
8658 loadThrottle: 300,
8659 loadingClass: 'loading',
8660 dataAttr: null, //'data-data',
8661 optgroupField: 'optgroup',
8662 valueField: 'value',
8663 labelField: 'text',
8664 disabledField: 'disabled',
8665 optgroupLabelField: 'label',
8666 optgroupValueField: 'value',
8667 lockOptgroupOrder: false,
8668 sortField: '$order',
8669 searchField: ['text'],
8670 searchConjunction: 'and',
8671 mode: null,
8672 wrapperClass: 'ts-wrapper',
8673 controlClass: 'ts-control',
8674 dropdownClass: 'ts-dropdown',
8675 dropdownContentClass: 'ts-dropdown-content',
8676 itemClass: 'item',
8677 optionClass: 'option',
8678 dropdownParent: null,
8679 controlInput: '<input type="text" autocomplete="off" size="1" />',
8680 copyClassesToDropdown: false,
8681 placeholder: null,
8682 hidePlaceholder: null,
8683 shouldLoad: function (query) {
8684 return query.length > 0;
8685 },
8686 /*
8687 load : null, // function(query, callback) { ... }
8688 score : null, // function(search) { ... }
8689 onInitialize : null, // function() { ... }
8690 onChange : null, // function(value) { ... }
8691 onItemAdd : null, // function(value, $item) { ... }
8692 onItemRemove : null, // function(value) { ... }
8693 onClear : null, // function() { ... }
8694 onOptionAdd : null, // function(value, data) { ... }
8695 onOptionRemove : null, // function(value) { ... }
8696 onOptionClear : null, // function() { ... }
8697 onOptionGroupAdd : null, // function(id, data) { ... }
8698 onOptionGroupRemove : null, // function(id) { ... }
8699 onOptionGroupClear : null, // function() { ... }
8700 onDropdownOpen : null, // function(dropdown) { ... }
8701 onDropdownClose : null, // function(dropdown) { ... }
8702 onType : null, // function(str) { ... }
8703 onDelete : null, // function(values) { ... }
8704 */
8705 render: {
8706 /*
8707 item: null,
8708 optgroup: null,
8709 optgroup_header: null,
8710 option: null,
8711 option_create: null
8712 */
8713 }
8714 });
8715 //# sourceMappingURL=defaults.js.map
8716
8717 /***/ },
8718
8719 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
8720 /*!*********************************************************!*\
8721 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
8722 \*********************************************************/
8723 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8724
8725 "use strict";
8726 __webpack_require__.r(__webpack_exports__);
8727 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8728 /* harmony export */ "default": () => (/* binding */ getSettings)
8729 /* harmony export */ });
8730 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
8731 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8732
8733
8734 function getSettings(input, settings_user) {
8735 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
8736 var attr_data = settings.dataAttr;
8737 var field_label = settings.labelField;
8738 var field_value = settings.valueField;
8739 var field_disabled = settings.disabledField;
8740 var field_optgroup = settings.optgroupField;
8741 var field_optgroup_label = settings.optgroupLabelField;
8742 var field_optgroup_value = settings.optgroupValueField;
8743 var tag_name = input.tagName.toLowerCase();
8744 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
8745 if (!placeholder && !settings.allowEmptyOption) {
8746 let option = input.querySelector('option[value=""]');
8747 if (option) {
8748 placeholder = option.textContent;
8749 }
8750 }
8751 var settings_element = {
8752 placeholder: placeholder,
8753 options: [],
8754 optgroups: [],
8755 items: [],
8756 maxItems: null,
8757 };
8758 /**
8759 * Initialize from a <select> element.
8760 *
8761 */
8762 var init_select = () => {
8763 var tagName;
8764 var options = settings_element.options;
8765 var optionsMap = {};
8766 var group_count = 1;
8767 let $order = 0;
8768 var readData = (el) => {
8769 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
8770 var json = attr_data && data[attr_data];
8771 if (typeof json === 'string' && json.length) {
8772 data = Object.assign(data, JSON.parse(json));
8773 }
8774 return data;
8775 };
8776 var addOption = (option, group) => {
8777 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
8778 if (value == null)
8779 return;
8780 if (!value && !settings.allowEmptyOption)
8781 return;
8782 // if the option already exists, it's probably been
8783 // duplicated in another optgroup. in this case, push
8784 // the current group to the "optgroup" property on the
8785 // existing option so that it's rendered in both places.
8786 if (optionsMap.hasOwnProperty(value)) {
8787 if (group) {
8788 var arr = optionsMap[value][field_optgroup];
8789 if (!arr) {
8790 optionsMap[value][field_optgroup] = group;
8791 }
8792 else if (!Array.isArray(arr)) {
8793 optionsMap[value][field_optgroup] = [arr, group];
8794 }
8795 else {
8796 arr.push(group);
8797 }
8798 }
8799 }
8800 else {
8801 var option_data = readData(option);
8802 option_data[field_label] = option_data[field_label] || option.textContent;
8803 option_data[field_value] = option_data[field_value] || value;
8804 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
8805 option_data[field_optgroup] = option_data[field_optgroup] || group;
8806 option_data.$option = option;
8807 option_data.$order = option_data.$order || ++$order;
8808 optionsMap[value] = option_data;
8809 options.push(option_data);
8810 }
8811 if (option.selected) {
8812 settings_element.items.push(value);
8813 }
8814 };
8815 var addGroup = (optgroup) => {
8816 var id, optgroup_data;
8817 optgroup_data = readData(optgroup);
8818 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
8819 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
8820 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
8821 optgroup_data.$order = optgroup_data.$order || ++$order;
8822 settings_element.optgroups.push(optgroup_data);
8823 id = optgroup_data[field_optgroup_value];
8824 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
8825 addOption(option, id);
8826 });
8827 };
8828 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
8829 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
8830 tagName = child.tagName.toLowerCase();
8831 if (tagName === 'optgroup') {
8832 addGroup(child);
8833 }
8834 else if (tagName === 'option') {
8835 addOption(child);
8836 }
8837 });
8838 };
8839 /**
8840 * Initialize from a <input type="text"> element.
8841 *
8842 */
8843 var init_textbox = () => {
8844 const data_raw = input.getAttribute(attr_data);
8845 if (!data_raw) {
8846 var value = input.value.trim() || '';
8847 if (!settings.allowEmptyOption && !value.length)
8848 return;
8849 const values = value.split(settings.delimiter);
8850 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
8851 const option = {};
8852 option[field_label] = value;
8853 option[field_value] = value;
8854 settings_element.options.push(option);
8855 });
8856 settings_element.items = values;
8857 }
8858 else {
8859 settings_element.options = JSON.parse(data_raw);
8860 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
8861 settings_element.items.push(opt[field_value]);
8862 });
8863 }
8864 };
8865 if (tag_name === 'select') {
8866 init_select();
8867 }
8868 else {
8869 init_textbox();
8870 }
8871 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
8872 }
8873 ;
8874 //# sourceMappingURL=getSettings.js.map
8875
8876 /***/ },
8877
8878 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
8879 /*!***************************************************************************!*\
8880 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
8881 \***************************************************************************/
8882 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8883
8884 "use strict";
8885 __webpack_require__.r(__webpack_exports__);
8886 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8887 /* harmony export */ "default": () => (/* binding */ plugin)
8888 /* harmony export */ });
8889 /**
8890 * Tom Select v2.4.3
8891 * Licensed under the Apache License, Version 2.0 (the "License");
8892 */
8893
8894 /**
8895 * Converts a scalar to its best string representation
8896 * for hash keys and HTML attribute values.
8897 *
8898 * Transformations:
8899 * 'str' -> 'str'
8900 * null -> ''
8901 * undefined -> ''
8902 * true -> '1'
8903 * false -> '0'
8904 * 0 -> '0'
8905 * 1 -> '1'
8906 *
8907 */
8908
8909 /**
8910 * Iterates over arrays and hashes.
8911 *
8912 * ```
8913 * iterate(this.items, function(item, id) {
8914 * // invoked for each item
8915 * });
8916 * ```
8917 *
8918 */
8919 const iterate = (object, callback) => {
8920 if (Array.isArray(object)) {
8921 object.forEach(callback);
8922 } else {
8923 for (var key in object) {
8924 if (object.hasOwnProperty(key)) {
8925 callback(object[key], key);
8926 }
8927 }
8928 }
8929 };
8930
8931 /**
8932 * Remove css classes
8933 *
8934 */
8935 const removeClasses = (elmts, ...classes) => {
8936 var norm_classes = classesArray(classes);
8937 elmts = castAsArray(elmts);
8938 elmts.map(el => {
8939 norm_classes.map(cls => {
8940 el.classList.remove(cls);
8941 });
8942 });
8943 };
8944
8945 /**
8946 * Return arguments
8947 *
8948 */
8949 const classesArray = args => {
8950 var classes = [];
8951 iterate(args, _classes => {
8952 if (typeof _classes === 'string') {
8953 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8954 }
8955 if (Array.isArray(_classes)) {
8956 classes = classes.concat(_classes);
8957 }
8958 });
8959 return classes.filter(Boolean);
8960 };
8961
8962 /**
8963 * Create an array from arg if it's not already an array
8964 *
8965 */
8966 const castAsArray = arg => {
8967 if (!Array.isArray(arg)) {
8968 arg = [arg];
8969 }
8970 return arg;
8971 };
8972
8973 /**
8974 * Get the index of an element amongst sibling nodes of the same type
8975 *
8976 */
8977 const nodeIndex = (el, amongst) => {
8978 if (!el) return -1;
8979 amongst = amongst || el.nodeName;
8980 var i = 0;
8981 while (el = el.previousElementSibling) {
8982 if (el.matches(amongst)) {
8983 i++;
8984 }
8985 }
8986 return i;
8987 };
8988
8989 /**
8990 * Plugin: "dropdown_input" (Tom Select)
8991 * Copyright (c) contributors
8992 *
8993 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8994 * file except in compliance with the License. You may obtain a copy of the License at:
8995 * http://www.apache.org/licenses/LICENSE-2.0
8996 *
8997 * Unless required by applicable law or agreed to in writing, software distributed under
8998 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8999 * ANY KIND, either express or implied. See the License for the specific language
9000 * governing permissions and limitations under the License.
9001 *
9002 */
9003
9004 function plugin () {
9005 var self = this;
9006
9007 /**
9008 * Moves the caret to the specified index.
9009 *
9010 * The input must be moved by leaving it in place and moving the
9011 * siblings, due to the fact that focus cannot be restored once lost
9012 * on mobile webkit devices
9013 *
9014 */
9015 self.hook('instead', 'setCaret', new_pos => {
9016 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
9017 new_pos = self.items.length;
9018 } else {
9019 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
9020 if (new_pos != self.caretPos && !self.isPending) {
9021 self.controlChildren().forEach((child, j) => {
9022 if (j < new_pos) {
9023 self.control_input.insertAdjacentElement('beforebegin', child);
9024 } else {
9025 self.control.appendChild(child);
9026 }
9027 });
9028 }
9029 }
9030 self.caretPos = new_pos;
9031 });
9032 self.hook('instead', 'moveCaret', direction => {
9033 if (!self.isFocused) return;
9034
9035 // move caret before or after selected items
9036 const last_active = self.getLastActive(direction);
9037 if (last_active) {
9038 const idx = nodeIndex(last_active);
9039 self.setCaret(direction > 0 ? idx + 1 : idx);
9040 self.setActiveItem();
9041 removeClasses(last_active, 'last-active');
9042
9043 // move caret left or right of current position
9044 } else {
9045 self.setCaret(self.caretPos + direction);
9046 }
9047 });
9048 }
9049
9050
9051 //# sourceMappingURL=plugin.js.map
9052
9053
9054 /***/ },
9055
9056 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9057 /*!****************************************************************************!*\
9058 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9059 \****************************************************************************/
9060 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9061
9062 "use strict";
9063 __webpack_require__.r(__webpack_exports__);
9064 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9065 /* harmony export */ "default": () => (/* binding */ plugin)
9066 /* harmony export */ });
9067 /**
9068 * Tom Select v2.4.3
9069 * Licensed under the Apache License, Version 2.0 (the "License");
9070 */
9071
9072 /**
9073 * Converts a scalar to its best string representation
9074 * for hash keys and HTML attribute values.
9075 *
9076 * Transformations:
9077 * 'str' -> 'str'
9078 * null -> ''
9079 * undefined -> ''
9080 * true -> '1'
9081 * false -> '0'
9082 * 0 -> '0'
9083 * 1 -> '1'
9084 *
9085 */
9086
9087 /**
9088 * Add event helper
9089 *
9090 */
9091 const addEvent = (target, type, callback, options) => {
9092 target.addEventListener(type, callback, options);
9093 };
9094
9095 /**
9096 * Plugin: "change_listener" (Tom Select)
9097 * Copyright (c) contributors
9098 *
9099 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9100 * file except in compliance with the License. You may obtain a copy of the License at:
9101 * http://www.apache.org/licenses/LICENSE-2.0
9102 *
9103 * Unless required by applicable law or agreed to in writing, software distributed under
9104 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9105 * ANY KIND, either express or implied. See the License for the specific language
9106 * governing permissions and limitations under the License.
9107 *
9108 */
9109
9110 function plugin () {
9111 addEvent(this.input, 'change', () => {
9112 this.sync();
9113 });
9114 }
9115
9116
9117 //# sourceMappingURL=plugin.js.map
9118
9119
9120 /***/ },
9121
9122 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9123 /*!*****************************************************************************!*\
9124 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9125 \*****************************************************************************/
9126 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9127
9128 "use strict";
9129 __webpack_require__.r(__webpack_exports__);
9130 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9131 /* harmony export */ "default": () => (/* binding */ plugin)
9132 /* harmony export */ });
9133 /**
9134 * Tom Select v2.4.3
9135 * Licensed under the Apache License, Version 2.0 (the "License");
9136 */
9137
9138 /**
9139 * Converts a scalar to its best string representation
9140 * for hash keys and HTML attribute values.
9141 *
9142 * Transformations:
9143 * 'str' -> 'str'
9144 * null -> ''
9145 * undefined -> ''
9146 * true -> '1'
9147 * false -> '0'
9148 * 0 -> '0'
9149 * 1 -> '1'
9150 *
9151 */
9152 const hash_key = value => {
9153 if (typeof value === 'undefined' || value === null) return null;
9154 return get_hash(value);
9155 };
9156 const get_hash = value => {
9157 if (typeof value === 'boolean') return value ? '1' : '0';
9158 return value + '';
9159 };
9160
9161 /**
9162 * Prevent default
9163 *
9164 */
9165 const preventDefault = (evt, stop = false) => {
9166 if (evt) {
9167 evt.preventDefault();
9168 if (stop) {
9169 evt.stopPropagation();
9170 }
9171 }
9172 };
9173
9174 /**
9175 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9176 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9177 *
9178 * param query should be {}
9179 */
9180 const getDom = query => {
9181 if (query.jquery) {
9182 return query[0];
9183 }
9184 if (query instanceof HTMLElement) {
9185 return query;
9186 }
9187 if (isHtmlString(query)) {
9188 var tpl = document.createElement('template');
9189 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9190 return tpl.content.firstChild;
9191 }
9192 return document.querySelector(query);
9193 };
9194 const isHtmlString = arg => {
9195 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9196 return true;
9197 }
9198 return false;
9199 };
9200
9201 /**
9202 * Plugin: "checkbox_options" (Tom Select)
9203 * Copyright (c) contributors
9204 *
9205 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9206 * file except in compliance with the License. You may obtain a copy of the License at:
9207 * http://www.apache.org/licenses/LICENSE-2.0
9208 *
9209 * Unless required by applicable law or agreed to in writing, software distributed under
9210 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9211 * ANY KIND, either express or implied. See the License for the specific language
9212 * governing permissions and limitations under the License.
9213 *
9214 */
9215
9216 function plugin (userOptions) {
9217 var self = this;
9218 var orig_onOptionSelect = self.onOptionSelect;
9219 self.settings.hideSelected = false;
9220 const cbOptions = Object.assign({
9221 // so that the user may add different ones as well
9222 className: "tomselect-checkbox",
9223 // the following default to the historic plugin's values
9224 checkedClassNames: undefined,
9225 uncheckedClassNames: undefined
9226 }, userOptions);
9227 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9228 if (toCheck) {
9229 checkbox.checked = true;
9230 if (cbOptions.uncheckedClassNames) {
9231 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9232 }
9233 if (cbOptions.checkedClassNames) {
9234 checkbox.classList.add(...cbOptions.checkedClassNames);
9235 }
9236 } else {
9237 checkbox.checked = false;
9238 if (cbOptions.checkedClassNames) {
9239 checkbox.classList.remove(...cbOptions.checkedClassNames);
9240 }
9241 if (cbOptions.uncheckedClassNames) {
9242 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9243 }
9244 }
9245 };
9246
9247 // update the checkbox for an option
9248 var UpdateCheckbox = function UpdateCheckbox(option) {
9249 setTimeout(() => {
9250 var checkbox = option.querySelector('input.' + cbOptions.className);
9251 if (checkbox instanceof HTMLInputElement) {
9252 UpdateChecked(checkbox, option.classList.contains('selected'));
9253 }
9254 }, 1);
9255 };
9256
9257 // add checkbox to option template
9258 self.hook('after', 'setupTemplates', () => {
9259 var orig_render_option = self.settings.render.option;
9260 self.settings.render.option = (data, escape_html) => {
9261 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9262 var checkbox = document.createElement('input');
9263 if (cbOptions.className) {
9264 checkbox.classList.add(cbOptions.className);
9265 }
9266 checkbox.addEventListener('click', function (evt) {
9267 preventDefault(evt);
9268 });
9269 checkbox.type = 'checkbox';
9270 const hashed = hash_key(data[self.settings.valueField]);
9271 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9272 rendered.prepend(checkbox);
9273 return rendered;
9274 };
9275 });
9276
9277 // uncheck when item removed
9278 self.on('item_remove', value => {
9279 var option = self.getOption(value);
9280 if (option) {
9281 // if dropdown hasn't been opened yet, the option won't exist
9282 option.classList.remove('selected'); // selected class won't be removed yet
9283 UpdateCheckbox(option);
9284 }
9285 });
9286
9287 // check when item added
9288 self.on('item_add', value => {
9289 var option = self.getOption(value);
9290 if (option) {
9291 // if dropdown hasn't been opened yet, the option won't exist
9292 UpdateCheckbox(option);
9293 }
9294 });
9295
9296 // remove items when selected option is clicked
9297 self.hook('instead', 'onOptionSelect', (evt, option) => {
9298 if (option.classList.contains('selected')) {
9299 option.classList.remove('selected');
9300 self.removeItem(option.dataset.value);
9301 self.refreshOptions();
9302 preventDefault(evt, true);
9303 return;
9304 }
9305 orig_onOptionSelect.call(self, evt, option);
9306 UpdateCheckbox(option);
9307 });
9308 }
9309
9310
9311 //# sourceMappingURL=plugin.js.map
9312
9313
9314 /***/ },
9315
9316 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9317 /*!*************************************************************************!*\
9318 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9319 \*************************************************************************/
9320 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9321
9322 "use strict";
9323 __webpack_require__.r(__webpack_exports__);
9324 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9325 /* harmony export */ "default": () => (/* binding */ plugin)
9326 /* harmony export */ });
9327 /**
9328 * Tom Select v2.4.3
9329 * Licensed under the Apache License, Version 2.0 (the "License");
9330 */
9331
9332 /**
9333 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9334 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9335 *
9336 * param query should be {}
9337 */
9338 const getDom = query => {
9339 if (query.jquery) {
9340 return query[0];
9341 }
9342 if (query instanceof HTMLElement) {
9343 return query;
9344 }
9345 if (isHtmlString(query)) {
9346 var tpl = document.createElement('template');
9347 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9348 return tpl.content.firstChild;
9349 }
9350 return document.querySelector(query);
9351 };
9352 const isHtmlString = arg => {
9353 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9354 return true;
9355 }
9356 return false;
9357 };
9358
9359 /**
9360 * Plugin: "dropdown_header" (Tom Select)
9361 * Copyright (c) contributors
9362 *
9363 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9364 * file except in compliance with the License. You may obtain a copy of the License at:
9365 * http://www.apache.org/licenses/LICENSE-2.0
9366 *
9367 * Unless required by applicable law or agreed to in writing, software distributed under
9368 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9369 * ANY KIND, either express or implied. See the License for the specific language
9370 * governing permissions and limitations under the License.
9371 *
9372 */
9373
9374 function plugin (userOptions) {
9375 const self = this;
9376 const options = Object.assign({
9377 className: 'clear-button',
9378 title: 'Clear All',
9379 html: data => {
9380 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
9381 }
9382 }, userOptions);
9383 self.on('initialize', () => {
9384 var button = getDom(options.html(options));
9385 button.addEventListener('click', evt => {
9386 if (self.isLocked) return;
9387 self.clear();
9388 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9389 self.addItem('');
9390 }
9391 evt.preventDefault();
9392 evt.stopPropagation();
9393 });
9394 self.control.appendChild(button);
9395 });
9396 }
9397
9398
9399 //# sourceMappingURL=plugin.js.map
9400
9401
9402 /***/ },
9403
9404 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9405 /*!**********************************************************************!*\
9406 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9407 \**********************************************************************/
9408 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9409
9410 "use strict";
9411 __webpack_require__.r(__webpack_exports__);
9412 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9413 /* harmony export */ "default": () => (/* binding */ plugin)
9414 /* harmony export */ });
9415 /**
9416 * Tom Select v2.4.3
9417 * Licensed under the Apache License, Version 2.0 (the "License");
9418 */
9419
9420 /**
9421 * Converts a scalar to its best string representation
9422 * for hash keys and HTML attribute values.
9423 *
9424 * Transformations:
9425 * 'str' -> 'str'
9426 * null -> ''
9427 * undefined -> ''
9428 * true -> '1'
9429 * false -> '0'
9430 * 0 -> '0'
9431 * 1 -> '1'
9432 *
9433 */
9434
9435 /**
9436 * Prevent default
9437 *
9438 */
9439 const preventDefault = (evt, stop = false) => {
9440 if (evt) {
9441 evt.preventDefault();
9442 if (stop) {
9443 evt.stopPropagation();
9444 }
9445 }
9446 };
9447
9448 /**
9449 * Add event helper
9450 *
9451 */
9452 const addEvent = (target, type, callback, options) => {
9453 target.addEventListener(type, callback, options);
9454 };
9455
9456 /**
9457 * Iterates over arrays and hashes.
9458 *
9459 * ```
9460 * iterate(this.items, function(item, id) {
9461 * // invoked for each item
9462 * });
9463 * ```
9464 *
9465 */
9466 const iterate = (object, callback) => {
9467 if (Array.isArray(object)) {
9468 object.forEach(callback);
9469 } else {
9470 for (var key in object) {
9471 if (object.hasOwnProperty(key)) {
9472 callback(object[key], key);
9473 }
9474 }
9475 }
9476 };
9477
9478 /**
9479 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9480 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9481 *
9482 * param query should be {}
9483 */
9484 const getDom = query => {
9485 if (query.jquery) {
9486 return query[0];
9487 }
9488 if (query instanceof HTMLElement) {
9489 return query;
9490 }
9491 if (isHtmlString(query)) {
9492 var tpl = document.createElement('template');
9493 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9494 return tpl.content.firstChild;
9495 }
9496 return document.querySelector(query);
9497 };
9498 const isHtmlString = arg => {
9499 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9500 return true;
9501 }
9502 return false;
9503 };
9504
9505 /**
9506 * Set attributes of an element
9507 *
9508 */
9509 const setAttr = (el, attrs) => {
9510 iterate(attrs, (val, attr) => {
9511 if (val == null) {
9512 el.removeAttribute(attr);
9513 } else {
9514 el.setAttribute(attr, '' + val);
9515 }
9516 });
9517 };
9518
9519 /**
9520 * Plugin: "drag_drop" (Tom Select)
9521 * Copyright (c) contributors
9522 *
9523 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9524 * file except in compliance with the License. You may obtain a copy of the License at:
9525 * http://www.apache.org/licenses/LICENSE-2.0
9526 *
9527 * Unless required by applicable law or agreed to in writing, software distributed under
9528 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9529 * ANY KIND, either express or implied. See the License for the specific language
9530 * governing permissions and limitations under the License.
9531 *
9532 */
9533
9534 const insertAfter = (referenceNode, newNode) => {
9535 var _referenceNode$parent;
9536 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
9537 };
9538 const insertBefore = (referenceNode, newNode) => {
9539 var _referenceNode$parent2;
9540 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
9541 };
9542 const isBefore = (referenceNode, newNode) => {
9543 do {
9544 var _newNode;
9545 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
9546 if (referenceNode == newNode) {
9547 return true;
9548 }
9549 } while (newNode && newNode.previousElementSibling);
9550 return false;
9551 };
9552 function plugin () {
9553 var self = this;
9554 if (self.settings.mode !== 'multi') return;
9555 var orig_lock = self.lock;
9556 var orig_unlock = self.unlock;
9557 let sortable = true;
9558 let drag_item;
9559
9560 /**
9561 * Add draggable attribute to item
9562 */
9563 self.hook('after', 'setupTemplates', () => {
9564 var orig_render_item = self.settings.render.item;
9565 self.settings.render.item = (data, escape) => {
9566 const item = getDom(orig_render_item.call(self, data, escape));
9567 setAttr(item, {
9568 'draggable': 'true'
9569 });
9570
9571 // prevent doc_mousedown (see tom-select.ts)
9572 const mousedown = evt => {
9573 if (!sortable) preventDefault(evt);
9574 evt.stopPropagation();
9575 };
9576 const dragStart = evt => {
9577 drag_item = item;
9578 setTimeout(() => {
9579 item.classList.add('ts-dragging');
9580 }, 0);
9581 };
9582 const dragOver = evt => {
9583 evt.preventDefault();
9584 item.classList.add('ts-drag-over');
9585 moveitem(item, drag_item);
9586 };
9587 const dragLeave = () => {
9588 item.classList.remove('ts-drag-over');
9589 };
9590 const moveitem = (targetitem, dragitem) => {
9591 if (dragitem === undefined) return;
9592 if (isBefore(dragitem, item)) {
9593 insertAfter(targetitem, dragitem);
9594 } else {
9595 insertBefore(targetitem, dragitem);
9596 }
9597 };
9598 const dragend = () => {
9599 var _drag_item;
9600 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
9601 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
9602 drag_item = undefined;
9603 var values = [];
9604 self.control.querySelectorAll(`[data-value]`).forEach(el => {
9605 if (el.dataset.value) {
9606 let value = el.dataset.value;
9607 if (value) {
9608 values.push(value);
9609 }
9610 }
9611 });
9612 self.setValue(values);
9613 };
9614 addEvent(item, 'mousedown', mousedown);
9615 addEvent(item, 'dragstart', dragStart);
9616 addEvent(item, 'dragenter', dragOver);
9617 addEvent(item, 'dragover', dragOver);
9618 addEvent(item, 'dragleave', dragLeave);
9619 addEvent(item, 'dragend', dragend);
9620 return item;
9621 };
9622 });
9623 self.hook('instead', 'lock', () => {
9624 sortable = false;
9625 return orig_lock.call(self);
9626 });
9627 self.hook('instead', 'unlock', () => {
9628 sortable = true;
9629 return orig_unlock.call(self);
9630 });
9631 }
9632
9633
9634 //# sourceMappingURL=plugin.js.map
9635
9636
9637 /***/ },
9638
9639 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
9640 /*!****************************************************************************!*\
9641 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
9642 \****************************************************************************/
9643 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9644
9645 "use strict";
9646 __webpack_require__.r(__webpack_exports__);
9647 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9648 /* harmony export */ "default": () => (/* binding */ plugin)
9649 /* harmony export */ });
9650 /**
9651 * Tom Select v2.4.3
9652 * Licensed under the Apache License, Version 2.0 (the "License");
9653 */
9654
9655 /**
9656 * Converts a scalar to its best string representation
9657 * for hash keys and HTML attribute values.
9658 *
9659 * Transformations:
9660 * 'str' -> 'str'
9661 * null -> ''
9662 * undefined -> ''
9663 * true -> '1'
9664 * false -> '0'
9665 * 0 -> '0'
9666 * 1 -> '1'
9667 *
9668 */
9669
9670 /**
9671 * Prevent default
9672 *
9673 */
9674 const preventDefault = (evt, stop = false) => {
9675 if (evt) {
9676 evt.preventDefault();
9677 if (stop) {
9678 evt.stopPropagation();
9679 }
9680 }
9681 };
9682
9683 /**
9684 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9685 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9686 *
9687 * param query should be {}
9688 */
9689 const getDom = query => {
9690 if (query.jquery) {
9691 return query[0];
9692 }
9693 if (query instanceof HTMLElement) {
9694 return query;
9695 }
9696 if (isHtmlString(query)) {
9697 var tpl = document.createElement('template');
9698 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9699 return tpl.content.firstChild;
9700 }
9701 return document.querySelector(query);
9702 };
9703 const isHtmlString = arg => {
9704 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9705 return true;
9706 }
9707 return false;
9708 };
9709
9710 /**
9711 * Plugin: "dropdown_header" (Tom Select)
9712 * Copyright (c) contributors
9713 *
9714 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9715 * file except in compliance with the License. You may obtain a copy of the License at:
9716 * http://www.apache.org/licenses/LICENSE-2.0
9717 *
9718 * Unless required by applicable law or agreed to in writing, software distributed under
9719 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9720 * ANY KIND, either express or implied. See the License for the specific language
9721 * governing permissions and limitations under the License.
9722 *
9723 */
9724
9725 function plugin (userOptions) {
9726 const self = this;
9727 const options = Object.assign({
9728 title: 'Untitled',
9729 headerClass: 'dropdown-header',
9730 titleRowClass: 'dropdown-header-title',
9731 labelClass: 'dropdown-header-label',
9732 closeClass: 'dropdown-header-close',
9733 html: data => {
9734 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
9735 }
9736 }, userOptions);
9737 self.on('initialize', () => {
9738 var header = getDom(options.html(options));
9739 var close_link = header.querySelector('.' + options.closeClass);
9740 if (close_link) {
9741 close_link.addEventListener('click', evt => {
9742 preventDefault(evt, true);
9743 self.close();
9744 });
9745 }
9746 self.dropdown.insertBefore(header, self.dropdown.firstChild);
9747 });
9748 }
9749
9750
9751 //# sourceMappingURL=plugin.js.map
9752
9753
9754 /***/ },
9755
9756 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
9757 /*!***************************************************************************!*\
9758 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
9759 \***************************************************************************/
9760 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9761
9762 "use strict";
9763 __webpack_require__.r(__webpack_exports__);
9764 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9765 /* harmony export */ "default": () => (/* binding */ plugin)
9766 /* harmony export */ });
9767 /**
9768 * Tom Select v2.4.3
9769 * Licensed under the Apache License, Version 2.0 (the "License");
9770 */
9771
9772 const KEY_ESC = 27;
9773 const KEY_TAB = 9;
9774 // ctrl key or apple key for ma
9775
9776 /**
9777 * Converts a scalar to its best string representation
9778 * for hash keys and HTML attribute values.
9779 *
9780 * Transformations:
9781 * 'str' -> 'str'
9782 * null -> ''
9783 * undefined -> ''
9784 * true -> '1'
9785 * false -> '0'
9786 * 0 -> '0'
9787 * 1 -> '1'
9788 *
9789 */
9790
9791 /**
9792 * Prevent default
9793 *
9794 */
9795 const preventDefault = (evt, stop = false) => {
9796 if (evt) {
9797 evt.preventDefault();
9798 if (stop) {
9799 evt.stopPropagation();
9800 }
9801 }
9802 };
9803
9804 /**
9805 * Add event helper
9806 *
9807 */
9808 const addEvent = (target, type, callback, options) => {
9809 target.addEventListener(type, callback, options);
9810 };
9811
9812 /**
9813 * Iterates over arrays and hashes.
9814 *
9815 * ```
9816 * iterate(this.items, function(item, id) {
9817 * // invoked for each item
9818 * });
9819 * ```
9820 *
9821 */
9822 const iterate = (object, callback) => {
9823 if (Array.isArray(object)) {
9824 object.forEach(callback);
9825 } else {
9826 for (var key in object) {
9827 if (object.hasOwnProperty(key)) {
9828 callback(object[key], key);
9829 }
9830 }
9831 }
9832 };
9833
9834 /**
9835 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9836 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9837 *
9838 * param query should be {}
9839 */
9840 const getDom = query => {
9841 if (query.jquery) {
9842 return query[0];
9843 }
9844 if (query instanceof HTMLElement) {
9845 return query;
9846 }
9847 if (isHtmlString(query)) {
9848 var tpl = document.createElement('template');
9849 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9850 return tpl.content.firstChild;
9851 }
9852 return document.querySelector(query);
9853 };
9854 const isHtmlString = arg => {
9855 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9856 return true;
9857 }
9858 return false;
9859 };
9860
9861 /**
9862 * Add css classes
9863 *
9864 */
9865 const addClasses = (elmts, ...classes) => {
9866 var norm_classes = classesArray(classes);
9867 elmts = castAsArray(elmts);
9868 elmts.map(el => {
9869 norm_classes.map(cls => {
9870 el.classList.add(cls);
9871 });
9872 });
9873 };
9874
9875 /**
9876 * Return arguments
9877 *
9878 */
9879 const classesArray = args => {
9880 var classes = [];
9881 iterate(args, _classes => {
9882 if (typeof _classes === 'string') {
9883 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9884 }
9885 if (Array.isArray(_classes)) {
9886 classes = classes.concat(_classes);
9887 }
9888 });
9889 return classes.filter(Boolean);
9890 };
9891
9892 /**
9893 * Create an array from arg if it's not already an array
9894 *
9895 */
9896 const castAsArray = arg => {
9897 if (!Array.isArray(arg)) {
9898 arg = [arg];
9899 }
9900 return arg;
9901 };
9902
9903 /**
9904 * Plugin: "dropdown_input" (Tom Select)
9905 * Copyright (c) contributors
9906 *
9907 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9908 * file except in compliance with the License. You may obtain a copy of the License at:
9909 * http://www.apache.org/licenses/LICENSE-2.0
9910 *
9911 * Unless required by applicable law or agreed to in writing, software distributed under
9912 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9913 * ANY KIND, either express or implied. See the License for the specific language
9914 * governing permissions and limitations under the License.
9915 *
9916 */
9917
9918 function plugin () {
9919 const self = this;
9920 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
9921
9922 self.hook('before', 'setup', () => {
9923 self.focus_node = self.control;
9924 addClasses(self.control_input, 'dropdown-input');
9925 const div = getDom('<div class="dropdown-input-wrap">');
9926 div.append(self.control_input);
9927 self.dropdown.insertBefore(div, self.dropdown.firstChild);
9928
9929 // set a placeholder in the select control
9930 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
9931 placeholder.placeholder = self.settings.placeholder || '';
9932 self.control.append(placeholder);
9933 });
9934 self.on('initialize', () => {
9935 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
9936 self.control_input.addEventListener('keydown', evt => {
9937 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
9938 switch (evt.keyCode) {
9939 case KEY_ESC:
9940 if (self.isOpen) {
9941 preventDefault(evt, true);
9942 self.close();
9943 }
9944 self.clearActiveItems();
9945 return;
9946 case KEY_TAB:
9947 self.focus_node.tabIndex = -1;
9948 break;
9949 }
9950 return self.onKeyDown.call(self, evt);
9951 });
9952 self.on('blur', () => {
9953 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
9954 });
9955
9956 // give the control_input focus when the dropdown is open
9957 self.on('dropdown_open', () => {
9958 self.control_input.focus();
9959 });
9960
9961 // prevent onBlur from closing when focus is on the control_input
9962 const orig_onBlur = self.onBlur;
9963 self.hook('instead', 'onBlur', evt => {
9964 if (evt && evt.relatedTarget == self.control_input) return;
9965 return orig_onBlur.call(self);
9966 });
9967 addEvent(self.control_input, 'blur', () => self.onBlur());
9968
9969 // return focus to control to allow further keyboard input
9970 self.hook('before', 'close', () => {
9971 if (!self.isOpen) return;
9972 self.focus_node.focus({
9973 preventScroll: true
9974 });
9975 });
9976 });
9977 }
9978
9979
9980 //# sourceMappingURL=plugin.js.map
9981
9982
9983 /***/ },
9984
9985 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
9986 /*!***************************************************************************!*\
9987 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
9988 \***************************************************************************/
9989 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9990
9991 "use strict";
9992 __webpack_require__.r(__webpack_exports__);
9993 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9994 /* harmony export */ "default": () => (/* binding */ plugin)
9995 /* harmony export */ });
9996 /**
9997 * Tom Select v2.4.3
9998 * Licensed under the Apache License, Version 2.0 (the "License");
9999 */
10000
10001 /**
10002 * Converts a scalar to its best string representation
10003 * for hash keys and HTML attribute values.
10004 *
10005 * Transformations:
10006 * 'str' -> 'str'
10007 * null -> ''
10008 * undefined -> ''
10009 * true -> '1'
10010 * false -> '0'
10011 * 0 -> '0'
10012 * 1 -> '1'
10013 *
10014 */
10015
10016 /**
10017 * Add event helper
10018 *
10019 */
10020 const addEvent = (target, type, callback, options) => {
10021 target.addEventListener(type, callback, options);
10022 };
10023
10024 /**
10025 * Plugin: "input_autogrow" (Tom Select)
10026 *
10027 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10028 * file except in compliance with the License. You may obtain a copy of the License at:
10029 * http://www.apache.org/licenses/LICENSE-2.0
10030 *
10031 * Unless required by applicable law or agreed to in writing, software distributed under
10032 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10033 * ANY KIND, either express or implied. See the License for the specific language
10034 * governing permissions and limitations under the License.
10035 *
10036 */
10037
10038 function plugin () {
10039 var self = this;
10040 self.on('initialize', () => {
10041 var test_input = document.createElement('span');
10042 var control = self.control_input;
10043 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10044 self.wrapper.appendChild(test_input);
10045 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10046 for (const style_name of transfer_styles) {
10047 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10048 test_input.style[style_name] = control.style[style_name];
10049 }
10050
10051 /**
10052 * Set the control width
10053 *
10054 */
10055 var resize = () => {
10056 test_input.textContent = control.value;
10057 control.style.width = test_input.clientWidth + 'px';
10058 };
10059 resize();
10060 self.on('update item_add item_remove', resize);
10061 addEvent(control, 'input', resize);
10062 addEvent(control, 'keyup', resize);
10063 addEvent(control, 'blur', resize);
10064 addEvent(control, 'update', resize);
10065 });
10066 }
10067
10068
10069 //# sourceMappingURL=plugin.js.map
10070
10071
10072 /***/ },
10073
10074 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10075 /*!****************************************************************************!*\
10076 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10077 \****************************************************************************/
10078 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10079
10080 "use strict";
10081 __webpack_require__.r(__webpack_exports__);
10082 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10083 /* harmony export */ "default": () => (/* binding */ plugin)
10084 /* harmony export */ });
10085 /**
10086 * Tom Select v2.4.3
10087 * Licensed under the Apache License, Version 2.0 (the "License");
10088 */
10089
10090 /**
10091 * Plugin: "no_active_items" (Tom Select)
10092 *
10093 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10094 * file except in compliance with the License. You may obtain a copy of the License at:
10095 * http://www.apache.org/licenses/LICENSE-2.0
10096 *
10097 * Unless required by applicable law or agreed to in writing, software distributed under
10098 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10099 * ANY KIND, either express or implied. See the License for the specific language
10100 * governing permissions and limitations under the License.
10101 *
10102 */
10103
10104 function plugin () {
10105 this.hook('instead', 'setActiveItem', () => {});
10106 this.hook('instead', 'selectAll', () => {});
10107 }
10108
10109
10110 //# sourceMappingURL=plugin.js.map
10111
10112
10113 /***/ },
10114
10115 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10116 /*!********************************************************************************!*\
10117 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10118 \********************************************************************************/
10119 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10120
10121 "use strict";
10122 __webpack_require__.r(__webpack_exports__);
10123 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10124 /* harmony export */ "default": () => (/* binding */ plugin)
10125 /* harmony export */ });
10126 /**
10127 * Tom Select v2.4.3
10128 * Licensed under the Apache License, Version 2.0 (the "License");
10129 */
10130
10131 /**
10132 * Plugin: "input_autogrow" (Tom Select)
10133 *
10134 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10135 * file except in compliance with the License. You may obtain a copy of the License at:
10136 * http://www.apache.org/licenses/LICENSE-2.0
10137 *
10138 * Unless required by applicable law or agreed to in writing, software distributed under
10139 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10140 * ANY KIND, either express or implied. See the License for the specific language
10141 * governing permissions and limitations under the License.
10142 *
10143 */
10144
10145 function plugin () {
10146 var self = this;
10147 var orig_deleteSelection = self.deleteSelection;
10148 this.hook('instead', 'deleteSelection', evt => {
10149 if (self.activeItems.length) {
10150 return orig_deleteSelection.call(self, evt);
10151 }
10152 return false;
10153 });
10154 }
10155
10156
10157 //# sourceMappingURL=plugin.js.map
10158
10159
10160 /***/ },
10161
10162 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10163 /*!*****************************************************************************!*\
10164 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10165 \*****************************************************************************/
10166 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10167
10168 "use strict";
10169 __webpack_require__.r(__webpack_exports__);
10170 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10171 /* harmony export */ "default": () => (/* binding */ plugin)
10172 /* harmony export */ });
10173 /**
10174 * Tom Select v2.4.3
10175 * Licensed under the Apache License, Version 2.0 (the "License");
10176 */
10177
10178 const KEY_LEFT = 37;
10179 const KEY_RIGHT = 39;
10180 // ctrl key or apple key for ma
10181
10182 /**
10183 * Get the closest node to the evt.target matching the selector
10184 * Stops at wrapper
10185 *
10186 */
10187 const parentMatch = (target, selector, wrapper) => {
10188 while (target && target.matches) {
10189 if (target.matches(selector)) {
10190 return target;
10191 }
10192 target = target.parentNode;
10193 }
10194 };
10195
10196 /**
10197 * Get the index of an element amongst sibling nodes of the same type
10198 *
10199 */
10200 const nodeIndex = (el, amongst) => {
10201 if (!el) return -1;
10202 amongst = amongst || el.nodeName;
10203 var i = 0;
10204 while (el = el.previousElementSibling) {
10205 if (el.matches(amongst)) {
10206 i++;
10207 }
10208 }
10209 return i;
10210 };
10211
10212 /**
10213 * Plugin: "optgroup_columns" (Tom Select.js)
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 () {
10228 var self = this;
10229 var orig_keydown = self.onKeyDown;
10230 self.hook('instead', 'onKeyDown', evt => {
10231 var index, option, options, optgroup;
10232 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10233 return orig_keydown.call(self, evt);
10234 }
10235 self.ignoreHover = true;
10236 optgroup = parentMatch(self.activeOption, '[data-group]');
10237 index = nodeIndex(self.activeOption, '[data-selectable]');
10238 if (!optgroup) {
10239 return;
10240 }
10241 if (evt.keyCode === KEY_LEFT) {
10242 optgroup = optgroup.previousSibling;
10243 } else {
10244 optgroup = optgroup.nextSibling;
10245 }
10246 if (!optgroup) {
10247 return;
10248 }
10249 options = optgroup.querySelectorAll('[data-selectable]');
10250 option = options[Math.min(options.length - 1, index)];
10251 if (option) {
10252 self.setActiveOption(option);
10253 }
10254 });
10255 }
10256
10257
10258 //# sourceMappingURL=plugin.js.map
10259
10260
10261 /***/ },
10262
10263 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10264 /*!**************************************************************************!*\
10265 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10266 \**************************************************************************/
10267 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10268
10269 "use strict";
10270 __webpack_require__.r(__webpack_exports__);
10271 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10272 /* harmony export */ "default": () => (/* binding */ plugin)
10273 /* harmony export */ });
10274 /**
10275 * Tom Select v2.4.3
10276 * Licensed under the Apache License, Version 2.0 (the "License");
10277 */
10278
10279 /**
10280 * Converts a scalar to its best string representation
10281 * for hash keys and HTML attribute values.
10282 *
10283 * Transformations:
10284 * 'str' -> 'str'
10285 * null -> ''
10286 * undefined -> ''
10287 * true -> '1'
10288 * false -> '0'
10289 * 0 -> '0'
10290 * 1 -> '1'
10291 *
10292 */
10293
10294 /**
10295 * Escapes a string for use within HTML.
10296 *
10297 */
10298 const escape_html = str => {
10299 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
10300 };
10301
10302 /**
10303 * Prevent default
10304 *
10305 */
10306 const preventDefault = (evt, stop = false) => {
10307 if (evt) {
10308 evt.preventDefault();
10309 if (stop) {
10310 evt.stopPropagation();
10311 }
10312 }
10313 };
10314
10315 /**
10316 * Add event helper
10317 *
10318 */
10319 const addEvent = (target, type, callback, options) => {
10320 target.addEventListener(type, callback, options);
10321 };
10322
10323 /**
10324 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10325 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10326 *
10327 * param query should be {}
10328 */
10329 const getDom = query => {
10330 if (query.jquery) {
10331 return query[0];
10332 }
10333 if (query instanceof HTMLElement) {
10334 return query;
10335 }
10336 if (isHtmlString(query)) {
10337 var tpl = document.createElement('template');
10338 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10339 return tpl.content.firstChild;
10340 }
10341 return document.querySelector(query);
10342 };
10343 const isHtmlString = arg => {
10344 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10345 return true;
10346 }
10347 return false;
10348 };
10349
10350 /**
10351 * Plugin: "remove_button" (Tom Select)
10352 * Copyright (c) contributors
10353 *
10354 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10355 * file except in compliance with the License. You may obtain a copy of the License at:
10356 * http://www.apache.org/licenses/LICENSE-2.0
10357 *
10358 * Unless required by applicable law or agreed to in writing, software distributed under
10359 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10360 * ANY KIND, either express or implied. See the License for the specific language
10361 * governing permissions and limitations under the License.
10362 *
10363 */
10364
10365 function plugin (userOptions) {
10366 const options = Object.assign({
10367 label: '&times;',
10368 title: 'Remove',
10369 className: 'remove',
10370 append: true
10371 }, userOptions);
10372
10373 //options.className = 'remove-single';
10374 var self = this;
10375
10376 // override the render method to add remove button to each item
10377 if (!options.append) {
10378 return;
10379 }
10380 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
10381 self.hook('after', 'setupTemplates', () => {
10382 var orig_render_item = self.settings.render.item;
10383 self.settings.render.item = (data, escape) => {
10384 var item = getDom(orig_render_item.call(self, data, escape));
10385 var close_button = getDom(html);
10386 item.appendChild(close_button);
10387 addEvent(close_button, 'mousedown', evt => {
10388 preventDefault(evt, true);
10389 });
10390 addEvent(close_button, 'click', evt => {
10391 if (self.isLocked) return;
10392
10393 // propagating will trigger the dropdown to show for single mode
10394 preventDefault(evt, true);
10395 if (self.isLocked) return;
10396 if (!self.shouldDelete([item], evt)) return;
10397 self.removeItem(item);
10398 self.refreshOptions(false);
10399 self.inputState();
10400 });
10401 return item;
10402 };
10403 });
10404 }
10405
10406
10407 //# sourceMappingURL=plugin.js.map
10408
10409
10410 /***/ },
10411
10412 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10413 /*!*********************************************************************************!*\
10414 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10415 \*********************************************************************************/
10416 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10417
10418 "use strict";
10419 __webpack_require__.r(__webpack_exports__);
10420 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10421 /* harmony export */ "default": () => (/* binding */ plugin)
10422 /* harmony export */ });
10423 /**
10424 * Tom Select v2.4.3
10425 * Licensed under the Apache License, Version 2.0 (the "License");
10426 */
10427
10428 /**
10429 * Plugin: "restore_on_backspace" (Tom Select)
10430 * Copyright (c) contributors
10431 *
10432 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10433 * file except in compliance with the License. You may obtain a copy of the License at:
10434 * http://www.apache.org/licenses/LICENSE-2.0
10435 *
10436 * Unless required by applicable law or agreed to in writing, software distributed under
10437 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10438 * ANY KIND, either express or implied. See the License for the specific language
10439 * governing permissions and limitations under the License.
10440 *
10441 */
10442
10443 function plugin (userOptions) {
10444 const self = this;
10445 const options = Object.assign({
10446 text: option => {
10447 return option[self.settings.labelField];
10448 }
10449 }, userOptions);
10450 self.on('item_remove', function (value) {
10451 if (!self.isFocused) {
10452 return;
10453 }
10454 if (self.control_input.value.trim() === '') {
10455 var option = self.options[value];
10456 if (option) {
10457 self.setTextboxValue(options.text.call(self, option));
10458 }
10459 }
10460 });
10461 }
10462
10463
10464 //# sourceMappingURL=plugin.js.map
10465
10466
10467 /***/ },
10468
10469 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10470 /*!***************************************************************************!*\
10471 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10472 \***************************************************************************/
10473 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10474
10475 "use strict";
10476 __webpack_require__.r(__webpack_exports__);
10477 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10478 /* harmony export */ "default": () => (/* binding */ plugin)
10479 /* harmony export */ });
10480 /**
10481 * Tom Select v2.4.3
10482 * Licensed under the Apache License, Version 2.0 (the "License");
10483 */
10484
10485 /**
10486 * Converts a scalar to its best string representation
10487 * for hash keys and HTML attribute values.
10488 *
10489 * Transformations:
10490 * 'str' -> 'str'
10491 * null -> ''
10492 * undefined -> ''
10493 * true -> '1'
10494 * false -> '0'
10495 * 0 -> '0'
10496 * 1 -> '1'
10497 *
10498 */
10499
10500 /**
10501 * Iterates over arrays and hashes.
10502 *
10503 * ```
10504 * iterate(this.items, function(item, id) {
10505 * // invoked for each item
10506 * });
10507 * ```
10508 *
10509 */
10510 const iterate = (object, callback) => {
10511 if (Array.isArray(object)) {
10512 object.forEach(callback);
10513 } else {
10514 for (var key in object) {
10515 if (object.hasOwnProperty(key)) {
10516 callback(object[key], key);
10517 }
10518 }
10519 }
10520 };
10521
10522 /**
10523 * Add css classes
10524 *
10525 */
10526 const addClasses = (elmts, ...classes) => {
10527 var norm_classes = classesArray(classes);
10528 elmts = castAsArray(elmts);
10529 elmts.map(el => {
10530 norm_classes.map(cls => {
10531 el.classList.add(cls);
10532 });
10533 });
10534 };
10535
10536 /**
10537 * Return arguments
10538 *
10539 */
10540 const classesArray = args => {
10541 var classes = [];
10542 iterate(args, _classes => {
10543 if (typeof _classes === 'string') {
10544 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10545 }
10546 if (Array.isArray(_classes)) {
10547 classes = classes.concat(_classes);
10548 }
10549 });
10550 return classes.filter(Boolean);
10551 };
10552
10553 /**
10554 * Create an array from arg if it's not already an array
10555 *
10556 */
10557 const castAsArray = arg => {
10558 if (!Array.isArray(arg)) {
10559 arg = [arg];
10560 }
10561 return arg;
10562 };
10563
10564 /**
10565 * Plugin: "restore_on_backspace" (Tom Select)
10566 * Copyright (c) contributors
10567 *
10568 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10569 * file except in compliance with the License. You may obtain a copy of the License at:
10570 * http://www.apache.org/licenses/LICENSE-2.0
10571 *
10572 * Unless required by applicable law or agreed to in writing, software distributed under
10573 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10574 * ANY KIND, either express or implied. See the License for the specific language
10575 * governing permissions and limitations under the License.
10576 *
10577 */
10578
10579 function plugin () {
10580 const self = this;
10581 const orig_canLoad = self.canLoad;
10582 const orig_clearActiveOption = self.clearActiveOption;
10583 const orig_loadCallback = self.loadCallback;
10584 var pagination = {};
10585 var dropdown_content;
10586 var loading_more = false;
10587 var load_more_opt;
10588 var default_values = [];
10589 if (!self.settings.shouldLoadMore) {
10590 // return true if additional results should be loaded
10591 self.settings.shouldLoadMore = () => {
10592 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
10593 if (scroll_percent > 0.9) {
10594 return true;
10595 }
10596 if (self.activeOption) {
10597 var selectable = self.selectable();
10598 var index = Array.from(selectable).indexOf(self.activeOption);
10599 if (index >= selectable.length - 2) {
10600 return true;
10601 }
10602 }
10603 return false;
10604 };
10605 }
10606 if (!self.settings.firstUrl) {
10607 throw 'virtual_scroll plugin requires a firstUrl() method';
10608 }
10609
10610 // in order for virtual scrolling to work,
10611 // options need to be ordered the same way they're returned from the remote data source
10612 self.settings.sortField = [{
10613 field: '$order'
10614 }, {
10615 field: '$score'
10616 }];
10617
10618 // can we load more results for given query?
10619 const canLoadMore = query => {
10620 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
10621 return false;
10622 }
10623 if (query in pagination && pagination[query]) {
10624 return true;
10625 }
10626 return false;
10627 };
10628 const clearFilter = (option, value) => {
10629 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
10630 return true;
10631 }
10632 return false;
10633 };
10634
10635 // set the next url that will be
10636 self.setNextUrl = (value, next_url) => {
10637 pagination[value] = next_url;
10638 };
10639
10640 // getUrl() to be used in settings.load()
10641 self.getUrl = query => {
10642 if (query in pagination) {
10643 const next_url = pagination[query];
10644 pagination[query] = false;
10645 return next_url;
10646 }
10647
10648 // if the user goes back to a previous query
10649 // we need to load the first page again
10650 self.clearPagination();
10651 return self.settings.firstUrl.call(self, query);
10652 };
10653
10654 // clear pagination
10655 self.clearPagination = () => {
10656 pagination = {};
10657 };
10658
10659 // don't clear the active option (and cause unwanted dropdown scroll)
10660 // while loading more results
10661 self.hook('instead', 'clearActiveOption', () => {
10662 if (loading_more) {
10663 return;
10664 }
10665 return orig_clearActiveOption.call(self);
10666 });
10667
10668 // override the canLoad method
10669 self.hook('instead', 'canLoad', query => {
10670 // first time the query has been seen
10671 if (!(query in pagination)) {
10672 return orig_canLoad.call(self, query);
10673 }
10674 return canLoadMore(query);
10675 });
10676
10677 // wrap the load
10678 self.hook('instead', 'loadCallback', (options, optgroups) => {
10679 if (!loading_more) {
10680 self.clearOptions(clearFilter);
10681 } else if (load_more_opt) {
10682 const first_option = options[0];
10683 if (first_option !== undefined) {
10684 load_more_opt.dataset.value = first_option[self.settings.valueField];
10685 }
10686 }
10687 orig_loadCallback.call(self, options, optgroups);
10688 loading_more = false;
10689 });
10690
10691 // add templates to dropdown
10692 // loading_more if we have another url in the queue
10693 // no_more_results if we don't have another url in the queue
10694 self.hook('after', 'refreshOptions', () => {
10695 const query = self.lastValue;
10696 var option;
10697 if (canLoadMore(query)) {
10698 option = self.render('loading_more', {
10699 query: query
10700 });
10701 if (option) {
10702 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
10703 load_more_opt = option;
10704 }
10705 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
10706 option = self.render('no_more_results', {
10707 query: query
10708 });
10709 }
10710 if (option) {
10711 addClasses(option, self.settings.optionClass);
10712 dropdown_content.append(option);
10713 }
10714 });
10715
10716 // add scroll listener and default templates
10717 self.on('initialize', () => {
10718 default_values = Object.keys(self.options);
10719 dropdown_content = self.dropdown_content;
10720
10721 // default templates
10722 self.settings.render = Object.assign({}, {
10723 loading_more: () => {
10724 return `<div class="loading-more-results">Loading more results ... </div>`;
10725 },
10726 no_more_results: () => {
10727 return `<div class="no-more-results">No more results</div>`;
10728 }
10729 }, self.settings.render);
10730
10731 // watch dropdown content scroll position
10732 dropdown_content.addEventListener('scroll', () => {
10733 if (!self.settings.shouldLoadMore.call(self)) {
10734 return;
10735 }
10736
10737 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
10738 if (!canLoadMore(self.lastValue)) {
10739 return;
10740 }
10741
10742 // don't call load() too much
10743 if (loading_more) return;
10744 loading_more = true;
10745 self.load.call(self, self.lastValue);
10746 });
10747 });
10748 }
10749
10750
10751 //# sourceMappingURL=plugin.js.map
10752
10753
10754 /***/ },
10755
10756 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
10757 /*!*****************************************************************!*\
10758 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
10759 \*****************************************************************/
10760 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10761
10762 "use strict";
10763 __webpack_require__.r(__webpack_exports__);
10764 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10765 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10766 /* harmony export */ });
10767 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
10768 /* 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");
10769 /* 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");
10770 /* 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");
10771 /* 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");
10772 /* 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");
10773 /* 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");
10774 /* 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");
10775 /* 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");
10776 /* 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");
10777 /* 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");
10778 /* 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");
10779 /* 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");
10780 /* 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");
10781 /* 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");
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
10798 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
10799 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
10800 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
10801 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
10802 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
10803 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
10804 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
10805 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
10806 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
10807 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
10808 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
10809 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
10810 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
10811 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
10812 //# sourceMappingURL=tom-select.complete.js.map
10813
10814 /***/ },
10815
10816 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
10817 /*!********************************************************!*\
10818 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
10819 \********************************************************/
10820 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10821
10822 "use strict";
10823 __webpack_require__.r(__webpack_exports__);
10824 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10825 /* harmony export */ "default": () => (/* binding */ TomSelect)
10826 /* harmony export */ });
10827 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
10828 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
10829 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
10830 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10831 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
10832 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
10833 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
10834 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
10835 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845 var instance_i = 0;
10846 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
10847 constructor(input_arg, user_settings) {
10848 super();
10849 this.order = 0;
10850 this.isOpen = false;
10851 this.isDisabled = false;
10852 this.isReadOnly = false;
10853 this.isInvalid = false; // @deprecated 1.8
10854 this.isValid = true;
10855 this.isLocked = false;
10856 this.isFocused = false;
10857 this.isInputHidden = false;
10858 this.isSetup = false;
10859 this.ignoreFocus = false;
10860 this.ignoreHover = false;
10861 this.hasOptions = false;
10862 this.lastValue = '';
10863 this.caretPos = 0;
10864 this.loading = 0;
10865 this.loadedSearches = {};
10866 this.activeOption = null;
10867 this.activeItems = [];
10868 this.optgroups = {};
10869 this.options = {};
10870 this.userOptions = {};
10871 this.items = [];
10872 this.refreshTimeout = null;
10873 instance_i++;
10874 var dir;
10875 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
10876 if (input.tomselect) {
10877 throw new Error('Tom Select already initialized on this element');
10878 }
10879 input.tomselect = this;
10880 // detect rtl environment
10881 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
10882 dir = computedStyle.getPropertyValue('direction');
10883 // setup default state
10884 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
10885 this.settings = settings;
10886 this.input = input;
10887 this.tabIndex = input.tabIndex || 0;
10888 this.is_select_tag = input.tagName.toLowerCase() === 'select';
10889 this.rtl = /rtl/i.test(dir);
10890 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
10891 this.isRequired = input.required;
10892 // search system
10893 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
10894 // option-dependent defaults
10895 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
10896 if (typeof settings.hideSelected !== 'boolean') {
10897 settings.hideSelected = settings.mode === 'multi';
10898 }
10899 if (typeof settings.hidePlaceholder !== 'boolean') {
10900 settings.hidePlaceholder = settings.mode !== 'multi';
10901 }
10902 // set up createFilter callback
10903 var filter = settings.createFilter;
10904 if (typeof filter !== 'function') {
10905 if (typeof filter === 'string') {
10906 filter = new RegExp(filter);
10907 }
10908 if (filter instanceof RegExp) {
10909 settings.createFilter = (input) => filter.test(input);
10910 }
10911 else {
10912 settings.createFilter = (value) => {
10913 return this.settings.duplicates || !this.options[value];
10914 };
10915 }
10916 }
10917 this.initializePlugins(settings.plugins);
10918 this.setupCallbacks();
10919 this.setupTemplates();
10920 // Create all elements
10921 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10922 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10923 const dropdown = this._render('dropdown');
10924 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
10925 const classes = this.input.getAttribute('class') || '';
10926 const inputMode = settings.mode;
10927 var control_input;
10928 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
10929 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
10930 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
10931 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
10932 if (settings.copyClassesToDropdown) {
10933 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
10934 }
10935 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
10936 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
10937 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
10938 // default controlInput
10939 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
10940 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10941 // set attributes
10942 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
10943 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
10944 if (input.getAttribute(attr)) {
10945 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
10946 }
10947 });
10948 control_input.tabIndex = -1;
10949 control.appendChild(control_input);
10950 this.focus_node = control_input;
10951 // dom element
10952 }
10953 else if (settings.controlInput) {
10954 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10955 this.focus_node = control_input;
10956 }
10957 else {
10958 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
10959 this.focus_node = control;
10960 }
10961 this.wrapper = wrapper;
10962 this.dropdown = dropdown;
10963 this.dropdown_content = dropdown_content;
10964 this.control = control;
10965 this.control_input = control_input;
10966 this.setup();
10967 }
10968 /**
10969 * set up event bindings.
10970 *
10971 */
10972 setup() {
10973 const self = this;
10974 const settings = self.settings;
10975 const control_input = self.control_input;
10976 const dropdown = self.dropdown;
10977 const dropdown_content = self.dropdown_content;
10978 const wrapper = self.wrapper;
10979 const control = self.control;
10980 const input = self.input;
10981 const focus_node = self.focus_node;
10982 const passive_event = { passive: true };
10983 const listboxId = self.inputId + '-ts-dropdown';
10984 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
10985 id: listboxId
10986 });
10987 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
10988 role: 'combobox',
10989 'aria-haspopup': 'listbox',
10990 'aria-expanded': 'false',
10991 'aria-controls': listboxId
10992 });
10993 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
10994 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
10995 const label = document.querySelector(query);
10996 const label_click = self.focus.bind(self);
10997 if (label) {
10998 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
10999 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
11000 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
11001 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
11002 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11003 }
11004 wrapper.style.width = input.style.width;
11005 if (self.plugins.names.length) {
11006 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11007 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11008 }
11009 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11010 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11011 }
11012 if (settings.placeholder) {
11013 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11014 }
11015 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11016 if (!settings.splitOn && settings.delimiter) {
11017 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11018 }
11019 // debounce user defined load() if loadThrottle > 0
11020 // after initializePlugins() so plugins can create/modify user defined loaders
11021 if (settings.load && settings.loadThrottle) {
11022 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11023 }
11024 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11025 self.ignoreHover = false;
11026 });
11027 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11028 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11029 if (target_match)
11030 self.onOptionHover(e, target_match);
11031 }, { capture: true });
11032 // clicking on an option should select it
11033 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11034 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11035 if (option) {
11036 self.onOptionSelect(evt, option);
11037 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11038 }
11039 });
11040 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11041 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11042 if (target_match && self.onItemSelect(evt, target_match)) {
11043 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11044 return;
11045 }
11046 // retain focus (see control_input mousedown)
11047 if (control_input.value != '') {
11048 return;
11049 }
11050 self.onClick();
11051 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11052 });
11053 // keydown on focus_node for arrow_down/arrow_up
11054 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11055 // keypress and input/keyup
11056 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11057 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11058 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11059 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11060 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11061 const doc_mousedown = (evt) => {
11062 // blur if target is outside of this instance
11063 // dropdown is not always inside wrapper
11064 const target = evt.composedPath()[0];
11065 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11066 if (self.isFocused) {
11067 self.blur();
11068 }
11069 self.inputState();
11070 return;
11071 }
11072 // retain focus by preventing native handling. if the
11073 // event target is the input it should not be modified.
11074 // otherwise, text selection within the input won't work.
11075 // Fixes bug #212 which is no covered by tests
11076 if (target == control_input && self.isOpen) {
11077 evt.stopPropagation();
11078 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11079 }
11080 else {
11081 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11082 }
11083 };
11084 const win_scroll = () => {
11085 if (self.isOpen) {
11086 self.positionDropdown();
11087 }
11088 };
11089 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11090 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11091 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11092 this._destroy = () => {
11093 document.removeEventListener('mousedown', doc_mousedown);
11094 window.removeEventListener('scroll', win_scroll);
11095 window.removeEventListener('resize', win_scroll);
11096 if (label)
11097 label.removeEventListener('click', label_click);
11098 };
11099 // store original html and tab index so that they can be
11100 // restored when the destroy() method is called.
11101 this.revertSettings = {
11102 innerHTML: input.innerHTML,
11103 tabIndex: input.tabIndex
11104 };
11105 input.tabIndex = -1;
11106 input.insertAdjacentElement('afterend', self.wrapper);
11107 self.sync(false);
11108 settings.items = [];
11109 delete settings.optgroups;
11110 delete settings.options;
11111 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
11112 if (self.isValid) {
11113 self.isValid = false;
11114 self.isInvalid = true;
11115 self.refreshState();
11116 }
11117 });
11118 self.updateOriginalInput();
11119 self.refreshItems();
11120 self.close(false);
11121 self.inputState();
11122 self.isSetup = true;
11123 if (input.disabled) {
11124 self.disable();
11125 }
11126 else if (input.readOnly) {
11127 self.setReadOnly(true);
11128 }
11129 else {
11130 self.enable(); //sets tabIndex
11131 }
11132 self.on('change', this.onChange);
11133 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11134 self.trigger('initialize');
11135 // preload options
11136 if (settings.preload === true) {
11137 self.preload();
11138 }
11139 }
11140 /**
11141 * Register options and optgroups
11142 *
11143 */
11144 setupOptions(options = [], optgroups = []) {
11145 // build options table
11146 this.addOptions(options);
11147 // build optgroup table
11148 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11149 this.registerOptionGroup(optgroup);
11150 });
11151 }
11152 /**
11153 * Sets up default rendering functions.
11154 */
11155 setupTemplates() {
11156 var self = this;
11157 var field_label = self.settings.labelField;
11158 var field_optgroup = self.settings.optgroupLabelField;
11159 var templates = {
11160 'optgroup': (data) => {
11161 let optgroup = document.createElement('div');
11162 optgroup.className = 'optgroup';
11163 optgroup.appendChild(data.options);
11164 return optgroup;
11165 },
11166 'optgroup_header': (data, escape) => {
11167 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11168 },
11169 'option': (data, escape) => {
11170 return '<div>' + escape(data[field_label]) + '</div>';
11171 },
11172 'item': (data, escape) => {
11173 return '<div>' + escape(data[field_label]) + '</div>';
11174 },
11175 'option_create': (data, escape) => {
11176 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11177 },
11178 'no_results': () => {
11179 return '<div class="no-results">No results found</div>';
11180 },
11181 'loading': () => {
11182 return '<div class="spinner"></div>';
11183 },
11184 'not_loading': () => { },
11185 'dropdown': () => {
11186 return '<div></div>';
11187 }
11188 };
11189 self.settings.render = Object.assign({}, templates, self.settings.render);
11190 }
11191 /**
11192 * Maps fired events to callbacks provided
11193 * in the settings used when creating the control.
11194 */
11195 setupCallbacks() {
11196 var key, fn;
11197 var callbacks = {
11198 'initialize': 'onInitialize',
11199 'change': 'onChange',
11200 'item_add': 'onItemAdd',
11201 'item_remove': 'onItemRemove',
11202 'item_select': 'onItemSelect',
11203 'clear': 'onClear',
11204 'option_add': 'onOptionAdd',
11205 'option_remove': 'onOptionRemove',
11206 'option_clear': 'onOptionClear',
11207 'optgroup_add': 'onOptionGroupAdd',
11208 'optgroup_remove': 'onOptionGroupRemove',
11209 'optgroup_clear': 'onOptionGroupClear',
11210 'dropdown_open': 'onDropdownOpen',
11211 'dropdown_close': 'onDropdownClose',
11212 'type': 'onType',
11213 'load': 'onLoad',
11214 'focus': 'onFocus',
11215 'blur': 'onBlur'
11216 };
11217 for (key in callbacks) {
11218 fn = this.settings[callbacks[key]];
11219 if (fn)
11220 this.on(key, fn);
11221 }
11222 }
11223 /**
11224 * Sync the Tom Select instance with the original input or select
11225 *
11226 */
11227 sync(get_settings = true) {
11228 const self = this;
11229 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
11230 self.setupOptions(settings.options, settings.optgroups);
11231 self.setValue(settings.items || [], true); // silent prevents recursion
11232 self.lastQuery = null; // so updated options will be displayed in dropdown
11233 }
11234 /**
11235 * Triggered when the main control element
11236 * has a click event.
11237 *
11238 */
11239 onClick() {
11240 var self = this;
11241 if (self.activeItems.length > 0) {
11242 self.clearActiveItems();
11243 self.focus();
11244 return;
11245 }
11246 if (self.isFocused && self.isOpen) {
11247 self.blur();
11248 }
11249 else {
11250 self.focus();
11251 }
11252 }
11253 /**
11254 * @deprecated v1.7
11255 *
11256 */
11257 onMouseDown() { }
11258 /**
11259 * Triggered when the value of the control has been changed.
11260 * This should propagate the event to the original DOM
11261 * input / select element.
11262 */
11263 onChange() {
11264 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11265 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11266 }
11267 /**
11268 * Triggered on <input> paste.
11269 *
11270 */
11271 onPaste(e) {
11272 var self = this;
11273 if (self.isInputHidden || self.isLocked) {
11274 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11275 return;
11276 }
11277 // If a regex or string is included, this will split the pasted
11278 // input and create Items for each separate value
11279 if (!self.settings.splitOn) {
11280 return;
11281 }
11282 // Wait for pasted text to be recognized in value
11283 setTimeout(() => {
11284 var pastedText = self.inputValue();
11285 if (!pastedText.match(self.settings.splitOn)) {
11286 return;
11287 }
11288 var splitInput = pastedText.trim().split(self.settings.splitOn);
11289 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11290 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11291 if (hash) {
11292 if (this.options[piece]) {
11293 self.addItem(piece);
11294 }
11295 else {
11296 self.createItem(piece);
11297 }
11298 }
11299 });
11300 }, 0);
11301 }
11302 /**
11303 * Triggered on <input> keypress.
11304 *
11305 */
11306 onKeyPress(e) {
11307 var self = this;
11308 if (self.isLocked) {
11309 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11310 return;
11311 }
11312 var character = String.fromCharCode(e.keyCode || e.which);
11313 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11314 self.createItem();
11315 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11316 return;
11317 }
11318 }
11319 /**
11320 * Triggered on <input> keydown.
11321 *
11322 */
11323 onKeyDown(e) {
11324 var self = this;
11325 self.ignoreHover = true;
11326 if (self.isLocked) {
11327 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11328 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11329 }
11330 return;
11331 }
11332 switch (e.keyCode) {
11333 // ctrl+A: select all
11334 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11335 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11336 if (self.control_input.value == '') {
11337 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11338 self.selectAll();
11339 return;
11340 }
11341 }
11342 break;
11343 // esc: close dropdown
11344 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11345 if (self.isOpen) {
11346 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11347 self.close();
11348 }
11349 self.clearActiveItems();
11350 return;
11351 // down: open dropdown or move selection down
11352 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11353 if (!self.isOpen && self.hasOptions) {
11354 self.open();
11355 }
11356 else if (self.activeOption) {
11357 let next = self.getAdjacent(self.activeOption, 1);
11358 if (next)
11359 self.setActiveOption(next);
11360 }
11361 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11362 return;
11363 // up: move selection up
11364 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11365 if (self.activeOption) {
11366 let prev = self.getAdjacent(self.activeOption, -1);
11367 if (prev)
11368 self.setActiveOption(prev);
11369 }
11370 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11371 return;
11372 // return: select active option
11373 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11374 if (self.canSelect(self.activeOption)) {
11375 self.onOptionSelect(e, self.activeOption);
11376 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11377 // if the option_create=null, the dropdown might be closed
11378 }
11379 else if (self.settings.create && self.createItem()) {
11380 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11381 // don't submit form when searching for a value
11382 }
11383 else if (document.activeElement == self.control_input && self.isOpen) {
11384 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11385 }
11386 return;
11387 // left: modifiy item selection to the left
11388 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11389 self.advanceSelection(-1, e);
11390 return;
11391 // right: modifiy item selection to the right
11392 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11393 self.advanceSelection(1, e);
11394 return;
11395 // tab: select active option and/or create item
11396 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11397 if (self.settings.selectOnTab) {
11398 if (self.canSelect(self.activeOption)) {
11399 self.onOptionSelect(e, self.activeOption);
11400 // prevent default [tab] behaviour of jump to the next field
11401 // if select isFull, then the dropdown won't be open and [tab] will work normally
11402 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11403 }
11404 if (self.settings.create && self.createItem()) {
11405 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11406 }
11407 }
11408 return;
11409 // delete|backspace: delete items
11410 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11411 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11412 self.deleteSelection(e);
11413 return;
11414 }
11415 // don't enter text in the control_input when active items are selected
11416 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11417 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11418 }
11419 }
11420 /**
11421 * Triggered on <input> keyup.
11422 *
11423 */
11424 onInput(e) {
11425 if (this.isLocked) {
11426 return;
11427 }
11428 const value = this.inputValue();
11429 if (this.lastValue === value)
11430 return;
11431 this.lastValue = value;
11432 if (value == '') {
11433 this._onInput();
11434 return;
11435 }
11436 if (this.refreshTimeout) {
11437 window.clearTimeout(this.refreshTimeout);
11438 }
11439 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11440 this.refreshTimeout = null;
11441 this._onInput();
11442 }, this.settings.refreshThrottle);
11443 }
11444 _onInput() {
11445 const value = this.lastValue;
11446 if (this.settings.shouldLoad.call(this, value)) {
11447 this.load(value);
11448 }
11449 this.refreshOptions();
11450 this.trigger('type', value);
11451 }
11452 /**
11453 * Triggered when the user rolls over
11454 * an option in the autocomplete dropdown menu.
11455 *
11456 */
11457 onOptionHover(evt, option) {
11458 if (this.ignoreHover)
11459 return;
11460 this.setActiveOption(option, false);
11461 }
11462 /**
11463 * Triggered on <input> focus.
11464 *
11465 */
11466 onFocus(e) {
11467 var self = this;
11468 var wasFocused = self.isFocused;
11469 if (self.isDisabled || self.isReadOnly) {
11470 self.blur();
11471 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11472 return;
11473 }
11474 if (self.ignoreFocus)
11475 return;
11476 self.isFocused = true;
11477 if (self.settings.preload === 'focus')
11478 self.preload();
11479 if (!wasFocused)
11480 self.trigger('focus');
11481 if (!self.activeItems.length) {
11482 self.inputState();
11483 self.refreshOptions(!!self.settings.openOnFocus);
11484 }
11485 self.refreshState();
11486 }
11487 /**
11488 * Triggered on <input> blur.
11489 *
11490 */
11491 onBlur(e) {
11492 if (document.hasFocus() === false)
11493 return;
11494 var self = this;
11495 if (!self.isFocused)
11496 return;
11497 self.isFocused = false;
11498 self.ignoreFocus = false;
11499 var deactivate = () => {
11500 self.close();
11501 self.setActiveItem();
11502 self.setCaret(self.items.length);
11503 self.trigger('blur');
11504 };
11505 if (self.settings.create && self.settings.createOnBlur) {
11506 self.createItem(null, deactivate);
11507 }
11508 else {
11509 deactivate();
11510 }
11511 }
11512 /**
11513 * Triggered when the user clicks on an option
11514 * in the autocomplete dropdown menu.
11515 *
11516 */
11517 onOptionSelect(evt, option) {
11518 var value, self = this;
11519 // should not be possible to trigger a option under a disabled optgroup
11520 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
11521 return;
11522 }
11523 if (option.classList.contains('create')) {
11524 self.createItem(null, () => {
11525 if (self.settings.closeAfterSelect) {
11526 self.close();
11527 }
11528 });
11529 }
11530 else {
11531 value = option.dataset.value;
11532 if (typeof value !== 'undefined') {
11533 self.lastQuery = null;
11534 self.addItem(value);
11535 if (self.settings.closeAfterSelect) {
11536 self.close();
11537 }
11538 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
11539 self.setActiveOption(option);
11540 }
11541 }
11542 }
11543 }
11544 /**
11545 * Return true if the given option can be selected
11546 *
11547 */
11548 canSelect(option) {
11549 if (this.isOpen && option && this.dropdown_content.contains(option)) {
11550 return true;
11551 }
11552 return false;
11553 }
11554 /**
11555 * Triggered when the user clicks on an item
11556 * that has been selected.
11557 *
11558 */
11559 onItemSelect(evt, item) {
11560 var self = this;
11561 if (!self.isLocked && self.settings.mode === 'multi') {
11562 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
11563 self.setActiveItem(item, evt);
11564 return true;
11565 }
11566 return false;
11567 }
11568 /**
11569 * Determines whether or not to invoke
11570 * the user-provided option provider / loader
11571 *
11572 * Note, there is a subtle difference between
11573 * this.canLoad() and this.settings.shouldLoad();
11574 *
11575 * - settings.shouldLoad() is a user-input validator.
11576 * When false is returned, the not_loading template
11577 * will be added to the dropdown
11578 *
11579 * - canLoad() is lower level validator that checks
11580 * the Tom Select instance. There is no inherent user
11581 * feedback when canLoad returns false
11582 *
11583 */
11584 canLoad(value) {
11585 if (!this.settings.load)
11586 return false;
11587 if (this.loadedSearches.hasOwnProperty(value))
11588 return false;
11589 return true;
11590 }
11591 /**
11592 * Invokes the user-provided option provider / loader.
11593 *
11594 */
11595 load(value) {
11596 const self = this;
11597 if (!self.canLoad(value))
11598 return;
11599 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
11600 self.loading++;
11601 const callback = self.loadCallback.bind(self);
11602 self.settings.load.call(self, value, callback);
11603 }
11604 /**
11605 * Invoked by the user-provided option provider
11606 *
11607 */
11608 loadCallback(options, optgroups) {
11609 const self = this;
11610 self.loading = Math.max(self.loading - 1, 0);
11611 self.lastQuery = null;
11612 self.clearActiveOption(); // when new results load, focus should be on first option
11613 self.setupOptions(options, optgroups);
11614 self.refreshOptions(self.isFocused && !self.isInputHidden);
11615 if (!self.loading) {
11616 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
11617 }
11618 self.trigger('load', options, optgroups);
11619 }
11620 preload() {
11621 var classList = this.wrapper.classList;
11622 if (classList.contains('preloaded'))
11623 return;
11624 classList.add('preloaded');
11625 this.load('');
11626 }
11627 /**
11628 * Sets the input field of the control to the specified value.
11629 *
11630 */
11631 setTextboxValue(value = '') {
11632 var input = this.control_input;
11633 var changed = input.value !== value;
11634 if (changed) {
11635 input.value = value;
11636 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
11637 this.lastValue = value;
11638 }
11639 }
11640 /**
11641 * Returns the value of the control. If multiple items
11642 * can be selected (e.g. <select multiple>), this returns
11643 * an array. If only one item can be selected, this
11644 * returns a string.
11645 *
11646 */
11647 getValue() {
11648 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
11649 return this.items;
11650 }
11651 return this.items.join(this.settings.delimiter);
11652 }
11653 /**
11654 * Resets the selected items to the given value.
11655 *
11656 */
11657 setValue(value, silent) {
11658 var events = silent ? [] : ['change'];
11659 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
11660 this.clear(silent);
11661 this.addItems(value, silent);
11662 });
11663 }
11664 /**
11665 * Resets the number of max items to the given value
11666 *
11667 */
11668 setMaxItems(value) {
11669 if (value === 0)
11670 value = null; //reset to unlimited items.
11671 this.settings.maxItems = value;
11672 this.refreshState();
11673 }
11674 /**
11675 * Sets the selected item.
11676 *
11677 */
11678 setActiveItem(item, e) {
11679 var self = this;
11680 var eventName;
11681 var i, begin, end, swap;
11682 var last;
11683 if (self.settings.mode === 'single')
11684 return;
11685 // clear the active selection
11686 if (!item) {
11687 self.clearActiveItems();
11688 if (self.isFocused) {
11689 self.inputState();
11690 }
11691 return;
11692 }
11693 // modify selection
11694 eventName = e && e.type.toLowerCase();
11695 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
11696 last = self.getLastActive();
11697 begin = Array.prototype.indexOf.call(self.control.children, last);
11698 end = Array.prototype.indexOf.call(self.control.children, item);
11699 if (begin > end) {
11700 swap = begin;
11701 begin = end;
11702 end = swap;
11703 }
11704 for (i = begin; i <= end; i++) {
11705 item = self.control.children[i];
11706 if (self.activeItems.indexOf(item) === -1) {
11707 self.setActiveItemClass(item);
11708 }
11709 }
11710 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11711 }
11712 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))) {
11713 if (item.classList.contains('active')) {
11714 self.removeActiveItem(item);
11715 }
11716 else {
11717 self.setActiveItemClass(item);
11718 }
11719 }
11720 else {
11721 self.clearActiveItems();
11722 self.setActiveItemClass(item);
11723 }
11724 // ensure control has focus
11725 self.inputState();
11726 if (!self.isFocused) {
11727 self.focus();
11728 }
11729 }
11730 /**
11731 * Set the active and last-active classes
11732 *
11733 */
11734 setActiveItemClass(item) {
11735 const self = this;
11736 const last_active = self.control.querySelector('.last-active');
11737 if (last_active)
11738 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
11739 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
11740 self.trigger('item_select', item);
11741 if (self.activeItems.indexOf(item) == -1) {
11742 self.activeItems.push(item);
11743 }
11744 }
11745 /**
11746 * Remove active item
11747 *
11748 */
11749 removeActiveItem(item) {
11750 var idx = this.activeItems.indexOf(item);
11751 this.activeItems.splice(idx, 1);
11752 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
11753 }
11754 /**
11755 * Clears all the active items
11756 *
11757 */
11758 clearActiveItems() {
11759 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
11760 this.activeItems = [];
11761 }
11762 /**
11763 * Sets the selected item in the dropdown menu
11764 * of available options.
11765 *
11766 */
11767 setActiveOption(option, scroll = true) {
11768 if (option === this.activeOption) {
11769 return;
11770 }
11771 this.clearActiveOption();
11772 if (!option)
11773 return;
11774 this.activeOption = option;
11775 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
11776 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
11777 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
11778 if (scroll)
11779 this.scrollToOption(option);
11780 }
11781 /**
11782 * Sets the dropdown_content scrollTop to display the option
11783 *
11784 */
11785 scrollToOption(option, behavior) {
11786 if (!option)
11787 return;
11788 const content = this.dropdown_content;
11789 const height_menu = content.clientHeight;
11790 const scrollTop = content.scrollTop || 0;
11791 const height_item = option.offsetHeight;
11792 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
11793 if (y + height_item > height_menu + scrollTop) {
11794 this.scroll(y - height_menu + height_item, behavior);
11795 }
11796 else if (y < scrollTop) {
11797 this.scroll(y, behavior);
11798 }
11799 }
11800 /**
11801 * Scroll the dropdown to the given position
11802 *
11803 */
11804 scroll(scrollTop, behavior) {
11805 const content = this.dropdown_content;
11806 if (behavior) {
11807 content.style.scrollBehavior = behavior;
11808 }
11809 content.scrollTop = scrollTop;
11810 content.style.scrollBehavior = '';
11811 }
11812 /**
11813 * Clears the active option
11814 *
11815 */
11816 clearActiveOption() {
11817 if (this.activeOption) {
11818 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
11819 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
11820 }
11821 this.activeOption = null;
11822 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
11823 }
11824 /**
11825 * Selects all items (CTRL + A).
11826 */
11827 selectAll() {
11828 const self = this;
11829 if (self.settings.mode === 'single')
11830 return;
11831 const activeItems = self.controlChildren();
11832 if (!activeItems.length)
11833 return;
11834 self.inputState();
11835 self.close();
11836 self.activeItems = activeItems;
11837 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
11838 self.setActiveItemClass(item);
11839 });
11840 }
11841 /**
11842 * Determines if the control_input should be in a hidden or visible state
11843 *
11844 */
11845 inputState() {
11846 var self = this;
11847 if (!self.control.contains(self.control_input))
11848 return;
11849 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
11850 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
11851 self.setTextboxValue();
11852 self.isInputHidden = true;
11853 }
11854 else {
11855 if (self.settings.hidePlaceholder && self.items.length > 0) {
11856 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
11857 }
11858 self.isInputHidden = false;
11859 }
11860 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
11861 }
11862 /**
11863 * Get the input value
11864 */
11865 inputValue() {
11866 return this.control_input.value.trim();
11867 }
11868 /**
11869 * Gives the control focus.
11870 */
11871 focus() {
11872 var self = this;
11873 if (self.isDisabled || self.isReadOnly)
11874 return;
11875 self.ignoreFocus = true;
11876 if (self.control_input.offsetWidth) {
11877 self.control_input.focus();
11878 }
11879 else {
11880 self.focus_node.focus();
11881 }
11882 setTimeout(() => {
11883 self.ignoreFocus = false;
11884 self.onFocus();
11885 }, 0);
11886 }
11887 /**
11888 * Forces the control out of focus.
11889 *
11890 */
11891 blur() {
11892 this.focus_node.blur();
11893 this.onBlur();
11894 }
11895 /**
11896 * Returns a function that scores an object
11897 * to show how good of a match it is to the
11898 * provided query.
11899 *
11900 * @return {function}
11901 */
11902 getScoreFunction(query) {
11903 return this.sifter.getScoreFunction(query, this.getSearchOptions());
11904 }
11905 /**
11906 * Returns search options for sifter (the system
11907 * for scoring and sorting results).
11908 *
11909 * @see https://github.com/orchidjs/sifter.js
11910 * @return {object}
11911 */
11912 getSearchOptions() {
11913 var settings = this.settings;
11914 var sort = settings.sortField;
11915 if (typeof settings.sortField === 'string') {
11916 sort = [{ field: settings.sortField }];
11917 }
11918 return {
11919 fields: settings.searchField,
11920 conjunction: settings.searchConjunction,
11921 sort: sort,
11922 nesting: settings.nesting
11923 };
11924 }
11925 /**
11926 * Searches through available options and returns
11927 * a sorted array of matches.
11928 *
11929 */
11930 search(query) {
11931 var result, calculateScore;
11932 var self = this;
11933 var options = this.getSearchOptions();
11934 // validate user-provided result scoring function
11935 if (self.settings.score) {
11936 calculateScore = self.settings.score.call(self, query);
11937 if (typeof calculateScore !== 'function') {
11938 throw new Error('Tom Select "score" setting must be a function that returns a function');
11939 }
11940 }
11941 // perform search
11942 if (query !== self.lastQuery) {
11943 self.lastQuery = query;
11944 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
11945 self.currentResults = result;
11946 }
11947 else {
11948 result = Object.assign({}, self.currentResults);
11949 }
11950 // filter out selected items
11951 if (self.settings.hideSelected) {
11952 result.items = result.items.filter((item) => {
11953 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
11954 return !(hashed && self.items.indexOf(hashed) !== -1);
11955 });
11956 }
11957 return result;
11958 }
11959 /**
11960 * Refreshes the list of available options shown
11961 * in the autocomplete dropdown menu.
11962 *
11963 */
11964 refreshOptions(triggerDropdown = true) {
11965 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
11966 var create;
11967 const groups = {};
11968 const groups_order = [];
11969 var self = this;
11970 var query = self.inputValue();
11971 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
11972 var results = self.search(query);
11973 var active_option = null;
11974 var show_dropdown = self.settings.shouldOpen || false;
11975 var dropdown_content = self.dropdown_content;
11976 if (same_query) {
11977 active_option = self.activeOption;
11978 if (active_option) {
11979 active_group = active_option.closest('[data-group]');
11980 }
11981 }
11982 // build markup
11983 n = results.items.length;
11984 if (typeof self.settings.maxOptions === 'number') {
11985 n = Math.min(n, self.settings.maxOptions);
11986 }
11987 if (n > 0) {
11988 show_dropdown = true;
11989 }
11990 // get fragment for group and the position of the group in group_order
11991 const getGroupFragment = (optgroup, order) => {
11992 let group_order_i = groups[optgroup];
11993 if (group_order_i !== undefined) {
11994 let order_group = groups_order[group_order_i];
11995 if (order_group !== undefined) {
11996 return [group_order_i, order_group.fragment];
11997 }
11998 }
11999 let group_fragment = document.createDocumentFragment();
12000 group_order_i = groups_order.length;
12001 groups_order.push({ fragment: group_fragment, order, optgroup });
12002 return [group_order_i, group_fragment];
12003 };
12004 // render and group available options individually
12005 for (i = 0; i < n; i++) {
12006 // get option dom element
12007 let item = results.items[i];
12008 if (!item)
12009 continue;
12010 let opt_value = item.id;
12011 let option = self.options[opt_value];
12012 if (option === undefined)
12013 continue;
12014 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12015 let option_el = self.getOption(opt_hash, true);
12016 // toggle 'selected' class
12017 if (!self.settings.hideSelected) {
12018 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12019 }
12020 optgroup = option[self.settings.optgroupField] || '';
12021 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12022 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12023 optgroup = optgroups[j];
12024 let order = option.$order;
12025 let self_optgroup = self.optgroups[optgroup];
12026 if (self_optgroup === undefined) {
12027 optgroup = '';
12028 }
12029 else {
12030 order = self_optgroup.$order;
12031 }
12032 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12033 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12034 if (j > 0) {
12035 option_el = option_el.cloneNode(true);
12036 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12037 option_el.classList.add('ts-cloned');
12038 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12039 // make sure we keep the activeOption in the same group
12040 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12041 if (active_group && active_group.dataset.group === optgroup.toString()) {
12042 active_option = option_el;
12043 }
12044 }
12045 }
12046 group_fragment.appendChild(option_el);
12047 if (optgroup != '') {
12048 groups[optgroup] = group_order_i;
12049 }
12050 }
12051 }
12052 // sort optgroups
12053 if (self.settings.lockOptgroupOrder) {
12054 groups_order.sort((a, b) => {
12055 return a.order - b.order;
12056 });
12057 }
12058 // render optgroup headers & join groups
12059 html = document.createDocumentFragment();
12060 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12061 let group_fragment = group_order.fragment;
12062 let optgroup = group_order.optgroup;
12063 if (!group_fragment || !group_fragment.children.length)
12064 return;
12065 let group_heading = self.optgroups[optgroup];
12066 if (group_heading !== undefined) {
12067 let group_options = document.createDocumentFragment();
12068 let header = self.render('optgroup_header', group_heading);
12069 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12070 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12071 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12072 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12073 }
12074 else {
12075 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12076 }
12077 });
12078 dropdown_content.innerHTML = '';
12079 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12080 // highlight matching terms inline
12081 if (self.settings.highlight) {
12082 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12083 if (results.query.length && results.tokens.length) {
12084 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12085 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12086 });
12087 }
12088 }
12089 // helper method for adding templates to dropdown
12090 var add_template = (template) => {
12091 let content = self.render(template, { input: query });
12092 if (content) {
12093 show_dropdown = true;
12094 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12095 }
12096 return content;
12097 };
12098 // add loading message
12099 if (self.loading) {
12100 add_template('loading');
12101 // invalid query
12102 }
12103 else if (!self.settings.shouldLoad.call(self, query)) {
12104 add_template('not_loading');
12105 // add no_results message
12106 }
12107 else if (results.items.length === 0) {
12108 add_template('no_results');
12109 }
12110 // add create option
12111 has_create_option = self.canCreate(query);
12112 if (has_create_option) {
12113 create = add_template('option_create');
12114 }
12115 // activate
12116 self.hasOptions = results.items.length > 0 || has_create_option;
12117 if (show_dropdown) {
12118 if (results.items.length > 0) {
12119 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12120 active_option = self.getOption(self.items[0]);
12121 }
12122 if (!dropdown_content.contains(active_option)) {
12123 let active_index = 0;
12124 if (create && !self.settings.addPrecedence) {
12125 active_index = 1;
12126 }
12127 active_option = self.selectable()[active_index];
12128 }
12129 }
12130 else if (create) {
12131 active_option = create;
12132 }
12133 if (triggerDropdown && !self.isOpen) {
12134 self.open();
12135 self.scrollToOption(active_option, 'auto');
12136 }
12137 self.setActiveOption(active_option);
12138 }
12139 else {
12140 self.clearActiveOption();
12141 if (triggerDropdown && self.isOpen) {
12142 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12143 }
12144 }
12145 }
12146 /**
12147 * Return list of selectable options
12148 *
12149 */
12150 selectable() {
12151 return this.dropdown_content.querySelectorAll('[data-selectable]');
12152 }
12153 /**
12154 * Adds an available option. If it already exists,
12155 * nothing will happen. Note: this does not refresh
12156 * the options list dropdown (use `refreshOptions`
12157 * for that).
12158 *
12159 * Usage:
12160 *
12161 * this.addOption(data)
12162 *
12163 */
12164 addOption(data, user_created = false) {
12165 const self = this;
12166 // @deprecated 1.7.7
12167 // use addOptions( array, user_created ) for adding multiple options
12168 if (Array.isArray(data)) {
12169 self.addOptions(data, user_created);
12170 return false;
12171 }
12172 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12173 if (key === null || self.options.hasOwnProperty(key)) {
12174 return false;
12175 }
12176 data.$order = data.$order || ++self.order;
12177 data.$id = self.inputId + '-opt-' + data.$order;
12178 self.options[key] = data;
12179 self.lastQuery = null;
12180 if (user_created) {
12181 self.userOptions[key] = user_created;
12182 self.trigger('option_add', key, data);
12183 }
12184 return key;
12185 }
12186 /**
12187 * Add multiple options
12188 *
12189 */
12190 addOptions(data, user_created = false) {
12191 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12192 this.addOption(dat, user_created);
12193 });
12194 }
12195 /**
12196 * @deprecated 1.7.7
12197 */
12198 registerOption(data) {
12199 return this.addOption(data);
12200 }
12201 /**
12202 * Registers an option group to the pool of option groups.
12203 *
12204 * @return {boolean|string}
12205 */
12206 registerOptionGroup(data) {
12207 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12208 if (key === null)
12209 return false;
12210 data.$order = data.$order || ++this.order;
12211 this.optgroups[key] = data;
12212 return key;
12213 }
12214 /**
12215 * Registers a new optgroup for options
12216 * to be bucketed into.
12217 *
12218 */
12219 addOptionGroup(id, data) {
12220 var hashed_id;
12221 data[this.settings.optgroupValueField] = id;
12222 if (hashed_id = this.registerOptionGroup(data)) {
12223 this.trigger('optgroup_add', hashed_id, data);
12224 }
12225 }
12226 /**
12227 * Removes an existing option group.
12228 *
12229 */
12230 removeOptionGroup(id) {
12231 if (this.optgroups.hasOwnProperty(id)) {
12232 delete this.optgroups[id];
12233 this.clearCache();
12234 this.trigger('optgroup_remove', id);
12235 }
12236 }
12237 /**
12238 * Clears all existing option groups.
12239 */
12240 clearOptionGroups() {
12241 this.optgroups = {};
12242 this.clearCache();
12243 this.trigger('optgroup_clear');
12244 }
12245 /**
12246 * Updates an option available for selection. If
12247 * it is visible in the selected items or options
12248 * dropdown, it will be re-rendered automatically.
12249 *
12250 */
12251 updateOption(value, data) {
12252 const self = this;
12253 var item_new;
12254 var index_item;
12255 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12256 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12257 // sanity checks
12258 if (value_old === null)
12259 return;
12260 const data_old = self.options[value_old];
12261 if (data_old == undefined)
12262 return;
12263 if (typeof value_new !== 'string')
12264 throw new Error('Value must be set in option data');
12265 const option = self.getOption(value_old);
12266 const item = self.getItem(value_old);
12267 data.$order = data.$order || data_old.$order;
12268 delete self.options[value_old];
12269 // invalidate render cache
12270 // don't remove existing node yet, we'll remove it after replacing it
12271 self.uncacheValue(value_new);
12272 self.options[value_new] = data;
12273 // update the option if it's in the dropdown
12274 if (option) {
12275 if (self.dropdown_content.contains(option)) {
12276 const option_new = self._render('option', data);
12277 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12278 if (self.activeOption === option) {
12279 self.setActiveOption(option_new);
12280 }
12281 }
12282 option.remove();
12283 }
12284 // update the item if we have one
12285 if (item) {
12286 index_item = self.items.indexOf(value_old);
12287 if (index_item !== -1) {
12288 self.items.splice(index_item, 1, value_new);
12289 }
12290 item_new = self._render('item', data);
12291 if (item.classList.contains('active'))
12292 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12293 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12294 }
12295 // invalidate last query because we might have updated the sortField
12296 self.lastQuery = null;
12297 }
12298 /**
12299 * Removes a single option.
12300 *
12301 */
12302 removeOption(value, silent) {
12303 const self = this;
12304 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12305 self.uncacheValue(value);
12306 delete self.userOptions[value];
12307 delete self.options[value];
12308 self.lastQuery = null;
12309 self.trigger('option_remove', value);
12310 self.removeItem(value, silent);
12311 }
12312 /**
12313 * Clears all options.
12314 */
12315 clearOptions(filter) {
12316 const boundFilter = (filter || this.clearFilter).bind(this);
12317 this.loadedSearches = {};
12318 this.userOptions = {};
12319 this.clearCache();
12320 const selected = {};
12321 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12322 if (boundFilter(option, key)) {
12323 selected[key] = option;
12324 }
12325 });
12326 this.options = this.sifter.items = selected;
12327 this.lastQuery = null;
12328 this.trigger('option_clear');
12329 }
12330 /**
12331 * Used by clearOptions() to decide whether or not an option should be removed
12332 * Return true to keep an option, false to remove
12333 *
12334 */
12335 clearFilter(option, value) {
12336 if (this.items.indexOf(value) >= 0) {
12337 return true;
12338 }
12339 return false;
12340 }
12341 /**
12342 * Returns the dom element of the option
12343 * matching the given value.
12344 *
12345 */
12346 getOption(value, create = false) {
12347 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12348 if (hashed === null)
12349 return null;
12350 const option = this.options[hashed];
12351 if (option != undefined) {
12352 if (option.$div) {
12353 return option.$div;
12354 }
12355 if (create) {
12356 return this._render('option', option);
12357 }
12358 }
12359 return null;
12360 }
12361 /**
12362 * Returns the dom element of the next or previous dom element of the same type
12363 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12364 *
12365 */
12366 getAdjacent(option, direction, type = 'option') {
12367 var self = this, all;
12368 if (!option) {
12369 return null;
12370 }
12371 if (type == 'item') {
12372 all = self.controlChildren();
12373 }
12374 else {
12375 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12376 }
12377 for (let i = 0; i < all.length; i++) {
12378 if (all[i] != option) {
12379 continue;
12380 }
12381 if (direction > 0) {
12382 return all[i + 1];
12383 }
12384 return all[i - 1];
12385 }
12386 return null;
12387 }
12388 /**
12389 * Returns the dom element of the item
12390 * matching the given value.
12391 *
12392 */
12393 getItem(item) {
12394 if (typeof item == 'object') {
12395 return item;
12396 }
12397 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12398 return value !== null
12399 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12400 : null;
12401 }
12402 /**
12403 * "Selects" multiple items at once. Adds them to the list
12404 * at the current caret position.
12405 *
12406 */
12407 addItems(values, silent) {
12408 var self = this;
12409 var items = Array.isArray(values) ? values : [values];
12410 items = items.filter(x => self.items.indexOf(x) === -1);
12411 const last_item = items[items.length - 1];
12412 items.forEach(item => {
12413 self.isPending = (item !== last_item);
12414 self.addItem(item, silent);
12415 });
12416 }
12417 /**
12418 * "Selects" an item. Adds it to the list
12419 * at the current caret position.
12420 *
12421 */
12422 addItem(value, silent) {
12423 var events = silent ? [] : ['change', 'dropdown_close'];
12424 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12425 var item, wasFull;
12426 const self = this;
12427 const inputMode = self.settings.mode;
12428 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12429 if (hashed && self.items.indexOf(hashed) !== -1) {
12430 if (inputMode === 'single') {
12431 self.close();
12432 }
12433 if (inputMode === 'single' || !self.settings.duplicates) {
12434 return;
12435 }
12436 }
12437 if (hashed === null || !self.options.hasOwnProperty(hashed))
12438 return;
12439 if (inputMode === 'single')
12440 self.clear(silent);
12441 if (inputMode === 'multi' && self.isFull())
12442 return;
12443 item = self._render('item', self.options[hashed]);
12444 if (self.control.contains(item)) { // duplicates
12445 item = item.cloneNode(true);
12446 }
12447 wasFull = self.isFull();
12448 self.items.splice(self.caretPos, 0, hashed);
12449 self.insertAtCaret(item);
12450 if (self.isSetup) {
12451 // update menu / remove the option (if this is not one item being added as part of series)
12452 if (!self.isPending && self.settings.hideSelected) {
12453 let option = self.getOption(hashed);
12454 let next = self.getAdjacent(option, 1);
12455 if (next) {
12456 self.setActiveOption(next);
12457 }
12458 }
12459 // refreshOptions after setActiveOption(),
12460 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12461 if (!self.isPending && !self.settings.closeAfterSelect) {
12462 self.refreshOptions(self.isFocused && inputMode !== 'single');
12463 }
12464 // hide the menu if the maximum number of items have been selected or no options are left
12465 if (self.settings.closeAfterSelect != false && self.isFull()) {
12466 self.close();
12467 }
12468 else if (!self.isPending) {
12469 self.positionDropdown();
12470 }
12471 self.trigger('item_add', hashed, item);
12472 if (!self.isPending) {
12473 self.updateOriginalInput({ silent: silent });
12474 }
12475 }
12476 if (!self.isPending || (!wasFull && self.isFull())) {
12477 self.inputState();
12478 self.refreshState();
12479 }
12480 });
12481 }
12482 /**
12483 * Removes the selected item matching
12484 * the provided value.
12485 *
12486 */
12487 removeItem(item = null, silent) {
12488 const self = this;
12489 item = self.getItem(item);
12490 if (!item)
12491 return;
12492 var i, idx;
12493 const value = item.dataset.value;
12494 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
12495 item.remove();
12496 if (item.classList.contains('active')) {
12497 idx = self.activeItems.indexOf(item);
12498 self.activeItems.splice(idx, 1);
12499 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12500 }
12501 self.items.splice(i, 1);
12502 self.lastQuery = null;
12503 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
12504 self.removeOption(value, silent);
12505 }
12506 if (i < self.caretPos) {
12507 self.setCaret(self.caretPos - 1);
12508 }
12509 self.updateOriginalInput({ silent: silent });
12510 self.refreshState();
12511 self.positionDropdown();
12512 self.trigger('item_remove', value, item);
12513 }
12514 /**
12515 * Invokes the `create` method provided in the
12516 * TomSelect options that should provide the data
12517 * for the new item, given the user input.
12518 *
12519 * Once this completes, it will be added
12520 * to the item list.
12521 *
12522 */
12523 createItem(input = null, callback = () => { }) {
12524 // triggerDropdown parameter @deprecated 2.1.1
12525 if (arguments.length === 3) {
12526 callback = arguments[2];
12527 }
12528 if (typeof callback != 'function') {
12529 callback = () => { };
12530 }
12531 var self = this;
12532 var caret = self.caretPos;
12533 var output;
12534 input = input || self.inputValue();
12535 if (!self.canCreate(input)) {
12536 callback();
12537 return false;
12538 }
12539 self.lock();
12540 var created = false;
12541 var create = (data) => {
12542 self.unlock();
12543 if (!data || typeof data !== 'object')
12544 return callback();
12545 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12546 if (typeof value !== 'string') {
12547 return callback();
12548 }
12549 self.setTextboxValue();
12550 self.addOption(data, true);
12551 self.setCaret(caret);
12552 self.addItem(value);
12553 callback(data);
12554 created = true;
12555 };
12556 if (typeof self.settings.create === 'function') {
12557 output = self.settings.create.call(this, input, create);
12558 }
12559 else {
12560 output = {
12561 [self.settings.labelField]: input,
12562 [self.settings.valueField]: input,
12563 };
12564 }
12565 if (!created) {
12566 create(output);
12567 }
12568 return true;
12569 }
12570 /**
12571 * Re-renders the selected item lists.
12572 */
12573 refreshItems() {
12574 var self = this;
12575 self.lastQuery = null;
12576 if (self.isSetup) {
12577 self.addItems(self.items);
12578 }
12579 self.updateOriginalInput();
12580 self.refreshState();
12581 }
12582 /**
12583 * Updates all state-dependent attributes
12584 * and CSS classes.
12585 */
12586 refreshState() {
12587 const self = this;
12588 self.refreshValidityState();
12589 const isFull = self.isFull();
12590 const isLocked = self.isLocked;
12591 self.wrapper.classList.toggle('rtl', self.rtl);
12592 const wrap_classList = self.wrapper.classList;
12593 wrap_classList.toggle('focus', self.isFocused);
12594 wrap_classList.toggle('disabled', self.isDisabled);
12595 wrap_classList.toggle('readonly', self.isReadOnly);
12596 wrap_classList.toggle('required', self.isRequired);
12597 wrap_classList.toggle('invalid', !self.isValid);
12598 wrap_classList.toggle('locked', isLocked);
12599 wrap_classList.toggle('full', isFull);
12600 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
12601 wrap_classList.toggle('dropdown-active', self.isOpen);
12602 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
12603 wrap_classList.toggle('has-items', self.items.length > 0);
12604 }
12605 /**
12606 * Update the `required` attribute of both input and control input.
12607 *
12608 * The `required` property needs to be activated on the control input
12609 * for the error to be displayed at the right place. `required` also
12610 * needs to be temporarily deactivated on the input since the input is
12611 * hidden and can't show errors.
12612 */
12613 refreshValidityState() {
12614 var self = this;
12615 if (!self.input.validity) {
12616 return;
12617 }
12618 self.isValid = self.input.validity.valid;
12619 self.isInvalid = !self.isValid;
12620 }
12621 /**
12622 * Determines whether or not more items can be added
12623 * to the control without exceeding the user-defined maximum.
12624 *
12625 * @returns {boolean}
12626 */
12627 isFull() {
12628 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
12629 }
12630 /**
12631 * Refreshes the original <select> or <input>
12632 * element to reflect the current state.
12633 *
12634 */
12635 updateOriginalInput(opts = {}) {
12636 const self = this;
12637 var option, label;
12638 const empty_option = self.input.querySelector('option[value=""]');
12639 if (self.is_select_tag) {
12640 const selected = [];
12641 const has_selected = self.input.querySelectorAll('option:checked').length;
12642 function AddSelected(option_el, value, label) {
12643 if (!option_el) {
12644 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>');
12645 }
12646 // don't move empty option from top of list
12647 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
12648 if (option_el != empty_option) {
12649 self.input.append(option_el);
12650 }
12651 selected.push(option_el);
12652 // marking empty option as selected can break validation
12653 // fixes https://github.com/orchidjs/tom-select/issues/303
12654 if (option_el != empty_option || has_selected > 0) {
12655 option_el.selected = true;
12656 }
12657 return option_el;
12658 }
12659 // unselect all selected options
12660 self.input.querySelectorAll('option:checked').forEach((option_el) => {
12661 option_el.selected = false;
12662 });
12663 // nothing selected?
12664 if (self.items.length == 0 && self.settings.mode == 'single') {
12665 AddSelected(empty_option, "", "");
12666 // order selected <option> tags for values in self.items
12667 }
12668 else {
12669 self.items.forEach((value) => {
12670 option = self.options[value];
12671 label = option[self.settings.labelField] || '';
12672 if (selected.includes(option.$option)) {
12673 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
12674 AddSelected(reuse_opt, value, label);
12675 }
12676 else {
12677 option.$option = AddSelected(option.$option, value, label);
12678 }
12679 });
12680 }
12681 }
12682 else {
12683 self.input.value = self.getValue();
12684 }
12685 if (self.isSetup) {
12686 if (!opts.silent) {
12687 self.trigger('change', self.getValue());
12688 }
12689 }
12690 }
12691 /**
12692 * Shows the autocomplete dropdown containing
12693 * the available options.
12694 */
12695 open() {
12696 var self = this;
12697 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
12698 return;
12699 self.isOpen = true;
12700 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
12701 self.refreshState();
12702 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
12703 self.positionDropdown();
12704 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
12705 self.focus();
12706 self.trigger('dropdown_open', self.dropdown);
12707 }
12708 /**
12709 * Closes the autocomplete dropdown menu.
12710 */
12711 close(setTextboxValue = true) {
12712 var self = this;
12713 var trigger = self.isOpen;
12714 if (setTextboxValue) {
12715 // before blur() to prevent form onchange event
12716 self.setTextboxValue();
12717 if (self.settings.mode === 'single' && self.items.length) {
12718 self.inputState();
12719 }
12720 }
12721 self.isOpen = false;
12722 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
12723 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
12724 if (self.settings.hideSelected) {
12725 self.clearActiveOption();
12726 }
12727 self.refreshState();
12728 if (trigger)
12729 self.trigger('dropdown_close', self.dropdown);
12730 }
12731 /**
12732 * Calculates and applies the appropriate
12733 * position of the dropdown if dropdownParent = 'body'.
12734 * Otherwise, position is determined by css
12735 */
12736 positionDropdown() {
12737 if (this.settings.dropdownParent !== 'body') {
12738 return;
12739 }
12740 var context = this.control;
12741 var rect = context.getBoundingClientRect();
12742 var top = context.offsetHeight + rect.top + window.scrollY;
12743 var left = rect.left + window.scrollX;
12744 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
12745 width: rect.width + 'px',
12746 top: top + 'px',
12747 left: left + 'px'
12748 });
12749 }
12750 /**
12751 * Resets / clears all selected items
12752 * from the control.
12753 *
12754 */
12755 clear(silent) {
12756 var self = this;
12757 if (!self.items.length)
12758 return;
12759 var items = self.controlChildren();
12760 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
12761 self.removeItem(item, true);
12762 });
12763 self.inputState();
12764 if (!silent)
12765 self.updateOriginalInput();
12766 self.trigger('clear');
12767 }
12768 /**
12769 * A helper method for inserting an element
12770 * at the current caret position.
12771 *
12772 */
12773 insertAtCaret(el) {
12774 const self = this;
12775 const caret = self.caretPos;
12776 const target = self.control;
12777 target.insertBefore(el, target.children[caret] || null);
12778 self.setCaret(caret + 1);
12779 }
12780 /**
12781 * Removes the current selected item(s).
12782 *
12783 */
12784 deleteSelection(e) {
12785 var direction, selection, caret, tail;
12786 var self = this;
12787 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
12788 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
12789 // determine items that will be removed
12790 const rm_items = [];
12791 if (self.activeItems.length) {
12792 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
12793 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
12794 if (direction > 0) {
12795 caret++;
12796 }
12797 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
12798 }
12799 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
12800 const items = self.controlChildren();
12801 let rm_item;
12802 if (direction < 0 && selection.start === 0 && selection.length === 0) {
12803 rm_item = items[self.caretPos - 1];
12804 }
12805 else if (direction > 0 && selection.start === self.inputValue().length) {
12806 rm_item = items[self.caretPos];
12807 }
12808 if (rm_item !== undefined) {
12809 rm_items.push(rm_item);
12810 }
12811 }
12812 if (!self.shouldDelete(rm_items, e)) {
12813 return false;
12814 }
12815 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
12816 // perform removal
12817 if (typeof caret !== 'undefined') {
12818 self.setCaret(caret);
12819 }
12820 while (rm_items.length) {
12821 self.removeItem(rm_items.pop());
12822 }
12823 self.inputState();
12824 self.positionDropdown();
12825 self.refreshOptions(false);
12826 return true;
12827 }
12828 /**
12829 * Return true if the items should be deleted
12830 */
12831 shouldDelete(items, evt) {
12832 const values = items.map(item => item.dataset.value);
12833 // allow the callback to abort
12834 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
12835 return false;
12836 }
12837 return true;
12838 }
12839 /**
12840 * Selects the previous / next item (depending on the `direction` argument).
12841 *
12842 * > 0 - right
12843 * < 0 - left
12844 *
12845 */
12846 advanceSelection(direction, e) {
12847 var last_active, adjacent, self = this;
12848 if (self.rtl)
12849 direction *= -1;
12850 if (self.inputValue().length)
12851 return;
12852 // add or remove to active items
12853 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)) {
12854 last_active = self.getLastActive(direction);
12855 if (last_active) {
12856 if (!last_active.classList.contains('active')) {
12857 adjacent = last_active;
12858 }
12859 else {
12860 adjacent = self.getAdjacent(last_active, direction, 'item');
12861 }
12862 // if no active item, get items adjacent to the control input
12863 }
12864 else if (direction > 0) {
12865 adjacent = self.control_input.nextElementSibling;
12866 }
12867 else {
12868 adjacent = self.control_input.previousElementSibling;
12869 }
12870 if (adjacent) {
12871 if (adjacent.classList.contains('active')) {
12872 self.removeActiveItem(last_active);
12873 }
12874 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
12875 }
12876 // move caret to the left or right
12877 }
12878 else {
12879 self.moveCaret(direction);
12880 }
12881 }
12882 moveCaret(direction) { }
12883 /**
12884 * Get the last active item
12885 *
12886 */
12887 getLastActive(direction) {
12888 let last_active = this.control.querySelector('.last-active');
12889 if (last_active) {
12890 return last_active;
12891 }
12892 var result = this.control.querySelectorAll('.active');
12893 if (result) {
12894 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
12895 }
12896 }
12897 /**
12898 * Moves the caret to the specified index.
12899 *
12900 * The input must be moved by leaving it in place and moving the
12901 * siblings, due to the fact that focus cannot be restored once lost
12902 * on mobile webkit devices
12903 *
12904 */
12905 setCaret(new_pos) {
12906 this.caretPos = this.items.length;
12907 }
12908 /**
12909 * Return list of item dom elements
12910 *
12911 */
12912 controlChildren() {
12913 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
12914 }
12915 /**
12916 * Disables user input on the control. Used while
12917 * items are being asynchronously created.
12918 */
12919 lock() {
12920 this.setLocked(true);
12921 }
12922 /**
12923 * Re-enables user input on the control.
12924 */
12925 unlock() {
12926 this.setLocked(false);
12927 }
12928 /**
12929 * Disable or enable user input on the control
12930 */
12931 setLocked(lock = this.isReadOnly || this.isDisabled) {
12932 this.isLocked = lock;
12933 this.refreshState();
12934 }
12935 /**
12936 * Disables user input on the control completely.
12937 * While disabled, it cannot receive focus.
12938 */
12939 disable() {
12940 this.setDisabled(true);
12941 this.close();
12942 }
12943 /**
12944 * Enables the control so that it can respond
12945 * to focus and user input.
12946 */
12947 enable() {
12948 this.setDisabled(false);
12949 }
12950 setDisabled(disabled) {
12951 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
12952 this.isDisabled = disabled;
12953 this.input.disabled = disabled;
12954 this.control_input.disabled = disabled;
12955 this.setLocked();
12956 }
12957 setReadOnly(isReadOnly) {
12958 this.isReadOnly = isReadOnly;
12959 this.input.readOnly = isReadOnly;
12960 this.control_input.readOnly = isReadOnly;
12961 this.setLocked();
12962 }
12963 /**
12964 * Completely destroys the control and
12965 * unbinds all event listeners so that it can
12966 * be garbage collected.
12967 */
12968 destroy() {
12969 var self = this;
12970 var revertSettings = self.revertSettings;
12971 self.trigger('destroy');
12972 self.off();
12973 self.wrapper.remove();
12974 self.dropdown.remove();
12975 self.input.innerHTML = revertSettings.innerHTML;
12976 self.input.tabIndex = revertSettings.tabIndex;
12977 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
12978 self._destroy();
12979 delete self.input.tomselect;
12980 }
12981 /**
12982 * A helper method for rendering "item" and
12983 * "option" templates, given the data.
12984 *
12985 */
12986 render(templateName, data) {
12987 var id, html;
12988 const self = this;
12989 if (typeof this.settings.render[templateName] !== 'function') {
12990 return null;
12991 }
12992 // render markup
12993 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
12994 if (!html) {
12995 return null;
12996 }
12997 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
12998 // add mandatory attributes
12999 if (templateName === 'option' || templateName === 'option_create') {
13000 if (data[self.settings.disabledField]) {
13001 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
13002 }
13003 else {
13004 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13005 }
13006 }
13007 else if (templateName === 'optgroup') {
13008 id = data.group[self.settings.optgroupValueField];
13009 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13010 if (data.group[self.settings.disabledField]) {
13011 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13012 }
13013 }
13014 if (templateName === 'option' || templateName === 'item') {
13015 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13016 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13017 // make sure we have some classes if a template is overwritten
13018 if (templateName === 'item') {
13019 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13020 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13021 }
13022 else {
13023 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13024 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13025 role: 'option',
13026 id: data.$id
13027 });
13028 // update cache
13029 data.$div = html;
13030 self.options[value] = data;
13031 }
13032 }
13033 return html;
13034 }
13035 /**
13036 * Type guarded rendering
13037 *
13038 */
13039 _render(templateName, data) {
13040 const html = this.render(templateName, data);
13041 if (html == null) {
13042 throw 'HTMLElement expected';
13043 }
13044 return html;
13045 }
13046 /**
13047 * Clears the render cache for a template. If
13048 * no template is given, clears all render
13049 * caches.
13050 *
13051 */
13052 clearCache() {
13053 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13054 if (option.$div) {
13055 option.$div.remove();
13056 delete option.$div;
13057 }
13058 });
13059 }
13060 /**
13061 * Removes a value from item and option caches
13062 *
13063 */
13064 uncacheValue(value) {
13065 const option_el = this.getOption(value);
13066 if (option_el)
13067 option_el.remove();
13068 }
13069 /**
13070 * Determines whether or not to display the
13071 * create item prompt, given a user input.
13072 *
13073 */
13074 canCreate(input) {
13075 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13076 }
13077 /**
13078 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13079 *
13080 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13081 *
13082 * });
13083 */
13084 hook(when, method, new_fn) {
13085 var self = this;
13086 var orig_method = self[method];
13087 self[method] = function () {
13088 var result, result_new;
13089 if (when === 'after') {
13090 result = orig_method.apply(self, arguments);
13091 }
13092 result_new = new_fn.apply(self, arguments);
13093 if (when === 'instead') {
13094 return result_new;
13095 }
13096 if (when === 'before') {
13097 result = orig_method.apply(self, arguments);
13098 }
13099 return result;
13100 };
13101 }
13102 }
13103 ;
13104 //# sourceMappingURL=tom-select.js.map
13105
13106 /***/ },
13107
13108 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13109 /*!***************************************************!*\
13110 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13111 \***************************************************/
13112 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13113
13114 "use strict";
13115 __webpack_require__.r(__webpack_exports__);
13116 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13117 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13118 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13119 /* harmony export */ append: () => (/* binding */ append),
13120 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13121 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13122 /* harmony export */ getId: () => (/* binding */ getId),
13123 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13124 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13125 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13126 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13127 /* harmony export */ iterate: () => (/* binding */ iterate),
13128 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13129 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13130 /* harmony export */ timeout: () => (/* binding */ timeout)
13131 /* harmony export */ });
13132 /**
13133 * Converts a scalar to its best string representation
13134 * for hash keys and HTML attribute values.
13135 *
13136 * Transformations:
13137 * 'str' -> 'str'
13138 * null -> ''
13139 * undefined -> ''
13140 * true -> '1'
13141 * false -> '0'
13142 * 0 -> '0'
13143 * 1 -> '1'
13144 *
13145 */
13146 const hash_key = (value) => {
13147 if (typeof value === 'undefined' || value === null)
13148 return null;
13149 return get_hash(value);
13150 };
13151 const get_hash = (value) => {
13152 if (typeof value === 'boolean')
13153 return value ? '1' : '0';
13154 return value + '';
13155 };
13156 /**
13157 * Escapes a string for use within HTML.
13158 *
13159 */
13160 const escape_html = (str) => {
13161 return (str + '')
13162 .replace(/&/g, '&amp;')
13163 .replace(/</g, '&lt;')
13164 .replace(/>/g, '&gt;')
13165 .replace(/"/g, '&quot;');
13166 };
13167 /**
13168 * use setTimeout if timeout > 0
13169 */
13170 const timeout = (fn, timeout) => {
13171 if (timeout > 0) {
13172 return window.setTimeout(fn, timeout);
13173 }
13174 fn.call(null);
13175 return null;
13176 };
13177 /**
13178 * Debounce the user provided load function
13179 *
13180 */
13181 const loadDebounce = (fn, delay) => {
13182 var timeout;
13183 return function (value, callback) {
13184 var self = this;
13185 if (timeout) {
13186 self.loading = Math.max(self.loading - 1, 0);
13187 clearTimeout(timeout);
13188 }
13189 timeout = setTimeout(function () {
13190 timeout = null;
13191 self.loadedSearches[value] = true;
13192 fn.call(self, value, callback);
13193 }, delay);
13194 };
13195 };
13196 /**
13197 * Debounce all fired events types listed in `types`
13198 * while executing the provided `fn`.
13199 *
13200 */
13201 const debounce_events = (self, types, fn) => {
13202 var type;
13203 var trigger = self.trigger;
13204 var event_args = {};
13205 // override trigger method
13206 self.trigger = function () {
13207 var type = arguments[0];
13208 if (types.indexOf(type) !== -1) {
13209 event_args[type] = arguments;
13210 }
13211 else {
13212 return trigger.apply(self, arguments);
13213 }
13214 };
13215 // invoke provided function
13216 fn.apply(self, []);
13217 self.trigger = trigger;
13218 // trigger queued events
13219 for (type of types) {
13220 if (type in event_args) {
13221 trigger.apply(self, event_args[type]);
13222 }
13223 }
13224 };
13225 /**
13226 * Determines the current selection within a text input control.
13227 * Returns an object containing:
13228 * - start
13229 * - length
13230 *
13231 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13232 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13233 */
13234 const getSelection = (input) => {
13235 return {
13236 start: input.selectionStart || 0,
13237 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13238 };
13239 };
13240 /**
13241 * Prevent default
13242 *
13243 */
13244 const preventDefault = (evt, stop = false) => {
13245 if (evt) {
13246 evt.preventDefault();
13247 if (stop) {
13248 evt.stopPropagation();
13249 }
13250 }
13251 };
13252 /**
13253 * Add event helper
13254 *
13255 */
13256 const addEvent = (target, type, callback, options) => {
13257 target.addEventListener(type, callback, options);
13258 };
13259 /**
13260 * Return true if the requested key is down
13261 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13262 * The current evt may not always set ( eg calling advanceSelection() )
13263 *
13264 */
13265 const isKeyDown = (key_name, evt) => {
13266 if (!evt) {
13267 return false;
13268 }
13269 if (!evt[key_name]) {
13270 return false;
13271 }
13272 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13273 if (count === 1) {
13274 return true;
13275 }
13276 return false;
13277 };
13278 /**
13279 * Get the id of an element
13280 * If the id attribute is not set, set the attribute with the given id
13281 *
13282 */
13283 const getId = (el, id) => {
13284 const existing_id = el.getAttribute('id');
13285 if (existing_id) {
13286 return existing_id;
13287 }
13288 el.setAttribute('id', id);
13289 return id;
13290 };
13291 /**
13292 * Returns a string with backslashes added before characters that need to be escaped.
13293 */
13294 const addSlashes = (str) => {
13295 return str.replace(/[\\"']/g, '\\$&');
13296 };
13297 /**
13298 *
13299 */
13300 const append = (parent, node) => {
13301 if (node)
13302 parent.append(node);
13303 };
13304 /**
13305 * Iterates over arrays and hashes.
13306 *
13307 * ```
13308 * iterate(this.items, function(item, id) {
13309 * // invoked for each item
13310 * });
13311 * ```
13312 *
13313 */
13314 const iterate = (object, callback) => {
13315 if (Array.isArray(object)) {
13316 object.forEach(callback);
13317 }
13318 else {
13319 for (var key in object) {
13320 if (object.hasOwnProperty(key)) {
13321 callback(object[key], key);
13322 }
13323 }
13324 }
13325 };
13326 //# sourceMappingURL=utils.js.map
13327
13328 /***/ },
13329
13330 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13331 /*!*****************************************************!*\
13332 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13333 \*****************************************************/
13334 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13335
13336 "use strict";
13337 __webpack_require__.r(__webpack_exports__);
13338 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13339 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13340 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13341 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13342 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13343 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13344 /* harmony export */ getDom: () => (/* binding */ getDom),
13345 /* harmony export */ getTail: () => (/* binding */ getTail),
13346 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13347 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13348 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13349 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13350 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13351 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13352 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13353 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13354 /* harmony export */ });
13355 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13356
13357 /**
13358 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13359 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13360 *
13361 * param query should be {}
13362 */
13363 const getDom = (query) => {
13364 if (query.jquery) {
13365 return query[0];
13366 }
13367 if (query instanceof HTMLElement) {
13368 return query;
13369 }
13370 if (isHtmlString(query)) {
13371 var tpl = document.createElement('template');
13372 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13373 return tpl.content.firstChild;
13374 }
13375 return document.querySelector(query);
13376 };
13377 const isHtmlString = (arg) => {
13378 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13379 return true;
13380 }
13381 return false;
13382 };
13383 const escapeQuery = (query) => {
13384 return query.replace(/['"\\]/g, '\\$&');
13385 };
13386 /**
13387 * Dispatch an event
13388 *
13389 */
13390 const triggerEvent = (dom_el, event_name) => {
13391 var event = document.createEvent('HTMLEvents');
13392 event.initEvent(event_name, true, false);
13393 dom_el.dispatchEvent(event);
13394 };
13395 /**
13396 * Apply CSS rules to a dom element
13397 *
13398 */
13399 const applyCSS = (dom_el, css) => {
13400 Object.assign(dom_el.style, css);
13401 };
13402 /**
13403 * Add css classes
13404 *
13405 */
13406 const addClasses = (elmts, ...classes) => {
13407 var norm_classes = classesArray(classes);
13408 elmts = castAsArray(elmts);
13409 elmts.map(el => {
13410 norm_classes.map(cls => {
13411 el.classList.add(cls);
13412 });
13413 });
13414 };
13415 /**
13416 * Remove css classes
13417 *
13418 */
13419 const removeClasses = (elmts, ...classes) => {
13420 var norm_classes = classesArray(classes);
13421 elmts = castAsArray(elmts);
13422 elmts.map(el => {
13423 norm_classes.map(cls => {
13424 el.classList.remove(cls);
13425 });
13426 });
13427 };
13428 /**
13429 * Return arguments
13430 *
13431 */
13432 const classesArray = (args) => {
13433 var classes = [];
13434 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13435 if (typeof _classes === 'string') {
13436 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13437 }
13438 if (Array.isArray(_classes)) {
13439 classes = classes.concat(_classes);
13440 }
13441 });
13442 return classes.filter(Boolean);
13443 };
13444 /**
13445 * Create an array from arg if it's not already an array
13446 *
13447 */
13448 const castAsArray = (arg) => {
13449 if (!Array.isArray(arg)) {
13450 arg = [arg];
13451 }
13452 return arg;
13453 };
13454 /**
13455 * Get the closest node to the evt.target matching the selector
13456 * Stops at wrapper
13457 *
13458 */
13459 const parentMatch = (target, selector, wrapper) => {
13460 if (wrapper && !wrapper.contains(target)) {
13461 return;
13462 }
13463 while (target && target.matches) {
13464 if (target.matches(selector)) {
13465 return target;
13466 }
13467 target = target.parentNode;
13468 }
13469 };
13470 /**
13471 * Get the first or last item from an array
13472 *
13473 * > 0 - right (last)
13474 * <= 0 - left (first)
13475 *
13476 */
13477 const getTail = (list, direction = 0) => {
13478 if (direction > 0) {
13479 return list[list.length - 1];
13480 }
13481 return list[0];
13482 };
13483 /**
13484 * Return true if an object is empty
13485 *
13486 */
13487 const isEmptyObject = (obj) => {
13488 return (Object.keys(obj).length === 0);
13489 };
13490 /**
13491 * Get the index of an element amongst sibling nodes of the same type
13492 *
13493 */
13494 const nodeIndex = (el, amongst) => {
13495 if (!el)
13496 return -1;
13497 amongst = amongst || el.nodeName;
13498 var i = 0;
13499 while (el = el.previousElementSibling) {
13500 if (el.matches(amongst)) {
13501 i++;
13502 }
13503 }
13504 return i;
13505 };
13506 /**
13507 * Set attributes of an element
13508 *
13509 */
13510 const setAttr = (el, attrs) => {
13511 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
13512 if (val == null) {
13513 el.removeAttribute(attr);
13514 }
13515 else {
13516 el.setAttribute(attr, '' + val);
13517 }
13518 });
13519 };
13520 /**
13521 * Replace a node
13522 */
13523 const replaceNode = (existing, replacement) => {
13524 if (existing.parentNode)
13525 existing.parentNode.replaceChild(replacement, existing);
13526 };
13527 //# sourceMappingURL=vanilla.js.map
13528
13529 /***/ }
13530
13531 /******/ });
13532 /************************************************************************/
13533 /******/ // The module cache
13534 /******/ var __webpack_module_cache__ = {};
13535 /******/
13536 /******/ // The require function
13537 /******/ function __webpack_require__(moduleId) {
13538 /******/ // Check if module is in cache
13539 /******/ var cachedModule = __webpack_module_cache__[moduleId];
13540 /******/ if (cachedModule !== undefined) {
13541 /******/ return cachedModule.exports;
13542 /******/ }
13543 /******/ // Create a new module (and put it into the cache)
13544 /******/ var module = __webpack_module_cache__[moduleId] = {
13545 /******/ id: moduleId,
13546 /******/ // no module.loaded needed
13547 /******/ exports: {}
13548 /******/ };
13549 /******/
13550 /******/ // Execute the module function
13551 /******/ if (!(moduleId in __webpack_modules__)) {
13552 /******/ delete __webpack_module_cache__[moduleId];
13553 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
13554 /******/ e.code = 'MODULE_NOT_FOUND';
13555 /******/ throw e;
13556 /******/ }
13557 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
13558 /******/
13559 /******/ // Return the exports of the module
13560 /******/ return module.exports;
13561 /******/ }
13562 /******/
13563 /************************************************************************/
13564 /******/ /* webpack/runtime/compat get default export */
13565 /******/ (() => {
13566 /******/ // getDefaultExport function for compatibility with non-harmony modules
13567 /******/ __webpack_require__.n = (module) => {
13568 /******/ var getter = module && module.__esModule ?
13569 /******/ () => (module['default']) :
13570 /******/ () => (module);
13571 /******/ __webpack_require__.d(getter, { a: getter });
13572 /******/ return getter;
13573 /******/ };
13574 /******/ })();
13575 /******/
13576 /******/ /* webpack/runtime/define property getters */
13577 /******/ (() => {
13578 /******/ // define getter functions for harmony exports
13579 /******/ __webpack_require__.d = (exports, definition) => {
13580 /******/ for(var key in definition) {
13581 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13582 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
13583 /******/ }
13584 /******/ }
13585 /******/ };
13586 /******/ })();
13587 /******/
13588 /******/ /* webpack/runtime/hasOwnProperty shorthand */
13589 /******/ (() => {
13590 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
13591 /******/ })();
13592 /******/
13593 /******/ /* webpack/runtime/make namespace object */
13594 /******/ (() => {
13595 /******/ // define __esModule on exports
13596 /******/ __webpack_require__.r = (exports) => {
13597 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
13598 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13599 /******/ }
13600 /******/ Object.defineProperty(exports, '__esModule', { value: true });
13601 /******/ };
13602 /******/ })();
13603 /******/
13604 /******/ /* webpack/runtime/nonce */
13605 /******/ (() => {
13606 /******/ __webpack_require__.nc = undefined;
13607 /******/ })();
13608 /******/
13609 /************************************************************************/
13610 var __webpack_exports__ = {};
13611 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
13612 (() => {
13613 "use strict";
13614 /*!********************************************!*\
13615 !*** ./assets/src/js/admin/admin-order.js ***!
13616 \********************************************/
13617 __webpack_require__.r(__webpack_exports__);
13618 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
13619 /* 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");
13620 /* harmony import */ var _order_refund_order__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./order/refund-order */ "./assets/src/js/admin/order/refund-order.js");
13621
13622
13623 //import modalSearchCourses from './order/modal-search-courses';
13624
13625
13626 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
13627 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
13628 (0,_order_refund_order__WEBPACK_IMPORTED_MODULE_2__["default"])();
13629 })();
13630
13631 /******/ })()
13632 ;
13633 //# sourceMappingURL=admin-order.js.map