PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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-tools.js

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

14,249 lines 502.1 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/tools/assign-user-course.js"
5 /*!*********************************************************!*\
6 !*** ./assets/src/js/admin/tools/assign-user-course.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": () => (/* binding */ assignUserCourse)
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 /**
17 * Assign user to course
18 *
19 * @since 4.2.5.6
20 * @version 1.0.1
21 */
22
23 function assignUserCourse() {
24 let elFormAssignUserCourse;
25 let elFormUnAssignUserCourse;
26 let elUserUnAssign, elCourseUnAssign, elUserAssign, elCourseAssign;
27 const limitHandle = 5;
28 const getAllElements = () => {
29 elFormAssignUserCourse = document.querySelector('#lp-assign-user-course-form');
30 elFormUnAssignUserCourse = document.querySelector('#lp-unassign-user-course-form');
31 if (elFormAssignUserCourse) {
32 elUserUnAssign = elFormUnAssignUserCourse.querySelector('[name=user_ids]');
33 elCourseUnAssign = elFormUnAssignUserCourse.querySelector('[name=course_ids]');
34 }
35 if (elFormUnAssignUserCourse) {
36 elUserAssign = elFormAssignUserCourse.querySelector('[name=user_ids]');
37 elCourseAssign = elFormAssignUserCourse.querySelector('[name=course_ids]');
38 }
39 };
40 const events = () => {
41 const elForm = document.querySelector('form');
42 if (!elForm) {
43 return;
44 }
45 document.addEventListener('submit', e => {
46 const elForm = e.target;
47 const formData = new FormData(e.target); // Create a FormData object from the form
48
49 // get values of form.
50 const obj = Object.fromEntries(Array.from(formData.keys(), key => {
51 const val = formData.getAll(key);
52 return [key, val.length > 1 ? val : val.pop()];
53 }));
54 if (elForm.id === 'lp-assign-user-course-form') {
55 e.preventDefault();
56 if (!confirm('Are you sure you want to Assign?')) {
57 return;
58 }
59 const {
60 packages,
61 data,
62 totalPage
63 } = handleDataBeforeSend(obj);
64 fetchAPIAssignCourse(packages, data, 1, totalPage);
65 } else if (elForm.id === 'lp-unassign-user-course-form') {
66 e.preventDefault();
67 if (!confirm('Are you sure you want to Unassign?')) {
68 return;
69 }
70 const {
71 packages,
72 data,
73 totalPage
74 } = handleDataBeforeSend(obj);
75 fetchAPIUnAssignCourse(packages, data, 1, totalPage);
76 }
77 });
78 };
79 const handleDataBeforeSend = dataRaw => {
80 // Cut to packages to send, 1 packages has 5 items.
81 let arrCourseIds = [];
82 let arrUserIds = [];
83 if (typeof dataRaw.course_ids === 'string') {
84 arrCourseIds.push(dataRaw.course_ids);
85 } else if (typeof dataRaw.course_ids === 'object') {
86 arrCourseIds = dataRaw.course_ids;
87 }
88 if (typeof dataRaw.user_ids === 'string') {
89 arrUserIds.push(dataRaw.user_ids);
90 } else if (typeof dataRaw.user_ids === 'object') {
91 arrUserIds = dataRaw.user_ids;
92 }
93 const packages = [];
94 arrCourseIds.map((courseId, indexCourse) => {
95 const item = {};
96 item.course_id = courseId;
97 arrUserIds.map((userID, indexUser) => {
98 const newItem = {
99 ...item,
100 user_id: userID
101 };
102 packages.push(newItem);
103 });
104 });
105 const data = packages.slice(0, limitHandle);
106 const totalPage = Math.ceil(packages.length / limitHandle);
107 return {
108 packages,
109 data,
110 totalPage
111 };
112 };
113 const fetchAPIAssignCourse = (packages, data, page, totalPage) => {
114 const url = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiAssignUserCourse;
115 const params = {
116 headers: {
117 'Content-Type': 'application/json',
118 'X-WP-Nonce': lpDataAdmin.nonce
119 },
120 method: 'POST',
121 body: JSON.stringify({
122 data,
123 page,
124 totalPage
125 })
126 };
127 const elProgress = elFormAssignUserCourse.querySelector('.percent');
128 const elButtonAssign = elFormAssignUserCourse.querySelector('.lp-button-assign-course');
129 const elMessage = elFormAssignUserCourse.querySelector('.message');
130 elButtonAssign.disabled = true;
131 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, {
132 success: response => {
133 const {
134 status,
135 message
136 } = response;
137 if (status === 'success') {
138 let page = parseInt(response.data.page);
139 const begin = page * limitHandle;
140 const end = begin + limitHandle;
141 data = packages.slice(begin, end);
142 elProgress.innerHTML = response.data.percent;
143 fetchAPIAssignCourse(packages, data, ++page, totalPage);
144 } else if (status === 'finished') {
145 elProgress.innerHTML = '';
146 elMessage.style.color = 'green';
147 elMessage.innerHTML = message;
148 setTimeout(() => {
149 elMessage.innerHTML = '';
150 }, 2000);
151 elButtonAssign.disabled = false;
152 // Clear data selected on Tom Select.
153 if (!elUserAssign.tomselect || !elCourseAssign.tomselect) {
154 return;
155 }
156 elUserAssign.tomselect.clear();
157 elCourseAssign.tomselect.clear();
158 } else if (status === 'error') {
159 elButtonAssign.disabled = false;
160 elMessage.style.color = 'red';
161 elMessage.innerHTML = message;
162 setTimeout(() => {
163 elMessage.innerHTML = '';
164 }, 2000);
165 }
166 },
167 error: err => {
168 elButtonAssign.disabled = false;
169 elMessage.innerHTML = err.message;
170 },
171 completed: () => {}
172 });
173 };
174 const fetchAPIUnAssignCourse = (packages, data, page, totalPage) => {
175 const url = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiUnAssignUserCourse;
176 const params = {
177 headers: {
178 'Content-Type': 'application/json',
179 'X-WP-Nonce': lpDataAdmin.nonce
180 },
181 method: 'POST',
182 body: JSON.stringify({
183 data,
184 page,
185 totalPage
186 })
187 };
188 const elProgress = elFormUnAssignUserCourse.querySelector('.percent');
189 const elButtonAssign = elFormUnAssignUserCourse.querySelector('.lp-button-unassign-course');
190 const elMessage = elFormUnAssignUserCourse.querySelector('.message');
191 elButtonAssign.disabled = true;
192 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, {
193 success: response => {
194 const {
195 status,
196 message
197 } = response;
198 if (status === 'success') {
199 let page = parseInt(response.data.page);
200 const begin = page * limitHandle;
201 const end = begin + limitHandle;
202 data = packages.slice(begin, end);
203 elProgress.innerHTML = response.data.percent;
204 fetchAPIUnAssignCourse(packages, data, ++page, totalPage);
205 } else if (status === 'finished') {
206 elProgress.innerHTML = '';
207 elMessage.style.color = 'green';
208 elMessage.innerHTML = message;
209 setTimeout(() => {
210 elMessage.innerHTML = '';
211 }, 2000);
212 elButtonAssign.disabled = false;
213 // Clear data selected on Tom Select.
214 if (!elUserUnAssign.tomselect || !elCourseUnAssign.tomselect) {
215 return;
216 }
217 elUserUnAssign.tomselect.clear();
218 elCourseUnAssign.tomselect.clear();
219 } else if (status === 'error') {
220 elButtonAssign.disabled = false;
221 elMessage.style.color = 'red';
222 elMessage.innerHTML = message;
223 setTimeout(() => {
224 elMessage.innerHTML = '';
225 }, 2000);
226 }
227 },
228 error: err => {
229 elButtonAssign.disabled = false;
230 elMessage.innerHTML = err.message;
231 },
232 completed: () => {}
233 });
234 };
235
236 // DOMContentLoaded.
237 document.addEventListener('DOMContentLoaded', () => {
238 getAllElements();
239 if (!elFormAssignUserCourse) {
240 return;
241 }
242 events();
243 });
244 }
245
246 /***/ },
247
248 /***/ "./assets/src/js/admin/tools/handle-sample-data.js"
249 /*!*********************************************************!*\
250 !*** ./assets/src/js/admin/tools/handle-sample-data.js ***!
251 \*********************************************************/
252 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
253
254 "use strict";
255 __webpack_require__.r(__webpack_exports__);
256 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
257 /* harmony export */ "default": () => (/* binding */ HandleSampleData)
258 /* harmony export */ });
259 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
260 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
261 /**
262 * Handle install/uninstall sample course data on the Tools page.
263 *
264 * @since 4.4.5
265 * @version 1.0.0
266 */
267
268
269 class HandleSampleData {
270 static selectors = {
271 wrapper: '.lp-install-sample',
272 form: '.lp-form-handle-sample-data',
273 elBtnHandleSampleData: '.lp-btn-install-sample-handle',
274 elTriggerToggle: '.lp-install-sample__toggle-options',
275 elMessage: '.lp-install-sample-message'
276 };
277 constructor() {
278 this.wrapper = null;
279 }
280 init() {
281 this.wrapper = document.querySelector(HandleSampleData.selectors.wrapper);
282 if (!this.wrapper) {
283 return;
284 }
285 this.preventFormSubmit();
286 this.events();
287 }
288 preventFormSubmit() {
289 const form = this.wrapper.querySelector(HandleSampleData.selectors.form);
290 if (form) {
291 form.addEventListener('submit', e => {
292 e.preventDefault();
293 });
294 }
295 }
296 events() {
297 if (HandleSampleData._loadedEvents) {
298 return;
299 }
300 HandleSampleData._loadedEvents = this;
301 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
302 selector: HandleSampleData.selectors.elBtnHandleSampleData,
303 class: this,
304 callBack: this.handleAction.name
305 }, {
306 selector: HandleSampleData.selectors.elTriggerToggle,
307 callBack: args => {
308 const {
309 e,
310 target
311 } = args;
312 const elForm = this.wrapper.querySelector(HandleSampleData.selectors.form);
313 if (elForm) {
314 elForm.classList.toggle('lp-hidden');
315 const textShow = target.dataset.showText;
316 const textHide = target.dataset.hideText;
317 target.textContent = elForm.classList.contains('lp-hidden') ? textShow : textHide;
318 }
319 }
320 }]);
321 }
322 handleAction(args) {
323 const {
324 e,
325 target
326 } = args;
327 const button = target.closest(HandleSampleData.selectors.elBtnHandleSampleData);
328 e.preventDefault();
329 const elMessage = this.wrapper.querySelector(HandleSampleData.selectors.elMessage);
330 const message = button.dataset.message;
331 if (!message || !confirm(message)) {
332 return;
333 }
334 elMessage.innerHTML = '';
335 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(button, true);
336 const wrapper = button.closest(HandleSampleData.selectors.wrapper);
337 const elForm = wrapper.querySelector(HandleSampleData.selectors.form);
338 let dataSend = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.getDataOfForm(elForm);
339 dataSend.action = button.dataset.action;
340 dataSend.id_url = 'handle-sample-data';
341 const callBack = {
342 success: response => {
343 const {
344 status,
345 message,
346 data
347 } = response;
348 if ('success' === status) {
349 this.wrapper.querySelector(HandleSampleData.selectors.elMessage).innerHTML = data.html;
350 } else {
351 throw new Error(message);
352 }
353 },
354 error: error => {
355 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
356 },
357 completed: () => {
358 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(button, false);
359 setTimeout(() => {
360 elMessage.innerHTML = '';
361 }, 3000);
362 }
363 };
364 window.lpAJAXG.fetchAJAX(dataSend, callBack);
365 }
366 }
367
368 /***/ },
369
370 /***/ "./assets/src/js/admin/tools/reset-course-progress.js"
371 /*!************************************************************!*\
372 !*** ./assets/src/js/admin/tools/reset-course-progress.js ***!
373 \************************************************************/
374 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
375
376 "use strict";
377 __webpack_require__.r(__webpack_exports__);
378 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
379 /* harmony export */ "default": () => (/* binding */ ResetCourseProgress)
380 /* harmony export */ });
381 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
382 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
383 /* harmony import */ var lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/lpPopupSelectItemToAdd.js */ "./assets/src/js/lpPopupSelectItemToAdd.js");
384 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
385 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_3__);
386 /**
387 * Reset course user progress handler.
388 *
389 * @since 4.4.6
390 * @version 1.0.0
391 */
392
393
394
395
396 const lpPopupSelectItemToAdd = new lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd();
397 class ResetCourseProgress {
398 static selectors = {
399 elPopupTemplate: '#lp-tmpl-select-courses-to-reset-progress',
400 elFilterField: '.lp-filter-field',
401 elFormFilter: '.lp-form-filter-reset-course-progress',
402 elPopupItemsToSelect: '.lp-popup-select-courses-to-reset-progress',
403 elBtnResetAll: '.lp-btn-reset-all-courses-progress'
404 };
405 constructor() {
406 this.btnChooseCourses = null;
407 this.elFormFilter = null;
408 this.elPopupItemsToSelect = null;
409 this.elBtnResetAll = null;
410 this.elBtnAddItemsSelected = null;
411 this.debouncedSearchUsers = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.debounce(elForm => {
412 this.fetchCourses(elForm);
413 }, 800);
414 }
415 init() {
416 this.events();
417 }
418 events() {
419 // Check and attach events only once.
420 if (ResetCourseProgress._loadedEvents) {
421 return;
422 }
423 ResetCourseProgress._loadedEvents = this;
424
425 // Click events.
426 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
427 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
428 class: this,
429 callBack: this.handleShowPopupItemsToSelect.name
430 }, {
431 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected,
432 class: lpPopupSelectItemToAdd,
433 callBack: lpPopupSelectItemToAdd.addItemsSelectedToSection.name,
434 callBackHandle: this.addItemsSelectedToSection.bind(this),
435 conditionBeforeCallBack: args => {
436 // Only run when the Add button inside this tool's popup is clicked.
437 return !!args.target.closest(ResetCourseProgress.selectors.elPopupItemsToSelect);
438 }
439 }, {
440 selector: ResetCourseProgress.selectors.elBtnResetAll,
441 class: this,
442 callBack: this.resetAllCoursesProgress.name
443 }]);
444
445 // Change events.
446 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
447 selector: ResetCourseProgress.selectors.elFilterField,
448 class: this,
449 callBack: this.filterCourses.name
450 }]);
451 }
452
453 /**
454 * Called when the picker button is clicked.
455 *
456 * @param {Object} args Event arguments.
457 */
458 handleShowPopupItemsToSelect(args) {
459 const {
460 e,
461 target
462 } = args;
463 this.btnChooseCourses = target.closest('.lp-btn-choose-courses-to-reset-progress');
464 if (!this.btnChooseCourses) {
465 return;
466 }
467 this.elPopupItemsToSelect = sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().getPopup().querySelector(ResetCourseProgress.selectors.elPopupItemsToSelect);
468 if (!this.elPopupItemsToSelect) {
469 return;
470 }
471 this.elBtnAddItemsSelected = this.elPopupItemsToSelect.querySelector(lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected);
472 if (!this.elBtnAddItemsSelected) {
473 return;
474 }
475 this.elBtnResetAll = this.elPopupItemsToSelect.querySelector(ResetCourseProgress.selectors.elBtnResetAll);
476 }
477
478 /**
479 * Called after courses are selected in the popup and the action button is clicked.
480 *
481 * @param {Array} itemsSelectedData Selected item data from the popup.
482 */
483 addItemsSelectedToSection(itemsSelectedData) {
484 if (!this.btnChooseCourses) {
485 return;
486 }
487 const messageConfirm = this.elBtnAddItemsSelected.dataset.messageConfirm;
488 if (!messageConfirm || confirm(messageConfirm) === false) {
489 return;
490 }
491 this.btnChooseCourses.textContent = this.btnChooseCourses.dataset.messageResetting;
492 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 1);
493 const userItemIds = itemsSelectedData.map(item => parseInt(item.id, 10)).filter(id => !isNaN(id) && id > 0);
494 const elSearchUser = this.elFormFilter?.querySelector('.lp-search-user');
495 const searchUserValue = elSearchUser?.value || '';
496 window.lpAJAXG.fetchAJAX({
497 id_url: 'course-reset-progress-tool',
498 action: 'reset_progress_courses',
499 user_item_ids: userItemIds,
500 search_user: searchUserValue
501 }, {
502 success: response => {
503 const {
504 status,
505 message
506 } = response;
507 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
508 },
509 error: error => {
510 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
511 },
512 completed: () => {
513 this.btnChooseCourses.textContent = this.btnChooseCourses.dataset.messageChoose;
514 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 0);
515 }
516 });
517 }
518
519 /**
520 * Reset all courses progress.
521 *
522 * @param {Object} args Event arguments.
523 */
524 resetAllCoursesProgress(args) {
525 const {
526 e,
527 target
528 } = args;
529 const elPopupItemsToSelect = target.closest(ResetCourseProgress.selectors.elPopupItemsToSelect);
530 if (!elPopupItemsToSelect) {
531 return;
532 }
533 const elFormFilter = elPopupItemsToSelect.querySelector(ResetCourseProgress.selectors.elFormFilter);
534 if (!elFormFilter) {
535 return;
536 }
537 const messageConfirm = this.elBtnResetAll.dataset.messageConfirm;
538 if (!messageConfirm || confirm(messageConfirm) === false) {
539 return;
540 }
541
542 // Show loading
543 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 1);
544 sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().close();
545 const formData = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.getDataOfForm(elFormFilter);
546 window.lpAJAXG.fetchAJAX({
547 id_url: 'course-reset-progress-tool',
548 action: 'reset_progress_courses',
549 reset_all: 1,
550 ...formData
551 }, {
552 success: response => {
553 const {
554 status,
555 message
556 } = response;
557 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
558 },
559 error: error => {
560 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
561 },
562 completed: () => {
563 this.btnChooseCourses.textContent = this.btnChooseCourses.dataset.messageChoose;
564 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 0);
565 }
566 });
567 }
568
569 /**
570 * Fetch courses to reset progress.
571 *
572 * @param {HTMLElement} elForm The form element.
573 */
574 fetchCourses(elForm) {
575 this.elFormFilter = elForm;
576 const elPopup = elForm.closest(ResetCourseProgress.selectors.elPopupItemsToSelect);
577 const elLPTarget = elPopup.querySelector('.lp-target');
578 let dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
579 dataSend.args = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(elForm, dataSend.args);
580 dataSend.args.paged = 1;
581 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
582
583 // Show loading
584 window.lpAJAXG.showHideLoading(elLPTarget, 1);
585 window.lpAJAXG.fetchAJAX(dataSend, {
586 success: response => {
587 const {
588 data
589 } = response;
590 elLPTarget.innerHTML = data.content || '';
591 },
592 error: error => {
593 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
594 },
595 completed: () => {
596 window.lpAJAXG.showHideLoading(elLPTarget, 0);
597 }
598 });
599 }
600
601 /**
602 * Filter courses to reset progress.
603 *
604 * @param {Object} args Event arguments.
605 */
606 filterCourses(args) {
607 const {
608 target
609 } = args;
610 const elFilterField = target.closest(ResetCourseProgress.selectors.elFilterField);
611 if (!elFilterField) {
612 return;
613 }
614 const elForm = elFilterField.closest(ResetCourseProgress.selectors.elFormFilter);
615 if (!elForm) {
616 return;
617 }
618 this.debouncedSearchUsers(elForm);
619 }
620 }
621
622 /***/ },
623
624 /***/ "./assets/src/js/admin/tools/reset-item-progress.js"
625 /*!**********************************************************!*\
626 !*** ./assets/src/js/admin/tools/reset-item-progress.js ***!
627 \**********************************************************/
628 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
629
630 "use strict";
631 __webpack_require__.r(__webpack_exports__);
632 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
633 /* harmony export */ "default": () => (/* binding */ ResetItemProgress)
634 /* harmony export */ });
635 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
636 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
637 /* harmony import */ var lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/lpPopupSelectItemToAdd.js */ "./assets/src/js/lpPopupSelectItemToAdd.js");
638 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
639 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_3__);
640 /**
641 * Reset item user progress handler.
642 *
643 * @since 4.4.6
644 * @version 1.0.0
645 */
646
647
648
649
650 const lpPopupSelectItemToAdd = new lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd({
651 openButtonSelector: '.lp-btn-choose-item-to-reset-progress'
652 });
653 class ResetItemProgress {
654 static selectors = {
655 elPopupTemplate: '#lp-tmpl-select-items-to-reset-progress',
656 elFilterField: '.lp-filter-field',
657 elFormFilter: '.lp-form-filter-reset-item-progress',
658 elPopupItemsToSelect: '.lp-popup-select-items-to-reset-progress',
659 elBtnResetAll: '.lp-btn-reset-all-items-progress'
660 };
661 constructor() {
662 this.btnChooseItems = null;
663 this.elFormFilter = null;
664 this.elPopupItemsToSelect = null;
665 this.elBtnResetAll = null;
666 this.elBtnAddItemsSelected = null;
667 this.debouncedSearchItems = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.debounce(elForm => {
668 this.fetchItems(elForm);
669 }, 800);
670 }
671 init() {
672 this.events();
673 }
674 events() {
675 // Check and attach events only once.
676 if (ResetItemProgress._loadedEvents) {
677 return;
678 }
679 ResetItemProgress._loadedEvents = this;
680
681 // Click events.
682 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
683 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
684 class: this,
685 callBack: this.handleShowPopupItemsToSelect.name
686 }, {
687 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected,
688 class: lpPopupSelectItemToAdd,
689 callBack: lpPopupSelectItemToAdd.addItemsSelectedToSection.name,
690 callBackHandle: this.addItemsSelectedToSection.bind(this),
691 conditionBeforeCallBack: args => {
692 // Only run when the Add button inside this tool's popup is clicked.
693 return !!args.target.closest(ResetItemProgress.selectors.elPopupItemsToSelect);
694 }
695 }, {
696 selector: ResetItemProgress.selectors.elBtnResetAll,
697 class: this,
698 callBack: this.resetAllItemsProgress.name
699 }]);
700
701 // Change events.
702 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
703 selector: ResetItemProgress.selectors.elFilterField,
704 class: this,
705 callBack: this.filterItems.name
706 }]);
707 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('change', [{
708 selector: ResetItemProgress.selectors.elFilterField,
709 class: this,
710 callBack: this.filterItems.name
711 }]);
712 }
713
714 /**
715 * Called when the picker button is clicked.
716 *
717 * @param {Object} args Event arguments.
718 */
719 handleShowPopupItemsToSelect(args) {
720 const {
721 e,
722 target
723 } = args;
724 this.btnChooseItems = target.closest('.lp-btn-choose-item-to-reset-progress');
725 if (!this.btnChooseItems) {
726 return;
727 }
728 this.elPopupItemsToSelect = sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().getPopup().querySelector(ResetItemProgress.selectors.elPopupItemsToSelect);
729 this.elBtnAddItemsSelected = this.elPopupItemsToSelect.querySelector(lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected);
730 this.elBtnResetAll = this.elPopupItemsToSelect.querySelector(ResetItemProgress.selectors.elBtnResetAll);
731 }
732
733 /**
734 * Called after items are selected in the popup and the action button is clicked.
735 *
736 * @param {Array} itemsSelectedData Selected item data from the popup.
737 */
738 addItemsSelectedToSection(itemsSelectedData) {
739 if (!this.btnChooseItems) {
740 return;
741 }
742 const messageConfirm = this.elBtnAddItemsSelected.dataset.messageConfirm;
743 if (!messageConfirm || confirm(messageConfirm) === false) {
744 return;
745 }
746 this.btnChooseItems.textContent = this.btnChooseItems.dataset.messageResetting;
747 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 1);
748 const userItemIds = itemsSelectedData.map(item => parseInt(item.id, 10)).filter(id => !isNaN(id) && id > 0);
749 window.lpAJAXG.fetchAJAX({
750 id_url: 'item-reset-progress-tool',
751 action: 'reset_progress_items_course',
752 user_item_ids: userItemIds
753 }, {
754 success: response => {
755 const {
756 status,
757 message
758 } = response;
759 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
760 },
761 error: error => {
762 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
763 },
764 completed: () => {
765 this.btnChooseItems.textContent = this.btnChooseItems.dataset.messageChoose;
766 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 0);
767 }
768 });
769 }
770
771 /**
772 * Reset all items progress.
773 *
774 * @param {Object} args Event arguments.
775 */
776 resetAllItemsProgress(args) {
777 const {
778 e,
779 target
780 } = args;
781 const elPopupItemsToSelect = target.closest(ResetItemProgress.selectors.elPopupItemsToSelect);
782 if (!elPopupItemsToSelect) {
783 return;
784 }
785 const elFormFilter = elPopupItemsToSelect.querySelector(ResetItemProgress.selectors.elFormFilter);
786 if (!elFormFilter) {
787 return;
788 }
789 const messageConfirm = this.elBtnResetAll.dataset.messageConfirm;
790 if (!messageConfirm || confirm(messageConfirm) === false) {
791 return;
792 }
793
794 // Show loading
795 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 1);
796 sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().close();
797 const formData = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.getDataOfForm(elFormFilter);
798 window.lpAJAXG.fetchAJAX({
799 id_url: 'item-reset-progress-tool',
800 action: 'reset_progress_items_course',
801 reset_all: 1,
802 ...formData
803 }, {
804 success: response => {
805 const {
806 status,
807 message
808 } = response;
809 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
810 },
811 error: error => {
812 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
813 },
814 completed: () => {
815 this.btnChooseItems.textContent = this.btnChooseItems.dataset.messageChoose;
816 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 0);
817 }
818 });
819 }
820
821 /**
822 * Fetch items to reset progress.
823 *
824 * @param {HTMLElement} elForm The form element.
825 */
826 fetchItems(elForm) {
827 this.elFormFilter = elForm;
828 const elPopup = elForm.closest(ResetItemProgress.selectors.elPopupItemsToSelect);
829 const elLPTarget = elPopup.querySelector('.lp-target');
830 let dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
831 dataSend.args = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(elForm, dataSend.args);
832 dataSend.args.paged = 1;
833 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
834
835 // Show loading
836 window.lpAJAXG.showHideLoading(elLPTarget, 1);
837 window.lpAJAXG.fetchAJAX(dataSend, {
838 success: response => {
839 const {
840 data
841 } = response;
842 elLPTarget.innerHTML = data.content || '';
843 },
844 error: error => {
845 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
846 },
847 completed: () => {
848 window.lpAJAXG.showHideLoading(elLPTarget, 0);
849 }
850 });
851 }
852
853 /**
854 * Filter items to reset progress.
855 *
856 * @param {Object} args Event arguments.
857 */
858 filterItems(args) {
859 const {
860 target
861 } = args;
862 const elFilterField = target.closest(ResetItemProgress.selectors.elFilterField);
863 if (!elFilterField) {
864 return;
865 }
866 const elForm = elFilterField.closest(ResetItemProgress.selectors.elFormFilter);
867 if (!elForm) {
868 return;
869 }
870 this.debouncedSearchItems(elForm);
871 }
872 }
873
874 /***/ },
875
876 /***/ "./assets/src/js/admin/utils-admin.js"
877 /*!********************************************!*\
878 !*** ./assets/src/js/admin/utils-admin.js ***!
879 \********************************************/
880 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
881
882 "use strict";
883 __webpack_require__.r(__webpack_exports__);
884 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
885 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
886 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
887 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
888 /* harmony export */ });
889 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
890 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
891 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
892 /**
893 * Library run on Admin
894 *
895 * @since 4.2.6.9
896 * @version 1.0.1
897 */
898
899
900
901 const AdminUtilsFunctions = {
902 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
903 if (!elTomSelect) {
904 return;
905 }
906 const optionDefault = {
907 plugins: {
908 remove_button: {
909 title: 'Remove this item'
910 },
911 dropdown_input: {}
912 },
913 onInitialize() {},
914 onItemAdd(e) {
915 // Get list without current item.
916 if (fetchAPI) {
917 const selectedOptions = Array.from(elTomSelect.selectedOptions);
918 const selectedValues = selectedOptions.map(option => option.value);
919 selectedValues.push(e);
920 dataSend.id_not_in = selectedValues.join(',');
921 fetchAPI('', dataSend, callBackHandleData);
922 }
923 }
924 };
925 if (fetchAPI) {
926 optionDefault.load = (keySearch, callbackTom) => {
927 const selectedOptions = Array.from(elTomSelect.selectedOptions);
928 const selectedValues = selectedOptions.map(option => option.value);
929 dataSend.id_not_in = selectedValues.join(',');
930 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
931 };
932 }
933 options = {
934 ...optionDefault,
935 ...options
936 };
937 const items_selected = options.options;
938 /*if ( options?.options?.length > 20 ) {
939 const chunkSize = 20;
940 const length = options.options.length;
941 let i = 0;
942 const chunkedOptions = { ...options };
943 chunkedOptions.options = items_selected.slice( i, chunkSize );
944 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
945 i += chunkSize;
946 const interval = setInterval( () => {
947 if ( i > ( length - 1 ) ) {
948 clearInterval( interval );
949 }
950 const optionsSlice = items_selected.slice( i, i + chunkSize );
951 i += chunkSize;
952 tomSelect.addOptions( optionsSlice );
953 tomSelect.setValue( options.items );
954 }, 200 );
955 return tomSelect;
956 }*/
957
958 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
959 },
960 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
961 return {
962 success: response => {
963 const options = callBackHandleData.success(response);
964 callbackTom(options);
965 }
966 };
967 },
968 fetchCourses(keySearch = '', dataSend = {}, callback) {
969 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
970 dataSend.search = keySearch;
971 const params = {
972 headers: {
973 'Content-Type': 'application/json',
974 'X-WP-Nonce': lpDataAdmin.nonce
975 },
976 method: 'POST',
977 body: JSON.stringify(dataSend)
978 };
979 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
980 },
981 fetchUsers(keySearch = '', dataSend = {}, callback) {
982 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
983 dataSend.search = keySearch;
984 const params = {
985 headers: {
986 'Content-Type': 'application/json',
987 'X-WP-Nonce': lpDataAdmin.nonce
988 },
989 method: 'POST',
990 body: JSON.stringify(dataSend)
991 };
992 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
993 }
994 };
995
996
997 /***/ },
998
999 /***/ "./assets/src/js/api.js"
1000 /*!******************************!*\
1001 !*** ./assets/src/js/api.js ***!
1002 \******************************/
1003 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1004
1005 "use strict";
1006 __webpack_require__.r(__webpack_exports__);
1007 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1008 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1009 /* harmony export */ });
1010 /**
1011 * List API on backend
1012 *
1013 * @since 4.2.6
1014 * @version 1.0.2
1015 */
1016
1017 const lplistAPI = {};
1018 let lp_rest_url;
1019 if ('undefined' !== typeof lpDataAdmin) {
1020 lp_rest_url = lpDataAdmin.lp_rest_url;
1021 lplistAPI.admin = {
1022 apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
1023 apiAddons: lp_rest_url + 'lp/v1/addon/all',
1024 apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
1025 apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
1026 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
1027 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
1028 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
1029 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
1030 };
1031 }
1032 if ('undefined' !== typeof lpData) {
1033 lp_rest_url = lpData.lp_rest_url;
1034 lplistAPI.frontend = {
1035 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
1036 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
1037 // Deprecated API, don't load from v4.3.7
1038 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
1039 // Deprecated since 4.3.0
1040 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
1041 };
1042 }
1043 if (lp_rest_url) {
1044 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
1045 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
1046 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
1047 }
1048 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
1049
1050 /***/ },
1051
1052 /***/ "./assets/src/js/lpPopupSelectItemToAdd.js"
1053 /*!*************************************************!*\
1054 !*** ./assets/src/js/lpPopupSelectItemToAdd.js ***!
1055 \*************************************************/
1056 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1057
1058 "use strict";
1059 __webpack_require__.r(__webpack_exports__);
1060 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1061 /* harmony export */ LpPopupSelectItemToAdd: () => (/* binding */ LpPopupSelectItemToAdd)
1062 /* harmony export */ });
1063 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
1064 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
1065 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
1066 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_2__);
1067 /**
1068 * LearnPress Popup Select Item
1069 *
1070 * Handles load(search) item from API, show in popup and select item.
1071 */
1072
1073
1074
1075
1076 let itemsSelectedData = [];
1077 let elPopup;
1078 let timeSearchTitleItem;
1079 class LpPopupSelectItemToAdd {
1080 constructor() {
1081 this.init();
1082 }
1083 static selectors = {
1084 elBtnShowPopupItemsToSelect: '.lp-btn-show-popup-items-to-select',
1085 elBtnAddItemsSelected: '.lp-btn-add-items-selected',
1086 elBtnCountItemsSelected: '.lp-btn-count-items-selected',
1087 elHeaderCountItemSelected: '.header-count-items-selected',
1088 elSelectItem: '.lp-select-item',
1089 elListItems: '.list-items',
1090 elPopupItemsToSelect: '.lp-popup-items-to-select',
1091 elSearchTitleItem: '.lp-search-title-item',
1092 elBtnBackListItems: '.lp-btn-back-to-select-items',
1093 elListItemsWrap: '.list-items-wrap',
1094 elListItemsSelected: '.list-items-selected',
1095 elItemSelectedClone: '.li-item-selected.clone',
1096 elItemSelected: '.li-item-selected',
1097 LPTarget: '.lp-target'
1098 };
1099 init() {
1100 this.events();
1101 }
1102 events = () => {
1103 if (LpPopupSelectItemToAdd._loadedEvents) {
1104 return;
1105 }
1106 LpPopupSelectItemToAdd._loadedEvents = true;
1107 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
1108 selector: LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
1109 callBack: this.showPopupItemsToSelect.name,
1110 class: this
1111 }, {
1112 selector: LpPopupSelectItemToAdd.selectors.elSelectItem,
1113 callBack: this.selectItemsFromList.name,
1114 class: this
1115 }, {
1116 selector: LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected,
1117 callBack: this.showItemsSelected.name,
1118 class: this
1119 }, {
1120 selector: LpPopupSelectItemToAdd.selectors.elBtnBackListItems,
1121 callBack: this.backToSelectItems.name,
1122 class: this
1123 }, {
1124 selector: LpPopupSelectItemToAdd.selectors.elItemSelected,
1125 callBack: this.removeItemSelected.name,
1126 class: this
1127 }, {
1128 selector: '.tabs .tab',
1129 callBack: this.chooseTabItemsType.name,
1130 class: this
1131 }]);
1132 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
1133 selector: LpPopupSelectItemToAdd.selectors.elSearchTitleItem,
1134 callBack: this.searchTitleItemToSelect.name,
1135 class: this
1136 }]);
1137 };
1138
1139 // Show popup items to select
1140 showPopupItemsToSelect = args => {
1141 const {
1142 e,
1143 target = false,
1144 callBack
1145 } = args;
1146 const elBtnShowPopupItemsToSelect = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect}`);
1147 if (!elBtnShowPopupItemsToSelect) {
1148 return;
1149 }
1150
1151 // Reset items selected data when opening popup
1152 itemsSelectedData = [];
1153 const templateId = target.dataset.template || '';
1154 const modalTemplate = document.querySelector(templateId);
1155 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
1156 html: modalTemplate.innerHTML,
1157 showConfirmButton: false,
1158 showCloseButton: true,
1159 width: 'max(350px, 65vw)',
1160 customClass: {
1161 popup: 'lp-select-items-popup',
1162 htmlContainer: 'lp-select-items-html-container',
1163 container: 'lp-select-items-container'
1164 },
1165 willOpen: () => {
1166 elPopup = sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().getPopup();
1167 const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1168
1169 // Avoid duplicate AJAX: loadAJAX.js handles fresh elements; skip if already loaded. Set timeout to ensure DOM is ready handle.
1170 setTimeout(() => {
1171 const elLoadAjaxElement = elLPTarget.closest('.lp-load-ajax-element:not(.loaded)');
1172 if (!elLoadAjaxElement) {
1173 return;
1174 }
1175 if (elLPTarget) {
1176 const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1177 dataSend.args.paged = 1;
1178 dataSend.args.item_selecting = itemsSelectedData || [];
1179 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
1180 window.lpAJAXG.fetchAJAX(dataSend, {
1181 success: response => {
1182 const {
1183 data
1184 } = response;
1185 const elSkeleton = elPopup.querySelector('.lp-skeleton-animation');
1186 elSkeleton.remove();
1187 elLPTarget.innerHTML = data.content || '';
1188 this.watchItemsSelectedDataChange();
1189 }
1190 });
1191 }
1192 }, 1);
1193 }
1194 }).then(result => {
1195 if (result.isDismissed) {}
1196 });
1197 };
1198
1199 // Choose tab items type
1200 chooseTabItemsType = args => {
1201 const {
1202 e,
1203 target,
1204 callBack
1205 } = args;
1206 const elTabType = target.closest('.tab');
1207 if (!elTabType) {
1208 return;
1209 }
1210 e.preventDefault();
1211 const elTabs = elTabType.closest('.tabs');
1212 if (!elTabs) {
1213 return;
1214 }
1215 const elSelectItemsToAdd = elTabs.closest(`${LpPopupSelectItemToAdd.selectors.elPopupItemsToSelect}`);
1216 const elInputSearch = elSelectItemsToAdd.querySelector(`${LpPopupSelectItemToAdd.selectors.elSearchTitleItem}`);
1217 const itemType = elTabType.dataset.type;
1218 const elTabLis = elTabs.querySelectorAll('.tab');
1219 elTabLis.forEach(elTabLi => {
1220 if (elTabLi.classList.contains('active')) {
1221 elTabLi.classList.remove('active');
1222 }
1223 });
1224 elTabType.classList.add('active');
1225 // Reset search input
1226 elInputSearch.value = '';
1227 const elLPTarget = elSelectItemsToAdd.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1228 const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1229 dataSend.args.item_type = itemType;
1230 dataSend.args.paged = 1;
1231 dataSend.args.item_selecting = itemsSelectedData || [];
1232 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
1233 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1234 window.lpAJAXG.fetchAJAX(dataSend, {
1235 success: response => {
1236 const {
1237 data
1238 } = response;
1239 elLPTarget.innerHTML = data.content || '';
1240 },
1241 error: error => {
1242 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
1243 },
1244 completed: () => {
1245 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1246 this.watchItemsSelectedDataChange();
1247 }
1248 });
1249 };
1250
1251 // Choice items to add list items selected before adding to section
1252 selectItemsFromList = args => {
1253 const {
1254 e,
1255 target
1256 } = args;
1257 const elItemAttend = target.closest(`${LpPopupSelectItemToAdd.selectors.elSelectItem}`);
1258 if (!elItemAttend) {
1259 return;
1260 }
1261 const elInput = elItemAttend.querySelector('input[type="checkbox"]');
1262 if (target.tagName !== 'INPUT') {
1263 elInput.click();
1264 return;
1265 }
1266 const elUl = elItemAttend.closest(`${LpPopupSelectItemToAdd.selectors.elListItems}`);
1267 if (!elUl) {
1268 return;
1269 }
1270 const itemSelected = {
1271 ...elInput.dataset
1272 };
1273 //console.log( 'itemSelected', itemSelected );
1274
1275 if (elInput.checked) {
1276 const exists = itemsSelectedData.some(item => item.id === itemSelected.id);
1277 if (!exists) {
1278 itemsSelectedData.push(itemSelected);
1279 }
1280 } else {
1281 const index = itemsSelectedData.findIndex(item => item.id === itemSelected.id);
1282 if (index !== -1) {
1283 itemsSelectedData.splice(index, 1);
1284 }
1285 }
1286 this.watchItemsSelectedDataChange();
1287 };
1288
1289 // Search title item
1290 searchTitleItemToSelect = args => {
1291 const {
1292 e,
1293 target
1294 } = args;
1295 const elInputSearch = target.closest(LpPopupSelectItemToAdd.selectors.elSearchTitleItem);
1296 if (!elInputSearch) {
1297 return;
1298 }
1299 const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1300 clearTimeout(timeSearchTitleItem);
1301 timeSearchTitleItem = setTimeout(() => {
1302 const dataSet = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1303 dataSet.args.search_title = elInputSearch.value.trim();
1304 dataSet.args.item_selecting = itemsSelectedData;
1305 dataSet.args.paged = 1;
1306 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSet);
1307
1308 // Show loading
1309 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1310 window.lpAJAXG.fetchAJAX(dataSet, {
1311 success: response => {
1312 const {
1313 data
1314 } = response;
1315 elLPTarget.innerHTML = data.content || '';
1316 },
1317 error: error => {
1318 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
1319 },
1320 completed: () => {
1321 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1322 }
1323 });
1324 }, 800);
1325 };
1326
1327 // Show list of items, to choose items to add to section
1328 showItemsSelected = args => {
1329 const {
1330 e,
1331 target
1332 } = args;
1333 const elBtnCountItemsSelected = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1334 if (!elBtnCountItemsSelected) {
1335 return;
1336 }
1337 const elBtnBack = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnBackListItems}`);
1338 const elTabs = elPopup.querySelector('.tabs');
1339 const elListItemsWrap = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsWrap}`);
1340 const elHeaderItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1341 const elListItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsSelected}`);
1342 const elItemClone = elListItemsSelected.querySelector(`${LpPopupSelectItemToAdd.selectors.elItemSelectedClone}`);
1343 elHeaderItemsSelected.innerHTML = elBtnCountItemsSelected.innerHTML;
1344 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsWrap, 0);
1345 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnCountItemsSelected, 0);
1346 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elTabs, 0);
1347 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnBack, 1);
1348 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elHeaderItemsSelected, 1);
1349 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsSelected, 1);
1350 elListItemsSelected.querySelectorAll(`${LpPopupSelectItemToAdd.selectors.elItemSelected}:not(.clone)`).forEach(elItem => {
1351 elItem.remove();
1352 });
1353 itemsSelectedData.forEach(item => {
1354 const elItemSelected = elItemClone.cloneNode(true);
1355 elItemSelected.classList.remove('clone');
1356 Object.entries(item).forEach(([key, value]) => {
1357 elItemSelected.dataset[key] = value;
1358 });
1359 const elTitleDisplay = elItemSelected.querySelector('.title-display');
1360 elTitleDisplay.innerHTML = item.title;
1361 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elItemSelected, 1);
1362 elItemClone.insertAdjacentElement('beforebegin', elItemSelected);
1363 });
1364 };
1365
1366 // Back to list of items
1367 backToSelectItems = args => {
1368 const {
1369 e,
1370 target
1371 } = args;
1372 const elBtnBack = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnBackListItems}`);
1373 if (!elBtnBack) {
1374 return;
1375 }
1376 const elBtnCountItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1377 const elTabs = elPopup.querySelector('.tabs');
1378 const elListItemsWrap = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsWrap}`);
1379 const elHeaderCountItemSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1380 const elListItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsSelected}`);
1381 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnCountItemsSelected, 1);
1382 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsWrap, 1);
1383 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elTabs, 1);
1384 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnBack, 0);
1385 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elHeaderCountItemSelected, 0);
1386 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsSelected, 0);
1387 };
1388
1389 // Remove item selected from list items selected
1390 removeItemSelected = args => {
1391 const {
1392 e,
1393 target
1394 } = args;
1395 const elRemoveItemSelected = target.closest(`${LpPopupSelectItemToAdd.selectors.elItemSelected}`);
1396 if (!elRemoveItemSelected) {
1397 return;
1398 }
1399 const itemRemove = elRemoveItemSelected.dataset;
1400 const index = itemsSelectedData.findIndex(item => item.id === itemRemove.id);
1401 if (index !== -1) {
1402 itemsSelectedData.splice(index, 1);
1403 }
1404 elRemoveItemSelected.remove();
1405 this.watchItemsSelectedDataChange();
1406 };
1407
1408 // Watch items selected when data change
1409 watchItemsSelectedDataChange = () => {
1410 // Update count items selected, disable/enable buttons
1411 const elBtnAddItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected}`);
1412 const elBtnCountItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1413 const elSpanCount = elBtnCountItemsSelected.querySelector('span');
1414 const elHeaderCount = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1415 const elTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1416 if (itemsSelectedData.length !== 0) {
1417 elBtnCountItemsSelected.disabled = false;
1418 elBtnAddItemsSelected.disabled = false;
1419 elBtnAddItemsSelected.classList.add('active');
1420 elSpanCount.textContent = `(${itemsSelectedData.length})`;
1421 elHeaderCount.innerHTML = elBtnCountItemsSelected.innerHTML;
1422 } else {
1423 elBtnCountItemsSelected.disabled = true;
1424 elBtnAddItemsSelected.disabled = true;
1425 elBtnAddItemsSelected.classList.remove('active');
1426 elSpanCount.textContent = '';
1427 elHeaderCount.textContent = '';
1428 }
1429
1430 // Update list input checked, when items removed, or change tab type
1431 const elListItems = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItems}`);
1432 const elInputs = elListItems.querySelectorAll('input[type="checkbox"]');
1433 elInputs.forEach(elInputItem => {
1434 const itemSelected = elInputItem.dataset;
1435 const exists = itemsSelectedData.some(item => item.id === itemSelected.id);
1436 elInputItem.checked = exists;
1437 });
1438
1439 // Set item selecting data to dataset for query.
1440 const dataSet = window.lpAJAXG.getDataSetCurrent(elTarget);
1441 dataSet.args.item_selecting = itemsSelectedData;
1442 window.lpAJAXG.setDataSetCurrent(elTarget, dataSet);
1443 };
1444
1445 // Add items selected to section
1446 addItemsSelectedToSection = args => {
1447 const {
1448 e,
1449 target,
1450 callBackHandle
1451 } = args;
1452 if (!elPopup) {
1453 return;
1454 }
1455 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().close();
1456 if (typeof callBackHandle === 'function') {
1457 callBackHandle(itemsSelectedData);
1458 itemsSelectedData = [];
1459 }
1460 };
1461 }
1462
1463 /***/ },
1464
1465 /***/ "./assets/src/js/lpToastify.js"
1466 /*!*************************************!*\
1467 !*** ./assets/src/js/lpToastify.js ***!
1468 \*************************************/
1469 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1470
1471 "use strict";
1472 __webpack_require__.r(__webpack_exports__);
1473 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1474 /* harmony export */ show: () => (/* binding */ show)
1475 /* harmony export */ });
1476 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
1477 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
1478 /* 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");
1479 /**
1480 * Utils functions
1481 *
1482 * @param url
1483 * @param data
1484 * @param functions
1485 * @since 4.3.0
1486 * @version 1.0.0
1487 */
1488
1489
1490 const argsToastify = {
1491 text: '',
1492 gravity: lpData.toast.gravity,
1493 // `top` or `bottom`
1494 position: lpData.toast.position,
1495 // `left`, `center` or `right`
1496 className: `${lpData.toast.classPrefix}`,
1497 close: lpData.toast.close == 1,
1498 stopOnFocus: lpData.toast.stopOnFocus == 1,
1499 duration: lpData.toast.duration
1500 };
1501 const show = (message, status = 'success', argsCustom) => {
1502 let args = argsToastify;
1503 if (argsCustom) {
1504 args = {
1505 ...args,
1506 ...argsCustom
1507 };
1508 }
1509 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
1510 ...args,
1511 text: message,
1512 className: `${lpData.toast.classPrefix} ${status}`
1513 });
1514 toastify.showToast();
1515 };
1516
1517 /***/ },
1518
1519 /***/ "./assets/src/js/utils.js"
1520 /*!********************************!*\
1521 !*** ./assets/src/js/utils.js ***!
1522 \********************************/
1523 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1524
1525 "use strict";
1526 __webpack_require__.r(__webpack_exports__);
1527 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1528 /* harmony export */ debounce: () => (/* binding */ debounce),
1529 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
1530 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
1531 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
1532 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
1533 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
1534 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
1535 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
1536 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
1537 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
1538 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
1539 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
1540 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1541 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1542 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1543 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1544 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
1545 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
1546 /* harmony export */ });
1547 /**
1548 * Utils functions
1549 *
1550 * @param url
1551 * @param data
1552 * @param functions
1553 * @since 4.2.5.1
1554 * @version 1.0.7
1555 */
1556 const lpClassName = {
1557 hidden: 'lp-hidden',
1558 loading: 'loading',
1559 elCollapse: 'lp-collapse',
1560 elSectionToggle: '.lp-section-toggle',
1561 elTriggerToggle: '.lp-trigger-toggle',
1562 elBtnFullScreen: '.lp-btn-full-screen-view',
1563 elFullScreen: 'lp-full-screen-view',
1564 elBtnFullScreenClose: 'lp-full-screen-view__close'
1565 };
1566 const lpFetchAPI = (url, data = {}, functions = {}) => {
1567 if ('function' === typeof functions.before) {
1568 functions.before();
1569 }
1570 fetch(url, {
1571 method: 'GET',
1572 ...data
1573 }).then(response => response.json()).then(response => {
1574 if ('function' === typeof functions.success) {
1575 functions.success(response);
1576 }
1577 }).catch(err => {
1578 if ('function' === typeof functions.error) {
1579 functions.error(err);
1580 }
1581 }).finally(() => {
1582 if ('function' === typeof functions.completed) {
1583 functions.completed();
1584 }
1585 });
1586 };
1587
1588 /**
1589 * Get current URL without params.
1590 *
1591 * @since 4.2.5.1
1592 */
1593 const lpGetCurrentURLNoParam = () => {
1594 let currentUrl = window.location.href;
1595 const hasParams = currentUrl.includes('?');
1596 if (hasParams) {
1597 currentUrl = currentUrl.split('?')[0];
1598 }
1599 return currentUrl;
1600 };
1601 const lpAddQueryArgs = (endpoint, args) => {
1602 const url = new URL(endpoint);
1603 Object.keys(args).forEach(arg => {
1604 url.searchParams.set(arg, args[arg]);
1605 });
1606 return url;
1607 };
1608
1609 /**
1610 * Listen element viewed.
1611 *
1612 * @param el
1613 * @param callback
1614 * @since 4.2.5.8
1615 */
1616 const listenElementViewed = (el, callback) => {
1617 const observerSeeItem = new IntersectionObserver(function (entries) {
1618 for (const entry of entries) {
1619 if (entry.isIntersecting) {
1620 callback(entry);
1621 }
1622 }
1623 });
1624 observerSeeItem.observe(el);
1625 };
1626
1627 /**
1628 * Listen element created.
1629 *
1630 * @param callback
1631 * @since 4.2.5.8
1632 */
1633 const listenElementCreated = callback => {
1634 const observerCreateItem = new MutationObserver(function (mutations) {
1635 mutations.forEach(function (mutation) {
1636 if (mutation.addedNodes) {
1637 mutation.addedNodes.forEach(function (node) {
1638 if (node.nodeType === 1) {
1639 callback(node);
1640 }
1641 });
1642 }
1643 });
1644 });
1645 observerCreateItem.observe(document, {
1646 childList: true,
1647 subtree: true
1648 });
1649 // End.
1650 };
1651
1652 /**
1653 * Listen element created.
1654 *
1655 * @param selector
1656 * @param callback
1657 * @since 4.2.7.1
1658 */
1659 const lpOnElementReady = (selector, callback) => {
1660 const element = document.querySelector(selector);
1661 if (element) {
1662 callback(element);
1663 return;
1664 }
1665 const observer = new MutationObserver((mutations, obs) => {
1666 const element = document.querySelector(selector);
1667 if (element) {
1668 obs.disconnect();
1669 callback(element);
1670 }
1671 });
1672 observer.observe(document.documentElement, {
1673 childList: true,
1674 subtree: true
1675 });
1676 };
1677
1678 // Parse JSON from string with content include LP_AJAX_START.
1679 const lpAjaxParseJsonOld = data => {
1680 if (typeof data !== 'string') {
1681 return data;
1682 }
1683 const m = String.raw({
1684 raw: data
1685 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1686 try {
1687 if (m) {
1688 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1689 } else {
1690 data = JSON.parse(data);
1691 }
1692 } catch (e) {
1693 data = {};
1694 }
1695 return data;
1696 };
1697
1698 // status 0: hide, 1: show
1699 const lpShowHideEl = (el, status = 0) => {
1700 if (!el) {
1701 return;
1702 }
1703 if (!status) {
1704 el.classList.add(lpClassName.hidden);
1705 } else {
1706 el.classList.remove(lpClassName.hidden);
1707 }
1708 };
1709
1710 // status 0: hide, 1: show
1711 const lpSetLoadingEl = (el, status) => {
1712 if (!el) {
1713 return;
1714 }
1715 if (!status) {
1716 el.classList.remove(lpClassName.loading);
1717 } else {
1718 el.classList.add(lpClassName.loading);
1719 }
1720 };
1721
1722 // Toggle collapse section
1723 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1724 if (!elTriggerClassName) {
1725 elTriggerClassName = lpClassName.elTriggerToggle;
1726 }
1727
1728 // Exclude elements, which should not trigger the collapse toggle
1729 if (elsExclude && elsExclude.length > 0) {
1730 for (const elExclude of elsExclude) {
1731 if (target.closest(elExclude)) {
1732 return;
1733 }
1734 }
1735 }
1736 const elTrigger = target.closest(elTriggerClassName);
1737 if (!elTrigger) {
1738 return;
1739 }
1740
1741 //console.log( 'elTrigger', elTrigger );
1742
1743 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1744 if (!elSectionToggle) {
1745 return;
1746 }
1747 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1748 if ('function' === typeof callback) {
1749 callback(elSectionToggle);
1750 }
1751 };
1752
1753 // Get data of form
1754 const getDataOfForm = form => {
1755 const dataSend = {};
1756 const formData = new FormData(form);
1757 for (const pair of formData.entries()) {
1758 const key = pair[0];
1759 const value = formData.getAll(key);
1760 if (!dataSend.hasOwnProperty(key)) {
1761 // Convert value array to string.
1762 dataSend[key] = value.join(',');
1763 }
1764 }
1765 return dataSend;
1766 };
1767
1768 // Get field keys of form
1769 const getFieldKeysOfForm = form => {
1770 const keys = [];
1771 const elements = form.elements;
1772 for (let i = 0; i < elements.length; i++) {
1773 const name = elements[i].name;
1774 if (name && !keys.includes(name)) {
1775 keys.push(name);
1776 }
1777 }
1778 return keys;
1779 };
1780
1781 // Merge data handle with data form.
1782 const mergeDataWithDatForm = (elForm, dataHandle) => {
1783 const dataForm = getDataOfForm(elForm);
1784 const keys = getFieldKeysOfForm(elForm);
1785 keys.forEach(key => {
1786 if (!dataForm.hasOwnProperty(key)) {
1787 delete dataHandle[key];
1788 } else if (dataForm[key][0] === '') {
1789 delete dataForm[key];
1790 delete dataHandle[key];
1791 }
1792 });
1793 dataHandle = {
1794 ...dataHandle,
1795 ...dataForm
1796 };
1797 return dataHandle;
1798 };
1799
1800 /**
1801 * Event trigger
1802 * For each list of event handlers, listen event on document.
1803 *
1804 * eventName: 'click', 'change', ...
1805 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1806 *
1807 * @param eventName
1808 * @param eventHandlers
1809 */
1810 const eventHandlers = (eventName, eventHandlers) => {
1811 document.addEventListener(eventName, e => {
1812 const target = e.target;
1813 let args = {
1814 e,
1815 target
1816 };
1817 eventHandlers.forEach(eventHandler => {
1818 args = {
1819 ...args,
1820 ...eventHandler
1821 };
1822
1823 //console.log( args );
1824
1825 // Check condition before call back
1826 if (eventHandler.conditionBeforeCallBack) {
1827 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1828 return;
1829 }
1830 }
1831
1832 // Special check for keydown event with checkIsEventEnter = true
1833 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1834 if (e.key !== 'Enter') {
1835 return;
1836 }
1837 }
1838 if (target.closest(eventHandler.selector)) {
1839 if (eventHandler.class) {
1840 // Call method of class, function callBack will understand exactly {this} is class object.
1841 eventHandler.class[eventHandler.callBack](args);
1842 } else {
1843 // For send args is objected, {this} is eventHandler object, not class object.
1844 eventHandler.callBack(args);
1845 }
1846 }
1847 });
1848 });
1849 };
1850
1851 /**
1852 * Debounce - delays function execution until after `wait` ms of inactivity.
1853 *
1854 * Each call resets the timer. Only the last call in a burst executes.
1855 *
1856 * USE CASES:
1857 * - Search inputs, form validation, window resize
1858 * - Multiple elements need independent timers
1859 * - When you need to call with different arguments
1860 *
1861 * EXAMPLES:
1862 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1863 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1864 *
1865 * const debouncedResize = debounce( recalculateLayout, 250 );
1866 * window.addEventListener('resize', debouncedResize);
1867 *
1868 * ⚠️ Create ONCE outside event handlers, not inside.
1869 *
1870 * @param {Function} func - Function to debounce (can be anonymous)
1871 * @param {number} wait - Milliseconds to wait (default: 500)
1872 * @return {Function} Debounced wrapper function
1873 * @since 4.3.7
1874 * @version 1.0.0
1875 */
1876 const debounce = (func, wait = 500) => {
1877 let timer;
1878 return args => {
1879 clearTimeout(timer);
1880 timer = setTimeout(() => func(args), wait);
1881 };
1882 };
1883
1884 /**
1885 * Initialize lp-toggle-enable components.
1886 *
1887 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1888 * Reads initial state from `data-enabled` attribute ("true"/"false").
1889 * Calls `data-on-toggle` callback (if provided via options) on state change.
1890 *
1891 * HTML structure:
1892 * <label class="lp-toggle-enable" data-enabled="true">
1893 * <input type="checkbox" class="lp-toggle-enable__input" />
1894 * <span class="lp-toggle-enable__track"></span>
1895 * </label>
1896 *
1897 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1898 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1899 * @since 4.4.5
1900 * @version 1.0.0
1901 */
1902 window.lpToggleEnableInit = 0;
1903 const toggleEnable = (onToggle = null) => {
1904 if (window.lpToggleEnableInit) {
1905 return;
1906 }
1907 window.lpToggleEnableInit = 1;
1908 const selector = '.lp-toggle-enable';
1909 const updateUI = (toggle, isEnabled) => {
1910 toggle.classList.toggle('is-enabled', isEnabled);
1911 const input = toggle.querySelector('.lp-toggle-enable__input');
1912 if (input) {
1913 input.checked = isEnabled;
1914 input.value = isEnabled ? '1' : '0';
1915 }
1916 };
1917
1918 // Delegate click handling via eventHandlers.
1919 eventHandlers('click', [{
1920 selector,
1921 callBack: args => {
1922 const {
1923 e,
1924 target
1925 } = args;
1926 const toggle = target.closest(selector);
1927 if (!toggle || toggle.classList.contains('is-disabled')) {
1928 return;
1929 }
1930 e.preventDefault();
1931 const isEnabled = !toggle.classList.contains('is-enabled');
1932 updateUI(toggle, isEnabled);
1933 if ('function' === typeof onToggle) {
1934 onToggle(toggle, isEnabled);
1935 }
1936 }
1937 }]);
1938 };
1939
1940 /**
1941 * Initialize custom fullscreen view buttons.
1942 *
1943 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1944 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1945 * target element. Falls back to the button's parent element when
1946 * `data-target` is not provided.
1947 *
1948 * @since 4.4.5
1949 * @version 1.0.0
1950 */
1951 window.lpFullScreenViewInit = 0;
1952 const fullScreenView = () => {
1953 if (window.lpFullScreenViewInit) {
1954 return;
1955 }
1956 window.lpFullScreenViewInit = 1;
1957 let lastScrollY = 0;
1958 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1959 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1960 if (isFullscreen) {
1961 elTarget.classList.remove(lpClassName.elFullScreen);
1962 document.documentElement.classList.remove('lp-full-screen-active');
1963 window.scrollTo(0, lastScrollY);
1964 } else {
1965 lastScrollY = window.scrollY;
1966 elTarget.classList.add(lpClassName.elFullScreen);
1967 document.documentElement.classList.add('lp-full-screen-active');
1968 }
1969 if (!isFullscreen) {
1970 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1971 const closeButton = document.createElement('button');
1972 closeButton.type = 'button';
1973 closeButton.className = lpClassName.elBtnFullScreenClose;
1974 closeButton.setAttribute('aria-label', 'Close');
1975 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1976 closeButton.addEventListener('click', e => {
1977 e.preventDefault();
1978 lpToggleFullscreenView(elTarget);
1979 });
1980 elTarget.appendChild(closeButton);
1981 }
1982 } else {
1983 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1984 if (closeButton) {
1985 closeButton.remove();
1986 }
1987 }
1988 };
1989 eventHandlers('click', [{
1990 selector: lpClassName.elBtnFullScreen,
1991 callBack: args => {
1992 const {
1993 e,
1994 target
1995 } = args;
1996 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1997 if (!elBtnFullScreen) {
1998 console.log('No full screen button found');
1999 return;
2000 }
2001 e.preventDefault();
2002 let elTarget = null;
2003 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
2004 console.log(targetSelector);
2005 if (targetSelector) {
2006 elTarget = document.querySelector(targetSelector);
2007 }
2008 if (!elTarget) {
2009 console.log('No target element found');
2010 return;
2011 }
2012 lpToggleFullscreenView(elTarget, elBtnFullScreen);
2013 }
2014 }]);
2015 };
2016
2017 /***/ },
2018
2019 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
2020 /*!*****************************************************************************************!*\
2021 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
2022 \*****************************************************************************************/
2023 (module, __webpack_exports__, __webpack_require__) {
2024
2025 "use strict";
2026 __webpack_require__.r(__webpack_exports__);
2027 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2028 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2029 /* harmony export */ });
2030 /* 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");
2031 /* 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__);
2032 /* 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");
2033 /* 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__);
2034 // Imports
2035
2036
2037 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()));
2038 // Module
2039 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
2040 * Toastify js 1.12.0
2041 * https://github.com/apvarun/toastify-js
2042 * @license MIT licensed
2043 *
2044 * Copyright (C) 2018 Varun A P
2045 */
2046
2047 .toastify {
2048 padding: 12px 20px;
2049 color: #ffffff;
2050 display: inline-block;
2051 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
2052 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
2053 background: linear-gradient(135deg, #73a5ff, #5477f5);
2054 position: fixed;
2055 opacity: 0;
2056 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
2057 border-radius: 2px;
2058 cursor: pointer;
2059 text-decoration: none;
2060 max-width: calc(50% - 20px);
2061 z-index: 2147483647;
2062 }
2063
2064 .toastify.on {
2065 opacity: 1;
2066 }
2067
2068 .toast-close {
2069 background: transparent;
2070 border: 0;
2071 color: white;
2072 cursor: pointer;
2073 font-family: inherit;
2074 font-size: 1em;
2075 opacity: 0.4;
2076 padding: 0 5px;
2077 }
2078
2079 .toastify-right {
2080 right: 15px;
2081 }
2082
2083 .toastify-left {
2084 left: 15px;
2085 }
2086
2087 .toastify-top {
2088 top: -150px;
2089 }
2090
2091 .toastify-bottom {
2092 bottom: -150px;
2093 }
2094
2095 .toastify-rounded {
2096 border-radius: 25px;
2097 }
2098
2099 .toastify-avatar {
2100 width: 1.5em;
2101 height: 1.5em;
2102 margin: -7px 5px;
2103 border-radius: 2px;
2104 }
2105
2106 .toastify-center {
2107 margin-left: auto;
2108 margin-right: auto;
2109 left: 0;
2110 right: 0;
2111 max-width: fit-content;
2112 max-width: -moz-fit-content;
2113 }
2114
2115 @media only screen and (max-width: 360px) {
2116 .toastify-right, .toastify-left {
2117 margin-left: auto;
2118 margin-right: auto;
2119 left: 0;
2120 right: 0;
2121 max-width: fit-content;
2122 }
2123 }
2124 `, "",{"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":""}]);
2125 // Exports
2126 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
2127
2128
2129 /***/ },
2130
2131 /***/ "./node_modules/css-loader/dist/runtime/api.js"
2132 /*!*****************************************************!*\
2133 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
2134 \*****************************************************/
2135 (module) {
2136
2137 "use strict";
2138
2139
2140 /*
2141 MIT License http://www.opensource.org/licenses/mit-license.php
2142 Author Tobias Koppers @sokra
2143 */
2144 module.exports = function (cssWithMappingToString) {
2145 var list = [];
2146
2147 // return the list of modules as css string
2148 list.toString = function toString() {
2149 return this.map(function (item) {
2150 var content = "";
2151 var needLayer = typeof item[5] !== "undefined";
2152 if (item[4]) {
2153 content += "@supports (".concat(item[4], ") {");
2154 }
2155 if (item[2]) {
2156 content += "@media ".concat(item[2], " {");
2157 }
2158 if (needLayer) {
2159 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
2160 }
2161 content += cssWithMappingToString(item);
2162 if (needLayer) {
2163 content += "}";
2164 }
2165 if (item[2]) {
2166 content += "}";
2167 }
2168 if (item[4]) {
2169 content += "}";
2170 }
2171 return content;
2172 }).join("");
2173 };
2174
2175 // import a list of modules into the list
2176 list.i = function i(modules, media, dedupe, supports, layer) {
2177 if (typeof modules === "string") {
2178 modules = [[null, modules, undefined]];
2179 }
2180 var alreadyImportedModules = {};
2181 if (dedupe) {
2182 for (var k = 0; k < this.length; k++) {
2183 var id = this[k][0];
2184 if (id != null) {
2185 alreadyImportedModules[id] = true;
2186 }
2187 }
2188 }
2189 for (var _k = 0; _k < modules.length; _k++) {
2190 var item = [].concat(modules[_k]);
2191 if (dedupe && alreadyImportedModules[item[0]]) {
2192 continue;
2193 }
2194 if (typeof layer !== "undefined") {
2195 if (typeof item[5] === "undefined") {
2196 item[5] = layer;
2197 } else {
2198 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
2199 item[5] = layer;
2200 }
2201 }
2202 if (media) {
2203 if (!item[2]) {
2204 item[2] = media;
2205 } else {
2206 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
2207 item[2] = media;
2208 }
2209 }
2210 if (supports) {
2211 if (!item[4]) {
2212 item[4] = "".concat(supports);
2213 } else {
2214 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
2215 item[4] = supports;
2216 }
2217 }
2218 list.push(item);
2219 }
2220 };
2221 return list;
2222 };
2223
2224 /***/ },
2225
2226 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
2227 /*!************************************************************!*\
2228 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
2229 \************************************************************/
2230 (module) {
2231
2232 "use strict";
2233
2234
2235 module.exports = function (item) {
2236 var content = item[1];
2237 var cssMapping = item[3];
2238 if (!cssMapping) {
2239 return content;
2240 }
2241 if (typeof btoa === "function") {
2242 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
2243 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
2244 var sourceMapping = "/*# ".concat(data, " */");
2245 return [content].concat([sourceMapping]).join("\n");
2246 }
2247 return [content].join("\n");
2248 };
2249
2250 /***/ },
2251
2252 /***/ "./node_modules/toastify-js/src/toastify.css"
2253 /*!***************************************************!*\
2254 !*** ./node_modules/toastify-js/src/toastify.css ***!
2255 \***************************************************/
2256 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2257
2258 "use strict";
2259 __webpack_require__.r(__webpack_exports__);
2260 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2261 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2262 /* harmony export */ });
2263 /* 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");
2264 /* 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__);
2265 /* 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");
2266 /* 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__);
2267 /* 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");
2268 /* 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__);
2269 /* 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");
2270 /* 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__);
2271 /* 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");
2272 /* 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__);
2273 /* 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");
2274 /* 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__);
2275 /* 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");
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287 var options = {};
2288
2289 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
2290 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
2291
2292 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
2293
2294 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
2295 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
2296
2297 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);
2298
2299
2300
2301
2302 /* 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);
2303
2304
2305 /***/ },
2306
2307 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
2308 /*!****************************************************************************!*\
2309 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
2310 \****************************************************************************/
2311 (module) {
2312
2313 "use strict";
2314
2315
2316 var stylesInDOM = [];
2317 function getIndexByIdentifier(identifier) {
2318 var result = -1;
2319 for (var i = 0; i < stylesInDOM.length; i++) {
2320 if (stylesInDOM[i].identifier === identifier) {
2321 result = i;
2322 break;
2323 }
2324 }
2325 return result;
2326 }
2327 function modulesToDom(list, options) {
2328 var idCountMap = {};
2329 var identifiers = [];
2330 for (var i = 0; i < list.length; i++) {
2331 var item = list[i];
2332 var id = options.base ? item[0] + options.base : item[0];
2333 var count = idCountMap[id] || 0;
2334 var identifier = "".concat(id, " ").concat(count);
2335 idCountMap[id] = count + 1;
2336 var indexByIdentifier = getIndexByIdentifier(identifier);
2337 var obj = {
2338 css: item[1],
2339 media: item[2],
2340 sourceMap: item[3],
2341 supports: item[4],
2342 layer: item[5]
2343 };
2344 if (indexByIdentifier !== -1) {
2345 stylesInDOM[indexByIdentifier].references++;
2346 stylesInDOM[indexByIdentifier].updater(obj);
2347 } else {
2348 var updater = addElementStyle(obj, options);
2349 options.byIndex = i;
2350 stylesInDOM.splice(i, 0, {
2351 identifier: identifier,
2352 updater: updater,
2353 references: 1
2354 });
2355 }
2356 identifiers.push(identifier);
2357 }
2358 return identifiers;
2359 }
2360 function addElementStyle(obj, options) {
2361 var api = options.domAPI(options);
2362 api.update(obj);
2363 var updater = function updater(newObj) {
2364 if (newObj) {
2365 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
2366 return;
2367 }
2368 api.update(obj = newObj);
2369 } else {
2370 api.remove();
2371 }
2372 };
2373 return updater;
2374 }
2375 module.exports = function (list, options) {
2376 options = options || {};
2377 list = list || [];
2378 var lastIdentifiers = modulesToDom(list, options);
2379 return function update(newList) {
2380 newList = newList || [];
2381 for (var i = 0; i < lastIdentifiers.length; i++) {
2382 var identifier = lastIdentifiers[i];
2383 var index = getIndexByIdentifier(identifier);
2384 stylesInDOM[index].references--;
2385 }
2386 var newLastIdentifiers = modulesToDom(newList, options);
2387 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
2388 var _identifier = lastIdentifiers[_i];
2389 var _index = getIndexByIdentifier(_identifier);
2390 if (stylesInDOM[_index].references === 0) {
2391 stylesInDOM[_index].updater();
2392 stylesInDOM.splice(_index, 1);
2393 }
2394 }
2395 lastIdentifiers = newLastIdentifiers;
2396 };
2397 };
2398
2399 /***/ },
2400
2401 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
2402 /*!********************************************************************!*\
2403 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
2404 \********************************************************************/
2405 (module) {
2406
2407 "use strict";
2408
2409
2410 var memo = {};
2411
2412 /* istanbul ignore next */
2413 function getTarget(target) {
2414 if (typeof memo[target] === "undefined") {
2415 var styleTarget = document.querySelector(target);
2416
2417 // Special case to return head of iframe instead of iframe itself
2418 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
2419 try {
2420 // This will throw an exception if access to iframe is blocked
2421 // due to cross-origin restrictions
2422 styleTarget = styleTarget.contentDocument.head;
2423 } catch (e) {
2424 // istanbul ignore next
2425 styleTarget = null;
2426 }
2427 }
2428 memo[target] = styleTarget;
2429 }
2430 return memo[target];
2431 }
2432
2433 /* istanbul ignore next */
2434 function insertBySelector(insert, style) {
2435 var target = getTarget(insert);
2436 if (!target) {
2437 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
2438 }
2439 target.appendChild(style);
2440 }
2441 module.exports = insertBySelector;
2442
2443 /***/ },
2444
2445 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
2446 /*!**********************************************************************!*\
2447 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
2448 \**********************************************************************/
2449 (module) {
2450
2451 "use strict";
2452
2453
2454 /* istanbul ignore next */
2455 function insertStyleElement(options) {
2456 var element = document.createElement("style");
2457 options.setAttributes(element, options.attributes);
2458 options.insert(element, options.options);
2459 return element;
2460 }
2461 module.exports = insertStyleElement;
2462
2463 /***/ },
2464
2465 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
2466 /*!**********************************************************************************!*\
2467 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
2468 \**********************************************************************************/
2469 (module, __unused_webpack_exports, __webpack_require__) {
2470
2471 "use strict";
2472
2473
2474 /* istanbul ignore next */
2475 function setAttributesWithoutAttributes(styleElement) {
2476 var nonce = true ? __webpack_require__.nc : 0;
2477 if (nonce) {
2478 styleElement.setAttribute("nonce", nonce);
2479 }
2480 }
2481 module.exports = setAttributesWithoutAttributes;
2482
2483 /***/ },
2484
2485 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
2486 /*!***************************************************************!*\
2487 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
2488 \***************************************************************/
2489 (module) {
2490
2491 "use strict";
2492
2493
2494 /* istanbul ignore next */
2495 function apply(styleElement, options, obj) {
2496 var css = "";
2497 if (obj.supports) {
2498 css += "@supports (".concat(obj.supports, ") {");
2499 }
2500 if (obj.media) {
2501 css += "@media ".concat(obj.media, " {");
2502 }
2503 var needLayer = typeof obj.layer !== "undefined";
2504 if (needLayer) {
2505 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
2506 }
2507 css += obj.css;
2508 if (needLayer) {
2509 css += "}";
2510 }
2511 if (obj.media) {
2512 css += "}";
2513 }
2514 if (obj.supports) {
2515 css += "}";
2516 }
2517 var sourceMap = obj.sourceMap;
2518 if (sourceMap && typeof btoa !== "undefined") {
2519 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
2520 }
2521
2522 // For old IE
2523 /* istanbul ignore if */
2524 options.styleTagTransform(css, styleElement, options.options);
2525 }
2526 function removeStyleElement(styleElement) {
2527 // istanbul ignore if
2528 if (styleElement.parentNode === null) {
2529 return false;
2530 }
2531 styleElement.parentNode.removeChild(styleElement);
2532 }
2533
2534 /* istanbul ignore next */
2535 function domAPI(options) {
2536 if (typeof document === "undefined") {
2537 return {
2538 update: function update() {},
2539 remove: function remove() {}
2540 };
2541 }
2542 var styleElement = options.insertStyleElement(options);
2543 return {
2544 update: function update(obj) {
2545 apply(styleElement, options, obj);
2546 },
2547 remove: function remove() {
2548 removeStyleElement(styleElement);
2549 }
2550 };
2551 }
2552 module.exports = domAPI;
2553
2554 /***/ },
2555
2556 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
2557 /*!*********************************************************************!*\
2558 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
2559 \*********************************************************************/
2560 (module) {
2561
2562 "use strict";
2563
2564
2565 /* istanbul ignore next */
2566 function styleTagTransform(css, styleElement) {
2567 if (styleElement.styleSheet) {
2568 styleElement.styleSheet.cssText = css;
2569 } else {
2570 while (styleElement.firstChild) {
2571 styleElement.removeChild(styleElement.firstChild);
2572 }
2573 styleElement.appendChild(document.createTextNode(css));
2574 }
2575 }
2576 module.exports = styleTagTransform;
2577
2578 /***/ },
2579
2580 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
2581 /*!**********************************************************!*\
2582 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
2583 \**********************************************************/
2584 (module) {
2585
2586 /*!
2587 * sweetalert2 v11.26.25
2588 * Released under the MIT License.
2589 */
2590 (function (global, factory) {
2591 true ? module.exports = factory() :
2592 0;
2593 })(this, (function () { 'use strict';
2594
2595 function _assertClassBrand(e, t, n) {
2596 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2597 throw new TypeError("Private element is not present on this object");
2598 }
2599 function _checkPrivateRedeclaration(e, t) {
2600 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2601 }
2602 function _classPrivateFieldGet2(s, a) {
2603 return s.get(_assertClassBrand(s, a));
2604 }
2605 function _classPrivateFieldInitSpec(e, t, a) {
2606 _checkPrivateRedeclaration(e, t), t.set(e, a);
2607 }
2608 function _classPrivateFieldSet2(s, a, r) {
2609 return s.set(_assertClassBrand(s, a), r), r;
2610 }
2611
2612 const RESTORE_FOCUS_TIMEOUT = 100;
2613
2614 /** @type {GlobalState} */
2615 const globalState = {};
2616 const focusPreviousActiveElement = () => {
2617 if (globalState.previousActiveElement instanceof HTMLElement) {
2618 globalState.previousActiveElement.focus();
2619 globalState.previousActiveElement = null;
2620 } else if (document.body) {
2621 document.body.focus();
2622 }
2623 };
2624
2625 /**
2626 * Restore previous active (focused) element
2627 *
2628 * @param {boolean} returnFocus
2629 * @returns {Promise<void>}
2630 */
2631 const restoreActiveElement = returnFocus => {
2632 return new Promise(resolve => {
2633 if (!returnFocus) {
2634 return resolve();
2635 }
2636 const x = window.scrollX;
2637 const y = window.scrollY;
2638 globalState.restoreFocusTimeout = setTimeout(() => {
2639 focusPreviousActiveElement();
2640 resolve();
2641 }, RESTORE_FOCUS_TIMEOUT); // issues/900
2642
2643 window.scrollTo(x, y);
2644 });
2645 };
2646
2647 const swalPrefix = 'swal2-';
2648
2649 /**
2650 * @typedef {Record<SwalClass, string>} SwalClasses
2651 */
2652
2653 /**
2654 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
2655 * @typedef {Record<SwalIcon, string>} SwalIcons
2656 */
2657
2658 /** @type {SwalClass[]} */
2659 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'];
2660 const swalClasses = classNames.reduce((acc, className) => {
2661 acc[className] = swalPrefix + className;
2662 return acc;
2663 }, /** @type {SwalClasses} */{});
2664
2665 /** @type {SwalIcon[]} */
2666 const icons = ['success', 'warning', 'info', 'question', 'error'];
2667 const iconTypes = icons.reduce((acc, icon) => {
2668 acc[icon] = swalPrefix + icon;
2669 return acc;
2670 }, /** @type {SwalIcons} */{});
2671
2672 const consolePrefix = 'SweetAlert2:';
2673
2674 /**
2675 * Capitalize the first letter of a string
2676 *
2677 * @param {string} str
2678 * @returns {string}
2679 */
2680 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2681
2682 /**
2683 * Standardize console warnings
2684 *
2685 * @param {string | string[]} message
2686 */
2687 const warn = message => {
2688 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2689 };
2690
2691 /**
2692 * Standardize console errors
2693 *
2694 * @param {string} message
2695 */
2696 const error = message => {
2697 console.error(`${consolePrefix} ${message}`);
2698 };
2699
2700 /**
2701 * Private global state for `warnOnce`
2702 *
2703 * @type {string[]}
2704 * @private
2705 */
2706 const previousWarnOnceMessages = [];
2707
2708 /**
2709 * Show a console warning, but only if it hasn't already been shown
2710 *
2711 * @param {string} message
2712 */
2713 const warnOnce = message => {
2714 if (!previousWarnOnceMessages.includes(message)) {
2715 previousWarnOnceMessages.push(message);
2716 warn(message);
2717 }
2718 };
2719
2720 /**
2721 * Show a one-time console warning about deprecated params/methods
2722 *
2723 * @param {string} deprecatedParam
2724 * @param {string?} useInstead
2725 */
2726 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2727 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2728 };
2729
2730 /**
2731 * If `arg` is a function, call it (with no arguments or context) and return the result.
2732 * Otherwise, just pass the value through
2733 *
2734 * @param {(() => *) | *} arg
2735 * @returns {*}
2736 */
2737 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2738
2739 /**
2740 * @param {*} arg
2741 * @returns {boolean}
2742 */
2743 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2744
2745 /**
2746 * @param {*} arg
2747 * @returns {Promise<*>}
2748 */
2749 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2750
2751 /**
2752 * @param {*} arg
2753 * @returns {boolean}
2754 */
2755 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2756
2757 /**
2758 * @returns {boolean}
2759 */
2760 const isFirefox = () => navigator.userAgent.includes('Firefox');
2761
2762 /**
2763 * Gets the popup container which contains the backdrop and the popup itself.
2764 *
2765 * @returns {HTMLElement | null}
2766 */
2767 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2768
2769 /**
2770 * @param {string} selectorString
2771 * @returns {HTMLElement | null}
2772 */
2773 const elementBySelector = selectorString => {
2774 const container = getContainer();
2775 return container ? container.querySelector(selectorString) : null;
2776 };
2777
2778 /**
2779 * @param {string} className
2780 * @returns {HTMLElement | null}
2781 */
2782 const elementByClass = className => {
2783 return elementBySelector(`.${className}`);
2784 };
2785
2786 /**
2787 * @returns {HTMLElement | null}
2788 */
2789 const getPopup = () => elementByClass(swalClasses.popup);
2790
2791 /**
2792 * @returns {HTMLElement | null}
2793 */
2794 const getIcon = () => elementByClass(swalClasses.icon);
2795
2796 /**
2797 * @returns {HTMLElement | null}
2798 */
2799 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2800
2801 /**
2802 * @returns {HTMLElement | null}
2803 */
2804 const getTitle = () => elementByClass(swalClasses.title);
2805
2806 /**
2807 * @returns {HTMLElement | null}
2808 */
2809 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2810
2811 /**
2812 * @returns {HTMLElement | null}
2813 */
2814 const getImage = () => elementByClass(swalClasses.image);
2815
2816 /**
2817 * @returns {HTMLElement | null}
2818 */
2819 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2820
2821 /**
2822 * @returns {HTMLElement | null}
2823 */
2824 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2825
2826 /**
2827 * @returns {HTMLButtonElement | null}
2828 */
2829 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2830
2831 /**
2832 * @returns {HTMLButtonElement | null}
2833 */
2834 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2835
2836 /**
2837 * @returns {HTMLButtonElement | null}
2838 */
2839 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2840
2841 /**
2842 * @returns {HTMLElement | null}
2843 */
2844 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2845
2846 /**
2847 * @returns {HTMLElement | null}
2848 */
2849 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2850
2851 /**
2852 * @returns {HTMLElement | null}
2853 */
2854 const getActions = () => elementByClass(swalClasses.actions);
2855
2856 /**
2857 * @returns {HTMLElement | null}
2858 */
2859 const getFooter = () => elementByClass(swalClasses.footer);
2860
2861 /**
2862 * @returns {HTMLElement | null}
2863 */
2864 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2865
2866 /**
2867 * @returns {HTMLElement | null}
2868 */
2869 const getCloseButton = () => elementByClass(swalClasses.close);
2870
2871 // https://github.com/jkup/focusable/blob/master/index.js
2872 const focusable = `
2873 a[href],
2874 area[href],
2875 input:not([disabled]),
2876 select:not([disabled]),
2877 textarea:not([disabled]),
2878 button:not([disabled]),
2879 iframe,
2880 object,
2881 embed,
2882 [tabindex="0"],
2883 [contenteditable],
2884 audio[controls],
2885 video[controls],
2886 summary
2887 `;
2888 /**
2889 * @returns {HTMLElement[]}
2890 */
2891 const getFocusableElements = () => {
2892 const popup = getPopup();
2893 if (!popup) {
2894 return [];
2895 }
2896 /** @type {NodeListOf<HTMLElement>} */
2897 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2898 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2899 // sort according to tabindex
2900 .sort((a, b) => {
2901 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2902 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2903 if (tabindexA > tabindexB) {
2904 return 1;
2905 } else if (tabindexA < tabindexB) {
2906 return -1;
2907 }
2908 return 0;
2909 });
2910
2911 /** @type {NodeListOf<HTMLElement>} */
2912 const otherFocusableElements = popup.querySelectorAll(focusable);
2913 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2914 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2915 };
2916
2917 /**
2918 * @returns {boolean}
2919 */
2920 const isModal = () => {
2921 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2922 };
2923
2924 /**
2925 * @returns {boolean}
2926 */
2927 const isToast = () => {
2928 const popup = getPopup();
2929 if (!popup) {
2930 return false;
2931 }
2932 return hasClass(popup, swalClasses.toast);
2933 };
2934
2935 /**
2936 * @returns {boolean}
2937 */
2938 const isLoading = () => {
2939 const popup = getPopup();
2940 if (!popup) {
2941 return false;
2942 }
2943 return popup.hasAttribute('data-loading');
2944 };
2945
2946 /**
2947 * Securely set innerHTML of an element
2948 * https://github.com/sweetalert2/sweetalert2/issues/1926
2949 *
2950 * @param {HTMLElement} elem
2951 * @param {string} html
2952 */
2953 const setInnerHtml = (elem, html) => {
2954 elem.textContent = '';
2955 if (html) {
2956 const parser = new DOMParser();
2957 const parsed = parser.parseFromString(html, `text/html`);
2958 const head = parsed.querySelector('head');
2959 if (head) {
2960 Array.from(head.childNodes).forEach(child => {
2961 elem.appendChild(child);
2962 });
2963 }
2964 const body = parsed.querySelector('body');
2965 if (body) {
2966 Array.from(body.childNodes).forEach(child => {
2967 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2968 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2969 } else {
2970 elem.appendChild(child);
2971 }
2972 });
2973 }
2974 }
2975 };
2976
2977 /**
2978 * @param {HTMLElement} elem
2979 * @param {string} className
2980 * @returns {boolean}
2981 */
2982 const hasClass = (elem, className) => {
2983 if (!className) {
2984 return false;
2985 }
2986 return className.split(/\s+/).every(cls => elem.classList.contains(cls));
2987 };
2988
2989 /**
2990 * @param {HTMLElement} elem
2991 * @param {SweetAlertOptions} params
2992 */
2993 const removeCustomClasses = (elem, params) => {
2994 Array.from(elem.classList).forEach(className => {
2995 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2996 elem.classList.remove(className);
2997 }
2998 });
2999 };
3000
3001 /**
3002 * @param {HTMLElement} elem
3003 * @param {SweetAlertOptions} params
3004 * @param {string} className
3005 */
3006 const applyCustomClass = (elem, params, className) => {
3007 removeCustomClasses(elem, params);
3008 if (!params.customClass) {
3009 return;
3010 }
3011 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
3012 if (!customClass) {
3013 return;
3014 }
3015 if (typeof customClass !== 'string' && !customClass.forEach) {
3016 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
3017 return;
3018 }
3019 addClass(elem, customClass);
3020 };
3021
3022 /**
3023 * @param {HTMLElement} popup
3024 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
3025 * @returns {HTMLInputElement | null}
3026 */
3027 const getInput$1 = (popup, inputClass) => {
3028 if (!inputClass) {
3029 return null;
3030 }
3031 switch (inputClass) {
3032 case 'select':
3033 case 'textarea':
3034 case 'file':
3035 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
3036 case 'checkbox':
3037 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
3038 case 'radio':
3039 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
3040 case 'range':
3041 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
3042 default:
3043 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
3044 }
3045 };
3046
3047 /**
3048 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
3049 */
3050 const focusInput = input => {
3051 input.focus();
3052
3053 // place cursor at end of text in text input
3054 if (input.type !== 'file') {
3055 // http://stackoverflow.com/a/2345915
3056 const val = input.value;
3057 input.value = '';
3058 input.value = val;
3059 }
3060 };
3061
3062 /**
3063 * @param {HTMLElement | HTMLElement[] | null} target
3064 * @param {string | string[] | readonly string[] | undefined} classList
3065 * @param {boolean} condition
3066 */
3067 const toggleClass = (target, classList, condition) => {
3068 if (!target || !classList) {
3069 return;
3070 }
3071 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
3072 const targets = Array.isArray(target) ? target : [target];
3073 targets.forEach(elem => {
3074 classes.forEach(className => {
3075 if (condition) {
3076 elem.classList.add(className);
3077 } else {
3078 elem.classList.remove(className);
3079 }
3080 });
3081 });
3082 };
3083
3084 /**
3085 * @param {HTMLElement | HTMLElement[] | null} target
3086 * @param {string | string[] | readonly string[] | undefined} classList
3087 */
3088 const addClass = (target, classList) => {
3089 toggleClass(target, classList, true);
3090 };
3091
3092 /**
3093 * @param {HTMLElement | HTMLElement[] | null} target
3094 * @param {string | string[] | readonly string[] | undefined} classList
3095 */
3096 const removeClass = (target, classList) => {
3097 toggleClass(target, classList, false);
3098 };
3099
3100 /**
3101 * Get direct child of an element by class name
3102 *
3103 * @param {HTMLElement} elem
3104 * @param {string} className
3105 * @returns {HTMLElement | undefined}
3106 */
3107 const getDirectChildByClass = (elem, className) => (/** @type {HTMLElement | undefined} */
3108 Array.from(elem.children).find(child => child instanceof HTMLElement && hasClass(child, className)));
3109
3110 /**
3111 * @param {HTMLElement} elem
3112 * @param {string} property
3113 * @param {string | number | null | undefined} value
3114 */
3115 const applyNumericalStyle = (elem, property, value) => {
3116 if (value === `${parseInt(`${value}`)}`) {
3117 value = parseInt(value);
3118 }
3119 if (value || value === 0) {
3120 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
3121 } else {
3122 elem.style.removeProperty(property);
3123 }
3124 };
3125
3126 /**
3127 * @param {HTMLElement | null} elem
3128 * @param {string} display
3129 */
3130 const show = (elem, display = 'flex') => {
3131 if (!elem) {
3132 return;
3133 }
3134 elem.style.display = display;
3135 };
3136
3137 /**
3138 * @param {HTMLElement | null} elem
3139 */
3140 const hide = elem => {
3141 if (!elem) {
3142 return;
3143 }
3144 elem.style.display = 'none';
3145 };
3146
3147 /**
3148 * @param {HTMLElement | null} elem
3149 * @param {string} display
3150 */
3151 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
3152 if (!elem) {
3153 return;
3154 }
3155 new MutationObserver(() => {
3156 toggle(elem, elem.innerHTML, display);
3157 }).observe(elem, {
3158 childList: true,
3159 subtree: true
3160 });
3161 };
3162
3163 /**
3164 * @param {HTMLElement} parent
3165 * @param {string} selector
3166 * @param {string} property
3167 * @param {string} value
3168 */
3169 const setStyle = (parent, selector, property, value) => {
3170 /** @type {HTMLElement | null} */
3171 const el = parent.querySelector(selector);
3172 if (el) {
3173 el.style.setProperty(property, value);
3174 }
3175 };
3176
3177 /**
3178 * @param {HTMLElement} elem
3179 * @param {boolean | string | null | undefined} condition
3180 * @param {string} display
3181 */
3182 const toggle = (elem, condition, display = 'flex') => {
3183 if (condition) {
3184 show(elem, display);
3185 } else {
3186 hide(elem);
3187 }
3188 };
3189
3190 /**
3191 * borrowed from jquery $(elem).is(':visible') implementation
3192 *
3193 * @param {HTMLElement | null} elem
3194 * @returns {boolean}
3195 */
3196 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
3197
3198 /**
3199 * @returns {boolean}
3200 */
3201 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
3202
3203 /**
3204 * @param {HTMLElement} elem
3205 * @returns {boolean}
3206 */
3207 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
3208
3209 /**
3210 * @param {HTMLElement} element
3211 * @param {HTMLElement} stopElement
3212 * @returns {boolean}
3213 */
3214 const selfOrParentIsScrollable = (element, stopElement) => {
3215 let parent = /** @type {HTMLElement | null} */element;
3216 while (parent && parent !== stopElement) {
3217 if (isScrollable(parent)) {
3218 return true;
3219 }
3220 parent = parent.parentElement;
3221 }
3222 return false;
3223 };
3224
3225 /**
3226 * borrowed from https://stackoverflow.com/a/46352119
3227 *
3228 * @param {HTMLElement} elem
3229 * @returns {boolean}
3230 */
3231 const hasCssAnimation = elem => {
3232 const style = window.getComputedStyle(elem);
3233 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
3234 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
3235 return animDuration > 0 || transDuration > 0;
3236 };
3237
3238 /**
3239 * @param {number} timer
3240 * @param {boolean} reset
3241 */
3242 const animateTimerProgressBar = (timer, reset = false) => {
3243 const timerProgressBar = getTimerProgressBar();
3244 if (!timerProgressBar) {
3245 return;
3246 }
3247 if (isVisible$1(timerProgressBar)) {
3248 if (reset) {
3249 timerProgressBar.style.transition = 'none';
3250 timerProgressBar.style.width = '100%';
3251 }
3252 setTimeout(() => {
3253 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
3254 timerProgressBar.style.width = '0%';
3255 }, 10);
3256 }
3257 };
3258 const stopTimerProgressBar = () => {
3259 const timerProgressBar = getTimerProgressBar();
3260 if (!timerProgressBar) {
3261 return;
3262 }
3263 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
3264 timerProgressBar.style.removeProperty('transition');
3265 timerProgressBar.style.width = '100%';
3266 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
3267 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
3268 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
3269 };
3270
3271 /**
3272 * Detect Node env
3273 *
3274 * @returns {boolean}
3275 */
3276 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
3277
3278 const sweetHTML = `
3279 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
3280 <button type="button" class="${swalClasses.close}"></button>
3281 <ul class="${swalClasses['progress-steps']}"></ul>
3282 <div class="${swalClasses.icon}"></div>
3283 <img class="${swalClasses.image}" />
3284 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
3285 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
3286 <input class="${swalClasses.input}" id="${swalClasses.input}" />
3287 <input type="file" class="${swalClasses.file}" />
3288 <div class="${swalClasses.range}">
3289 <input type="range" />
3290 <output></output>
3291 </div>
3292 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
3293 <div class="${swalClasses.radio}"></div>
3294 <label class="${swalClasses.checkbox}">
3295 <input type="checkbox" id="${swalClasses.checkbox}" />
3296 <span class="${swalClasses.label}"></span>
3297 </label>
3298 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
3299 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
3300 <div class="${swalClasses.actions}">
3301 <div class="${swalClasses.loader}"></div>
3302 <button type="button" class="${swalClasses.confirm}"></button>
3303 <button type="button" class="${swalClasses.deny}"></button>
3304 <button type="button" class="${swalClasses.cancel}"></button>
3305 </div>
3306 <div class="${swalClasses.footer}"></div>
3307 <div class="${swalClasses['timer-progress-bar-container']}">
3308 <div class="${swalClasses['timer-progress-bar']}"></div>
3309 </div>
3310 </div>
3311 `.replace(/(^|\n)\s*/g, '');
3312
3313 /**
3314 * @returns {boolean}
3315 */
3316 const resetOldContainer = () => {
3317 const oldContainer = getContainer();
3318 if (!oldContainer) {
3319 return false;
3320 }
3321 oldContainer.remove();
3322 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
3323 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
3324 swalClasses['has-column']]);
3325 return true;
3326 };
3327 const resetValidationMessage$1 = () => {
3328 if (globalState.currentInstance) {
3329 globalState.currentInstance.resetValidationMessage();
3330 }
3331 };
3332 const addInputChangeListeners = () => {
3333 const popup = getPopup();
3334 if (!popup) {
3335 return;
3336 }
3337 const input = getDirectChildByClass(popup, swalClasses.input);
3338 const file = getDirectChildByClass(popup, swalClasses.file);
3339 /** @type {HTMLInputElement | null} */
3340 const range = popup.querySelector(`.${swalClasses.range} input`);
3341 /** @type {HTMLOutputElement | null} */
3342 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
3343 const select = getDirectChildByClass(popup, swalClasses.select);
3344 /** @type {HTMLInputElement | null} */
3345 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
3346 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
3347 if (input) {
3348 input.oninput = resetValidationMessage$1;
3349 }
3350 if (file) {
3351 file.onchange = resetValidationMessage$1;
3352 }
3353 if (select) {
3354 select.onchange = resetValidationMessage$1;
3355 }
3356 if (checkbox) {
3357 checkbox.onchange = resetValidationMessage$1;
3358 }
3359 if (textarea) {
3360 textarea.oninput = resetValidationMessage$1;
3361 }
3362 if (range && rangeOutput) {
3363 range.oninput = () => {
3364 resetValidationMessage$1();
3365 rangeOutput.value = range.value;
3366 };
3367 range.onchange = () => {
3368 resetValidationMessage$1();
3369 rangeOutput.value = range.value;
3370 };
3371 }
3372 };
3373
3374 /**
3375 * @param {string | HTMLElement} target
3376 * @returns {HTMLElement}
3377 */
3378 const getTarget = target => {
3379 if (typeof target === 'string') {
3380 const element = document.querySelector(target);
3381 if (!element) {
3382 throw new Error(`Target element "${target}" not found`);
3383 }
3384 return /** @type {HTMLElement} */element;
3385 }
3386 return target;
3387 };
3388
3389 /**
3390 * @param {SweetAlertOptions} params
3391 */
3392 const setupAccessibility = params => {
3393 const popup = getPopup();
3394 if (!popup) {
3395 return;
3396 }
3397 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
3398 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
3399 if (!params.toast) {
3400 popup.setAttribute('aria-modal', 'true');
3401 }
3402 };
3403
3404 /**
3405 * @param {HTMLElement} targetElement
3406 */
3407 const setupRTL = targetElement => {
3408 if (window.getComputedStyle(targetElement).direction === 'rtl') {
3409 addClass(getContainer(), swalClasses.rtl);
3410 globalState.isRTL = true;
3411 }
3412 };
3413
3414 /**
3415 * Add modal + backdrop to DOM
3416 *
3417 * @param {SweetAlertOptions} params
3418 */
3419 const init = params => {
3420 // Clean up the old popup container if it exists
3421 const oldContainerExisted = resetOldContainer();
3422 if (isNodeEnv()) {
3423 error('SweetAlert2 requires document to initialize');
3424 return;
3425 }
3426 const container = document.createElement('div');
3427 container.className = swalClasses.container;
3428 if (oldContainerExisted) {
3429 addClass(container, swalClasses['no-transition']);
3430 }
3431 setInnerHtml(container, sweetHTML);
3432 container.dataset['swal2Theme'] = params.theme;
3433 const targetElement = getTarget(params.target || 'body');
3434 targetElement.appendChild(container);
3435 if (params.topLayer) {
3436 container.setAttribute('popover', '');
3437 container.showPopover();
3438 }
3439 setupAccessibility(params);
3440 setupRTL(targetElement);
3441 addInputChangeListeners();
3442 };
3443
3444 /**
3445 * @param {HTMLElement | object | string} param
3446 * @param {HTMLElement} target
3447 */
3448 const parseHtmlToContainer = (param, target) => {
3449 // DOM element
3450 if (param instanceof HTMLElement) {
3451 target.appendChild(param);
3452 }
3453
3454 // Object
3455 else if (typeof param === 'object') {
3456 handleObject(param, target);
3457 }
3458
3459 // Plain string
3460 else if (param) {
3461 setInnerHtml(target, param);
3462 }
3463 };
3464
3465 /**
3466 * @param {object} param
3467 * @param {HTMLElement} target
3468 */
3469 const handleObject = (param, target) => {
3470 // JQuery element(s)
3471 if ('jquery' in param) {
3472 handleJqueryElem(target, param);
3473 }
3474
3475 // For other objects use their string representation
3476 else {
3477 setInnerHtml(target, param.toString());
3478 }
3479 };
3480
3481 /**
3482 * @param {HTMLElement} target
3483 * @param {any} elem
3484 */
3485 const handleJqueryElem = (target, elem) => {
3486 target.textContent = '';
3487 if (0 in elem) {
3488 for (let i = 0; i in elem; i++) {
3489 target.appendChild(elem[i].cloneNode(true));
3490 }
3491 } else {
3492 target.appendChild(elem.cloneNode(true));
3493 }
3494 };
3495
3496 /**
3497 * @param {SweetAlert} instance
3498 * @param {SweetAlertOptions} params
3499 */
3500 const renderActions = (instance, params) => {
3501 const actions = getActions();
3502 const loader = getLoader();
3503 if (!actions || !loader) {
3504 return;
3505 }
3506
3507 // Actions (buttons) wrapper
3508 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
3509 hide(actions);
3510 } else {
3511 show(actions);
3512 }
3513
3514 // Custom class
3515 applyCustomClass(actions, params, 'actions');
3516
3517 // Render all the buttons
3518 renderButtons(actions, loader, params);
3519
3520 // Loader
3521 setInnerHtml(loader, params.loaderHtml || '');
3522 applyCustomClass(loader, params, 'loader');
3523 };
3524
3525 /**
3526 * @param {HTMLElement} actions
3527 * @param {HTMLElement} loader
3528 * @param {SweetAlertOptions} params
3529 */
3530 function renderButtons(actions, loader, params) {
3531 const confirmButton = getConfirmButton();
3532 const denyButton = getDenyButton();
3533 const cancelButton = getCancelButton();
3534 if (!confirmButton || !denyButton || !cancelButton) {
3535 return;
3536 }
3537
3538 // Render buttons
3539 renderButton(confirmButton, 'confirm', params);
3540 renderButton(denyButton, 'deny', params);
3541 renderButton(cancelButton, 'cancel', params);
3542 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3543 if (params.reverseButtons) {
3544 if (params.toast) {
3545 actions.insertBefore(cancelButton, confirmButton);
3546 actions.insertBefore(denyButton, confirmButton);
3547 } else {
3548 actions.insertBefore(cancelButton, loader);
3549 actions.insertBefore(denyButton, loader);
3550 actions.insertBefore(confirmButton, loader);
3551 }
3552 }
3553 }
3554
3555 /**
3556 * @param {HTMLElement} confirmButton
3557 * @param {HTMLElement} denyButton
3558 * @param {HTMLElement} cancelButton
3559 * @param {SweetAlertOptions} params
3560 */
3561 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3562 if (!params.buttonsStyling) {
3563 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3564 return;
3565 }
3566 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3567
3568 // Apply custom background colors and outline colors to action buttons
3569 /** @type {[HTMLElement, string, string | undefined][]} */
3570 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
3571 buttons.forEach(([button, type, color]) => {
3572 if (color) {
3573 button.style.setProperty(`--swal2-${type}-button-background-color`, color);
3574 }
3575 applyOutlineColor(button);
3576 });
3577 }
3578
3579 /**
3580 * @param {HTMLElement} button
3581 */
3582 function applyOutlineColor(button) {
3583 const buttonStyle = window.getComputedStyle(button);
3584 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3585 // If the button already has a custom outline color, no need to change it
3586 return;
3587 }
3588 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3589 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3590 }
3591
3592 /**
3593 * @param {HTMLElement} button
3594 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3595 * @param {SweetAlertOptions} params
3596 */
3597 function renderButton(button, buttonType, params) {
3598 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3599 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3600 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3601 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3602
3603 // Add buttons custom classes
3604 button.className = swalClasses[buttonType];
3605 applyCustomClass(button, params, `${buttonType}Button`);
3606 }
3607
3608 /**
3609 * @param {SweetAlert} instance
3610 * @param {SweetAlertOptions} params
3611 */
3612 const renderCloseButton = (instance, params) => {
3613 const closeButton = getCloseButton();
3614 if (!closeButton) {
3615 return;
3616 }
3617 setInnerHtml(closeButton, params.closeButtonHtml || '');
3618
3619 // Custom class
3620 applyCustomClass(closeButton, params, 'closeButton');
3621 toggle(closeButton, params.showCloseButton);
3622 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3623 };
3624
3625 /**
3626 * @param {SweetAlert} instance
3627 * @param {SweetAlertOptions} params
3628 */
3629 const renderContainer = (instance, params) => {
3630 const container = getContainer();
3631 if (!container) {
3632 return;
3633 }
3634 handleBackdropParam(container, params.backdrop);
3635 handlePositionParam(container, params.position);
3636 handleGrowParam(container, params.grow);
3637
3638 // Custom class
3639 applyCustomClass(container, params, 'container');
3640 };
3641
3642 /**
3643 * @param {HTMLElement} container
3644 * @param {SweetAlertOptions['backdrop']} backdrop
3645 */
3646 function handleBackdropParam(container, backdrop) {
3647 if (typeof backdrop === 'string') {
3648 container.style.background = backdrop;
3649 } else if (!backdrop) {
3650 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3651 }
3652 }
3653
3654 /**
3655 * @param {HTMLElement} container
3656 * @param {SweetAlertOptions['position']} position
3657 */
3658 function handlePositionParam(container, position) {
3659 if (!position) {
3660 return;
3661 }
3662 if (position in swalClasses) {
3663 addClass(container, swalClasses[position]);
3664 } else {
3665 warn('The "position" parameter is not valid, defaulting to "center"');
3666 addClass(container, swalClasses.center);
3667 }
3668 }
3669
3670 /**
3671 * @param {HTMLElement} container
3672 * @param {SweetAlertOptions['grow']} grow
3673 */
3674 function handleGrowParam(container, grow) {
3675 if (!grow) {
3676 return;
3677 }
3678 addClass(container, swalClasses[`grow-${grow}`]);
3679 }
3680
3681 /**
3682 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3683 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3684 * This is the approach that Babel will probably take to implement private methods/fields
3685 * https://github.com/tc39/proposal-private-methods
3686 * https://github.com/babel/babel/pull/7555
3687 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3688 * then we can use that language feature.
3689 */
3690
3691 var privateProps = {
3692 innerParams: new WeakMap(),
3693 domCache: new WeakMap(),
3694 focusedElement: new WeakMap()
3695 };
3696
3697 /// <reference path="../../../../sweetalert2.d.ts"/>
3698
3699
3700 /** @type {InputClass[]} */
3701 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3702
3703 /**
3704 * @param {SweetAlert} instance
3705 * @param {SweetAlertOptions} params
3706 */
3707 const renderInput = (instance, params) => {
3708 const popup = getPopup();
3709 if (!popup) {
3710 return;
3711 }
3712 const innerParams = privateProps.innerParams.get(instance);
3713 const rerender = !innerParams || params.input !== innerParams.input;
3714 inputClasses.forEach(inputClass => {
3715 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3716 if (!inputContainer) {
3717 return;
3718 }
3719
3720 // set attributes
3721 setAttributes(inputClass, params.inputAttributes);
3722
3723 // set class
3724 inputContainer.className = swalClasses[inputClass];
3725 if (rerender) {
3726 hide(inputContainer);
3727 }
3728 });
3729 if (params.input) {
3730 if (rerender) {
3731 showInput(params);
3732 }
3733 // set custom class
3734 setCustomClass(params);
3735 }
3736 };
3737
3738 /**
3739 * @param {SweetAlertOptions} params
3740 */
3741 const showInput = params => {
3742 if (!params.input) {
3743 return;
3744 }
3745 if (!renderInputType[params.input]) {
3746 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3747 return;
3748 }
3749 const inputContainer = getInputContainer(params.input);
3750 if (!inputContainer) {
3751 return;
3752 }
3753 const input = renderInputType[params.input](inputContainer, params);
3754 show(inputContainer);
3755
3756 // input autofocus
3757 if (params.inputAutoFocus) {
3758 setTimeout(() => {
3759 focusInput(input);
3760 });
3761 }
3762 };
3763
3764 /**
3765 * @param {HTMLInputElement} input
3766 */
3767 const removeAttributes = input => {
3768 for (const {
3769 name
3770 } of Array.from(input.attributes)) {
3771 if (!['id', 'type', 'value', 'style'].includes(name)) {
3772 input.removeAttribute(name);
3773 }
3774 }
3775 };
3776
3777 /**
3778 * @param {InputClass} inputClass
3779 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3780 */
3781 const setAttributes = (inputClass, inputAttributes) => {
3782 const popup = getPopup();
3783 if (!popup) {
3784 return;
3785 }
3786 const input = getInput$1(popup, inputClass);
3787 if (!input) {
3788 return;
3789 }
3790 removeAttributes(input);
3791 for (const attr in inputAttributes) {
3792 input.setAttribute(attr, inputAttributes[attr]);
3793 }
3794 };
3795
3796 /**
3797 * @param {SweetAlertOptions} params
3798 */
3799 const setCustomClass = params => {
3800 if (!params.input) {
3801 return;
3802 }
3803 const inputContainer = getInputContainer(params.input);
3804 if (inputContainer) {
3805 applyCustomClass(inputContainer, params, 'input');
3806 }
3807 };
3808
3809 /**
3810 * @param {HTMLInputElement | HTMLTextAreaElement} input
3811 * @param {SweetAlertOptions} params
3812 */
3813 const setInputPlaceholder = (input, params) => {
3814 if (!input.placeholder && params.inputPlaceholder) {
3815 input.placeholder = params.inputPlaceholder;
3816 }
3817 };
3818
3819 /**
3820 * @param {Input} input
3821 * @param {Input} prependTo
3822 * @param {SweetAlertOptions} params
3823 */
3824 const setInputLabel = (input, prependTo, params) => {
3825 if (params.inputLabel) {
3826 const label = document.createElement('label');
3827 const labelClass = swalClasses['input-label'];
3828 label.setAttribute('for', input.id);
3829 label.className = labelClass;
3830 if (typeof params.customClass === 'object') {
3831 addClass(label, params.customClass.inputLabel);
3832 }
3833 label.innerText = params.inputLabel;
3834 prependTo.insertAdjacentElement('beforebegin', label);
3835 }
3836 };
3837
3838 /**
3839 * @param {SweetAlertInput} inputType
3840 * @returns {HTMLElement | undefined}
3841 */
3842 const getInputContainer = inputType => {
3843 const popup = getPopup();
3844 if (!popup) {
3845 return;
3846 }
3847 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3848 };
3849
3850 /**
3851 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3852 * @param {SweetAlertOptions['inputValue']} inputValue
3853 */
3854 const checkAndSetInputValue = (input, inputValue) => {
3855 if (['string', 'number'].includes(typeof inputValue)) {
3856 input.value = `${inputValue}`;
3857 } else if (!isPromise(inputValue)) {
3858 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3859 }
3860 };
3861
3862 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3863 const renderInputType = {};
3864
3865 /**
3866 * @param {Input | HTMLElement} input
3867 * @param {SweetAlertOptions} params
3868 * @returns {Input}
3869 */
3870 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} */
3871 (input, params) => {
3872 // oxfmt-ignore
3873 const inputElement = /** @type {HTMLInputElement} */input;
3874 checkAndSetInputValue(inputElement, params.inputValue);
3875 setInputLabel(inputElement, inputElement, params);
3876 setInputPlaceholder(inputElement, params);
3877 // oxfmt-ignore
3878 inputElement.type = /** @type {string} */params.input;
3879 return inputElement;
3880 };
3881
3882 /**
3883 * @param {Input | HTMLElement} input
3884 * @param {SweetAlertOptions} params
3885 * @returns {Input}
3886 */
3887 renderInputType.file = (input, params) => {
3888 const inputElement = /** @type {HTMLInputElement} */input;
3889 setInputLabel(inputElement, inputElement, params);
3890 setInputPlaceholder(inputElement, params);
3891 return inputElement;
3892 };
3893
3894 /**
3895 * @param {Input | HTMLElement} range
3896 * @param {SweetAlertOptions} params
3897 * @returns {Input}
3898 */
3899 renderInputType.range = (range, params) => {
3900 const rangeContainer = /** @type {HTMLElement} */range;
3901 const rangeInput = rangeContainer.querySelector('input');
3902 const rangeOutput = rangeContainer.querySelector('output');
3903 if (rangeInput) {
3904 checkAndSetInputValue(rangeInput, params.inputValue);
3905 rangeInput.type = /** @type {string} */params.input;
3906 setInputLabel(rangeInput, /** @type {Input} */range, params);
3907 }
3908 if (rangeOutput) {
3909 checkAndSetInputValue(rangeOutput, params.inputValue);
3910 }
3911 return /** @type {Input} */range;
3912 };
3913
3914 /**
3915 * @param {Input | HTMLElement} select
3916 * @param {SweetAlertOptions} params
3917 * @returns {Input}
3918 */
3919 renderInputType.select = (select, params) => {
3920 const selectElement = /** @type {HTMLSelectElement} */select;
3921 selectElement.textContent = '';
3922 if (params.inputPlaceholder) {
3923 const placeholder = document.createElement('option');
3924 setInnerHtml(placeholder, params.inputPlaceholder);
3925 placeholder.value = '';
3926 placeholder.disabled = true;
3927 placeholder.selected = true;
3928 selectElement.appendChild(placeholder);
3929 }
3930 setInputLabel(selectElement, selectElement, params);
3931 return selectElement;
3932 };
3933
3934 /**
3935 * @param {Input | HTMLElement} radio
3936 * @returns {Input}
3937 */
3938 renderInputType.radio = radio => {
3939 const radioElement = /** @type {HTMLElement} */radio;
3940 radioElement.textContent = '';
3941 return /** @type {Input} */radio;
3942 };
3943
3944 /**
3945 * @param {Input | HTMLElement} checkboxContainer
3946 * @param {SweetAlertOptions} params
3947 * @returns {Input}
3948 */
3949 renderInputType.checkbox = (checkboxContainer, params) => {
3950 const popup = getPopup();
3951 if (!popup) {
3952 throw new Error('Popup not found');
3953 }
3954 const checkbox = getInput$1(popup, 'checkbox');
3955 if (!checkbox) {
3956 throw new Error('Checkbox input not found');
3957 }
3958 checkbox.value = '1';
3959 checkbox.checked = Boolean(params.inputValue);
3960 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3961 const label = containerElement.querySelector('span');
3962 if (label) {
3963 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3964 if (placeholderOrLabel) {
3965 setInnerHtml(label, placeholderOrLabel);
3966 }
3967 }
3968 return checkbox;
3969 };
3970
3971 /**
3972 * @param {Input | HTMLElement} textarea
3973 * @param {SweetAlertOptions} params
3974 * @returns {Input}
3975 */
3976 renderInputType.textarea = (textarea, params) => {
3977 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3978 checkAndSetInputValue(textareaElement, params.inputValue);
3979 setInputPlaceholder(textareaElement, params);
3980 setInputLabel(textareaElement, textareaElement, params);
3981
3982 /**
3983 * @param {HTMLElement} el
3984 * @returns {number}
3985 */
3986 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3987
3988 // https://github.com/sweetalert2/sweetalert2/issues/2291
3989 setTimeout(() => {
3990 // https://github.com/sweetalert2/sweetalert2/issues/1699
3991 if ('MutationObserver' in window) {
3992 const popup = getPopup();
3993 if (!popup) {
3994 return;
3995 }
3996 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3997 const textareaResizeHandler = () => {
3998 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3999 if (!document.body.contains(textareaElement)) {
4000 return;
4001 }
4002 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
4003 const popupElement = getPopup();
4004 if (popupElement) {
4005 if (textareaWidth > initialPopupWidth) {
4006 popupElement.style.width = `${textareaWidth}px`;
4007 } else {
4008 applyNumericalStyle(popupElement, 'width', params.width);
4009 }
4010 }
4011 };
4012 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
4013 attributes: true,
4014 attributeFilter: ['style']
4015 });
4016 }
4017 });
4018 return textareaElement;
4019 };
4020
4021 /**
4022 * @param {SweetAlert} instance
4023 * @param {SweetAlertOptions} params
4024 */
4025 const renderContent = (instance, params) => {
4026 const htmlContainer = getHtmlContainer();
4027 if (!htmlContainer) {
4028 return;
4029 }
4030 showWhenInnerHtmlPresent(htmlContainer);
4031 applyCustomClass(htmlContainer, params, 'htmlContainer');
4032
4033 // Content as HTML
4034 if (params.html) {
4035 parseHtmlToContainer(params.html, htmlContainer);
4036 show(htmlContainer, 'block');
4037 }
4038
4039 // Content as plain text
4040 else if (params.text) {
4041 htmlContainer.textContent = params.text;
4042 show(htmlContainer, 'block');
4043 }
4044
4045 // No content
4046 else {
4047 hide(htmlContainer);
4048 }
4049 renderInput(instance, params);
4050 };
4051
4052 /**
4053 * @param {SweetAlert} instance
4054 * @param {SweetAlertOptions} params
4055 */
4056 const renderFooter = (instance, params) => {
4057 const footer = getFooter();
4058 if (!footer) {
4059 return;
4060 }
4061 showWhenInnerHtmlPresent(footer);
4062 toggle(footer, Boolean(params.footer), 'block');
4063 if (params.footer) {
4064 parseHtmlToContainer(params.footer, footer);
4065 }
4066
4067 // Custom class
4068 applyCustomClass(footer, params, 'footer');
4069 };
4070
4071 /**
4072 * @param {SweetAlert} instance
4073 * @param {SweetAlertOptions} params
4074 */
4075 const renderIcon = (instance, params) => {
4076 const innerParams = privateProps.innerParams.get(instance);
4077 const icon = getIcon();
4078 if (!icon) {
4079 return;
4080 }
4081
4082 // if the given icon already rendered, apply the styling without re-rendering the icon
4083 if (innerParams && params.icon === innerParams.icon) {
4084 // Custom or default content
4085 setContent(icon, params);
4086 applyStyles(icon, params);
4087 return;
4088 }
4089 if (!params.icon && !params.iconHtml) {
4090 hide(icon);
4091 return;
4092 }
4093 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
4094 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
4095 hide(icon);
4096 return;
4097 }
4098 show(icon);
4099
4100 // Custom or default content
4101 setContent(icon, params);
4102 applyStyles(icon, params);
4103
4104 // Animate icon
4105 addClass(icon, params.showClass && params.showClass.icon);
4106
4107 // Re-adjust the success icon on system theme change
4108 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
4109 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
4110 };
4111
4112 /**
4113 * @param {HTMLElement} icon
4114 * @param {SweetAlertOptions} params
4115 */
4116 const applyStyles = (icon, params) => {
4117 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
4118 if (params.icon !== iconType) {
4119 removeClass(icon, iconClassName);
4120 }
4121 }
4122 addClass(icon, params.icon && iconTypes[params.icon]);
4123
4124 // Icon color
4125 setColor(icon, params);
4126
4127 // Success icon background color
4128 adjustSuccessIconBackgroundColor();
4129
4130 // Custom class
4131 applyCustomClass(icon, params, 'icon');
4132 };
4133
4134 // Adjust success icon background color to match the popup background color
4135 const adjustSuccessIconBackgroundColor = () => {
4136 const popup = getPopup();
4137 if (!popup) {
4138 return;
4139 }
4140 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
4141 /** @type {NodeListOf<HTMLElement>} */
4142 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
4143 successIconParts.forEach(part => {
4144 part.style.backgroundColor = popupBackgroundColor;
4145 });
4146 };
4147
4148 /**
4149 *
4150 * @param {SweetAlertOptions} params
4151 * @returns {string}
4152 */
4153 const successIconHtml = params => `
4154 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
4155 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
4156 <div class="swal2-success-ring"></div>
4157 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
4158 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
4159 `;
4160 const errorIconHtml = `
4161 <span class="swal2-x-mark">
4162 <span class="swal2-x-mark-line-left"></span>
4163 <span class="swal2-x-mark-line-right"></span>
4164 </span>
4165 `;
4166
4167 /**
4168 * @param {HTMLElement} icon
4169 * @param {SweetAlertOptions} params
4170 */
4171 const setContent = (icon, params) => {
4172 if (!params.icon && !params.iconHtml) {
4173 return;
4174 }
4175 let oldContent = icon.innerHTML;
4176 let newContent = '';
4177 if (params.iconHtml) {
4178 newContent = iconContent(params.iconHtml);
4179 } else if (params.icon === 'success') {
4180 newContent = successIconHtml(params);
4181 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
4182 } else if (params.icon === 'error') {
4183 newContent = errorIconHtml;
4184 } else if (params.icon) {
4185 const defaultIconHtml = {
4186 question: '?',
4187 warning: '!',
4188 info: 'i'
4189 };
4190 newContent = iconContent(defaultIconHtml[params.icon]);
4191 }
4192 if (oldContent.trim() !== newContent.trim()) {
4193 setInnerHtml(icon, newContent);
4194 }
4195 };
4196
4197 /**
4198 * @param {HTMLElement} icon
4199 * @param {SweetAlertOptions} params
4200 */
4201 const setColor = (icon, params) => {
4202 if (!params.iconColor) {
4203 return;
4204 }
4205 icon.style.color = params.iconColor;
4206 icon.style.borderColor = params.iconColor;
4207 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
4208 setStyle(icon, sel, 'background-color', params.iconColor);
4209 }
4210 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
4211 };
4212
4213 /**
4214 * @param {string} content
4215 * @returns {string}
4216 */
4217 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
4218
4219 /**
4220 * @param {SweetAlert} instance
4221 * @param {SweetAlertOptions} params
4222 */
4223 const renderImage = (instance, params) => {
4224 const image = getImage();
4225 if (!image) {
4226 return;
4227 }
4228 if (!params.imageUrl) {
4229 hide(image);
4230 return;
4231 }
4232 show(image, '');
4233
4234 // Src, alt
4235 image.setAttribute('src', params.imageUrl);
4236 image.setAttribute('alt', params.imageAlt || '');
4237
4238 // Width, height
4239 applyNumericalStyle(image, 'width', params.imageWidth);
4240 applyNumericalStyle(image, 'height', params.imageHeight);
4241
4242 // Class
4243 image.className = swalClasses.image;
4244 applyCustomClass(image, params, 'image');
4245 };
4246
4247 let dragging = false;
4248 let mousedownX = 0;
4249 let mousedownY = 0;
4250 let initialX = 0;
4251 let initialY = 0;
4252
4253 /**
4254 * @param {HTMLElement} popup
4255 */
4256 const addDraggableListeners = popup => {
4257 popup.addEventListener('mousedown', down);
4258 document.body.addEventListener('mousemove', move);
4259 popup.addEventListener('mouseup', up);
4260 popup.addEventListener('touchstart', down);
4261 document.body.addEventListener('touchmove', move);
4262 popup.addEventListener('touchend', up);
4263 };
4264
4265 /**
4266 * @param {HTMLElement} popup
4267 */
4268 const removeDraggableListeners = popup => {
4269 popup.removeEventListener('mousedown', down);
4270 document.body.removeEventListener('mousemove', move);
4271 popup.removeEventListener('mouseup', up);
4272 popup.removeEventListener('touchstart', down);
4273 document.body.removeEventListener('touchmove', move);
4274 popup.removeEventListener('touchend', up);
4275 };
4276
4277 /**
4278 * @param {MouseEvent | TouchEvent} event
4279 */
4280 const down = event => {
4281 const popup = getPopup();
4282 if (!popup) {
4283 return;
4284 }
4285 const icon = getIcon();
4286 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
4287 dragging = true;
4288 const clientXY = getClientXY(event);
4289 mousedownX = clientXY.clientX;
4290 mousedownY = clientXY.clientY;
4291 initialX = parseInt(popup.style.insetInlineStart) || 0;
4292 initialY = parseInt(popup.style.insetBlockStart) || 0;
4293 addClass(popup, 'swal2-dragging');
4294 }
4295 };
4296
4297 /**
4298 * @param {MouseEvent | TouchEvent} event
4299 */
4300 const move = event => {
4301 const popup = getPopup();
4302 if (!popup) {
4303 return;
4304 }
4305 if (dragging) {
4306 let {
4307 clientX,
4308 clientY
4309 } = getClientXY(event);
4310 const deltaX = clientX - mousedownX;
4311 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
4312 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
4313 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
4314 }
4315 };
4316 const up = () => {
4317 const popup = getPopup();
4318 dragging = false;
4319 removeClass(popup, 'swal2-dragging');
4320 };
4321
4322 /**
4323 * @param {MouseEvent | TouchEvent} event
4324 * @returns {{ clientX: number, clientY: number }}
4325 */
4326 const getClientXY = event => {
4327 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
4328 return {
4329 clientX: source.clientX,
4330 clientY: source.clientY
4331 };
4332 };
4333
4334 /**
4335 * @param {SweetAlert} instance
4336 * @param {SweetAlertOptions} params
4337 */
4338 const renderPopup = (instance, params) => {
4339 const container = getContainer();
4340 const popup = getPopup();
4341 if (!container || !popup) {
4342 return;
4343 }
4344
4345 // Width
4346 // https://github.com/sweetalert2/sweetalert2/issues/2170
4347 if (params.toast) {
4348 applyNumericalStyle(container, 'width', params.width);
4349 popup.style.width = '100%';
4350 const loader = getLoader();
4351 if (loader) {
4352 popup.insertBefore(loader, getIcon());
4353 }
4354 } else {
4355 applyNumericalStyle(popup, 'width', params.width);
4356 }
4357
4358 // Padding
4359 applyNumericalStyle(popup, 'padding', params.padding);
4360
4361 // Color
4362 if (params.color) {
4363 popup.style.color = params.color;
4364 }
4365
4366 // Background
4367 if (params.background) {
4368 popup.style.background = params.background;
4369 }
4370 hide(getValidationMessage());
4371
4372 // Classes
4373 addClasses$1(popup, params);
4374 if (params.draggable && !params.toast) {
4375 addClass(popup, swalClasses.draggable);
4376 addDraggableListeners(popup);
4377 } else {
4378 removeClass(popup, swalClasses.draggable);
4379 removeDraggableListeners(popup);
4380 }
4381 };
4382
4383 /**
4384 * @param {HTMLElement} popup
4385 * @param {SweetAlertOptions} params
4386 */
4387 const addClasses$1 = (popup, params) => {
4388 const showClass = params.showClass || {};
4389 // Default Class + showClass when updating Swal.update({})
4390 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
4391 if (params.toast) {
4392 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
4393 addClass(popup, swalClasses.toast);
4394 } else {
4395 addClass(popup, swalClasses.modal);
4396 }
4397
4398 // Custom class
4399 applyCustomClass(popup, params, 'popup');
4400 // TODO: remove in the next major
4401 if (typeof params.customClass === 'string') {
4402 addClass(popup, params.customClass);
4403 }
4404
4405 // Icon class (#1842)
4406 if (params.icon) {
4407 addClass(popup, swalClasses[`icon-${params.icon}`]);
4408 }
4409 };
4410
4411 /**
4412 * @param {SweetAlert} instance
4413 * @param {SweetAlertOptions} params
4414 */
4415 const renderProgressSteps = (instance, params) => {
4416 const progressStepsContainer = getProgressSteps();
4417 if (!progressStepsContainer) {
4418 return;
4419 }
4420 const {
4421 progressSteps,
4422 currentProgressStep
4423 } = params;
4424 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
4425 hide(progressStepsContainer);
4426 return;
4427 }
4428 show(progressStepsContainer);
4429 progressStepsContainer.textContent = '';
4430 if (currentProgressStep >= progressSteps.length) {
4431 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
4432 }
4433 progressSteps.forEach((step, index) => {
4434 const stepEl = createStepElement(step);
4435 progressStepsContainer.appendChild(stepEl);
4436 if (index === currentProgressStep) {
4437 addClass(stepEl, swalClasses['active-progress-step']);
4438 }
4439 if (index !== progressSteps.length - 1) {
4440 const lineEl = createLineElement(params);
4441 progressStepsContainer.appendChild(lineEl);
4442 }
4443 });
4444 };
4445
4446 /**
4447 * @param {string} step
4448 * @returns {HTMLLIElement}
4449 */
4450 const createStepElement = step => {
4451 const stepEl = document.createElement('li');
4452 addClass(stepEl, swalClasses['progress-step']);
4453 setInnerHtml(stepEl, step);
4454 return stepEl;
4455 };
4456
4457 /**
4458 * @param {SweetAlertOptions} params
4459 * @returns {HTMLLIElement}
4460 */
4461 const createLineElement = params => {
4462 const lineEl = document.createElement('li');
4463 addClass(lineEl, swalClasses['progress-step-line']);
4464 if (params.progressStepsDistance) {
4465 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
4466 }
4467 return lineEl;
4468 };
4469
4470 /**
4471 * @param {SweetAlert} instance
4472 * @param {SweetAlertOptions} params
4473 */
4474 const renderTitle = (instance, params) => {
4475 const title = getTitle();
4476 if (!title) {
4477 return;
4478 }
4479 showWhenInnerHtmlPresent(title);
4480 toggle(title, Boolean(params.title || params.titleText), 'block');
4481 if (params.title) {
4482 parseHtmlToContainer(params.title, title);
4483 }
4484 if (params.titleText) {
4485 title.innerText = params.titleText;
4486 }
4487
4488 // Custom class
4489 applyCustomClass(title, params, 'title');
4490 };
4491
4492 /**
4493 * @param {SweetAlert} instance
4494 * @param {SweetAlertOptions} params
4495 */
4496 const render = (instance, params) => {
4497 var _globalState$eventEmi;
4498 renderPopup(instance, params);
4499 renderContainer(instance, params);
4500 renderProgressSteps(instance, params);
4501 renderIcon(instance, params);
4502 renderImage(instance, params);
4503 renderTitle(instance, params);
4504 renderCloseButton(instance, params);
4505 renderContent(instance, params);
4506 renderActions(instance, params);
4507 renderFooter(instance, params);
4508 const popup = getPopup();
4509 if (typeof params.didRender === 'function' && popup) {
4510 params.didRender(popup);
4511 }
4512 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
4513 };
4514
4515 /*
4516 * Global function to determine if SweetAlert2 popup is shown
4517 */
4518 const isVisible = () => {
4519 return isVisible$1(getPopup());
4520 };
4521
4522 /*
4523 * Global function to click 'Confirm' button
4524 */
4525 const clickConfirm = () => {
4526 var _dom$getConfirmButton;
4527 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
4528 };
4529
4530 /*
4531 * Global function to click 'Deny' button
4532 */
4533 const clickDeny = () => {
4534 var _dom$getDenyButton;
4535 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
4536 };
4537
4538 /*
4539 * Global function to click 'Cancel' button
4540 */
4541 const clickCancel = () => {
4542 var _dom$getCancelButton;
4543 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4544 };
4545
4546 /** @type {Record<DismissReason, DismissReason>} */
4547 const DismissReason = Object.freeze({
4548 cancel: 'cancel',
4549 backdrop: 'backdrop',
4550 close: 'close',
4551 esc: 'esc',
4552 timer: 'timer'
4553 });
4554
4555 /**
4556 * @param {GlobalState} globalState
4557 */
4558 const removeKeydownHandler = globalState => {
4559 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4560 const handler = /** @type {EventListenerOrEventListenerObject} */
4561 /** @type {unknown} */globalState.keydownHandler;
4562 globalState.keydownTarget.removeEventListener('keydown', handler, {
4563 capture: globalState.keydownListenerCapture
4564 });
4565 globalState.keydownHandlerAdded = false;
4566 }
4567 };
4568
4569 /**
4570 * @param {GlobalState} globalState
4571 * @param {SweetAlertOptions} innerParams
4572 * @param {(dismiss: DismissReason) => void} dismissWith
4573 */
4574 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4575 removeKeydownHandler(globalState);
4576 if (!innerParams.toast) {
4577 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4578 const handler = e => keydownHandler(innerParams, e, dismissWith);
4579 globalState.keydownHandler = handler;
4580 const target = innerParams.keydownListenerCapture ? window : getPopup();
4581 if (target) {
4582 globalState.keydownTarget = target;
4583 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4584 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4585 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4586 capture: globalState.keydownListenerCapture
4587 });
4588 globalState.keydownHandlerAdded = true;
4589 }
4590 }
4591 };
4592
4593 /**
4594 * @param {number} index
4595 * @param {number} increment
4596 * @returns {boolean} shouldPreventDefault
4597 */
4598 const setFocus = (index, increment) => {
4599 var _dom$getPopup;
4600 const focusableElements = getFocusableElements();
4601 // search for visible elements and select the next possible match
4602 if (focusableElements.length) {
4603 index = index + increment;
4604
4605 // shift + tab when .swal2-popup is focused
4606 if (index === -2) {
4607 index = focusableElements.length - 1;
4608 }
4609
4610 // rollover to first item
4611 if (index === focusableElements.length) {
4612 index = 0;
4613
4614 // go to last item
4615 } else if (index === -1) {
4616 index = focusableElements.length - 1;
4617 }
4618 focusableElements[index].focus();
4619
4620 // don't prevent default for iframes (Firefox fix)
4621 // https://github.com/sweetalert2/sweetalert2/issues/2931
4622 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
4623 return false;
4624 }
4625 return true;
4626 }
4627 // no visible focusable elements, focus the popup
4628 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4629 return true;
4630 };
4631 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4632 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4633
4634 /**
4635 * @param {SweetAlertOptions} innerParams
4636 * @param {KeyboardEvent} event
4637 * @param {(dismiss: DismissReason) => void} dismissWith
4638 */
4639 const keydownHandler = (innerParams, event, dismissWith) => {
4640 if (!innerParams) {
4641 return; // This instance has already been destroyed
4642 }
4643
4644 // Ignore keydown during IME composition
4645 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4646 // https://github.com/sweetalert2/sweetalert2/issues/720
4647 // https://github.com/sweetalert2/sweetalert2/issues/2406
4648 if (event.isComposing || event.keyCode === 229) {
4649 return;
4650 }
4651 if (innerParams.stopKeydownPropagation) {
4652 event.stopPropagation();
4653 }
4654
4655 // ENTER
4656 if (event.key === 'Enter') {
4657 handleEnter(event, innerParams);
4658 }
4659
4660 // TAB
4661 else if (event.key === 'Tab') {
4662 handleTab(event);
4663 }
4664
4665 // ARROWS - switch focus between buttons
4666 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4667 handleArrows(event.key);
4668 }
4669
4670 // ESC
4671 else if (event.key === 'Escape') {
4672 handleEsc(event, innerParams, dismissWith);
4673 }
4674 };
4675
4676 /**
4677 * @param {KeyboardEvent} event
4678 * @param {SweetAlertOptions} innerParams
4679 */
4680 const handleEnter = (event, innerParams) => {
4681 // https://github.com/sweetalert2/sweetalert2/issues/2386
4682 if (!callIfFunction(innerParams.allowEnterKey)) {
4683 return;
4684 }
4685 const popup = getPopup();
4686 if (!popup || !innerParams.input) {
4687 return;
4688 }
4689 const input = getInput$1(popup, innerParams.input);
4690 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4691 if (['textarea', 'file'].includes(innerParams.input)) {
4692 return; // do not submit
4693 }
4694 clickConfirm();
4695 event.preventDefault();
4696 }
4697 };
4698
4699 /**
4700 * @param {KeyboardEvent} event
4701 */
4702 const handleTab = event => {
4703 const targetElement = event.target;
4704 const focusableElements = getFocusableElements();
4705 const btnIndex = focusableElements.findIndex(el => el === targetElement);
4706
4707 // don't prevent default for iframes (Firefox fix)
4708 // https://github.com/sweetalert2/sweetalert2/issues/2931
4709 let shouldPreventDefault = true;
4710
4711 // Cycle to the next button
4712 if (!event.shiftKey) {
4713 shouldPreventDefault = setFocus(btnIndex, 1);
4714 }
4715
4716 // Cycle to the prev button
4717 else {
4718 shouldPreventDefault = setFocus(btnIndex, -1);
4719 }
4720 event.stopPropagation();
4721 if (shouldPreventDefault) {
4722 event.preventDefault();
4723 }
4724 };
4725
4726 /**
4727 * @param {string} key
4728 */
4729 const handleArrows = key => {
4730 const actions = getActions();
4731 const confirmButton = getConfirmButton();
4732 const denyButton = getDenyButton();
4733 const cancelButton = getCancelButton();
4734 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4735 return;
4736 }
4737 /** @type HTMLElement[] */
4738 const buttons = [confirmButton, denyButton, cancelButton];
4739 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4740 return;
4741 }
4742 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4743 let buttonToFocus = document.activeElement;
4744 if (!buttonToFocus) {
4745 return;
4746 }
4747 for (let i = 0; i < actions.children.length; i++) {
4748 buttonToFocus = buttonToFocus[sibling];
4749 if (!buttonToFocus) {
4750 return;
4751 }
4752 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4753 break;
4754 }
4755 }
4756 if (buttonToFocus instanceof HTMLButtonElement) {
4757 buttonToFocus.focus();
4758 }
4759 };
4760
4761 /**
4762 * @param {KeyboardEvent} event
4763 * @param {SweetAlertOptions} innerParams
4764 * @param {(dismiss: DismissReason) => void} dismissWith
4765 */
4766 const handleEsc = (event, innerParams, dismissWith) => {
4767 event.preventDefault();
4768 if (callIfFunction(innerParams.allowEscapeKey)) {
4769 dismissWith(DismissReason.esc);
4770 }
4771 };
4772
4773 /**
4774 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4775 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4776 * This is the approach that Babel will probably take to implement private methods/fields
4777 * https://github.com/tc39/proposal-private-methods
4778 * https://github.com/babel/babel/pull/7555
4779 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4780 * then we can use that language feature.
4781 */
4782
4783 var privateMethods = {
4784 swalPromiseResolve: new WeakMap(),
4785 swalPromiseReject: new WeakMap()
4786 };
4787
4788 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4789 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4790 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4791 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4792
4793 const setAriaHidden = () => {
4794 const container = getContainer();
4795 const bodyChildren = Array.from(document.body.children);
4796 bodyChildren.forEach(el => {
4797 if (el.contains(container)) {
4798 return;
4799 }
4800 if (el.hasAttribute('aria-hidden')) {
4801 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4802 }
4803 el.setAttribute('aria-hidden', 'true');
4804 });
4805 };
4806 const unsetAriaHidden = () => {
4807 const bodyChildren = Array.from(document.body.children);
4808 bodyChildren.forEach(el => {
4809 if (el.hasAttribute('data-previous-aria-hidden')) {
4810 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4811 el.removeAttribute('data-previous-aria-hidden');
4812 } else {
4813 el.removeAttribute('aria-hidden');
4814 }
4815 });
4816 };
4817
4818 // @ts-ignore
4819 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4820
4821 // @ts-ignore
4822 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
4823
4824 /**
4825 * Fix iOS scrolling
4826 * http://stackoverflow.com/q/39626302
4827 */
4828 const iOSfix = () => {
4829 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4830 const offset = document.body.scrollTop;
4831 document.body.style.top = `${offset * -1}px`;
4832 addClass(document.body, swalClasses.iosfix);
4833 lockBodyScroll();
4834 }
4835 };
4836
4837 /**
4838 * https://github.com/sweetalert2/sweetalert2/issues/1246
4839 */
4840 const lockBodyScroll = () => {
4841 const container = getContainer();
4842 if (!container) {
4843 return;
4844 }
4845 /** @type {boolean} */
4846 let preventTouchMove;
4847 /**
4848 * @param {TouchEvent} event
4849 */
4850 container.ontouchstart = event => {
4851 preventTouchMove = shouldPreventTouchMove(event);
4852 };
4853 /**
4854 * @param {TouchEvent} event
4855 */
4856 container.ontouchmove = event => {
4857 if (preventTouchMove) {
4858 event.preventDefault();
4859 event.stopPropagation();
4860 }
4861 };
4862 };
4863
4864 /**
4865 * @param {TouchEvent} event
4866 * @returns {boolean}
4867 */
4868 const shouldPreventTouchMove = event => {
4869 const target = event.target;
4870 const container = getContainer();
4871 const htmlContainer = getHtmlContainer();
4872 if (!container || !htmlContainer) {
4873 return false;
4874 }
4875 if (isStylus(event) || isZoom(event)) {
4876 return false;
4877 }
4878 if (target === container) {
4879 return true;
4880 }
4881 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4882 // #2823
4883 target.tagName !== 'INPUT' &&
4884 // #1603
4885 target.tagName !== 'TEXTAREA' &&
4886 // #2266
4887 !(isScrollable(htmlContainer) &&
4888 // #1944
4889 htmlContainer.contains(target))) {
4890 return true;
4891 }
4892 return false;
4893 };
4894
4895 /**
4896 * https://github.com/sweetalert2/sweetalert2/issues/1786
4897 *
4898 * @param {TouchEvent} event
4899 * @returns {boolean}
4900 */
4901 const isStylus = event => {
4902 return Boolean(event.touches && event.touches.length &&
4903 // @ts-ignore - touchType is not a standard property
4904 event.touches[0].touchType === 'stylus');
4905 };
4906
4907 /**
4908 * https://github.com/sweetalert2/sweetalert2/issues/1891
4909 *
4910 * @param {TouchEvent} event
4911 * @returns {boolean}
4912 */
4913 const isZoom = event => {
4914 return event.touches && event.touches.length > 1;
4915 };
4916 const undoIOSfix = () => {
4917 if (hasClass(document.body, swalClasses.iosfix)) {
4918 const offset = parseInt(document.body.style.top, 10);
4919 removeClass(document.body, swalClasses.iosfix);
4920 document.body.style.top = '';
4921 document.body.scrollTop = offset * -1;
4922 }
4923 };
4924
4925 /**
4926 * Measure scrollbar width for padding body during modal show/hide
4927 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4928 *
4929 * @returns {number}
4930 */
4931 const measureScrollbar = () => {
4932 const scrollDiv = document.createElement('div');
4933 scrollDiv.className = swalClasses['scrollbar-measure'];
4934 document.body.appendChild(scrollDiv);
4935 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4936 document.body.removeChild(scrollDiv);
4937 return scrollbarWidth;
4938 };
4939
4940 /**
4941 * Remember state in cases where opening and handling a modal will fiddle with it.
4942 * @type {number | null}
4943 */
4944 let previousBodyPadding = null;
4945
4946 /**
4947 * @param {string} initialBodyOverflow
4948 */
4949 const replaceScrollbarWithPadding = initialBodyOverflow => {
4950 // for queues, do not do this more than once
4951 if (previousBodyPadding !== null) {
4952 return;
4953 }
4954 // if the body has overflow
4955 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4956 ) {
4957 // add padding so the content doesn't shift after removal of scrollbar
4958 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4959 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4960 }
4961 };
4962 const undoReplaceScrollbarWithPadding = () => {
4963 if (previousBodyPadding !== null) {
4964 document.body.style.paddingRight = `${previousBodyPadding}px`;
4965 previousBodyPadding = null;
4966 }
4967 };
4968
4969 /**
4970 * @param {SweetAlert} instance
4971 * @param {HTMLElement} container
4972 * @param {boolean} returnFocus
4973 * @param {(() => void) | undefined} didClose
4974 */
4975 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4976 if (isToast()) {
4977 triggerDidCloseAndDispose(instance, didClose);
4978 } else {
4979 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4980 removeKeydownHandler(globalState);
4981 }
4982
4983 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4984 // for some reason removing the container in Safari will scroll the document to bottom
4985 if (isSafariOrIOS) {
4986 container.setAttribute('style', 'display:none !important');
4987 container.removeAttribute('class');
4988 container.innerHTML = '';
4989 } else {
4990 container.remove();
4991 }
4992 if (isModal()) {
4993 undoReplaceScrollbarWithPadding();
4994 undoIOSfix();
4995 unsetAriaHidden();
4996 }
4997 removeBodyClasses();
4998 }
4999
5000 /**
5001 * Remove SweetAlert2 classes from body
5002 */
5003 function removeBodyClasses() {
5004 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
5005 }
5006
5007 /**
5008 * Instance method to close sweetAlert
5009 *
5010 * @param {SweetAlertResult | undefined} resolveValue
5011 * @this {SweetAlert}
5012 */
5013 function close(resolveValue) {
5014 resolveValue = prepareResolveValue(resolveValue);
5015 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
5016 const didClose = triggerClosePopup(this);
5017 if (this.isAwaitingPromise) {
5018 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
5019 if (!resolveValue.isDismissed) {
5020 handleAwaitingPromise(this);
5021 swalPromiseResolve(resolveValue);
5022 }
5023 } else if (didClose) {
5024 // Resolve Swal promise
5025 swalPromiseResolve(resolveValue);
5026 }
5027 }
5028
5029 /**
5030 * @param {SweetAlert} instance
5031 * @returns {boolean}
5032 */
5033 const triggerClosePopup = instance => {
5034 const popup = getPopup();
5035 if (!popup) {
5036 return false;
5037 }
5038 const innerParams = privateProps.innerParams.get(instance);
5039 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
5040 return false;
5041 }
5042 removeClass(popup, innerParams.showClass.popup);
5043 addClass(popup, innerParams.hideClass.popup);
5044 const backdrop = getContainer();
5045 removeClass(backdrop, innerParams.showClass.backdrop);
5046 addClass(backdrop, innerParams.hideClass.backdrop);
5047 handlePopupAnimation(instance, popup, innerParams);
5048 return true;
5049 };
5050
5051 /**
5052 * @param {Error | string} error
5053 * @this {SweetAlert}
5054 */
5055 function rejectPromise(error) {
5056 const rejectPromise = privateMethods.swalPromiseReject.get(this);
5057 handleAwaitingPromise(this);
5058 if (rejectPromise) {
5059 // Reject Swal promise
5060 rejectPromise(error);
5061 }
5062 }
5063
5064 /**
5065 * @param {SweetAlert} instance
5066 */
5067 const handleAwaitingPromise = instance => {
5068 if (instance.isAwaitingPromise) {
5069 // @ts-ignore
5070 delete instance.isAwaitingPromise;
5071 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
5072 if (!privateProps.innerParams.get(instance)) {
5073 instance._destroy();
5074 }
5075 }
5076 };
5077
5078 /**
5079 * @param {SweetAlertResult | undefined} resolveValue
5080 * @returns {SweetAlertResult}
5081 */
5082 const prepareResolveValue = resolveValue => {
5083 // When user calls Swal.close()
5084 if (typeof resolveValue === 'undefined') {
5085 return {
5086 isConfirmed: false,
5087 isDenied: false,
5088 isDismissed: true
5089 };
5090 }
5091 return Object.assign({
5092 isConfirmed: false,
5093 isDenied: false,
5094 isDismissed: false
5095 }, resolveValue);
5096 };
5097
5098 /**
5099 * @param {SweetAlert} instance
5100 * @param {HTMLElement} popup
5101 * @param {SweetAlertOptions} innerParams
5102 */
5103 const handlePopupAnimation = (instance, popup, innerParams) => {
5104 var _globalState$eventEmi;
5105 const container = getContainer();
5106 // If animation is supported, animate
5107 const animationIsSupported = hasCssAnimation(popup);
5108 if (typeof innerParams.willClose === 'function') {
5109 innerParams.willClose(popup);
5110 }
5111 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
5112 if (animationIsSupported && container) {
5113 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
5114 } else if (container) {
5115 // Otherwise, remove immediately
5116 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
5117 }
5118 };
5119
5120 /**
5121 * @param {SweetAlert} instance
5122 * @param {HTMLElement} popup
5123 * @param {HTMLElement} container
5124 * @param {boolean} returnFocus
5125 * @param {(() => void) | undefined} didClose
5126 */
5127 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
5128 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
5129 /**
5130 * @param {AnimationEvent | TransitionEvent} e
5131 */
5132 const swalCloseAnimationFinished = function (e) {
5133 if (e.target === popup) {
5134 var _globalState$swalClos;
5135 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
5136 delete globalState.swalCloseEventFinishedCallback;
5137 popup.removeEventListener('animationend', swalCloseAnimationFinished);
5138 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
5139 }
5140 };
5141 popup.addEventListener('animationend', swalCloseAnimationFinished);
5142 popup.addEventListener('transitionend', swalCloseAnimationFinished);
5143 };
5144
5145 /**
5146 * @param {SweetAlert} instance
5147 * @param {(() => void) | undefined} didClose
5148 */
5149 const triggerDidCloseAndDispose = (instance, didClose) => {
5150 setTimeout(() => {
5151 var _globalState$eventEmi2;
5152 if (typeof didClose === 'function') {
5153 didClose.bind(instance.params)();
5154 }
5155 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
5156 // instance might have been destroyed already
5157 if (instance._destroy) {
5158 instance._destroy();
5159 }
5160 });
5161 };
5162
5163 /**
5164 * Shows loader (spinner), this is useful with AJAX requests.
5165 * By default the loader be shown instead of the "Confirm" button.
5166 *
5167 * @param {HTMLButtonElement | null} [buttonToReplace]
5168 */
5169 const showLoading = buttonToReplace => {
5170 let popup = getPopup();
5171 if (!popup) {
5172 new Swal();
5173 }
5174 popup = getPopup();
5175 if (!popup) {
5176 return;
5177 }
5178 const loader = getLoader();
5179 if (isToast()) {
5180 hide(getIcon());
5181 } else {
5182 replaceButton(popup, buttonToReplace);
5183 }
5184 show(loader);
5185 popup.setAttribute('data-loading', 'true');
5186 popup.setAttribute('aria-busy', 'true');
5187 popup.focus();
5188 };
5189
5190 /**
5191 * @param {HTMLElement} popup
5192 * @param {HTMLButtonElement | null} [buttonToReplace]
5193 */
5194 const replaceButton = (popup, buttonToReplace) => {
5195 const actions = getActions();
5196 const loader = getLoader();
5197 if (!actions || !loader) {
5198 return;
5199 }
5200 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
5201 buttonToReplace = getConfirmButton();
5202 }
5203 show(actions);
5204 if (buttonToReplace) {
5205 hide(buttonToReplace);
5206 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
5207 actions.insertBefore(loader, buttonToReplace);
5208 }
5209 addClass([popup, actions], swalClasses.loading);
5210 };
5211
5212 /**
5213 * @param {SweetAlert} instance
5214 * @param {SweetAlertOptions} params
5215 */
5216 const handleInputOptionsAndValue = (instance, params) => {
5217 if (params.input === 'select' || params.input === 'radio') {
5218 handleInputOptions(instance, params);
5219 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
5220 showLoading(getConfirmButton());
5221 handleInputValue(instance, params);
5222 }
5223 };
5224
5225 /**
5226 * @param {SweetAlert} instance
5227 * @param {SweetAlertOptions} innerParams
5228 * @returns {SweetAlertInputValue}
5229 */
5230 const getInputValue = (instance, innerParams) => {
5231 const input = instance.getInput();
5232 if (!input) {
5233 return null;
5234 }
5235 switch (innerParams.input) {
5236 case 'checkbox':
5237 return getCheckboxValue(input);
5238 case 'radio':
5239 return getRadioValue(input);
5240 case 'file':
5241 return getFileValue(input);
5242 default:
5243 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
5244 }
5245 };
5246
5247 /**
5248 * @param {HTMLInputElement} input
5249 * @returns {number}
5250 */
5251 const getCheckboxValue = input => input.checked ? 1 : 0;
5252
5253 /**
5254 * @param {HTMLInputElement} input
5255 * @returns {string | null}
5256 */
5257 const getRadioValue = input => input.checked ? input.value : null;
5258
5259 /**
5260 * @param {HTMLInputElement} input
5261 * @returns {FileList | File | null}
5262 */
5263 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
5264
5265 /**
5266 * @param {SweetAlert} instance
5267 * @param {SweetAlertOptions} params
5268 */
5269 const handleInputOptions = (instance, params) => {
5270 const popup = getPopup();
5271 if (!popup) {
5272 return;
5273 }
5274 /**
5275 * @param {*} inputOptions
5276 */
5277 const processInputOptions = inputOptions => {
5278 if (params.input === 'select') {
5279 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
5280 } else if (params.input === 'radio') {
5281 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
5282 }
5283 };
5284 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
5285 showLoading(getConfirmButton());
5286 asPromise(params.inputOptions).then(inputOptions => {
5287 instance.hideLoading();
5288 processInputOptions(inputOptions);
5289 });
5290 } else if (typeof params.inputOptions === 'object') {
5291 processInputOptions(params.inputOptions);
5292 } else {
5293 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
5294 }
5295 };
5296
5297 /**
5298 * @param {SweetAlert} instance
5299 * @param {SweetAlertOptions} params
5300 */
5301 const handleInputValue = (instance, params) => {
5302 const input = instance.getInput();
5303 if (!input) {
5304 return;
5305 }
5306 hide(input);
5307 asPromise(params.inputValue).then(inputValue => {
5308 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
5309 show(input);
5310 input.focus();
5311 instance.hideLoading();
5312 }).catch(err => {
5313 error(`Error in inputValue promise: ${err}`);
5314 input.value = '';
5315 show(input);
5316 input.focus();
5317 instance.hideLoading();
5318 });
5319 };
5320
5321 /**
5322 * @param {HTMLElement} popup
5323 * @param {InputOptionFlattened[]} inputOptions
5324 * @param {SweetAlertOptions} params
5325 */
5326 function populateSelectOptions(popup, inputOptions, params) {
5327 const select = getDirectChildByClass(popup, swalClasses.select);
5328 if (!select) {
5329 return;
5330 }
5331 /**
5332 * @param {HTMLElement} parent
5333 * @param {string} optionLabel
5334 * @param {string} optionValue
5335 */
5336 const renderOption = (parent, optionLabel, optionValue) => {
5337 const option = document.createElement('option');
5338 option.value = optionValue;
5339 setInnerHtml(option, optionLabel);
5340 option.selected = isSelected(optionValue, params.inputValue);
5341 parent.appendChild(option);
5342 };
5343 inputOptions.forEach(inputOption => {
5344 const optionValue = inputOption[0];
5345 const optionLabel = inputOption[1];
5346 // <optgroup> spec:
5347 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
5348 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
5349 // check whether this is a <optgroup>
5350 if (Array.isArray(optionLabel)) {
5351 // if it is an array, then it is an <optgroup>
5352 const optgroup = document.createElement('optgroup');
5353 optgroup.label = optionValue;
5354 optgroup.disabled = false; // not configurable for now
5355 select.appendChild(optgroup);
5356 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
5357 } else {
5358 // case of <option>
5359 renderOption(select, optionLabel, optionValue);
5360 }
5361 });
5362 select.focus();
5363 }
5364
5365 /**
5366 * @param {HTMLElement} popup
5367 * @param {InputOptionFlattened[]} inputOptions
5368 * @param {SweetAlertOptions} params
5369 */
5370 function populateRadioOptions(popup, inputOptions, params) {
5371 const radio = getDirectChildByClass(popup, swalClasses.radio);
5372 if (!radio) {
5373 return;
5374 }
5375 inputOptions.forEach(inputOption => {
5376 const radioValue = inputOption[0];
5377 const radioLabel = inputOption[1];
5378 const radioInput = document.createElement('input');
5379 const radioLabelElement = document.createElement('label');
5380 radioInput.type = 'radio';
5381 radioInput.name = swalClasses.radio;
5382 radioInput.value = radioValue;
5383 if (isSelected(radioValue, params.inputValue)) {
5384 radioInput.checked = true;
5385 }
5386 const label = document.createElement('span');
5387 setInnerHtml(label, radioLabel);
5388 label.className = swalClasses.label;
5389 radioLabelElement.appendChild(radioInput);
5390 radioLabelElement.appendChild(label);
5391 radio.appendChild(radioLabelElement);
5392 });
5393 const radios = radio.querySelectorAll('input');
5394 if (radios.length) {
5395 radios[0].focus();
5396 }
5397 }
5398
5399 /**
5400 * Converts `inputOptions` into an array of `[value, label]`s
5401 *
5402 * @param {*} inputOptions
5403 * @typedef {string[]} InputOptionFlattened
5404 * @returns {InputOptionFlattened[]}
5405 */
5406 const formatInputOptions = inputOptions => {
5407 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
5408 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
5409 };
5410
5411 /**
5412 * @param {string} optionValue
5413 * @param {SweetAlertInputValue} inputValue
5414 * @returns {boolean}
5415 */
5416 const isSelected = (optionValue, inputValue) => Boolean(inputValue) && inputValue != null && inputValue.toString() === optionValue.toString();
5417
5418 /**
5419 * @param {SweetAlert} instance
5420 */
5421 const handleConfirmButtonClick = instance => {
5422 const innerParams = privateProps.innerParams.get(instance);
5423 instance.disableButtons();
5424 if (innerParams.input) {
5425 handleConfirmOrDenyWithInput(instance, 'confirm');
5426 } else {
5427 confirm(instance, true);
5428 }
5429 };
5430
5431 /**
5432 * @param {SweetAlert} instance
5433 */
5434 const handleDenyButtonClick = instance => {
5435 const innerParams = privateProps.innerParams.get(instance);
5436 instance.disableButtons();
5437 if (innerParams.returnInputValueOnDeny) {
5438 handleConfirmOrDenyWithInput(instance, 'deny');
5439 } else {
5440 deny(instance, false);
5441 }
5442 };
5443
5444 /**
5445 * @param {SweetAlert} instance
5446 * @param {(dismiss: DismissReason) => void} dismissWith
5447 */
5448 const handleCancelButtonClick = (instance, dismissWith) => {
5449 instance.disableButtons();
5450 dismissWith(DismissReason.cancel);
5451 };
5452
5453 /**
5454 * @param {SweetAlert} instance
5455 * @param {'confirm' | 'deny'} type
5456 */
5457 const handleConfirmOrDenyWithInput = (instance, type) => {
5458 const innerParams = privateProps.innerParams.get(instance);
5459 if (!innerParams.input) {
5460 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
5461 return;
5462 }
5463 const input = instance.getInput();
5464 const inputValue = getInputValue(instance, innerParams);
5465 if (innerParams.inputValidator) {
5466 handleInputValidator(instance, inputValue, type);
5467 } else if (input && !input.checkValidity()) {
5468 instance.enableButtons();
5469 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
5470 } else if (type === 'deny') {
5471 deny(instance, inputValue);
5472 } else {
5473 confirm(instance, inputValue);
5474 }
5475 };
5476
5477 /**
5478 * @param {SweetAlert} instance
5479 * @param {SweetAlertInputValue} inputValue
5480 * @param {'confirm' | 'deny'} type
5481 */
5482 const handleInputValidator = (instance, inputValue, type) => {
5483 const innerParams = privateProps.innerParams.get(instance);
5484 instance.disableInput();
5485 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
5486 validationPromise.then(validationMessage => {
5487 instance.enableButtons();
5488 instance.enableInput();
5489 if (validationMessage) {
5490 instance.showValidationMessage(validationMessage);
5491 } else if (type === 'deny') {
5492 deny(instance, inputValue);
5493 } else {
5494 confirm(instance, inputValue);
5495 }
5496 });
5497 };
5498
5499 /**
5500 * @param {SweetAlert} instance
5501 * @param {*} value
5502 */
5503 const deny = (instance, value) => {
5504 const innerParams = privateProps.innerParams.get(instance);
5505 if (innerParams.showLoaderOnDeny) {
5506 showLoading(getDenyButton());
5507 }
5508 if (innerParams.preDeny) {
5509 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
5510 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
5511 preDenyPromise.then(preDenyValue => {
5512 if (preDenyValue === false) {
5513 instance.hideLoading();
5514 handleAwaitingPromise(instance);
5515 } else {
5516 instance.close(/** @type SweetAlertResult */{
5517 isDenied: true,
5518 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
5519 });
5520 }
5521 }).catch(error => rejectWith(instance, error));
5522 } else {
5523 instance.close(/** @type SweetAlertResult */{
5524 isDenied: true,
5525 value
5526 });
5527 }
5528 };
5529
5530 /**
5531 * @param {SweetAlert} instance
5532 * @param {*} value
5533 */
5534 const succeedWith = (instance, value) => {
5535 instance.close(/** @type SweetAlertResult */{
5536 isConfirmed: true,
5537 value
5538 });
5539 };
5540
5541 /**
5542 *
5543 * @param {SweetAlert} instance
5544 * @param {string} error
5545 */
5546 const rejectWith = (instance, error) => {
5547 instance.rejectPromise(error);
5548 };
5549
5550 /**
5551 *
5552 * @param {SweetAlert} instance
5553 * @param {*} value
5554 */
5555 const confirm = (instance, value) => {
5556 const innerParams = privateProps.innerParams.get(instance);
5557 if (innerParams.showLoaderOnConfirm) {
5558 showLoading();
5559 }
5560 if (innerParams.preConfirm) {
5561 instance.resetValidationMessage();
5562 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
5563 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5564 preConfirmPromise.then(preConfirmValue => {
5565 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5566 instance.hideLoading();
5567 handleAwaitingPromise(instance);
5568 } else {
5569 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5570 }
5571 }).catch(error => rejectWith(instance, error));
5572 } else {
5573 succeedWith(instance, value);
5574 }
5575 };
5576
5577 /**
5578 * Hides loader and shows back the button which was hidden by .showLoading()
5579 * @this {SweetAlert}
5580 */
5581 function hideLoading() {
5582 // do nothing if popup is closed
5583 const innerParams = privateProps.innerParams.get(this);
5584 if (!innerParams) {
5585 return;
5586 }
5587 const domCache = privateProps.domCache.get(this);
5588 hide(domCache.loader);
5589 if (isToast()) {
5590 if (innerParams.icon) {
5591 show(getIcon());
5592 }
5593 } else {
5594 showRelatedButton(domCache);
5595 }
5596 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5597 domCache.popup.removeAttribute('aria-busy');
5598 domCache.popup.removeAttribute('data-loading');
5599 this.enableButtons();
5600 }
5601
5602 /**
5603 * @param {DomCache} domCache
5604 */
5605 const showRelatedButton = domCache => {
5606 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5607 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5608 if (buttonToReplace.length) {
5609 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5610 } else if (allButtonsAreHidden()) {
5611 hide(domCache.actions);
5612 }
5613 };
5614
5615 /**
5616 * Gets the input DOM node, this method works with input parameter.
5617 *
5618 * @returns {HTMLInputElement | null}
5619 * @this {SweetAlert}
5620 */
5621 function getInput() {
5622 const innerParams = privateProps.innerParams.get(this);
5623 const domCache = privateProps.domCache.get(this);
5624 if (!domCache) {
5625 return null;
5626 }
5627 return getInput$1(domCache.popup, innerParams.input);
5628 }
5629
5630 /**
5631 * @param {SweetAlert} instance
5632 * @param {string[]} buttons
5633 * @param {boolean} disabled
5634 */
5635 function setButtonsDisabled(instance, buttons, disabled) {
5636 const domCache = privateProps.domCache.get(instance);
5637 buttons.forEach(button => {
5638 domCache[button].disabled = disabled;
5639 });
5640 }
5641
5642 /**
5643 * @param {HTMLInputElement | null} input
5644 * @param {boolean} disabled
5645 */
5646 function setInputDisabled(input, disabled) {
5647 const popup = getPopup();
5648 if (!popup || !input) {
5649 return;
5650 }
5651 if (input.type === 'radio') {
5652 /** @type {NodeListOf<HTMLInputElement>} */
5653 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5654 radios.forEach(radio => {
5655 radio.disabled = disabled;
5656 });
5657 } else {
5658 input.disabled = disabled;
5659 }
5660 }
5661
5662 /**
5663 * Enable all the buttons
5664 * @this {SweetAlert}
5665 */
5666 function enableButtons() {
5667 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5668 const focusedElement = privateProps.focusedElement.get(this);
5669 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
5670 focusedElement.focus();
5671 }
5672 privateProps.focusedElement.delete(this);
5673 }
5674
5675 /**
5676 * Disable all the buttons
5677 * @this {SweetAlert}
5678 */
5679 function disableButtons() {
5680 privateProps.focusedElement.set(this, document.activeElement);
5681 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5682 }
5683
5684 /**
5685 * Enable the input field
5686 * @this {SweetAlert}
5687 */
5688 function enableInput() {
5689 setInputDisabled(this.getInput(), false);
5690 }
5691
5692 /**
5693 * Disable the input field
5694 * @this {SweetAlert}
5695 */
5696 function disableInput() {
5697 setInputDisabled(this.getInput(), true);
5698 }
5699
5700 /**
5701 * Show block with validation message
5702 *
5703 * @param {string} error
5704 * @this {SweetAlert}
5705 */
5706 function showValidationMessage(error) {
5707 const domCache = privateProps.domCache.get(this);
5708 const params = privateProps.innerParams.get(this);
5709 setInnerHtml(domCache.validationMessage, error);
5710 domCache.validationMessage.className = swalClasses['validation-message'];
5711 if (params.customClass && params.customClass.validationMessage) {
5712 addClass(domCache.validationMessage, params.customClass.validationMessage);
5713 }
5714 show(domCache.validationMessage);
5715 const input = this.getInput();
5716 if (input) {
5717 input.setAttribute('aria-invalid', 'true');
5718 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5719 focusInput(input);
5720 addClass(input, swalClasses.inputerror);
5721 }
5722 }
5723
5724 /**
5725 * Hide block with validation message
5726 *
5727 * @this {SweetAlert}
5728 */
5729 function resetValidationMessage() {
5730 const domCache = privateProps.domCache.get(this);
5731 if (domCache.validationMessage) {
5732 hide(domCache.validationMessage);
5733 }
5734 const input = this.getInput();
5735 if (input) {
5736 input.removeAttribute('aria-invalid');
5737 input.removeAttribute('aria-describedby');
5738 removeClass(input, swalClasses.inputerror);
5739 }
5740 }
5741
5742 const defaultParams = {
5743 title: '',
5744 titleText: '',
5745 text: '',
5746 html: '',
5747 footer: '',
5748 icon: undefined,
5749 iconColor: undefined,
5750 iconHtml: undefined,
5751 template: undefined,
5752 toast: false,
5753 draggable: false,
5754 animation: true,
5755 theme: 'light',
5756 showClass: {
5757 popup: 'swal2-show',
5758 backdrop: 'swal2-backdrop-show',
5759 icon: 'swal2-icon-show'
5760 },
5761 hideClass: {
5762 popup: 'swal2-hide',
5763 backdrop: 'swal2-backdrop-hide',
5764 icon: 'swal2-icon-hide'
5765 },
5766 customClass: {},
5767 target: 'body',
5768 color: undefined,
5769 backdrop: true,
5770 heightAuto: true,
5771 allowOutsideClick: true,
5772 allowEscapeKey: true,
5773 allowEnterKey: true,
5774 stopKeydownPropagation: true,
5775 keydownListenerCapture: false,
5776 showConfirmButton: true,
5777 showDenyButton: false,
5778 showCancelButton: false,
5779 preConfirm: undefined,
5780 preDeny: undefined,
5781 confirmButtonText: 'OK',
5782 confirmButtonAriaLabel: '',
5783 confirmButtonColor: undefined,
5784 denyButtonText: 'No',
5785 denyButtonAriaLabel: '',
5786 denyButtonColor: undefined,
5787 cancelButtonText: 'Cancel',
5788 cancelButtonAriaLabel: '',
5789 cancelButtonColor: undefined,
5790 buttonsStyling: true,
5791 reverseButtons: false,
5792 focusConfirm: true,
5793 focusDeny: false,
5794 focusCancel: false,
5795 returnFocus: true,
5796 showCloseButton: false,
5797 closeButtonHtml: '&times;',
5798 closeButtonAriaLabel: 'Close this dialog',
5799 loaderHtml: '',
5800 showLoaderOnConfirm: false,
5801 showLoaderOnDeny: false,
5802 imageUrl: undefined,
5803 imageWidth: undefined,
5804 imageHeight: undefined,
5805 imageAlt: '',
5806 timer: undefined,
5807 timerProgressBar: false,
5808 width: undefined,
5809 padding: undefined,
5810 background: undefined,
5811 input: undefined,
5812 inputPlaceholder: '',
5813 inputLabel: '',
5814 inputValue: '',
5815 inputOptions: {},
5816 inputAutoFocus: true,
5817 inputAutoTrim: true,
5818 inputAttributes: {},
5819 inputValidator: undefined,
5820 returnInputValueOnDeny: false,
5821 validationMessage: undefined,
5822 grow: false,
5823 position: 'center',
5824 progressSteps: [],
5825 currentProgressStep: undefined,
5826 progressStepsDistance: undefined,
5827 willOpen: undefined,
5828 didOpen: undefined,
5829 didRender: undefined,
5830 willClose: undefined,
5831 didClose: undefined,
5832 didDestroy: undefined,
5833 scrollbarPadding: true,
5834 topLayer: false
5835 };
5836 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'];
5837
5838 /** @type {Record<string, string | undefined>} */
5839 const deprecatedParams = {
5840 allowEnterKey: undefined
5841 };
5842 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5843
5844 /**
5845 * Is valid parameter
5846 *
5847 * @param {string} paramName
5848 * @returns {boolean}
5849 */
5850 const isValidParameter = paramName => {
5851 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5852 };
5853
5854 /**
5855 * Is valid parameter for Swal.update() method
5856 *
5857 * @param {string} paramName
5858 * @returns {boolean}
5859 */
5860 const isUpdatableParameter = paramName => {
5861 return updatableParams.indexOf(paramName) !== -1;
5862 };
5863
5864 /**
5865 * Is deprecated parameter
5866 *
5867 * @param {string} paramName
5868 * @returns {string | undefined}
5869 */
5870 const isDeprecatedParameter = paramName => {
5871 return deprecatedParams[paramName];
5872 };
5873
5874 /**
5875 * @param {string} param
5876 */
5877 const checkIfParamIsValid = param => {
5878 if (!isValidParameter(param)) {
5879 warn(`Unknown parameter "${param}"`);
5880 }
5881 };
5882
5883 /**
5884 * @param {string} param
5885 */
5886 const checkIfToastParamIsValid = param => {
5887 if (toastIncompatibleParams.includes(param)) {
5888 warn(`The parameter "${param}" is incompatible with toasts`);
5889 }
5890 };
5891
5892 /**
5893 * @param {string} param
5894 */
5895 const checkIfParamIsDeprecated = param => {
5896 const isDeprecated = isDeprecatedParameter(param);
5897 if (isDeprecated) {
5898 warnAboutDeprecation(param, isDeprecated);
5899 }
5900 };
5901
5902 /**
5903 * Show relevant warnings for given params
5904 *
5905 * @param {SweetAlertOptions} params
5906 */
5907 const showWarningsForParams = params => {
5908 if (params.backdrop === false && params.allowOutsideClick) {
5909 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5910 }
5911 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)) {
5912 warn(`Invalid theme "${params.theme}"`);
5913 }
5914 for (const param in params) {
5915 checkIfParamIsValid(param);
5916 if (params.toast) {
5917 checkIfToastParamIsValid(param);
5918 }
5919 checkIfParamIsDeprecated(param);
5920 }
5921 };
5922
5923 /**
5924 * Updates popup parameters.
5925 *
5926 * @this {any}
5927 * @param {SweetAlertOptions} params
5928 */
5929 function update(params) {
5930 const container = getContainer();
5931 const popup = getPopup();
5932 const innerParams = privateProps.innerParams.get(this);
5933 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5934 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.`);
5935 return;
5936 }
5937 const validUpdatableParams = filterValidParams(params);
5938 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5939 showWarningsForParams(updatedParams);
5940 if (container) {
5941 container.dataset['swal2Theme'] = updatedParams.theme;
5942 }
5943 render(this, updatedParams);
5944 privateProps.innerParams.set(this, updatedParams);
5945 Object.defineProperties(this, {
5946 params: {
5947 value: Object.assign({}, this.params, params),
5948 writable: false,
5949 enumerable: true
5950 }
5951 });
5952 }
5953
5954 /**
5955 * @param {SweetAlertOptions} params
5956 * @returns {SweetAlertOptions}
5957 */
5958 const filterValidParams = params => {
5959 /** @type {Record<string, any>} */
5960 const validUpdatableParams = {};
5961 Object.keys(params).forEach(param => {
5962 if (isUpdatableParameter(param)) {
5963 const typedParams = /** @type {Record<string, any>} */params;
5964 validUpdatableParams[param] = typedParams[param];
5965 } else {
5966 warn(`Invalid parameter to update: ${param}`);
5967 }
5968 });
5969 return validUpdatableParams;
5970 };
5971
5972 /**
5973 * Dispose the current SweetAlert2 instance
5974 * @this {SweetAlert}
5975 */
5976 function _destroy() {
5977 var _globalState$eventEmi;
5978 const domCache = privateProps.domCache.get(this);
5979 const innerParams = privateProps.innerParams.get(this);
5980 if (!innerParams) {
5981 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5982 return; // This instance has already been destroyed
5983 }
5984
5985 // Check if there is another Swal closing
5986 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5987 globalState.swalCloseEventFinishedCallback();
5988 delete globalState.swalCloseEventFinishedCallback;
5989 }
5990 if (typeof innerParams.didDestroy === 'function') {
5991 innerParams.didDestroy();
5992 }
5993 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5994 disposeSwal(this);
5995 }
5996
5997 /**
5998 * @param {SweetAlert} instance
5999 */
6000 const disposeSwal = instance => {
6001 disposeWeakMaps(instance);
6002 // Unset this.params so GC will dispose it (#1569)
6003 // @ts-ignore
6004 delete instance.params;
6005 // Unset globalState props so GC will dispose globalState (#1569)
6006 delete globalState.keydownHandler;
6007 delete globalState.keydownTarget;
6008 // Unset currentInstance
6009 delete globalState.currentInstance;
6010 };
6011
6012 /**
6013 * @param {SweetAlert} instance
6014 */
6015 const disposeWeakMaps = instance => {
6016 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
6017 if (instance.isAwaitingPromise) {
6018 unsetWeakMaps(privateProps, instance);
6019 instance.isAwaitingPromise = true;
6020 } else {
6021 unsetWeakMaps(privateMethods, instance);
6022 unsetWeakMaps(privateProps, instance);
6023
6024 // @ts-ignore
6025 delete instance.isAwaitingPromise;
6026 // Unset instance methods
6027 // @ts-ignore
6028 delete instance.disableButtons;
6029 // @ts-ignore
6030 delete instance.enableButtons;
6031 // @ts-ignore
6032 delete instance.getInput;
6033 // @ts-ignore
6034 delete instance.disableInput;
6035 // @ts-ignore
6036 delete instance.enableInput;
6037 // @ts-ignore
6038 delete instance.hideLoading;
6039 // @ts-ignore
6040 delete instance.disableLoading;
6041 // @ts-ignore
6042 delete instance.showValidationMessage;
6043 // @ts-ignore
6044 delete instance.resetValidationMessage;
6045 // @ts-ignore
6046 delete instance.close;
6047 // @ts-ignore
6048 delete instance.closePopup;
6049 // @ts-ignore
6050 delete instance.closeModal;
6051 // @ts-ignore
6052 delete instance.closeToast;
6053 // @ts-ignore
6054 delete instance.rejectPromise;
6055 // @ts-ignore
6056 delete instance.update;
6057 // @ts-ignore
6058 delete instance._destroy;
6059 }
6060 };
6061
6062 /**
6063 * @param {Record<string, WeakMap<any, any>>} obj
6064 * @param {SweetAlert} instance
6065 */
6066 const unsetWeakMaps = (obj, instance) => {
6067 for (const i in obj) {
6068 obj[i].delete(instance);
6069 }
6070 };
6071
6072 var instanceMethods = /*#__PURE__*/Object.freeze({
6073 __proto__: null,
6074 _destroy: _destroy,
6075 close: close,
6076 closeModal: close,
6077 closePopup: close,
6078 closeToast: close,
6079 disableButtons: disableButtons,
6080 disableInput: disableInput,
6081 disableLoading: hideLoading,
6082 enableButtons: enableButtons,
6083 enableInput: enableInput,
6084 getInput: getInput,
6085 handleAwaitingPromise: handleAwaitingPromise,
6086 hideLoading: hideLoading,
6087 rejectPromise: rejectPromise,
6088 resetValidationMessage: resetValidationMessage,
6089 showValidationMessage: showValidationMessage,
6090 update: update
6091 });
6092
6093 /**
6094 * @param {SweetAlertOptions} innerParams
6095 * @param {DomCache} domCache
6096 * @param {(dismiss: DismissReason) => void} dismissWith
6097 */
6098 const handlePopupClick = (innerParams, domCache, dismissWith) => {
6099 if (innerParams.toast) {
6100 handleToastClick(innerParams, domCache, dismissWith);
6101 } else {
6102 // Ignore click events that had mousedown on the popup but mouseup on the container
6103 // This can happen when the user drags a slider
6104 handleModalMousedown(domCache);
6105
6106 // Ignore click events that had mousedown on the container but mouseup on the popup
6107 handleContainerMousedown(domCache);
6108 handleModalClick(innerParams, domCache, dismissWith);
6109 }
6110 };
6111
6112 /**
6113 * @param {SweetAlertOptions} innerParams
6114 * @param {DomCache} domCache
6115 * @param {(dismiss: DismissReason) => void} dismissWith
6116 */
6117 const handleToastClick = (innerParams, domCache, dismissWith) => {
6118 // Closing toast by internal click
6119 domCache.popup.onclick = () => {
6120 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
6121 return;
6122 }
6123 dismissWith(DismissReason.close);
6124 };
6125 };
6126
6127 /**
6128 * @param {SweetAlertOptions} innerParams
6129 * @returns {boolean}
6130 */
6131 const isAnyButtonShown = innerParams => {
6132 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
6133 };
6134 let ignoreOutsideClick = false;
6135
6136 /**
6137 * @param {DomCache} domCache
6138 */
6139 const handleModalMousedown = domCache => {
6140 domCache.popup.onmousedown = () => {
6141 domCache.container.onmouseup = function (e) {
6142 domCache.container.onmouseup = () => {};
6143 // We only check if the mouseup target is the container because usually it doesn't
6144 // have any other direct children aside of the popup
6145 if (e.target === domCache.container) {
6146 ignoreOutsideClick = true;
6147 }
6148 };
6149 };
6150 };
6151
6152 /**
6153 * @param {DomCache} domCache
6154 */
6155 const handleContainerMousedown = domCache => {
6156 domCache.container.onmousedown = e => {
6157 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
6158 if (e.target === domCache.container) {
6159 e.preventDefault();
6160 }
6161 domCache.popup.onmouseup = function (e) {
6162 domCache.popup.onmouseup = () => {};
6163 // We also need to check if the mouseup target is a child of the popup
6164 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
6165 ignoreOutsideClick = true;
6166 }
6167 };
6168 };
6169 };
6170
6171 /**
6172 * @param {SweetAlertOptions} innerParams
6173 * @param {DomCache} domCache
6174 * @param {(dismiss: DismissReason) => void} dismissWith
6175 */
6176 const handleModalClick = (innerParams, domCache, dismissWith) => {
6177 domCache.container.onclick = e => {
6178 if (ignoreOutsideClick) {
6179 ignoreOutsideClick = false;
6180 return;
6181 }
6182 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
6183 dismissWith(DismissReason.backdrop);
6184 }
6185 };
6186 };
6187
6188 /**
6189 * @param {unknown} elem
6190 * @returns {boolean}
6191 */
6192 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
6193
6194 /**
6195 * @param {unknown} elem
6196 * @returns {boolean}
6197 */
6198 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
6199
6200 /**
6201 * @param {ReadonlyArray<unknown>} args
6202 * @returns {SweetAlertOptions}
6203 */
6204 const argsToParams = args => {
6205 /** @type {Record<string, unknown>} */
6206 const params = {};
6207 if (typeof args[0] === 'object' && !isElement(args[0])) {
6208 Object.assign(params, args[0]);
6209 } else {
6210 ['title', 'html', 'icon'].forEach((name, index) => {
6211 const arg = args[index];
6212 if (typeof arg === 'string' || isElement(arg)) {
6213 params[name] = arg;
6214 } else if (arg !== undefined) {
6215 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
6216 }
6217 });
6218 }
6219 return /** @type {SweetAlertOptions} */params;
6220 };
6221
6222 /**
6223 * Main method to create a new SweetAlert2 popup
6224 *
6225 * @this {new (...args: any[]) => any}
6226 * @param {...SweetAlertOptions} args
6227 * @returns {Promise<SweetAlertResult>}
6228 */
6229 function fire(...args) {
6230 return new this(...args);
6231 }
6232
6233 /**
6234 * Returns an extended version of `Swal` containing `params` as defaults.
6235 * Useful for reusing Swal configuration.
6236 *
6237 * For example:
6238 *
6239 * Before:
6240 * const textPromptOptions = { input: 'text', showCancelButton: true }
6241 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
6242 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
6243 *
6244 * After:
6245 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
6246 * const {value: firstName} = await TextPrompt('What is your first name?')
6247 * const {value: lastName} = await TextPrompt('What is your last name?')
6248 *
6249 * @param {SweetAlertOptions} mixinParams
6250 * @returns {SweetAlert}
6251 * @this {typeof import('../SweetAlert.js').SweetAlert}
6252 */
6253 function mixin(mixinParams) {
6254 // @ts-ignore: 'this' refers to the SweetAlert constructor
6255 class MixinSwal extends this {
6256 /**
6257 * @param {any} params
6258 * @param {any} priorityMixinParams
6259 */
6260 _main(params, priorityMixinParams) {
6261 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
6262 }
6263 }
6264 // @ts-ignore
6265 return MixinSwal;
6266 }
6267
6268 /**
6269 * If `timer` parameter is set, returns number of milliseconds of timer remained.
6270 * Otherwise, returns undefined.
6271 *
6272 * @returns {number | undefined}
6273 */
6274 const getTimerLeft = () => {
6275 return globalState.timeout && globalState.timeout.getTimerLeft();
6276 };
6277
6278 /**
6279 * Stop timer. Returns number of milliseconds of timer remained.
6280 * If `timer` parameter isn't set, returns undefined.
6281 *
6282 * @returns {number | undefined}
6283 */
6284 const stopTimer = () => {
6285 if (globalState.timeout) {
6286 stopTimerProgressBar();
6287 return globalState.timeout.stop();
6288 }
6289 };
6290
6291 /**
6292 * Resume timer. Returns number of milliseconds of timer remained.
6293 * If `timer` parameter isn't set, returns undefined.
6294 *
6295 * @returns {number | undefined}
6296 */
6297 const resumeTimer = () => {
6298 if (globalState.timeout) {
6299 const remaining = globalState.timeout.start();
6300 animateTimerProgressBar(remaining);
6301 return remaining;
6302 }
6303 };
6304
6305 /**
6306 * Resume timer. Returns number of milliseconds of timer remained.
6307 * If `timer` parameter isn't set, returns undefined.
6308 *
6309 * @returns {number | undefined}
6310 */
6311 const toggleTimer = () => {
6312 const timer = globalState.timeout;
6313 return timer && (timer.running ? stopTimer() : resumeTimer());
6314 };
6315
6316 /**
6317 * Increase timer. Returns number of milliseconds of an updated timer.
6318 * If `timer` parameter isn't set, returns undefined.
6319 *
6320 * @param {number} ms
6321 * @returns {number | undefined}
6322 */
6323 const increaseTimer = ms => {
6324 if (globalState.timeout) {
6325 const remaining = globalState.timeout.increase(ms);
6326 animateTimerProgressBar(remaining, true);
6327 return remaining;
6328 }
6329 };
6330
6331 /**
6332 * Check if timer is running. Returns true if timer is running
6333 * or false if timer is paused or stopped.
6334 * If `timer` parameter isn't set, returns undefined
6335 *
6336 * @returns {boolean}
6337 */
6338 const isTimerRunning = () => {
6339 return Boolean(globalState.timeout && globalState.timeout.isRunning());
6340 };
6341
6342 let bodyClickListenerAdded = false;
6343 /** @type {Record<string, any>} */
6344 const clickHandlers = {};
6345
6346 /**
6347 * @this {any}
6348 * @param {string} attr
6349 */
6350 function bindClickHandler(attr = 'data-swal-template') {
6351 clickHandlers[attr] = this;
6352 if (!bodyClickListenerAdded) {
6353 document.body.addEventListener('click', bodyClickListener);
6354 bodyClickListenerAdded = true;
6355 }
6356 }
6357
6358 /**
6359 * @param {MouseEvent} event
6360 */
6361 const bodyClickListener = event => {
6362 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
6363 for (const attr in clickHandlers) {
6364 const template = el.getAttribute && el.getAttribute(attr);
6365 if (template) {
6366 clickHandlers[attr].fire({
6367 template
6368 });
6369 return;
6370 }
6371 }
6372 }
6373 };
6374
6375 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
6376
6377 class EventEmitter {
6378 constructor() {
6379 /** @type {Events} */
6380 this.events = {};
6381 }
6382
6383 /**
6384 * @param {string} eventName
6385 * @returns {EventHandlers}
6386 */
6387 _getHandlersByEventName(eventName) {
6388 if (typeof this.events[eventName] === 'undefined') {
6389 // not Set because we need to keep the FIFO order
6390 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
6391 this.events[eventName] = [];
6392 }
6393 return this.events[eventName];
6394 }
6395
6396 /**
6397 * @param {string} eventName
6398 * @param {EventHandler} eventHandler
6399 */
6400 on(eventName, eventHandler) {
6401 const currentHandlers = this._getHandlersByEventName(eventName);
6402 if (!currentHandlers.includes(eventHandler)) {
6403 currentHandlers.push(eventHandler);
6404 }
6405 }
6406
6407 /**
6408 * @param {string} eventName
6409 * @param {EventHandler} eventHandler
6410 */
6411 once(eventName, eventHandler) {
6412 /**
6413 * @param {...any} args
6414 */
6415 const onceFn = (...args) => {
6416 this.removeListener(eventName, onceFn);
6417 // @ts-ignore
6418 eventHandler.apply(this, args);
6419 };
6420 this.on(eventName, onceFn);
6421 }
6422
6423 /**
6424 * @param {string} eventName
6425 * @param {...any} args
6426 */
6427 emit(eventName, ...args) {
6428 this._getHandlersByEventName(eventName).forEach(
6429 /**
6430 * @param {EventHandler} eventHandler
6431 */
6432 eventHandler => {
6433 try {
6434 // @ts-ignore
6435 eventHandler.apply(this, args);
6436 } catch (error) {
6437 console.error(error);
6438 }
6439 });
6440 }
6441
6442 /**
6443 * @param {string} eventName
6444 * @param {EventHandler} eventHandler
6445 */
6446 removeListener(eventName, eventHandler) {
6447 const currentHandlers = this._getHandlersByEventName(eventName);
6448 const index = currentHandlers.indexOf(eventHandler);
6449 if (index > -1) {
6450 currentHandlers.splice(index, 1);
6451 }
6452 }
6453
6454 /**
6455 * @param {string} eventName
6456 */
6457 removeAllListeners(eventName) {
6458 if (this.events[eventName] !== undefined) {
6459 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
6460 this.events[eventName].length = 0;
6461 }
6462 }
6463 reset() {
6464 this.events = {};
6465 }
6466 }
6467
6468 globalState.eventEmitter = new EventEmitter();
6469
6470 /**
6471 * @param {string} eventName
6472 * @param {EventHandler} eventHandler
6473 */
6474 const on = (eventName, eventHandler) => {
6475 if (globalState.eventEmitter) {
6476 globalState.eventEmitter.on(eventName, eventHandler);
6477 }
6478 };
6479
6480 /**
6481 * @param {string} eventName
6482 * @param {EventHandler} eventHandler
6483 */
6484 const once = (eventName, eventHandler) => {
6485 if (globalState.eventEmitter) {
6486 globalState.eventEmitter.once(eventName, eventHandler);
6487 }
6488 };
6489
6490 /**
6491 * @param {string} [eventName]
6492 * @param {EventHandler} [eventHandler]
6493 */
6494 const off = (eventName, eventHandler) => {
6495 if (!globalState.eventEmitter) {
6496 return;
6497 }
6498
6499 // Remove all handlers for all events
6500 if (!eventName) {
6501 globalState.eventEmitter.reset();
6502 return;
6503 }
6504 if (eventHandler) {
6505 // Remove a specific handler
6506 globalState.eventEmitter.removeListener(eventName, eventHandler);
6507 } else {
6508 // Remove all handlers for a specific event
6509 globalState.eventEmitter.removeAllListeners(eventName);
6510 }
6511 };
6512
6513 var staticMethods = /*#__PURE__*/Object.freeze({
6514 __proto__: null,
6515 argsToParams: argsToParams,
6516 bindClickHandler: bindClickHandler,
6517 clickCancel: clickCancel,
6518 clickConfirm: clickConfirm,
6519 clickDeny: clickDeny,
6520 enableLoading: showLoading,
6521 fire: fire,
6522 getActions: getActions,
6523 getCancelButton: getCancelButton,
6524 getCloseButton: getCloseButton,
6525 getConfirmButton: getConfirmButton,
6526 getContainer: getContainer,
6527 getDenyButton: getDenyButton,
6528 getFocusableElements: getFocusableElements,
6529 getFooter: getFooter,
6530 getHtmlContainer: getHtmlContainer,
6531 getIcon: getIcon,
6532 getIconContent: getIconContent,
6533 getImage: getImage,
6534 getInputLabel: getInputLabel,
6535 getLoader: getLoader,
6536 getPopup: getPopup,
6537 getProgressSteps: getProgressSteps,
6538 getTimerLeft: getTimerLeft,
6539 getTimerProgressBar: getTimerProgressBar,
6540 getTitle: getTitle,
6541 getValidationMessage: getValidationMessage,
6542 increaseTimer: increaseTimer,
6543 isDeprecatedParameter: isDeprecatedParameter,
6544 isLoading: isLoading,
6545 isTimerRunning: isTimerRunning,
6546 isUpdatableParameter: isUpdatableParameter,
6547 isValidParameter: isValidParameter,
6548 isVisible: isVisible,
6549 mixin: mixin,
6550 off: off,
6551 on: on,
6552 once: once,
6553 resumeTimer: resumeTimer,
6554 showLoading: showLoading,
6555 stopTimer: stopTimer,
6556 toggleTimer: toggleTimer
6557 });
6558
6559 class Timer {
6560 /**
6561 * @param {() => void} callback
6562 * @param {number} delay
6563 */
6564 constructor(callback, delay) {
6565 this.callback = callback;
6566 this.remaining = delay;
6567 this.running = false;
6568 this.start();
6569 }
6570
6571 /**
6572 * @returns {number}
6573 */
6574 start() {
6575 if (!this.running) {
6576 this.running = true;
6577 this.started = new Date();
6578 this.id = setTimeout(this.callback, this.remaining);
6579 }
6580 return this.remaining;
6581 }
6582
6583 /**
6584 * @returns {number}
6585 */
6586 stop() {
6587 if (this.started && this.running) {
6588 this.running = false;
6589 clearTimeout(this.id);
6590 this.remaining -= new Date().getTime() - this.started.getTime();
6591 }
6592 return this.remaining;
6593 }
6594
6595 /**
6596 * @param {number} n
6597 * @returns {number}
6598 */
6599 increase(n) {
6600 const running = this.running;
6601 if (running) {
6602 this.stop();
6603 }
6604 this.remaining += n;
6605 if (running) {
6606 this.start();
6607 }
6608 return this.remaining;
6609 }
6610
6611 /**
6612 * @returns {number}
6613 */
6614 getTimerLeft() {
6615 if (this.running) {
6616 this.stop();
6617 this.start();
6618 }
6619 return this.remaining;
6620 }
6621
6622 /**
6623 * @returns {boolean}
6624 */
6625 isRunning() {
6626 return this.running;
6627 }
6628 }
6629
6630 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6631
6632 /**
6633 * @param {SweetAlertOptions} params
6634 * @returns {SweetAlertOptions}
6635 */
6636 const getTemplateParams = params => {
6637 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6638 if (!template) {
6639 return {};
6640 }
6641 /** @type {DocumentFragment} */
6642 const templateContent = template.content;
6643 showWarningsForElements(templateContent);
6644 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6645 return result;
6646 };
6647
6648 /**
6649 * @param {DocumentFragment} templateContent
6650 * @returns {Record<string, string | boolean | number>}
6651 */
6652 const getSwalParams = templateContent => {
6653 /** @type {Record<string, string | boolean | number>} */
6654 const result = {};
6655 /** @type {HTMLElement[]} */
6656 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6657 swalParams.forEach(param => {
6658 showWarningsForAttributes(param, ['name', 'value']);
6659 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6660 const value = param.getAttribute('value');
6661 if (!paramName || !value) {
6662 return;
6663 }
6664 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6665 result[paramName] = value !== 'false';
6666 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6667 result[paramName] = JSON.parse(value);
6668 } else {
6669 result[paramName] = value;
6670 }
6671 });
6672 return result;
6673 };
6674
6675 /**
6676 * @param {DocumentFragment} templateContent
6677 * @returns {Record<string, () => void>}
6678 */
6679 const getSwalFunctionParams = templateContent => {
6680 /** @type {Record<string, () => void>} */
6681 const result = {};
6682 /** @type {HTMLElement[]} */
6683 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6684 swalFunctions.forEach(param => {
6685 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6686 const value = param.getAttribute('value');
6687 if (!paramName || !value) {
6688 return;
6689 }
6690 result[paramName] = new Function(`return ${value}`)();
6691 });
6692 return result;
6693 };
6694
6695 /**
6696 * @param {DocumentFragment} templateContent
6697 * @returns {Record<string, string | boolean>}
6698 */
6699 const getSwalButtons = templateContent => {
6700 /** @type {Record<string, string | boolean>} */
6701 const result = {};
6702 /** @type {HTMLElement[]} */
6703 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6704 swalButtons.forEach(button => {
6705 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6706 const type = button.getAttribute('type');
6707 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6708 return;
6709 }
6710 result[`${type}ButtonText`] = button.innerHTML;
6711 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6712 const color = button.getAttribute('color');
6713 if (color !== null) {
6714 result[`${type}ButtonColor`] = color;
6715 }
6716 const ariaLabel = button.getAttribute('aria-label');
6717 if (ariaLabel !== null) {
6718 result[`${type}ButtonAriaLabel`] = ariaLabel;
6719 }
6720 });
6721 return result;
6722 };
6723
6724 /**
6725 * @param {DocumentFragment} templateContent
6726 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6727 */
6728 const getSwalImage = templateContent => {
6729 const result = {};
6730 /** @type {HTMLElement | null} */
6731 const image = templateContent.querySelector('swal-image');
6732 if (image) {
6733 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6734 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
6735 const src = image.getAttribute('src');
6736 if (src !== null) result.imageUrl = src || undefined;
6737 const width = image.getAttribute('width');
6738 if (width !== null) result.imageWidth = width || undefined;
6739 const height = image.getAttribute('height');
6740 if (height !== null) result.imageHeight = height || undefined;
6741 const alt = image.getAttribute('alt');
6742 if (alt !== null) result.imageAlt = alt || undefined;
6743 }
6744 return result;
6745 };
6746
6747 /**
6748 * @param {DocumentFragment} templateContent
6749 * @returns {object}
6750 */
6751 const getSwalIcon = templateContent => {
6752 const result = {};
6753 /** @type {HTMLElement | null} */
6754 const icon = templateContent.querySelector('swal-icon');
6755 if (icon) {
6756 showWarningsForAttributes(icon, ['type', 'color']);
6757 if (icon.hasAttribute('type')) {
6758 result.icon = icon.getAttribute('type');
6759 }
6760 if (icon.hasAttribute('color')) {
6761 result.iconColor = icon.getAttribute('color');
6762 }
6763 result.iconHtml = icon.innerHTML;
6764 }
6765 return result;
6766 };
6767
6768 /**
6769 * @param {DocumentFragment} templateContent
6770 * @returns {object}
6771 */
6772 const getSwalInput = templateContent => {
6773 /** @type {Record<string, any>} */
6774 const result = {};
6775 /** @type {HTMLElement | null} */
6776 const input = templateContent.querySelector('swal-input');
6777 if (input) {
6778 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6779 result.input = input.getAttribute('type') || 'text';
6780 if (input.hasAttribute('label')) {
6781 result.inputLabel = input.getAttribute('label');
6782 }
6783 if (input.hasAttribute('placeholder')) {
6784 result.inputPlaceholder = input.getAttribute('placeholder');
6785 }
6786 if (input.hasAttribute('value')) {
6787 result.inputValue = input.getAttribute('value');
6788 }
6789 }
6790 /** @type {HTMLElement[]} */
6791 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6792 if (inputOptions.length) {
6793 result.inputOptions = {};
6794 inputOptions.forEach(option => {
6795 showWarningsForAttributes(option, ['value']);
6796 const optionValue = option.getAttribute('value');
6797 if (!optionValue) {
6798 return;
6799 }
6800 const optionName = option.innerHTML;
6801 result.inputOptions[optionValue] = optionName;
6802 });
6803 }
6804 return result;
6805 };
6806
6807 /**
6808 * @param {DocumentFragment} templateContent
6809 * @param {string[]} paramNames
6810 * @returns {Record<string, string>}
6811 */
6812 const getSwalStringParams = (templateContent, paramNames) => {
6813 /** @type {Record<string, string>} */
6814 const result = {};
6815 for (const i in paramNames) {
6816 const paramName = paramNames[i];
6817 /** @type {HTMLElement | null} */
6818 const tag = templateContent.querySelector(paramName);
6819 if (tag) {
6820 showWarningsForAttributes(tag, []);
6821 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6822 }
6823 }
6824 return result;
6825 };
6826
6827 /**
6828 * @param {DocumentFragment} templateContent
6829 */
6830 const showWarningsForElements = templateContent => {
6831 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6832 Array.from(templateContent.children).forEach(el => {
6833 const tagName = el.tagName.toLowerCase();
6834 if (!allowedElements.includes(tagName)) {
6835 warn(`Unrecognized element <${tagName}>`);
6836 }
6837 });
6838 };
6839
6840 /**
6841 * @param {HTMLElement} el
6842 * @param {string[]} allowedAttributes
6843 */
6844 const showWarningsForAttributes = (el, allowedAttributes) => {
6845 Array.from(el.attributes).forEach(attribute => {
6846 if (allowedAttributes.indexOf(attribute.name) === -1) {
6847 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.'}`]);
6848 }
6849 });
6850 };
6851
6852 const SHOW_CLASS_TIMEOUT = 10;
6853
6854 /**
6855 * Open popup, add necessary classes and styles, fix scrollbar
6856 *
6857 * @param {SweetAlertOptions} params
6858 */
6859 const openPopup = params => {
6860 var _globalState$eventEmi, _globalState$eventEmi2;
6861 const container = getContainer();
6862 const popup = getPopup();
6863 if (!container || !popup) {
6864 return;
6865 }
6866 if (typeof params.willOpen === 'function') {
6867 params.willOpen(popup);
6868 }
6869 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6870 const bodyStyles = window.getComputedStyle(document.body);
6871 const initialBodyOverflow = bodyStyles.overflowY;
6872 addClasses(container, popup, params);
6873
6874 // scrolling is 'hidden' until animation is done, after that 'auto'
6875 setTimeout(() => {
6876 setScrollingVisibility(container, popup);
6877 }, SHOW_CLASS_TIMEOUT);
6878 if (isModal()) {
6879 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6880 setAriaHidden();
6881 }
6882
6883 // https://github.com/sweetalert2/sweetalert2/issues/2923
6884 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
6885 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
6886 container.style.pointerEvents = 'auto';
6887 }
6888 if (!isToast() && !globalState.previousActiveElement) {
6889 globalState.previousActiveElement = document.activeElement;
6890 }
6891 if (typeof params.didOpen === 'function') {
6892 const didOpen = params.didOpen;
6893 setTimeout(() => didOpen(popup));
6894 }
6895 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6896 };
6897
6898 /**
6899 * @param {Event} event
6900 */
6901 const swalOpenAnimationFinished = event => {
6902 const popup = getPopup();
6903 if (!popup || event.target !== popup) {
6904 return;
6905 }
6906 const container = getContainer();
6907 if (!container) {
6908 return;
6909 }
6910 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6911 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6912 container.style.overflowY = 'auto';
6913
6914 // no-transition is added in init() in case one swal is opened right after another
6915 removeClass(container, swalClasses['no-transition']);
6916 };
6917
6918 /**
6919 * @param {HTMLElement} container
6920 * @param {HTMLElement} popup
6921 */
6922 const setScrollingVisibility = (container, popup) => {
6923 if (hasCssAnimation(popup)) {
6924 container.style.overflowY = 'hidden';
6925 popup.addEventListener('animationend', swalOpenAnimationFinished);
6926 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6927 } else {
6928 container.style.overflowY = 'auto';
6929 }
6930 };
6931
6932 /**
6933 * @param {HTMLElement} container
6934 * @param {boolean} scrollbarPadding
6935 * @param {string} initialBodyOverflow
6936 */
6937 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6938 iOSfix();
6939 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6940 replaceScrollbarWithPadding(initialBodyOverflow);
6941 }
6942
6943 // sweetalert2/issues/1247
6944 setTimeout(() => {
6945 container.scrollTop = 0;
6946 });
6947 };
6948
6949 /**
6950 * @param {HTMLElement} container
6951 * @param {HTMLElement} popup
6952 * @param {SweetAlertOptions} params
6953 */
6954 const addClasses = (container, popup, params) => {
6955 var _params$showClass;
6956 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6957 addClass(container, params.showClass.backdrop);
6958 }
6959 if (params.animation) {
6960 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6961 popup.style.setProperty('opacity', '0', 'important');
6962 show(popup, 'grid');
6963 setTimeout(() => {
6964 var _params$showClass2;
6965 // Animate popup right after showing it
6966 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6967 addClass(popup, params.showClass.popup);
6968 }
6969 // and remove the opacity workaround
6970 popup.style.removeProperty('opacity');
6971 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6972 } else {
6973 show(popup, 'grid');
6974 }
6975 addClass([document.documentElement, document.body], swalClasses.shown);
6976 if (params.heightAuto && params.backdrop && !params.toast) {
6977 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6978 }
6979 };
6980
6981 var defaultInputValidators = {
6982 /**
6983 * @param {string} string
6984 * @param {string} [validationMessage]
6985 * @returns {Promise<string | void>}
6986 */
6987 email: (string, validationMessage) => {
6988 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6989 },
6990 /**
6991 * @param {string} string
6992 * @param {string} [validationMessage]
6993 * @returns {Promise<string | void>}
6994 */
6995 url: (string, validationMessage) => {
6996 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6997 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');
6998 }
6999 };
7000
7001 /**
7002 * @param {SweetAlertOptions} params
7003 */
7004 function setDefaultInputValidators(params) {
7005 // Use default `inputValidator` for supported input types if not provided
7006 if (params.inputValidator) {
7007 return;
7008 }
7009 if (params.input === 'email') {
7010 params.inputValidator = defaultInputValidators['email'];
7011 }
7012 if (params.input === 'url') {
7013 params.inputValidator = defaultInputValidators['url'];
7014 }
7015 }
7016
7017 /**
7018 * @param {SweetAlertOptions} params
7019 */
7020 function validateCustomTargetElement(params) {
7021 // Determine if the custom target element is valid
7022 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
7023 warn('Target parameter is not valid, defaulting to "body"');
7024 params.target = 'body';
7025 }
7026 }
7027
7028 /**
7029 * Set type, text and actions on popup
7030 *
7031 * @param {SweetAlertOptions} params
7032 */
7033 function setParameters(params) {
7034 setDefaultInputValidators(params);
7035
7036 // showLoaderOnConfirm && preConfirm
7037 if (params.showLoaderOnConfirm && !params.preConfirm) {
7038 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');
7039 }
7040 validateCustomTargetElement(params);
7041
7042 // Replace newlines with <br> in title
7043 if (typeof params.title === 'string') {
7044 params.title = params.title.split('\n').join('<br />');
7045 }
7046 init(params);
7047 }
7048
7049 /** @type {SweetAlert} */
7050 let currentInstance;
7051 var _promise = /*#__PURE__*/new WeakMap();
7052 class SweetAlert {
7053 /**
7054 * @param {...(SweetAlertOptions | string)} args
7055 * @this {SweetAlert}
7056 */
7057 constructor(...args) {
7058 /**
7059 * @type {Promise<SweetAlertResult>}
7060 */
7061 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
7062 Promise.resolve({
7063 isConfirmed: false,
7064 isDenied: false,
7065 isDismissed: true
7066 }));
7067 // Prevent run in Node env
7068 if (typeof window === 'undefined') {
7069 return;
7070 }
7071 currentInstance = this;
7072
7073 // @ts-ignore
7074 const outerParams = Object.freeze(this.constructor.argsToParams(args));
7075
7076 /** @type {Readonly<SweetAlertOptions>} */
7077 this.params = outerParams;
7078
7079 /** @type {boolean} */
7080 this.isAwaitingPromise = false;
7081 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
7082 }
7083
7084 /**
7085 * @param {any} userParams
7086 * @param {any} mixinParams
7087 */
7088 _main(userParams, mixinParams = {}) {
7089 showWarningsForParams(Object.assign({}, mixinParams, userParams));
7090 if (globalState.currentInstance) {
7091 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
7092 const {
7093 isAwaitingPromise
7094 } = globalState.currentInstance;
7095 globalState.currentInstance._destroy();
7096 if (!isAwaitingPromise) {
7097 swalPromiseResolve({
7098 isDismissed: true
7099 });
7100 }
7101 if (isModal()) {
7102 unsetAriaHidden();
7103 }
7104 }
7105 globalState.currentInstance = currentInstance;
7106 const innerParams = prepareParams(userParams, mixinParams);
7107 setParameters(innerParams);
7108 Object.freeze(innerParams);
7109
7110 // clear the previous timer
7111 if (globalState.timeout) {
7112 globalState.timeout.stop();
7113 delete globalState.timeout;
7114 }
7115
7116 // clear the restore focus timeout
7117 clearTimeout(globalState.restoreFocusTimeout);
7118 const domCache = populateDomCache(currentInstance);
7119 render(currentInstance, innerParams);
7120 privateProps.innerParams.set(currentInstance, innerParams);
7121 return swalPromise(currentInstance, domCache, innerParams);
7122 }
7123
7124 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
7125 /**
7126 * @param {any} onFulfilled
7127 */
7128 // oxlint-disable-next-line unicorn/no-thenable
7129 then(onFulfilled) {
7130 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
7131 }
7132
7133 /**
7134 * @param {any} onFinally
7135 */
7136 finally(onFinally) {
7137 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
7138 }
7139 }
7140
7141 /**
7142 * @param {SweetAlert} instance
7143 * @param {DomCache} domCache
7144 * @param {SweetAlertOptions} innerParams
7145 * @returns {Promise<SweetAlertResult>}
7146 */
7147 const swalPromise = (instance, domCache, innerParams) => {
7148 return new Promise((resolve, reject) => {
7149 // functions to handle all closings/dismissals
7150 /**
7151 * @param {DismissReason} dismiss
7152 */
7153 const dismissWith = dismiss => {
7154 instance.close({
7155 isDismissed: true,
7156 dismiss,
7157 isConfirmed: false,
7158 isDenied: false
7159 });
7160 };
7161 privateMethods.swalPromiseResolve.set(instance, resolve);
7162 privateMethods.swalPromiseReject.set(instance, reject);
7163 domCache.confirmButton.onclick = () => {
7164 handleConfirmButtonClick(instance);
7165 };
7166 domCache.denyButton.onclick = () => {
7167 handleDenyButtonClick(instance);
7168 };
7169 domCache.cancelButton.onclick = () => {
7170 handleCancelButtonClick(instance, dismissWith);
7171 };
7172 domCache.closeButton.onclick = () => {
7173 dismissWith(DismissReason.close);
7174 };
7175 handlePopupClick(innerParams, domCache, dismissWith);
7176 addKeydownHandler(globalState, innerParams, dismissWith);
7177 handleInputOptionsAndValue(instance, innerParams);
7178 openPopup(innerParams);
7179 setupTimer(globalState, innerParams, dismissWith);
7180 initFocus(domCache, innerParams);
7181
7182 // Scroll container to top on open (#1247, #1946)
7183 setTimeout(() => {
7184 domCache.container.scrollTop = 0;
7185 });
7186 });
7187 };
7188
7189 /**
7190 * @param {SweetAlertOptions} userParams
7191 * @param {SweetAlertOptions} mixinParams
7192 * @returns {SweetAlertOptions}
7193 */
7194 const prepareParams = (userParams, mixinParams) => {
7195 const templateParams = getTemplateParams(userParams);
7196 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
7197 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
7198 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
7199 if (params.animation === false) {
7200 params.showClass = {
7201 backdrop: 'swal2-noanimation'
7202 };
7203 params.hideClass = {};
7204 }
7205 return params;
7206 };
7207
7208 /**
7209 * @param {SweetAlert} instance
7210 * @returns {DomCache}
7211 */
7212 const populateDomCache = instance => {
7213 const domCache = /** @type {DomCache} */{
7214 popup: (/** @type {HTMLElement} */getPopup()),
7215 container: (/** @type {HTMLElement} */getContainer()),
7216 actions: (/** @type {HTMLElement} */getActions()),
7217 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
7218 denyButton: (/** @type {HTMLElement} */getDenyButton()),
7219 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
7220 loader: (/** @type {HTMLElement} */getLoader()),
7221 closeButton: (/** @type {HTMLElement} */getCloseButton()),
7222 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
7223 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
7224 };
7225 privateProps.domCache.set(instance, domCache);
7226 return domCache;
7227 };
7228
7229 /**
7230 * @param {GlobalState} globalState
7231 * @param {SweetAlertOptions} innerParams
7232 * @param {(dismiss: DismissReason) => void} dismissWith
7233 */
7234 const setupTimer = (globalState, innerParams, dismissWith) => {
7235 const timerProgressBar = getTimerProgressBar();
7236 hide(timerProgressBar);
7237 if (innerParams.timer) {
7238 globalState.timeout = new Timer(() => {
7239 dismissWith('timer');
7240 delete globalState.timeout;
7241 }, innerParams.timer);
7242 if (innerParams.timerProgressBar && timerProgressBar) {
7243 show(timerProgressBar);
7244 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
7245 setTimeout(() => {
7246 if (globalState.timeout && globalState.timeout.running) {
7247 // timer can be already stopped or unset at this point
7248 animateTimerProgressBar(/** @type {number} */innerParams.timer);
7249 }
7250 });
7251 }
7252 }
7253 };
7254
7255 /**
7256 * Initialize focus in the popup:
7257 *
7258 * 1. If `toast` is `true`, don't steal focus from the document.
7259 * 2. Else if there is an [autofocus] element, focus it.
7260 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
7261 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
7262 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
7263 * 6. Else focus the first focusable element in a popup (if any).
7264 *
7265 * @param {DomCache} domCache
7266 * @param {SweetAlertOptions} innerParams
7267 */
7268 const initFocus = (domCache, innerParams) => {
7269 if (innerParams.toast) {
7270 return;
7271 }
7272 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
7273 if (!callIfFunction(innerParams.allowEnterKey)) {
7274 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
7275 domCache.popup.focus();
7276 return;
7277 }
7278 if (focusAutofocus(domCache)) {
7279 return;
7280 }
7281 if (focusButton(domCache, innerParams)) {
7282 return;
7283 }
7284 setFocus(-1, 1);
7285 };
7286
7287 /**
7288 * @param {DomCache} domCache
7289 * @returns {boolean}
7290 */
7291 const focusAutofocus = domCache => {
7292 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
7293 for (const autofocusElement of autofocusElements) {
7294 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
7295 autofocusElement.focus();
7296 return true;
7297 }
7298 }
7299 return false;
7300 };
7301
7302 /**
7303 * @param {DomCache} domCache
7304 * @param {SweetAlertOptions} innerParams
7305 * @returns {boolean}
7306 */
7307 const focusButton = (domCache, innerParams) => {
7308 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
7309 domCache.denyButton.focus();
7310 return true;
7311 }
7312 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
7313 domCache.cancelButton.focus();
7314 return true;
7315 }
7316 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
7317 domCache.confirmButton.focus();
7318 return true;
7319 }
7320 return false;
7321 };
7322
7323 // Assign instance methods from src/instanceMethods/*.js to prototype
7324 SweetAlert.prototype.disableButtons = disableButtons;
7325 SweetAlert.prototype.enableButtons = enableButtons;
7326 SweetAlert.prototype.getInput = getInput;
7327 SweetAlert.prototype.disableInput = disableInput;
7328 SweetAlert.prototype.enableInput = enableInput;
7329 SweetAlert.prototype.hideLoading = hideLoading;
7330 SweetAlert.prototype.disableLoading = hideLoading;
7331 SweetAlert.prototype.showValidationMessage = showValidationMessage;
7332 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
7333 SweetAlert.prototype.close = close;
7334 SweetAlert.prototype.closePopup = close;
7335 SweetAlert.prototype.closeModal = close;
7336 SweetAlert.prototype.closeToast = close;
7337 SweetAlert.prototype.rejectPromise = rejectPromise;
7338 SweetAlert.prototype.update = update;
7339 SweetAlert.prototype._destroy = _destroy;
7340
7341 // Assign static methods from src/staticMethods/*.js to constructor
7342 Object.assign(SweetAlert, staticMethods);
7343
7344 // Proxy to instance methods to constructor, for now, for backwards compatibility
7345 Object.keys(instanceMethods).forEach(key => {
7346 /**
7347 * @param {...(SweetAlertOptions | string | undefined)} args
7348 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
7349 */
7350 // @ts-ignore: Dynamic property assignment for backwards compatibility
7351 SweetAlert[key] = function (...args) {
7352 // @ts-ignore
7353 if (currentInstance && currentInstance[key]) {
7354 // @ts-ignore
7355 return currentInstance[key](...args);
7356 }
7357 return undefined;
7358 };
7359 });
7360 SweetAlert.DismissReason = DismissReason;
7361 SweetAlert.version = '11.26.25';
7362
7363 const Swal = SweetAlert;
7364 // @ts-ignore
7365 Swal.default = Swal;
7366
7367 return Swal;
7368
7369 }));
7370 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
7371 "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-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:auto}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}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)}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}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}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}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)}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:auto}.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}.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}}");
7372
7373 /***/ },
7374
7375 /***/ "./node_modules/toastify-js/src/toastify.js"
7376 /*!**************************************************!*\
7377 !*** ./node_modules/toastify-js/src/toastify.js ***!
7378 \**************************************************/
7379 (module) {
7380
7381 /*!
7382 * Toastify js 1.12.0
7383 * https://github.com/apvarun/toastify-js
7384 * @license MIT licensed
7385 *
7386 * Copyright (C) 2018 Varun A P
7387 */
7388 (function(root, factory) {
7389 if ( true && module.exports) {
7390 module.exports = factory();
7391 } else {
7392 root.Toastify = factory();
7393 }
7394 })(this, function(global) {
7395 // Object initialization
7396 var Toastify = function(options) {
7397 // Returning a new init object
7398 return new Toastify.lib.init(options);
7399 },
7400 // Library version
7401 version = "1.12.0";
7402
7403 // Set the default global options
7404 Toastify.defaults = {
7405 oldestFirst: true,
7406 text: "Toastify is awesome!",
7407 node: undefined,
7408 duration: 3000,
7409 selector: undefined,
7410 callback: function () {
7411 },
7412 destination: undefined,
7413 newWindow: false,
7414 close: false,
7415 gravity: "toastify-top",
7416 positionLeft: false,
7417 position: '',
7418 backgroundColor: '',
7419 avatar: "",
7420 className: "",
7421 stopOnFocus: true,
7422 onClick: function () {
7423 },
7424 offset: {x: 0, y: 0},
7425 escapeMarkup: true,
7426 ariaLive: 'polite',
7427 style: {background: ''}
7428 };
7429
7430 // Defining the prototype of the object
7431 Toastify.lib = Toastify.prototype = {
7432 toastify: version,
7433
7434 constructor: Toastify,
7435
7436 // Initializing the object with required parameters
7437 init: function(options) {
7438 // Verifying and validating the input object
7439 if (!options) {
7440 options = {};
7441 }
7442
7443 // Creating the options object
7444 this.options = {};
7445
7446 this.toastElement = null;
7447
7448 // Validating the options
7449 this.options.text = options.text || Toastify.defaults.text; // Display message
7450 this.options.node = options.node || Toastify.defaults.node; // Display content as node
7451 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
7452 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
7453 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
7454 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
7455 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
7456 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
7457 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
7458 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
7459 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
7460 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
7461 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
7462 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
7463 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
7464 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
7465 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
7466 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
7467 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
7468 this.options.style = options.style || Toastify.defaults.style;
7469 if(options.backgroundColor) {
7470 this.options.style.background = options.backgroundColor;
7471 }
7472
7473 // Returning the current object for chaining functions
7474 return this;
7475 },
7476
7477 // Building the DOM element
7478 buildToast: function() {
7479 // Validating if the options are defined
7480 if (!this.options) {
7481 throw "Toastify is not initialized";
7482 }
7483
7484 // Creating the DOM object
7485 var divElement = document.createElement("div");
7486 divElement.className = "toastify on " + this.options.className;
7487
7488 // Positioning toast to left or right or center
7489 if (!!this.options.position) {
7490 divElement.className += " toastify-" + this.options.position;
7491 } else {
7492 // To be depreciated in further versions
7493 if (this.options.positionLeft === true) {
7494 divElement.className += " toastify-left";
7495 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
7496 } else {
7497 // Default position
7498 divElement.className += " toastify-right";
7499 }
7500 }
7501
7502 // Assigning gravity of element
7503 divElement.className += " " + this.options.gravity;
7504
7505 if (this.options.backgroundColor) {
7506 // This is being deprecated in favor of using the style HTML DOM property
7507 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
7508 }
7509
7510 // Loop through our style object and apply styles to divElement
7511 for (var property in this.options.style) {
7512 divElement.style[property] = this.options.style[property];
7513 }
7514
7515 // Announce the toast to screen readers
7516 if (this.options.ariaLive) {
7517 divElement.setAttribute('aria-live', this.options.ariaLive)
7518 }
7519
7520 // Adding the toast message/node
7521 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
7522 // If we have a valid node, we insert it
7523 divElement.appendChild(this.options.node)
7524 } else {
7525 if (this.options.escapeMarkup) {
7526 divElement.innerText = this.options.text;
7527 } else {
7528 divElement.innerHTML = this.options.text;
7529 }
7530
7531 if (this.options.avatar !== "") {
7532 var avatarElement = document.createElement("img");
7533 avatarElement.src = this.options.avatar;
7534
7535 avatarElement.className = "toastify-avatar";
7536
7537 if (this.options.position == "left" || this.options.positionLeft === true) {
7538 // Adding close icon on the left of content
7539 divElement.appendChild(avatarElement);
7540 } else {
7541 // Adding close icon on the right of content
7542 divElement.insertAdjacentElement("afterbegin", avatarElement);
7543 }
7544 }
7545 }
7546
7547 // Adding a close icon to the toast
7548 if (this.options.close === true) {
7549 // Create a span for close element
7550 var closeElement = document.createElement("button");
7551 closeElement.type = "button";
7552 closeElement.setAttribute("aria-label", "Close");
7553 closeElement.className = "toast-close";
7554 closeElement.innerHTML = "&#10006;";
7555
7556 // Triggering the removal of toast from DOM on close click
7557 closeElement.addEventListener(
7558 "click",
7559 function(event) {
7560 event.stopPropagation();
7561 this.removeElement(this.toastElement);
7562 window.clearTimeout(this.toastElement.timeOutValue);
7563 }.bind(this)
7564 );
7565
7566 //Calculating screen width
7567 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7568
7569 // Adding the close icon to the toast element
7570 // Display on the right if screen width is less than or equal to 360px
7571 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7572 // Adding close icon on the left of content
7573 divElement.insertAdjacentElement("afterbegin", closeElement);
7574 } else {
7575 // Adding close icon on the right of content
7576 divElement.appendChild(closeElement);
7577 }
7578 }
7579
7580 // Clear timeout while toast is focused
7581 if (this.options.stopOnFocus && this.options.duration > 0) {
7582 var self = this;
7583 // stop countdown
7584 divElement.addEventListener(
7585 "mouseover",
7586 function(event) {
7587 window.clearTimeout(divElement.timeOutValue);
7588 }
7589 )
7590 // add back the timeout
7591 divElement.addEventListener(
7592 "mouseleave",
7593 function() {
7594 divElement.timeOutValue = window.setTimeout(
7595 function() {
7596 // Remove the toast from DOM
7597 self.removeElement(divElement);
7598 },
7599 self.options.duration
7600 )
7601 }
7602 )
7603 }
7604
7605 // Adding an on-click destination path
7606 if (typeof this.options.destination !== "undefined") {
7607 divElement.addEventListener(
7608 "click",
7609 function(event) {
7610 event.stopPropagation();
7611 if (this.options.newWindow === true) {
7612 window.open(this.options.destination, "_blank");
7613 } else {
7614 window.location = this.options.destination;
7615 }
7616 }.bind(this)
7617 );
7618 }
7619
7620 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7621 divElement.addEventListener(
7622 "click",
7623 function(event) {
7624 event.stopPropagation();
7625 this.options.onClick();
7626 }.bind(this)
7627 );
7628 }
7629
7630 // Adding offset
7631 if(typeof this.options.offset === "object") {
7632
7633 var x = getAxisOffsetAValue("x", this.options);
7634 var y = getAxisOffsetAValue("y", this.options);
7635
7636 var xOffset = this.options.position == "left" ? x : "-" + x;
7637 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7638
7639 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7640
7641 }
7642
7643 // Returning the generated element
7644 return divElement;
7645 },
7646
7647 // Displaying the toast
7648 showToast: function() {
7649 // Creating the DOM object for the toast
7650 this.toastElement = this.buildToast();
7651
7652 // Getting the root element to with the toast needs to be added
7653 var rootElement;
7654 if (typeof this.options.selector === "string") {
7655 rootElement = document.getElementById(this.options.selector);
7656 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7657 rootElement = this.options.selector;
7658 } else {
7659 rootElement = document.body;
7660 }
7661
7662 // Validating if root element is present in DOM
7663 if (!rootElement) {
7664 throw "Root element is not defined";
7665 }
7666
7667 // Adding the DOM element
7668 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7669 rootElement.insertBefore(this.toastElement, elementToInsert);
7670
7671 // Repositioning the toasts in case multiple toasts are present
7672 Toastify.reposition();
7673
7674 if (this.options.duration > 0) {
7675 this.toastElement.timeOutValue = window.setTimeout(
7676 function() {
7677 // Remove the toast from DOM
7678 this.removeElement(this.toastElement);
7679 }.bind(this),
7680 this.options.duration
7681 ); // Binding `this` for function invocation
7682 }
7683
7684 // Supporting function chaining
7685 return this;
7686 },
7687
7688 hideToast: function() {
7689 if (this.toastElement.timeOutValue) {
7690 clearTimeout(this.toastElement.timeOutValue);
7691 }
7692 this.removeElement(this.toastElement);
7693 },
7694
7695 // Removing the element from the DOM
7696 removeElement: function(toastElement) {
7697 // Hiding the element
7698 // toastElement.classList.remove("on");
7699 toastElement.className = toastElement.className.replace(" on", "");
7700
7701 // Removing the element from DOM after transition end
7702 window.setTimeout(
7703 function() {
7704 // remove options node if any
7705 if (this.options.node && this.options.node.parentNode) {
7706 this.options.node.parentNode.removeChild(this.options.node);
7707 }
7708
7709 // Remove the element from the DOM, only when the parent node was not removed before.
7710 if (toastElement.parentNode) {
7711 toastElement.parentNode.removeChild(toastElement);
7712 }
7713
7714 // Calling the callback function
7715 this.options.callback.call(toastElement);
7716
7717 // Repositioning the toasts again
7718 Toastify.reposition();
7719 }.bind(this),
7720 400
7721 ); // Binding `this` for function invocation
7722 },
7723 };
7724
7725 // Positioning the toasts on the DOM
7726 Toastify.reposition = function() {
7727
7728 // Top margins with gravity
7729 var topLeftOffsetSize = {
7730 top: 15,
7731 bottom: 15,
7732 };
7733 var topRightOffsetSize = {
7734 top: 15,
7735 bottom: 15,
7736 };
7737 var offsetSize = {
7738 top: 15,
7739 bottom: 15,
7740 };
7741
7742 // Get all toast messages on the DOM
7743 var allToasts = document.getElementsByClassName("toastify");
7744
7745 var classUsed;
7746
7747 // Modifying the position of each toast element
7748 for (var i = 0; i < allToasts.length; i++) {
7749 // Getting the applied gravity
7750 if (containsClass(allToasts[i], "toastify-top") === true) {
7751 classUsed = "toastify-top";
7752 } else {
7753 classUsed = "toastify-bottom";
7754 }
7755
7756 var height = allToasts[i].offsetHeight;
7757 classUsed = classUsed.substr(9, classUsed.length-1)
7758 // Spacing between toasts
7759 var offset = 15;
7760
7761 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7762
7763 // Show toast in center if screen with less than or equal to 360px
7764 if (width <= 360) {
7765 // Setting the position
7766 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7767
7768 offsetSize[classUsed] += height + offset;
7769 } else {
7770 if (containsClass(allToasts[i], "toastify-left") === true) {
7771 // Setting the position
7772 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7773
7774 topLeftOffsetSize[classUsed] += height + offset;
7775 } else {
7776 // Setting the position
7777 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7778
7779 topRightOffsetSize[classUsed] += height + offset;
7780 }
7781 }
7782 }
7783
7784 // Supporting function chaining
7785 return this;
7786 };
7787
7788 // Helper function to get offset.
7789 function getAxisOffsetAValue(axis, options) {
7790
7791 if(options.offset[axis]) {
7792 if(isNaN(options.offset[axis])) {
7793 return options.offset[axis];
7794 }
7795 else {
7796 return options.offset[axis] + 'px';
7797 }
7798 }
7799
7800 return '0px';
7801
7802 }
7803
7804 function containsClass(elem, yourClass) {
7805 if (!elem || typeof yourClass !== "string") {
7806 return false;
7807 } else if (
7808 elem.className &&
7809 elem.className
7810 .trim()
7811 .split(/\s+/gi)
7812 .indexOf(yourClass) > -1
7813 ) {
7814 return true;
7815 } else {
7816 return false;
7817 }
7818 }
7819
7820 // Setting up the prototype for the init object
7821 Toastify.lib.init.prototype = Toastify.lib;
7822
7823 // Returning the Toastify function to be assigned to the window object/module
7824 return Toastify;
7825 });
7826
7827
7828 /***/ },
7829
7830 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7831 /*!**********************************************************!*\
7832 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7833 \**********************************************************/
7834 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7835
7836 "use strict";
7837 __webpack_require__.r(__webpack_exports__);
7838 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7839 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7840 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7841 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7842 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7843 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7844 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7845 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7846 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7847 /* harmony export */ });
7848 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7849 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7850 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7851 /**
7852 * sifter.js
7853 * Copyright (c) 2013–2020 Brian Reavis & contributors
7854 *
7855 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7856 * file except in compliance with the License. You may obtain a copy of the License at:
7857 * http://www.apache.org/licenses/LICENSE-2.0
7858 *
7859 * Unless required by applicable law or agreed to in writing, software distributed under
7860 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7861 * ANY KIND, either express or implied. See the License for the specific language
7862 * governing permissions and limitations under the License.
7863 *
7864 * @author Brian Reavis <brian@thirdroute.com>
7865 */
7866
7867
7868 class Sifter {
7869 items; // []|{};
7870 settings;
7871 /**
7872 * Textually searches arrays and hashes of objects
7873 * by property (or multiple properties). Designed
7874 * specifically for autocomplete.
7875 *
7876 */
7877 constructor(items, settings) {
7878 this.items = items;
7879 this.settings = settings || { diacritics: true };
7880 }
7881 ;
7882 /**
7883 * Splits a search string into an array of individual
7884 * regexps to be used to match results.
7885 *
7886 */
7887 tokenize(query, respect_word_boundaries, weights) {
7888 if (!query || !query.length)
7889 return [];
7890 const tokens = [];
7891 const words = query.split(/\s+/);
7892 var field_regex;
7893 if (weights) {
7894 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7895 }
7896 words.forEach((word) => {
7897 let field_match;
7898 let field = null;
7899 let regex = null;
7900 // look for "field:query" tokens
7901 if (field_regex && (field_match = word.match(field_regex))) {
7902 field = field_match[1];
7903 word = field_match[2];
7904 }
7905 if (word.length > 0) {
7906 if (this.settings.diacritics) {
7907 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7908 }
7909 else {
7910 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7911 }
7912 if (regex && respect_word_boundaries)
7913 regex = "\\b" + regex;
7914 }
7915 tokens.push({
7916 string: word,
7917 regex: regex ? new RegExp(regex, 'iu') : null,
7918 field: field,
7919 });
7920 });
7921 return tokens;
7922 }
7923 ;
7924 /**
7925 * Returns a function to be used to score individual results.
7926 *
7927 * Good matches will have a higher score than poor matches.
7928 * If an item is not a match, 0 will be returned by the function.
7929 *
7930 * @returns {T.ScoreFn}
7931 */
7932 getScoreFunction(query, options) {
7933 var search = this.prepareSearch(query, options);
7934 return this._getScoreFunction(search);
7935 }
7936 /**
7937 * @returns {T.ScoreFn}
7938 *
7939 */
7940 _getScoreFunction(search) {
7941 const tokens = search.tokens, token_count = tokens.length;
7942 if (!token_count) {
7943 return function () { return 0; };
7944 }
7945 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7946 if (!field_count) {
7947 return function () { return 1; };
7948 }
7949 /**
7950 * Calculates the score of an object
7951 * against the search query.
7952 *
7953 */
7954 const scoreObject = (function () {
7955 if (field_count === 1) {
7956 return function (token, data) {
7957 const field = fields[0].field;
7958 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7959 };
7960 }
7961 return function (token, data) {
7962 var sum = 0;
7963 // is the token specific to a field?
7964 if (token.field) {
7965 const value = getAttrFn(data, token.field);
7966 if (!token.regex && value) {
7967 sum += (1 / field_count);
7968 }
7969 else {
7970 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7971 }
7972 }
7973 else {
7974 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7975 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7976 });
7977 }
7978 return sum / field_count;
7979 };
7980 })();
7981 if (token_count === 1) {
7982 return function (data) {
7983 return scoreObject(tokens[0], data);
7984 };
7985 }
7986 if (search.options.conjunction === 'and') {
7987 return function (data) {
7988 var score, sum = 0;
7989 for (let token of tokens) {
7990 score = scoreObject(token, data);
7991 if (score <= 0)
7992 return 0;
7993 sum += score;
7994 }
7995 return sum / token_count;
7996 };
7997 }
7998 else {
7999 return function (data) {
8000 var sum = 0;
8001 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
8002 sum += scoreObject(token, data);
8003 });
8004 return sum / token_count;
8005 };
8006 }
8007 }
8008 ;
8009 /**
8010 * Returns a function that can be used to compare two
8011 * results, for sorting purposes. If no sorting should
8012 * be performed, `null` will be returned.
8013 *
8014 * @return function(a,b)
8015 */
8016 getSortFunction(query, options) {
8017 var search = this.prepareSearch(query, options);
8018 return this._getSortFunction(search);
8019 }
8020 _getSortFunction(search) {
8021 var implicit_score, sort_flds = [];
8022 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
8023 if (typeof sort == 'function') {
8024 return sort.bind(this);
8025 }
8026 /**
8027 * Fetches the specified sort field value
8028 * from a search result item.
8029 *
8030 */
8031 const get_field = function (name, result) {
8032 if (name === '$score')
8033 return result.score;
8034 return search.getAttrFn(self.items[result.id], name);
8035 };
8036 // parse options
8037 if (sort) {
8038 for (let s of sort) {
8039 if (search.query || s.field !== '$score') {
8040 sort_flds.push(s);
8041 }
8042 }
8043 }
8044 // the "$score" field is implied to be the primary
8045 // sort field, unless it's manually specified
8046 if (search.query) {
8047 implicit_score = true;
8048 for (let fld of sort_flds) {
8049 if (fld.field === '$score') {
8050 implicit_score = false;
8051 break;
8052 }
8053 }
8054 if (implicit_score) {
8055 sort_flds.unshift({ field: '$score', direction: 'desc' });
8056 }
8057 // without a search.query, all items will have the same score
8058 }
8059 else {
8060 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
8061 }
8062 // build function
8063 const sort_flds_count = sort_flds.length;
8064 if (!sort_flds_count) {
8065 return null;
8066 }
8067 return function (a, b) {
8068 var result, field;
8069 for (let sort_fld of sort_flds) {
8070 field = sort_fld.field;
8071 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
8072 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
8073 if (result)
8074 return result;
8075 }
8076 return 0;
8077 };
8078 }
8079 ;
8080 /**
8081 * Parses a search query and returns an object
8082 * with tokens and fields ready to be populated
8083 * with results.
8084 *
8085 */
8086 prepareSearch(query, optsUser) {
8087 const weights = {};
8088 var options = Object.assign({}, optsUser);
8089 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
8090 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
8091 // convert fields to new format
8092 if (options.fields) {
8093 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
8094 const fields = [];
8095 options.fields.forEach((field) => {
8096 if (typeof field == 'string') {
8097 field = { field: field, weight: 1 };
8098 }
8099 fields.push(field);
8100 weights[field.field] = ('weight' in field) ? field.weight : 1;
8101 });
8102 options.fields = fields;
8103 }
8104 return {
8105 options: options,
8106 query: query.toLowerCase().trim(),
8107 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
8108 total: 0,
8109 items: [],
8110 weights: weights,
8111 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
8112 };
8113 }
8114 ;
8115 /**
8116 * Searches through all items and returns a sorted array of matches.
8117 *
8118 */
8119 search(query, options) {
8120 var self = this, score, search;
8121 search = this.prepareSearch(query, options);
8122 options = search.options;
8123 query = search.query;
8124 // generate result scoring function
8125 const fn_score = options.score || self._getScoreFunction(search);
8126 // perform search and sort
8127 if (query.length) {
8128 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
8129 score = fn_score(item);
8130 if (options.filter === false || score > 0) {
8131 search.items.push({ 'score': score, 'id': id });
8132 }
8133 });
8134 }
8135 else {
8136 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
8137 search.items.push({ 'score': 1, 'id': id });
8138 });
8139 }
8140 const fn_sort = self._getSortFunction(search);
8141 if (fn_sort)
8142 search.items.sort(fn_sort);
8143 // apply limits
8144 search.total = search.items.length;
8145 if (typeof options.limit === 'number') {
8146 search.items = search.items.slice(0, options.limit);
8147 }
8148 return search;
8149 }
8150 ;
8151 }
8152
8153
8154 //# sourceMappingURL=sifter.js.map
8155
8156 /***/ },
8157
8158 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
8159 /*!*********************************************************!*\
8160 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
8161 \*********************************************************/
8162 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8163
8164 "use strict";
8165 __webpack_require__.r(__webpack_exports__);
8166
8167 //# sourceMappingURL=types.js.map
8168
8169 /***/ },
8170
8171 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
8172 /*!*********************************************************!*\
8173 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
8174 \*********************************************************/
8175 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8176
8177 "use strict";
8178 __webpack_require__.r(__webpack_exports__);
8179 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8180 /* harmony export */ cmp: () => (/* binding */ cmp),
8181 /* harmony export */ getAttr: () => (/* binding */ getAttr),
8182 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
8183 /* harmony export */ iterate: () => (/* binding */ iterate),
8184 /* harmony export */ propToArray: () => (/* binding */ propToArray),
8185 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
8186 /* harmony export */ });
8187 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
8188
8189 /**
8190 * A property getter resolving dot-notation
8191 * @param {Object} obj The root object to fetch property on
8192 * @param {String} name The optionally dotted property name to fetch
8193 * @return {Object} The resolved property value
8194 */
8195 const getAttr = (obj, name) => {
8196 if (!obj)
8197 return;
8198 return obj[name];
8199 };
8200 /**
8201 * A property getter resolving dot-notation
8202 * @param {Object} obj The root object to fetch property on
8203 * @param {String} name The optionally dotted property name to fetch
8204 * @return {Object} The resolved property value
8205 */
8206 const getAttrNesting = (obj, name) => {
8207 if (!obj)
8208 return;
8209 var part, names = name.split(".");
8210 while ((part = names.shift()) && (obj = obj[part]))
8211 ;
8212 return obj;
8213 };
8214 /**
8215 * Calculates how close of a match the
8216 * given value is against a search token.
8217 *
8218 */
8219 const scoreValue = (value, token, weight) => {
8220 var score, pos;
8221 if (!value)
8222 return 0;
8223 value = value + '';
8224 if (token.regex == null)
8225 return 0;
8226 pos = value.search(token.regex);
8227 if (pos === -1)
8228 return 0;
8229 score = token.string.length / value.length;
8230 if (pos === 0)
8231 score += 0.5;
8232 return score * weight;
8233 };
8234 /**
8235 * Cast object property to an array if it exists and has a value
8236 *
8237 */
8238 const propToArray = (obj, key) => {
8239 var value = obj[key];
8240 if (typeof value == 'function')
8241 return value;
8242 if (value && !Array.isArray(value)) {
8243 obj[key] = [value];
8244 }
8245 };
8246 /**
8247 * Iterates over arrays and hashes.
8248 *
8249 * ```
8250 * iterate(this.items, function(item, id) {
8251 * // invoked for each item
8252 * });
8253 * ```
8254 *
8255 */
8256 const iterate = (object, callback) => {
8257 if (Array.isArray(object)) {
8258 object.forEach(callback);
8259 }
8260 else {
8261 for (var key in object) {
8262 if (object.hasOwnProperty(key)) {
8263 callback(object[key], key);
8264 }
8265 }
8266 }
8267 };
8268 const cmp = (a, b) => {
8269 if (typeof a === 'number' && typeof b === 'number') {
8270 return a > b ? 1 : (a < b ? -1 : 0);
8271 }
8272 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
8273 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
8274 if (a > b)
8275 return 1;
8276 if (b > a)
8277 return -1;
8278 return 0;
8279 };
8280 //# sourceMappingURL=utils.js.map
8281
8282 /***/ },
8283
8284 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
8285 /*!*******************************************************************!*\
8286 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
8287 \*******************************************************************/
8288 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8289
8290 "use strict";
8291 __webpack_require__.r(__webpack_exports__);
8292 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8293 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
8294 /* harmony export */ asciifold: () => (/* binding */ asciifold),
8295 /* harmony export */ code_points: () => (/* binding */ code_points),
8296 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
8297 /* harmony export */ generateMap: () => (/* binding */ generateMap),
8298 /* harmony export */ generateSets: () => (/* binding */ generateSets),
8299 /* harmony export */ generator: () => (/* binding */ generator),
8300 /* harmony export */ getPattern: () => (/* binding */ getPattern),
8301 /* harmony export */ initialize: () => (/* binding */ initialize),
8302 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
8303 /* harmony export */ normalize: () => (/* binding */ normalize),
8304 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
8305 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
8306 /* harmony export */ });
8307 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
8308 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
8309
8310
8311 const code_points = [[0, 65535]];
8312 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
8313 let unicode_map;
8314 let multi_char_reg;
8315 const max_char_length = 3;
8316 const latin_convert = {};
8317 const latin_condensed = {
8318 '/': '⁄∕',
8319 '0': '߀',
8320 "a": "ⱥɐɑ",
8321 "aa": "ꜳ",
8322 "ae": "æǽǣ",
8323 "ao": "ꜵ",
8324 "au": "ꜷ",
8325 "av": "ꜹꜻ",
8326 "ay": "ꜽ",
8327 "b": "ƀɓƃ",
8328 "c": "ꜿƈȼↄ",
8329 "d": "đɗɖᴅƌꮷԁɦ",
8330 "e": "ɛǝᴇɇ",
8331 "f": "ꝼƒ",
8332 "g": "ǥɠꞡᵹꝿɢ",
8333 "h": "ħⱨⱶɥ",
8334 "i": "ɨı",
8335 "j": "ɉȷ",
8336 "k": "ƙⱪꝁꝃꝅꞣ",
8337 "l": "łƚɫⱡꝉꝇꞁɭ",
8338 "m": "ɱɯϻ",
8339 "n": "ꞥƞɲꞑᴎлԉ",
8340 "o": "øǿɔɵꝋꝍᴑ",
8341 "oe": "œ",
8342 "oi": "ƣ",
8343 "oo": "ꝏ",
8344 "ou": "ȣ",
8345 "p": "ƥᵽꝑꝓꝕρ",
8346 "q": "ꝗꝙɋ",
8347 "r": "ɍɽꝛꞧꞃ",
8348 "s": "ßȿꞩꞅʂ",
8349 "t": "ŧƭʈⱦꞇ",
8350 "th": "þ",
8351 "tz": "ꜩ",
8352 "u": "ʉ",
8353 "v": "ʋꝟʌ",
8354 "vy": "ꝡ",
8355 "w": "ⱳ",
8356 "y": "ƴɏỿ",
8357 "z": "ƶȥɀⱬꝣ",
8358 "hv": "ƕ"
8359 };
8360 for (let latin in latin_condensed) {
8361 let unicode = latin_condensed[latin] || '';
8362 for (let i = 0; i < unicode.length; i++) {
8363 let char = unicode.substring(i, i + 1);
8364 latin_convert[char] = latin;
8365 }
8366 }
8367 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
8368 /**
8369 * Initialize the unicode_map from the give code point ranges
8370 */
8371 const initialize = (_code_points) => {
8372 if (unicode_map !== undefined)
8373 return;
8374 unicode_map = generateMap(_code_points || code_points);
8375 };
8376 /**
8377 * Helper method for normalize a string
8378 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
8379 */
8380 const normalize = (str, form = 'NFKD') => str.normalize(form);
8381 /**
8382 * Remove accents without reordering string
8383 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
8384 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
8385 */
8386 const asciifold = (str) => {
8387 return Array.from(str).reduce(
8388 /**
8389 * @param {string} result
8390 * @param {string} char
8391 */
8392 (result, char) => {
8393 return result + _asciifold(char);
8394 }, '');
8395 };
8396 const _asciifold = (str) => {
8397 str = normalize(str)
8398 .toLowerCase()
8399 .replace(convert_pat, (/** @type {string} */ char) => {
8400 return latin_convert[char] || '';
8401 });
8402 //return str;
8403 return normalize(str, 'NFC');
8404 };
8405 /**
8406 * Generate a list of unicode variants from the list of code points
8407 */
8408 function* generator(code_points) {
8409 for (const [code_point_min, code_point_max] of code_points) {
8410 for (let i = code_point_min; i <= code_point_max; i++) {
8411 let composed = String.fromCharCode(i);
8412 let folded = asciifold(composed);
8413 if (folded == composed.toLowerCase()) {
8414 continue;
8415 }
8416 // skip when folded is a string longer than 3 characters long
8417 // bc the resulting regex patterns will be long
8418 // eg:
8419 // folded صلى الله عليه وسلم length 18 code point 65018
8420 // folded جل جلاله length 8 code point 65019
8421 if (folded.length > max_char_length) {
8422 continue;
8423 }
8424 if (folded.length == 0) {
8425 continue;
8426 }
8427 yield { folded: folded, composed: composed, code_point: i };
8428 }
8429 }
8430 }
8431 /**
8432 * Generate a unicode map from the list of code points
8433 */
8434 const generateSets = (code_points) => {
8435 const unicode_sets = {};
8436 const addMatching = (folded, to_add) => {
8437 /** @type {Set<string>} */
8438 const folded_set = unicode_sets[folded] || new Set();
8439 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
8440 if (to_add.match(patt)) {
8441 return;
8442 }
8443 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
8444 unicode_sets[folded] = folded_set;
8445 };
8446 for (let value of generator(code_points)) {
8447 addMatching(value.folded, value.folded);
8448 addMatching(value.folded, value.composed);
8449 }
8450 return unicode_sets;
8451 };
8452 /**
8453 * Generate a unicode map from the list of code points
8454 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
8455 */
8456 const generateMap = (code_points) => {
8457 const unicode_sets = generateSets(code_points);
8458 const unicode_map = {};
8459 let multi_char = [];
8460 for (let folded in unicode_sets) {
8461 let set = unicode_sets[folded];
8462 if (set) {
8463 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
8464 }
8465 if (folded.length > 1) {
8466 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
8467 }
8468 }
8469 multi_char.sort((a, b) => b.length - a.length);
8470 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
8471 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
8472 return unicode_map;
8473 };
8474 /**
8475 * Map each element of an array from its folded value to all possible unicode matches
8476 */
8477 const mapSequence = (strings, min_replacement = 1) => {
8478 let chars_replaced = 0;
8479 strings = strings.map((str) => {
8480 if (unicode_map[str]) {
8481 chars_replaced += str.length;
8482 }
8483 return unicode_map[str] || str;
8484 });
8485 if (chars_replaced >= min_replacement) {
8486 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
8487 }
8488 return '';
8489 };
8490 /**
8491 * Convert a short string and split it into all possible patterns
8492 * Keep a pattern only if min_replacement is met
8493 *
8494 * 'abc'
8495 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
8496 * => ['abc-pattern','ab-c-pattern'...]
8497 */
8498 const substringsToPattern = (str, min_replacement = 1) => {
8499 min_replacement = Math.max(min_replacement, str.length - 1);
8500 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
8501 return mapSequence(sub_pat, min_replacement);
8502 }));
8503 };
8504 /**
8505 * Convert an array of sequences into a pattern
8506 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
8507 */
8508 const sequencesToPattern = (sequences, all = true) => {
8509 let min_replacement = sequences.length > 1 ? 1 : 0;
8510 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
8511 let seq = [];
8512 const len = all ? sequence.length() : sequence.length() - 1;
8513 for (let j = 0; j < len; j++) {
8514 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
8515 }
8516 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
8517 }));
8518 };
8519 /**
8520 * Return true if the sequence is already in the sequences
8521 */
8522 const inSequences = (needle_seq, sequences) => {
8523 for (const seq of sequences) {
8524 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
8525 continue;
8526 }
8527 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
8528 continue;
8529 }
8530 let needle_parts = needle_seq.parts;
8531 const filter = (part) => {
8532 for (const needle_part of needle_parts) {
8533 if (needle_part.start === part.start && needle_part.substr === part.substr) {
8534 return false;
8535 }
8536 if (part.length == 1 || needle_part.length == 1) {
8537 continue;
8538 }
8539 // check for overlapping parts
8540 // a = ['::=','==']
8541 // b = ['::','===']
8542 // a = ['r','sm']
8543 // b = ['rs','m']
8544 if (part.start < needle_part.start && part.end > needle_part.start) {
8545 return true;
8546 }
8547 if (needle_part.start < part.start && needle_part.end > part.start) {
8548 return true;
8549 }
8550 }
8551 return false;
8552 };
8553 let filtered = seq.parts.filter(filter);
8554 if (filtered.length > 0) {
8555 continue;
8556 }
8557 return true;
8558 }
8559 return false;
8560 };
8561 class Sequence {
8562 parts;
8563 substrs;
8564 start;
8565 end;
8566 constructor() {
8567 this.parts = [];
8568 this.substrs = [];
8569 this.start = 0;
8570 this.end = 0;
8571 }
8572 add(part) {
8573 if (part) {
8574 this.parts.push(part);
8575 this.substrs.push(part.substr);
8576 this.start = Math.min(part.start, this.start);
8577 this.end = Math.max(part.end, this.end);
8578 }
8579 }
8580 last() {
8581 return this.parts[this.parts.length - 1];
8582 }
8583 length() {
8584 return this.parts.length;
8585 }
8586 clone(position, last_piece) {
8587 let clone = new Sequence();
8588 let parts = JSON.parse(JSON.stringify(this.parts));
8589 let last_part = parts.pop();
8590 for (const part of parts) {
8591 clone.add(part);
8592 }
8593 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8594 let clone_last_len = last_substr.length;
8595 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8596 return clone;
8597 }
8598 }
8599 /**
8600 * Expand a regular expression pattern to include unicode variants
8601 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8602 *
8603 * Issue:
8604 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8605 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8606 *
8607 * İIJ = IIJ = ⅡJ
8608 *
8609 * 1/2/4
8610 */
8611 const getPattern = (str) => {
8612 initialize();
8613 str = asciifold(str);
8614 let pattern = '';
8615 let sequences = [new Sequence()];
8616 for (let i = 0; i < str.length; i++) {
8617 let substr = str.substring(i);
8618 let match = substr.match(multi_char_reg);
8619 const char = str.substring(i, i + 1);
8620 const match_str = match ? match[0] : null;
8621 // loop through sequences
8622 // add either the char or multi_match
8623 let overlapping = [];
8624 let added_types = new Set();
8625 for (const sequence of sequences) {
8626 const last_piece = sequence.last();
8627 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8628 // if we have a multi match
8629 if (match_str) {
8630 const len = match_str.length;
8631 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8632 added_types.add('1');
8633 }
8634 else {
8635 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8636 added_types.add('2');
8637 }
8638 }
8639 else if (match_str) {
8640 let clone = sequence.clone(i, last_piece);
8641 const len = match_str.length;
8642 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8643 overlapping.push(clone);
8644 }
8645 else {
8646 // don't add char
8647 // adding would create invalid patterns: 234 => [2,34,4]
8648 added_types.add('3');
8649 }
8650 }
8651 // if we have overlapping
8652 if (overlapping.length > 0) {
8653 // ['ii','iii'] before ['i','i','iii']
8654 overlapping = overlapping.sort((a, b) => {
8655 return a.length() - b.length();
8656 });
8657 for (let clone of overlapping) {
8658 // don't add if we already have an equivalent sequence
8659 if (inSequences(clone, sequences)) {
8660 continue;
8661 }
8662 sequences.push(clone);
8663 }
8664 continue;
8665 }
8666 // if we haven't done anything unique
8667 // clean up the patterns
8668 // helps keep patterns smaller
8669 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8670 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8671 pattern += sequencesToPattern(sequences, false);
8672 let new_seq = new Sequence();
8673 const old_seq = sequences[0];
8674 if (old_seq) {
8675 new_seq.add(old_seq.last());
8676 }
8677 sequences = [new_seq];
8678 }
8679 }
8680 pattern += sequencesToPattern(sequences, true);
8681 return pattern;
8682 };
8683
8684 //# sourceMappingURL=index.js.map
8685
8686 /***/ },
8687
8688 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8689 /*!*******************************************************************!*\
8690 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8691 \*******************************************************************/
8692 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8693
8694 "use strict";
8695 __webpack_require__.r(__webpack_exports__);
8696 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8697 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8698 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8699 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8700 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8701 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8702 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8703 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8704 /* harmony export */ });
8705 /**
8706 * Convert array of strings to a regular expression
8707 * ex ['ab','a'] => (?:ab|a)
8708 * ex ['a','b'] => [ab]
8709 */
8710 const arrayToPattern = (chars) => {
8711 chars = chars.filter(Boolean);
8712 if (chars.length < 2) {
8713 return chars[0] || '';
8714 }
8715 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8716 };
8717 const sequencePattern = (array) => {
8718 if (!hasDuplicates(array)) {
8719 return array.join('');
8720 }
8721 let pattern = '';
8722 let prev_char_count = 0;
8723 const prev_pattern = () => {
8724 if (prev_char_count > 1) {
8725 pattern += '{' + prev_char_count + '}';
8726 }
8727 };
8728 array.forEach((char, i) => {
8729 if (char === array[i - 1]) {
8730 prev_char_count++;
8731 return;
8732 }
8733 prev_pattern();
8734 pattern += char;
8735 prev_char_count = 1;
8736 });
8737 prev_pattern();
8738 return pattern;
8739 };
8740 /**
8741 * Convert array of strings to a regular expression
8742 * ex ['ab','a'] => (?:ab|a)
8743 * ex ['a','b'] => [ab]
8744 */
8745 const setToPattern = (chars) => {
8746 let array = Array.from(chars);
8747 return arrayToPattern(array);
8748 };
8749 /**
8750 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8751 */
8752 const hasDuplicates = (array) => {
8753 return (new Set(array)).size !== array.length;
8754 };
8755 /**
8756 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8757 */
8758 const escape_regex = (str) => {
8759 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8760 };
8761 /**
8762 * Return the max length of array values
8763 */
8764 const maxValueLength = (array) => {
8765 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8766 };
8767 const unicodeLength = (str) => {
8768 return Array.from(str).length;
8769 };
8770 //# sourceMappingURL=regex.js.map
8771
8772 /***/ },
8773
8774 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8775 /*!*********************************************************************!*\
8776 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8777 \*********************************************************************/
8778 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8779
8780 "use strict";
8781 __webpack_require__.r(__webpack_exports__);
8782 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8783 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8784 /* harmony export */ });
8785 /**
8786 * Get all possible combinations of substrings that add up to the given string
8787 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8788 */
8789 const allSubstrings = (input) => {
8790 if (input.length === 1)
8791 return [[input]];
8792 let result = [];
8793 const start = input.substring(1);
8794 const suba = allSubstrings(start);
8795 suba.forEach(function (subresult) {
8796 let tmp = subresult.slice(0);
8797 tmp[0] = input.charAt(0) + tmp[0];
8798 result.push(tmp);
8799 tmp = subresult.slice(0);
8800 tmp.unshift(input.charAt(0));
8801 result.push(tmp);
8802 });
8803 return result;
8804 };
8805 //# sourceMappingURL=strings.js.map
8806
8807 /***/ },
8808
8809 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8810 /*!*******************************************************!*\
8811 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8812 \*******************************************************/
8813 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8814
8815 "use strict";
8816 __webpack_require__.r(__webpack_exports__);
8817 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8818 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8819 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8820 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8821 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8822 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8823 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8824 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8825 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8826 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8827 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8828 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8829 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8830 /* harmony export */ });
8831 const KEY_A = 65;
8832 const KEY_RETURN = 13;
8833 const KEY_ESC = 27;
8834 const KEY_LEFT = 37;
8835 const KEY_UP = 38;
8836 const KEY_RIGHT = 39;
8837 const KEY_DOWN = 40;
8838 const KEY_BACKSPACE = 8;
8839 const KEY_DELETE = 46;
8840 const KEY_TAB = 9;
8841 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8842 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8843 //# sourceMappingURL=constants.js.map
8844
8845 /***/ },
8846
8847 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8848 /*!***************************************************************!*\
8849 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8850 \***************************************************************/
8851 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8852
8853 "use strict";
8854 __webpack_require__.r(__webpack_exports__);
8855 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8856 /* harmony export */ highlight: () => (/* binding */ highlight),
8857 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8858 /* harmony export */ });
8859 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8860 /**
8861 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
8862 * Highlights arbitrary terms in a node.
8863 *
8864 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
8865 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
8866 */
8867
8868 const highlight = (element, regex) => {
8869 if (regex === null)
8870 return;
8871 // convet string to regex
8872 if (typeof regex === 'string') {
8873 if (!regex.length)
8874 return;
8875 regex = new RegExp(regex, 'i');
8876 }
8877 // Wrap matching part of text node with highlighting <span>, e.g.
8878 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8879 const highlightText = (node) => {
8880 var match = node.data.match(regex);
8881 if (match && node.data.length > 0) {
8882 var spannode = document.createElement('span');
8883 spannode.className = 'highlight';
8884 var middlebit = node.splitText(match.index);
8885 middlebit.splitText(match[0].length);
8886 var middleclone = middlebit.cloneNode(true);
8887 spannode.appendChild(middleclone);
8888 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8889 return 1;
8890 }
8891 return 0;
8892 };
8893 // Recurse element node, looking for child text nodes to highlight, unless element
8894 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8895 const highlightChildren = (node) => {
8896 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8897 Array.from(node.childNodes).forEach(element => {
8898 highlightRecursive(element);
8899 });
8900 }
8901 };
8902 const highlightRecursive = (node) => {
8903 if (node.nodeType === 3) {
8904 return highlightText(node);
8905 }
8906 highlightChildren(node);
8907 return 0;
8908 };
8909 highlightRecursive(element);
8910 };
8911 /**
8912 * removeHighlight fn copied from highlight v5 and
8913 * edited to remove with(), pass js strict mode, and use without jquery
8914 */
8915 const removeHighlight = (el) => {
8916 var elements = el.querySelectorAll("span.highlight");
8917 Array.prototype.forEach.call(elements, function (el) {
8918 var parent = el.parentNode;
8919 parent.replaceChild(el.firstChild, el);
8920 parent.normalize();
8921 });
8922 };
8923 //# sourceMappingURL=highlight.js.map
8924
8925 /***/ },
8926
8927 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8928 /*!****************************************************************!*\
8929 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8930 \****************************************************************/
8931 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8932
8933 "use strict";
8934 __webpack_require__.r(__webpack_exports__);
8935 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8936 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8937 /* harmony export */ });
8938 /**
8939 * MicroEvent - to make any js object an event emitter
8940 *
8941 * - pure javascript - server compatible, browser compatible
8942 * - dont rely on the browser doms
8943 * - super simple - you get it immediatly, no mistery, no magic involved
8944 *
8945 * @author Jerome Etienne (https://github.com/jeromeetienne)
8946 */
8947 /**
8948 * Execute callback for each event in space separated list of event names
8949 *
8950 */
8951 function forEvents(events, callback) {
8952 events.split(/\s+/).forEach((event) => {
8953 callback(event);
8954 });
8955 }
8956 class MicroEvent {
8957 constructor() {
8958 this._events = {};
8959 }
8960 on(events, fct) {
8961 forEvents(events, (event) => {
8962 const event_array = this._events[event] || [];
8963 event_array.push(fct);
8964 this._events[event] = event_array;
8965 });
8966 }
8967 off(events, fct) {
8968 var n = arguments.length;
8969 if (n === 0) {
8970 this._events = {};
8971 return;
8972 }
8973 forEvents(events, (event) => {
8974 if (n === 1) {
8975 delete this._events[event];
8976 return;
8977 }
8978 const event_array = this._events[event];
8979 if (event_array === undefined)
8980 return;
8981 event_array.splice(event_array.indexOf(fct), 1);
8982 this._events[event] = event_array;
8983 });
8984 }
8985 trigger(events, ...args) {
8986 var self = this;
8987 forEvents(events, (event) => {
8988 const event_array = self._events[event];
8989 if (event_array === undefined)
8990 return;
8991 event_array.forEach(fct => {
8992 fct.apply(self, args);
8993 });
8994 });
8995 }
8996 }
8997 ;
8998 //# sourceMappingURL=microevent.js.map
8999
9000 /***/ },
9001
9002 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
9003 /*!*****************************************************************!*\
9004 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
9005 \*****************************************************************/
9006 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9007
9008 "use strict";
9009 __webpack_require__.r(__webpack_exports__);
9010 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9011 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
9012 /* harmony export */ });
9013 /**
9014 * microplugin.js
9015 * Copyright (c) 2013 Brian Reavis & contributors
9016 *
9017 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9018 * file except in compliance with the License. You may obtain a copy of the License at:
9019 * http://www.apache.org/licenses/LICENSE-2.0
9020 *
9021 * Unless required by applicable law or agreed to in writing, software distributed under
9022 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9023 * ANY KIND, either express or implied. See the License for the specific language
9024 * governing permissions and limitations under the License.
9025 *
9026 * @author Brian Reavis <brian@thirdroute.com>
9027 */
9028 function MicroPlugin(Interface) {
9029 Interface.plugins = {};
9030 return class extends Interface {
9031 constructor() {
9032 super(...arguments);
9033 this.plugins = {
9034 names: [],
9035 settings: {},
9036 requested: {},
9037 loaded: {}
9038 };
9039 }
9040 /**
9041 * Registers a plugin.
9042 *
9043 * @param {function} fn
9044 */
9045 static define(name, fn) {
9046 Interface.plugins[name] = {
9047 'name': name,
9048 'fn': fn
9049 };
9050 }
9051 /**
9052 * Initializes the listed plugins (with options).
9053 * Acceptable formats:
9054 *
9055 * List (without options):
9056 * ['a', 'b', 'c']
9057 *
9058 * List (with options):
9059 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
9060 *
9061 * Hash (with options):
9062 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
9063 *
9064 * @param {array|object} plugins
9065 */
9066 initializePlugins(plugins) {
9067 var key, name;
9068 const self = this;
9069 const queue = [];
9070 if (Array.isArray(plugins)) {
9071 plugins.forEach((plugin) => {
9072 if (typeof plugin === 'string') {
9073 queue.push(plugin);
9074 }
9075 else {
9076 self.plugins.settings[plugin.name] = plugin.options;
9077 queue.push(plugin.name);
9078 }
9079 });
9080 }
9081 else if (plugins) {
9082 for (key in plugins) {
9083 if (plugins.hasOwnProperty(key)) {
9084 self.plugins.settings[key] = plugins[key];
9085 queue.push(key);
9086 }
9087 }
9088 }
9089 while (name = queue.shift()) {
9090 self.require(name);
9091 }
9092 }
9093 loadPlugin(name) {
9094 var self = this;
9095 var plugins = self.plugins;
9096 var plugin = Interface.plugins[name];
9097 if (!Interface.plugins.hasOwnProperty(name)) {
9098 throw new Error('Unable to find "' + name + '" plugin');
9099 }
9100 plugins.requested[name] = true;
9101 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
9102 plugins.names.push(name);
9103 }
9104 /**
9105 * Initializes a plugin.
9106 *
9107 */
9108 require(name) {
9109 var self = this;
9110 var plugins = self.plugins;
9111 if (!self.plugins.loaded.hasOwnProperty(name)) {
9112 if (plugins.requested[name]) {
9113 throw new Error('Plugin has circular dependency ("' + name + '")');
9114 }
9115 self.loadPlugin(name);
9116 }
9117 return plugins.loaded[name];
9118 }
9119 };
9120 }
9121 //# sourceMappingURL=microplugin.js.map
9122
9123 /***/ },
9124
9125 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
9126 /*!******************************************************!*\
9127 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
9128 \******************************************************/
9129 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9130
9131 "use strict";
9132 __webpack_require__.r(__webpack_exports__);
9133 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9134 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
9135 /* harmony export */ });
9136 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
9137 options: [],
9138 optgroups: [],
9139 plugins: [],
9140 delimiter: ',',
9141 splitOn: null, // regexp or string for splitting up values from a paste command
9142 persist: true,
9143 diacritics: true,
9144 create: null,
9145 createOnBlur: false,
9146 createFilter: null,
9147 clearAfterSelect: false,
9148 highlight: true,
9149 openOnFocus: true,
9150 shouldOpen: null,
9151 maxOptions: 50,
9152 maxItems: null,
9153 hideSelected: null,
9154 duplicates: false,
9155 addPrecedence: false,
9156 selectOnTab: false,
9157 preload: null,
9158 allowEmptyOption: false,
9159 //closeAfterSelect: false,
9160 refreshThrottle: 300,
9161 loadThrottle: 300,
9162 loadingClass: 'loading',
9163 dataAttr: null, //'data-data',
9164 optgroupField: 'optgroup',
9165 valueField: 'value',
9166 labelField: 'text',
9167 disabledField: 'disabled',
9168 optgroupLabelField: 'label',
9169 optgroupValueField: 'value',
9170 lockOptgroupOrder: false,
9171 sortField: '$order',
9172 searchField: ['text'],
9173 searchConjunction: 'and',
9174 mode: null,
9175 wrapperClass: 'ts-wrapper',
9176 controlClass: 'ts-control',
9177 dropdownClass: 'ts-dropdown',
9178 dropdownContentClass: 'ts-dropdown-content',
9179 itemClass: 'item',
9180 optionClass: 'option',
9181 dropdownParent: null,
9182 controlInput: '<input type="text" autocomplete="off" size="1" />',
9183 copyClassesToDropdown: false,
9184 placeholder: null,
9185 hidePlaceholder: null,
9186 shouldLoad: function (query) {
9187 return query.length > 0;
9188 },
9189 /*
9190 load : null, // function(query, callback) { ... }
9191 score : null, // function(search) { ... }
9192 onInitialize : null, // function() { ... }
9193 onChange : null, // function(value) { ... }
9194 onItemAdd : null, // function(value, $item) { ... }
9195 onItemRemove : null, // function(value) { ... }
9196 onClear : null, // function() { ... }
9197 onOptionAdd : null, // function(value, data) { ... }
9198 onOptionRemove : null, // function(value) { ... }
9199 onOptionClear : null, // function() { ... }
9200 onOptionGroupAdd : null, // function(id, data) { ... }
9201 onOptionGroupRemove : null, // function(id) { ... }
9202 onOptionGroupClear : null, // function() { ... }
9203 onDropdownOpen : null, // function(dropdown) { ... }
9204 onDropdownClose : null, // function(dropdown) { ... }
9205 onType : null, // function(str) { ... }
9206 onDelete : null, // function(values) { ... }
9207 */
9208 render: {
9209 /*
9210 item: null,
9211 optgroup: null,
9212 optgroup_header: null,
9213 option: null,
9214 option_create: null
9215 */
9216 }
9217 });
9218 //# sourceMappingURL=defaults.js.map
9219
9220 /***/ },
9221
9222 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
9223 /*!*********************************************************!*\
9224 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
9225 \*********************************************************/
9226 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9227
9228 "use strict";
9229 __webpack_require__.r(__webpack_exports__);
9230 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9231 /* harmony export */ "default": () => (/* binding */ getSettings)
9232 /* harmony export */ });
9233 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
9234 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
9235
9236
9237 function getSettings(input, settings_user) {
9238 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
9239 var attr_data = settings.dataAttr;
9240 var field_label = settings.labelField;
9241 var field_value = settings.valueField;
9242 var field_disabled = settings.disabledField;
9243 var field_optgroup = settings.optgroupField;
9244 var field_optgroup_label = settings.optgroupLabelField;
9245 var field_optgroup_value = settings.optgroupValueField;
9246 var tag_name = input.tagName.toLowerCase();
9247 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
9248 if (!placeholder && !settings.allowEmptyOption) {
9249 let option = input.querySelector('option[value=""]');
9250 if (option) {
9251 placeholder = option.textContent;
9252 }
9253 }
9254 var settings_element = {
9255 placeholder: placeholder,
9256 options: [],
9257 optgroups: [],
9258 items: [],
9259 maxItems: null,
9260 };
9261 /**
9262 * Initialize from a <select> element.
9263 *
9264 */
9265 var init_select = () => {
9266 var tagName;
9267 var options = settings_element.options;
9268 var optionsMap = {};
9269 var group_count = 1;
9270 let $order = 0;
9271 var readData = (el) => {
9272 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
9273 var json = attr_data && data[attr_data];
9274 if (typeof json === 'string' && json.length) {
9275 data = Object.assign(data, JSON.parse(json));
9276 }
9277 return data;
9278 };
9279 var addOption = (option, group) => {
9280 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
9281 if (value == null)
9282 return;
9283 if (!value && !settings.allowEmptyOption)
9284 return;
9285 // if the option already exists, it's probably been
9286 // duplicated in another optgroup. in this case, push
9287 // the current group to the "optgroup" property on the
9288 // existing option so that it's rendered in both places.
9289 if (optionsMap.hasOwnProperty(value)) {
9290 if (group) {
9291 var arr = optionsMap[value][field_optgroup];
9292 if (!arr) {
9293 optionsMap[value][field_optgroup] = group;
9294 }
9295 else if (!Array.isArray(arr)) {
9296 optionsMap[value][field_optgroup] = [arr, group];
9297 }
9298 else {
9299 arr.push(group);
9300 }
9301 }
9302 }
9303 else {
9304 var option_data = readData(option);
9305 option_data[field_label] = option_data[field_label] || option.textContent;
9306 option_data[field_value] = option_data[field_value] || value;
9307 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
9308 option_data[field_optgroup] = option_data[field_optgroup] || group;
9309 option_data.$option = option;
9310 option_data.$order = option_data.$order || ++$order;
9311 optionsMap[value] = option_data;
9312 options.push(option_data);
9313 }
9314 if (option.selected) {
9315 settings_element.items.push(value);
9316 }
9317 };
9318 var addGroup = (optgroup) => {
9319 var id, optgroup_data;
9320 optgroup_data = readData(optgroup);
9321 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
9322 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
9323 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
9324 optgroup_data.$order = optgroup_data.$order || ++$order;
9325 settings_element.optgroups.push(optgroup_data);
9326 id = optgroup_data[field_optgroup_value];
9327 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
9328 addOption(option, id);
9329 });
9330 };
9331 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
9332 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
9333 tagName = child.tagName.toLowerCase();
9334 if (tagName === 'optgroup') {
9335 addGroup(child);
9336 }
9337 else if (tagName === 'option') {
9338 addOption(child);
9339 }
9340 });
9341 };
9342 /**
9343 * Initialize from a <input type="text"> element.
9344 *
9345 */
9346 var init_textbox = () => {
9347 var _a, _b;
9348 const data_raw = input.getAttribute(attr_data);
9349 if (!data_raw) {
9350 var value = (_b = (_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
9351 if (!settings.allowEmptyOption && !value.length)
9352 return;
9353 const values = value.split(settings.delimiter);
9354 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
9355 const option = {};
9356 option[field_label] = value;
9357 option[field_value] = value;
9358 settings_element.options.push(option);
9359 });
9360 settings_element.items = values;
9361 }
9362 else {
9363 settings_element.options = JSON.parse(data_raw);
9364 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
9365 settings_element.items.push(opt[field_value]);
9366 });
9367 }
9368 };
9369 if (tag_name === 'select') {
9370 init_select();
9371 }
9372 else {
9373 init_textbox();
9374 }
9375 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
9376 }
9377 ;
9378 //# sourceMappingURL=getSettings.js.map
9379
9380 /***/ },
9381
9382 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
9383 /*!***************************************************************************!*\
9384 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
9385 \***************************************************************************/
9386 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9387
9388 "use strict";
9389 __webpack_require__.r(__webpack_exports__);
9390 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9391 /* harmony export */ "default": () => (/* binding */ plugin)
9392 /* harmony export */ });
9393 /**
9394 * Tom Select v2.6.2
9395 * Licensed under the Apache License, Version 2.0 (the "License");
9396 */
9397
9398 /**
9399 * Converts a scalar to its best string representation
9400 * for hash keys and HTML attribute values.
9401 *
9402 * Transformations:
9403 * 'str' -> 'str'
9404 * null -> ''
9405 * undefined -> ''
9406 * true -> '1'
9407 * false -> '0'
9408 * 0 -> '0'
9409 * 1 -> '1'
9410 *
9411 */
9412
9413 /**
9414 * Iterates over arrays and hashes.
9415 *
9416 * ```
9417 * iterate(this.items, function(item, id) {
9418 * // invoked for each item
9419 * });
9420 * ```
9421 *
9422 */
9423 const iterate = (object, callback) => {
9424 if (Array.isArray(object)) {
9425 object.forEach(callback);
9426 } else {
9427 for (var key in object) {
9428 if (object.hasOwnProperty(key)) {
9429 callback(object[key], key);
9430 }
9431 }
9432 }
9433 };
9434
9435 /**
9436 * Remove css classes
9437 *
9438 */
9439 const removeClasses = (elmts, ...classes) => {
9440 var norm_classes = classesArray(classes);
9441 elmts = castAsArray(elmts);
9442 elmts.map(el => {
9443 norm_classes.map(cls => {
9444 el.classList.remove(cls);
9445 });
9446 });
9447 };
9448
9449 /**
9450 * Return arguments
9451 *
9452 */
9453 const classesArray = args => {
9454 var classes = [];
9455 iterate(args, _classes => {
9456 if (typeof _classes === 'string') {
9457 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9458 }
9459 if (Array.isArray(_classes)) {
9460 classes = classes.concat(_classes);
9461 }
9462 });
9463 return classes.filter(Boolean);
9464 };
9465
9466 /**
9467 * Create an array from arg if it's not already an array
9468 *
9469 */
9470 const castAsArray = arg => {
9471 if (!Array.isArray(arg)) {
9472 arg = [arg];
9473 }
9474 return arg;
9475 };
9476
9477 /**
9478 * Get the index of an element amongst sibling nodes of the same type
9479 *
9480 */
9481 const nodeIndex = (el, amongst) => {
9482 if (!el) return -1;
9483 amongst = amongst || el.nodeName;
9484 var i = 0;
9485 while (el = el.previousElementSibling) {
9486 if (el.matches(amongst)) {
9487 i++;
9488 }
9489 }
9490 return i;
9491 };
9492
9493 /**
9494 * Plugin: "dropdown_input" (Tom Select)
9495 * Copyright (c) contributors
9496 *
9497 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9498 * file except in compliance with the License. You may obtain a copy of the License at:
9499 * http://www.apache.org/licenses/LICENSE-2.0
9500 *
9501 * Unless required by applicable law or agreed to in writing, software distributed under
9502 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9503 * ANY KIND, either express or implied. See the License for the specific language
9504 * governing permissions and limitations under the License.
9505 *
9506 */
9507
9508 function plugin () {
9509 var self = this;
9510
9511 /**
9512 * Moves the caret to the specified index.
9513 *
9514 * The input must be moved by leaving it in place and moving the
9515 * siblings, due to the fact that focus cannot be restored once lost
9516 * on mobile webkit devices
9517 *
9518 */
9519 self.hook('instead', 'setCaret', new_pos => {
9520 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
9521 new_pos = self.items.length;
9522 } else {
9523 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
9524 if (new_pos != self.caretPos && !self.isPending) {
9525 self.controlChildren().forEach((child, j) => {
9526 if (j < new_pos) {
9527 self.control_input.insertAdjacentElement('beforebegin', child);
9528 } else {
9529 self.control.appendChild(child);
9530 }
9531 });
9532 }
9533 }
9534 self.caretPos = new_pos;
9535 });
9536 self.hook('instead', 'moveCaret', direction => {
9537 if (!self.isFocused) return;
9538
9539 // move caret before or after selected items
9540 const last_active = self.getLastActive(direction);
9541 if (last_active) {
9542 const idx = nodeIndex(last_active);
9543 self.setCaret(direction > 0 ? idx + 1 : idx);
9544 self.setActiveItem();
9545 removeClasses(last_active, 'last-active');
9546
9547 // move caret left or right of current position
9548 } else {
9549 self.setCaret(self.caretPos + direction);
9550 }
9551 });
9552 }
9553
9554
9555 //# sourceMappingURL=plugin.js.map
9556
9557
9558 /***/ },
9559
9560 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9561 /*!****************************************************************************!*\
9562 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9563 \****************************************************************************/
9564 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9565
9566 "use strict";
9567 __webpack_require__.r(__webpack_exports__);
9568 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9569 /* harmony export */ "default": () => (/* binding */ plugin)
9570 /* harmony export */ });
9571 /**
9572 * Tom Select v2.6.2
9573 * Licensed under the Apache License, Version 2.0 (the "License");
9574 */
9575
9576 /**
9577 * Converts a scalar to its best string representation
9578 * for hash keys and HTML attribute values.
9579 *
9580 * Transformations:
9581 * 'str' -> 'str'
9582 * null -> ''
9583 * undefined -> ''
9584 * true -> '1'
9585 * false -> '0'
9586 * 0 -> '0'
9587 * 1 -> '1'
9588 *
9589 */
9590
9591 /**
9592 * Add event helper
9593 *
9594 */
9595 const addEvent = (target, type, callback, options) => {
9596 target.addEventListener(type, callback, options);
9597 };
9598
9599 /**
9600 * Plugin: "change_listener" (Tom Select)
9601 * Copyright (c) contributors
9602 *
9603 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9604 * file except in compliance with the License. You may obtain a copy of the License at:
9605 * http://www.apache.org/licenses/LICENSE-2.0
9606 *
9607 * Unless required by applicable law or agreed to in writing, software distributed under
9608 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9609 * ANY KIND, either express or implied. See the License for the specific language
9610 * governing permissions and limitations under the License.
9611 *
9612 */
9613
9614 function plugin () {
9615 addEvent(this.input, 'change', () => {
9616 this.sync();
9617 });
9618 }
9619
9620
9621 //# sourceMappingURL=plugin.js.map
9622
9623
9624 /***/ },
9625
9626 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9627 /*!*****************************************************************************!*\
9628 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9629 \*****************************************************************************/
9630 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9631
9632 "use strict";
9633 __webpack_require__.r(__webpack_exports__);
9634 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9635 /* harmony export */ "default": () => (/* binding */ plugin)
9636 /* harmony export */ });
9637 /**
9638 * Tom Select v2.6.2
9639 * Licensed under the Apache License, Version 2.0 (the "License");
9640 */
9641
9642 /**
9643 * Converts a scalar to its best string representation
9644 * for hash keys and HTML attribute values.
9645 *
9646 * Transformations:
9647 * 'str' -> 'str'
9648 * null -> ''
9649 * undefined -> ''
9650 * true -> '1'
9651 * false -> '0'
9652 * 0 -> '0'
9653 * 1 -> '1'
9654 *
9655 */
9656 const hash_key = value => {
9657 if (typeof value === 'undefined' || value === null) return null;
9658 return get_hash(value);
9659 };
9660 const get_hash = value => {
9661 if (typeof value === 'boolean') return value ? '1' : '0';
9662 return value + '';
9663 };
9664
9665 /**
9666 * Prevent default
9667 *
9668 */
9669 const preventDefault = (evt, stop = false) => {
9670 if (evt) {
9671 evt.preventDefault();
9672 if (stop) {
9673 evt.stopPropagation();
9674 }
9675 }
9676 };
9677
9678 /**
9679 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9680 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9681 *
9682 * param query should be {}
9683 */
9684 const getDom = query => {
9685 if (query.jquery) {
9686 return query[0];
9687 }
9688 if (query instanceof HTMLElement) {
9689 return query;
9690 }
9691 if (isHtmlString(query)) {
9692 var tpl = document.createElement('template');
9693 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9694 return tpl.content.firstChild;
9695 }
9696 return document.querySelector(query);
9697 };
9698 const isHtmlString = arg => {
9699 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9700 return true;
9701 }
9702 return false;
9703 };
9704
9705 /**
9706 * Plugin: "checkbox_options" (Tom Select)
9707 * Copyright (c) contributors
9708 *
9709 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9710 * file except in compliance with the License. You may obtain a copy of the License at:
9711 * http://www.apache.org/licenses/LICENSE-2.0
9712 *
9713 * Unless required by applicable law or agreed to in writing, software distributed under
9714 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9715 * ANY KIND, either express or implied. See the License for the specific language
9716 * governing permissions and limitations under the License.
9717 *
9718 */
9719
9720 function plugin (userOptions) {
9721 var self = this;
9722 var orig_onOptionSelect = self.onOptionSelect;
9723 self.settings.hideSelected = false;
9724 const cbOptions = Object.assign({
9725 // so that the user may add different ones as well
9726 className: "tomselect-checkbox",
9727 // the following default to the historic plugin's values
9728 checkedClassNames: undefined,
9729 uncheckedClassNames: undefined
9730 }, userOptions);
9731 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9732 if (toCheck) {
9733 checkbox.checked = true;
9734 if (cbOptions.uncheckedClassNames) {
9735 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9736 }
9737 if (cbOptions.checkedClassNames) {
9738 checkbox.classList.add(...cbOptions.checkedClassNames);
9739 }
9740 } else {
9741 checkbox.checked = false;
9742 if (cbOptions.checkedClassNames) {
9743 checkbox.classList.remove(...cbOptions.checkedClassNames);
9744 }
9745 if (cbOptions.uncheckedClassNames) {
9746 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9747 }
9748 }
9749 };
9750
9751 // update the checkbox for an option
9752 var UpdateCheckbox = function UpdateCheckbox(option) {
9753 setTimeout(() => {
9754 var checkbox = option.querySelector('input.' + cbOptions.className);
9755 if (checkbox instanceof HTMLInputElement) {
9756 UpdateChecked(checkbox, option.classList.contains('selected'));
9757 }
9758 }, 1);
9759 };
9760
9761 // add checkbox to option template
9762 self.hook('after', 'setupTemplates', () => {
9763 var orig_render_option = self.settings.render.option;
9764 self.settings.render.option = (data, escape_html) => {
9765 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9766 var checkbox = document.createElement('input');
9767 if (cbOptions.className) {
9768 checkbox.classList.add(cbOptions.className);
9769 }
9770 checkbox.addEventListener('click', function (evt) {
9771 preventDefault(evt);
9772 });
9773 checkbox.type = 'checkbox';
9774 const hashed = hash_key(data[self.settings.valueField]);
9775 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9776 rendered.prepend(checkbox);
9777 return rendered;
9778 };
9779 });
9780
9781 // uncheck when item removed
9782 self.on('item_remove', value => {
9783 var option = self.getOption(value);
9784 if (option) {
9785 // if dropdown hasn't been opened yet, the option won't exist
9786 option.classList.remove('selected'); // selected class won't be removed yet
9787 UpdateCheckbox(option);
9788 }
9789 });
9790
9791 // check when item added
9792 self.on('item_add', value => {
9793 var option = self.getOption(value);
9794 if (option) {
9795 // if dropdown hasn't been opened yet, the option won't exist
9796 UpdateCheckbox(option);
9797 }
9798 });
9799
9800 // remove items when selected option is clicked
9801 self.hook('instead', 'onOptionSelect', (evt, option) => {
9802 if (option.classList.contains('selected')) {
9803 option.classList.remove('selected');
9804 self.removeItem(option.dataset.value);
9805 self.refreshOptions();
9806 preventDefault(evt, true);
9807 return;
9808 }
9809 orig_onOptionSelect.call(self, evt, option);
9810 UpdateCheckbox(option);
9811 });
9812 }
9813
9814
9815 //# sourceMappingURL=plugin.js.map
9816
9817
9818 /***/ },
9819
9820 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9821 /*!*************************************************************************!*\
9822 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9823 \*************************************************************************/
9824 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9825
9826 "use strict";
9827 __webpack_require__.r(__webpack_exports__);
9828 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9829 /* harmony export */ "default": () => (/* binding */ plugin)
9830 /* harmony export */ });
9831 /**
9832 * Tom Select v2.6.2
9833 * Licensed under the Apache License, Version 2.0 (the "License");
9834 */
9835
9836 /**
9837 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9838 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9839 *
9840 * param query should be {}
9841 */
9842 const getDom = query => {
9843 if (query.jquery) {
9844 return query[0];
9845 }
9846 if (query instanceof HTMLElement) {
9847 return query;
9848 }
9849 if (isHtmlString(query)) {
9850 var tpl = document.createElement('template');
9851 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9852 return tpl.content.firstChild;
9853 }
9854 return document.querySelector(query);
9855 };
9856 const isHtmlString = arg => {
9857 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9858 return true;
9859 }
9860 return false;
9861 };
9862
9863 /**
9864 * Plugin: "dropdown_header" (Tom Select)
9865 * Copyright (c) contributors
9866 *
9867 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9868 * file except in compliance with the License. You may obtain a copy of the License at:
9869 * http://www.apache.org/licenses/LICENSE-2.0
9870 *
9871 * Unless required by applicable law or agreed to in writing, software distributed under
9872 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9873 * ANY KIND, either express or implied. See the License for the specific language
9874 * governing permissions and limitations under the License.
9875 *
9876 */
9877
9878 function plugin (userOptions) {
9879 const self = this;
9880 const options = Object.assign({
9881 className: 'clear-button',
9882 title: 'Clear All',
9883 role: 'button',
9884 tabindex: 0,
9885 html: data => {
9886 return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">&times;</div>`;
9887 }
9888 }, userOptions);
9889 self.on('initialize', () => {
9890 var button = getDom(options.html(options));
9891 button.addEventListener('click', evt => {
9892 if (self.isLocked) return;
9893 self.clear();
9894 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9895 self.addItem('');
9896 }
9897 self.refreshOptions(false);
9898 evt.preventDefault();
9899 evt.stopPropagation();
9900 });
9901 self.control.appendChild(button);
9902 });
9903 }
9904
9905
9906 //# sourceMappingURL=plugin.js.map
9907
9908
9909 /***/ },
9910
9911 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9912 /*!**********************************************************************!*\
9913 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9914 \**********************************************************************/
9915 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9916
9917 "use strict";
9918 __webpack_require__.r(__webpack_exports__);
9919 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9920 /* harmony export */ "default": () => (/* binding */ plugin)
9921 /* harmony export */ });
9922 /**
9923 * Tom Select v2.6.2
9924 * Licensed under the Apache License, Version 2.0 (the "License");
9925 */
9926
9927 /**
9928 * Converts a scalar to its best string representation
9929 * for hash keys and HTML attribute values.
9930 *
9931 * Transformations:
9932 * 'str' -> 'str'
9933 * null -> ''
9934 * undefined -> ''
9935 * true -> '1'
9936 * false -> '0'
9937 * 0 -> '0'
9938 * 1 -> '1'
9939 *
9940 */
9941
9942 /**
9943 * Prevent default
9944 *
9945 */
9946 const preventDefault = (evt, stop = false) => {
9947 if (evt) {
9948 evt.preventDefault();
9949 if (stop) {
9950 evt.stopPropagation();
9951 }
9952 }
9953 };
9954
9955 /**
9956 * Add event helper
9957 *
9958 */
9959 const addEvent = (target, type, callback, options) => {
9960 target.addEventListener(type, callback, options);
9961 };
9962
9963 /**
9964 * Iterates over arrays and hashes.
9965 *
9966 * ```
9967 * iterate(this.items, function(item, id) {
9968 * // invoked for each item
9969 * });
9970 * ```
9971 *
9972 */
9973 const iterate = (object, callback) => {
9974 if (Array.isArray(object)) {
9975 object.forEach(callback);
9976 } else {
9977 for (var key in object) {
9978 if (object.hasOwnProperty(key)) {
9979 callback(object[key], key);
9980 }
9981 }
9982 }
9983 };
9984
9985 /**
9986 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9987 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9988 *
9989 * param query should be {}
9990 */
9991 const getDom = query => {
9992 if (query.jquery) {
9993 return query[0];
9994 }
9995 if (query instanceof HTMLElement) {
9996 return query;
9997 }
9998 if (isHtmlString(query)) {
9999 var tpl = document.createElement('template');
10000 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10001 return tpl.content.firstChild;
10002 }
10003 return document.querySelector(query);
10004 };
10005 const isHtmlString = arg => {
10006 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10007 return true;
10008 }
10009 return false;
10010 };
10011
10012 /**
10013 * Set attributes of an element
10014 *
10015 */
10016 const setAttr = (el, attrs) => {
10017 iterate(attrs, (val, attr) => {
10018 if (val == null) {
10019 el.removeAttribute(attr);
10020 } else {
10021 el.setAttribute(attr, '' + val);
10022 }
10023 });
10024 };
10025
10026 /**
10027 * Plugin: "drag_drop" (Tom Select)
10028 * Copyright (c) contributors
10029 *
10030 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10031 * file except in compliance with the License. You may obtain a copy of the License at:
10032 * http://www.apache.org/licenses/LICENSE-2.0
10033 *
10034 * Unless required by applicable law or agreed to in writing, software distributed under
10035 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10036 * ANY KIND, either express or implied. See the License for the specific language
10037 * governing permissions and limitations under the License.
10038 *
10039 */
10040
10041 const insertAfter = (referenceNode, newNode) => {
10042 var _referenceNode$parent;
10043 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
10044 };
10045 const insertBefore = (referenceNode, newNode) => {
10046 var _referenceNode$parent2;
10047 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
10048 };
10049 const isBefore = (referenceNode, newNode) => {
10050 do {
10051 var _newNode;
10052 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
10053 if (referenceNode == newNode) {
10054 return true;
10055 }
10056 } while (newNode && newNode.previousElementSibling);
10057 return false;
10058 };
10059 function plugin () {
10060 var self = this;
10061 if (self.settings.mode !== 'multi') return;
10062 var orig_lock = self.lock;
10063 var orig_unlock = self.unlock;
10064 let sortable = true;
10065 let drag_item;
10066
10067 /**
10068 * Add draggable attribute to item
10069 */
10070 self.hook('after', 'setupTemplates', () => {
10071 var orig_render_item = self.settings.render.item;
10072 self.settings.render.item = (data, escape) => {
10073 const item = getDom(orig_render_item.call(self, data, escape));
10074 setAttr(item, {
10075 'draggable': 'true'
10076 });
10077
10078 // prevent doc_mousedown (see tom-select.ts)
10079 const mousedown = evt => {
10080 if (!sortable) preventDefault(evt);
10081 evt.stopPropagation();
10082 };
10083 const dragStart = evt => {
10084 drag_item = item;
10085 setTimeout(() => {
10086 item.classList.add('ts-dragging');
10087 }, 0);
10088 };
10089 const dragOver = evt => {
10090 evt.preventDefault();
10091 item.classList.add('ts-drag-over');
10092 moveitem(item, drag_item);
10093 };
10094 const dragLeave = () => {
10095 item.classList.remove('ts-drag-over');
10096 };
10097 const moveitem = (targetitem, dragitem) => {
10098 if (dragitem === undefined) return;
10099 if (isBefore(dragitem, item)) {
10100 insertAfter(targetitem, dragitem);
10101 } else {
10102 insertBefore(targetitem, dragitem);
10103 }
10104 };
10105 const dragend = () => {
10106 var _drag_item;
10107 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
10108 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
10109 drag_item = undefined;
10110 var values = [];
10111 self.control.querySelectorAll(`[data-value]`).forEach(el => {
10112 if (el.dataset.value) {
10113 let value = el.dataset.value;
10114 if (value) {
10115 values.push(value);
10116 }
10117 }
10118 });
10119 self.setValue(values);
10120 };
10121 addEvent(item, 'mousedown', mousedown);
10122 addEvent(item, 'dragstart', dragStart);
10123 addEvent(item, 'dragenter', dragOver);
10124 addEvent(item, 'dragover', dragOver);
10125 addEvent(item, 'dragleave', dragLeave);
10126 addEvent(item, 'dragend', dragend);
10127 return item;
10128 };
10129 });
10130 self.hook('instead', 'lock', () => {
10131 sortable = false;
10132 return orig_lock.call(self);
10133 });
10134 self.hook('instead', 'unlock', () => {
10135 sortable = true;
10136 return orig_unlock.call(self);
10137 });
10138 }
10139
10140
10141 //# sourceMappingURL=plugin.js.map
10142
10143
10144 /***/ },
10145
10146 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
10147 /*!****************************************************************************!*\
10148 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
10149 \****************************************************************************/
10150 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10151
10152 "use strict";
10153 __webpack_require__.r(__webpack_exports__);
10154 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10155 /* harmony export */ "default": () => (/* binding */ plugin)
10156 /* harmony export */ });
10157 /**
10158 * Tom Select v2.6.2
10159 * Licensed under the Apache License, Version 2.0 (the "License");
10160 */
10161
10162 /**
10163 * Converts a scalar to its best string representation
10164 * for hash keys and HTML attribute values.
10165 *
10166 * Transformations:
10167 * 'str' -> 'str'
10168 * null -> ''
10169 * undefined -> ''
10170 * true -> '1'
10171 * false -> '0'
10172 * 0 -> '0'
10173 * 1 -> '1'
10174 *
10175 */
10176
10177 /**
10178 * Prevent default
10179 *
10180 */
10181 const preventDefault = (evt, stop = false) => {
10182 if (evt) {
10183 evt.preventDefault();
10184 if (stop) {
10185 evt.stopPropagation();
10186 }
10187 }
10188 };
10189
10190 /**
10191 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10192 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10193 *
10194 * param query should be {}
10195 */
10196 const getDom = query => {
10197 if (query.jquery) {
10198 return query[0];
10199 }
10200 if (query instanceof HTMLElement) {
10201 return query;
10202 }
10203 if (isHtmlString(query)) {
10204 var tpl = document.createElement('template');
10205 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10206 return tpl.content.firstChild;
10207 }
10208 return document.querySelector(query);
10209 };
10210 const isHtmlString = arg => {
10211 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10212 return true;
10213 }
10214 return false;
10215 };
10216
10217 /**
10218 * Plugin: "dropdown_header" (Tom Select)
10219 * Copyright (c) contributors
10220 *
10221 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10222 * file except in compliance with the License. You may obtain a copy of the License at:
10223 * http://www.apache.org/licenses/LICENSE-2.0
10224 *
10225 * Unless required by applicable law or agreed to in writing, software distributed under
10226 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10227 * ANY KIND, either express or implied. See the License for the specific language
10228 * governing permissions and limitations under the License.
10229 *
10230 */
10231
10232 function plugin (userOptions) {
10233 const self = this;
10234 const options = Object.assign({
10235 title: 'Untitled',
10236 headerClass: 'dropdown-header',
10237 titleRowClass: 'dropdown-header-title',
10238 labelClass: 'dropdown-header-label',
10239 closeClass: 'dropdown-header-close',
10240 html: data => {
10241 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
10242 }
10243 }, userOptions);
10244 self.on('initialize', () => {
10245 var header = getDom(options.html(options));
10246 var close_link = header.querySelector('.' + options.closeClass);
10247 if (close_link) {
10248 close_link.addEventListener('click', evt => {
10249 preventDefault(evt, true);
10250 self.close();
10251 });
10252 }
10253 self.dropdown.insertBefore(header, self.dropdown.firstChild);
10254 });
10255 }
10256
10257
10258 //# sourceMappingURL=plugin.js.map
10259
10260
10261 /***/ },
10262
10263 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
10264 /*!***************************************************************************!*\
10265 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/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.6.2
10276 * Licensed under the Apache License, Version 2.0 (the "License");
10277 */
10278
10279 const KEY_ESC = 27;
10280 const KEY_TAB = 9;
10281 // ctrl key or apple key for ma
10282
10283 /**
10284 * Converts a scalar to its best string representation
10285 * for hash keys and HTML attribute values.
10286 *
10287 * Transformations:
10288 * 'str' -> 'str'
10289 * null -> ''
10290 * undefined -> ''
10291 * true -> '1'
10292 * false -> '0'
10293 * 0 -> '0'
10294 * 1 -> '1'
10295 *
10296 */
10297
10298 /**
10299 * Prevent default
10300 *
10301 */
10302 const preventDefault = (evt, stop = false) => {
10303 if (evt) {
10304 evt.preventDefault();
10305 if (stop) {
10306 evt.stopPropagation();
10307 }
10308 }
10309 };
10310
10311 /**
10312 * Add event helper
10313 *
10314 */
10315 const addEvent = (target, type, callback, options) => {
10316 target.addEventListener(type, callback, options);
10317 };
10318
10319 /**
10320 * Iterates over arrays and hashes.
10321 *
10322 * ```
10323 * iterate(this.items, function(item, id) {
10324 * // invoked for each item
10325 * });
10326 * ```
10327 *
10328 */
10329 const iterate = (object, callback) => {
10330 if (Array.isArray(object)) {
10331 object.forEach(callback);
10332 } else {
10333 for (var key in object) {
10334 if (object.hasOwnProperty(key)) {
10335 callback(object[key], key);
10336 }
10337 }
10338 }
10339 };
10340
10341 /**
10342 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10343 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10344 *
10345 * param query should be {}
10346 */
10347 const getDom = query => {
10348 if (query.jquery) {
10349 return query[0];
10350 }
10351 if (query instanceof HTMLElement) {
10352 return query;
10353 }
10354 if (isHtmlString(query)) {
10355 var tpl = document.createElement('template');
10356 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10357 return tpl.content.firstChild;
10358 }
10359 return document.querySelector(query);
10360 };
10361 const isHtmlString = arg => {
10362 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10363 return true;
10364 }
10365 return false;
10366 };
10367
10368 /**
10369 * Add css classes
10370 *
10371 */
10372 const addClasses = (elmts, ...classes) => {
10373 var norm_classes = classesArray(classes);
10374 elmts = castAsArray(elmts);
10375 elmts.map(el => {
10376 norm_classes.map(cls => {
10377 el.classList.add(cls);
10378 });
10379 });
10380 };
10381
10382 /**
10383 * Return arguments
10384 *
10385 */
10386 const classesArray = args => {
10387 var classes = [];
10388 iterate(args, _classes => {
10389 if (typeof _classes === 'string') {
10390 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10391 }
10392 if (Array.isArray(_classes)) {
10393 classes = classes.concat(_classes);
10394 }
10395 });
10396 return classes.filter(Boolean);
10397 };
10398
10399 /**
10400 * Create an array from arg if it's not already an array
10401 *
10402 */
10403 const castAsArray = arg => {
10404 if (!Array.isArray(arg)) {
10405 arg = [arg];
10406 }
10407 return arg;
10408 };
10409
10410 /**
10411 * Plugin: "dropdown_input" (Tom Select)
10412 * Copyright (c) contributors
10413 *
10414 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10415 * file except in compliance with the License. You may obtain a copy of the License at:
10416 * http://www.apache.org/licenses/LICENSE-2.0
10417 *
10418 * Unless required by applicable law or agreed to in writing, software distributed under
10419 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10420 * ANY KIND, either express or implied. See the License for the specific language
10421 * governing permissions and limitations under the License.
10422 *
10423 */
10424
10425 function plugin () {
10426 const self = this;
10427 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
10428
10429 self.hook('before', 'setup', () => {
10430 var _self$input;
10431 self.focus_node = self.control;
10432 addClasses(self.control_input, 'dropdown-input');
10433 const div = getDom('<div class="dropdown-input-wrap">');
10434 div.append(self.control_input);
10435 self.dropdown.insertBefore(div, self.dropdown.firstChild);
10436
10437 // set a placeholder in the select control
10438 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
10439 placeholder.placeholder = self.settings.placeholder || '';
10440 self.control.append(placeholder);
10441 /**
10442 * TomSelect renders a custom control with a focusable <input class="items-placeholder">.
10443 * The source <select>'s aria-label is not automatically propagated to that input,
10444 * which triggers "Missing form label" accessibility warnings.
10445 * This helper copies the label from the <select> onto the generated input.
10446 */
10447 const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label');
10448 if (!label) return;
10449 placeholder.setAttribute('aria-label', label);
10450 });
10451 self.on('initialize', () => {
10452 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
10453 self.control_input.addEventListener('keydown', evt => {
10454 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
10455 switch (evt.keyCode) {
10456 case KEY_ESC:
10457 if (self.isOpen) {
10458 preventDefault(evt, true);
10459 self.close();
10460 }
10461 self.clearActiveItems();
10462 return;
10463 case KEY_TAB:
10464 self.focus_node.tabIndex = -1;
10465 break;
10466 }
10467 return self.onKeyDown.call(self, evt);
10468 });
10469 self.on('blur', () => {
10470 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
10471 });
10472
10473 // give the control_input focus when the dropdown is open
10474 self.on('dropdown_open', () => {
10475 self.control_input.focus();
10476 });
10477
10478 // prevent onBlur from closing when focus is on the control_input
10479 const orig_onBlur = self.onBlur;
10480 self.hook('instead', 'onBlur', evt => {
10481 if (evt && evt.relatedTarget == self.control_input) return;
10482 return orig_onBlur.call(self);
10483 });
10484 addEvent(self.control_input, 'blur', () => self.onBlur());
10485
10486 // return focus to control to allow further keyboard input
10487 self.hook('before', 'close', () => {
10488 if (!self.isOpen) return;
10489 self.focus_node.focus({
10490 preventScroll: true
10491 });
10492 });
10493 });
10494 }
10495
10496
10497 //# sourceMappingURL=plugin.js.map
10498
10499
10500 /***/ },
10501
10502 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
10503 /*!***************************************************************************!*\
10504 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
10505 \***************************************************************************/
10506 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10507
10508 "use strict";
10509 __webpack_require__.r(__webpack_exports__);
10510 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10511 /* harmony export */ "default": () => (/* binding */ plugin)
10512 /* harmony export */ });
10513 /**
10514 * Tom Select v2.6.2
10515 * Licensed under the Apache License, Version 2.0 (the "License");
10516 */
10517
10518 /**
10519 * Converts a scalar to its best string representation
10520 * for hash keys and HTML attribute values.
10521 *
10522 * Transformations:
10523 * 'str' -> 'str'
10524 * null -> ''
10525 * undefined -> ''
10526 * true -> '1'
10527 * false -> '0'
10528 * 0 -> '0'
10529 * 1 -> '1'
10530 *
10531 */
10532
10533 /**
10534 * Add event helper
10535 *
10536 */
10537 const addEvent = (target, type, callback, options) => {
10538 target.addEventListener(type, callback, options);
10539 };
10540
10541 /**
10542 * Plugin: "input_autogrow" (Tom Select)
10543 *
10544 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10545 * file except in compliance with the License. You may obtain a copy of the License at:
10546 * http://www.apache.org/licenses/LICENSE-2.0
10547 *
10548 * Unless required by applicable law or agreed to in writing, software distributed under
10549 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10550 * ANY KIND, either express or implied. See the License for the specific language
10551 * governing permissions and limitations under the License.
10552 *
10553 */
10554
10555 function plugin () {
10556 var self = this;
10557 self.on('initialize', () => {
10558 var test_input = document.createElement('span');
10559 var control = self.control_input;
10560 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10561 self.wrapper.appendChild(test_input);
10562 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10563 for (const style_name of transfer_styles) {
10564 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10565 test_input.style[style_name] = control.style[style_name];
10566 }
10567
10568 /**
10569 * Set the control width
10570 *
10571 */
10572 var resize = () => {
10573 test_input.textContent = control.value;
10574 control.style.width = test_input.clientWidth + 'px';
10575 };
10576 resize();
10577 self.on('update item_add item_remove', resize);
10578 addEvent(control, 'input', resize);
10579 addEvent(control, 'keyup', resize);
10580 addEvent(control, 'blur', resize);
10581 addEvent(control, 'update', resize);
10582 });
10583 }
10584
10585
10586 //# sourceMappingURL=plugin.js.map
10587
10588
10589 /***/ },
10590
10591 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10592 /*!****************************************************************************!*\
10593 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10594 \****************************************************************************/
10595 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10596
10597 "use strict";
10598 __webpack_require__.r(__webpack_exports__);
10599 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10600 /* harmony export */ "default": () => (/* binding */ plugin)
10601 /* harmony export */ });
10602 /**
10603 * Tom Select v2.6.2
10604 * Licensed under the Apache License, Version 2.0 (the "License");
10605 */
10606
10607 /**
10608 * Plugin: "no_active_items" (Tom Select)
10609 *
10610 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10611 * file except in compliance with the License. You may obtain a copy of the License at:
10612 * http://www.apache.org/licenses/LICENSE-2.0
10613 *
10614 * Unless required by applicable law or agreed to in writing, software distributed under
10615 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10616 * ANY KIND, either express or implied. See the License for the specific language
10617 * governing permissions and limitations under the License.
10618 *
10619 */
10620
10621 function plugin () {
10622 this.hook('instead', 'setActiveItem', () => {});
10623 this.hook('instead', 'selectAll', () => {});
10624 }
10625
10626
10627 //# sourceMappingURL=plugin.js.map
10628
10629
10630 /***/ },
10631
10632 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10633 /*!********************************************************************************!*\
10634 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10635 \********************************************************************************/
10636 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10637
10638 "use strict";
10639 __webpack_require__.r(__webpack_exports__);
10640 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10641 /* harmony export */ "default": () => (/* binding */ plugin)
10642 /* harmony export */ });
10643 /**
10644 * Tom Select v2.6.2
10645 * Licensed under the Apache License, Version 2.0 (the "License");
10646 */
10647
10648 /**
10649 * Plugin: "input_autogrow" (Tom Select)
10650 *
10651 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10652 * file except in compliance with the License. You may obtain a copy of the License at:
10653 * http://www.apache.org/licenses/LICENSE-2.0
10654 *
10655 * Unless required by applicable law or agreed to in writing, software distributed under
10656 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10657 * ANY KIND, either express or implied. See the License for the specific language
10658 * governing permissions and limitations under the License.
10659 *
10660 */
10661
10662 function plugin () {
10663 var self = this;
10664 var orig_deleteSelection = self.deleteSelection;
10665 this.hook('instead', 'deleteSelection', evt => {
10666 if (self.activeItems.length) {
10667 return orig_deleteSelection.call(self, evt);
10668 }
10669 return false;
10670 });
10671 }
10672
10673
10674 //# sourceMappingURL=plugin.js.map
10675
10676
10677 /***/ },
10678
10679 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10680 /*!*****************************************************************************!*\
10681 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10682 \*****************************************************************************/
10683 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10684
10685 "use strict";
10686 __webpack_require__.r(__webpack_exports__);
10687 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10688 /* harmony export */ "default": () => (/* binding */ plugin)
10689 /* harmony export */ });
10690 /**
10691 * Tom Select v2.6.2
10692 * Licensed under the Apache License, Version 2.0 (the "License");
10693 */
10694
10695 const KEY_LEFT = 37;
10696 const KEY_RIGHT = 39;
10697 // ctrl key or apple key for ma
10698
10699 /**
10700 * Get the closest node to the evt.target matching the selector
10701 * Stops at wrapper
10702 *
10703 */
10704 const parentMatch = (target, selector, wrapper) => {
10705 while (target && target.matches) {
10706 if (target.matches(selector)) {
10707 return target;
10708 }
10709 target = target.parentNode;
10710 }
10711 };
10712
10713 /**
10714 * Get the index of an element amongst sibling nodes of the same type
10715 *
10716 */
10717 const nodeIndex = (el, amongst) => {
10718 if (!el) return -1;
10719 amongst = amongst || el.nodeName;
10720 var i = 0;
10721 while (el = el.previousElementSibling) {
10722 if (el.matches(amongst)) {
10723 i++;
10724 }
10725 }
10726 return i;
10727 };
10728
10729 /**
10730 * Plugin: "optgroup_columns" (Tom Select.js)
10731 * Copyright (c) contributors
10732 *
10733 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10734 * file except in compliance with the License. You may obtain a copy of the License at:
10735 * http://www.apache.org/licenses/LICENSE-2.0
10736 *
10737 * Unless required by applicable law or agreed to in writing, software distributed under
10738 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10739 * ANY KIND, either express or implied. See the License for the specific language
10740 * governing permissions and limitations under the License.
10741 *
10742 */
10743
10744 function plugin () {
10745 var self = this;
10746 var orig_keydown = self.onKeyDown;
10747 self.hook('instead', 'onKeyDown', evt => {
10748 var index, option, options, optgroup;
10749 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10750 return orig_keydown.call(self, evt);
10751 }
10752 self.ignoreHover = true;
10753 optgroup = parentMatch(self.activeOption, '[data-group]');
10754 index = nodeIndex(self.activeOption, '[data-selectable]');
10755 if (!optgroup) {
10756 return;
10757 }
10758 if (evt.keyCode === KEY_LEFT) {
10759 optgroup = optgroup.previousSibling;
10760 } else {
10761 optgroup = optgroup.nextSibling;
10762 }
10763 if (!optgroup) {
10764 return;
10765 }
10766 options = optgroup.querySelectorAll('[data-selectable]');
10767 option = options[Math.min(options.length - 1, index)];
10768 if (option) {
10769 self.setActiveOption(option);
10770 }
10771 });
10772 }
10773
10774
10775 //# sourceMappingURL=plugin.js.map
10776
10777
10778 /***/ },
10779
10780 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10781 /*!**************************************************************************!*\
10782 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10783 \**************************************************************************/
10784 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10785
10786 "use strict";
10787 __webpack_require__.r(__webpack_exports__);
10788 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10789 /* harmony export */ "default": () => (/* binding */ plugin)
10790 /* harmony export */ });
10791 /**
10792 * Tom Select v2.6.2
10793 * Licensed under the Apache License, Version 2.0 (the "License");
10794 */
10795
10796 /**
10797 * Converts a scalar to its best string representation
10798 * for hash keys and HTML attribute values.
10799 *
10800 * Transformations:
10801 * 'str' -> 'str'
10802 * null -> ''
10803 * undefined -> ''
10804 * true -> '1'
10805 * false -> '0'
10806 * 0 -> '0'
10807 * 1 -> '1'
10808 *
10809 */
10810
10811 /**
10812 * Prevent default
10813 *
10814 */
10815 const preventDefault = (evt, stop = false) => {
10816 if (evt) {
10817 evt.preventDefault();
10818 if (stop) {
10819 evt.stopPropagation();
10820 }
10821 }
10822 };
10823
10824 /**
10825 * Add event helper
10826 *
10827 */
10828 const addEvent = (target, type, callback, options) => {
10829 target.addEventListener(type, callback, options);
10830 };
10831
10832 /**
10833 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10834 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10835 *
10836 * param query should be {}
10837 */
10838 const getDom = query => {
10839 if (query.jquery) {
10840 return query[0];
10841 }
10842 if (query instanceof HTMLElement) {
10843 return query;
10844 }
10845 if (isHtmlString(query)) {
10846 var tpl = document.createElement('template');
10847 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10848 return tpl.content.firstChild;
10849 }
10850 return document.querySelector(query);
10851 };
10852 const isHtmlString = arg => {
10853 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10854 return true;
10855 }
10856 return false;
10857 };
10858
10859 /**
10860 * Plugin: "remove_button" (Tom Select)
10861 * Copyright (c) contributors
10862 *
10863 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10864 * file except in compliance with the License. You may obtain a copy of the License at:
10865 * http://www.apache.org/licenses/LICENSE-2.0
10866 *
10867 * Unless required by applicable law or agreed to in writing, software distributed under
10868 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10869 * ANY KIND, either express or implied. See the License for the specific language
10870 * governing permissions and limitations under the License.
10871 *
10872 */
10873
10874 function plugin (userOptions) {
10875 const self = this;
10876 const options = Object.assign({
10877 label: '×',
10878 title: 'Remove',
10879 className: 'remove',
10880 tabindex: -1,
10881 role: 'button',
10882 html: data => {
10883 var _data$tabindex;
10884 const el = document.createElement('div');
10885 el.className = data.className || '';
10886 el.title = data.title || '';
10887 el.setAttribute('role', data.role || 'button');
10888 el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1;
10889 el.textContent = data.label || '';
10890 return el;
10891 }
10892 }, userOptions);
10893 self.hook('after', 'setupTemplates', () => {
10894 var orig_render_item = self.settings.render.item;
10895 self.settings.render.item = (data, escape) => {
10896 var item = getDom(orig_render_item.call(self, data, escape));
10897 var close_button = getDom(options.html(options));
10898 item.appendChild(close_button);
10899 addEvent(close_button, 'mousedown', evt => {
10900 preventDefault(evt, true);
10901 });
10902 addEvent(close_button, 'click', evt => {
10903 if (self.isLocked) return;
10904
10905 // propagating will trigger the dropdown to show for single mode
10906 preventDefault(evt, true);
10907 if (self.isLocked) return;
10908 if (!self.shouldDelete([item], evt)) return;
10909 self.removeItem(item);
10910 self.refreshOptions(false);
10911 self.inputState();
10912 });
10913 return item;
10914 };
10915 });
10916 }
10917
10918
10919 //# sourceMappingURL=plugin.js.map
10920
10921
10922 /***/ },
10923
10924 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10925 /*!*********************************************************************************!*\
10926 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10927 \*********************************************************************************/
10928 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10929
10930 "use strict";
10931 __webpack_require__.r(__webpack_exports__);
10932 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10933 /* harmony export */ "default": () => (/* binding */ plugin)
10934 /* harmony export */ });
10935 /**
10936 * Tom Select v2.6.2
10937 * Licensed under the Apache License, Version 2.0 (the "License");
10938 */
10939
10940 /**
10941 * Plugin: "restore_on_backspace" (Tom Select)
10942 * Copyright (c) contributors
10943 *
10944 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10945 * file except in compliance with the License. You may obtain a copy of the License at:
10946 * http://www.apache.org/licenses/LICENSE-2.0
10947 *
10948 * Unless required by applicable law or agreed to in writing, software distributed under
10949 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10950 * ANY KIND, either express or implied. See the License for the specific language
10951 * governing permissions and limitations under the License.
10952 *
10953 */
10954
10955 function plugin (userOptions) {
10956 const self = this;
10957 const options = Object.assign({
10958 text: option => {
10959 return option[self.settings.labelField];
10960 }
10961 }, userOptions);
10962 self.on('item_remove', function (value) {
10963 if (!self.isFocused) {
10964 return;
10965 }
10966 if (self.control_input.value.trim() === '') {
10967 var option = self.options[value];
10968 if (option) {
10969 self.setTextboxValue(options.text.call(self, option));
10970 }
10971 }
10972 });
10973 }
10974
10975
10976 //# sourceMappingURL=plugin.js.map
10977
10978
10979 /***/ },
10980
10981 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10982 /*!***************************************************************************!*\
10983 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10984 \***************************************************************************/
10985 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10986
10987 "use strict";
10988 __webpack_require__.r(__webpack_exports__);
10989 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10990 /* harmony export */ "default": () => (/* binding */ plugin)
10991 /* harmony export */ });
10992 /**
10993 * Tom Select v2.6.2
10994 * Licensed under the Apache License, Version 2.0 (the "License");
10995 */
10996
10997 /**
10998 * Converts a scalar to its best string representation
10999 * for hash keys and HTML attribute values.
11000 *
11001 * Transformations:
11002 * 'str' -> 'str'
11003 * null -> ''
11004 * undefined -> ''
11005 * true -> '1'
11006 * false -> '0'
11007 * 0 -> '0'
11008 * 1 -> '1'
11009 *
11010 */
11011
11012 /**
11013 * Iterates over arrays and hashes.
11014 *
11015 * ```
11016 * iterate(this.items, function(item, id) {
11017 * // invoked for each item
11018 * });
11019 * ```
11020 *
11021 */
11022 const iterate = (object, callback) => {
11023 if (Array.isArray(object)) {
11024 object.forEach(callback);
11025 } else {
11026 for (var key in object) {
11027 if (object.hasOwnProperty(key)) {
11028 callback(object[key], key);
11029 }
11030 }
11031 }
11032 };
11033
11034 /**
11035 * Add css classes
11036 *
11037 */
11038 const addClasses = (elmts, ...classes) => {
11039 var norm_classes = classesArray(classes);
11040 elmts = castAsArray(elmts);
11041 elmts.map(el => {
11042 norm_classes.map(cls => {
11043 el.classList.add(cls);
11044 });
11045 });
11046 };
11047
11048 /**
11049 * Return arguments
11050 *
11051 */
11052 const classesArray = args => {
11053 var classes = [];
11054 iterate(args, _classes => {
11055 if (typeof _classes === 'string') {
11056 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
11057 }
11058 if (Array.isArray(_classes)) {
11059 classes = classes.concat(_classes);
11060 }
11061 });
11062 return classes.filter(Boolean);
11063 };
11064
11065 /**
11066 * Create an array from arg if it's not already an array
11067 *
11068 */
11069 const castAsArray = arg => {
11070 if (!Array.isArray(arg)) {
11071 arg = [arg];
11072 }
11073 return arg;
11074 };
11075
11076 /**
11077 * Plugin: "virtual_scroll" (Tom Select)
11078 * Copyright (c) contributors
11079 *
11080 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
11081 * file except in compliance with the License. You may obtain a copy of the License at:
11082 * http://www.apache.org/licenses/LICENSE-2.0
11083 *
11084 * Unless required by applicable law or agreed to in writing, software distributed under
11085 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11086 * ANY KIND, either express or implied. See the License for the specific language
11087 * governing permissions and limitations under the License.
11088 *
11089 */
11090
11091 function plugin () {
11092 const self = this;
11093 const orig_canLoad = self.canLoad;
11094 const orig_clearActiveOption = self.clearActiveOption;
11095 const orig_loadCallback = self.loadCallback;
11096 var pagination = {};
11097 var dropdown_content;
11098 var loading_more = false;
11099 var load_more_opt;
11100 var default_values = [];
11101 var default_values_loaded = false;
11102 var default_pagination;
11103 var default_options = [];
11104 var html_values = [];
11105 if (!self.settings.shouldLoadMore) {
11106 // return true if additional results should be loaded
11107 self.settings.shouldLoadMore = () => {
11108 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
11109 if (scroll_percent > 0.9) {
11110 return true;
11111 }
11112 if (self.activeOption) {
11113 var selectable = self.selectable();
11114 var index = Array.from(selectable).indexOf(self.activeOption);
11115 if (index >= selectable.length - 2) {
11116 return true;
11117 }
11118 }
11119 return false;
11120 };
11121 }
11122 if (!self.settings.firstUrl) {
11123 throw 'virtual_scroll plugin requires a firstUrl() method';
11124 }
11125
11126 // in order for virtual scrolling to work,
11127 // options need to be ordered the same way they're returned from the remote data source
11128 self.settings.sortField = [{
11129 field: '$order'
11130 }, {
11131 field: '$score'
11132 }];
11133
11134 // can we load more results for given query?
11135 const canLoadMore = query => {
11136 if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
11137 return false;
11138 }
11139 if (query in pagination && pagination[query]) {
11140 return true;
11141 }
11142 return false;
11143 };
11144 const clearFilter = (option, value) => {
11145 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
11146 return true;
11147 }
11148 return false;
11149 };
11150
11151 // set the next url that will be
11152 self.setNextUrl = (value, next_url) => {
11153 pagination[value] = next_url;
11154 };
11155
11156 // getUrl() to be used in settings.load()
11157 self.getUrl = query => {
11158 if (query in pagination) {
11159 const next_url = pagination[query];
11160 pagination[query] = false;
11161 return next_url;
11162 }
11163
11164 // if the user goes back to a previous query
11165 // we need to load the first page again
11166 self.clearPagination();
11167 return self.settings.firstUrl.call(self, query);
11168 };
11169
11170 // clear pagination
11171 self.clearPagination = () => {
11172 pagination = {};
11173 };
11174
11175 // don't clear the active option (and cause unwanted dropdown scroll)
11176 // while loading more results
11177 self.hook('instead', 'clearActiveOption', () => {
11178 if (loading_more) {
11179 return;
11180 }
11181 return orig_clearActiveOption.call(self);
11182 });
11183
11184 // override the canLoad method
11185 self.hook('instead', 'canLoad', query => {
11186 // first time the query has been seen
11187 if (!(query in pagination)) {
11188 return orig_canLoad.call(self, query);
11189 }
11190 return canLoadMore(query);
11191 });
11192
11193 // wrap the load
11194 self.hook('instead', 'loadCallback', (options, optgroups) => {
11195 if (!loading_more) {
11196 // When searching (non-empty query), keep selected items and HTML default options,
11197 // but remove preloaded remote options so they don't bleed into search results.
11198 // For empty query, use clearFilter (keeps default_values + items).
11199 const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter;
11200 self.clearOptions(activeFilter);
11201 } else if (load_more_opt) {
11202 const first_option = options[0];
11203 if (first_option !== undefined) {
11204 load_more_opt.dataset.value = first_option[self.settings.valueField];
11205 }
11206 }
11207 orig_loadCallback.call(self, options, optgroups);
11208
11209 // After the initial preload (empty query), snapshot default_values and option objects
11210 // so they can be restored when the user clears their search.
11211 if (!loading_more && !default_values_loaded) {
11212 default_values_loaded = true;
11213 if (self.lastValue === '') {
11214 default_values = Object.keys(self.options);
11215 default_pagination = pagination[''];
11216 default_options = Object.values(self.options);
11217 }
11218 }
11219 loading_more = false;
11220 });
11221
11222 // as the “loading_more” element will be removed from the dropdown,
11223 // we activate the previous option if needed
11224 // to avoid the dropdown being scrolled back to the first one
11225 self.hook('before', 'refreshOptions', () => {
11226 if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) {
11227 self.setActiveOption(self.activeOption.previousElementSibling);
11228 }
11229 });
11230
11231 // add templates to dropdown
11232 // loading_more if we have another url in the queue
11233 // no_more_results if we don't have another url in the queue
11234 self.hook('after', 'refreshOptions', () => {
11235 const query = self.lastValue;
11236 var option;
11237 if (canLoadMore(query)) {
11238 option = self.render('loading_more', {
11239 query: query
11240 });
11241 if (option) {
11242 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
11243 load_more_opt = option;
11244 }
11245 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
11246 option = self.render('no_more_results', {
11247 query: query
11248 });
11249 }
11250 if (option) {
11251 addClasses(option, self.settings.optionClass);
11252 dropdown_content.append(option);
11253 }
11254 });
11255
11256 // Restore preloaded options and pagination when clearing search
11257 const restoreDefaults = () => {
11258 if (!default_values_loaded) {
11259 return;
11260 }
11261 // Re-add preloaded option objects (clearOptions can only remove, not restore)
11262 self.addOptions(default_options);
11263 // Remove any search results that are not part of the preloaded defaults
11264 self.clearOptions(clearFilter);
11265 if (default_pagination) {
11266 pagination[''] = default_pagination;
11267 }
11268 };
11269 self.on('type', query => {
11270 if (query === '') {
11271 restoreDefaults();
11272 self.refreshOptions(false);
11273 }
11274 });
11275 self.on('dropdown_close', restoreDefaults);
11276
11277 // add scroll listener and default templates
11278 self.on('initialize', () => {
11279 html_values = Object.keys(self.options);
11280 default_values = Object.keys(self.options);
11281 dropdown_content = self.dropdown_content;
11282
11283 // default templates
11284 self.settings.render = Object.assign({}, {
11285 loading_more: () => {
11286 return `<div class="loading-more-results">Loading more results ... </div>`;
11287 },
11288 no_more_results: () => {
11289 return `<div class="no-more-results">No more results</div>`;
11290 }
11291 }, self.settings.render);
11292
11293 // watch dropdown content scroll position
11294 dropdown_content.addEventListener('scroll', () => {
11295 if (!self.settings.shouldLoadMore.call(self)) {
11296 return;
11297 }
11298
11299 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
11300 if (!canLoadMore(self.lastValue)) {
11301 return;
11302 }
11303
11304 // don't call load() too much
11305 if (loading_more) return;
11306 loading_more = true;
11307 self.load.call(self, self.lastValue);
11308 });
11309 });
11310 }
11311
11312
11313 //# sourceMappingURL=plugin.js.map
11314
11315
11316 /***/ },
11317
11318 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
11319 /*!*****************************************************************!*\
11320 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
11321 \*****************************************************************/
11322 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11323
11324 "use strict";
11325 __webpack_require__.r(__webpack_exports__);
11326 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11327 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11328 /* harmony export */ });
11329 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
11330 /* 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");
11331 /* 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");
11332 /* 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");
11333 /* 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");
11334 /* 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");
11335 /* 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");
11336 /* 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");
11337 /* 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");
11338 /* 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");
11339 /* 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");
11340 /* 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");
11341 /* 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");
11342 /* 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");
11343 /* 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");
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
11360 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
11361 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
11362 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
11363 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
11364 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
11365 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
11366 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
11367 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
11368 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
11369 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
11370 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
11371 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
11372 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
11373 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
11374 //# sourceMappingURL=tom-select.complete.js.map
11375
11376 /***/ },
11377
11378 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
11379 /*!********************************************************!*\
11380 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
11381 \********************************************************/
11382 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11383
11384 "use strict";
11385 __webpack_require__.r(__webpack_exports__);
11386 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11387 /* harmony export */ "default": () => (/* binding */ TomSelect)
11388 /* harmony export */ });
11389 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
11390 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
11391 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
11392 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
11393 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
11394 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
11395 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
11396 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
11397 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407 var instance_i = 0;
11408 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
11409 constructor(input_arg, user_settings) {
11410 super();
11411 this.order = 0;
11412 this.isOpen = false;
11413 this.isDisabled = false;
11414 this.isReadOnly = false;
11415 this.isInvalid = false; // @deprecated 1.8
11416 this.isValid = true;
11417 this.isLocked = false;
11418 this.isFocused = false;
11419 this.isInputHidden = false;
11420 this.isSetup = false;
11421 this.isDropdownContentStale = true;
11422 this.ignoreFocus = false;
11423 this.ignoreHover = false;
11424 this.hasOptions = false;
11425 this.lastValue = '';
11426 this.caretPos = 0;
11427 this.loading = 0;
11428 this.loadedSearches = {};
11429 this.activeOption = null;
11430 this.activeItems = [];
11431 this.optgroups = {};
11432 this.options = {};
11433 this.userOptions = {};
11434 this.items = [];
11435 this.refreshTimeout = null;
11436 instance_i++;
11437 var dir;
11438 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
11439 if (input.tomselect) {
11440 throw new Error('Tom Select already initialized on this element');
11441 }
11442 input.tomselect = this;
11443 // detect rtl environment
11444 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
11445 dir = computedStyle.getPropertyValue('direction');
11446 // setup default state
11447 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
11448 this.settings = settings;
11449 this.input = input;
11450 this.tabIndex = input.tabIndex || 0;
11451 this.is_select_tag = input.tagName.toLowerCase() === 'select';
11452 this.rtl = /rtl/i.test(dir);
11453 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
11454 this.isRequired = input.required;
11455 // search system
11456 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
11457 // option-dependent defaults
11458 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
11459 if (typeof settings.hideSelected !== 'boolean') {
11460 settings.hideSelected = settings.mode === 'multi';
11461 }
11462 if (typeof settings.hidePlaceholder !== 'boolean') {
11463 settings.hidePlaceholder = settings.mode !== 'multi';
11464 }
11465 // set up createFilter callback
11466 var filter = settings.createFilter;
11467 if (typeof filter !== 'function') {
11468 if (typeof filter === 'string') {
11469 filter = new RegExp(filter);
11470 }
11471 if (filter instanceof RegExp) {
11472 settings.createFilter = (input) => filter.test(input);
11473 }
11474 else {
11475 settings.createFilter = (value) => {
11476 return this.settings.duplicates || !this.options[value];
11477 };
11478 }
11479 }
11480 this.initializePlugins(settings.plugins);
11481 this.setupCallbacks();
11482 this.setupTemplates();
11483 // Create all elements
11484 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
11485 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
11486 const dropdown = this._render('dropdown');
11487 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
11488 const classes = this.input.getAttribute('class') || '';
11489 const inputMode = settings.mode;
11490 var control_input;
11491 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
11492 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
11493 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
11494 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
11495 if (settings.copyClassesToDropdown) {
11496 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
11497 }
11498 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
11499 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
11500 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
11501 // default controlInput
11502 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
11503 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
11504 // set attributes
11505 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
11506 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
11507 if (input.getAttribute(attr)) {
11508 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
11509 }
11510 });
11511 control_input.tabIndex = -1;
11512 control.appendChild(control_input);
11513 this.focus_node = control_input;
11514 // dom element
11515 }
11516 else if (settings.controlInput) {
11517 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
11518 this.focus_node = control_input;
11519 }
11520 else {
11521 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
11522 this.focus_node = control;
11523 }
11524 this.wrapper = wrapper;
11525 this.dropdown = dropdown;
11526 this.dropdown_content = dropdown_content;
11527 this.control = control;
11528 this.control_input = control_input;
11529 this.setup();
11530 }
11531 /**
11532 * set up event bindings.
11533 *
11534 */
11535 setup() {
11536 const self = this;
11537 const settings = self.settings;
11538 const control_input = self.control_input;
11539 const dropdown = self.dropdown;
11540 const dropdown_content = self.dropdown_content;
11541 const wrapper = self.wrapper;
11542 const control = self.control;
11543 const input = self.input;
11544 const focus_node = self.focus_node;
11545 const passive_event = { passive: true };
11546 const listboxId = self.inputId + '-ts-dropdown';
11547 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
11548 id: listboxId
11549 });
11550 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
11551 role: 'combobox',
11552 'aria-haspopup': 'listbox',
11553 'aria-expanded': 'false',
11554 'aria-controls': listboxId
11555 });
11556 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
11557 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
11558 const label = document.querySelector(query);
11559 const label_click = self.focus.bind(self);
11560 if (label) {
11561 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
11562 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
11563 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
11564 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
11565 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11566 }
11567 wrapper.style.width = input.style.width;
11568 wrapper.style.minWidth = input.style.minWidth;
11569 wrapper.style.maxWidth = input.style.maxWidth;
11570 if (self.plugins.names.length) {
11571 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11572 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11573 }
11574 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11575 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11576 }
11577 if (settings.placeholder) {
11578 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11579 }
11580 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11581 if (!settings.splitOn && settings.delimiter) {
11582 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11583 }
11584 // debounce user defined load() if loadThrottle > 0
11585 // after initializePlugins() so plugins can create/modify user defined loaders
11586 if (settings.load && settings.loadThrottle) {
11587 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11588 }
11589 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11590 self.ignoreHover = false;
11591 });
11592 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11593 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11594 if (target_match)
11595 self.onOptionHover(e, target_match);
11596 }, { capture: true });
11597 // clicking on an option should select it
11598 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11599 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11600 if (option) {
11601 self.onOptionSelect(evt, option);
11602 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11603 }
11604 });
11605 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11606 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11607 if (target_match && self.onItemSelect(evt, target_match)) {
11608 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11609 return;
11610 }
11611 // retain focus (see control_input mousedown)
11612 if (control_input.value != '') {
11613 return;
11614 }
11615 self.onClick();
11616 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11617 });
11618 // keydown on focus_node for arrow_down/arrow_up
11619 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11620 // keypress and input/keyup
11621 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11622 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11623 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11624 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11625 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11626 const doc_mousedown = (evt) => {
11627 // blur if target is outside of this instance
11628 // dropdown is not always inside wrapper
11629 const target = evt.composedPath()[0];
11630 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11631 if (self.isFocused) {
11632 self.blur();
11633 }
11634 self.inputState();
11635 return;
11636 }
11637 // retain focus by preventing native handling. if the
11638 // event target is the input it should not be modified.
11639 // otherwise, text selection within the input won't work.
11640 // Fixes bug #212 which is no covered by tests
11641 if (target == control_input && self.isOpen) {
11642 evt.stopPropagation();
11643 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11644 }
11645 else {
11646 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11647 }
11648 };
11649 const win_scroll = () => {
11650 if (self.isOpen) {
11651 self.positionDropdown();
11652 }
11653 };
11654 const input_invalid = () => {
11655 if (self.isValid) {
11656 self.isValid = false;
11657 self.isInvalid = true;
11658 self.refreshState();
11659 }
11660 };
11661 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid);
11662 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11663 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11664 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11665 this._destroy = () => {
11666 input.removeEventListener('invalid', input_invalid);
11667 document.removeEventListener('mousedown', doc_mousedown);
11668 window.removeEventListener('scroll', win_scroll);
11669 window.removeEventListener('resize', win_scroll);
11670 if (label)
11671 label.removeEventListener('click', label_click);
11672 };
11673 // store original html and tab index so that they can be
11674 // restored when the destroy() method is called.
11675 this.revertSettings = {
11676 innerHTML: input.innerHTML,
11677 tabIndex: input.tabIndex
11678 };
11679 input.tabIndex = -1;
11680 input.insertAdjacentElement('afterend', self.wrapper);
11681 self.sync(false);
11682 settings.items = [];
11683 delete settings.optgroups;
11684 delete settings.options;
11685 self.refreshItems();
11686 self.close(false);
11687 self.inputState();
11688 self.isSetup = true;
11689 self.on('change', this.onChange);
11690 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11691 self.trigger('initialize');
11692 // preload options
11693 if (settings.preload === true) {
11694 self.preload();
11695 }
11696 }
11697 /**
11698 * Register options and optgroups
11699 *
11700 */
11701 setupOptions(options = [], optgroups = []) {
11702 // build options table
11703 this.addOptions(options);
11704 // build optgroup table
11705 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11706 this.registerOptionGroup(optgroup);
11707 });
11708 }
11709 /**
11710 * Sets up default rendering functions.
11711 */
11712 setupTemplates() {
11713 var self = this;
11714 var field_label = self.settings.labelField;
11715 var field_optgroup = self.settings.optgroupLabelField;
11716 var templates = {
11717 'optgroup': (data) => {
11718 let optgroup = document.createElement('div');
11719 optgroup.className = 'optgroup';
11720 optgroup.appendChild(data.options);
11721 return optgroup;
11722 },
11723 'optgroup_header': (data, escape) => {
11724 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11725 },
11726 'option': (data, escape) => {
11727 return '<div>' + escape(data[field_label]) + '</div>';
11728 },
11729 'item': (data, escape) => {
11730 return '<div>' + escape(data[field_label]) + '</div>';
11731 },
11732 'option_create': (data, escape) => {
11733 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11734 },
11735 'no_results': () => {
11736 return '<div class="no-results">No results found</div>';
11737 },
11738 'loading': () => {
11739 return '<div class="spinner"></div>';
11740 },
11741 'not_loading': () => { },
11742 'dropdown': () => {
11743 return '<div></div>';
11744 }
11745 };
11746 self.settings.render = Object.assign({}, templates, self.settings.render);
11747 }
11748 /**
11749 * Maps fired events to callbacks provided
11750 * in the settings used when creating the control.
11751 */
11752 setupCallbacks() {
11753 var key, fn;
11754 var callbacks = {
11755 'initialize': 'onInitialize',
11756 'change': 'onChange',
11757 'item_add': 'onItemAdd',
11758 'item_remove': 'onItemRemove',
11759 'item_select': 'onItemSelect',
11760 'clear': 'onClear',
11761 'option_add': 'onOptionAdd',
11762 'option_remove': 'onOptionRemove',
11763 'option_clear': 'onOptionClear',
11764 'optgroup_add': 'onOptionGroupAdd',
11765 'optgroup_remove': 'onOptionGroupRemove',
11766 'optgroup_clear': 'onOptionGroupClear',
11767 'dropdown_open': 'onDropdownOpen',
11768 'dropdown_close': 'onDropdownClose',
11769 'type': 'onType',
11770 'load': 'onLoad',
11771 'focus': 'onFocus',
11772 'blur': 'onBlur'
11773 };
11774 for (key in callbacks) {
11775 fn = this.settings[callbacks[key]];
11776 if (fn)
11777 this.on(key, fn);
11778 }
11779 }
11780 /**
11781 * Sync the Tom Select instance with the original input or select
11782 *
11783 */
11784 sync(get_settings = true) {
11785 const self = this;
11786 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings;
11787 self.setupOptions(settings.options, settings.optgroups);
11788 self.setValue(settings.items || [], true); // silent prevents recursion
11789 if (self.input.disabled) {
11790 self.disable();
11791 }
11792 else if (self.input.readOnly) {
11793 self.setReadOnly(true);
11794 }
11795 else {
11796 self.enable(); //sets tabIndex
11797 }
11798 self.lastQuery = null; // so updated options will be displayed in dropdown
11799 }
11800 /**
11801 * Triggered when the main control element
11802 * has a click event.
11803 *
11804 */
11805 onClick() {
11806 var self = this;
11807 if (self.activeItems.length > 0) {
11808 self.clearActiveItems();
11809 self.focus();
11810 return;
11811 }
11812 if (self.isFocused && self.isOpen) {
11813 self.blur();
11814 }
11815 else {
11816 self.focus();
11817 }
11818 }
11819 /**
11820 * @deprecated v1.7
11821 *
11822 */
11823 onMouseDown() { }
11824 /**
11825 * Triggered when the value of the control has been changed.
11826 * This should propagate the event to the original DOM
11827 * input / select element.
11828 */
11829 onChange() {
11830 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11831 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11832 }
11833 /**
11834 * Triggered on <input> paste.
11835 *
11836 */
11837 onPaste(e) {
11838 var self = this;
11839 if (self.isInputHidden || self.isLocked) {
11840 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11841 return;
11842 }
11843 // If a regex or string is included, this will split the pasted
11844 // input and create Items for each separate value
11845 if (!self.settings.splitOn) {
11846 return;
11847 }
11848 // Wait for pasted text to be recognized in value
11849 setTimeout(() => {
11850 var pastedText = self.inputValue();
11851 if (!pastedText.match(self.settings.splitOn)) {
11852 return;
11853 }
11854 var splitInput = pastedText.trim().split(self.settings.splitOn);
11855 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11856 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11857 if (hash) {
11858 if (this.options[piece]) {
11859 self.addItem(piece);
11860 }
11861 else {
11862 self.createItem(piece);
11863 }
11864 }
11865 });
11866 }, 0);
11867 }
11868 /**
11869 * Triggered on <input> keypress.
11870 *
11871 */
11872 onKeyPress(e) {
11873 var self = this;
11874 if (self.isLocked) {
11875 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11876 return;
11877 }
11878 var character = String.fromCharCode(e.keyCode || e.which);
11879 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11880 self.createItem();
11881 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11882 return;
11883 }
11884 }
11885 /**
11886 * Triggered on <input> keydown.
11887 *
11888 */
11889 onKeyDown(e) {
11890 var self = this;
11891 self.ignoreHover = true;
11892 if (self.isLocked) {
11893 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11894 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11895 }
11896 return;
11897 }
11898 switch (e.keyCode) {
11899 // ctrl+A: select all
11900 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11901 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11902 if (self.control_input.value == '') {
11903 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11904 self.selectAll();
11905 return;
11906 }
11907 }
11908 break;
11909 // esc: close dropdown
11910 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11911 if (self.isOpen) {
11912 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11913 self.close();
11914 }
11915 self.clearActiveItems();
11916 return;
11917 // down: open dropdown or move selection down
11918 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11919 if (!self.isOpen && self.hasOptions) {
11920 self.open();
11921 }
11922 else if (self.activeOption) {
11923 let next = self.getAdjacent(self.activeOption, 1);
11924 if (next)
11925 self.setActiveOption(next);
11926 }
11927 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11928 return;
11929 // up: move selection up
11930 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11931 if (self.activeOption) {
11932 let prev = self.getAdjacent(self.activeOption, -1);
11933 if (prev)
11934 self.setActiveOption(prev);
11935 }
11936 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11937 return;
11938 // return: select active option
11939 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11940 if (self.canSelect(self.activeOption)) {
11941 self.onOptionSelect(e, self.activeOption);
11942 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11943 // if the option_create=null, the dropdown might be closed
11944 }
11945 else if (self.settings.create && self.createItem()) {
11946 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11947 // don't submit form when searching for a value
11948 }
11949 else if (document.activeElement == self.control_input && self.isOpen) {
11950 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11951 }
11952 return;
11953 // left: modifiy item selection to the left
11954 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11955 self.advanceSelection(-1, e);
11956 return;
11957 // right: modifiy item selection to the right
11958 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11959 self.advanceSelection(1, e);
11960 return;
11961 // tab: select active option and/or create item
11962 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11963 if (self.settings.selectOnTab) {
11964 if (self.canSelect(self.activeOption)) {
11965 self.onOptionSelect(e, self.activeOption);
11966 // prevent default [tab] behaviour of jump to the next field
11967 // if select isFull, then the dropdown won't be open and [tab] will work normally
11968 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11969 }
11970 else if (self.settings.create && self.createItem()) {
11971 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11972 }
11973 }
11974 return;
11975 // delete|backspace: delete items
11976 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11977 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11978 self.deleteSelection(e);
11979 return;
11980 }
11981 // don't enter text in the control_input when active items are selected
11982 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11983 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11984 }
11985 }
11986 /**
11987 * Triggered on <input> keyup.
11988 *
11989 */
11990 onInput(e) {
11991 if (this.isLocked) {
11992 return;
11993 }
11994 const value = this.inputValue();
11995 if (this.lastValue === value)
11996 return;
11997 this.lastValue = value;
11998 if (value == '') {
11999 this._onInput();
12000 return;
12001 }
12002 if (this.refreshTimeout) {
12003 window.clearTimeout(this.refreshTimeout);
12004 }
12005 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
12006 this.refreshTimeout = null;
12007 this._onInput();
12008 }, this.settings.refreshThrottle);
12009 }
12010 _onInput() {
12011 const value = this.lastValue;
12012 if (this.settings.shouldLoad.call(this, value)) {
12013 this.load(value);
12014 }
12015 this.refreshOptions();
12016 this.trigger('type', value);
12017 }
12018 /**
12019 * Triggered when the user rolls over
12020 * an option in the autocomplete dropdown menu.
12021 *
12022 */
12023 onOptionHover(evt, option) {
12024 if (this.ignoreHover)
12025 return;
12026 this.setActiveOption(option, false);
12027 }
12028 /**
12029 * Triggered on <input> focus.
12030 *
12031 */
12032 onFocus(e) {
12033 var self = this;
12034 var wasFocused = self.isFocused;
12035 if (self.isDisabled || self.isReadOnly) {
12036 self.blur();
12037 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
12038 return;
12039 }
12040 if (self.ignoreFocus)
12041 return;
12042 self.isFocused = true;
12043 if (self.settings.preload === 'focus')
12044 self.preload();
12045 if (!wasFocused)
12046 self.trigger('focus');
12047 if (!self.activeItems.length) {
12048 self.inputState();
12049 self.refreshOptions(!!self.settings.openOnFocus);
12050 }
12051 self.refreshState();
12052 }
12053 /**
12054 * Triggered on <input> blur.
12055 *
12056 */
12057 onBlur(e) {
12058 if (document.hasFocus() === false)
12059 return;
12060 var self = this;
12061 if (!self.isFocused)
12062 return;
12063 self.isFocused = false;
12064 self.ignoreFocus = false;
12065 var deactivate = () => {
12066 self.close();
12067 self.setActiveItem();
12068 self.setCaret(self.items.length);
12069 self.trigger('blur');
12070 };
12071 if (self.settings.create && self.settings.createOnBlur) {
12072 self.createItem(null, deactivate);
12073 }
12074 else {
12075 deactivate();
12076 }
12077 }
12078 /**
12079 * Triggered when the user clicks on an option
12080 * in the autocomplete dropdown menu.
12081 *
12082 */
12083 onOptionSelect(evt, option) {
12084 var value, self = this;
12085 // should not be possible to trigger a option under a disabled optgroup
12086 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
12087 return;
12088 }
12089 if (option.classList.contains('create')) {
12090 self.createItem(null, () => {
12091 if (self.settings.closeAfterSelect) {
12092 self.close();
12093 }
12094 else if (self.settings.clearAfterSelect) {
12095 self.setTextboxValue();
12096 }
12097 });
12098 }
12099 else {
12100 value = option.dataset.value;
12101 if (typeof value !== 'undefined') {
12102 self.isDropdownContentStale = self.settings.hideSelected;
12103 self.addItem(value);
12104 if (self.settings.closeAfterSelect) {
12105 self.close();
12106 }
12107 else if (self.settings.clearAfterSelect) {
12108 self.setTextboxValue();
12109 }
12110 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
12111 self.setActiveOption(option);
12112 }
12113 }
12114 }
12115 }
12116 /**
12117 * Return true if the given option can be selected
12118 *
12119 */
12120 canSelect(option) {
12121 if (this.isOpen && option && this.dropdown_content.contains(option)) {
12122 return true;
12123 }
12124 return false;
12125 }
12126 /**
12127 * Triggered when the user clicks on an item
12128 * that has been selected.
12129 *
12130 */
12131 onItemSelect(evt, item) {
12132 var self = this;
12133 if (!self.isLocked && self.settings.mode === 'multi') {
12134 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
12135 self.setActiveItem(item, evt);
12136 return true;
12137 }
12138 return false;
12139 }
12140 /**
12141 * Determines whether or not to invoke
12142 * the user-provided option provider / loader
12143 *
12144 * Note, there is a subtle difference between
12145 * this.canLoad() and this.settings.shouldLoad();
12146 *
12147 * - settings.shouldLoad() is a user-input validator.
12148 * When false is returned, the not_loading template
12149 * will be added to the dropdown
12150 *
12151 * - canLoad() is lower level validator that checks
12152 * the Tom Select instance. There is no inherent user
12153 * feedback when canLoad returns false
12154 *
12155 */
12156 canLoad(value) {
12157 if (!this.settings.load)
12158 return false;
12159 if (this.loadedSearches.hasOwnProperty(value))
12160 return false;
12161 return true;
12162 }
12163 /**
12164 * Invokes the user-provided option provider / loader.
12165 *
12166 */
12167 load(value) {
12168 const self = this;
12169 if (!self.canLoad(value))
12170 return;
12171 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
12172 self.loading++;
12173 const callback = self.loadCallback.bind(self);
12174 self.settings.load.call(self, value, callback);
12175 }
12176 /**
12177 * Invoked by the user-provided option provider
12178 *
12179 */
12180 loadCallback(options, optgroups) {
12181 const self = this;
12182 self.loading = Math.max(self.loading - 1, 0);
12183 self.isDropdownContentStale = true;
12184 self.clearActiveOption(); // when new results load, focus should be on first option
12185 self.setupOptions(options, optgroups);
12186 self.refreshOptions(self.isFocused && !self.isInputHidden);
12187 if (!self.loading) {
12188 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
12189 }
12190 self.trigger('load', options, optgroups);
12191 }
12192 preload() {
12193 var classList = this.wrapper.classList;
12194 if (classList.contains('preloaded'))
12195 return;
12196 classList.add('preloaded');
12197 this.load('');
12198 }
12199 /**
12200 * Sets the input field of the control to the specified value.
12201 *
12202 */
12203 setTextboxValue(value = '') {
12204 var input = this.control_input;
12205 var changed = input.value !== value;
12206 if (changed) {
12207 input.value = value;
12208 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
12209 this.lastValue = value;
12210 }
12211 }
12212 /**
12213 * Returns the value of the control. If multiple items
12214 * can be selected (e.g. <select multiple>), this returns
12215 * an array. If only one item can be selected, this
12216 * returns a string.
12217 *
12218 */
12219 getValue() {
12220 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
12221 return this.items;
12222 }
12223 return this.items.join(this.settings.delimiter);
12224 }
12225 /**
12226 * Resets the selected items to the given value.
12227 *
12228 */
12229 setValue(value, silent) {
12230 var events = silent ? [] : ['change'];
12231 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12232 this.clear(silent);
12233 this.addItems(value, silent);
12234 });
12235 }
12236 /**
12237 * Resets the number of max items to the given value
12238 *
12239 */
12240 setMaxItems(value) {
12241 if (value === 0)
12242 value = null; //reset to unlimited items.
12243 this.settings.maxItems = value;
12244 this.refreshState();
12245 }
12246 /**
12247 * Sets the selected item.
12248 *
12249 */
12250 setActiveItem(item, e) {
12251 var self = this;
12252 var eventName;
12253 var i, begin, end, swap;
12254 var last;
12255 if (self.settings.mode === 'single')
12256 return;
12257 // clear the active selection
12258 if (!item) {
12259 self.clearActiveItems();
12260 if (self.isFocused) {
12261 self.inputState();
12262 }
12263 return;
12264 }
12265 // modify selection
12266 eventName = e && e.type.toLowerCase();
12267 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
12268 last = self.getLastActive();
12269 begin = Array.prototype.indexOf.call(self.control.children, last);
12270 end = Array.prototype.indexOf.call(self.control.children, item);
12271 if (begin > end) {
12272 swap = begin;
12273 begin = end;
12274 end = swap;
12275 }
12276 for (i = begin; i <= end; i++) {
12277 item = self.control.children[i];
12278 if (self.activeItems.indexOf(item) === -1) {
12279 self.setActiveItemClass(item);
12280 }
12281 }
12282 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
12283 }
12284 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))) {
12285 if (item.classList.contains('active')) {
12286 self.removeActiveItem(item);
12287 }
12288 else {
12289 self.setActiveItemClass(item);
12290 }
12291 }
12292 else {
12293 self.clearActiveItems();
12294 self.setActiveItemClass(item);
12295 }
12296 // ensure control has focus
12297 self.inputState();
12298 if (!self.isFocused) {
12299 self.focus();
12300 }
12301 }
12302 /**
12303 * Set the active and last-active classes
12304 *
12305 */
12306 setActiveItemClass(item) {
12307 const self = this;
12308 const last_active = self.control.querySelector('.last-active');
12309 if (last_active)
12310 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
12311 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
12312 self.trigger('item_select', item);
12313 if (self.activeItems.indexOf(item) == -1) {
12314 self.activeItems.push(item);
12315 }
12316 }
12317 /**
12318 * Remove active item
12319 *
12320 */
12321 removeActiveItem(item) {
12322 var idx = this.activeItems.indexOf(item);
12323 this.activeItems.splice(idx, 1);
12324 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12325 }
12326 /**
12327 * Clears all the active items
12328 *
12329 */
12330 clearActiveItems() {
12331 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
12332 this.activeItems = [];
12333 }
12334 /**
12335 * Sets the selected item in the dropdown menu
12336 * of available options.
12337 *
12338 */
12339 setActiveOption(option, scroll = true) {
12340 if (option === this.activeOption) {
12341 return;
12342 }
12343 this.clearActiveOption();
12344 if (!option)
12345 return;
12346 this.activeOption = option;
12347 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
12348 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
12349 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
12350 if (scroll)
12351 this.scrollToOption(option);
12352 }
12353 /**
12354 * Sets the dropdown_content scrollTop to display the option
12355 *
12356 */
12357 scrollToOption(option, behavior) {
12358 if (!option)
12359 return;
12360 const content = this.dropdown_content;
12361 const height_menu = content.clientHeight;
12362 const scrollTop = content.scrollTop || 0;
12363 const height_item = option.offsetHeight;
12364 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
12365 if (y + height_item > height_menu + scrollTop) {
12366 this.scroll(y - height_menu + height_item, behavior);
12367 }
12368 else if (y < scrollTop) {
12369 this.scroll(y, behavior);
12370 }
12371 }
12372 /**
12373 * Scroll the dropdown to the given position
12374 *
12375 */
12376 scroll(scrollTop, behavior) {
12377 const content = this.dropdown_content;
12378 if (behavior) {
12379 content.style.scrollBehavior = behavior;
12380 }
12381 content.scrollTop = scrollTop;
12382 content.style.scrollBehavior = '';
12383 }
12384 /**
12385 * Clears the active option
12386 *
12387 */
12388 clearActiveOption() {
12389 if (this.activeOption) {
12390 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
12391 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
12392 }
12393 this.activeOption = null;
12394 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
12395 }
12396 /**
12397 * Selects all items (CTRL + A).
12398 */
12399 selectAll() {
12400 const self = this;
12401 if (self.settings.mode === 'single')
12402 return;
12403 const activeItems = self.controlChildren();
12404 if (!activeItems.length)
12405 return;
12406 self.inputState();
12407 self.close();
12408 self.activeItems = activeItems;
12409 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
12410 self.setActiveItemClass(item);
12411 });
12412 }
12413 /**
12414 * Determines if the control_input should be in a hidden or visible state
12415 *
12416 */
12417 inputState() {
12418 var self = this;
12419 if (!self.control.contains(self.control_input))
12420 return;
12421 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
12422 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
12423 self.setTextboxValue();
12424 self.isInputHidden = true;
12425 }
12426 else {
12427 if (self.settings.hidePlaceholder && self.items.length > 0) {
12428 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
12429 }
12430 self.isInputHidden = false;
12431 }
12432 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
12433 }
12434 /**
12435 * Get the input value
12436 */
12437 inputValue() {
12438 return this.control_input.value.trim();
12439 }
12440 /**
12441 * Gives the control focus.
12442 */
12443 focus() {
12444 var self = this;
12445 if (self.isDisabled || self.isReadOnly)
12446 return;
12447 self.ignoreFocus = true;
12448 const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node;
12449 focusTarget.focus();
12450 setTimeout(() => {
12451 self.ignoreFocus = false;
12452 // Fix https://github.com/orchidjs/tom-select/issues/806
12453 // Only proceed if this instance's element is still the active element. If Edge autofill
12454 // (or anything else) has moved focus to a different element in the interim, calling
12455 // onFocus() here would steal focus back and restart the cascade loop.
12456 const root = focusTarget.getRootNode();
12457 if (root.activeElement !== focusTarget) {
12458 return;
12459 }
12460 this.onFocus();
12461 }, 0);
12462 }
12463 /**
12464 * Forces the control out of focus.
12465 *
12466 */
12467 blur() {
12468 this.focus_node.blur();
12469 this.onBlur();
12470 }
12471 /**
12472 * Returns a function that scores an object
12473 * to show how good of a match it is to the
12474 * provided query.
12475 *
12476 * @return {function}
12477 */
12478 getScoreFunction(query) {
12479 return this.sifter.getScoreFunction(query, this.getSearchOptions());
12480 }
12481 /**
12482 * Returns search options for sifter (the system
12483 * for scoring and sorting results).
12484 *
12485 * @see https://github.com/orchidjs/sifter.js
12486 * @return {object}
12487 */
12488 getSearchOptions() {
12489 var settings = this.settings;
12490 var sort = settings.sortField;
12491 if (typeof settings.sortField === 'string') {
12492 sort = [{ field: settings.sortField }];
12493 }
12494 return {
12495 fields: settings.searchField,
12496 conjunction: settings.searchConjunction,
12497 sort: sort,
12498 nesting: settings.nesting
12499 };
12500 }
12501 /**
12502 * Searches through available options and returns
12503 * a sorted array of matches.
12504 *
12505 */
12506 search(query) {
12507 var result, calculateScore;
12508 var self = this;
12509 var options = this.getSearchOptions();
12510 // validate user-provided result scoring function
12511 if (self.settings.score) {
12512 calculateScore = self.settings.score.call(self, query);
12513 if (typeof calculateScore !== 'function') {
12514 throw new Error('Tom Select "score" setting must be a function that returns a function');
12515 }
12516 }
12517 // perform search
12518 if (self.isDropdownContentStale || query !== self.lastQuery) {
12519 self.lastQuery = query;
12520 // temp fix for https://github.com/orchidjs/tom-select/issues/987
12521 // UI crashed when more than 30 same chars in a row, prevent search and return empt result
12522 if (/(.)\1{15,}/.test(query)) {
12523 query = '';
12524 }
12525 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
12526 self.currentResults = result;
12527 }
12528 else {
12529 result = Object.assign({}, self.currentResults);
12530 }
12531 // filter out selected items
12532 if (self.settings.hideSelected) {
12533 result.items = result.items.filter((item) => {
12534 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
12535 return !(hashed !== null && self.items.indexOf(hashed) !== -1);
12536 });
12537 }
12538 return result;
12539 }
12540 /**
12541 * Refreshes the list of available options shown
12542 * in the autocomplete dropdown menu.
12543 *
12544 */
12545 refreshOptions(triggerDropdown = true) {
12546 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
12547 var create;
12548 const groups = {};
12549 const groups_order = [];
12550 var self = this;
12551 var query = self.inputValue();
12552 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
12553 var results = self.search(query);
12554 var active_option = null;
12555 var show_dropdown = self.settings.shouldOpen || false;
12556 var dropdown_content = self.dropdown_content;
12557 if (same_query) {
12558 active_option = self.activeOption;
12559 if (active_option) {
12560 active_group = active_option.closest('[data-group]');
12561 }
12562 }
12563 // build markup
12564 n = results.items.length;
12565 if (typeof self.settings.maxOptions === 'number') {
12566 n = Math.min(n, self.settings.maxOptions);
12567 }
12568 if (n > 0) {
12569 show_dropdown = true;
12570 }
12571 // get fragment for group and the position of the group in group_order
12572 const getGroupFragment = (optgroup, order) => {
12573 let group_order_i = groups[optgroup];
12574 if (group_order_i !== undefined) {
12575 let order_group = groups_order[group_order_i];
12576 if (order_group !== undefined) {
12577 return [group_order_i, order_group.fragment];
12578 }
12579 }
12580 let group_fragment = document.createDocumentFragment();
12581 group_order_i = groups_order.length;
12582 groups_order.push({ fragment: group_fragment, order, optgroup });
12583 return [group_order_i, group_fragment];
12584 };
12585 // render and group available options individually
12586 for (i = 0; i < n; i++) {
12587 // get option dom element
12588 let item = results.items[i];
12589 if (!item)
12590 continue;
12591 let opt_value = item.id;
12592 let option = self.options[opt_value];
12593 if (option === undefined)
12594 continue;
12595 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12596 let option_el = self.getOption(opt_hash, true);
12597 // toggle 'selected' class
12598 if (!self.settings.hideSelected) {
12599 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12600 }
12601 optgroup = option[self.settings.optgroupField] || '';
12602 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12603 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12604 optgroup = optgroups[j];
12605 let order = option.$order;
12606 let self_optgroup = self.optgroups[optgroup];
12607 if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') {
12608 var regGroup;
12609 if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) {
12610 self.registerOptionGroup(regGroup);
12611 }
12612 }
12613 self_optgroup = self.optgroups[optgroup];
12614 if (self_optgroup === undefined) {
12615 optgroup = '';
12616 }
12617 else {
12618 order = self_optgroup.$order;
12619 }
12620 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12621 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12622 if (j > 0) {
12623 option_el = option_el.cloneNode(true);
12624 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12625 option_el.classList.add('ts-cloned');
12626 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12627 // make sure we keep the activeOption in the same group
12628 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12629 if (active_group && active_group.dataset.group === optgroup.toString()) {
12630 active_option = option_el;
12631 }
12632 }
12633 }
12634 group_fragment.appendChild(option_el);
12635 if (optgroup != '') {
12636 groups[optgroup] = group_order_i;
12637 }
12638 }
12639 }
12640 // sort optgroups
12641 if (self.settings.lockOptgroupOrder) {
12642 groups_order.sort((a, b) => {
12643 return a.order - b.order;
12644 });
12645 }
12646 // render optgroup headers & join groups
12647 html = document.createDocumentFragment();
12648 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12649 let group_fragment = group_order.fragment;
12650 let optgroup = group_order.optgroup;
12651 if (!group_fragment || !group_fragment.children.length)
12652 return;
12653 let group_heading = self.optgroups[optgroup];
12654 if (group_heading !== undefined) {
12655 let group_options = document.createDocumentFragment();
12656 let header = self.render('optgroup_header', group_heading);
12657 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12658 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12659 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12660 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12661 }
12662 else {
12663 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12664 }
12665 });
12666 dropdown_content.innerHTML = '';
12667 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12668 self.isDropdownContentStale = false;
12669 // highlight matching terms inline
12670 if (self.settings.highlight) {
12671 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12672 if (results.query.length && results.tokens.length) {
12673 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12674 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12675 });
12676 }
12677 }
12678 // helper method for adding templates to dropdown
12679 var add_template = (template) => {
12680 let content = self.render(template, { input: query });
12681 if (content) {
12682 show_dropdown = true;
12683 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12684 }
12685 return content;
12686 };
12687 // add loading message
12688 if (self.loading) {
12689 add_template('loading');
12690 // invalid query
12691 }
12692 else if (!self.settings.shouldLoad.call(self, query)) {
12693 add_template('not_loading');
12694 // add no_results message
12695 }
12696 else if (results.items.length === 0) {
12697 add_template('no_results');
12698 }
12699 // add create option
12700 has_create_option = self.canCreate(query);
12701 if (has_create_option) {
12702 create = add_template('option_create');
12703 }
12704 // activate
12705 self.hasOptions = results.items.length > 0 || has_create_option;
12706 if (show_dropdown) {
12707 if (results.items.length > 0) {
12708 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12709 active_option = self.getOption(self.items[0]);
12710 }
12711 if (!dropdown_content.contains(active_option)) {
12712 let active_index = 0;
12713 if (create && !self.settings.addPrecedence) {
12714 active_index = 1;
12715 }
12716 active_option = self.selectable()[active_index];
12717 }
12718 }
12719 else if (create) {
12720 active_option = create;
12721 }
12722 if (triggerDropdown && !self.isOpen) {
12723 self.open();
12724 self.scrollToOption(active_option, 'auto');
12725 }
12726 self.setActiveOption(active_option);
12727 }
12728 else {
12729 self.clearActiveOption();
12730 if (triggerDropdown && self.isOpen) {
12731 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12732 }
12733 }
12734 }
12735 /**
12736 * Return list of selectable options
12737 *
12738 */
12739 selectable() {
12740 return this.dropdown_content.querySelectorAll('[data-selectable]');
12741 }
12742 /**
12743 * Adds an available option. If it already exists,
12744 * nothing will happen. Note: this does not refresh
12745 * the options list dropdown (use `refreshOptions`
12746 * for that).
12747 *
12748 * Usage:
12749 *
12750 * this.addOption(data)
12751 *
12752 */
12753 addOption(data, user_created = false) {
12754 const self = this;
12755 // @deprecated 1.7.7
12756 // use addOptions( array, user_created ) for adding multiple options
12757 if (Array.isArray(data)) {
12758 self.addOptions(data, user_created);
12759 return false;
12760 }
12761 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12762 if (key === null || self.options.hasOwnProperty(key)) {
12763 self.updateOption(data[self.settings.valueField], data);
12764 return false;
12765 }
12766 data.$order = data.$order || ++self.order;
12767 data.$id = self.inputId + '-opt-' + data.$order;
12768 self.options[key] = data;
12769 self.isDropdownContentStale = true;
12770 if (user_created) {
12771 self.userOptions[key] = user_created;
12772 self.trigger('option_add', key, data);
12773 }
12774 return key;
12775 }
12776 /**
12777 * Add multiple options
12778 *
12779 */
12780 addOptions(data, user_created = false) {
12781 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12782 this.addOption(dat, user_created);
12783 });
12784 }
12785 /**
12786 * @deprecated 1.7.7
12787 */
12788 registerOption(data) {
12789 return this.addOption(data);
12790 }
12791 /**
12792 * Registers an option group to the pool of option groups.
12793 *
12794 * @return {boolean|string}
12795 */
12796 registerOptionGroup(data) {
12797 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12798 if (key === null)
12799 return false;
12800 data.$order = data.$order || ++this.order;
12801 this.optgroups[key] = data;
12802 return key;
12803 }
12804 /**
12805 * Registers a new optgroup for options
12806 * to be bucketed into.
12807 *
12808 */
12809 addOptionGroup(id, data) {
12810 var hashed_id;
12811 data[this.settings.optgroupValueField] = id;
12812 if (hashed_id = this.registerOptionGroup(data)) {
12813 this.trigger('optgroup_add', hashed_id, data);
12814 }
12815 }
12816 /**
12817 * Removes an existing option group.
12818 *
12819 */
12820 removeOptionGroup(id) {
12821 if (this.optgroups.hasOwnProperty(id)) {
12822 delete this.optgroups[id];
12823 this.clearCache();
12824 this.trigger('optgroup_remove', id);
12825 }
12826 }
12827 /**
12828 * Clears all existing option groups.
12829 */
12830 clearOptionGroups() {
12831 this.optgroups = {};
12832 this.clearCache();
12833 this.trigger('optgroup_clear');
12834 }
12835 /**
12836 * Updates an option available for selection. If
12837 * it is visible in the selected items or options
12838 * dropdown, it will be re-rendered automatically.
12839 *
12840 */
12841 updateOption(value, data) {
12842 const self = this;
12843 var item_new;
12844 var index_item;
12845 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12846 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12847 // sanity checks
12848 if (value_old === null)
12849 return;
12850 const data_old = self.options[value_old];
12851 if (data_old == undefined)
12852 return;
12853 if (typeof value_new !== 'string')
12854 throw new Error('Value must be set in option data');
12855 const option = self.getOption(value_old);
12856 const item = self.getItem(value_old);
12857 data.$order = data.$order || data_old.$order;
12858 delete self.options[value_old];
12859 // invalidate render cache
12860 // don't remove existing node yet, we'll remove it after replacing it
12861 self.uncacheValue(value_new);
12862 self.options[value_new] = data;
12863 // update the option if it's in the dropdown
12864 if (option) {
12865 if (self.dropdown_content.contains(option)) {
12866 const option_new = self._render('option', data);
12867 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12868 if (self.activeOption === option) {
12869 self.setActiveOption(option_new);
12870 }
12871 }
12872 option.remove();
12873 }
12874 // update the item if we have one
12875 if (item) {
12876 index_item = self.items.indexOf(value_old);
12877 if (index_item !== -1) {
12878 self.items.splice(index_item, 1, value_new);
12879 }
12880 item_new = self._render('item', data);
12881 if (item.classList.contains('active'))
12882 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12883 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12884 }
12885 // we might have updated the sortField
12886 self.isDropdownContentStale = true;
12887 }
12888 /**
12889 * Removes a single option.
12890 *
12891 */
12892 removeOption(value, silent) {
12893 const self = this;
12894 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12895 self.uncacheValue(value);
12896 delete self.userOptions[value];
12897 delete self.options[value];
12898 self.isDropdownContentStale = true;
12899 self.trigger('option_remove', value);
12900 self.removeItem(value, silent);
12901 }
12902 /**
12903 * Clears all options.
12904 */
12905 clearOptions(filter) {
12906 const boundFilter = (filter || this.clearFilter).bind(this);
12907 this.loadedSearches = {};
12908 this.userOptions = {};
12909 this.clearCache();
12910 const selected = {};
12911 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12912 if (boundFilter(option, key)) {
12913 selected[key] = option;
12914 }
12915 });
12916 this.options = this.sifter.items = selected;
12917 this.isDropdownContentStale = true;
12918 this.trigger('option_clear');
12919 }
12920 /**
12921 * Used by clearOptions() to decide whether or not an option should be removed
12922 * Return true to keep an option, false to remove
12923 *
12924 */
12925 clearFilter(option, value) {
12926 if (this.items.indexOf(value) >= 0) {
12927 return true;
12928 }
12929 return false;
12930 }
12931 /**
12932 * Returns the dom element of the option
12933 * matching the given value.
12934 *
12935 */
12936 getOption(value, create = false) {
12937 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12938 if (hashed === null)
12939 return null;
12940 const option = this.options[hashed];
12941 if (option != undefined) {
12942 if (option.$div) {
12943 return option.$div;
12944 }
12945 if (create) {
12946 return this._render('option', option);
12947 }
12948 }
12949 return null;
12950 }
12951 /**
12952 * Returns the dom element of the next or previous dom element of the same type
12953 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12954 *
12955 */
12956 getAdjacent(option, direction, type = 'option') {
12957 var self = this, all;
12958 if (!option) {
12959 return null;
12960 }
12961 if (type == 'item') {
12962 all = self.controlChildren();
12963 }
12964 else {
12965 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12966 }
12967 for (let i = 0; i < all.length; i++) {
12968 if (all[i] != option) {
12969 continue;
12970 }
12971 if (direction > 0) {
12972 return all[i + 1];
12973 }
12974 return all[i - 1];
12975 }
12976 return null;
12977 }
12978 /**
12979 * Returns the dom element of the item
12980 * matching the given value.
12981 *
12982 */
12983 getItem(item) {
12984 if (typeof item == 'object') {
12985 return item;
12986 }
12987 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12988 return value !== null
12989 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12990 : null;
12991 }
12992 /**
12993 * "Selects" multiple items at once. Adds them to the list
12994 * at the current caret position.
12995 *
12996 */
12997 addItems(values, silent) {
12998 var self = this;
12999 var items = Array.isArray(values) ? values : [values];
13000 items = items.filter(x => self.items.indexOf(x) === -1);
13001 const last_item = items[items.length - 1];
13002 items.forEach(item => {
13003 self.isPending = (item !== last_item);
13004 self.addItem(item, silent);
13005 });
13006 }
13007 /**
13008 * "Selects" an item. Adds it to the list
13009 * at the current caret position.
13010 *
13011 */
13012 addItem(value, silent) {
13013 var events = silent ? [] : ['change', 'dropdown_close'];
13014 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
13015 var item, wasFull;
13016 const self = this;
13017 const inputMode = self.settings.mode;
13018 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
13019 if (hashed && self.items.indexOf(hashed) !== -1) {
13020 if (inputMode === 'single') {
13021 self.close();
13022 }
13023 if (inputMode === 'single' || !self.settings.duplicates) {
13024 return;
13025 }
13026 }
13027 if (hashed === null || !self.options.hasOwnProperty(hashed))
13028 return;
13029 if (inputMode === 'single')
13030 self.clear(silent);
13031 if (inputMode === 'multi' && self.isFull())
13032 return;
13033 item = self._render('item', self.options[hashed]);
13034 if (self.control.contains(item)) { // duplicates
13035 item = item.cloneNode(true);
13036 }
13037 wasFull = self.isFull();
13038 self.items.splice(self.caretPos, 0, hashed);
13039 self.insertAtCaret(item);
13040 if (self.isSetup) {
13041 // update menu / remove the option (if this is not one item being added as part of series)
13042 if (!self.isPending && self.settings.hideSelected) {
13043 let option = self.getOption(hashed);
13044 let next = self.getAdjacent(option, 1);
13045 if (next) {
13046 self.setActiveOption(next);
13047 }
13048 }
13049 //remove input value when enabled
13050 if (self.settings.clearAfterSelect) {
13051 self.setTextboxValue();
13052 }
13053 // refreshOptions after setActiveOption(),
13054 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
13055 if (!self.isPending && !self.settings.closeAfterSelect) {
13056 self.refreshOptions(self.isFocused && inputMode !== 'single');
13057 }
13058 // hide the menu if the maximum number of items have been selected or no options are left
13059 if (self.settings.closeAfterSelect != false && self.isFull()) {
13060 self.close();
13061 }
13062 else if (!self.isPending) {
13063 self.positionDropdown();
13064 }
13065 self.trigger('item_add', hashed, item);
13066 if (!self.isPending) {
13067 self.updateOriginalInput({ silent: silent });
13068 }
13069 }
13070 if (!self.isPending || (!wasFull && self.isFull())) {
13071 self.inputState();
13072 self.refreshState();
13073 }
13074 });
13075 }
13076 /**
13077 * Removes the selected item matching
13078 * the provided value.
13079 *
13080 */
13081 removeItem(item = null, silent) {
13082 const self = this;
13083 item = self.getItem(item);
13084 if (!item)
13085 return;
13086 var i, idx;
13087 const value = item.dataset.value;
13088 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
13089 item.remove();
13090 if (item.classList.contains('active')) {
13091 idx = self.activeItems.indexOf(item);
13092 self.activeItems.splice(idx, 1);
13093 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
13094 }
13095 self.items.splice(i, 1);
13096 self.isDropdownContentStale = true;
13097 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
13098 self.removeOption(value, silent);
13099 }
13100 if (i < self.caretPos) {
13101 self.setCaret(self.caretPos - 1);
13102 }
13103 self.updateOriginalInput({ silent: silent });
13104 self.refreshState();
13105 self.positionDropdown();
13106 self.trigger('item_remove', value, item);
13107 }
13108 /**
13109 * Invokes the `create` method provided in the
13110 * TomSelect options that should provide the data
13111 * for the new item, given the user input.
13112 *
13113 * Once this completes, it will be added
13114 * to the item list.
13115 *
13116 */
13117 createItem(input = null, callback = () => { }) {
13118 // triggerDropdown parameter @deprecated 2.1.1
13119 if (arguments.length === 3) {
13120 callback = arguments[2];
13121 }
13122 if (typeof callback != 'function') {
13123 callback = () => { };
13124 }
13125 var self = this;
13126 var caret = self.caretPos;
13127 var output;
13128 input = input || self.inputValue();
13129 if (!self.canCreate(input)) {
13130 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input);
13131 if (hash) {
13132 if (this.options[input]) {
13133 self.addItem(input);
13134 }
13135 }
13136 callback();
13137 return false;
13138 }
13139 self.lock();
13140 var created = false;
13141 var create = (data) => {
13142 self.unlock();
13143 if (!data || typeof data !== 'object')
13144 return callback();
13145 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
13146 if (typeof value !== 'string') {
13147 return callback();
13148 }
13149 self.setTextboxValue();
13150 self.addOption(data, true);
13151 self.setCaret(caret);
13152 self.addItem(value);
13153 callback(data);
13154 created = true;
13155 };
13156 if (typeof self.settings.create === 'function') {
13157 output = self.settings.create.call(this, input, create);
13158 }
13159 else {
13160 output = {
13161 [self.settings.labelField]: input,
13162 [self.settings.valueField]: input,
13163 };
13164 }
13165 if (!created) {
13166 create(output);
13167 }
13168 return true;
13169 }
13170 /**
13171 * Re-renders the selected item lists.
13172 */
13173 refreshItems() {
13174 var self = this;
13175 self.isDropdownContentStale = true;
13176 if (self.isSetup) {
13177 self.addItems(self.items);
13178 }
13179 self.updateOriginalInput();
13180 self.refreshState();
13181 }
13182 /**
13183 * Updates all state-dependent attributes
13184 * and CSS classes.
13185 */
13186 refreshState() {
13187 const self = this;
13188 self.refreshValidityState();
13189 const isFull = self.isFull();
13190 const isLocked = self.isLocked;
13191 self.wrapper.classList.toggle('rtl', self.rtl);
13192 const wrap_classList = self.wrapper.classList;
13193 wrap_classList.toggle('focus', self.isFocused);
13194 wrap_classList.toggle('disabled', self.isDisabled);
13195 wrap_classList.toggle('readonly', self.isReadOnly);
13196 wrap_classList.toggle('required', self.isRequired);
13197 wrap_classList.toggle('invalid', !self.isValid);
13198 wrap_classList.toggle('locked', isLocked);
13199 wrap_classList.toggle('full', isFull);
13200 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
13201 wrap_classList.toggle('dropdown-active', self.isOpen);
13202 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
13203 wrap_classList.toggle('has-items', self.items.length > 0);
13204 }
13205 /**
13206 * Update the `required` attribute of both input and control input.
13207 *
13208 * The `required` property needs to be activated on the control input
13209 * for the error to be displayed at the right place. `required` also
13210 * needs to be temporarily deactivated on the input since the input is
13211 * hidden and can't show errors.
13212 */
13213 refreshValidityState() {
13214 var self = this;
13215 if (!self.input.validity) {
13216 return;
13217 }
13218 self.isValid = self.input.validity.valid;
13219 self.isInvalid = !self.isValid;
13220 }
13221 /**
13222 * Determines whether or not more items can be added
13223 * to the control without exceeding the user-defined maximum.
13224 *
13225 * @returns {boolean}
13226 */
13227 isFull() {
13228 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
13229 }
13230 /**
13231 * Refreshes the original <select> or <input>
13232 * element to reflect the current state.
13233 *
13234 */
13235 updateOriginalInput(opts = {}) {
13236 const self = this;
13237 var option, label;
13238 const empty_option = self.input.querySelector('option[value=""]');
13239 if (self.is_select_tag) {
13240 const selected = [];
13241 const has_selected = self.input.querySelectorAll('option:checked').length;
13242 function AddSelected(option_el, value, label) {
13243 if (!option_el) {
13244 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>');
13245 }
13246 // don't move empty option from top of list
13247 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
13248 if (option_el != empty_option) {
13249 self.input.append(option_el);
13250 }
13251 selected.push(option_el);
13252 // marking empty option as selected can break validation
13253 // fixes https://github.com/orchidjs/tom-select/issues/303
13254 if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') {
13255 option_el.selected = true;
13256 }
13257 return option_el;
13258 }
13259 // unselect all selected options
13260 self.input.querySelectorAll('option:checked').forEach((option_el) => {
13261 option_el.selected = false;
13262 });
13263 // nothing selected?
13264 if (self.items.length == 0 && self.settings.mode == 'single') {
13265 AddSelected(empty_option, "", "");
13266 // order selected <option> tags for values in self.items
13267 }
13268 else {
13269 self.items.forEach((value) => {
13270 option = self.options[value];
13271 label = option[self.settings.labelField] || '';
13272 if (selected.includes(option.$option)) {
13273 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
13274 AddSelected(reuse_opt, value, label);
13275 }
13276 else {
13277 option.$option = AddSelected(option.$option, value, label);
13278 }
13279 });
13280 }
13281 }
13282 else {
13283 self.input.value = self.getValue();
13284 }
13285 if (self.isSetup) {
13286 if (!opts.silent) {
13287 self.trigger('change', self.getValue());
13288 }
13289 }
13290 }
13291 /**
13292 * Shows the autocomplete dropdown containing
13293 * the available options.
13294 */
13295 open() {
13296 var self = this;
13297 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
13298 return;
13299 self.isOpen = true;
13300 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
13301 self.refreshState();
13302 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
13303 self.positionDropdown();
13304 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
13305 self.focus();
13306 self.trigger('dropdown_open', self.dropdown);
13307 }
13308 /**
13309 * Closes the autocomplete dropdown menu.
13310 */
13311 close(setTextboxValue = true) {
13312 var self = this;
13313 var trigger = self.isOpen;
13314 if (setTextboxValue) {
13315 // before blur() to prevent form onchange event
13316 self.setTextboxValue();
13317 if (self.settings.mode === 'single' && self.items.length) {
13318 self.inputState();
13319 }
13320 }
13321 self.isOpen = false;
13322 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
13323 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
13324 if (self.settings.hideSelected) {
13325 self.clearActiveOption();
13326 }
13327 self.refreshState();
13328 if (trigger)
13329 self.trigger('dropdown_close', self.dropdown);
13330 }
13331 /**
13332 * Calculates and applies the appropriate
13333 * position of the dropdown if dropdownParent = 'body'.
13334 * Otherwise, position is determined by css
13335 */
13336 positionDropdown() {
13337 if (this.settings.dropdownParent !== 'body') {
13338 return;
13339 }
13340 var context = this.control;
13341 var rect = context.getBoundingClientRect();
13342 var top = context.offsetHeight + rect.top + window.scrollY;
13343 var left = rect.left + window.scrollX;
13344 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
13345 width: rect.width + 'px',
13346 top: top + 'px',
13347 left: left + 'px'
13348 });
13349 }
13350 /**
13351 * Resets / clears all selected items
13352 * from the control.
13353 *
13354 */
13355 clear(silent) {
13356 var self = this;
13357 if (!self.items.length)
13358 return;
13359 var items = self.controlChildren();
13360 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
13361 self.removeItem(item, true);
13362 });
13363 self.inputState();
13364 if (!silent)
13365 self.updateOriginalInput();
13366 self.trigger('clear');
13367 }
13368 /**
13369 * A helper method for inserting an element
13370 * at the current caret position.
13371 *
13372 */
13373 insertAtCaret(el) {
13374 const self = this;
13375 const caret = self.caretPos;
13376 const target = self.control;
13377 target.insertBefore(el, target.children[caret] || null);
13378 self.setCaret(caret + 1);
13379 }
13380 /**
13381 * Removes the current selected item(s).
13382 *
13383 */
13384 deleteSelection(e) {
13385 var direction, selection, caret, tail;
13386 var self = this;
13387 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
13388 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
13389 // determine items that will be removed
13390 const rm_items = [];
13391 if (self.activeItems.length) {
13392 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
13393 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
13394 if (direction > 0) {
13395 caret++;
13396 }
13397 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
13398 }
13399 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
13400 const items = self.controlChildren();
13401 let rm_item;
13402 if (direction < 0 && selection.start === 0 && selection.length === 0) {
13403 rm_item = items[self.caretPos - 1];
13404 }
13405 else if (direction > 0 && selection.start === self.inputValue().length) {
13406 rm_item = items[self.caretPos];
13407 }
13408 if (rm_item !== undefined) {
13409 rm_items.push(rm_item);
13410 }
13411 }
13412 if (!self.shouldDelete(rm_items, e)) {
13413 return false;
13414 }
13415 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
13416 // perform removal
13417 if (typeof caret !== 'undefined') {
13418 self.setCaret(caret);
13419 }
13420 while (rm_items.length) {
13421 self.removeItem(rm_items.pop());
13422 }
13423 self.inputState();
13424 self.positionDropdown();
13425 self.refreshOptions(false);
13426 return true;
13427 }
13428 /**
13429 * Return true if the items should be deleted
13430 */
13431 shouldDelete(items, evt) {
13432 const values = items.map(item => item.dataset.value);
13433 // allow the callback to abort
13434 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) {
13435 return false;
13436 }
13437 return true;
13438 }
13439 /**
13440 * Selects the previous / next item (depending on the `direction` argument).
13441 *
13442 * > 0 - right
13443 * < 0 - left
13444 *
13445 */
13446 advanceSelection(direction, e) {
13447 var last_active, adjacent, self = this;
13448 if (self.rtl)
13449 direction *= -1;
13450 if (self.inputValue().length)
13451 return;
13452 // add or remove to active items
13453 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)) {
13454 last_active = self.getLastActive(direction);
13455 if (last_active) {
13456 if (!last_active.classList.contains('active')) {
13457 adjacent = last_active;
13458 }
13459 else {
13460 adjacent = self.getAdjacent(last_active, direction, 'item');
13461 }
13462 // if no active item, get items adjacent to the control input
13463 }
13464 else if (direction > 0) {
13465 adjacent = self.control_input.nextElementSibling;
13466 }
13467 else {
13468 adjacent = self.control_input.previousElementSibling;
13469 }
13470 if (adjacent) {
13471 if (adjacent.classList.contains('active')) {
13472 self.removeActiveItem(last_active);
13473 }
13474 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
13475 }
13476 // move caret to the left or right
13477 }
13478 else {
13479 self.moveCaret(direction);
13480 }
13481 }
13482 moveCaret(direction) { }
13483 /**
13484 * Get the last active item
13485 *
13486 */
13487 getLastActive(direction) {
13488 let last_active = this.control.querySelector('.last-active');
13489 if (last_active) {
13490 return last_active;
13491 }
13492 var result = this.control.querySelectorAll('.active');
13493 if (result) {
13494 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
13495 }
13496 }
13497 /**
13498 * Moves the caret to the specified index.
13499 *
13500 * The input must be moved by leaving it in place and moving the
13501 * siblings, due to the fact that focus cannot be restored once lost
13502 * on mobile webkit devices
13503 *
13504 */
13505 setCaret(new_pos) {
13506 this.caretPos = this.items.length;
13507 }
13508 /**
13509 * Return list of item dom elements
13510 *
13511 */
13512 controlChildren() {
13513 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
13514 }
13515 /**
13516 * Disables user input on the control. Used while
13517 * items are being asynchronously created.
13518 */
13519 lock() {
13520 this.setLocked(true);
13521 }
13522 /**
13523 * Re-enables user input on the control.
13524 */
13525 unlock() {
13526 this.setLocked(false);
13527 }
13528 /**
13529 * Disable or enable user input on the control
13530 */
13531 setLocked(lock = this.isReadOnly || this.isDisabled) {
13532 this.isLocked = lock;
13533 this.refreshState();
13534 }
13535 /**
13536 * Disables user input on the control completely.
13537 * While disabled, it cannot receive focus.
13538 */
13539 disable() {
13540 this.setDisabled(true);
13541 this.close();
13542 }
13543 /**
13544 * Enables the control so that it can respond
13545 * to focus and user input.
13546 */
13547 enable() {
13548 this.setDisabled(false);
13549 }
13550 setDisabled(disabled) {
13551 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
13552 this.isDisabled = disabled;
13553 this.input.disabled = disabled;
13554 this.control_input.disabled = disabled;
13555 this.setLocked();
13556 }
13557 setReadOnly(isReadOnly) {
13558 this.isReadOnly = isReadOnly;
13559 this.input.readOnly = isReadOnly;
13560 this.control_input.readOnly = isReadOnly;
13561 this.setLocked();
13562 }
13563 /**
13564 * Completely destroys the control and
13565 * unbinds all event listeners so that it can
13566 * be garbage collected.
13567 */
13568 destroy() {
13569 var self = this;
13570 var revertSettings = self.revertSettings;
13571 self.trigger('destroy');
13572 self.off();
13573 self.wrapper.remove();
13574 self.dropdown.remove();
13575 self.input.innerHTML = revertSettings.innerHTML;
13576 self.input.tabIndex = revertSettings.tabIndex;
13577 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
13578 self._destroy();
13579 delete self.input.tomselect;
13580 }
13581 /**
13582 * A helper method for rendering "item" and
13583 * "option" templates, given the data.
13584 *
13585 */
13586 render(templateName, data) {
13587 var id, html;
13588 const self = this;
13589 if (typeof this.settings.render[templateName] !== 'function') {
13590 return null;
13591 }
13592 // render markup
13593 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
13594 if (!html) {
13595 return null;
13596 }
13597 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
13598 // add mandatory attributes
13599 if (templateName === 'option' || templateName === 'option_create') {
13600 if (data[self.settings.disabledField]) {
13601 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
13602 }
13603 else {
13604 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13605 }
13606 }
13607 else if (templateName === 'optgroup') {
13608 id = data.group[self.settings.optgroupValueField];
13609 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13610 if (data.group[self.settings.disabledField]) {
13611 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13612 }
13613 }
13614 if (templateName === 'option' || templateName === 'item') {
13615 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13616 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13617 // make sure we have some classes if a template is overwritten
13618 if (templateName === 'item') {
13619 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13620 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13621 }
13622 else {
13623 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13624 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13625 role: 'option',
13626 id: data.$id
13627 });
13628 // update cache
13629 data.$div = html;
13630 self.options[value] = data;
13631 }
13632 }
13633 return html;
13634 }
13635 /**
13636 * Type guarded rendering
13637 *
13638 */
13639 _render(templateName, data) {
13640 const html = this.render(templateName, data);
13641 if (html == null) {
13642 throw 'HTMLElement expected';
13643 }
13644 return html;
13645 }
13646 /**
13647 * Clears the render cache for a template. If
13648 * no template is given, clears all render
13649 * caches.
13650 *
13651 */
13652 clearCache() {
13653 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13654 if (option.$div) {
13655 option.$div.remove();
13656 delete option.$div;
13657 }
13658 });
13659 }
13660 /**
13661 * Removes a value from item and option caches
13662 *
13663 */
13664 uncacheValue(value) {
13665 const option_el = this.getOption(value);
13666 if (option_el)
13667 option_el.remove();
13668 }
13669 /**
13670 * Determines whether or not to display the
13671 * create item prompt, given a user input.
13672 *
13673 */
13674 canCreate(input) {
13675 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13676 }
13677 /**
13678 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13679 *
13680 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13681 *
13682 * });
13683 */
13684 hook(when, method, new_fn) {
13685 var self = this;
13686 var orig_method = self[method];
13687 self[method] = function () {
13688 var result, result_new;
13689 if (when === 'after') {
13690 result = orig_method.apply(self, arguments);
13691 }
13692 result_new = new_fn.apply(self, arguments);
13693 if (when === 'instead') {
13694 return result_new;
13695 }
13696 if (when === 'before') {
13697 result = orig_method.apply(self, arguments);
13698 }
13699 return result;
13700 };
13701 }
13702 }
13703 ;
13704 //# sourceMappingURL=tom-select.js.map
13705
13706 /***/ },
13707
13708 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13709 /*!***************************************************!*\
13710 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13711 \***************************************************/
13712 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13713
13714 "use strict";
13715 __webpack_require__.r(__webpack_exports__);
13716 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13717 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13718 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13719 /* harmony export */ append: () => (/* binding */ append),
13720 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13721 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13722 /* harmony export */ getId: () => (/* binding */ getId),
13723 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13724 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13725 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13726 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13727 /* harmony export */ iterate: () => (/* binding */ iterate),
13728 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13729 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13730 /* harmony export */ timeout: () => (/* binding */ timeout)
13731 /* harmony export */ });
13732 /**
13733 * Converts a scalar to its best string representation
13734 * for hash keys and HTML attribute values.
13735 *
13736 * Transformations:
13737 * 'str' -> 'str'
13738 * null -> ''
13739 * undefined -> ''
13740 * true -> '1'
13741 * false -> '0'
13742 * 0 -> '0'
13743 * 1 -> '1'
13744 *
13745 */
13746 const hash_key = (value) => {
13747 if (typeof value === 'undefined' || value === null)
13748 return null;
13749 return get_hash(value);
13750 };
13751 const get_hash = (value) => {
13752 if (typeof value === 'boolean')
13753 return value ? '1' : '0';
13754 return value + '';
13755 };
13756 /**
13757 * Escapes a string for use within HTML.
13758 *
13759 */
13760 const escape_html = (str) => {
13761 return (str + '')
13762 .replace(/&/g, '&amp;')
13763 .replace(/</g, '&lt;')
13764 .replace(/>/g, '&gt;')
13765 .replace(/"/g, '&quot;');
13766 };
13767 /**
13768 * use setTimeout if timeout > 0
13769 */
13770 const timeout = (fn, timeout) => {
13771 if (timeout > 0) {
13772 return window.setTimeout(fn, timeout);
13773 }
13774 fn.call(null);
13775 return null;
13776 };
13777 /**
13778 * Debounce the user provided load function
13779 *
13780 */
13781 const loadDebounce = (fn, delay) => {
13782 var timeout;
13783 return function (value, callback) {
13784 var self = this;
13785 if (timeout) {
13786 self.loading = Math.max(self.loading - 1, 0);
13787 clearTimeout(timeout);
13788 }
13789 timeout = setTimeout(function () {
13790 timeout = null;
13791 self.loadedSearches[value] = true;
13792 fn.call(self, value, callback);
13793 }, delay);
13794 };
13795 };
13796 /**
13797 * Debounce all fired events types listed in `types`
13798 * while executing the provided `fn`.
13799 *
13800 */
13801 const debounce_events = (self, types, fn) => {
13802 var type;
13803 var trigger = self.trigger;
13804 var event_args = {};
13805 // override trigger method
13806 self.trigger = function () {
13807 var type = arguments[0];
13808 if (types.indexOf(type) !== -1) {
13809 event_args[type] = arguments;
13810 }
13811 else {
13812 return trigger.apply(self, arguments);
13813 }
13814 };
13815 // invoke provided function
13816 fn.apply(self, []);
13817 self.trigger = trigger;
13818 // trigger queued events
13819 for (type of types) {
13820 if (type in event_args) {
13821 trigger.apply(self, event_args[type]);
13822 }
13823 }
13824 };
13825 /**
13826 * Determines the current selection within a text input control.
13827 * Returns an object containing:
13828 * - start
13829 * - length
13830 *
13831 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13832 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13833 */
13834 const getSelection = (input) => {
13835 return {
13836 start: input.selectionStart || 0,
13837 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13838 };
13839 };
13840 /**
13841 * Prevent default
13842 *
13843 */
13844 const preventDefault = (evt, stop = false) => {
13845 if (evt) {
13846 evt.preventDefault();
13847 if (stop) {
13848 evt.stopPropagation();
13849 }
13850 }
13851 };
13852 /**
13853 * Add event helper
13854 *
13855 */
13856 const addEvent = (target, type, callback, options) => {
13857 target.addEventListener(type, callback, options);
13858 };
13859 /**
13860 * Return true if the requested key is down
13861 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13862 * The current evt may not always set ( eg calling advanceSelection() )
13863 *
13864 */
13865 const isKeyDown = (key_name, evt) => {
13866 if (!evt) {
13867 return false;
13868 }
13869 if (!evt[key_name]) {
13870 return false;
13871 }
13872 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13873 if (count === 1) {
13874 return true;
13875 }
13876 return false;
13877 };
13878 /**
13879 * Get the id of an element
13880 * If the id attribute is not set, set the attribute with the given id
13881 *
13882 */
13883 const getId = (el, id) => {
13884 const existing_id = el.getAttribute('id');
13885 if (existing_id) {
13886 return existing_id;
13887 }
13888 el.setAttribute('id', id);
13889 return id;
13890 };
13891 /**
13892 * Returns a string with backslashes added before characters that need to be escaped.
13893 */
13894 const addSlashes = (str) => {
13895 return str.replace(/[\\"']/g, '\\$&');
13896 };
13897 /**
13898 *
13899 */
13900 const append = (parent, node) => {
13901 if (node)
13902 parent.append(node);
13903 };
13904 /**
13905 * Iterates over arrays and hashes.
13906 *
13907 * ```
13908 * iterate(this.items, function(item, id) {
13909 * // invoked for each item
13910 * });
13911 * ```
13912 *
13913 */
13914 const iterate = (object, callback) => {
13915 if (Array.isArray(object)) {
13916 object.forEach(callback);
13917 }
13918 else {
13919 for (var key in object) {
13920 if (object.hasOwnProperty(key)) {
13921 callback(object[key], key);
13922 }
13923 }
13924 }
13925 };
13926 //# sourceMappingURL=utils.js.map
13927
13928 /***/ },
13929
13930 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13931 /*!*****************************************************!*\
13932 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13933 \*****************************************************/
13934 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13935
13936 "use strict";
13937 __webpack_require__.r(__webpack_exports__);
13938 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13939 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13940 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13941 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13942 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13943 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13944 /* harmony export */ getDom: () => (/* binding */ getDom),
13945 /* harmony export */ getTail: () => (/* binding */ getTail),
13946 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13947 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13948 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13949 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13950 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13951 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13952 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13953 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13954 /* harmony export */ });
13955 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13956
13957 /**
13958 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13959 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13960 *
13961 * param query should be {}
13962 */
13963 const getDom = (query) => {
13964 if (query.jquery) {
13965 return query[0];
13966 }
13967 if (query instanceof HTMLElement) {
13968 return query;
13969 }
13970 if (isHtmlString(query)) {
13971 var tpl = document.createElement('template');
13972 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13973 return tpl.content.firstChild;
13974 }
13975 return document.querySelector(query);
13976 };
13977 const isHtmlString = (arg) => {
13978 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13979 return true;
13980 }
13981 return false;
13982 };
13983 const escapeQuery = (query) => {
13984 return query.replace(/['"\\]/g, '\\$&');
13985 };
13986 /**
13987 * Dispatch an event
13988 *
13989 */
13990 const triggerEvent = (dom_el, event_name) => {
13991 var event = document.createEvent('HTMLEvents');
13992 event.initEvent(event_name, true, false);
13993 dom_el.dispatchEvent(event);
13994 };
13995 /**
13996 * Apply CSS rules to a dom element
13997 *
13998 */
13999 const applyCSS = (dom_el, css) => {
14000 Object.assign(dom_el.style, css);
14001 };
14002 /**
14003 * Add css classes
14004 *
14005 */
14006 const addClasses = (elmts, ...classes) => {
14007 var norm_classes = classesArray(classes);
14008 elmts = castAsArray(elmts);
14009 elmts.map(el => {
14010 norm_classes.map(cls => {
14011 el.classList.add(cls);
14012 });
14013 });
14014 };
14015 /**
14016 * Remove css classes
14017 *
14018 */
14019 const removeClasses = (elmts, ...classes) => {
14020 var norm_classes = classesArray(classes);
14021 elmts = castAsArray(elmts);
14022 elmts.map(el => {
14023 norm_classes.map(cls => {
14024 el.classList.remove(cls);
14025 });
14026 });
14027 };
14028 /**
14029 * Return arguments
14030 *
14031 */
14032 const classesArray = (args) => {
14033 var classes = [];
14034 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
14035 if (typeof _classes === 'string') {
14036 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
14037 }
14038 if (Array.isArray(_classes)) {
14039 classes = classes.concat(_classes);
14040 }
14041 });
14042 return classes.filter(Boolean);
14043 };
14044 /**
14045 * Create an array from arg if it's not already an array
14046 *
14047 */
14048 const castAsArray = (arg) => {
14049 if (!Array.isArray(arg)) {
14050 arg = [arg];
14051 }
14052 return arg;
14053 };
14054 /**
14055 * Get the closest node to the evt.target matching the selector
14056 * Stops at wrapper
14057 *
14058 */
14059 const parentMatch = (target, selector, wrapper) => {
14060 if (wrapper && !wrapper.contains(target)) {
14061 return;
14062 }
14063 while (target && target.matches) {
14064 if (target.matches(selector)) {
14065 return target;
14066 }
14067 target = target.parentNode;
14068 }
14069 };
14070 /**
14071 * Get the first or last item from an array
14072 *
14073 * > 0 - right (last)
14074 * <= 0 - left (first)
14075 *
14076 */
14077 const getTail = (list, direction = 0) => {
14078 if (direction > 0) {
14079 return list[list.length - 1];
14080 }
14081 return list[0];
14082 };
14083 /**
14084 * Return true if an object is empty
14085 *
14086 */
14087 const isEmptyObject = (obj) => {
14088 return (Object.keys(obj).length === 0);
14089 };
14090 /**
14091 * Get the index of an element amongst sibling nodes of the same type
14092 *
14093 */
14094 const nodeIndex = (el, amongst) => {
14095 if (!el)
14096 return -1;
14097 amongst = amongst || el.nodeName;
14098 var i = 0;
14099 while (el = el.previousElementSibling) {
14100 if (el.matches(amongst)) {
14101 i++;
14102 }
14103 }
14104 return i;
14105 };
14106 /**
14107 * Set attributes of an element
14108 *
14109 */
14110 const setAttr = (el, attrs) => {
14111 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
14112 if (val == null) {
14113 el.removeAttribute(attr);
14114 }
14115 else {
14116 el.setAttribute(attr, '' + val);
14117 }
14118 });
14119 };
14120 /**
14121 * Replace a node
14122 */
14123 const replaceNode = (existing, replacement) => {
14124 if (existing.parentNode)
14125 existing.parentNode.replaceChild(replacement, existing);
14126 };
14127 //# sourceMappingURL=vanilla.js.map
14128
14129 /***/ }
14130
14131 /******/ });
14132 /************************************************************************/
14133 /******/ // The module cache
14134 /******/ const __webpack_module_cache__ = {};
14135 /******/
14136 /******/ // The require function
14137 /******/ function __webpack_require__(moduleId) {
14138 /******/ // Check if module is in cache
14139 /******/ const cachedModule = __webpack_module_cache__[moduleId];
14140 /******/ if (cachedModule !== undefined) {
14141 /******/ return cachedModule.exports;
14142 /******/ }
14143 /******/ // Create a new module (and put it into the cache)
14144 /******/ const module = __webpack_module_cache__[moduleId] = {
14145 /******/ id: moduleId,
14146 /******/ // no module.loaded needed
14147 /******/ exports: {}
14148 /******/ };
14149 /******/
14150 /******/ // Execute the module function
14151 /******/ if (!(moduleId in __webpack_modules__)) {
14152 /******/ delete __webpack_module_cache__[moduleId];
14153 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
14154 /******/ e.code = 'MODULE_NOT_FOUND';
14155 /******/ throw e;
14156 /******/ }
14157 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
14158 /******/
14159 /******/ // Return the exports of the module
14160 /******/ return module.exports;
14161 /******/ }
14162 /******/
14163 /************************************************************************/
14164 /******/ /* webpack/runtime/compat get default export */
14165 /******/ (() => {
14166 /******/ // getDefaultExport function for compatibility with non-harmony modules
14167 /******/ __webpack_require__.n = (module) => {
14168 /******/ const getter = module && module.__esModule ?
14169 /******/ () => (module['default']) :
14170 /******/ () => (module);
14171 /******/ __webpack_require__.d(getter, { a: getter });
14172 /******/ return getter;
14173 /******/ };
14174 /******/ })();
14175 /******/
14176 /******/ /* webpack/runtime/define property getters */
14177 /******/ (() => {
14178 /******/ // define getter/value functions for harmony exports
14179 /******/ __webpack_require__.d = (exports, definition) => {
14180 /******/ if(Array.isArray(definition)) {
14181 /******/ var i = 0;
14182 /******/ while(i < definition.length) {
14183 /******/ var key = definition[i++];
14184 /******/ var binding = definition[i++];
14185 /******/ if(!__webpack_require__.o(exports, key)) {
14186 /******/ if(binding === 0) {
14187 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
14188 /******/ } else {
14189 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
14190 /******/ }
14191 /******/ } else if(binding === 0) { i++; }
14192 /******/ }
14193 /******/ } else {
14194 /******/ for(var key in definition) {
14195 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
14196 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14197 /******/ }
14198 /******/ }
14199 /******/ }
14200 /******/ };
14201 /******/ })();
14202 /******/
14203 /******/ /* webpack/runtime/hasOwnProperty shorthand */
14204 /******/ (() => {
14205 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
14206 /******/ })();
14207 /******/
14208 /******/ /* webpack/runtime/make namespace object */
14209 /******/ (() => {
14210 /******/ // define __esModule on exports
14211 /******/ __webpack_require__.r = (exports) => {
14212 /******/ if(Symbol.toStringTag) {
14213 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14214 /******/ }
14215 /******/ Object.defineProperty(exports, '__esModule', { value: true });
14216 /******/ };
14217 /******/ })();
14218 /******/
14219 /******/ /* webpack/runtime/nonce */
14220 /******/ (() => {
14221 /******/ __webpack_require__.nc = undefined;
14222 /******/ })();
14223 /******/
14224 /************************************************************************/
14225 let __webpack_exports__ = {};
14226 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
14227 (() => {
14228 "use strict";
14229 /*!********************************************!*\
14230 !*** ./assets/src/js/admin/admin-tools.js ***!
14231 \********************************************/
14232 __webpack_require__.r(__webpack_exports__);
14233 /* harmony import */ var _tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/assign-user-course */ "./assets/src/js/admin/tools/assign-user-course.js");
14234 /* harmony import */ var _tools_handle_sample_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools/handle-sample-data */ "./assets/src/js/admin/tools/handle-sample-data.js");
14235 /* harmony import */ var _tools_reset_course_progress__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools/reset-course-progress */ "./assets/src/js/admin/tools/reset-course-progress.js");
14236 /* harmony import */ var _tools_reset_item_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/reset-item-progress */ "./assets/src/js/admin/tools/reset-item-progress.js");
14237
14238
14239
14240
14241 (0,_tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__["default"])();
14242 new _tools_handle_sample_data__WEBPACK_IMPORTED_MODULE_1__["default"]().init();
14243 new _tools_reset_course_progress__WEBPACK_IMPORTED_MODULE_2__["default"]().init();
14244 new _tools_reset_item_progress__WEBPACK_IMPORTED_MODULE_3__["default"]().init();
14245 })();
14246
14247 /******/ })()
14248 ;
14249 //# sourceMappingURL=admin-tools.js.map