PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9.1
4.4.9.1 4.4.9 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 All 141 releases
learnpress / assets / dist / js / admin / admin-tools.js

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

14,246 lines 501.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/admin/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 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
1024 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
1025 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
1026 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
1027 };
1028 }
1029 if ('undefined' !== typeof lpData) {
1030 lp_rest_url = lpData.lp_rest_url;
1031 lplistAPI.frontend = {
1032 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
1033 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
1034 // Deprecated API, don't load from v4.3.7
1035 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
1036 // Deprecated since 4.3.0
1037 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
1038 };
1039 }
1040 if (lp_rest_url) {
1041 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
1042 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
1043 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
1044 }
1045 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
1046
1047 /***/ },
1048
1049 /***/ "./assets/src/js/lpPopupSelectItemToAdd.js"
1050 /*!*************************************************!*\
1051 !*** ./assets/src/js/lpPopupSelectItemToAdd.js ***!
1052 \*************************************************/
1053 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1054
1055 "use strict";
1056 __webpack_require__.r(__webpack_exports__);
1057 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1058 /* harmony export */ LpPopupSelectItemToAdd: () => (/* binding */ LpPopupSelectItemToAdd)
1059 /* harmony export */ });
1060 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
1061 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
1062 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
1063 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_2__);
1064 /**
1065 * LearnPress Popup Select Item
1066 *
1067 * Handles load(search) item from API, show in popup and select item.
1068 */
1069
1070
1071
1072
1073 let itemsSelectedData = [];
1074 let elPopup;
1075 let timeSearchTitleItem;
1076 class LpPopupSelectItemToAdd {
1077 constructor() {
1078 this.init();
1079 }
1080 static selectors = {
1081 elBtnShowPopupItemsToSelect: '.lp-btn-show-popup-items-to-select',
1082 elBtnAddItemsSelected: '.lp-btn-add-items-selected',
1083 elBtnCountItemsSelected: '.lp-btn-count-items-selected',
1084 elHeaderCountItemSelected: '.header-count-items-selected',
1085 elSelectItem: '.lp-select-item',
1086 elListItems: '.list-items',
1087 elPopupItemsToSelect: '.lp-popup-items-to-select',
1088 elSearchTitleItem: '.lp-search-title-item',
1089 elBtnBackListItems: '.lp-btn-back-to-select-items',
1090 elListItemsWrap: '.list-items-wrap',
1091 elListItemsSelected: '.list-items-selected',
1092 elItemSelectedClone: '.li-item-selected.clone',
1093 elItemSelected: '.li-item-selected',
1094 LPTarget: '.lp-target'
1095 };
1096 init() {
1097 this.events();
1098 }
1099 events = () => {
1100 if (LpPopupSelectItemToAdd._loadedEvents) {
1101 return;
1102 }
1103 LpPopupSelectItemToAdd._loadedEvents = true;
1104 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
1105 selector: LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
1106 callBack: this.showPopupItemsToSelect.name,
1107 class: this
1108 }, {
1109 selector: LpPopupSelectItemToAdd.selectors.elSelectItem,
1110 callBack: this.selectItemsFromList.name,
1111 class: this
1112 }, {
1113 selector: LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected,
1114 callBack: this.showItemsSelected.name,
1115 class: this
1116 }, {
1117 selector: LpPopupSelectItemToAdd.selectors.elBtnBackListItems,
1118 callBack: this.backToSelectItems.name,
1119 class: this
1120 }, {
1121 selector: LpPopupSelectItemToAdd.selectors.elItemSelected,
1122 callBack: this.removeItemSelected.name,
1123 class: this
1124 }, {
1125 selector: '.tabs .tab',
1126 callBack: this.chooseTabItemsType.name,
1127 class: this
1128 }]);
1129 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
1130 selector: LpPopupSelectItemToAdd.selectors.elSearchTitleItem,
1131 callBack: this.searchTitleItemToSelect.name,
1132 class: this
1133 }]);
1134 };
1135
1136 // Show popup items to select
1137 showPopupItemsToSelect = args => {
1138 const {
1139 e,
1140 target = false,
1141 callBack
1142 } = args;
1143 const elBtnShowPopupItemsToSelect = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect}`);
1144 if (!elBtnShowPopupItemsToSelect) {
1145 return;
1146 }
1147
1148 // Reset items selected data when opening popup
1149 itemsSelectedData = [];
1150 const templateId = target.dataset.template || '';
1151 const modalTemplate = document.querySelector(templateId);
1152 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
1153 html: modalTemplate.innerHTML,
1154 showConfirmButton: false,
1155 showCloseButton: true,
1156 width: 'max(350px, 65vw)',
1157 customClass: {
1158 popup: 'lp-select-items-popup',
1159 htmlContainer: 'lp-select-items-html-container',
1160 container: 'lp-select-items-container'
1161 },
1162 willOpen: () => {
1163 elPopup = sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().getPopup();
1164 const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1165
1166 // Avoid duplicate AJAX: loadAJAX.js handles fresh elements; skip if already loaded. Set timeout to ensure DOM is ready handle.
1167 setTimeout(() => {
1168 const elLoadAjaxElement = elLPTarget.closest('.lp-load-ajax-element:not(.loaded)');
1169 if (!elLoadAjaxElement) {
1170 return;
1171 }
1172 if (elLPTarget) {
1173 const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1174 dataSend.args.paged = 1;
1175 dataSend.args.item_selecting = itemsSelectedData || [];
1176 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
1177 window.lpAJAXG.fetchAJAX(dataSend, {
1178 success: response => {
1179 const {
1180 data
1181 } = response;
1182 const elSkeleton = elPopup.querySelector('.lp-skeleton-animation');
1183 elSkeleton.remove();
1184 elLPTarget.innerHTML = data.content || '';
1185 this.watchItemsSelectedDataChange();
1186 }
1187 });
1188 }
1189 }, 1);
1190 }
1191 }).then(result => {
1192 if (result.isDismissed) {}
1193 });
1194 };
1195
1196 // Choose tab items type
1197 chooseTabItemsType = args => {
1198 const {
1199 e,
1200 target,
1201 callBack
1202 } = args;
1203 const elTabType = target.closest('.tab');
1204 if (!elTabType) {
1205 return;
1206 }
1207 e.preventDefault();
1208 const elTabs = elTabType.closest('.tabs');
1209 if (!elTabs) {
1210 return;
1211 }
1212 const elSelectItemsToAdd = elTabs.closest(`${LpPopupSelectItemToAdd.selectors.elPopupItemsToSelect}`);
1213 const elInputSearch = elSelectItemsToAdd.querySelector(`${LpPopupSelectItemToAdd.selectors.elSearchTitleItem}`);
1214 const itemType = elTabType.dataset.type;
1215 const elTabLis = elTabs.querySelectorAll('.tab');
1216 elTabLis.forEach(elTabLi => {
1217 if (elTabLi.classList.contains('active')) {
1218 elTabLi.classList.remove('active');
1219 }
1220 });
1221 elTabType.classList.add('active');
1222 // Reset search input
1223 elInputSearch.value = '';
1224 const elLPTarget = elSelectItemsToAdd.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1225 const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1226 dataSend.args.item_type = itemType;
1227 dataSend.args.paged = 1;
1228 dataSend.args.item_selecting = itemsSelectedData || [];
1229 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
1230 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1231 window.lpAJAXG.fetchAJAX(dataSend, {
1232 success: response => {
1233 const {
1234 data
1235 } = response;
1236 elLPTarget.innerHTML = data.content || '';
1237 },
1238 error: error => {
1239 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
1240 },
1241 completed: () => {
1242 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1243 this.watchItemsSelectedDataChange();
1244 }
1245 });
1246 };
1247
1248 // Choice items to add list items selected before adding to section
1249 selectItemsFromList = args => {
1250 const {
1251 e,
1252 target
1253 } = args;
1254 const elItemAttend = target.closest(`${LpPopupSelectItemToAdd.selectors.elSelectItem}`);
1255 if (!elItemAttend) {
1256 return;
1257 }
1258 const elInput = elItemAttend.querySelector('input[type="checkbox"]');
1259 if (target.tagName !== 'INPUT') {
1260 elInput.click();
1261 return;
1262 }
1263 const elUl = elItemAttend.closest(`${LpPopupSelectItemToAdd.selectors.elListItems}`);
1264 if (!elUl) {
1265 return;
1266 }
1267 const itemSelected = {
1268 ...elInput.dataset
1269 };
1270 //console.log( 'itemSelected', itemSelected );
1271
1272 if (elInput.checked) {
1273 const exists = itemsSelectedData.some(item => item.id === itemSelected.id);
1274 if (!exists) {
1275 itemsSelectedData.push(itemSelected);
1276 }
1277 } else {
1278 const index = itemsSelectedData.findIndex(item => item.id === itemSelected.id);
1279 if (index !== -1) {
1280 itemsSelectedData.splice(index, 1);
1281 }
1282 }
1283 this.watchItemsSelectedDataChange();
1284 };
1285
1286 // Search title item
1287 searchTitleItemToSelect = args => {
1288 const {
1289 e,
1290 target
1291 } = args;
1292 const elInputSearch = target.closest(LpPopupSelectItemToAdd.selectors.elSearchTitleItem);
1293 if (!elInputSearch) {
1294 return;
1295 }
1296 const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1297 clearTimeout(timeSearchTitleItem);
1298 timeSearchTitleItem = setTimeout(() => {
1299 const dataSet = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1300 dataSet.args.search_title = elInputSearch.value.trim();
1301 dataSet.args.item_selecting = itemsSelectedData;
1302 dataSet.args.paged = 1;
1303 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSet);
1304
1305 // Show loading
1306 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1307 window.lpAJAXG.fetchAJAX(dataSet, {
1308 success: response => {
1309 const {
1310 data
1311 } = response;
1312 elLPTarget.innerHTML = data.content || '';
1313 },
1314 error: error => {
1315 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
1316 },
1317 completed: () => {
1318 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1319 }
1320 });
1321 }, 800);
1322 };
1323
1324 // Show list of items, to choose items to add to section
1325 showItemsSelected = args => {
1326 const {
1327 e,
1328 target
1329 } = args;
1330 const elBtnCountItemsSelected = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1331 if (!elBtnCountItemsSelected) {
1332 return;
1333 }
1334 const elBtnBack = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnBackListItems}`);
1335 const elTabs = elPopup.querySelector('.tabs');
1336 const elListItemsWrap = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsWrap}`);
1337 const elHeaderItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1338 const elListItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsSelected}`);
1339 const elItemClone = elListItemsSelected.querySelector(`${LpPopupSelectItemToAdd.selectors.elItemSelectedClone}`);
1340 elHeaderItemsSelected.innerHTML = elBtnCountItemsSelected.innerHTML;
1341 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsWrap, 0);
1342 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnCountItemsSelected, 0);
1343 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elTabs, 0);
1344 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnBack, 1);
1345 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elHeaderItemsSelected, 1);
1346 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsSelected, 1);
1347 elListItemsSelected.querySelectorAll(`${LpPopupSelectItemToAdd.selectors.elItemSelected}:not(.clone)`).forEach(elItem => {
1348 elItem.remove();
1349 });
1350 itemsSelectedData.forEach(item => {
1351 const elItemSelected = elItemClone.cloneNode(true);
1352 elItemSelected.classList.remove('clone');
1353 Object.entries(item).forEach(([key, value]) => {
1354 elItemSelected.dataset[key] = value;
1355 });
1356 const elTitleDisplay = elItemSelected.querySelector('.title-display');
1357 elTitleDisplay.innerHTML = item.title;
1358 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elItemSelected, 1);
1359 elItemClone.insertAdjacentElement('beforebegin', elItemSelected);
1360 });
1361 };
1362
1363 // Back to list of items
1364 backToSelectItems = args => {
1365 const {
1366 e,
1367 target
1368 } = args;
1369 const elBtnBack = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnBackListItems}`);
1370 if (!elBtnBack) {
1371 return;
1372 }
1373 const elBtnCountItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1374 const elTabs = elPopup.querySelector('.tabs');
1375 const elListItemsWrap = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsWrap}`);
1376 const elHeaderCountItemSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1377 const elListItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsSelected}`);
1378 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnCountItemsSelected, 1);
1379 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsWrap, 1);
1380 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elTabs, 1);
1381 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnBack, 0);
1382 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elHeaderCountItemSelected, 0);
1383 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsSelected, 0);
1384 };
1385
1386 // Remove item selected from list items selected
1387 removeItemSelected = args => {
1388 const {
1389 e,
1390 target
1391 } = args;
1392 const elRemoveItemSelected = target.closest(`${LpPopupSelectItemToAdd.selectors.elItemSelected}`);
1393 if (!elRemoveItemSelected) {
1394 return;
1395 }
1396 const itemRemove = elRemoveItemSelected.dataset;
1397 const index = itemsSelectedData.findIndex(item => item.id === itemRemove.id);
1398 if (index !== -1) {
1399 itemsSelectedData.splice(index, 1);
1400 }
1401 elRemoveItemSelected.remove();
1402 this.watchItemsSelectedDataChange();
1403 };
1404
1405 // Watch items selected when data change
1406 watchItemsSelectedDataChange = () => {
1407 // Update count items selected, disable/enable buttons
1408 const elBtnAddItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected}`);
1409 const elBtnCountItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1410 const elSpanCount = elBtnCountItemsSelected.querySelector('span');
1411 const elHeaderCount = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1412 const elTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1413 if (itemsSelectedData.length !== 0) {
1414 elBtnCountItemsSelected.disabled = false;
1415 elBtnAddItemsSelected.disabled = false;
1416 elBtnAddItemsSelected.classList.add('active');
1417 elSpanCount.textContent = `(${itemsSelectedData.length})`;
1418 elHeaderCount.innerHTML = elBtnCountItemsSelected.innerHTML;
1419 } else {
1420 elBtnCountItemsSelected.disabled = true;
1421 elBtnAddItemsSelected.disabled = true;
1422 elBtnAddItemsSelected.classList.remove('active');
1423 elSpanCount.textContent = '';
1424 elHeaderCount.textContent = '';
1425 }
1426
1427 // Update list input checked, when items removed, or change tab type
1428 const elListItems = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItems}`);
1429 const elInputs = elListItems.querySelectorAll('input[type="checkbox"]');
1430 elInputs.forEach(elInputItem => {
1431 const itemSelected = elInputItem.dataset;
1432 const exists = itemsSelectedData.some(item => item.id === itemSelected.id);
1433 elInputItem.checked = exists;
1434 });
1435
1436 // Set item selecting data to dataset for query.
1437 const dataSet = window.lpAJAXG.getDataSetCurrent(elTarget);
1438 dataSet.args.item_selecting = itemsSelectedData;
1439 window.lpAJAXG.setDataSetCurrent(elTarget, dataSet);
1440 };
1441
1442 // Add items selected to section
1443 addItemsSelectedToSection = args => {
1444 const {
1445 e,
1446 target,
1447 callBackHandle
1448 } = args;
1449 if (!elPopup) {
1450 return;
1451 }
1452 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().close();
1453 if (typeof callBackHandle === 'function') {
1454 callBackHandle(itemsSelectedData);
1455 itemsSelectedData = [];
1456 }
1457 };
1458 }
1459
1460 /***/ },
1461
1462 /***/ "./assets/src/js/lpToastify.js"
1463 /*!*************************************!*\
1464 !*** ./assets/src/js/lpToastify.js ***!
1465 \*************************************/
1466 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1467
1468 "use strict";
1469 __webpack_require__.r(__webpack_exports__);
1470 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1471 /* harmony export */ show: () => (/* binding */ show)
1472 /* harmony export */ });
1473 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
1474 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
1475 /* 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");
1476 /**
1477 * Utils functions
1478 *
1479 * @param url
1480 * @param data
1481 * @param functions
1482 * @since 4.3.0
1483 * @version 1.0.0
1484 */
1485
1486
1487 const argsToastify = {
1488 text: '',
1489 gravity: lpData.toast.gravity,
1490 // `top` or `bottom`
1491 position: lpData.toast.position,
1492 // `left`, `center` or `right`
1493 className: `${lpData.toast.classPrefix}`,
1494 close: lpData.toast.close == 1,
1495 stopOnFocus: lpData.toast.stopOnFocus == 1,
1496 duration: lpData.toast.duration
1497 };
1498 const show = (message, status = 'success', argsCustom) => {
1499 let args = argsToastify;
1500 if (argsCustom) {
1501 args = {
1502 ...args,
1503 ...argsCustom
1504 };
1505 }
1506 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
1507 ...args,
1508 text: message,
1509 className: `${lpData.toast.classPrefix} ${status}`
1510 });
1511 toastify.showToast();
1512 };
1513
1514 /***/ },
1515
1516 /***/ "./assets/src/js/utils.js"
1517 /*!********************************!*\
1518 !*** ./assets/src/js/utils.js ***!
1519 \********************************/
1520 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1521
1522 "use strict";
1523 __webpack_require__.r(__webpack_exports__);
1524 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1525 /* harmony export */ debounce: () => (/* binding */ debounce),
1526 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
1527 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
1528 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
1529 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
1530 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
1531 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
1532 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
1533 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
1534 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
1535 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
1536 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
1537 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1538 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1539 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1540 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1541 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
1542 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
1543 /* harmony export */ });
1544 /**
1545 * Utils functions
1546 *
1547 * @param url
1548 * @param data
1549 * @param functions
1550 * @since 4.2.5.1
1551 * @version 1.0.7
1552 */
1553 const lpClassName = {
1554 hidden: 'lp-hidden',
1555 loading: 'loading',
1556 elCollapse: 'lp-collapse',
1557 elSectionToggle: '.lp-section-toggle',
1558 elTriggerToggle: '.lp-trigger-toggle',
1559 elBtnFullScreen: '.lp-btn-full-screen-view',
1560 elFullScreen: 'lp-full-screen-view',
1561 elBtnFullScreenClose: 'lp-full-screen-view__close'
1562 };
1563 const lpFetchAPI = (url, data = {}, functions = {}) => {
1564 if ('function' === typeof functions.before) {
1565 functions.before();
1566 }
1567 fetch(url, {
1568 method: 'GET',
1569 ...data
1570 }).then(response => response.json()).then(response => {
1571 if ('function' === typeof functions.success) {
1572 functions.success(response);
1573 }
1574 }).catch(err => {
1575 if ('function' === typeof functions.error) {
1576 functions.error(err);
1577 }
1578 }).finally(() => {
1579 if ('function' === typeof functions.completed) {
1580 functions.completed();
1581 }
1582 });
1583 };
1584
1585 /**
1586 * Get current URL without params.
1587 *
1588 * @since 4.2.5.1
1589 */
1590 const lpGetCurrentURLNoParam = () => {
1591 let currentUrl = window.location.href;
1592 const hasParams = currentUrl.includes('?');
1593 if (hasParams) {
1594 currentUrl = currentUrl.split('?')[0];
1595 }
1596 return currentUrl;
1597 };
1598 const lpAddQueryArgs = (endpoint, args) => {
1599 const url = new URL(endpoint);
1600 Object.keys(args).forEach(arg => {
1601 url.searchParams.set(arg, args[arg]);
1602 });
1603 return url;
1604 };
1605
1606 /**
1607 * Listen element viewed.
1608 *
1609 * @param el
1610 * @param callback
1611 * @since 4.2.5.8
1612 */
1613 const listenElementViewed = (el, callback) => {
1614 const observerSeeItem = new IntersectionObserver(function (entries) {
1615 for (const entry of entries) {
1616 if (entry.isIntersecting) {
1617 callback(entry);
1618 }
1619 }
1620 });
1621 observerSeeItem.observe(el);
1622 };
1623
1624 /**
1625 * Listen element created.
1626 *
1627 * @param callback
1628 * @since 4.2.5.8
1629 */
1630 const listenElementCreated = callback => {
1631 const observerCreateItem = new MutationObserver(function (mutations) {
1632 mutations.forEach(function (mutation) {
1633 if (mutation.addedNodes) {
1634 mutation.addedNodes.forEach(function (node) {
1635 if (node.nodeType === 1) {
1636 callback(node);
1637 }
1638 });
1639 }
1640 });
1641 });
1642 observerCreateItem.observe(document, {
1643 childList: true,
1644 subtree: true
1645 });
1646 // End.
1647 };
1648
1649 /**
1650 * Listen element created.
1651 *
1652 * @param selector
1653 * @param callback
1654 * @since 4.2.7.1
1655 */
1656 const lpOnElementReady = (selector, callback) => {
1657 const element = document.querySelector(selector);
1658 if (element) {
1659 callback(element);
1660 return;
1661 }
1662 const observer = new MutationObserver((mutations, obs) => {
1663 const element = document.querySelector(selector);
1664 if (element) {
1665 obs.disconnect();
1666 callback(element);
1667 }
1668 });
1669 observer.observe(document.documentElement, {
1670 childList: true,
1671 subtree: true
1672 });
1673 };
1674
1675 // Parse JSON from string with content include LP_AJAX_START.
1676 const lpAjaxParseJsonOld = data => {
1677 if (typeof data !== 'string') {
1678 return data;
1679 }
1680 const m = String.raw({
1681 raw: data
1682 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1683 try {
1684 if (m) {
1685 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1686 } else {
1687 data = JSON.parse(data);
1688 }
1689 } catch (e) {
1690 data = {};
1691 }
1692 return data;
1693 };
1694
1695 // status 0: hide, 1: show
1696 const lpShowHideEl = (el, status = 0) => {
1697 if (!el) {
1698 return;
1699 }
1700 if (!status) {
1701 el.classList.add(lpClassName.hidden);
1702 } else {
1703 el.classList.remove(lpClassName.hidden);
1704 }
1705 };
1706
1707 // status 0: hide, 1: show
1708 const lpSetLoadingEl = (el, status) => {
1709 if (!el) {
1710 return;
1711 }
1712 if (!status) {
1713 el.classList.remove(lpClassName.loading);
1714 } else {
1715 el.classList.add(lpClassName.loading);
1716 }
1717 };
1718
1719 // Toggle collapse section
1720 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1721 if (!elTriggerClassName) {
1722 elTriggerClassName = lpClassName.elTriggerToggle;
1723 }
1724
1725 // Exclude elements, which should not trigger the collapse toggle
1726 if (elsExclude && elsExclude.length > 0) {
1727 for (const elExclude of elsExclude) {
1728 if (target.closest(elExclude)) {
1729 return;
1730 }
1731 }
1732 }
1733 const elTrigger = target.closest(elTriggerClassName);
1734 if (!elTrigger) {
1735 return;
1736 }
1737
1738 //console.log( 'elTrigger', elTrigger );
1739
1740 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1741 if (!elSectionToggle) {
1742 return;
1743 }
1744 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1745 if ('function' === typeof callback) {
1746 callback(elSectionToggle);
1747 }
1748 };
1749
1750 // Get data of form
1751 const getDataOfForm = form => {
1752 const dataSend = {};
1753 const formData = new FormData(form);
1754 for (const pair of formData.entries()) {
1755 const key = pair[0];
1756 const value = formData.getAll(key);
1757 if (!dataSend.hasOwnProperty(key)) {
1758 // Convert value array to string.
1759 dataSend[key] = value.join(',');
1760 }
1761 }
1762 return dataSend;
1763 };
1764
1765 // Get field keys of form
1766 const getFieldKeysOfForm = form => {
1767 const keys = [];
1768 const elements = form.elements;
1769 for (let i = 0; i < elements.length; i++) {
1770 const name = elements[i].name;
1771 if (name && !keys.includes(name)) {
1772 keys.push(name);
1773 }
1774 }
1775 return keys;
1776 };
1777
1778 // Merge data handle with data form.
1779 const mergeDataWithDatForm = (elForm, dataHandle) => {
1780 const dataForm = getDataOfForm(elForm);
1781 const keys = getFieldKeysOfForm(elForm);
1782 keys.forEach(key => {
1783 if (!dataForm.hasOwnProperty(key)) {
1784 delete dataHandle[key];
1785 } else if (dataForm[key][0] === '') {
1786 delete dataForm[key];
1787 delete dataHandle[key];
1788 }
1789 });
1790 dataHandle = {
1791 ...dataHandle,
1792 ...dataForm
1793 };
1794 return dataHandle;
1795 };
1796
1797 /**
1798 * Event trigger
1799 * For each list of event handlers, listen event on document.
1800 *
1801 * eventName: 'click', 'change', ...
1802 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1803 *
1804 * @param eventName
1805 * @param eventHandlers
1806 */
1807 const eventHandlers = (eventName, eventHandlers) => {
1808 document.addEventListener(eventName, e => {
1809 const target = e.target;
1810 let args = {
1811 e,
1812 target
1813 };
1814 eventHandlers.forEach(eventHandler => {
1815 args = {
1816 ...args,
1817 ...eventHandler
1818 };
1819
1820 //console.log( args );
1821
1822 // Check condition before call back
1823 if (eventHandler.conditionBeforeCallBack) {
1824 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1825 return;
1826 }
1827 }
1828
1829 // Special check for keydown event with checkIsEventEnter = true
1830 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1831 if (e.key !== 'Enter') {
1832 return;
1833 }
1834 }
1835 if (target.closest(eventHandler.selector)) {
1836 if (eventHandler.class) {
1837 // Call method of class, function callBack will understand exactly {this} is class object.
1838 eventHandler.class[eventHandler.callBack](args);
1839 } else {
1840 // For send args is objected, {this} is eventHandler object, not class object.
1841 eventHandler.callBack(args);
1842 }
1843 }
1844 });
1845 });
1846 };
1847
1848 /**
1849 * Debounce - delays function execution until after `wait` ms of inactivity.
1850 *
1851 * Each call resets the timer. Only the last call in a burst executes.
1852 *
1853 * USE CASES:
1854 * - Search inputs, form validation, window resize
1855 * - Multiple elements need independent timers
1856 * - When you need to call with different arguments
1857 *
1858 * EXAMPLES:
1859 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1860 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1861 *
1862 * const debouncedResize = debounce( recalculateLayout, 250 );
1863 * window.addEventListener('resize', debouncedResize);
1864 *
1865 * ⚠️ Create ONCE outside event handlers, not inside.
1866 *
1867 * @param {Function} func - Function to debounce (can be anonymous)
1868 * @param {number} wait - Milliseconds to wait (default: 500)
1869 * @return {Function} Debounced wrapper function
1870 * @since 4.3.7
1871 * @version 1.0.0
1872 */
1873 const debounce = (func, wait = 500) => {
1874 let timer;
1875 return args => {
1876 clearTimeout(timer);
1877 timer = setTimeout(() => func(args), wait);
1878 };
1879 };
1880
1881 /**
1882 * Initialize lp-toggle-enable components.
1883 *
1884 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1885 * Reads initial state from `data-enabled` attribute ("true"/"false").
1886 * Calls `data-on-toggle` callback (if provided via options) on state change.
1887 *
1888 * HTML structure:
1889 * <label class="lp-toggle-enable" data-enabled="true">
1890 * <input type="checkbox" class="lp-toggle-enable__input" />
1891 * <span class="lp-toggle-enable__track"></span>
1892 * </label>
1893 *
1894 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1895 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1896 * @since 4.4.5
1897 * @version 1.0.0
1898 */
1899 window.lpToggleEnableInit = 0;
1900 const toggleEnable = (onToggle = null) => {
1901 if (window.lpToggleEnableInit) {
1902 return;
1903 }
1904 window.lpToggleEnableInit = 1;
1905 const selector = '.lp-toggle-enable';
1906 const updateUI = (toggle, isEnabled) => {
1907 toggle.classList.toggle('is-enabled', isEnabled);
1908 const input = toggle.querySelector('.lp-toggle-enable__input');
1909 if (input) {
1910 input.checked = isEnabled;
1911 input.value = isEnabled ? '1' : '0';
1912 }
1913 };
1914
1915 // Delegate click handling via eventHandlers.
1916 eventHandlers('click', [{
1917 selector,
1918 callBack: args => {
1919 const {
1920 e,
1921 target
1922 } = args;
1923 const toggle = target.closest(selector);
1924 if (!toggle || toggle.classList.contains('is-disabled')) {
1925 return;
1926 }
1927 e.preventDefault();
1928 const isEnabled = !toggle.classList.contains('is-enabled');
1929 updateUI(toggle, isEnabled);
1930 if ('function' === typeof onToggle) {
1931 onToggle(toggle, isEnabled);
1932 }
1933 }
1934 }]);
1935 };
1936
1937 /**
1938 * Initialize custom fullscreen view buttons.
1939 *
1940 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1941 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1942 * target element. Falls back to the button's parent element when
1943 * `data-target` is not provided.
1944 *
1945 * @since 4.4.5
1946 * @version 1.0.0
1947 */
1948 window.lpFullScreenViewInit = 0;
1949 const fullScreenView = () => {
1950 if (window.lpFullScreenViewInit) {
1951 return;
1952 }
1953 window.lpFullScreenViewInit = 1;
1954 let lastScrollY = 0;
1955 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1956 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1957 if (isFullscreen) {
1958 elTarget.classList.remove(lpClassName.elFullScreen);
1959 document.documentElement.classList.remove('lp-full-screen-active');
1960 window.scrollTo(0, lastScrollY);
1961 } else {
1962 lastScrollY = window.scrollY;
1963 elTarget.classList.add(lpClassName.elFullScreen);
1964 document.documentElement.classList.add('lp-full-screen-active');
1965 }
1966 if (!isFullscreen) {
1967 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1968 const closeButton = document.createElement('button');
1969 closeButton.type = 'button';
1970 closeButton.className = lpClassName.elBtnFullScreenClose;
1971 closeButton.setAttribute('aria-label', 'Close');
1972 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1973 closeButton.addEventListener('click', e => {
1974 e.preventDefault();
1975 lpToggleFullscreenView(elTarget);
1976 });
1977 elTarget.appendChild(closeButton);
1978 }
1979 } else {
1980 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1981 if (closeButton) {
1982 closeButton.remove();
1983 }
1984 }
1985 };
1986 eventHandlers('click', [{
1987 selector: lpClassName.elBtnFullScreen,
1988 callBack: args => {
1989 const {
1990 e,
1991 target
1992 } = args;
1993 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1994 if (!elBtnFullScreen) {
1995 console.log('No full screen button found');
1996 return;
1997 }
1998 e.preventDefault();
1999 let elTarget = null;
2000 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
2001 console.log(targetSelector);
2002 if (targetSelector) {
2003 elTarget = document.querySelector(targetSelector);
2004 }
2005 if (!elTarget) {
2006 console.log('No target element found');
2007 return;
2008 }
2009 lpToggleFullscreenView(elTarget, elBtnFullScreen);
2010 }
2011 }]);
2012 };
2013
2014 /***/ },
2015
2016 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
2017 /*!*****************************************************************************************!*\
2018 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
2019 \*****************************************************************************************/
2020 (module, __webpack_exports__, __webpack_require__) {
2021
2022 "use strict";
2023 __webpack_require__.r(__webpack_exports__);
2024 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2025 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2026 /* harmony export */ });
2027 /* 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");
2028 /* 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__);
2029 /* 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");
2030 /* 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__);
2031 // Imports
2032
2033
2034 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()));
2035 // Module
2036 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
2037 * Toastify js 1.12.0
2038 * https://github.com/apvarun/toastify-js
2039 * @license MIT licensed
2040 *
2041 * Copyright (C) 2018 Varun A P
2042 */
2043
2044 .toastify {
2045 padding: 12px 20px;
2046 color: #ffffff;
2047 display: inline-block;
2048 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
2049 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
2050 background: linear-gradient(135deg, #73a5ff, #5477f5);
2051 position: fixed;
2052 opacity: 0;
2053 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
2054 border-radius: 2px;
2055 cursor: pointer;
2056 text-decoration: none;
2057 max-width: calc(50% - 20px);
2058 z-index: 2147483647;
2059 }
2060
2061 .toastify.on {
2062 opacity: 1;
2063 }
2064
2065 .toast-close {
2066 background: transparent;
2067 border: 0;
2068 color: white;
2069 cursor: pointer;
2070 font-family: inherit;
2071 font-size: 1em;
2072 opacity: 0.4;
2073 padding: 0 5px;
2074 }
2075
2076 .toastify-right {
2077 right: 15px;
2078 }
2079
2080 .toastify-left {
2081 left: 15px;
2082 }
2083
2084 .toastify-top {
2085 top: -150px;
2086 }
2087
2088 .toastify-bottom {
2089 bottom: -150px;
2090 }
2091
2092 .toastify-rounded {
2093 border-radius: 25px;
2094 }
2095
2096 .toastify-avatar {
2097 width: 1.5em;
2098 height: 1.5em;
2099 margin: -7px 5px;
2100 border-radius: 2px;
2101 }
2102
2103 .toastify-center {
2104 margin-left: auto;
2105 margin-right: auto;
2106 left: 0;
2107 right: 0;
2108 max-width: fit-content;
2109 max-width: -moz-fit-content;
2110 }
2111
2112 @media only screen and (max-width: 360px) {
2113 .toastify-right, .toastify-left {
2114 margin-left: auto;
2115 margin-right: auto;
2116 left: 0;
2117 right: 0;
2118 max-width: fit-content;
2119 }
2120 }
2121 `, "",{"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":""}]);
2122 // Exports
2123 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
2124
2125
2126 /***/ },
2127
2128 /***/ "./node_modules/css-loader/dist/runtime/api.js"
2129 /*!*****************************************************!*\
2130 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
2131 \*****************************************************/
2132 (module) {
2133
2134 "use strict";
2135
2136
2137 /*
2138 MIT License http://www.opensource.org/licenses/mit-license.php
2139 Author Tobias Koppers @sokra
2140 */
2141 module.exports = function (cssWithMappingToString) {
2142 var list = [];
2143
2144 // return the list of modules as css string
2145 list.toString = function toString() {
2146 return this.map(function (item) {
2147 var content = "";
2148 var needLayer = typeof item[5] !== "undefined";
2149 if (item[4]) {
2150 content += "@supports (".concat(item[4], ") {");
2151 }
2152 if (item[2]) {
2153 content += "@media ".concat(item[2], " {");
2154 }
2155 if (needLayer) {
2156 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
2157 }
2158 content += cssWithMappingToString(item);
2159 if (needLayer) {
2160 content += "}";
2161 }
2162 if (item[2]) {
2163 content += "}";
2164 }
2165 if (item[4]) {
2166 content += "}";
2167 }
2168 return content;
2169 }).join("");
2170 };
2171
2172 // import a list of modules into the list
2173 list.i = function i(modules, media, dedupe, supports, layer) {
2174 if (typeof modules === "string") {
2175 modules = [[null, modules, undefined]];
2176 }
2177 var alreadyImportedModules = {};
2178 if (dedupe) {
2179 for (var k = 0; k < this.length; k++) {
2180 var id = this[k][0];
2181 if (id != null) {
2182 alreadyImportedModules[id] = true;
2183 }
2184 }
2185 }
2186 for (var _k = 0; _k < modules.length; _k++) {
2187 var item = [].concat(modules[_k]);
2188 if (dedupe && alreadyImportedModules[item[0]]) {
2189 continue;
2190 }
2191 if (typeof layer !== "undefined") {
2192 if (typeof item[5] === "undefined") {
2193 item[5] = layer;
2194 } else {
2195 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
2196 item[5] = layer;
2197 }
2198 }
2199 if (media) {
2200 if (!item[2]) {
2201 item[2] = media;
2202 } else {
2203 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
2204 item[2] = media;
2205 }
2206 }
2207 if (supports) {
2208 if (!item[4]) {
2209 item[4] = "".concat(supports);
2210 } else {
2211 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
2212 item[4] = supports;
2213 }
2214 }
2215 list.push(item);
2216 }
2217 };
2218 return list;
2219 };
2220
2221 /***/ },
2222
2223 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
2224 /*!************************************************************!*\
2225 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
2226 \************************************************************/
2227 (module) {
2228
2229 "use strict";
2230
2231
2232 module.exports = function (item) {
2233 var content = item[1];
2234 var cssMapping = item[3];
2235 if (!cssMapping) {
2236 return content;
2237 }
2238 if (typeof btoa === "function") {
2239 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
2240 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
2241 var sourceMapping = "/*# ".concat(data, " */");
2242 return [content].concat([sourceMapping]).join("\n");
2243 }
2244 return [content].join("\n");
2245 };
2246
2247 /***/ },
2248
2249 /***/ "./node_modules/toastify-js/src/toastify.css"
2250 /*!***************************************************!*\
2251 !*** ./node_modules/toastify-js/src/toastify.css ***!
2252 \***************************************************/
2253 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2254
2255 "use strict";
2256 __webpack_require__.r(__webpack_exports__);
2257 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2258 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2259 /* harmony export */ });
2260 /* 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");
2261 /* 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__);
2262 /* 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");
2263 /* 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__);
2264 /* 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");
2265 /* 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__);
2266 /* 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");
2267 /* 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__);
2268 /* 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");
2269 /* 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__);
2270 /* 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");
2271 /* 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__);
2272 /* 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");
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284 var options = {};
2285
2286 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
2287 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
2288
2289 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
2290
2291 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
2292 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
2293
2294 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);
2295
2296
2297
2298
2299 /* 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);
2300
2301
2302 /***/ },
2303
2304 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
2305 /*!****************************************************************************!*\
2306 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
2307 \****************************************************************************/
2308 (module) {
2309
2310 "use strict";
2311
2312
2313 var stylesInDOM = [];
2314 function getIndexByIdentifier(identifier) {
2315 var result = -1;
2316 for (var i = 0; i < stylesInDOM.length; i++) {
2317 if (stylesInDOM[i].identifier === identifier) {
2318 result = i;
2319 break;
2320 }
2321 }
2322 return result;
2323 }
2324 function modulesToDom(list, options) {
2325 var idCountMap = {};
2326 var identifiers = [];
2327 for (var i = 0; i < list.length; i++) {
2328 var item = list[i];
2329 var id = options.base ? item[0] + options.base : item[0];
2330 var count = idCountMap[id] || 0;
2331 var identifier = "".concat(id, " ").concat(count);
2332 idCountMap[id] = count + 1;
2333 var indexByIdentifier = getIndexByIdentifier(identifier);
2334 var obj = {
2335 css: item[1],
2336 media: item[2],
2337 sourceMap: item[3],
2338 supports: item[4],
2339 layer: item[5]
2340 };
2341 if (indexByIdentifier !== -1) {
2342 stylesInDOM[indexByIdentifier].references++;
2343 stylesInDOM[indexByIdentifier].updater(obj);
2344 } else {
2345 var updater = addElementStyle(obj, options);
2346 options.byIndex = i;
2347 stylesInDOM.splice(i, 0, {
2348 identifier: identifier,
2349 updater: updater,
2350 references: 1
2351 });
2352 }
2353 identifiers.push(identifier);
2354 }
2355 return identifiers;
2356 }
2357 function addElementStyle(obj, options) {
2358 var api = options.domAPI(options);
2359 api.update(obj);
2360 var updater = function updater(newObj) {
2361 if (newObj) {
2362 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
2363 return;
2364 }
2365 api.update(obj = newObj);
2366 } else {
2367 api.remove();
2368 }
2369 };
2370 return updater;
2371 }
2372 module.exports = function (list, options) {
2373 options = options || {};
2374 list = list || [];
2375 var lastIdentifiers = modulesToDom(list, options);
2376 return function update(newList) {
2377 newList = newList || [];
2378 for (var i = 0; i < lastIdentifiers.length; i++) {
2379 var identifier = lastIdentifiers[i];
2380 var index = getIndexByIdentifier(identifier);
2381 stylesInDOM[index].references--;
2382 }
2383 var newLastIdentifiers = modulesToDom(newList, options);
2384 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
2385 var _identifier = lastIdentifiers[_i];
2386 var _index = getIndexByIdentifier(_identifier);
2387 if (stylesInDOM[_index].references === 0) {
2388 stylesInDOM[_index].updater();
2389 stylesInDOM.splice(_index, 1);
2390 }
2391 }
2392 lastIdentifiers = newLastIdentifiers;
2393 };
2394 };
2395
2396 /***/ },
2397
2398 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
2399 /*!********************************************************************!*\
2400 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
2401 \********************************************************************/
2402 (module) {
2403
2404 "use strict";
2405
2406
2407 var memo = {};
2408
2409 /* istanbul ignore next */
2410 function getTarget(target) {
2411 if (typeof memo[target] === "undefined") {
2412 var styleTarget = document.querySelector(target);
2413
2414 // Special case to return head of iframe instead of iframe itself
2415 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
2416 try {
2417 // This will throw an exception if access to iframe is blocked
2418 // due to cross-origin restrictions
2419 styleTarget = styleTarget.contentDocument.head;
2420 } catch (e) {
2421 // istanbul ignore next
2422 styleTarget = null;
2423 }
2424 }
2425 memo[target] = styleTarget;
2426 }
2427 return memo[target];
2428 }
2429
2430 /* istanbul ignore next */
2431 function insertBySelector(insert, style) {
2432 var target = getTarget(insert);
2433 if (!target) {
2434 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
2435 }
2436 target.appendChild(style);
2437 }
2438 module.exports = insertBySelector;
2439
2440 /***/ },
2441
2442 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
2443 /*!**********************************************************************!*\
2444 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
2445 \**********************************************************************/
2446 (module) {
2447
2448 "use strict";
2449
2450
2451 /* istanbul ignore next */
2452 function insertStyleElement(options) {
2453 var element = document.createElement("style");
2454 options.setAttributes(element, options.attributes);
2455 options.insert(element, options.options);
2456 return element;
2457 }
2458 module.exports = insertStyleElement;
2459
2460 /***/ },
2461
2462 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
2463 /*!**********************************************************************************!*\
2464 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
2465 \**********************************************************************************/
2466 (module, __unused_webpack_exports, __webpack_require__) {
2467
2468 "use strict";
2469
2470
2471 /* istanbul ignore next */
2472 function setAttributesWithoutAttributes(styleElement) {
2473 var nonce = true ? __webpack_require__.nc : 0;
2474 if (nonce) {
2475 styleElement.setAttribute("nonce", nonce);
2476 }
2477 }
2478 module.exports = setAttributesWithoutAttributes;
2479
2480 /***/ },
2481
2482 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
2483 /*!***************************************************************!*\
2484 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
2485 \***************************************************************/
2486 (module) {
2487
2488 "use strict";
2489
2490
2491 /* istanbul ignore next */
2492 function apply(styleElement, options, obj) {
2493 var css = "";
2494 if (obj.supports) {
2495 css += "@supports (".concat(obj.supports, ") {");
2496 }
2497 if (obj.media) {
2498 css += "@media ".concat(obj.media, " {");
2499 }
2500 var needLayer = typeof obj.layer !== "undefined";
2501 if (needLayer) {
2502 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
2503 }
2504 css += obj.css;
2505 if (needLayer) {
2506 css += "}";
2507 }
2508 if (obj.media) {
2509 css += "}";
2510 }
2511 if (obj.supports) {
2512 css += "}";
2513 }
2514 var sourceMap = obj.sourceMap;
2515 if (sourceMap && typeof btoa !== "undefined") {
2516 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
2517 }
2518
2519 // For old IE
2520 /* istanbul ignore if */
2521 options.styleTagTransform(css, styleElement, options.options);
2522 }
2523 function removeStyleElement(styleElement) {
2524 // istanbul ignore if
2525 if (styleElement.parentNode === null) {
2526 return false;
2527 }
2528 styleElement.parentNode.removeChild(styleElement);
2529 }
2530
2531 /* istanbul ignore next */
2532 function domAPI(options) {
2533 if (typeof document === "undefined") {
2534 return {
2535 update: function update() {},
2536 remove: function remove() {}
2537 };
2538 }
2539 var styleElement = options.insertStyleElement(options);
2540 return {
2541 update: function update(obj) {
2542 apply(styleElement, options, obj);
2543 },
2544 remove: function remove() {
2545 removeStyleElement(styleElement);
2546 }
2547 };
2548 }
2549 module.exports = domAPI;
2550
2551 /***/ },
2552
2553 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
2554 /*!*********************************************************************!*\
2555 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
2556 \*********************************************************************/
2557 (module) {
2558
2559 "use strict";
2560
2561
2562 /* istanbul ignore next */
2563 function styleTagTransform(css, styleElement) {
2564 if (styleElement.styleSheet) {
2565 styleElement.styleSheet.cssText = css;
2566 } else {
2567 while (styleElement.firstChild) {
2568 styleElement.removeChild(styleElement.firstChild);
2569 }
2570 styleElement.appendChild(document.createTextNode(css));
2571 }
2572 }
2573 module.exports = styleTagTransform;
2574
2575 /***/ },
2576
2577 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
2578 /*!**********************************************************!*\
2579 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
2580 \**********************************************************/
2581 (module) {
2582
2583 /*!
2584 * sweetalert2 v11.26.25
2585 * Released under the MIT License.
2586 */
2587 (function (global, factory) {
2588 true ? module.exports = factory() :
2589 0;
2590 })(this, (function () { 'use strict';
2591
2592 function _assertClassBrand(e, t, n) {
2593 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2594 throw new TypeError("Private element is not present on this object");
2595 }
2596 function _checkPrivateRedeclaration(e, t) {
2597 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2598 }
2599 function _classPrivateFieldGet2(s, a) {
2600 return s.get(_assertClassBrand(s, a));
2601 }
2602 function _classPrivateFieldInitSpec(e, t, a) {
2603 _checkPrivateRedeclaration(e, t), t.set(e, a);
2604 }
2605 function _classPrivateFieldSet2(s, a, r) {
2606 return s.set(_assertClassBrand(s, a), r), r;
2607 }
2608
2609 const RESTORE_FOCUS_TIMEOUT = 100;
2610
2611 /** @type {GlobalState} */
2612 const globalState = {};
2613 const focusPreviousActiveElement = () => {
2614 if (globalState.previousActiveElement instanceof HTMLElement) {
2615 globalState.previousActiveElement.focus();
2616 globalState.previousActiveElement = null;
2617 } else if (document.body) {
2618 document.body.focus();
2619 }
2620 };
2621
2622 /**
2623 * Restore previous active (focused) element
2624 *
2625 * @param {boolean} returnFocus
2626 * @returns {Promise<void>}
2627 */
2628 const restoreActiveElement = returnFocus => {
2629 return new Promise(resolve => {
2630 if (!returnFocus) {
2631 return resolve();
2632 }
2633 const x = window.scrollX;
2634 const y = window.scrollY;
2635 globalState.restoreFocusTimeout = setTimeout(() => {
2636 focusPreviousActiveElement();
2637 resolve();
2638 }, RESTORE_FOCUS_TIMEOUT); // issues/900
2639
2640 window.scrollTo(x, y);
2641 });
2642 };
2643
2644 const swalPrefix = 'swal2-';
2645
2646 /**
2647 * @typedef {Record<SwalClass, string>} SwalClasses
2648 */
2649
2650 /**
2651 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
2652 * @typedef {Record<SwalIcon, string>} SwalIcons
2653 */
2654
2655 /** @type {SwalClass[]} */
2656 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'];
2657 const swalClasses = classNames.reduce((acc, className) => {
2658 acc[className] = swalPrefix + className;
2659 return acc;
2660 }, /** @type {SwalClasses} */{});
2661
2662 /** @type {SwalIcon[]} */
2663 const icons = ['success', 'warning', 'info', 'question', 'error'];
2664 const iconTypes = icons.reduce((acc, icon) => {
2665 acc[icon] = swalPrefix + icon;
2666 return acc;
2667 }, /** @type {SwalIcons} */{});
2668
2669 const consolePrefix = 'SweetAlert2:';
2670
2671 /**
2672 * Capitalize the first letter of a string
2673 *
2674 * @param {string} str
2675 * @returns {string}
2676 */
2677 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2678
2679 /**
2680 * Standardize console warnings
2681 *
2682 * @param {string | string[]} message
2683 */
2684 const warn = message => {
2685 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2686 };
2687
2688 /**
2689 * Standardize console errors
2690 *
2691 * @param {string} message
2692 */
2693 const error = message => {
2694 console.error(`${consolePrefix} ${message}`);
2695 };
2696
2697 /**
2698 * Private global state for `warnOnce`
2699 *
2700 * @type {string[]}
2701 * @private
2702 */
2703 const previousWarnOnceMessages = [];
2704
2705 /**
2706 * Show a console warning, but only if it hasn't already been shown
2707 *
2708 * @param {string} message
2709 */
2710 const warnOnce = message => {
2711 if (!previousWarnOnceMessages.includes(message)) {
2712 previousWarnOnceMessages.push(message);
2713 warn(message);
2714 }
2715 };
2716
2717 /**
2718 * Show a one-time console warning about deprecated params/methods
2719 *
2720 * @param {string} deprecatedParam
2721 * @param {string?} useInstead
2722 */
2723 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2724 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2725 };
2726
2727 /**
2728 * If `arg` is a function, call it (with no arguments or context) and return the result.
2729 * Otherwise, just pass the value through
2730 *
2731 * @param {(() => *) | *} arg
2732 * @returns {*}
2733 */
2734 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2735
2736 /**
2737 * @param {*} arg
2738 * @returns {boolean}
2739 */
2740 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2741
2742 /**
2743 * @param {*} arg
2744 * @returns {Promise<*>}
2745 */
2746 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2747
2748 /**
2749 * @param {*} arg
2750 * @returns {boolean}
2751 */
2752 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2753
2754 /**
2755 * @returns {boolean}
2756 */
2757 const isFirefox = () => navigator.userAgent.includes('Firefox');
2758
2759 /**
2760 * Gets the popup container which contains the backdrop and the popup itself.
2761 *
2762 * @returns {HTMLElement | null}
2763 */
2764 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2765
2766 /**
2767 * @param {string} selectorString
2768 * @returns {HTMLElement | null}
2769 */
2770 const elementBySelector = selectorString => {
2771 const container = getContainer();
2772 return container ? container.querySelector(selectorString) : null;
2773 };
2774
2775 /**
2776 * @param {string} className
2777 * @returns {HTMLElement | null}
2778 */
2779 const elementByClass = className => {
2780 return elementBySelector(`.${className}`);
2781 };
2782
2783 /**
2784 * @returns {HTMLElement | null}
2785 */
2786 const getPopup = () => elementByClass(swalClasses.popup);
2787
2788 /**
2789 * @returns {HTMLElement | null}
2790 */
2791 const getIcon = () => elementByClass(swalClasses.icon);
2792
2793 /**
2794 * @returns {HTMLElement | null}
2795 */
2796 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2797
2798 /**
2799 * @returns {HTMLElement | null}
2800 */
2801 const getTitle = () => elementByClass(swalClasses.title);
2802
2803 /**
2804 * @returns {HTMLElement | null}
2805 */
2806 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2807
2808 /**
2809 * @returns {HTMLElement | null}
2810 */
2811 const getImage = () => elementByClass(swalClasses.image);
2812
2813 /**
2814 * @returns {HTMLElement | null}
2815 */
2816 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2817
2818 /**
2819 * @returns {HTMLElement | null}
2820 */
2821 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2822
2823 /**
2824 * @returns {HTMLButtonElement | null}
2825 */
2826 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2827
2828 /**
2829 * @returns {HTMLButtonElement | null}
2830 */
2831 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2832
2833 /**
2834 * @returns {HTMLButtonElement | null}
2835 */
2836 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2837
2838 /**
2839 * @returns {HTMLElement | null}
2840 */
2841 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2842
2843 /**
2844 * @returns {HTMLElement | null}
2845 */
2846 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2847
2848 /**
2849 * @returns {HTMLElement | null}
2850 */
2851 const getActions = () => elementByClass(swalClasses.actions);
2852
2853 /**
2854 * @returns {HTMLElement | null}
2855 */
2856 const getFooter = () => elementByClass(swalClasses.footer);
2857
2858 /**
2859 * @returns {HTMLElement | null}
2860 */
2861 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2862
2863 /**
2864 * @returns {HTMLElement | null}
2865 */
2866 const getCloseButton = () => elementByClass(swalClasses.close);
2867
2868 // https://github.com/jkup/focusable/blob/master/index.js
2869 const focusable = `
2870 a[href],
2871 area[href],
2872 input:not([disabled]),
2873 select:not([disabled]),
2874 textarea:not([disabled]),
2875 button:not([disabled]),
2876 iframe,
2877 object,
2878 embed,
2879 [tabindex="0"],
2880 [contenteditable],
2881 audio[controls],
2882 video[controls],
2883 summary
2884 `;
2885 /**
2886 * @returns {HTMLElement[]}
2887 */
2888 const getFocusableElements = () => {
2889 const popup = getPopup();
2890 if (!popup) {
2891 return [];
2892 }
2893 /** @type {NodeListOf<HTMLElement>} */
2894 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2895 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2896 // sort according to tabindex
2897 .sort((a, b) => {
2898 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2899 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2900 if (tabindexA > tabindexB) {
2901 return 1;
2902 } else if (tabindexA < tabindexB) {
2903 return -1;
2904 }
2905 return 0;
2906 });
2907
2908 /** @type {NodeListOf<HTMLElement>} */
2909 const otherFocusableElements = popup.querySelectorAll(focusable);
2910 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2911 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2912 };
2913
2914 /**
2915 * @returns {boolean}
2916 */
2917 const isModal = () => {
2918 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2919 };
2920
2921 /**
2922 * @returns {boolean}
2923 */
2924 const isToast = () => {
2925 const popup = getPopup();
2926 if (!popup) {
2927 return false;
2928 }
2929 return hasClass(popup, swalClasses.toast);
2930 };
2931
2932 /**
2933 * @returns {boolean}
2934 */
2935 const isLoading = () => {
2936 const popup = getPopup();
2937 if (!popup) {
2938 return false;
2939 }
2940 return popup.hasAttribute('data-loading');
2941 };
2942
2943 /**
2944 * Securely set innerHTML of an element
2945 * https://github.com/sweetalert2/sweetalert2/issues/1926
2946 *
2947 * @param {HTMLElement} elem
2948 * @param {string} html
2949 */
2950 const setInnerHtml = (elem, html) => {
2951 elem.textContent = '';
2952 if (html) {
2953 const parser = new DOMParser();
2954 const parsed = parser.parseFromString(html, `text/html`);
2955 const head = parsed.querySelector('head');
2956 if (head) {
2957 Array.from(head.childNodes).forEach(child => {
2958 elem.appendChild(child);
2959 });
2960 }
2961 const body = parsed.querySelector('body');
2962 if (body) {
2963 Array.from(body.childNodes).forEach(child => {
2964 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2965 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2966 } else {
2967 elem.appendChild(child);
2968 }
2969 });
2970 }
2971 }
2972 };
2973
2974 /**
2975 * @param {HTMLElement} elem
2976 * @param {string} className
2977 * @returns {boolean}
2978 */
2979 const hasClass = (elem, className) => {
2980 if (!className) {
2981 return false;
2982 }
2983 return className.split(/\s+/).every(cls => elem.classList.contains(cls));
2984 };
2985
2986 /**
2987 * @param {HTMLElement} elem
2988 * @param {SweetAlertOptions} params
2989 */
2990 const removeCustomClasses = (elem, params) => {
2991 Array.from(elem.classList).forEach(className => {
2992 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2993 elem.classList.remove(className);
2994 }
2995 });
2996 };
2997
2998 /**
2999 * @param {HTMLElement} elem
3000 * @param {SweetAlertOptions} params
3001 * @param {string} className
3002 */
3003 const applyCustomClass = (elem, params, className) => {
3004 removeCustomClasses(elem, params);
3005 if (!params.customClass) {
3006 return;
3007 }
3008 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
3009 if (!customClass) {
3010 return;
3011 }
3012 if (typeof customClass !== 'string' && !customClass.forEach) {
3013 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
3014 return;
3015 }
3016 addClass(elem, customClass);
3017 };
3018
3019 /**
3020 * @param {HTMLElement} popup
3021 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
3022 * @returns {HTMLInputElement | null}
3023 */
3024 const getInput$1 = (popup, inputClass) => {
3025 if (!inputClass) {
3026 return null;
3027 }
3028 switch (inputClass) {
3029 case 'select':
3030 case 'textarea':
3031 case 'file':
3032 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
3033 case 'checkbox':
3034 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
3035 case 'radio':
3036 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
3037 case 'range':
3038 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
3039 default:
3040 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
3041 }
3042 };
3043
3044 /**
3045 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
3046 */
3047 const focusInput = input => {
3048 input.focus();
3049
3050 // place cursor at end of text in text input
3051 if (input.type !== 'file') {
3052 // http://stackoverflow.com/a/2345915
3053 const val = input.value;
3054 input.value = '';
3055 input.value = val;
3056 }
3057 };
3058
3059 /**
3060 * @param {HTMLElement | HTMLElement[] | null} target
3061 * @param {string | string[] | readonly string[] | undefined} classList
3062 * @param {boolean} condition
3063 */
3064 const toggleClass = (target, classList, condition) => {
3065 if (!target || !classList) {
3066 return;
3067 }
3068 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
3069 const targets = Array.isArray(target) ? target : [target];
3070 targets.forEach(elem => {
3071 classes.forEach(className => {
3072 if (condition) {
3073 elem.classList.add(className);
3074 } else {
3075 elem.classList.remove(className);
3076 }
3077 });
3078 });
3079 };
3080
3081 /**
3082 * @param {HTMLElement | HTMLElement[] | null} target
3083 * @param {string | string[] | readonly string[] | undefined} classList
3084 */
3085 const addClass = (target, classList) => {
3086 toggleClass(target, classList, true);
3087 };
3088
3089 /**
3090 * @param {HTMLElement | HTMLElement[] | null} target
3091 * @param {string | string[] | readonly string[] | undefined} classList
3092 */
3093 const removeClass = (target, classList) => {
3094 toggleClass(target, classList, false);
3095 };
3096
3097 /**
3098 * Get direct child of an element by class name
3099 *
3100 * @param {HTMLElement} elem
3101 * @param {string} className
3102 * @returns {HTMLElement | undefined}
3103 */
3104 const getDirectChildByClass = (elem, className) => (/** @type {HTMLElement | undefined} */
3105 Array.from(elem.children).find(child => child instanceof HTMLElement && hasClass(child, className)));
3106
3107 /**
3108 * @param {HTMLElement} elem
3109 * @param {string} property
3110 * @param {string | number | null | undefined} value
3111 */
3112 const applyNumericalStyle = (elem, property, value) => {
3113 if (value === `${parseInt(`${value}`)}`) {
3114 value = parseInt(value);
3115 }
3116 if (value || value === 0) {
3117 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
3118 } else {
3119 elem.style.removeProperty(property);
3120 }
3121 };
3122
3123 /**
3124 * @param {HTMLElement | null} elem
3125 * @param {string} display
3126 */
3127 const show = (elem, display = 'flex') => {
3128 if (!elem) {
3129 return;
3130 }
3131 elem.style.display = display;
3132 };
3133
3134 /**
3135 * @param {HTMLElement | null} elem
3136 */
3137 const hide = elem => {
3138 if (!elem) {
3139 return;
3140 }
3141 elem.style.display = 'none';
3142 };
3143
3144 /**
3145 * @param {HTMLElement | null} elem
3146 * @param {string} display
3147 */
3148 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
3149 if (!elem) {
3150 return;
3151 }
3152 new MutationObserver(() => {
3153 toggle(elem, elem.innerHTML, display);
3154 }).observe(elem, {
3155 childList: true,
3156 subtree: true
3157 });
3158 };
3159
3160 /**
3161 * @param {HTMLElement} parent
3162 * @param {string} selector
3163 * @param {string} property
3164 * @param {string} value
3165 */
3166 const setStyle = (parent, selector, property, value) => {
3167 /** @type {HTMLElement | null} */
3168 const el = parent.querySelector(selector);
3169 if (el) {
3170 el.style.setProperty(property, value);
3171 }
3172 };
3173
3174 /**
3175 * @param {HTMLElement} elem
3176 * @param {boolean | string | null | undefined} condition
3177 * @param {string} display
3178 */
3179 const toggle = (elem, condition, display = 'flex') => {
3180 if (condition) {
3181 show(elem, display);
3182 } else {
3183 hide(elem);
3184 }
3185 };
3186
3187 /**
3188 * borrowed from jquery $(elem).is(':visible') implementation
3189 *
3190 * @param {HTMLElement | null} elem
3191 * @returns {boolean}
3192 */
3193 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
3194
3195 /**
3196 * @returns {boolean}
3197 */
3198 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
3199
3200 /**
3201 * @param {HTMLElement} elem
3202 * @returns {boolean}
3203 */
3204 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
3205
3206 /**
3207 * @param {HTMLElement} element
3208 * @param {HTMLElement} stopElement
3209 * @returns {boolean}
3210 */
3211 const selfOrParentIsScrollable = (element, stopElement) => {
3212 let parent = /** @type {HTMLElement | null} */element;
3213 while (parent && parent !== stopElement) {
3214 if (isScrollable(parent)) {
3215 return true;
3216 }
3217 parent = parent.parentElement;
3218 }
3219 return false;
3220 };
3221
3222 /**
3223 * borrowed from https://stackoverflow.com/a/46352119
3224 *
3225 * @param {HTMLElement} elem
3226 * @returns {boolean}
3227 */
3228 const hasCssAnimation = elem => {
3229 const style = window.getComputedStyle(elem);
3230 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
3231 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
3232 return animDuration > 0 || transDuration > 0;
3233 };
3234
3235 /**
3236 * @param {number} timer
3237 * @param {boolean} reset
3238 */
3239 const animateTimerProgressBar = (timer, reset = false) => {
3240 const timerProgressBar = getTimerProgressBar();
3241 if (!timerProgressBar) {
3242 return;
3243 }
3244 if (isVisible$1(timerProgressBar)) {
3245 if (reset) {
3246 timerProgressBar.style.transition = 'none';
3247 timerProgressBar.style.width = '100%';
3248 }
3249 setTimeout(() => {
3250 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
3251 timerProgressBar.style.width = '0%';
3252 }, 10);
3253 }
3254 };
3255 const stopTimerProgressBar = () => {
3256 const timerProgressBar = getTimerProgressBar();
3257 if (!timerProgressBar) {
3258 return;
3259 }
3260 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
3261 timerProgressBar.style.removeProperty('transition');
3262 timerProgressBar.style.width = '100%';
3263 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
3264 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
3265 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
3266 };
3267
3268 /**
3269 * Detect Node env
3270 *
3271 * @returns {boolean}
3272 */
3273 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
3274
3275 const sweetHTML = `
3276 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
3277 <button type="button" class="${swalClasses.close}"></button>
3278 <ul class="${swalClasses['progress-steps']}"></ul>
3279 <div class="${swalClasses.icon}"></div>
3280 <img class="${swalClasses.image}" />
3281 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
3282 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
3283 <input class="${swalClasses.input}" id="${swalClasses.input}" />
3284 <input type="file" class="${swalClasses.file}" />
3285 <div class="${swalClasses.range}">
3286 <input type="range" />
3287 <output></output>
3288 </div>
3289 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
3290 <div class="${swalClasses.radio}"></div>
3291 <label class="${swalClasses.checkbox}">
3292 <input type="checkbox" id="${swalClasses.checkbox}" />
3293 <span class="${swalClasses.label}"></span>
3294 </label>
3295 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
3296 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
3297 <div class="${swalClasses.actions}">
3298 <div class="${swalClasses.loader}"></div>
3299 <button type="button" class="${swalClasses.confirm}"></button>
3300 <button type="button" class="${swalClasses.deny}"></button>
3301 <button type="button" class="${swalClasses.cancel}"></button>
3302 </div>
3303 <div class="${swalClasses.footer}"></div>
3304 <div class="${swalClasses['timer-progress-bar-container']}">
3305 <div class="${swalClasses['timer-progress-bar']}"></div>
3306 </div>
3307 </div>
3308 `.replace(/(^|\n)\s*/g, '');
3309
3310 /**
3311 * @returns {boolean}
3312 */
3313 const resetOldContainer = () => {
3314 const oldContainer = getContainer();
3315 if (!oldContainer) {
3316 return false;
3317 }
3318 oldContainer.remove();
3319 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
3320 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
3321 swalClasses['has-column']]);
3322 return true;
3323 };
3324 const resetValidationMessage$1 = () => {
3325 if (globalState.currentInstance) {
3326 globalState.currentInstance.resetValidationMessage();
3327 }
3328 };
3329 const addInputChangeListeners = () => {
3330 const popup = getPopup();
3331 if (!popup) {
3332 return;
3333 }
3334 const input = getDirectChildByClass(popup, swalClasses.input);
3335 const file = getDirectChildByClass(popup, swalClasses.file);
3336 /** @type {HTMLInputElement | null} */
3337 const range = popup.querySelector(`.${swalClasses.range} input`);
3338 /** @type {HTMLOutputElement | null} */
3339 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
3340 const select = getDirectChildByClass(popup, swalClasses.select);
3341 /** @type {HTMLInputElement | null} */
3342 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
3343 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
3344 if (input) {
3345 input.oninput = resetValidationMessage$1;
3346 }
3347 if (file) {
3348 file.onchange = resetValidationMessage$1;
3349 }
3350 if (select) {
3351 select.onchange = resetValidationMessage$1;
3352 }
3353 if (checkbox) {
3354 checkbox.onchange = resetValidationMessage$1;
3355 }
3356 if (textarea) {
3357 textarea.oninput = resetValidationMessage$1;
3358 }
3359 if (range && rangeOutput) {
3360 range.oninput = () => {
3361 resetValidationMessage$1();
3362 rangeOutput.value = range.value;
3363 };
3364 range.onchange = () => {
3365 resetValidationMessage$1();
3366 rangeOutput.value = range.value;
3367 };
3368 }
3369 };
3370
3371 /**
3372 * @param {string | HTMLElement} target
3373 * @returns {HTMLElement}
3374 */
3375 const getTarget = target => {
3376 if (typeof target === 'string') {
3377 const element = document.querySelector(target);
3378 if (!element) {
3379 throw new Error(`Target element "${target}" not found`);
3380 }
3381 return /** @type {HTMLElement} */element;
3382 }
3383 return target;
3384 };
3385
3386 /**
3387 * @param {SweetAlertOptions} params
3388 */
3389 const setupAccessibility = params => {
3390 const popup = getPopup();
3391 if (!popup) {
3392 return;
3393 }
3394 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
3395 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
3396 if (!params.toast) {
3397 popup.setAttribute('aria-modal', 'true');
3398 }
3399 };
3400
3401 /**
3402 * @param {HTMLElement} targetElement
3403 */
3404 const setupRTL = targetElement => {
3405 if (window.getComputedStyle(targetElement).direction === 'rtl') {
3406 addClass(getContainer(), swalClasses.rtl);
3407 globalState.isRTL = true;
3408 }
3409 };
3410
3411 /**
3412 * Add modal + backdrop to DOM
3413 *
3414 * @param {SweetAlertOptions} params
3415 */
3416 const init = params => {
3417 // Clean up the old popup container if it exists
3418 const oldContainerExisted = resetOldContainer();
3419 if (isNodeEnv()) {
3420 error('SweetAlert2 requires document to initialize');
3421 return;
3422 }
3423 const container = document.createElement('div');
3424 container.className = swalClasses.container;
3425 if (oldContainerExisted) {
3426 addClass(container, swalClasses['no-transition']);
3427 }
3428 setInnerHtml(container, sweetHTML);
3429 container.dataset['swal2Theme'] = params.theme;
3430 const targetElement = getTarget(params.target || 'body');
3431 targetElement.appendChild(container);
3432 if (params.topLayer) {
3433 container.setAttribute('popover', '');
3434 container.showPopover();
3435 }
3436 setupAccessibility(params);
3437 setupRTL(targetElement);
3438 addInputChangeListeners();
3439 };
3440
3441 /**
3442 * @param {HTMLElement | object | string} param
3443 * @param {HTMLElement} target
3444 */
3445 const parseHtmlToContainer = (param, target) => {
3446 // DOM element
3447 if (param instanceof HTMLElement) {
3448 target.appendChild(param);
3449 }
3450
3451 // Object
3452 else if (typeof param === 'object') {
3453 handleObject(param, target);
3454 }
3455
3456 // Plain string
3457 else if (param) {
3458 setInnerHtml(target, param);
3459 }
3460 };
3461
3462 /**
3463 * @param {object} param
3464 * @param {HTMLElement} target
3465 */
3466 const handleObject = (param, target) => {
3467 // JQuery element(s)
3468 if ('jquery' in param) {
3469 handleJqueryElem(target, param);
3470 }
3471
3472 // For other objects use their string representation
3473 else {
3474 setInnerHtml(target, param.toString());
3475 }
3476 };
3477
3478 /**
3479 * @param {HTMLElement} target
3480 * @param {any} elem
3481 */
3482 const handleJqueryElem = (target, elem) => {
3483 target.textContent = '';
3484 if (0 in elem) {
3485 for (let i = 0; i in elem; i++) {
3486 target.appendChild(elem[i].cloneNode(true));
3487 }
3488 } else {
3489 target.appendChild(elem.cloneNode(true));
3490 }
3491 };
3492
3493 /**
3494 * @param {SweetAlert} instance
3495 * @param {SweetAlertOptions} params
3496 */
3497 const renderActions = (instance, params) => {
3498 const actions = getActions();
3499 const loader = getLoader();
3500 if (!actions || !loader) {
3501 return;
3502 }
3503
3504 // Actions (buttons) wrapper
3505 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
3506 hide(actions);
3507 } else {
3508 show(actions);
3509 }
3510
3511 // Custom class
3512 applyCustomClass(actions, params, 'actions');
3513
3514 // Render all the buttons
3515 renderButtons(actions, loader, params);
3516
3517 // Loader
3518 setInnerHtml(loader, params.loaderHtml || '');
3519 applyCustomClass(loader, params, 'loader');
3520 };
3521
3522 /**
3523 * @param {HTMLElement} actions
3524 * @param {HTMLElement} loader
3525 * @param {SweetAlertOptions} params
3526 */
3527 function renderButtons(actions, loader, params) {
3528 const confirmButton = getConfirmButton();
3529 const denyButton = getDenyButton();
3530 const cancelButton = getCancelButton();
3531 if (!confirmButton || !denyButton || !cancelButton) {
3532 return;
3533 }
3534
3535 // Render buttons
3536 renderButton(confirmButton, 'confirm', params);
3537 renderButton(denyButton, 'deny', params);
3538 renderButton(cancelButton, 'cancel', params);
3539 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3540 if (params.reverseButtons) {
3541 if (params.toast) {
3542 actions.insertBefore(cancelButton, confirmButton);
3543 actions.insertBefore(denyButton, confirmButton);
3544 } else {
3545 actions.insertBefore(cancelButton, loader);
3546 actions.insertBefore(denyButton, loader);
3547 actions.insertBefore(confirmButton, loader);
3548 }
3549 }
3550 }
3551
3552 /**
3553 * @param {HTMLElement} confirmButton
3554 * @param {HTMLElement} denyButton
3555 * @param {HTMLElement} cancelButton
3556 * @param {SweetAlertOptions} params
3557 */
3558 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3559 if (!params.buttonsStyling) {
3560 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3561 return;
3562 }
3563 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3564
3565 // Apply custom background colors and outline colors to action buttons
3566 /** @type {[HTMLElement, string, string | undefined][]} */
3567 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
3568 buttons.forEach(([button, type, color]) => {
3569 if (color) {
3570 button.style.setProperty(`--swal2-${type}-button-background-color`, color);
3571 }
3572 applyOutlineColor(button);
3573 });
3574 }
3575
3576 /**
3577 * @param {HTMLElement} button
3578 */
3579 function applyOutlineColor(button) {
3580 const buttonStyle = window.getComputedStyle(button);
3581 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3582 // If the button already has a custom outline color, no need to change it
3583 return;
3584 }
3585 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3586 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3587 }
3588
3589 /**
3590 * @param {HTMLElement} button
3591 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3592 * @param {SweetAlertOptions} params
3593 */
3594 function renderButton(button, buttonType, params) {
3595 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3596 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3597 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3598 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3599
3600 // Add buttons custom classes
3601 button.className = swalClasses[buttonType];
3602 applyCustomClass(button, params, `${buttonType}Button`);
3603 }
3604
3605 /**
3606 * @param {SweetAlert} instance
3607 * @param {SweetAlertOptions} params
3608 */
3609 const renderCloseButton = (instance, params) => {
3610 const closeButton = getCloseButton();
3611 if (!closeButton) {
3612 return;
3613 }
3614 setInnerHtml(closeButton, params.closeButtonHtml || '');
3615
3616 // Custom class
3617 applyCustomClass(closeButton, params, 'closeButton');
3618 toggle(closeButton, params.showCloseButton);
3619 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3620 };
3621
3622 /**
3623 * @param {SweetAlert} instance
3624 * @param {SweetAlertOptions} params
3625 */
3626 const renderContainer = (instance, params) => {
3627 const container = getContainer();
3628 if (!container) {
3629 return;
3630 }
3631 handleBackdropParam(container, params.backdrop);
3632 handlePositionParam(container, params.position);
3633 handleGrowParam(container, params.grow);
3634
3635 // Custom class
3636 applyCustomClass(container, params, 'container');
3637 };
3638
3639 /**
3640 * @param {HTMLElement} container
3641 * @param {SweetAlertOptions['backdrop']} backdrop
3642 */
3643 function handleBackdropParam(container, backdrop) {
3644 if (typeof backdrop === 'string') {
3645 container.style.background = backdrop;
3646 } else if (!backdrop) {
3647 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3648 }
3649 }
3650
3651 /**
3652 * @param {HTMLElement} container
3653 * @param {SweetAlertOptions['position']} position
3654 */
3655 function handlePositionParam(container, position) {
3656 if (!position) {
3657 return;
3658 }
3659 if (position in swalClasses) {
3660 addClass(container, swalClasses[position]);
3661 } else {
3662 warn('The "position" parameter is not valid, defaulting to "center"');
3663 addClass(container, swalClasses.center);
3664 }
3665 }
3666
3667 /**
3668 * @param {HTMLElement} container
3669 * @param {SweetAlertOptions['grow']} grow
3670 */
3671 function handleGrowParam(container, grow) {
3672 if (!grow) {
3673 return;
3674 }
3675 addClass(container, swalClasses[`grow-${grow}`]);
3676 }
3677
3678 /**
3679 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3680 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3681 * This is the approach that Babel will probably take to implement private methods/fields
3682 * https://github.com/tc39/proposal-private-methods
3683 * https://github.com/babel/babel/pull/7555
3684 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3685 * then we can use that language feature.
3686 */
3687
3688 var privateProps = {
3689 innerParams: new WeakMap(),
3690 domCache: new WeakMap(),
3691 focusedElement: new WeakMap()
3692 };
3693
3694 /// <reference path="../../../../sweetalert2.d.ts"/>
3695
3696
3697 /** @type {InputClass[]} */
3698 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3699
3700 /**
3701 * @param {SweetAlert} instance
3702 * @param {SweetAlertOptions} params
3703 */
3704 const renderInput = (instance, params) => {
3705 const popup = getPopup();
3706 if (!popup) {
3707 return;
3708 }
3709 const innerParams = privateProps.innerParams.get(instance);
3710 const rerender = !innerParams || params.input !== innerParams.input;
3711 inputClasses.forEach(inputClass => {
3712 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3713 if (!inputContainer) {
3714 return;
3715 }
3716
3717 // set attributes
3718 setAttributes(inputClass, params.inputAttributes);
3719
3720 // set class
3721 inputContainer.className = swalClasses[inputClass];
3722 if (rerender) {
3723 hide(inputContainer);
3724 }
3725 });
3726 if (params.input) {
3727 if (rerender) {
3728 showInput(params);
3729 }
3730 // set custom class
3731 setCustomClass(params);
3732 }
3733 };
3734
3735 /**
3736 * @param {SweetAlertOptions} params
3737 */
3738 const showInput = params => {
3739 if (!params.input) {
3740 return;
3741 }
3742 if (!renderInputType[params.input]) {
3743 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3744 return;
3745 }
3746 const inputContainer = getInputContainer(params.input);
3747 if (!inputContainer) {
3748 return;
3749 }
3750 const input = renderInputType[params.input](inputContainer, params);
3751 show(inputContainer);
3752
3753 // input autofocus
3754 if (params.inputAutoFocus) {
3755 setTimeout(() => {
3756 focusInput(input);
3757 });
3758 }
3759 };
3760
3761 /**
3762 * @param {HTMLInputElement} input
3763 */
3764 const removeAttributes = input => {
3765 for (const {
3766 name
3767 } of Array.from(input.attributes)) {
3768 if (!['id', 'type', 'value', 'style'].includes(name)) {
3769 input.removeAttribute(name);
3770 }
3771 }
3772 };
3773
3774 /**
3775 * @param {InputClass} inputClass
3776 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3777 */
3778 const setAttributes = (inputClass, inputAttributes) => {
3779 const popup = getPopup();
3780 if (!popup) {
3781 return;
3782 }
3783 const input = getInput$1(popup, inputClass);
3784 if (!input) {
3785 return;
3786 }
3787 removeAttributes(input);
3788 for (const attr in inputAttributes) {
3789 input.setAttribute(attr, inputAttributes[attr]);
3790 }
3791 };
3792
3793 /**
3794 * @param {SweetAlertOptions} params
3795 */
3796 const setCustomClass = params => {
3797 if (!params.input) {
3798 return;
3799 }
3800 const inputContainer = getInputContainer(params.input);
3801 if (inputContainer) {
3802 applyCustomClass(inputContainer, params, 'input');
3803 }
3804 };
3805
3806 /**
3807 * @param {HTMLInputElement | HTMLTextAreaElement} input
3808 * @param {SweetAlertOptions} params
3809 */
3810 const setInputPlaceholder = (input, params) => {
3811 if (!input.placeholder && params.inputPlaceholder) {
3812 input.placeholder = params.inputPlaceholder;
3813 }
3814 };
3815
3816 /**
3817 * @param {Input} input
3818 * @param {Input} prependTo
3819 * @param {SweetAlertOptions} params
3820 */
3821 const setInputLabel = (input, prependTo, params) => {
3822 if (params.inputLabel) {
3823 const label = document.createElement('label');
3824 const labelClass = swalClasses['input-label'];
3825 label.setAttribute('for', input.id);
3826 label.className = labelClass;
3827 if (typeof params.customClass === 'object') {
3828 addClass(label, params.customClass.inputLabel);
3829 }
3830 label.innerText = params.inputLabel;
3831 prependTo.insertAdjacentElement('beforebegin', label);
3832 }
3833 };
3834
3835 /**
3836 * @param {SweetAlertInput} inputType
3837 * @returns {HTMLElement | undefined}
3838 */
3839 const getInputContainer = inputType => {
3840 const popup = getPopup();
3841 if (!popup) {
3842 return;
3843 }
3844 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3845 };
3846
3847 /**
3848 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3849 * @param {SweetAlertOptions['inputValue']} inputValue
3850 */
3851 const checkAndSetInputValue = (input, inputValue) => {
3852 if (['string', 'number'].includes(typeof inputValue)) {
3853 input.value = `${inputValue}`;
3854 } else if (!isPromise(inputValue)) {
3855 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3856 }
3857 };
3858
3859 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3860 const renderInputType = {};
3861
3862 /**
3863 * @param {Input | HTMLElement} input
3864 * @param {SweetAlertOptions} params
3865 * @returns {Input}
3866 */
3867 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} */
3868 (input, params) => {
3869 // oxfmt-ignore
3870 const inputElement = /** @type {HTMLInputElement} */input;
3871 checkAndSetInputValue(inputElement, params.inputValue);
3872 setInputLabel(inputElement, inputElement, params);
3873 setInputPlaceholder(inputElement, params);
3874 // oxfmt-ignore
3875 inputElement.type = /** @type {string} */params.input;
3876 return inputElement;
3877 };
3878
3879 /**
3880 * @param {Input | HTMLElement} input
3881 * @param {SweetAlertOptions} params
3882 * @returns {Input}
3883 */
3884 renderInputType.file = (input, params) => {
3885 const inputElement = /** @type {HTMLInputElement} */input;
3886 setInputLabel(inputElement, inputElement, params);
3887 setInputPlaceholder(inputElement, params);
3888 return inputElement;
3889 };
3890
3891 /**
3892 * @param {Input | HTMLElement} range
3893 * @param {SweetAlertOptions} params
3894 * @returns {Input}
3895 */
3896 renderInputType.range = (range, params) => {
3897 const rangeContainer = /** @type {HTMLElement} */range;
3898 const rangeInput = rangeContainer.querySelector('input');
3899 const rangeOutput = rangeContainer.querySelector('output');
3900 if (rangeInput) {
3901 checkAndSetInputValue(rangeInput, params.inputValue);
3902 rangeInput.type = /** @type {string} */params.input;
3903 setInputLabel(rangeInput, /** @type {Input} */range, params);
3904 }
3905 if (rangeOutput) {
3906 checkAndSetInputValue(rangeOutput, params.inputValue);
3907 }
3908 return /** @type {Input} */range;
3909 };
3910
3911 /**
3912 * @param {Input | HTMLElement} select
3913 * @param {SweetAlertOptions} params
3914 * @returns {Input}
3915 */
3916 renderInputType.select = (select, params) => {
3917 const selectElement = /** @type {HTMLSelectElement} */select;
3918 selectElement.textContent = '';
3919 if (params.inputPlaceholder) {
3920 const placeholder = document.createElement('option');
3921 setInnerHtml(placeholder, params.inputPlaceholder);
3922 placeholder.value = '';
3923 placeholder.disabled = true;
3924 placeholder.selected = true;
3925 selectElement.appendChild(placeholder);
3926 }
3927 setInputLabel(selectElement, selectElement, params);
3928 return selectElement;
3929 };
3930
3931 /**
3932 * @param {Input | HTMLElement} radio
3933 * @returns {Input}
3934 */
3935 renderInputType.radio = radio => {
3936 const radioElement = /** @type {HTMLElement} */radio;
3937 radioElement.textContent = '';
3938 return /** @type {Input} */radio;
3939 };
3940
3941 /**
3942 * @param {Input | HTMLElement} checkboxContainer
3943 * @param {SweetAlertOptions} params
3944 * @returns {Input}
3945 */
3946 renderInputType.checkbox = (checkboxContainer, params) => {
3947 const popup = getPopup();
3948 if (!popup) {
3949 throw new Error('Popup not found');
3950 }
3951 const checkbox = getInput$1(popup, 'checkbox');
3952 if (!checkbox) {
3953 throw new Error('Checkbox input not found');
3954 }
3955 checkbox.value = '1';
3956 checkbox.checked = Boolean(params.inputValue);
3957 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3958 const label = containerElement.querySelector('span');
3959 if (label) {
3960 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3961 if (placeholderOrLabel) {
3962 setInnerHtml(label, placeholderOrLabel);
3963 }
3964 }
3965 return checkbox;
3966 };
3967
3968 /**
3969 * @param {Input | HTMLElement} textarea
3970 * @param {SweetAlertOptions} params
3971 * @returns {Input}
3972 */
3973 renderInputType.textarea = (textarea, params) => {
3974 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3975 checkAndSetInputValue(textareaElement, params.inputValue);
3976 setInputPlaceholder(textareaElement, params);
3977 setInputLabel(textareaElement, textareaElement, params);
3978
3979 /**
3980 * @param {HTMLElement} el
3981 * @returns {number}
3982 */
3983 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3984
3985 // https://github.com/sweetalert2/sweetalert2/issues/2291
3986 setTimeout(() => {
3987 // https://github.com/sweetalert2/sweetalert2/issues/1699
3988 if ('MutationObserver' in window) {
3989 const popup = getPopup();
3990 if (!popup) {
3991 return;
3992 }
3993 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3994 const textareaResizeHandler = () => {
3995 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3996 if (!document.body.contains(textareaElement)) {
3997 return;
3998 }
3999 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
4000 const popupElement = getPopup();
4001 if (popupElement) {
4002 if (textareaWidth > initialPopupWidth) {
4003 popupElement.style.width = `${textareaWidth}px`;
4004 } else {
4005 applyNumericalStyle(popupElement, 'width', params.width);
4006 }
4007 }
4008 };
4009 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
4010 attributes: true,
4011 attributeFilter: ['style']
4012 });
4013 }
4014 });
4015 return textareaElement;
4016 };
4017
4018 /**
4019 * @param {SweetAlert} instance
4020 * @param {SweetAlertOptions} params
4021 */
4022 const renderContent = (instance, params) => {
4023 const htmlContainer = getHtmlContainer();
4024 if (!htmlContainer) {
4025 return;
4026 }
4027 showWhenInnerHtmlPresent(htmlContainer);
4028 applyCustomClass(htmlContainer, params, 'htmlContainer');
4029
4030 // Content as HTML
4031 if (params.html) {
4032 parseHtmlToContainer(params.html, htmlContainer);
4033 show(htmlContainer, 'block');
4034 }
4035
4036 // Content as plain text
4037 else if (params.text) {
4038 htmlContainer.textContent = params.text;
4039 show(htmlContainer, 'block');
4040 }
4041
4042 // No content
4043 else {
4044 hide(htmlContainer);
4045 }
4046 renderInput(instance, params);
4047 };
4048
4049 /**
4050 * @param {SweetAlert} instance
4051 * @param {SweetAlertOptions} params
4052 */
4053 const renderFooter = (instance, params) => {
4054 const footer = getFooter();
4055 if (!footer) {
4056 return;
4057 }
4058 showWhenInnerHtmlPresent(footer);
4059 toggle(footer, Boolean(params.footer), 'block');
4060 if (params.footer) {
4061 parseHtmlToContainer(params.footer, footer);
4062 }
4063
4064 // Custom class
4065 applyCustomClass(footer, params, 'footer');
4066 };
4067
4068 /**
4069 * @param {SweetAlert} instance
4070 * @param {SweetAlertOptions} params
4071 */
4072 const renderIcon = (instance, params) => {
4073 const innerParams = privateProps.innerParams.get(instance);
4074 const icon = getIcon();
4075 if (!icon) {
4076 return;
4077 }
4078
4079 // if the given icon already rendered, apply the styling without re-rendering the icon
4080 if (innerParams && params.icon === innerParams.icon) {
4081 // Custom or default content
4082 setContent(icon, params);
4083 applyStyles(icon, params);
4084 return;
4085 }
4086 if (!params.icon && !params.iconHtml) {
4087 hide(icon);
4088 return;
4089 }
4090 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
4091 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
4092 hide(icon);
4093 return;
4094 }
4095 show(icon);
4096
4097 // Custom or default content
4098 setContent(icon, params);
4099 applyStyles(icon, params);
4100
4101 // Animate icon
4102 addClass(icon, params.showClass && params.showClass.icon);
4103
4104 // Re-adjust the success icon on system theme change
4105 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
4106 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
4107 };
4108
4109 /**
4110 * @param {HTMLElement} icon
4111 * @param {SweetAlertOptions} params
4112 */
4113 const applyStyles = (icon, params) => {
4114 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
4115 if (params.icon !== iconType) {
4116 removeClass(icon, iconClassName);
4117 }
4118 }
4119 addClass(icon, params.icon && iconTypes[params.icon]);
4120
4121 // Icon color
4122 setColor(icon, params);
4123
4124 // Success icon background color
4125 adjustSuccessIconBackgroundColor();
4126
4127 // Custom class
4128 applyCustomClass(icon, params, 'icon');
4129 };
4130
4131 // Adjust success icon background color to match the popup background color
4132 const adjustSuccessIconBackgroundColor = () => {
4133 const popup = getPopup();
4134 if (!popup) {
4135 return;
4136 }
4137 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
4138 /** @type {NodeListOf<HTMLElement>} */
4139 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
4140 successIconParts.forEach(part => {
4141 part.style.backgroundColor = popupBackgroundColor;
4142 });
4143 };
4144
4145 /**
4146 *
4147 * @param {SweetAlertOptions} params
4148 * @returns {string}
4149 */
4150 const successIconHtml = params => `
4151 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
4152 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
4153 <div class="swal2-success-ring"></div>
4154 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
4155 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
4156 `;
4157 const errorIconHtml = `
4158 <span class="swal2-x-mark">
4159 <span class="swal2-x-mark-line-left"></span>
4160 <span class="swal2-x-mark-line-right"></span>
4161 </span>
4162 `;
4163
4164 /**
4165 * @param {HTMLElement} icon
4166 * @param {SweetAlertOptions} params
4167 */
4168 const setContent = (icon, params) => {
4169 if (!params.icon && !params.iconHtml) {
4170 return;
4171 }
4172 let oldContent = icon.innerHTML;
4173 let newContent = '';
4174 if (params.iconHtml) {
4175 newContent = iconContent(params.iconHtml);
4176 } else if (params.icon === 'success') {
4177 newContent = successIconHtml(params);
4178 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
4179 } else if (params.icon === 'error') {
4180 newContent = errorIconHtml;
4181 } else if (params.icon) {
4182 const defaultIconHtml = {
4183 question: '?',
4184 warning: '!',
4185 info: 'i'
4186 };
4187 newContent = iconContent(defaultIconHtml[params.icon]);
4188 }
4189 if (oldContent.trim() !== newContent.trim()) {
4190 setInnerHtml(icon, newContent);
4191 }
4192 };
4193
4194 /**
4195 * @param {HTMLElement} icon
4196 * @param {SweetAlertOptions} params
4197 */
4198 const setColor = (icon, params) => {
4199 if (!params.iconColor) {
4200 return;
4201 }
4202 icon.style.color = params.iconColor;
4203 icon.style.borderColor = params.iconColor;
4204 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
4205 setStyle(icon, sel, 'background-color', params.iconColor);
4206 }
4207 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
4208 };
4209
4210 /**
4211 * @param {string} content
4212 * @returns {string}
4213 */
4214 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
4215
4216 /**
4217 * @param {SweetAlert} instance
4218 * @param {SweetAlertOptions} params
4219 */
4220 const renderImage = (instance, params) => {
4221 const image = getImage();
4222 if (!image) {
4223 return;
4224 }
4225 if (!params.imageUrl) {
4226 hide(image);
4227 return;
4228 }
4229 show(image, '');
4230
4231 // Src, alt
4232 image.setAttribute('src', params.imageUrl);
4233 image.setAttribute('alt', params.imageAlt || '');
4234
4235 // Width, height
4236 applyNumericalStyle(image, 'width', params.imageWidth);
4237 applyNumericalStyle(image, 'height', params.imageHeight);
4238
4239 // Class
4240 image.className = swalClasses.image;
4241 applyCustomClass(image, params, 'image');
4242 };
4243
4244 let dragging = false;
4245 let mousedownX = 0;
4246 let mousedownY = 0;
4247 let initialX = 0;
4248 let initialY = 0;
4249
4250 /**
4251 * @param {HTMLElement} popup
4252 */
4253 const addDraggableListeners = popup => {
4254 popup.addEventListener('mousedown', down);
4255 document.body.addEventListener('mousemove', move);
4256 popup.addEventListener('mouseup', up);
4257 popup.addEventListener('touchstart', down);
4258 document.body.addEventListener('touchmove', move);
4259 popup.addEventListener('touchend', up);
4260 };
4261
4262 /**
4263 * @param {HTMLElement} popup
4264 */
4265 const removeDraggableListeners = popup => {
4266 popup.removeEventListener('mousedown', down);
4267 document.body.removeEventListener('mousemove', move);
4268 popup.removeEventListener('mouseup', up);
4269 popup.removeEventListener('touchstart', down);
4270 document.body.removeEventListener('touchmove', move);
4271 popup.removeEventListener('touchend', up);
4272 };
4273
4274 /**
4275 * @param {MouseEvent | TouchEvent} event
4276 */
4277 const down = event => {
4278 const popup = getPopup();
4279 if (!popup) {
4280 return;
4281 }
4282 const icon = getIcon();
4283 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
4284 dragging = true;
4285 const clientXY = getClientXY(event);
4286 mousedownX = clientXY.clientX;
4287 mousedownY = clientXY.clientY;
4288 initialX = parseInt(popup.style.insetInlineStart) || 0;
4289 initialY = parseInt(popup.style.insetBlockStart) || 0;
4290 addClass(popup, 'swal2-dragging');
4291 }
4292 };
4293
4294 /**
4295 * @param {MouseEvent | TouchEvent} event
4296 */
4297 const move = event => {
4298 const popup = getPopup();
4299 if (!popup) {
4300 return;
4301 }
4302 if (dragging) {
4303 let {
4304 clientX,
4305 clientY
4306 } = getClientXY(event);
4307 const deltaX = clientX - mousedownX;
4308 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
4309 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
4310 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
4311 }
4312 };
4313 const up = () => {
4314 const popup = getPopup();
4315 dragging = false;
4316 removeClass(popup, 'swal2-dragging');
4317 };
4318
4319 /**
4320 * @param {MouseEvent | TouchEvent} event
4321 * @returns {{ clientX: number, clientY: number }}
4322 */
4323 const getClientXY = event => {
4324 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
4325 return {
4326 clientX: source.clientX,
4327 clientY: source.clientY
4328 };
4329 };
4330
4331 /**
4332 * @param {SweetAlert} instance
4333 * @param {SweetAlertOptions} params
4334 */
4335 const renderPopup = (instance, params) => {
4336 const container = getContainer();
4337 const popup = getPopup();
4338 if (!container || !popup) {
4339 return;
4340 }
4341
4342 // Width
4343 // https://github.com/sweetalert2/sweetalert2/issues/2170
4344 if (params.toast) {
4345 applyNumericalStyle(container, 'width', params.width);
4346 popup.style.width = '100%';
4347 const loader = getLoader();
4348 if (loader) {
4349 popup.insertBefore(loader, getIcon());
4350 }
4351 } else {
4352 applyNumericalStyle(popup, 'width', params.width);
4353 }
4354
4355 // Padding
4356 applyNumericalStyle(popup, 'padding', params.padding);
4357
4358 // Color
4359 if (params.color) {
4360 popup.style.color = params.color;
4361 }
4362
4363 // Background
4364 if (params.background) {
4365 popup.style.background = params.background;
4366 }
4367 hide(getValidationMessage());
4368
4369 // Classes
4370 addClasses$1(popup, params);
4371 if (params.draggable && !params.toast) {
4372 addClass(popup, swalClasses.draggable);
4373 addDraggableListeners(popup);
4374 } else {
4375 removeClass(popup, swalClasses.draggable);
4376 removeDraggableListeners(popup);
4377 }
4378 };
4379
4380 /**
4381 * @param {HTMLElement} popup
4382 * @param {SweetAlertOptions} params
4383 */
4384 const addClasses$1 = (popup, params) => {
4385 const showClass = params.showClass || {};
4386 // Default Class + showClass when updating Swal.update({})
4387 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
4388 if (params.toast) {
4389 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
4390 addClass(popup, swalClasses.toast);
4391 } else {
4392 addClass(popup, swalClasses.modal);
4393 }
4394
4395 // Custom class
4396 applyCustomClass(popup, params, 'popup');
4397 // TODO: remove in the next major
4398 if (typeof params.customClass === 'string') {
4399 addClass(popup, params.customClass);
4400 }
4401
4402 // Icon class (#1842)
4403 if (params.icon) {
4404 addClass(popup, swalClasses[`icon-${params.icon}`]);
4405 }
4406 };
4407
4408 /**
4409 * @param {SweetAlert} instance
4410 * @param {SweetAlertOptions} params
4411 */
4412 const renderProgressSteps = (instance, params) => {
4413 const progressStepsContainer = getProgressSteps();
4414 if (!progressStepsContainer) {
4415 return;
4416 }
4417 const {
4418 progressSteps,
4419 currentProgressStep
4420 } = params;
4421 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
4422 hide(progressStepsContainer);
4423 return;
4424 }
4425 show(progressStepsContainer);
4426 progressStepsContainer.textContent = '';
4427 if (currentProgressStep >= progressSteps.length) {
4428 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
4429 }
4430 progressSteps.forEach((step, index) => {
4431 const stepEl = createStepElement(step);
4432 progressStepsContainer.appendChild(stepEl);
4433 if (index === currentProgressStep) {
4434 addClass(stepEl, swalClasses['active-progress-step']);
4435 }
4436 if (index !== progressSteps.length - 1) {
4437 const lineEl = createLineElement(params);
4438 progressStepsContainer.appendChild(lineEl);
4439 }
4440 });
4441 };
4442
4443 /**
4444 * @param {string} step
4445 * @returns {HTMLLIElement}
4446 */
4447 const createStepElement = step => {
4448 const stepEl = document.createElement('li');
4449 addClass(stepEl, swalClasses['progress-step']);
4450 setInnerHtml(stepEl, step);
4451 return stepEl;
4452 };
4453
4454 /**
4455 * @param {SweetAlertOptions} params
4456 * @returns {HTMLLIElement}
4457 */
4458 const createLineElement = params => {
4459 const lineEl = document.createElement('li');
4460 addClass(lineEl, swalClasses['progress-step-line']);
4461 if (params.progressStepsDistance) {
4462 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
4463 }
4464 return lineEl;
4465 };
4466
4467 /**
4468 * @param {SweetAlert} instance
4469 * @param {SweetAlertOptions} params
4470 */
4471 const renderTitle = (instance, params) => {
4472 const title = getTitle();
4473 if (!title) {
4474 return;
4475 }
4476 showWhenInnerHtmlPresent(title);
4477 toggle(title, Boolean(params.title || params.titleText), 'block');
4478 if (params.title) {
4479 parseHtmlToContainer(params.title, title);
4480 }
4481 if (params.titleText) {
4482 title.innerText = params.titleText;
4483 }
4484
4485 // Custom class
4486 applyCustomClass(title, params, 'title');
4487 };
4488
4489 /**
4490 * @param {SweetAlert} instance
4491 * @param {SweetAlertOptions} params
4492 */
4493 const render = (instance, params) => {
4494 var _globalState$eventEmi;
4495 renderPopup(instance, params);
4496 renderContainer(instance, params);
4497 renderProgressSteps(instance, params);
4498 renderIcon(instance, params);
4499 renderImage(instance, params);
4500 renderTitle(instance, params);
4501 renderCloseButton(instance, params);
4502 renderContent(instance, params);
4503 renderActions(instance, params);
4504 renderFooter(instance, params);
4505 const popup = getPopup();
4506 if (typeof params.didRender === 'function' && popup) {
4507 params.didRender(popup);
4508 }
4509 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
4510 };
4511
4512 /*
4513 * Global function to determine if SweetAlert2 popup is shown
4514 */
4515 const isVisible = () => {
4516 return isVisible$1(getPopup());
4517 };
4518
4519 /*
4520 * Global function to click 'Confirm' button
4521 */
4522 const clickConfirm = () => {
4523 var _dom$getConfirmButton;
4524 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
4525 };
4526
4527 /*
4528 * Global function to click 'Deny' button
4529 */
4530 const clickDeny = () => {
4531 var _dom$getDenyButton;
4532 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
4533 };
4534
4535 /*
4536 * Global function to click 'Cancel' button
4537 */
4538 const clickCancel = () => {
4539 var _dom$getCancelButton;
4540 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4541 };
4542
4543 /** @type {Record<DismissReason, DismissReason>} */
4544 const DismissReason = Object.freeze({
4545 cancel: 'cancel',
4546 backdrop: 'backdrop',
4547 close: 'close',
4548 esc: 'esc',
4549 timer: 'timer'
4550 });
4551
4552 /**
4553 * @param {GlobalState} globalState
4554 */
4555 const removeKeydownHandler = globalState => {
4556 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4557 const handler = /** @type {EventListenerOrEventListenerObject} */
4558 /** @type {unknown} */globalState.keydownHandler;
4559 globalState.keydownTarget.removeEventListener('keydown', handler, {
4560 capture: globalState.keydownListenerCapture
4561 });
4562 globalState.keydownHandlerAdded = false;
4563 }
4564 };
4565
4566 /**
4567 * @param {GlobalState} globalState
4568 * @param {SweetAlertOptions} innerParams
4569 * @param {(dismiss: DismissReason) => void} dismissWith
4570 */
4571 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4572 removeKeydownHandler(globalState);
4573 if (!innerParams.toast) {
4574 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4575 const handler = e => keydownHandler(innerParams, e, dismissWith);
4576 globalState.keydownHandler = handler;
4577 const target = innerParams.keydownListenerCapture ? window : getPopup();
4578 if (target) {
4579 globalState.keydownTarget = target;
4580 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4581 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4582 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4583 capture: globalState.keydownListenerCapture
4584 });
4585 globalState.keydownHandlerAdded = true;
4586 }
4587 }
4588 };
4589
4590 /**
4591 * @param {number} index
4592 * @param {number} increment
4593 * @returns {boolean} shouldPreventDefault
4594 */
4595 const setFocus = (index, increment) => {
4596 var _dom$getPopup;
4597 const focusableElements = getFocusableElements();
4598 // search for visible elements and select the next possible match
4599 if (focusableElements.length) {
4600 index = index + increment;
4601
4602 // shift + tab when .swal2-popup is focused
4603 if (index === -2) {
4604 index = focusableElements.length - 1;
4605 }
4606
4607 // rollover to first item
4608 if (index === focusableElements.length) {
4609 index = 0;
4610
4611 // go to last item
4612 } else if (index === -1) {
4613 index = focusableElements.length - 1;
4614 }
4615 focusableElements[index].focus();
4616
4617 // don't prevent default for iframes (Firefox fix)
4618 // https://github.com/sweetalert2/sweetalert2/issues/2931
4619 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
4620 return false;
4621 }
4622 return true;
4623 }
4624 // no visible focusable elements, focus the popup
4625 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4626 return true;
4627 };
4628 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4629 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4630
4631 /**
4632 * @param {SweetAlertOptions} innerParams
4633 * @param {KeyboardEvent} event
4634 * @param {(dismiss: DismissReason) => void} dismissWith
4635 */
4636 const keydownHandler = (innerParams, event, dismissWith) => {
4637 if (!innerParams) {
4638 return; // This instance has already been destroyed
4639 }
4640
4641 // Ignore keydown during IME composition
4642 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4643 // https://github.com/sweetalert2/sweetalert2/issues/720
4644 // https://github.com/sweetalert2/sweetalert2/issues/2406
4645 if (event.isComposing || event.keyCode === 229) {
4646 return;
4647 }
4648 if (innerParams.stopKeydownPropagation) {
4649 event.stopPropagation();
4650 }
4651
4652 // ENTER
4653 if (event.key === 'Enter') {
4654 handleEnter(event, innerParams);
4655 }
4656
4657 // TAB
4658 else if (event.key === 'Tab') {
4659 handleTab(event);
4660 }
4661
4662 // ARROWS - switch focus between buttons
4663 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4664 handleArrows(event.key);
4665 }
4666
4667 // ESC
4668 else if (event.key === 'Escape') {
4669 handleEsc(event, innerParams, dismissWith);
4670 }
4671 };
4672
4673 /**
4674 * @param {KeyboardEvent} event
4675 * @param {SweetAlertOptions} innerParams
4676 */
4677 const handleEnter = (event, innerParams) => {
4678 // https://github.com/sweetalert2/sweetalert2/issues/2386
4679 if (!callIfFunction(innerParams.allowEnterKey)) {
4680 return;
4681 }
4682 const popup = getPopup();
4683 if (!popup || !innerParams.input) {
4684 return;
4685 }
4686 const input = getInput$1(popup, innerParams.input);
4687 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4688 if (['textarea', 'file'].includes(innerParams.input)) {
4689 return; // do not submit
4690 }
4691 clickConfirm();
4692 event.preventDefault();
4693 }
4694 };
4695
4696 /**
4697 * @param {KeyboardEvent} event
4698 */
4699 const handleTab = event => {
4700 const targetElement = event.target;
4701 const focusableElements = getFocusableElements();
4702 const btnIndex = focusableElements.findIndex(el => el === targetElement);
4703
4704 // don't prevent default for iframes (Firefox fix)
4705 // https://github.com/sweetalert2/sweetalert2/issues/2931
4706 let shouldPreventDefault = true;
4707
4708 // Cycle to the next button
4709 if (!event.shiftKey) {
4710 shouldPreventDefault = setFocus(btnIndex, 1);
4711 }
4712
4713 // Cycle to the prev button
4714 else {
4715 shouldPreventDefault = setFocus(btnIndex, -1);
4716 }
4717 event.stopPropagation();
4718 if (shouldPreventDefault) {
4719 event.preventDefault();
4720 }
4721 };
4722
4723 /**
4724 * @param {string} key
4725 */
4726 const handleArrows = key => {
4727 const actions = getActions();
4728 const confirmButton = getConfirmButton();
4729 const denyButton = getDenyButton();
4730 const cancelButton = getCancelButton();
4731 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4732 return;
4733 }
4734 /** @type HTMLElement[] */
4735 const buttons = [confirmButton, denyButton, cancelButton];
4736 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4737 return;
4738 }
4739 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4740 let buttonToFocus = document.activeElement;
4741 if (!buttonToFocus) {
4742 return;
4743 }
4744 for (let i = 0; i < actions.children.length; i++) {
4745 buttonToFocus = buttonToFocus[sibling];
4746 if (!buttonToFocus) {
4747 return;
4748 }
4749 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4750 break;
4751 }
4752 }
4753 if (buttonToFocus instanceof HTMLButtonElement) {
4754 buttonToFocus.focus();
4755 }
4756 };
4757
4758 /**
4759 * @param {KeyboardEvent} event
4760 * @param {SweetAlertOptions} innerParams
4761 * @param {(dismiss: DismissReason) => void} dismissWith
4762 */
4763 const handleEsc = (event, innerParams, dismissWith) => {
4764 event.preventDefault();
4765 if (callIfFunction(innerParams.allowEscapeKey)) {
4766 dismissWith(DismissReason.esc);
4767 }
4768 };
4769
4770 /**
4771 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4772 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4773 * This is the approach that Babel will probably take to implement private methods/fields
4774 * https://github.com/tc39/proposal-private-methods
4775 * https://github.com/babel/babel/pull/7555
4776 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4777 * then we can use that language feature.
4778 */
4779
4780 var privateMethods = {
4781 swalPromiseResolve: new WeakMap(),
4782 swalPromiseReject: new WeakMap()
4783 };
4784
4785 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4786 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4787 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4788 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4789
4790 const setAriaHidden = () => {
4791 const container = getContainer();
4792 const bodyChildren = Array.from(document.body.children);
4793 bodyChildren.forEach(el => {
4794 if (el.contains(container)) {
4795 return;
4796 }
4797 if (el.hasAttribute('aria-hidden')) {
4798 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4799 }
4800 el.setAttribute('aria-hidden', 'true');
4801 });
4802 };
4803 const unsetAriaHidden = () => {
4804 const bodyChildren = Array.from(document.body.children);
4805 bodyChildren.forEach(el => {
4806 if (el.hasAttribute('data-previous-aria-hidden')) {
4807 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4808 el.removeAttribute('data-previous-aria-hidden');
4809 } else {
4810 el.removeAttribute('aria-hidden');
4811 }
4812 });
4813 };
4814
4815 // @ts-ignore
4816 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4817
4818 // @ts-ignore
4819 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
4820
4821 /**
4822 * Fix iOS scrolling
4823 * http://stackoverflow.com/q/39626302
4824 */
4825 const iOSfix = () => {
4826 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4827 const offset = document.body.scrollTop;
4828 document.body.style.top = `${offset * -1}px`;
4829 addClass(document.body, swalClasses.iosfix);
4830 lockBodyScroll();
4831 }
4832 };
4833
4834 /**
4835 * https://github.com/sweetalert2/sweetalert2/issues/1246
4836 */
4837 const lockBodyScroll = () => {
4838 const container = getContainer();
4839 if (!container) {
4840 return;
4841 }
4842 /** @type {boolean} */
4843 let preventTouchMove;
4844 /**
4845 * @param {TouchEvent} event
4846 */
4847 container.ontouchstart = event => {
4848 preventTouchMove = shouldPreventTouchMove(event);
4849 };
4850 /**
4851 * @param {TouchEvent} event
4852 */
4853 container.ontouchmove = event => {
4854 if (preventTouchMove) {
4855 event.preventDefault();
4856 event.stopPropagation();
4857 }
4858 };
4859 };
4860
4861 /**
4862 * @param {TouchEvent} event
4863 * @returns {boolean}
4864 */
4865 const shouldPreventTouchMove = event => {
4866 const target = event.target;
4867 const container = getContainer();
4868 const htmlContainer = getHtmlContainer();
4869 if (!container || !htmlContainer) {
4870 return false;
4871 }
4872 if (isStylus(event) || isZoom(event)) {
4873 return false;
4874 }
4875 if (target === container) {
4876 return true;
4877 }
4878 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4879 // #2823
4880 target.tagName !== 'INPUT' &&
4881 // #1603
4882 target.tagName !== 'TEXTAREA' &&
4883 // #2266
4884 !(isScrollable(htmlContainer) &&
4885 // #1944
4886 htmlContainer.contains(target))) {
4887 return true;
4888 }
4889 return false;
4890 };
4891
4892 /**
4893 * https://github.com/sweetalert2/sweetalert2/issues/1786
4894 *
4895 * @param {TouchEvent} event
4896 * @returns {boolean}
4897 */
4898 const isStylus = event => {
4899 return Boolean(event.touches && event.touches.length &&
4900 // @ts-ignore - touchType is not a standard property
4901 event.touches[0].touchType === 'stylus');
4902 };
4903
4904 /**
4905 * https://github.com/sweetalert2/sweetalert2/issues/1891
4906 *
4907 * @param {TouchEvent} event
4908 * @returns {boolean}
4909 */
4910 const isZoom = event => {
4911 return event.touches && event.touches.length > 1;
4912 };
4913 const undoIOSfix = () => {
4914 if (hasClass(document.body, swalClasses.iosfix)) {
4915 const offset = parseInt(document.body.style.top, 10);
4916 removeClass(document.body, swalClasses.iosfix);
4917 document.body.style.top = '';
4918 document.body.scrollTop = offset * -1;
4919 }
4920 };
4921
4922 /**
4923 * Measure scrollbar width for padding body during modal show/hide
4924 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4925 *
4926 * @returns {number}
4927 */
4928 const measureScrollbar = () => {
4929 const scrollDiv = document.createElement('div');
4930 scrollDiv.className = swalClasses['scrollbar-measure'];
4931 document.body.appendChild(scrollDiv);
4932 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4933 document.body.removeChild(scrollDiv);
4934 return scrollbarWidth;
4935 };
4936
4937 /**
4938 * Remember state in cases where opening and handling a modal will fiddle with it.
4939 * @type {number | null}
4940 */
4941 let previousBodyPadding = null;
4942
4943 /**
4944 * @param {string} initialBodyOverflow
4945 */
4946 const replaceScrollbarWithPadding = initialBodyOverflow => {
4947 // for queues, do not do this more than once
4948 if (previousBodyPadding !== null) {
4949 return;
4950 }
4951 // if the body has overflow
4952 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4953 ) {
4954 // add padding so the content doesn't shift after removal of scrollbar
4955 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4956 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4957 }
4958 };
4959 const undoReplaceScrollbarWithPadding = () => {
4960 if (previousBodyPadding !== null) {
4961 document.body.style.paddingRight = `${previousBodyPadding}px`;
4962 previousBodyPadding = null;
4963 }
4964 };
4965
4966 /**
4967 * @param {SweetAlert} instance
4968 * @param {HTMLElement} container
4969 * @param {boolean} returnFocus
4970 * @param {(() => void) | undefined} didClose
4971 */
4972 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4973 if (isToast()) {
4974 triggerDidCloseAndDispose(instance, didClose);
4975 } else {
4976 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4977 removeKeydownHandler(globalState);
4978 }
4979
4980 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4981 // for some reason removing the container in Safari will scroll the document to bottom
4982 if (isSafariOrIOS) {
4983 container.setAttribute('style', 'display:none !important');
4984 container.removeAttribute('class');
4985 container.innerHTML = '';
4986 } else {
4987 container.remove();
4988 }
4989 if (isModal()) {
4990 undoReplaceScrollbarWithPadding();
4991 undoIOSfix();
4992 unsetAriaHidden();
4993 }
4994 removeBodyClasses();
4995 }
4996
4997 /**
4998 * Remove SweetAlert2 classes from body
4999 */
5000 function removeBodyClasses() {
5001 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
5002 }
5003
5004 /**
5005 * Instance method to close sweetAlert
5006 *
5007 * @param {SweetAlertResult | undefined} resolveValue
5008 * @this {SweetAlert}
5009 */
5010 function close(resolveValue) {
5011 resolveValue = prepareResolveValue(resolveValue);
5012 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
5013 const didClose = triggerClosePopup(this);
5014 if (this.isAwaitingPromise) {
5015 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
5016 if (!resolveValue.isDismissed) {
5017 handleAwaitingPromise(this);
5018 swalPromiseResolve(resolveValue);
5019 }
5020 } else if (didClose) {
5021 // Resolve Swal promise
5022 swalPromiseResolve(resolveValue);
5023 }
5024 }
5025
5026 /**
5027 * @param {SweetAlert} instance
5028 * @returns {boolean}
5029 */
5030 const triggerClosePopup = instance => {
5031 const popup = getPopup();
5032 if (!popup) {
5033 return false;
5034 }
5035 const innerParams = privateProps.innerParams.get(instance);
5036 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
5037 return false;
5038 }
5039 removeClass(popup, innerParams.showClass.popup);
5040 addClass(popup, innerParams.hideClass.popup);
5041 const backdrop = getContainer();
5042 removeClass(backdrop, innerParams.showClass.backdrop);
5043 addClass(backdrop, innerParams.hideClass.backdrop);
5044 handlePopupAnimation(instance, popup, innerParams);
5045 return true;
5046 };
5047
5048 /**
5049 * @param {Error | string} error
5050 * @this {SweetAlert}
5051 */
5052 function rejectPromise(error) {
5053 const rejectPromise = privateMethods.swalPromiseReject.get(this);
5054 handleAwaitingPromise(this);
5055 if (rejectPromise) {
5056 // Reject Swal promise
5057 rejectPromise(error);
5058 }
5059 }
5060
5061 /**
5062 * @param {SweetAlert} instance
5063 */
5064 const handleAwaitingPromise = instance => {
5065 if (instance.isAwaitingPromise) {
5066 // @ts-ignore
5067 delete instance.isAwaitingPromise;
5068 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
5069 if (!privateProps.innerParams.get(instance)) {
5070 instance._destroy();
5071 }
5072 }
5073 };
5074
5075 /**
5076 * @param {SweetAlertResult | undefined} resolveValue
5077 * @returns {SweetAlertResult}
5078 */
5079 const prepareResolveValue = resolveValue => {
5080 // When user calls Swal.close()
5081 if (typeof resolveValue === 'undefined') {
5082 return {
5083 isConfirmed: false,
5084 isDenied: false,
5085 isDismissed: true
5086 };
5087 }
5088 return Object.assign({
5089 isConfirmed: false,
5090 isDenied: false,
5091 isDismissed: false
5092 }, resolveValue);
5093 };
5094
5095 /**
5096 * @param {SweetAlert} instance
5097 * @param {HTMLElement} popup
5098 * @param {SweetAlertOptions} innerParams
5099 */
5100 const handlePopupAnimation = (instance, popup, innerParams) => {
5101 var _globalState$eventEmi;
5102 const container = getContainer();
5103 // If animation is supported, animate
5104 const animationIsSupported = hasCssAnimation(popup);
5105 if (typeof innerParams.willClose === 'function') {
5106 innerParams.willClose(popup);
5107 }
5108 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
5109 if (animationIsSupported && container) {
5110 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
5111 } else if (container) {
5112 // Otherwise, remove immediately
5113 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
5114 }
5115 };
5116
5117 /**
5118 * @param {SweetAlert} instance
5119 * @param {HTMLElement} popup
5120 * @param {HTMLElement} container
5121 * @param {boolean} returnFocus
5122 * @param {(() => void) | undefined} didClose
5123 */
5124 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
5125 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
5126 /**
5127 * @param {AnimationEvent | TransitionEvent} e
5128 */
5129 const swalCloseAnimationFinished = function (e) {
5130 if (e.target === popup) {
5131 var _globalState$swalClos;
5132 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
5133 delete globalState.swalCloseEventFinishedCallback;
5134 popup.removeEventListener('animationend', swalCloseAnimationFinished);
5135 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
5136 }
5137 };
5138 popup.addEventListener('animationend', swalCloseAnimationFinished);
5139 popup.addEventListener('transitionend', swalCloseAnimationFinished);
5140 };
5141
5142 /**
5143 * @param {SweetAlert} instance
5144 * @param {(() => void) | undefined} didClose
5145 */
5146 const triggerDidCloseAndDispose = (instance, didClose) => {
5147 setTimeout(() => {
5148 var _globalState$eventEmi2;
5149 if (typeof didClose === 'function') {
5150 didClose.bind(instance.params)();
5151 }
5152 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
5153 // instance might have been destroyed already
5154 if (instance._destroy) {
5155 instance._destroy();
5156 }
5157 });
5158 };
5159
5160 /**
5161 * Shows loader (spinner), this is useful with AJAX requests.
5162 * By default the loader be shown instead of the "Confirm" button.
5163 *
5164 * @param {HTMLButtonElement | null} [buttonToReplace]
5165 */
5166 const showLoading = buttonToReplace => {
5167 let popup = getPopup();
5168 if (!popup) {
5169 new Swal();
5170 }
5171 popup = getPopup();
5172 if (!popup) {
5173 return;
5174 }
5175 const loader = getLoader();
5176 if (isToast()) {
5177 hide(getIcon());
5178 } else {
5179 replaceButton(popup, buttonToReplace);
5180 }
5181 show(loader);
5182 popup.setAttribute('data-loading', 'true');
5183 popup.setAttribute('aria-busy', 'true');
5184 popup.focus();
5185 };
5186
5187 /**
5188 * @param {HTMLElement} popup
5189 * @param {HTMLButtonElement | null} [buttonToReplace]
5190 */
5191 const replaceButton = (popup, buttonToReplace) => {
5192 const actions = getActions();
5193 const loader = getLoader();
5194 if (!actions || !loader) {
5195 return;
5196 }
5197 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
5198 buttonToReplace = getConfirmButton();
5199 }
5200 show(actions);
5201 if (buttonToReplace) {
5202 hide(buttonToReplace);
5203 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
5204 actions.insertBefore(loader, buttonToReplace);
5205 }
5206 addClass([popup, actions], swalClasses.loading);
5207 };
5208
5209 /**
5210 * @param {SweetAlert} instance
5211 * @param {SweetAlertOptions} params
5212 */
5213 const handleInputOptionsAndValue = (instance, params) => {
5214 if (params.input === 'select' || params.input === 'radio') {
5215 handleInputOptions(instance, params);
5216 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
5217 showLoading(getConfirmButton());
5218 handleInputValue(instance, params);
5219 }
5220 };
5221
5222 /**
5223 * @param {SweetAlert} instance
5224 * @param {SweetAlertOptions} innerParams
5225 * @returns {SweetAlertInputValue}
5226 */
5227 const getInputValue = (instance, innerParams) => {
5228 const input = instance.getInput();
5229 if (!input) {
5230 return null;
5231 }
5232 switch (innerParams.input) {
5233 case 'checkbox':
5234 return getCheckboxValue(input);
5235 case 'radio':
5236 return getRadioValue(input);
5237 case 'file':
5238 return getFileValue(input);
5239 default:
5240 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
5241 }
5242 };
5243
5244 /**
5245 * @param {HTMLInputElement} input
5246 * @returns {number}
5247 */
5248 const getCheckboxValue = input => input.checked ? 1 : 0;
5249
5250 /**
5251 * @param {HTMLInputElement} input
5252 * @returns {string | null}
5253 */
5254 const getRadioValue = input => input.checked ? input.value : null;
5255
5256 /**
5257 * @param {HTMLInputElement} input
5258 * @returns {FileList | File | null}
5259 */
5260 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
5261
5262 /**
5263 * @param {SweetAlert} instance
5264 * @param {SweetAlertOptions} params
5265 */
5266 const handleInputOptions = (instance, params) => {
5267 const popup = getPopup();
5268 if (!popup) {
5269 return;
5270 }
5271 /**
5272 * @param {*} inputOptions
5273 */
5274 const processInputOptions = inputOptions => {
5275 if (params.input === 'select') {
5276 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
5277 } else if (params.input === 'radio') {
5278 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
5279 }
5280 };
5281 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
5282 showLoading(getConfirmButton());
5283 asPromise(params.inputOptions).then(inputOptions => {
5284 instance.hideLoading();
5285 processInputOptions(inputOptions);
5286 });
5287 } else if (typeof params.inputOptions === 'object') {
5288 processInputOptions(params.inputOptions);
5289 } else {
5290 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
5291 }
5292 };
5293
5294 /**
5295 * @param {SweetAlert} instance
5296 * @param {SweetAlertOptions} params
5297 */
5298 const handleInputValue = (instance, params) => {
5299 const input = instance.getInput();
5300 if (!input) {
5301 return;
5302 }
5303 hide(input);
5304 asPromise(params.inputValue).then(inputValue => {
5305 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
5306 show(input);
5307 input.focus();
5308 instance.hideLoading();
5309 }).catch(err => {
5310 error(`Error in inputValue promise: ${err}`);
5311 input.value = '';
5312 show(input);
5313 input.focus();
5314 instance.hideLoading();
5315 });
5316 };
5317
5318 /**
5319 * @param {HTMLElement} popup
5320 * @param {InputOptionFlattened[]} inputOptions
5321 * @param {SweetAlertOptions} params
5322 */
5323 function populateSelectOptions(popup, inputOptions, params) {
5324 const select = getDirectChildByClass(popup, swalClasses.select);
5325 if (!select) {
5326 return;
5327 }
5328 /**
5329 * @param {HTMLElement} parent
5330 * @param {string} optionLabel
5331 * @param {string} optionValue
5332 */
5333 const renderOption = (parent, optionLabel, optionValue) => {
5334 const option = document.createElement('option');
5335 option.value = optionValue;
5336 setInnerHtml(option, optionLabel);
5337 option.selected = isSelected(optionValue, params.inputValue);
5338 parent.appendChild(option);
5339 };
5340 inputOptions.forEach(inputOption => {
5341 const optionValue = inputOption[0];
5342 const optionLabel = inputOption[1];
5343 // <optgroup> spec:
5344 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
5345 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
5346 // check whether this is a <optgroup>
5347 if (Array.isArray(optionLabel)) {
5348 // if it is an array, then it is an <optgroup>
5349 const optgroup = document.createElement('optgroup');
5350 optgroup.label = optionValue;
5351 optgroup.disabled = false; // not configurable for now
5352 select.appendChild(optgroup);
5353 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
5354 } else {
5355 // case of <option>
5356 renderOption(select, optionLabel, optionValue);
5357 }
5358 });
5359 select.focus();
5360 }
5361
5362 /**
5363 * @param {HTMLElement} popup
5364 * @param {InputOptionFlattened[]} inputOptions
5365 * @param {SweetAlertOptions} params
5366 */
5367 function populateRadioOptions(popup, inputOptions, params) {
5368 const radio = getDirectChildByClass(popup, swalClasses.radio);
5369 if (!radio) {
5370 return;
5371 }
5372 inputOptions.forEach(inputOption => {
5373 const radioValue = inputOption[0];
5374 const radioLabel = inputOption[1];
5375 const radioInput = document.createElement('input');
5376 const radioLabelElement = document.createElement('label');
5377 radioInput.type = 'radio';
5378 radioInput.name = swalClasses.radio;
5379 radioInput.value = radioValue;
5380 if (isSelected(radioValue, params.inputValue)) {
5381 radioInput.checked = true;
5382 }
5383 const label = document.createElement('span');
5384 setInnerHtml(label, radioLabel);
5385 label.className = swalClasses.label;
5386 radioLabelElement.appendChild(radioInput);
5387 radioLabelElement.appendChild(label);
5388 radio.appendChild(radioLabelElement);
5389 });
5390 const radios = radio.querySelectorAll('input');
5391 if (radios.length) {
5392 radios[0].focus();
5393 }
5394 }
5395
5396 /**
5397 * Converts `inputOptions` into an array of `[value, label]`s
5398 *
5399 * @param {*} inputOptions
5400 * @typedef {string[]} InputOptionFlattened
5401 * @returns {InputOptionFlattened[]}
5402 */
5403 const formatInputOptions = inputOptions => {
5404 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
5405 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
5406 };
5407
5408 /**
5409 * @param {string} optionValue
5410 * @param {SweetAlertInputValue} inputValue
5411 * @returns {boolean}
5412 */
5413 const isSelected = (optionValue, inputValue) => Boolean(inputValue) && inputValue != null && inputValue.toString() === optionValue.toString();
5414
5415 /**
5416 * @param {SweetAlert} instance
5417 */
5418 const handleConfirmButtonClick = instance => {
5419 const innerParams = privateProps.innerParams.get(instance);
5420 instance.disableButtons();
5421 if (innerParams.input) {
5422 handleConfirmOrDenyWithInput(instance, 'confirm');
5423 } else {
5424 confirm(instance, true);
5425 }
5426 };
5427
5428 /**
5429 * @param {SweetAlert} instance
5430 */
5431 const handleDenyButtonClick = instance => {
5432 const innerParams = privateProps.innerParams.get(instance);
5433 instance.disableButtons();
5434 if (innerParams.returnInputValueOnDeny) {
5435 handleConfirmOrDenyWithInput(instance, 'deny');
5436 } else {
5437 deny(instance, false);
5438 }
5439 };
5440
5441 /**
5442 * @param {SweetAlert} instance
5443 * @param {(dismiss: DismissReason) => void} dismissWith
5444 */
5445 const handleCancelButtonClick = (instance, dismissWith) => {
5446 instance.disableButtons();
5447 dismissWith(DismissReason.cancel);
5448 };
5449
5450 /**
5451 * @param {SweetAlert} instance
5452 * @param {'confirm' | 'deny'} type
5453 */
5454 const handleConfirmOrDenyWithInput = (instance, type) => {
5455 const innerParams = privateProps.innerParams.get(instance);
5456 if (!innerParams.input) {
5457 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
5458 return;
5459 }
5460 const input = instance.getInput();
5461 const inputValue = getInputValue(instance, innerParams);
5462 if (innerParams.inputValidator) {
5463 handleInputValidator(instance, inputValue, type);
5464 } else if (input && !input.checkValidity()) {
5465 instance.enableButtons();
5466 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
5467 } else if (type === 'deny') {
5468 deny(instance, inputValue);
5469 } else {
5470 confirm(instance, inputValue);
5471 }
5472 };
5473
5474 /**
5475 * @param {SweetAlert} instance
5476 * @param {SweetAlertInputValue} inputValue
5477 * @param {'confirm' | 'deny'} type
5478 */
5479 const handleInputValidator = (instance, inputValue, type) => {
5480 const innerParams = privateProps.innerParams.get(instance);
5481 instance.disableInput();
5482 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
5483 validationPromise.then(validationMessage => {
5484 instance.enableButtons();
5485 instance.enableInput();
5486 if (validationMessage) {
5487 instance.showValidationMessage(validationMessage);
5488 } else if (type === 'deny') {
5489 deny(instance, inputValue);
5490 } else {
5491 confirm(instance, inputValue);
5492 }
5493 });
5494 };
5495
5496 /**
5497 * @param {SweetAlert} instance
5498 * @param {*} value
5499 */
5500 const deny = (instance, value) => {
5501 const innerParams = privateProps.innerParams.get(instance);
5502 if (innerParams.showLoaderOnDeny) {
5503 showLoading(getDenyButton());
5504 }
5505 if (innerParams.preDeny) {
5506 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
5507 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
5508 preDenyPromise.then(preDenyValue => {
5509 if (preDenyValue === false) {
5510 instance.hideLoading();
5511 handleAwaitingPromise(instance);
5512 } else {
5513 instance.close(/** @type SweetAlertResult */{
5514 isDenied: true,
5515 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
5516 });
5517 }
5518 }).catch(error => rejectWith(instance, error));
5519 } else {
5520 instance.close(/** @type SweetAlertResult */{
5521 isDenied: true,
5522 value
5523 });
5524 }
5525 };
5526
5527 /**
5528 * @param {SweetAlert} instance
5529 * @param {*} value
5530 */
5531 const succeedWith = (instance, value) => {
5532 instance.close(/** @type SweetAlertResult */{
5533 isConfirmed: true,
5534 value
5535 });
5536 };
5537
5538 /**
5539 *
5540 * @param {SweetAlert} instance
5541 * @param {string} error
5542 */
5543 const rejectWith = (instance, error) => {
5544 instance.rejectPromise(error);
5545 };
5546
5547 /**
5548 *
5549 * @param {SweetAlert} instance
5550 * @param {*} value
5551 */
5552 const confirm = (instance, value) => {
5553 const innerParams = privateProps.innerParams.get(instance);
5554 if (innerParams.showLoaderOnConfirm) {
5555 showLoading();
5556 }
5557 if (innerParams.preConfirm) {
5558 instance.resetValidationMessage();
5559 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
5560 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5561 preConfirmPromise.then(preConfirmValue => {
5562 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5563 instance.hideLoading();
5564 handleAwaitingPromise(instance);
5565 } else {
5566 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5567 }
5568 }).catch(error => rejectWith(instance, error));
5569 } else {
5570 succeedWith(instance, value);
5571 }
5572 };
5573
5574 /**
5575 * Hides loader and shows back the button which was hidden by .showLoading()
5576 * @this {SweetAlert}
5577 */
5578 function hideLoading() {
5579 // do nothing if popup is closed
5580 const innerParams = privateProps.innerParams.get(this);
5581 if (!innerParams) {
5582 return;
5583 }
5584 const domCache = privateProps.domCache.get(this);
5585 hide(domCache.loader);
5586 if (isToast()) {
5587 if (innerParams.icon) {
5588 show(getIcon());
5589 }
5590 } else {
5591 showRelatedButton(domCache);
5592 }
5593 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5594 domCache.popup.removeAttribute('aria-busy');
5595 domCache.popup.removeAttribute('data-loading');
5596 this.enableButtons();
5597 }
5598
5599 /**
5600 * @param {DomCache} domCache
5601 */
5602 const showRelatedButton = domCache => {
5603 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5604 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5605 if (buttonToReplace.length) {
5606 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5607 } else if (allButtonsAreHidden()) {
5608 hide(domCache.actions);
5609 }
5610 };
5611
5612 /**
5613 * Gets the input DOM node, this method works with input parameter.
5614 *
5615 * @returns {HTMLInputElement | null}
5616 * @this {SweetAlert}
5617 */
5618 function getInput() {
5619 const innerParams = privateProps.innerParams.get(this);
5620 const domCache = privateProps.domCache.get(this);
5621 if (!domCache) {
5622 return null;
5623 }
5624 return getInput$1(domCache.popup, innerParams.input);
5625 }
5626
5627 /**
5628 * @param {SweetAlert} instance
5629 * @param {string[]} buttons
5630 * @param {boolean} disabled
5631 */
5632 function setButtonsDisabled(instance, buttons, disabled) {
5633 const domCache = privateProps.domCache.get(instance);
5634 buttons.forEach(button => {
5635 domCache[button].disabled = disabled;
5636 });
5637 }
5638
5639 /**
5640 * @param {HTMLInputElement | null} input
5641 * @param {boolean} disabled
5642 */
5643 function setInputDisabled(input, disabled) {
5644 const popup = getPopup();
5645 if (!popup || !input) {
5646 return;
5647 }
5648 if (input.type === 'radio') {
5649 /** @type {NodeListOf<HTMLInputElement>} */
5650 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5651 radios.forEach(radio => {
5652 radio.disabled = disabled;
5653 });
5654 } else {
5655 input.disabled = disabled;
5656 }
5657 }
5658
5659 /**
5660 * Enable all the buttons
5661 * @this {SweetAlert}
5662 */
5663 function enableButtons() {
5664 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5665 const focusedElement = privateProps.focusedElement.get(this);
5666 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
5667 focusedElement.focus();
5668 }
5669 privateProps.focusedElement.delete(this);
5670 }
5671
5672 /**
5673 * Disable all the buttons
5674 * @this {SweetAlert}
5675 */
5676 function disableButtons() {
5677 privateProps.focusedElement.set(this, document.activeElement);
5678 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5679 }
5680
5681 /**
5682 * Enable the input field
5683 * @this {SweetAlert}
5684 */
5685 function enableInput() {
5686 setInputDisabled(this.getInput(), false);
5687 }
5688
5689 /**
5690 * Disable the input field
5691 * @this {SweetAlert}
5692 */
5693 function disableInput() {
5694 setInputDisabled(this.getInput(), true);
5695 }
5696
5697 /**
5698 * Show block with validation message
5699 *
5700 * @param {string} error
5701 * @this {SweetAlert}
5702 */
5703 function showValidationMessage(error) {
5704 const domCache = privateProps.domCache.get(this);
5705 const params = privateProps.innerParams.get(this);
5706 setInnerHtml(domCache.validationMessage, error);
5707 domCache.validationMessage.className = swalClasses['validation-message'];
5708 if (params.customClass && params.customClass.validationMessage) {
5709 addClass(domCache.validationMessage, params.customClass.validationMessage);
5710 }
5711 show(domCache.validationMessage);
5712 const input = this.getInput();
5713 if (input) {
5714 input.setAttribute('aria-invalid', 'true');
5715 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5716 focusInput(input);
5717 addClass(input, swalClasses.inputerror);
5718 }
5719 }
5720
5721 /**
5722 * Hide block with validation message
5723 *
5724 * @this {SweetAlert}
5725 */
5726 function resetValidationMessage() {
5727 const domCache = privateProps.domCache.get(this);
5728 if (domCache.validationMessage) {
5729 hide(domCache.validationMessage);
5730 }
5731 const input = this.getInput();
5732 if (input) {
5733 input.removeAttribute('aria-invalid');
5734 input.removeAttribute('aria-describedby');
5735 removeClass(input, swalClasses.inputerror);
5736 }
5737 }
5738
5739 const defaultParams = {
5740 title: '',
5741 titleText: '',
5742 text: '',
5743 html: '',
5744 footer: '',
5745 icon: undefined,
5746 iconColor: undefined,
5747 iconHtml: undefined,
5748 template: undefined,
5749 toast: false,
5750 draggable: false,
5751 animation: true,
5752 theme: 'light',
5753 showClass: {
5754 popup: 'swal2-show',
5755 backdrop: 'swal2-backdrop-show',
5756 icon: 'swal2-icon-show'
5757 },
5758 hideClass: {
5759 popup: 'swal2-hide',
5760 backdrop: 'swal2-backdrop-hide',
5761 icon: 'swal2-icon-hide'
5762 },
5763 customClass: {},
5764 target: 'body',
5765 color: undefined,
5766 backdrop: true,
5767 heightAuto: true,
5768 allowOutsideClick: true,
5769 allowEscapeKey: true,
5770 allowEnterKey: true,
5771 stopKeydownPropagation: true,
5772 keydownListenerCapture: false,
5773 showConfirmButton: true,
5774 showDenyButton: false,
5775 showCancelButton: false,
5776 preConfirm: undefined,
5777 preDeny: undefined,
5778 confirmButtonText: 'OK',
5779 confirmButtonAriaLabel: '',
5780 confirmButtonColor: undefined,
5781 denyButtonText: 'No',
5782 denyButtonAriaLabel: '',
5783 denyButtonColor: undefined,
5784 cancelButtonText: 'Cancel',
5785 cancelButtonAriaLabel: '',
5786 cancelButtonColor: undefined,
5787 buttonsStyling: true,
5788 reverseButtons: false,
5789 focusConfirm: true,
5790 focusDeny: false,
5791 focusCancel: false,
5792 returnFocus: true,
5793 showCloseButton: false,
5794 closeButtonHtml: '&times;',
5795 closeButtonAriaLabel: 'Close this dialog',
5796 loaderHtml: '',
5797 showLoaderOnConfirm: false,
5798 showLoaderOnDeny: false,
5799 imageUrl: undefined,
5800 imageWidth: undefined,
5801 imageHeight: undefined,
5802 imageAlt: '',
5803 timer: undefined,
5804 timerProgressBar: false,
5805 width: undefined,
5806 padding: undefined,
5807 background: undefined,
5808 input: undefined,
5809 inputPlaceholder: '',
5810 inputLabel: '',
5811 inputValue: '',
5812 inputOptions: {},
5813 inputAutoFocus: true,
5814 inputAutoTrim: true,
5815 inputAttributes: {},
5816 inputValidator: undefined,
5817 returnInputValueOnDeny: false,
5818 validationMessage: undefined,
5819 grow: false,
5820 position: 'center',
5821 progressSteps: [],
5822 currentProgressStep: undefined,
5823 progressStepsDistance: undefined,
5824 willOpen: undefined,
5825 didOpen: undefined,
5826 didRender: undefined,
5827 willClose: undefined,
5828 didClose: undefined,
5829 didDestroy: undefined,
5830 scrollbarPadding: true,
5831 topLayer: false
5832 };
5833 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'];
5834
5835 /** @type {Record<string, string | undefined>} */
5836 const deprecatedParams = {
5837 allowEnterKey: undefined
5838 };
5839 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5840
5841 /**
5842 * Is valid parameter
5843 *
5844 * @param {string} paramName
5845 * @returns {boolean}
5846 */
5847 const isValidParameter = paramName => {
5848 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5849 };
5850
5851 /**
5852 * Is valid parameter for Swal.update() method
5853 *
5854 * @param {string} paramName
5855 * @returns {boolean}
5856 */
5857 const isUpdatableParameter = paramName => {
5858 return updatableParams.indexOf(paramName) !== -1;
5859 };
5860
5861 /**
5862 * Is deprecated parameter
5863 *
5864 * @param {string} paramName
5865 * @returns {string | undefined}
5866 */
5867 const isDeprecatedParameter = paramName => {
5868 return deprecatedParams[paramName];
5869 };
5870
5871 /**
5872 * @param {string} param
5873 */
5874 const checkIfParamIsValid = param => {
5875 if (!isValidParameter(param)) {
5876 warn(`Unknown parameter "${param}"`);
5877 }
5878 };
5879
5880 /**
5881 * @param {string} param
5882 */
5883 const checkIfToastParamIsValid = param => {
5884 if (toastIncompatibleParams.includes(param)) {
5885 warn(`The parameter "${param}" is incompatible with toasts`);
5886 }
5887 };
5888
5889 /**
5890 * @param {string} param
5891 */
5892 const checkIfParamIsDeprecated = param => {
5893 const isDeprecated = isDeprecatedParameter(param);
5894 if (isDeprecated) {
5895 warnAboutDeprecation(param, isDeprecated);
5896 }
5897 };
5898
5899 /**
5900 * Show relevant warnings for given params
5901 *
5902 * @param {SweetAlertOptions} params
5903 */
5904 const showWarningsForParams = params => {
5905 if (params.backdrop === false && params.allowOutsideClick) {
5906 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5907 }
5908 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)) {
5909 warn(`Invalid theme "${params.theme}"`);
5910 }
5911 for (const param in params) {
5912 checkIfParamIsValid(param);
5913 if (params.toast) {
5914 checkIfToastParamIsValid(param);
5915 }
5916 checkIfParamIsDeprecated(param);
5917 }
5918 };
5919
5920 /**
5921 * Updates popup parameters.
5922 *
5923 * @this {any}
5924 * @param {SweetAlertOptions} params
5925 */
5926 function update(params) {
5927 const container = getContainer();
5928 const popup = getPopup();
5929 const innerParams = privateProps.innerParams.get(this);
5930 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5931 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.`);
5932 return;
5933 }
5934 const validUpdatableParams = filterValidParams(params);
5935 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5936 showWarningsForParams(updatedParams);
5937 if (container) {
5938 container.dataset['swal2Theme'] = updatedParams.theme;
5939 }
5940 render(this, updatedParams);
5941 privateProps.innerParams.set(this, updatedParams);
5942 Object.defineProperties(this, {
5943 params: {
5944 value: Object.assign({}, this.params, params),
5945 writable: false,
5946 enumerable: true
5947 }
5948 });
5949 }
5950
5951 /**
5952 * @param {SweetAlertOptions} params
5953 * @returns {SweetAlertOptions}
5954 */
5955 const filterValidParams = params => {
5956 /** @type {Record<string, any>} */
5957 const validUpdatableParams = {};
5958 Object.keys(params).forEach(param => {
5959 if (isUpdatableParameter(param)) {
5960 const typedParams = /** @type {Record<string, any>} */params;
5961 validUpdatableParams[param] = typedParams[param];
5962 } else {
5963 warn(`Invalid parameter to update: ${param}`);
5964 }
5965 });
5966 return validUpdatableParams;
5967 };
5968
5969 /**
5970 * Dispose the current SweetAlert2 instance
5971 * @this {SweetAlert}
5972 */
5973 function _destroy() {
5974 var _globalState$eventEmi;
5975 const domCache = privateProps.domCache.get(this);
5976 const innerParams = privateProps.innerParams.get(this);
5977 if (!innerParams) {
5978 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5979 return; // This instance has already been destroyed
5980 }
5981
5982 // Check if there is another Swal closing
5983 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5984 globalState.swalCloseEventFinishedCallback();
5985 delete globalState.swalCloseEventFinishedCallback;
5986 }
5987 if (typeof innerParams.didDestroy === 'function') {
5988 innerParams.didDestroy();
5989 }
5990 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5991 disposeSwal(this);
5992 }
5993
5994 /**
5995 * @param {SweetAlert} instance
5996 */
5997 const disposeSwal = instance => {
5998 disposeWeakMaps(instance);
5999 // Unset this.params so GC will dispose it (#1569)
6000 // @ts-ignore
6001 delete instance.params;
6002 // Unset globalState props so GC will dispose globalState (#1569)
6003 delete globalState.keydownHandler;
6004 delete globalState.keydownTarget;
6005 // Unset currentInstance
6006 delete globalState.currentInstance;
6007 };
6008
6009 /**
6010 * @param {SweetAlert} instance
6011 */
6012 const disposeWeakMaps = instance => {
6013 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
6014 if (instance.isAwaitingPromise) {
6015 unsetWeakMaps(privateProps, instance);
6016 instance.isAwaitingPromise = true;
6017 } else {
6018 unsetWeakMaps(privateMethods, instance);
6019 unsetWeakMaps(privateProps, instance);
6020
6021 // @ts-ignore
6022 delete instance.isAwaitingPromise;
6023 // Unset instance methods
6024 // @ts-ignore
6025 delete instance.disableButtons;
6026 // @ts-ignore
6027 delete instance.enableButtons;
6028 // @ts-ignore
6029 delete instance.getInput;
6030 // @ts-ignore
6031 delete instance.disableInput;
6032 // @ts-ignore
6033 delete instance.enableInput;
6034 // @ts-ignore
6035 delete instance.hideLoading;
6036 // @ts-ignore
6037 delete instance.disableLoading;
6038 // @ts-ignore
6039 delete instance.showValidationMessage;
6040 // @ts-ignore
6041 delete instance.resetValidationMessage;
6042 // @ts-ignore
6043 delete instance.close;
6044 // @ts-ignore
6045 delete instance.closePopup;
6046 // @ts-ignore
6047 delete instance.closeModal;
6048 // @ts-ignore
6049 delete instance.closeToast;
6050 // @ts-ignore
6051 delete instance.rejectPromise;
6052 // @ts-ignore
6053 delete instance.update;
6054 // @ts-ignore
6055 delete instance._destroy;
6056 }
6057 };
6058
6059 /**
6060 * @param {Record<string, WeakMap<any, any>>} obj
6061 * @param {SweetAlert} instance
6062 */
6063 const unsetWeakMaps = (obj, instance) => {
6064 for (const i in obj) {
6065 obj[i].delete(instance);
6066 }
6067 };
6068
6069 var instanceMethods = /*#__PURE__*/Object.freeze({
6070 __proto__: null,
6071 _destroy: _destroy,
6072 close: close,
6073 closeModal: close,
6074 closePopup: close,
6075 closeToast: close,
6076 disableButtons: disableButtons,
6077 disableInput: disableInput,
6078 disableLoading: hideLoading,
6079 enableButtons: enableButtons,
6080 enableInput: enableInput,
6081 getInput: getInput,
6082 handleAwaitingPromise: handleAwaitingPromise,
6083 hideLoading: hideLoading,
6084 rejectPromise: rejectPromise,
6085 resetValidationMessage: resetValidationMessage,
6086 showValidationMessage: showValidationMessage,
6087 update: update
6088 });
6089
6090 /**
6091 * @param {SweetAlertOptions} innerParams
6092 * @param {DomCache} domCache
6093 * @param {(dismiss: DismissReason) => void} dismissWith
6094 */
6095 const handlePopupClick = (innerParams, domCache, dismissWith) => {
6096 if (innerParams.toast) {
6097 handleToastClick(innerParams, domCache, dismissWith);
6098 } else {
6099 // Ignore click events that had mousedown on the popup but mouseup on the container
6100 // This can happen when the user drags a slider
6101 handleModalMousedown(domCache);
6102
6103 // Ignore click events that had mousedown on the container but mouseup on the popup
6104 handleContainerMousedown(domCache);
6105 handleModalClick(innerParams, domCache, dismissWith);
6106 }
6107 };
6108
6109 /**
6110 * @param {SweetAlertOptions} innerParams
6111 * @param {DomCache} domCache
6112 * @param {(dismiss: DismissReason) => void} dismissWith
6113 */
6114 const handleToastClick = (innerParams, domCache, dismissWith) => {
6115 // Closing toast by internal click
6116 domCache.popup.onclick = () => {
6117 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
6118 return;
6119 }
6120 dismissWith(DismissReason.close);
6121 };
6122 };
6123
6124 /**
6125 * @param {SweetAlertOptions} innerParams
6126 * @returns {boolean}
6127 */
6128 const isAnyButtonShown = innerParams => {
6129 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
6130 };
6131 let ignoreOutsideClick = false;
6132
6133 /**
6134 * @param {DomCache} domCache
6135 */
6136 const handleModalMousedown = domCache => {
6137 domCache.popup.onmousedown = () => {
6138 domCache.container.onmouseup = function (e) {
6139 domCache.container.onmouseup = () => {};
6140 // We only check if the mouseup target is the container because usually it doesn't
6141 // have any other direct children aside of the popup
6142 if (e.target === domCache.container) {
6143 ignoreOutsideClick = true;
6144 }
6145 };
6146 };
6147 };
6148
6149 /**
6150 * @param {DomCache} domCache
6151 */
6152 const handleContainerMousedown = domCache => {
6153 domCache.container.onmousedown = e => {
6154 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
6155 if (e.target === domCache.container) {
6156 e.preventDefault();
6157 }
6158 domCache.popup.onmouseup = function (e) {
6159 domCache.popup.onmouseup = () => {};
6160 // We also need to check if the mouseup target is a child of the popup
6161 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
6162 ignoreOutsideClick = true;
6163 }
6164 };
6165 };
6166 };
6167
6168 /**
6169 * @param {SweetAlertOptions} innerParams
6170 * @param {DomCache} domCache
6171 * @param {(dismiss: DismissReason) => void} dismissWith
6172 */
6173 const handleModalClick = (innerParams, domCache, dismissWith) => {
6174 domCache.container.onclick = e => {
6175 if (ignoreOutsideClick) {
6176 ignoreOutsideClick = false;
6177 return;
6178 }
6179 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
6180 dismissWith(DismissReason.backdrop);
6181 }
6182 };
6183 };
6184
6185 /**
6186 * @param {unknown} elem
6187 * @returns {boolean}
6188 */
6189 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
6190
6191 /**
6192 * @param {unknown} elem
6193 * @returns {boolean}
6194 */
6195 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
6196
6197 /**
6198 * @param {ReadonlyArray<unknown>} args
6199 * @returns {SweetAlertOptions}
6200 */
6201 const argsToParams = args => {
6202 /** @type {Record<string, unknown>} */
6203 const params = {};
6204 if (typeof args[0] === 'object' && !isElement(args[0])) {
6205 Object.assign(params, args[0]);
6206 } else {
6207 ['title', 'html', 'icon'].forEach((name, index) => {
6208 const arg = args[index];
6209 if (typeof arg === 'string' || isElement(arg)) {
6210 params[name] = arg;
6211 } else if (arg !== undefined) {
6212 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
6213 }
6214 });
6215 }
6216 return /** @type {SweetAlertOptions} */params;
6217 };
6218
6219 /**
6220 * Main method to create a new SweetAlert2 popup
6221 *
6222 * @this {new (...args: any[]) => any}
6223 * @param {...SweetAlertOptions} args
6224 * @returns {Promise<SweetAlertResult>}
6225 */
6226 function fire(...args) {
6227 return new this(...args);
6228 }
6229
6230 /**
6231 * Returns an extended version of `Swal` containing `params` as defaults.
6232 * Useful for reusing Swal configuration.
6233 *
6234 * For example:
6235 *
6236 * Before:
6237 * const textPromptOptions = { input: 'text', showCancelButton: true }
6238 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
6239 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
6240 *
6241 * After:
6242 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
6243 * const {value: firstName} = await TextPrompt('What is your first name?')
6244 * const {value: lastName} = await TextPrompt('What is your last name?')
6245 *
6246 * @param {SweetAlertOptions} mixinParams
6247 * @returns {SweetAlert}
6248 * @this {typeof import('../SweetAlert.js').SweetAlert}
6249 */
6250 function mixin(mixinParams) {
6251 // @ts-ignore: 'this' refers to the SweetAlert constructor
6252 class MixinSwal extends this {
6253 /**
6254 * @param {any} params
6255 * @param {any} priorityMixinParams
6256 */
6257 _main(params, priorityMixinParams) {
6258 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
6259 }
6260 }
6261 // @ts-ignore
6262 return MixinSwal;
6263 }
6264
6265 /**
6266 * If `timer` parameter is set, returns number of milliseconds of timer remained.
6267 * Otherwise, returns undefined.
6268 *
6269 * @returns {number | undefined}
6270 */
6271 const getTimerLeft = () => {
6272 return globalState.timeout && globalState.timeout.getTimerLeft();
6273 };
6274
6275 /**
6276 * Stop timer. Returns number of milliseconds of timer remained.
6277 * If `timer` parameter isn't set, returns undefined.
6278 *
6279 * @returns {number | undefined}
6280 */
6281 const stopTimer = () => {
6282 if (globalState.timeout) {
6283 stopTimerProgressBar();
6284 return globalState.timeout.stop();
6285 }
6286 };
6287
6288 /**
6289 * Resume timer. Returns number of milliseconds of timer remained.
6290 * If `timer` parameter isn't set, returns undefined.
6291 *
6292 * @returns {number | undefined}
6293 */
6294 const resumeTimer = () => {
6295 if (globalState.timeout) {
6296 const remaining = globalState.timeout.start();
6297 animateTimerProgressBar(remaining);
6298 return remaining;
6299 }
6300 };
6301
6302 /**
6303 * Resume timer. Returns number of milliseconds of timer remained.
6304 * If `timer` parameter isn't set, returns undefined.
6305 *
6306 * @returns {number | undefined}
6307 */
6308 const toggleTimer = () => {
6309 const timer = globalState.timeout;
6310 return timer && (timer.running ? stopTimer() : resumeTimer());
6311 };
6312
6313 /**
6314 * Increase timer. Returns number of milliseconds of an updated timer.
6315 * If `timer` parameter isn't set, returns undefined.
6316 *
6317 * @param {number} ms
6318 * @returns {number | undefined}
6319 */
6320 const increaseTimer = ms => {
6321 if (globalState.timeout) {
6322 const remaining = globalState.timeout.increase(ms);
6323 animateTimerProgressBar(remaining, true);
6324 return remaining;
6325 }
6326 };
6327
6328 /**
6329 * Check if timer is running. Returns true if timer is running
6330 * or false if timer is paused or stopped.
6331 * If `timer` parameter isn't set, returns undefined
6332 *
6333 * @returns {boolean}
6334 */
6335 const isTimerRunning = () => {
6336 return Boolean(globalState.timeout && globalState.timeout.isRunning());
6337 };
6338
6339 let bodyClickListenerAdded = false;
6340 /** @type {Record<string, any>} */
6341 const clickHandlers = {};
6342
6343 /**
6344 * @this {any}
6345 * @param {string} attr
6346 */
6347 function bindClickHandler(attr = 'data-swal-template') {
6348 clickHandlers[attr] = this;
6349 if (!bodyClickListenerAdded) {
6350 document.body.addEventListener('click', bodyClickListener);
6351 bodyClickListenerAdded = true;
6352 }
6353 }
6354
6355 /**
6356 * @param {MouseEvent} event
6357 */
6358 const bodyClickListener = event => {
6359 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
6360 for (const attr in clickHandlers) {
6361 const template = el.getAttribute && el.getAttribute(attr);
6362 if (template) {
6363 clickHandlers[attr].fire({
6364 template
6365 });
6366 return;
6367 }
6368 }
6369 }
6370 };
6371
6372 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
6373
6374 class EventEmitter {
6375 constructor() {
6376 /** @type {Events} */
6377 this.events = {};
6378 }
6379
6380 /**
6381 * @param {string} eventName
6382 * @returns {EventHandlers}
6383 */
6384 _getHandlersByEventName(eventName) {
6385 if (typeof this.events[eventName] === 'undefined') {
6386 // not Set because we need to keep the FIFO order
6387 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
6388 this.events[eventName] = [];
6389 }
6390 return this.events[eventName];
6391 }
6392
6393 /**
6394 * @param {string} eventName
6395 * @param {EventHandler} eventHandler
6396 */
6397 on(eventName, eventHandler) {
6398 const currentHandlers = this._getHandlersByEventName(eventName);
6399 if (!currentHandlers.includes(eventHandler)) {
6400 currentHandlers.push(eventHandler);
6401 }
6402 }
6403
6404 /**
6405 * @param {string} eventName
6406 * @param {EventHandler} eventHandler
6407 */
6408 once(eventName, eventHandler) {
6409 /**
6410 * @param {...any} args
6411 */
6412 const onceFn = (...args) => {
6413 this.removeListener(eventName, onceFn);
6414 // @ts-ignore
6415 eventHandler.apply(this, args);
6416 };
6417 this.on(eventName, onceFn);
6418 }
6419
6420 /**
6421 * @param {string} eventName
6422 * @param {...any} args
6423 */
6424 emit(eventName, ...args) {
6425 this._getHandlersByEventName(eventName).forEach(
6426 /**
6427 * @param {EventHandler} eventHandler
6428 */
6429 eventHandler => {
6430 try {
6431 // @ts-ignore
6432 eventHandler.apply(this, args);
6433 } catch (error) {
6434 console.error(error);
6435 }
6436 });
6437 }
6438
6439 /**
6440 * @param {string} eventName
6441 * @param {EventHandler} eventHandler
6442 */
6443 removeListener(eventName, eventHandler) {
6444 const currentHandlers = this._getHandlersByEventName(eventName);
6445 const index = currentHandlers.indexOf(eventHandler);
6446 if (index > -1) {
6447 currentHandlers.splice(index, 1);
6448 }
6449 }
6450
6451 /**
6452 * @param {string} eventName
6453 */
6454 removeAllListeners(eventName) {
6455 if (this.events[eventName] !== undefined) {
6456 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
6457 this.events[eventName].length = 0;
6458 }
6459 }
6460 reset() {
6461 this.events = {};
6462 }
6463 }
6464
6465 globalState.eventEmitter = new EventEmitter();
6466
6467 /**
6468 * @param {string} eventName
6469 * @param {EventHandler} eventHandler
6470 */
6471 const on = (eventName, eventHandler) => {
6472 if (globalState.eventEmitter) {
6473 globalState.eventEmitter.on(eventName, eventHandler);
6474 }
6475 };
6476
6477 /**
6478 * @param {string} eventName
6479 * @param {EventHandler} eventHandler
6480 */
6481 const once = (eventName, eventHandler) => {
6482 if (globalState.eventEmitter) {
6483 globalState.eventEmitter.once(eventName, eventHandler);
6484 }
6485 };
6486
6487 /**
6488 * @param {string} [eventName]
6489 * @param {EventHandler} [eventHandler]
6490 */
6491 const off = (eventName, eventHandler) => {
6492 if (!globalState.eventEmitter) {
6493 return;
6494 }
6495
6496 // Remove all handlers for all events
6497 if (!eventName) {
6498 globalState.eventEmitter.reset();
6499 return;
6500 }
6501 if (eventHandler) {
6502 // Remove a specific handler
6503 globalState.eventEmitter.removeListener(eventName, eventHandler);
6504 } else {
6505 // Remove all handlers for a specific event
6506 globalState.eventEmitter.removeAllListeners(eventName);
6507 }
6508 };
6509
6510 var staticMethods = /*#__PURE__*/Object.freeze({
6511 __proto__: null,
6512 argsToParams: argsToParams,
6513 bindClickHandler: bindClickHandler,
6514 clickCancel: clickCancel,
6515 clickConfirm: clickConfirm,
6516 clickDeny: clickDeny,
6517 enableLoading: showLoading,
6518 fire: fire,
6519 getActions: getActions,
6520 getCancelButton: getCancelButton,
6521 getCloseButton: getCloseButton,
6522 getConfirmButton: getConfirmButton,
6523 getContainer: getContainer,
6524 getDenyButton: getDenyButton,
6525 getFocusableElements: getFocusableElements,
6526 getFooter: getFooter,
6527 getHtmlContainer: getHtmlContainer,
6528 getIcon: getIcon,
6529 getIconContent: getIconContent,
6530 getImage: getImage,
6531 getInputLabel: getInputLabel,
6532 getLoader: getLoader,
6533 getPopup: getPopup,
6534 getProgressSteps: getProgressSteps,
6535 getTimerLeft: getTimerLeft,
6536 getTimerProgressBar: getTimerProgressBar,
6537 getTitle: getTitle,
6538 getValidationMessage: getValidationMessage,
6539 increaseTimer: increaseTimer,
6540 isDeprecatedParameter: isDeprecatedParameter,
6541 isLoading: isLoading,
6542 isTimerRunning: isTimerRunning,
6543 isUpdatableParameter: isUpdatableParameter,
6544 isValidParameter: isValidParameter,
6545 isVisible: isVisible,
6546 mixin: mixin,
6547 off: off,
6548 on: on,
6549 once: once,
6550 resumeTimer: resumeTimer,
6551 showLoading: showLoading,
6552 stopTimer: stopTimer,
6553 toggleTimer: toggleTimer
6554 });
6555
6556 class Timer {
6557 /**
6558 * @param {() => void} callback
6559 * @param {number} delay
6560 */
6561 constructor(callback, delay) {
6562 this.callback = callback;
6563 this.remaining = delay;
6564 this.running = false;
6565 this.start();
6566 }
6567
6568 /**
6569 * @returns {number}
6570 */
6571 start() {
6572 if (!this.running) {
6573 this.running = true;
6574 this.started = new Date();
6575 this.id = setTimeout(this.callback, this.remaining);
6576 }
6577 return this.remaining;
6578 }
6579
6580 /**
6581 * @returns {number}
6582 */
6583 stop() {
6584 if (this.started && this.running) {
6585 this.running = false;
6586 clearTimeout(this.id);
6587 this.remaining -= new Date().getTime() - this.started.getTime();
6588 }
6589 return this.remaining;
6590 }
6591
6592 /**
6593 * @param {number} n
6594 * @returns {number}
6595 */
6596 increase(n) {
6597 const running = this.running;
6598 if (running) {
6599 this.stop();
6600 }
6601 this.remaining += n;
6602 if (running) {
6603 this.start();
6604 }
6605 return this.remaining;
6606 }
6607
6608 /**
6609 * @returns {number}
6610 */
6611 getTimerLeft() {
6612 if (this.running) {
6613 this.stop();
6614 this.start();
6615 }
6616 return this.remaining;
6617 }
6618
6619 /**
6620 * @returns {boolean}
6621 */
6622 isRunning() {
6623 return this.running;
6624 }
6625 }
6626
6627 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6628
6629 /**
6630 * @param {SweetAlertOptions} params
6631 * @returns {SweetAlertOptions}
6632 */
6633 const getTemplateParams = params => {
6634 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6635 if (!template) {
6636 return {};
6637 }
6638 /** @type {DocumentFragment} */
6639 const templateContent = template.content;
6640 showWarningsForElements(templateContent);
6641 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6642 return result;
6643 };
6644
6645 /**
6646 * @param {DocumentFragment} templateContent
6647 * @returns {Record<string, string | boolean | number>}
6648 */
6649 const getSwalParams = templateContent => {
6650 /** @type {Record<string, string | boolean | number>} */
6651 const result = {};
6652 /** @type {HTMLElement[]} */
6653 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6654 swalParams.forEach(param => {
6655 showWarningsForAttributes(param, ['name', 'value']);
6656 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6657 const value = param.getAttribute('value');
6658 if (!paramName || !value) {
6659 return;
6660 }
6661 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6662 result[paramName] = value !== 'false';
6663 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6664 result[paramName] = JSON.parse(value);
6665 } else {
6666 result[paramName] = value;
6667 }
6668 });
6669 return result;
6670 };
6671
6672 /**
6673 * @param {DocumentFragment} templateContent
6674 * @returns {Record<string, () => void>}
6675 */
6676 const getSwalFunctionParams = templateContent => {
6677 /** @type {Record<string, () => void>} */
6678 const result = {};
6679 /** @type {HTMLElement[]} */
6680 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6681 swalFunctions.forEach(param => {
6682 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6683 const value = param.getAttribute('value');
6684 if (!paramName || !value) {
6685 return;
6686 }
6687 result[paramName] = new Function(`return ${value}`)();
6688 });
6689 return result;
6690 };
6691
6692 /**
6693 * @param {DocumentFragment} templateContent
6694 * @returns {Record<string, string | boolean>}
6695 */
6696 const getSwalButtons = templateContent => {
6697 /** @type {Record<string, string | boolean>} */
6698 const result = {};
6699 /** @type {HTMLElement[]} */
6700 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6701 swalButtons.forEach(button => {
6702 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6703 const type = button.getAttribute('type');
6704 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6705 return;
6706 }
6707 result[`${type}ButtonText`] = button.innerHTML;
6708 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6709 const color = button.getAttribute('color');
6710 if (color !== null) {
6711 result[`${type}ButtonColor`] = color;
6712 }
6713 const ariaLabel = button.getAttribute('aria-label');
6714 if (ariaLabel !== null) {
6715 result[`${type}ButtonAriaLabel`] = ariaLabel;
6716 }
6717 });
6718 return result;
6719 };
6720
6721 /**
6722 * @param {DocumentFragment} templateContent
6723 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6724 */
6725 const getSwalImage = templateContent => {
6726 const result = {};
6727 /** @type {HTMLElement | null} */
6728 const image = templateContent.querySelector('swal-image');
6729 if (image) {
6730 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6731 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
6732 const src = image.getAttribute('src');
6733 if (src !== null) result.imageUrl = src || undefined;
6734 const width = image.getAttribute('width');
6735 if (width !== null) result.imageWidth = width || undefined;
6736 const height = image.getAttribute('height');
6737 if (height !== null) result.imageHeight = height || undefined;
6738 const alt = image.getAttribute('alt');
6739 if (alt !== null) result.imageAlt = alt || undefined;
6740 }
6741 return result;
6742 };
6743
6744 /**
6745 * @param {DocumentFragment} templateContent
6746 * @returns {object}
6747 */
6748 const getSwalIcon = templateContent => {
6749 const result = {};
6750 /** @type {HTMLElement | null} */
6751 const icon = templateContent.querySelector('swal-icon');
6752 if (icon) {
6753 showWarningsForAttributes(icon, ['type', 'color']);
6754 if (icon.hasAttribute('type')) {
6755 result.icon = icon.getAttribute('type');
6756 }
6757 if (icon.hasAttribute('color')) {
6758 result.iconColor = icon.getAttribute('color');
6759 }
6760 result.iconHtml = icon.innerHTML;
6761 }
6762 return result;
6763 };
6764
6765 /**
6766 * @param {DocumentFragment} templateContent
6767 * @returns {object}
6768 */
6769 const getSwalInput = templateContent => {
6770 /** @type {Record<string, any>} */
6771 const result = {};
6772 /** @type {HTMLElement | null} */
6773 const input = templateContent.querySelector('swal-input');
6774 if (input) {
6775 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6776 result.input = input.getAttribute('type') || 'text';
6777 if (input.hasAttribute('label')) {
6778 result.inputLabel = input.getAttribute('label');
6779 }
6780 if (input.hasAttribute('placeholder')) {
6781 result.inputPlaceholder = input.getAttribute('placeholder');
6782 }
6783 if (input.hasAttribute('value')) {
6784 result.inputValue = input.getAttribute('value');
6785 }
6786 }
6787 /** @type {HTMLElement[]} */
6788 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6789 if (inputOptions.length) {
6790 result.inputOptions = {};
6791 inputOptions.forEach(option => {
6792 showWarningsForAttributes(option, ['value']);
6793 const optionValue = option.getAttribute('value');
6794 if (!optionValue) {
6795 return;
6796 }
6797 const optionName = option.innerHTML;
6798 result.inputOptions[optionValue] = optionName;
6799 });
6800 }
6801 return result;
6802 };
6803
6804 /**
6805 * @param {DocumentFragment} templateContent
6806 * @param {string[]} paramNames
6807 * @returns {Record<string, string>}
6808 */
6809 const getSwalStringParams = (templateContent, paramNames) => {
6810 /** @type {Record<string, string>} */
6811 const result = {};
6812 for (const i in paramNames) {
6813 const paramName = paramNames[i];
6814 /** @type {HTMLElement | null} */
6815 const tag = templateContent.querySelector(paramName);
6816 if (tag) {
6817 showWarningsForAttributes(tag, []);
6818 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6819 }
6820 }
6821 return result;
6822 };
6823
6824 /**
6825 * @param {DocumentFragment} templateContent
6826 */
6827 const showWarningsForElements = templateContent => {
6828 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6829 Array.from(templateContent.children).forEach(el => {
6830 const tagName = el.tagName.toLowerCase();
6831 if (!allowedElements.includes(tagName)) {
6832 warn(`Unrecognized element <${tagName}>`);
6833 }
6834 });
6835 };
6836
6837 /**
6838 * @param {HTMLElement} el
6839 * @param {string[]} allowedAttributes
6840 */
6841 const showWarningsForAttributes = (el, allowedAttributes) => {
6842 Array.from(el.attributes).forEach(attribute => {
6843 if (allowedAttributes.indexOf(attribute.name) === -1) {
6844 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.'}`]);
6845 }
6846 });
6847 };
6848
6849 const SHOW_CLASS_TIMEOUT = 10;
6850
6851 /**
6852 * Open popup, add necessary classes and styles, fix scrollbar
6853 *
6854 * @param {SweetAlertOptions} params
6855 */
6856 const openPopup = params => {
6857 var _globalState$eventEmi, _globalState$eventEmi2;
6858 const container = getContainer();
6859 const popup = getPopup();
6860 if (!container || !popup) {
6861 return;
6862 }
6863 if (typeof params.willOpen === 'function') {
6864 params.willOpen(popup);
6865 }
6866 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6867 const bodyStyles = window.getComputedStyle(document.body);
6868 const initialBodyOverflow = bodyStyles.overflowY;
6869 addClasses(container, popup, params);
6870
6871 // scrolling is 'hidden' until animation is done, after that 'auto'
6872 setTimeout(() => {
6873 setScrollingVisibility(container, popup);
6874 }, SHOW_CLASS_TIMEOUT);
6875 if (isModal()) {
6876 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6877 setAriaHidden();
6878 }
6879
6880 // https://github.com/sweetalert2/sweetalert2/issues/2923
6881 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
6882 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
6883 container.style.pointerEvents = 'auto';
6884 }
6885 if (!isToast() && !globalState.previousActiveElement) {
6886 globalState.previousActiveElement = document.activeElement;
6887 }
6888 if (typeof params.didOpen === 'function') {
6889 const didOpen = params.didOpen;
6890 setTimeout(() => didOpen(popup));
6891 }
6892 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6893 };
6894
6895 /**
6896 * @param {Event} event
6897 */
6898 const swalOpenAnimationFinished = event => {
6899 const popup = getPopup();
6900 if (!popup || event.target !== popup) {
6901 return;
6902 }
6903 const container = getContainer();
6904 if (!container) {
6905 return;
6906 }
6907 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6908 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6909 container.style.overflowY = 'auto';
6910
6911 // no-transition is added in init() in case one swal is opened right after another
6912 removeClass(container, swalClasses['no-transition']);
6913 };
6914
6915 /**
6916 * @param {HTMLElement} container
6917 * @param {HTMLElement} popup
6918 */
6919 const setScrollingVisibility = (container, popup) => {
6920 if (hasCssAnimation(popup)) {
6921 container.style.overflowY = 'hidden';
6922 popup.addEventListener('animationend', swalOpenAnimationFinished);
6923 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6924 } else {
6925 container.style.overflowY = 'auto';
6926 }
6927 };
6928
6929 /**
6930 * @param {HTMLElement} container
6931 * @param {boolean} scrollbarPadding
6932 * @param {string} initialBodyOverflow
6933 */
6934 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6935 iOSfix();
6936 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6937 replaceScrollbarWithPadding(initialBodyOverflow);
6938 }
6939
6940 // sweetalert2/issues/1247
6941 setTimeout(() => {
6942 container.scrollTop = 0;
6943 });
6944 };
6945
6946 /**
6947 * @param {HTMLElement} container
6948 * @param {HTMLElement} popup
6949 * @param {SweetAlertOptions} params
6950 */
6951 const addClasses = (container, popup, params) => {
6952 var _params$showClass;
6953 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6954 addClass(container, params.showClass.backdrop);
6955 }
6956 if (params.animation) {
6957 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6958 popup.style.setProperty('opacity', '0', 'important');
6959 show(popup, 'grid');
6960 setTimeout(() => {
6961 var _params$showClass2;
6962 // Animate popup right after showing it
6963 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6964 addClass(popup, params.showClass.popup);
6965 }
6966 // and remove the opacity workaround
6967 popup.style.removeProperty('opacity');
6968 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6969 } else {
6970 show(popup, 'grid');
6971 }
6972 addClass([document.documentElement, document.body], swalClasses.shown);
6973 if (params.heightAuto && params.backdrop && !params.toast) {
6974 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6975 }
6976 };
6977
6978 var defaultInputValidators = {
6979 /**
6980 * @param {string} string
6981 * @param {string} [validationMessage]
6982 * @returns {Promise<string | void>}
6983 */
6984 email: (string, validationMessage) => {
6985 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6986 },
6987 /**
6988 * @param {string} string
6989 * @param {string} [validationMessage]
6990 * @returns {Promise<string | void>}
6991 */
6992 url: (string, validationMessage) => {
6993 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6994 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');
6995 }
6996 };
6997
6998 /**
6999 * @param {SweetAlertOptions} params
7000 */
7001 function setDefaultInputValidators(params) {
7002 // Use default `inputValidator` for supported input types if not provided
7003 if (params.inputValidator) {
7004 return;
7005 }
7006 if (params.input === 'email') {
7007 params.inputValidator = defaultInputValidators['email'];
7008 }
7009 if (params.input === 'url') {
7010 params.inputValidator = defaultInputValidators['url'];
7011 }
7012 }
7013
7014 /**
7015 * @param {SweetAlertOptions} params
7016 */
7017 function validateCustomTargetElement(params) {
7018 // Determine if the custom target element is valid
7019 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
7020 warn('Target parameter is not valid, defaulting to "body"');
7021 params.target = 'body';
7022 }
7023 }
7024
7025 /**
7026 * Set type, text and actions on popup
7027 *
7028 * @param {SweetAlertOptions} params
7029 */
7030 function setParameters(params) {
7031 setDefaultInputValidators(params);
7032
7033 // showLoaderOnConfirm && preConfirm
7034 if (params.showLoaderOnConfirm && !params.preConfirm) {
7035 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');
7036 }
7037 validateCustomTargetElement(params);
7038
7039 // Replace newlines with <br> in title
7040 if (typeof params.title === 'string') {
7041 params.title = params.title.split('\n').join('<br />');
7042 }
7043 init(params);
7044 }
7045
7046 /** @type {SweetAlert} */
7047 let currentInstance;
7048 var _promise = /*#__PURE__*/new WeakMap();
7049 class SweetAlert {
7050 /**
7051 * @param {...(SweetAlertOptions | string)} args
7052 * @this {SweetAlert}
7053 */
7054 constructor(...args) {
7055 /**
7056 * @type {Promise<SweetAlertResult>}
7057 */
7058 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
7059 Promise.resolve({
7060 isConfirmed: false,
7061 isDenied: false,
7062 isDismissed: true
7063 }));
7064 // Prevent run in Node env
7065 if (typeof window === 'undefined') {
7066 return;
7067 }
7068 currentInstance = this;
7069
7070 // @ts-ignore
7071 const outerParams = Object.freeze(this.constructor.argsToParams(args));
7072
7073 /** @type {Readonly<SweetAlertOptions>} */
7074 this.params = outerParams;
7075
7076 /** @type {boolean} */
7077 this.isAwaitingPromise = false;
7078 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
7079 }
7080
7081 /**
7082 * @param {any} userParams
7083 * @param {any} mixinParams
7084 */
7085 _main(userParams, mixinParams = {}) {
7086 showWarningsForParams(Object.assign({}, mixinParams, userParams));
7087 if (globalState.currentInstance) {
7088 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
7089 const {
7090 isAwaitingPromise
7091 } = globalState.currentInstance;
7092 globalState.currentInstance._destroy();
7093 if (!isAwaitingPromise) {
7094 swalPromiseResolve({
7095 isDismissed: true
7096 });
7097 }
7098 if (isModal()) {
7099 unsetAriaHidden();
7100 }
7101 }
7102 globalState.currentInstance = currentInstance;
7103 const innerParams = prepareParams(userParams, mixinParams);
7104 setParameters(innerParams);
7105 Object.freeze(innerParams);
7106
7107 // clear the previous timer
7108 if (globalState.timeout) {
7109 globalState.timeout.stop();
7110 delete globalState.timeout;
7111 }
7112
7113 // clear the restore focus timeout
7114 clearTimeout(globalState.restoreFocusTimeout);
7115 const domCache = populateDomCache(currentInstance);
7116 render(currentInstance, innerParams);
7117 privateProps.innerParams.set(currentInstance, innerParams);
7118 return swalPromise(currentInstance, domCache, innerParams);
7119 }
7120
7121 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
7122 /**
7123 * @param {any} onFulfilled
7124 */
7125 // oxlint-disable-next-line unicorn/no-thenable
7126 then(onFulfilled) {
7127 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
7128 }
7129
7130 /**
7131 * @param {any} onFinally
7132 */
7133 finally(onFinally) {
7134 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
7135 }
7136 }
7137
7138 /**
7139 * @param {SweetAlert} instance
7140 * @param {DomCache} domCache
7141 * @param {SweetAlertOptions} innerParams
7142 * @returns {Promise<SweetAlertResult>}
7143 */
7144 const swalPromise = (instance, domCache, innerParams) => {
7145 return new Promise((resolve, reject) => {
7146 // functions to handle all closings/dismissals
7147 /**
7148 * @param {DismissReason} dismiss
7149 */
7150 const dismissWith = dismiss => {
7151 instance.close({
7152 isDismissed: true,
7153 dismiss,
7154 isConfirmed: false,
7155 isDenied: false
7156 });
7157 };
7158 privateMethods.swalPromiseResolve.set(instance, resolve);
7159 privateMethods.swalPromiseReject.set(instance, reject);
7160 domCache.confirmButton.onclick = () => {
7161 handleConfirmButtonClick(instance);
7162 };
7163 domCache.denyButton.onclick = () => {
7164 handleDenyButtonClick(instance);
7165 };
7166 domCache.cancelButton.onclick = () => {
7167 handleCancelButtonClick(instance, dismissWith);
7168 };
7169 domCache.closeButton.onclick = () => {
7170 dismissWith(DismissReason.close);
7171 };
7172 handlePopupClick(innerParams, domCache, dismissWith);
7173 addKeydownHandler(globalState, innerParams, dismissWith);
7174 handleInputOptionsAndValue(instance, innerParams);
7175 openPopup(innerParams);
7176 setupTimer(globalState, innerParams, dismissWith);
7177 initFocus(domCache, innerParams);
7178
7179 // Scroll container to top on open (#1247, #1946)
7180 setTimeout(() => {
7181 domCache.container.scrollTop = 0;
7182 });
7183 });
7184 };
7185
7186 /**
7187 * @param {SweetAlertOptions} userParams
7188 * @param {SweetAlertOptions} mixinParams
7189 * @returns {SweetAlertOptions}
7190 */
7191 const prepareParams = (userParams, mixinParams) => {
7192 const templateParams = getTemplateParams(userParams);
7193 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
7194 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
7195 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
7196 if (params.animation === false) {
7197 params.showClass = {
7198 backdrop: 'swal2-noanimation'
7199 };
7200 params.hideClass = {};
7201 }
7202 return params;
7203 };
7204
7205 /**
7206 * @param {SweetAlert} instance
7207 * @returns {DomCache}
7208 */
7209 const populateDomCache = instance => {
7210 const domCache = /** @type {DomCache} */{
7211 popup: (/** @type {HTMLElement} */getPopup()),
7212 container: (/** @type {HTMLElement} */getContainer()),
7213 actions: (/** @type {HTMLElement} */getActions()),
7214 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
7215 denyButton: (/** @type {HTMLElement} */getDenyButton()),
7216 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
7217 loader: (/** @type {HTMLElement} */getLoader()),
7218 closeButton: (/** @type {HTMLElement} */getCloseButton()),
7219 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
7220 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
7221 };
7222 privateProps.domCache.set(instance, domCache);
7223 return domCache;
7224 };
7225
7226 /**
7227 * @param {GlobalState} globalState
7228 * @param {SweetAlertOptions} innerParams
7229 * @param {(dismiss: DismissReason) => void} dismissWith
7230 */
7231 const setupTimer = (globalState, innerParams, dismissWith) => {
7232 const timerProgressBar = getTimerProgressBar();
7233 hide(timerProgressBar);
7234 if (innerParams.timer) {
7235 globalState.timeout = new Timer(() => {
7236 dismissWith('timer');
7237 delete globalState.timeout;
7238 }, innerParams.timer);
7239 if (innerParams.timerProgressBar && timerProgressBar) {
7240 show(timerProgressBar);
7241 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
7242 setTimeout(() => {
7243 if (globalState.timeout && globalState.timeout.running) {
7244 // timer can be already stopped or unset at this point
7245 animateTimerProgressBar(/** @type {number} */innerParams.timer);
7246 }
7247 });
7248 }
7249 }
7250 };
7251
7252 /**
7253 * Initialize focus in the popup:
7254 *
7255 * 1. If `toast` is `true`, don't steal focus from the document.
7256 * 2. Else if there is an [autofocus] element, focus it.
7257 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
7258 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
7259 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
7260 * 6. Else focus the first focusable element in a popup (if any).
7261 *
7262 * @param {DomCache} domCache
7263 * @param {SweetAlertOptions} innerParams
7264 */
7265 const initFocus = (domCache, innerParams) => {
7266 if (innerParams.toast) {
7267 return;
7268 }
7269 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
7270 if (!callIfFunction(innerParams.allowEnterKey)) {
7271 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
7272 domCache.popup.focus();
7273 return;
7274 }
7275 if (focusAutofocus(domCache)) {
7276 return;
7277 }
7278 if (focusButton(domCache, innerParams)) {
7279 return;
7280 }
7281 setFocus(-1, 1);
7282 };
7283
7284 /**
7285 * @param {DomCache} domCache
7286 * @returns {boolean}
7287 */
7288 const focusAutofocus = domCache => {
7289 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
7290 for (const autofocusElement of autofocusElements) {
7291 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
7292 autofocusElement.focus();
7293 return true;
7294 }
7295 }
7296 return false;
7297 };
7298
7299 /**
7300 * @param {DomCache} domCache
7301 * @param {SweetAlertOptions} innerParams
7302 * @returns {boolean}
7303 */
7304 const focusButton = (domCache, innerParams) => {
7305 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
7306 domCache.denyButton.focus();
7307 return true;
7308 }
7309 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
7310 domCache.cancelButton.focus();
7311 return true;
7312 }
7313 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
7314 domCache.confirmButton.focus();
7315 return true;
7316 }
7317 return false;
7318 };
7319
7320 // Assign instance methods from src/instanceMethods/*.js to prototype
7321 SweetAlert.prototype.disableButtons = disableButtons;
7322 SweetAlert.prototype.enableButtons = enableButtons;
7323 SweetAlert.prototype.getInput = getInput;
7324 SweetAlert.prototype.disableInput = disableInput;
7325 SweetAlert.prototype.enableInput = enableInput;
7326 SweetAlert.prototype.hideLoading = hideLoading;
7327 SweetAlert.prototype.disableLoading = hideLoading;
7328 SweetAlert.prototype.showValidationMessage = showValidationMessage;
7329 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
7330 SweetAlert.prototype.close = close;
7331 SweetAlert.prototype.closePopup = close;
7332 SweetAlert.prototype.closeModal = close;
7333 SweetAlert.prototype.closeToast = close;
7334 SweetAlert.prototype.rejectPromise = rejectPromise;
7335 SweetAlert.prototype.update = update;
7336 SweetAlert.prototype._destroy = _destroy;
7337
7338 // Assign static methods from src/staticMethods/*.js to constructor
7339 Object.assign(SweetAlert, staticMethods);
7340
7341 // Proxy to instance methods to constructor, for now, for backwards compatibility
7342 Object.keys(instanceMethods).forEach(key => {
7343 /**
7344 * @param {...(SweetAlertOptions | string | undefined)} args
7345 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
7346 */
7347 // @ts-ignore: Dynamic property assignment for backwards compatibility
7348 SweetAlert[key] = function (...args) {
7349 // @ts-ignore
7350 if (currentInstance && currentInstance[key]) {
7351 // @ts-ignore
7352 return currentInstance[key](...args);
7353 }
7354 return undefined;
7355 };
7356 });
7357 SweetAlert.DismissReason = DismissReason;
7358 SweetAlert.version = '11.26.25';
7359
7360 const Swal = SweetAlert;
7361 // @ts-ignore
7362 Swal.default = Swal;
7363
7364 return Swal;
7365
7366 }));
7367 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
7368 "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}}");
7369
7370 /***/ },
7371
7372 /***/ "./node_modules/toastify-js/src/toastify.js"
7373 /*!**************************************************!*\
7374 !*** ./node_modules/toastify-js/src/toastify.js ***!
7375 \**************************************************/
7376 (module) {
7377
7378 /*!
7379 * Toastify js 1.12.0
7380 * https://github.com/apvarun/toastify-js
7381 * @license MIT licensed
7382 *
7383 * Copyright (C) 2018 Varun A P
7384 */
7385 (function(root, factory) {
7386 if ( true && module.exports) {
7387 module.exports = factory();
7388 } else {
7389 root.Toastify = factory();
7390 }
7391 })(this, function(global) {
7392 // Object initialization
7393 var Toastify = function(options) {
7394 // Returning a new init object
7395 return new Toastify.lib.init(options);
7396 },
7397 // Library version
7398 version = "1.12.0";
7399
7400 // Set the default global options
7401 Toastify.defaults = {
7402 oldestFirst: true,
7403 text: "Toastify is awesome!",
7404 node: undefined,
7405 duration: 3000,
7406 selector: undefined,
7407 callback: function () {
7408 },
7409 destination: undefined,
7410 newWindow: false,
7411 close: false,
7412 gravity: "toastify-top",
7413 positionLeft: false,
7414 position: '',
7415 backgroundColor: '',
7416 avatar: "",
7417 className: "",
7418 stopOnFocus: true,
7419 onClick: function () {
7420 },
7421 offset: {x: 0, y: 0},
7422 escapeMarkup: true,
7423 ariaLive: 'polite',
7424 style: {background: ''}
7425 };
7426
7427 // Defining the prototype of the object
7428 Toastify.lib = Toastify.prototype = {
7429 toastify: version,
7430
7431 constructor: Toastify,
7432
7433 // Initializing the object with required parameters
7434 init: function(options) {
7435 // Verifying and validating the input object
7436 if (!options) {
7437 options = {};
7438 }
7439
7440 // Creating the options object
7441 this.options = {};
7442
7443 this.toastElement = null;
7444
7445 // Validating the options
7446 this.options.text = options.text || Toastify.defaults.text; // Display message
7447 this.options.node = options.node || Toastify.defaults.node; // Display content as node
7448 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
7449 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
7450 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
7451 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
7452 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
7453 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
7454 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
7455 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
7456 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
7457 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
7458 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
7459 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
7460 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
7461 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
7462 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
7463 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
7464 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
7465 this.options.style = options.style || Toastify.defaults.style;
7466 if(options.backgroundColor) {
7467 this.options.style.background = options.backgroundColor;
7468 }
7469
7470 // Returning the current object for chaining functions
7471 return this;
7472 },
7473
7474 // Building the DOM element
7475 buildToast: function() {
7476 // Validating if the options are defined
7477 if (!this.options) {
7478 throw "Toastify is not initialized";
7479 }
7480
7481 // Creating the DOM object
7482 var divElement = document.createElement("div");
7483 divElement.className = "toastify on " + this.options.className;
7484
7485 // Positioning toast to left or right or center
7486 if (!!this.options.position) {
7487 divElement.className += " toastify-" + this.options.position;
7488 } else {
7489 // To be depreciated in further versions
7490 if (this.options.positionLeft === true) {
7491 divElement.className += " toastify-left";
7492 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
7493 } else {
7494 // Default position
7495 divElement.className += " toastify-right";
7496 }
7497 }
7498
7499 // Assigning gravity of element
7500 divElement.className += " " + this.options.gravity;
7501
7502 if (this.options.backgroundColor) {
7503 // This is being deprecated in favor of using the style HTML DOM property
7504 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
7505 }
7506
7507 // Loop through our style object and apply styles to divElement
7508 for (var property in this.options.style) {
7509 divElement.style[property] = this.options.style[property];
7510 }
7511
7512 // Announce the toast to screen readers
7513 if (this.options.ariaLive) {
7514 divElement.setAttribute('aria-live', this.options.ariaLive)
7515 }
7516
7517 // Adding the toast message/node
7518 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
7519 // If we have a valid node, we insert it
7520 divElement.appendChild(this.options.node)
7521 } else {
7522 if (this.options.escapeMarkup) {
7523 divElement.innerText = this.options.text;
7524 } else {
7525 divElement.innerHTML = this.options.text;
7526 }
7527
7528 if (this.options.avatar !== "") {
7529 var avatarElement = document.createElement("img");
7530 avatarElement.src = this.options.avatar;
7531
7532 avatarElement.className = "toastify-avatar";
7533
7534 if (this.options.position == "left" || this.options.positionLeft === true) {
7535 // Adding close icon on the left of content
7536 divElement.appendChild(avatarElement);
7537 } else {
7538 // Adding close icon on the right of content
7539 divElement.insertAdjacentElement("afterbegin", avatarElement);
7540 }
7541 }
7542 }
7543
7544 // Adding a close icon to the toast
7545 if (this.options.close === true) {
7546 // Create a span for close element
7547 var closeElement = document.createElement("button");
7548 closeElement.type = "button";
7549 closeElement.setAttribute("aria-label", "Close");
7550 closeElement.className = "toast-close";
7551 closeElement.innerHTML = "&#10006;";
7552
7553 // Triggering the removal of toast from DOM on close click
7554 closeElement.addEventListener(
7555 "click",
7556 function(event) {
7557 event.stopPropagation();
7558 this.removeElement(this.toastElement);
7559 window.clearTimeout(this.toastElement.timeOutValue);
7560 }.bind(this)
7561 );
7562
7563 //Calculating screen width
7564 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7565
7566 // Adding the close icon to the toast element
7567 // Display on the right if screen width is less than or equal to 360px
7568 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7569 // Adding close icon on the left of content
7570 divElement.insertAdjacentElement("afterbegin", closeElement);
7571 } else {
7572 // Adding close icon on the right of content
7573 divElement.appendChild(closeElement);
7574 }
7575 }
7576
7577 // Clear timeout while toast is focused
7578 if (this.options.stopOnFocus && this.options.duration > 0) {
7579 var self = this;
7580 // stop countdown
7581 divElement.addEventListener(
7582 "mouseover",
7583 function(event) {
7584 window.clearTimeout(divElement.timeOutValue);
7585 }
7586 )
7587 // add back the timeout
7588 divElement.addEventListener(
7589 "mouseleave",
7590 function() {
7591 divElement.timeOutValue = window.setTimeout(
7592 function() {
7593 // Remove the toast from DOM
7594 self.removeElement(divElement);
7595 },
7596 self.options.duration
7597 )
7598 }
7599 )
7600 }
7601
7602 // Adding an on-click destination path
7603 if (typeof this.options.destination !== "undefined") {
7604 divElement.addEventListener(
7605 "click",
7606 function(event) {
7607 event.stopPropagation();
7608 if (this.options.newWindow === true) {
7609 window.open(this.options.destination, "_blank");
7610 } else {
7611 window.location = this.options.destination;
7612 }
7613 }.bind(this)
7614 );
7615 }
7616
7617 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7618 divElement.addEventListener(
7619 "click",
7620 function(event) {
7621 event.stopPropagation();
7622 this.options.onClick();
7623 }.bind(this)
7624 );
7625 }
7626
7627 // Adding offset
7628 if(typeof this.options.offset === "object") {
7629
7630 var x = getAxisOffsetAValue("x", this.options);
7631 var y = getAxisOffsetAValue("y", this.options);
7632
7633 var xOffset = this.options.position == "left" ? x : "-" + x;
7634 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7635
7636 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7637
7638 }
7639
7640 // Returning the generated element
7641 return divElement;
7642 },
7643
7644 // Displaying the toast
7645 showToast: function() {
7646 // Creating the DOM object for the toast
7647 this.toastElement = this.buildToast();
7648
7649 // Getting the root element to with the toast needs to be added
7650 var rootElement;
7651 if (typeof this.options.selector === "string") {
7652 rootElement = document.getElementById(this.options.selector);
7653 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7654 rootElement = this.options.selector;
7655 } else {
7656 rootElement = document.body;
7657 }
7658
7659 // Validating if root element is present in DOM
7660 if (!rootElement) {
7661 throw "Root element is not defined";
7662 }
7663
7664 // Adding the DOM element
7665 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7666 rootElement.insertBefore(this.toastElement, elementToInsert);
7667
7668 // Repositioning the toasts in case multiple toasts are present
7669 Toastify.reposition();
7670
7671 if (this.options.duration > 0) {
7672 this.toastElement.timeOutValue = window.setTimeout(
7673 function() {
7674 // Remove the toast from DOM
7675 this.removeElement(this.toastElement);
7676 }.bind(this),
7677 this.options.duration
7678 ); // Binding `this` for function invocation
7679 }
7680
7681 // Supporting function chaining
7682 return this;
7683 },
7684
7685 hideToast: function() {
7686 if (this.toastElement.timeOutValue) {
7687 clearTimeout(this.toastElement.timeOutValue);
7688 }
7689 this.removeElement(this.toastElement);
7690 },
7691
7692 // Removing the element from the DOM
7693 removeElement: function(toastElement) {
7694 // Hiding the element
7695 // toastElement.classList.remove("on");
7696 toastElement.className = toastElement.className.replace(" on", "");
7697
7698 // Removing the element from DOM after transition end
7699 window.setTimeout(
7700 function() {
7701 // remove options node if any
7702 if (this.options.node && this.options.node.parentNode) {
7703 this.options.node.parentNode.removeChild(this.options.node);
7704 }
7705
7706 // Remove the element from the DOM, only when the parent node was not removed before.
7707 if (toastElement.parentNode) {
7708 toastElement.parentNode.removeChild(toastElement);
7709 }
7710
7711 // Calling the callback function
7712 this.options.callback.call(toastElement);
7713
7714 // Repositioning the toasts again
7715 Toastify.reposition();
7716 }.bind(this),
7717 400
7718 ); // Binding `this` for function invocation
7719 },
7720 };
7721
7722 // Positioning the toasts on the DOM
7723 Toastify.reposition = function() {
7724
7725 // Top margins with gravity
7726 var topLeftOffsetSize = {
7727 top: 15,
7728 bottom: 15,
7729 };
7730 var topRightOffsetSize = {
7731 top: 15,
7732 bottom: 15,
7733 };
7734 var offsetSize = {
7735 top: 15,
7736 bottom: 15,
7737 };
7738
7739 // Get all toast messages on the DOM
7740 var allToasts = document.getElementsByClassName("toastify");
7741
7742 var classUsed;
7743
7744 // Modifying the position of each toast element
7745 for (var i = 0; i < allToasts.length; i++) {
7746 // Getting the applied gravity
7747 if (containsClass(allToasts[i], "toastify-top") === true) {
7748 classUsed = "toastify-top";
7749 } else {
7750 classUsed = "toastify-bottom";
7751 }
7752
7753 var height = allToasts[i].offsetHeight;
7754 classUsed = classUsed.substr(9, classUsed.length-1)
7755 // Spacing between toasts
7756 var offset = 15;
7757
7758 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7759
7760 // Show toast in center if screen with less than or equal to 360px
7761 if (width <= 360) {
7762 // Setting the position
7763 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7764
7765 offsetSize[classUsed] += height + offset;
7766 } else {
7767 if (containsClass(allToasts[i], "toastify-left") === true) {
7768 // Setting the position
7769 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7770
7771 topLeftOffsetSize[classUsed] += height + offset;
7772 } else {
7773 // Setting the position
7774 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7775
7776 topRightOffsetSize[classUsed] += height + offset;
7777 }
7778 }
7779 }
7780
7781 // Supporting function chaining
7782 return this;
7783 };
7784
7785 // Helper function to get offset.
7786 function getAxisOffsetAValue(axis, options) {
7787
7788 if(options.offset[axis]) {
7789 if(isNaN(options.offset[axis])) {
7790 return options.offset[axis];
7791 }
7792 else {
7793 return options.offset[axis] + 'px';
7794 }
7795 }
7796
7797 return '0px';
7798
7799 }
7800
7801 function containsClass(elem, yourClass) {
7802 if (!elem || typeof yourClass !== "string") {
7803 return false;
7804 } else if (
7805 elem.className &&
7806 elem.className
7807 .trim()
7808 .split(/\s+/gi)
7809 .indexOf(yourClass) > -1
7810 ) {
7811 return true;
7812 } else {
7813 return false;
7814 }
7815 }
7816
7817 // Setting up the prototype for the init object
7818 Toastify.lib.init.prototype = Toastify.lib;
7819
7820 // Returning the Toastify function to be assigned to the window object/module
7821 return Toastify;
7822 });
7823
7824
7825 /***/ },
7826
7827 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7828 /*!**********************************************************!*\
7829 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7830 \**********************************************************/
7831 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7832
7833 "use strict";
7834 __webpack_require__.r(__webpack_exports__);
7835 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7836 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7837 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7838 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7839 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7840 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7841 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7842 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7843 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7844 /* harmony export */ });
7845 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7846 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7847 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7848 /**
7849 * sifter.js
7850 * Copyright (c) 2013–2020 Brian Reavis & contributors
7851 *
7852 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7853 * file except in compliance with the License. You may obtain a copy of the License at:
7854 * http://www.apache.org/licenses/LICENSE-2.0
7855 *
7856 * Unless required by applicable law or agreed to in writing, software distributed under
7857 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7858 * ANY KIND, either express or implied. See the License for the specific language
7859 * governing permissions and limitations under the License.
7860 *
7861 * @author Brian Reavis <[email protected]>
7862 */
7863
7864
7865 class Sifter {
7866 items; // []|{};
7867 settings;
7868 /**
7869 * Textually searches arrays and hashes of objects
7870 * by property (or multiple properties). Designed
7871 * specifically for autocomplete.
7872 *
7873 */
7874 constructor(items, settings) {
7875 this.items = items;
7876 this.settings = settings || { diacritics: true };
7877 }
7878 ;
7879 /**
7880 * Splits a search string into an array of individual
7881 * regexps to be used to match results.
7882 *
7883 */
7884 tokenize(query, respect_word_boundaries, weights) {
7885 if (!query || !query.length)
7886 return [];
7887 const tokens = [];
7888 const words = query.split(/\s+/);
7889 var field_regex;
7890 if (weights) {
7891 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7892 }
7893 words.forEach((word) => {
7894 let field_match;
7895 let field = null;
7896 let regex = null;
7897 // look for "field:query" tokens
7898 if (field_regex && (field_match = word.match(field_regex))) {
7899 field = field_match[1];
7900 word = field_match[2];
7901 }
7902 if (word.length > 0) {
7903 if (this.settings.diacritics) {
7904 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7905 }
7906 else {
7907 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7908 }
7909 if (regex && respect_word_boundaries)
7910 regex = "\\b" + regex;
7911 }
7912 tokens.push({
7913 string: word,
7914 regex: regex ? new RegExp(regex, 'iu') : null,
7915 field: field,
7916 });
7917 });
7918 return tokens;
7919 }
7920 ;
7921 /**
7922 * Returns a function to be used to score individual results.
7923 *
7924 * Good matches will have a higher score than poor matches.
7925 * If an item is not a match, 0 will be returned by the function.
7926 *
7927 * @returns {T.ScoreFn}
7928 */
7929 getScoreFunction(query, options) {
7930 var search = this.prepareSearch(query, options);
7931 return this._getScoreFunction(search);
7932 }
7933 /**
7934 * @returns {T.ScoreFn}
7935 *
7936 */
7937 _getScoreFunction(search) {
7938 const tokens = search.tokens, token_count = tokens.length;
7939 if (!token_count) {
7940 return function () { return 0; };
7941 }
7942 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7943 if (!field_count) {
7944 return function () { return 1; };
7945 }
7946 /**
7947 * Calculates the score of an object
7948 * against the search query.
7949 *
7950 */
7951 const scoreObject = (function () {
7952 if (field_count === 1) {
7953 return function (token, data) {
7954 const field = fields[0].field;
7955 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7956 };
7957 }
7958 return function (token, data) {
7959 var sum = 0;
7960 // is the token specific to a field?
7961 if (token.field) {
7962 const value = getAttrFn(data, token.field);
7963 if (!token.regex && value) {
7964 sum += (1 / field_count);
7965 }
7966 else {
7967 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7968 }
7969 }
7970 else {
7971 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7972 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7973 });
7974 }
7975 return sum / field_count;
7976 };
7977 })();
7978 if (token_count === 1) {
7979 return function (data) {
7980 return scoreObject(tokens[0], data);
7981 };
7982 }
7983 if (search.options.conjunction === 'and') {
7984 return function (data) {
7985 var score, sum = 0;
7986 for (let token of tokens) {
7987 score = scoreObject(token, data);
7988 if (score <= 0)
7989 return 0;
7990 sum += score;
7991 }
7992 return sum / token_count;
7993 };
7994 }
7995 else {
7996 return function (data) {
7997 var sum = 0;
7998 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7999 sum += scoreObject(token, data);
8000 });
8001 return sum / token_count;
8002 };
8003 }
8004 }
8005 ;
8006 /**
8007 * Returns a function that can be used to compare two
8008 * results, for sorting purposes. If no sorting should
8009 * be performed, `null` will be returned.
8010 *
8011 * @return function(a,b)
8012 */
8013 getSortFunction(query, options) {
8014 var search = this.prepareSearch(query, options);
8015 return this._getSortFunction(search);
8016 }
8017 _getSortFunction(search) {
8018 var implicit_score, sort_flds = [];
8019 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
8020 if (typeof sort == 'function') {
8021 return sort.bind(this);
8022 }
8023 /**
8024 * Fetches the specified sort field value
8025 * from a search result item.
8026 *
8027 */
8028 const get_field = function (name, result) {
8029 if (name === '$score')
8030 return result.score;
8031 return search.getAttrFn(self.items[result.id], name);
8032 };
8033 // parse options
8034 if (sort) {
8035 for (let s of sort) {
8036 if (search.query || s.field !== '$score') {
8037 sort_flds.push(s);
8038 }
8039 }
8040 }
8041 // the "$score" field is implied to be the primary
8042 // sort field, unless it's manually specified
8043 if (search.query) {
8044 implicit_score = true;
8045 for (let fld of sort_flds) {
8046 if (fld.field === '$score') {
8047 implicit_score = false;
8048 break;
8049 }
8050 }
8051 if (implicit_score) {
8052 sort_flds.unshift({ field: '$score', direction: 'desc' });
8053 }
8054 // without a search.query, all items will have the same score
8055 }
8056 else {
8057 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
8058 }
8059 // build function
8060 const sort_flds_count = sort_flds.length;
8061 if (!sort_flds_count) {
8062 return null;
8063 }
8064 return function (a, b) {
8065 var result, field;
8066 for (let sort_fld of sort_flds) {
8067 field = sort_fld.field;
8068 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
8069 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
8070 if (result)
8071 return result;
8072 }
8073 return 0;
8074 };
8075 }
8076 ;
8077 /**
8078 * Parses a search query and returns an object
8079 * with tokens and fields ready to be populated
8080 * with results.
8081 *
8082 */
8083 prepareSearch(query, optsUser) {
8084 const weights = {};
8085 var options = Object.assign({}, optsUser);
8086 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
8087 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
8088 // convert fields to new format
8089 if (options.fields) {
8090 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
8091 const fields = [];
8092 options.fields.forEach((field) => {
8093 if (typeof field == 'string') {
8094 field = { field: field, weight: 1 };
8095 }
8096 fields.push(field);
8097 weights[field.field] = ('weight' in field) ? field.weight : 1;
8098 });
8099 options.fields = fields;
8100 }
8101 return {
8102 options: options,
8103 query: query.toLowerCase().trim(),
8104 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
8105 total: 0,
8106 items: [],
8107 weights: weights,
8108 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
8109 };
8110 }
8111 ;
8112 /**
8113 * Searches through all items and returns a sorted array of matches.
8114 *
8115 */
8116 search(query, options) {
8117 var self = this, score, search;
8118 search = this.prepareSearch(query, options);
8119 options = search.options;
8120 query = search.query;
8121 // generate result scoring function
8122 const fn_score = options.score || self._getScoreFunction(search);
8123 // perform search and sort
8124 if (query.length) {
8125 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
8126 score = fn_score(item);
8127 if (options.filter === false || score > 0) {
8128 search.items.push({ 'score': score, 'id': id });
8129 }
8130 });
8131 }
8132 else {
8133 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
8134 search.items.push({ 'score': 1, 'id': id });
8135 });
8136 }
8137 const fn_sort = self._getSortFunction(search);
8138 if (fn_sort)
8139 search.items.sort(fn_sort);
8140 // apply limits
8141 search.total = search.items.length;
8142 if (typeof options.limit === 'number') {
8143 search.items = search.items.slice(0, options.limit);
8144 }
8145 return search;
8146 }
8147 ;
8148 }
8149
8150
8151 //# sourceMappingURL=sifter.js.map
8152
8153 /***/ },
8154
8155 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
8156 /*!*********************************************************!*\
8157 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
8158 \*********************************************************/
8159 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8160
8161 "use strict";
8162 __webpack_require__.r(__webpack_exports__);
8163
8164 //# sourceMappingURL=types.js.map
8165
8166 /***/ },
8167
8168 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
8169 /*!*********************************************************!*\
8170 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
8171 \*********************************************************/
8172 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8173
8174 "use strict";
8175 __webpack_require__.r(__webpack_exports__);
8176 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8177 /* harmony export */ cmp: () => (/* binding */ cmp),
8178 /* harmony export */ getAttr: () => (/* binding */ getAttr),
8179 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
8180 /* harmony export */ iterate: () => (/* binding */ iterate),
8181 /* harmony export */ propToArray: () => (/* binding */ propToArray),
8182 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
8183 /* harmony export */ });
8184 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
8185
8186 /**
8187 * A property getter resolving dot-notation
8188 * @param {Object} obj The root object to fetch property on
8189 * @param {String} name The optionally dotted property name to fetch
8190 * @return {Object} The resolved property value
8191 */
8192 const getAttr = (obj, name) => {
8193 if (!obj)
8194 return;
8195 return obj[name];
8196 };
8197 /**
8198 * A property getter resolving dot-notation
8199 * @param {Object} obj The root object to fetch property on
8200 * @param {String} name The optionally dotted property name to fetch
8201 * @return {Object} The resolved property value
8202 */
8203 const getAttrNesting = (obj, name) => {
8204 if (!obj)
8205 return;
8206 var part, names = name.split(".");
8207 while ((part = names.shift()) && (obj = obj[part]))
8208 ;
8209 return obj;
8210 };
8211 /**
8212 * Calculates how close of a match the
8213 * given value is against a search token.
8214 *
8215 */
8216 const scoreValue = (value, token, weight) => {
8217 var score, pos;
8218 if (!value)
8219 return 0;
8220 value = value + '';
8221 if (token.regex == null)
8222 return 0;
8223 pos = value.search(token.regex);
8224 if (pos === -1)
8225 return 0;
8226 score = token.string.length / value.length;
8227 if (pos === 0)
8228 score += 0.5;
8229 return score * weight;
8230 };
8231 /**
8232 * Cast object property to an array if it exists and has a value
8233 *
8234 */
8235 const propToArray = (obj, key) => {
8236 var value = obj[key];
8237 if (typeof value == 'function')
8238 return value;
8239 if (value && !Array.isArray(value)) {
8240 obj[key] = [value];
8241 }
8242 };
8243 /**
8244 * Iterates over arrays and hashes.
8245 *
8246 * ```
8247 * iterate(this.items, function(item, id) {
8248 * // invoked for each item
8249 * });
8250 * ```
8251 *
8252 */
8253 const iterate = (object, callback) => {
8254 if (Array.isArray(object)) {
8255 object.forEach(callback);
8256 }
8257 else {
8258 for (var key in object) {
8259 if (object.hasOwnProperty(key)) {
8260 callback(object[key], key);
8261 }
8262 }
8263 }
8264 };
8265 const cmp = (a, b) => {
8266 if (typeof a === 'number' && typeof b === 'number') {
8267 return a > b ? 1 : (a < b ? -1 : 0);
8268 }
8269 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
8270 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
8271 if (a > b)
8272 return 1;
8273 if (b > a)
8274 return -1;
8275 return 0;
8276 };
8277 //# sourceMappingURL=utils.js.map
8278
8279 /***/ },
8280
8281 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
8282 /*!*******************************************************************!*\
8283 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
8284 \*******************************************************************/
8285 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8286
8287 "use strict";
8288 __webpack_require__.r(__webpack_exports__);
8289 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8290 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
8291 /* harmony export */ asciifold: () => (/* binding */ asciifold),
8292 /* harmony export */ code_points: () => (/* binding */ code_points),
8293 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
8294 /* harmony export */ generateMap: () => (/* binding */ generateMap),
8295 /* harmony export */ generateSets: () => (/* binding */ generateSets),
8296 /* harmony export */ generator: () => (/* binding */ generator),
8297 /* harmony export */ getPattern: () => (/* binding */ getPattern),
8298 /* harmony export */ initialize: () => (/* binding */ initialize),
8299 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
8300 /* harmony export */ normalize: () => (/* binding */ normalize),
8301 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
8302 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
8303 /* harmony export */ });
8304 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
8305 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
8306
8307
8308 const code_points = [[0, 65535]];
8309 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
8310 let unicode_map;
8311 let multi_char_reg;
8312 const max_char_length = 3;
8313 const latin_convert = {};
8314 const latin_condensed = {
8315 '/': '⁄∕',
8316 '0': '߀',
8317 "a": "ⱥɐɑ",
8318 "aa": "ꜳ",
8319 "ae": "æǽǣ",
8320 "ao": "ꜵ",
8321 "au": "ꜷ",
8322 "av": "ꜹꜻ",
8323 "ay": "ꜽ",
8324 "b": "ƀɓƃ",
8325 "c": "ꜿƈȼↄ",
8326 "d": "đɗɖᴅƌꮷԁɦ",
8327 "e": "ɛǝᴇɇ",
8328 "f": "ꝼƒ",
8329 "g": "ǥɠꞡᵹꝿɢ",
8330 "h": "ħⱨⱶɥ",
8331 "i": "ɨı",
8332 "j": "ɉȷ",
8333 "k": "ƙⱪꝁꝃꝅꞣ",
8334 "l": "łƚɫⱡꝉꝇꞁɭ",
8335 "m": "ɱɯϻ",
8336 "n": "ꞥƞɲꞑᴎлԉ",
8337 "o": "øǿɔɵꝋꝍᴑ",
8338 "oe": "œ",
8339 "oi": "ƣ",
8340 "oo": "ꝏ",
8341 "ou": "ȣ",
8342 "p": "ƥᵽꝑꝓꝕρ",
8343 "q": "ꝗꝙɋ",
8344 "r": "ɍɽꝛꞧꞃ",
8345 "s": "ßȿꞩꞅʂ",
8346 "t": "ŧƭʈⱦꞇ",
8347 "th": "þ",
8348 "tz": "ꜩ",
8349 "u": "ʉ",
8350 "v": "ʋꝟʌ",
8351 "vy": "ꝡ",
8352 "w": "ⱳ",
8353 "y": "ƴɏỿ",
8354 "z": "ƶȥɀⱬꝣ",
8355 "hv": "ƕ"
8356 };
8357 for (let latin in latin_condensed) {
8358 let unicode = latin_condensed[latin] || '';
8359 for (let i = 0; i < unicode.length; i++) {
8360 let char = unicode.substring(i, i + 1);
8361 latin_convert[char] = latin;
8362 }
8363 }
8364 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
8365 /**
8366 * Initialize the unicode_map from the give code point ranges
8367 */
8368 const initialize = (_code_points) => {
8369 if (unicode_map !== undefined)
8370 return;
8371 unicode_map = generateMap(_code_points || code_points);
8372 };
8373 /**
8374 * Helper method for normalize a string
8375 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
8376 */
8377 const normalize = (str, form = 'NFKD') => str.normalize(form);
8378 /**
8379 * Remove accents without reordering string
8380 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
8381 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
8382 */
8383 const asciifold = (str) => {
8384 return Array.from(str).reduce(
8385 /**
8386 * @param {string} result
8387 * @param {string} char
8388 */
8389 (result, char) => {
8390 return result + _asciifold(char);
8391 }, '');
8392 };
8393 const _asciifold = (str) => {
8394 str = normalize(str)
8395 .toLowerCase()
8396 .replace(convert_pat, (/** @type {string} */ char) => {
8397 return latin_convert[char] || '';
8398 });
8399 //return str;
8400 return normalize(str, 'NFC');
8401 };
8402 /**
8403 * Generate a list of unicode variants from the list of code points
8404 */
8405 function* generator(code_points) {
8406 for (const [code_point_min, code_point_max] of code_points) {
8407 for (let i = code_point_min; i <= code_point_max; i++) {
8408 let composed = String.fromCharCode(i);
8409 let folded = asciifold(composed);
8410 if (folded == composed.toLowerCase()) {
8411 continue;
8412 }
8413 // skip when folded is a string longer than 3 characters long
8414 // bc the resulting regex patterns will be long
8415 // eg:
8416 // folded صلى الله عليه وسلم length 18 code point 65018
8417 // folded جل جلاله length 8 code point 65019
8418 if (folded.length > max_char_length) {
8419 continue;
8420 }
8421 if (folded.length == 0) {
8422 continue;
8423 }
8424 yield { folded: folded, composed: composed, code_point: i };
8425 }
8426 }
8427 }
8428 /**
8429 * Generate a unicode map from the list of code points
8430 */
8431 const generateSets = (code_points) => {
8432 const unicode_sets = {};
8433 const addMatching = (folded, to_add) => {
8434 /** @type {Set<string>} */
8435 const folded_set = unicode_sets[folded] || new Set();
8436 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
8437 if (to_add.match(patt)) {
8438 return;
8439 }
8440 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
8441 unicode_sets[folded] = folded_set;
8442 };
8443 for (let value of generator(code_points)) {
8444 addMatching(value.folded, value.folded);
8445 addMatching(value.folded, value.composed);
8446 }
8447 return unicode_sets;
8448 };
8449 /**
8450 * Generate a unicode map from the list of code points
8451 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
8452 */
8453 const generateMap = (code_points) => {
8454 const unicode_sets = generateSets(code_points);
8455 const unicode_map = {};
8456 let multi_char = [];
8457 for (let folded in unicode_sets) {
8458 let set = unicode_sets[folded];
8459 if (set) {
8460 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
8461 }
8462 if (folded.length > 1) {
8463 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
8464 }
8465 }
8466 multi_char.sort((a, b) => b.length - a.length);
8467 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
8468 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
8469 return unicode_map;
8470 };
8471 /**
8472 * Map each element of an array from its folded value to all possible unicode matches
8473 */
8474 const mapSequence = (strings, min_replacement = 1) => {
8475 let chars_replaced = 0;
8476 strings = strings.map((str) => {
8477 if (unicode_map[str]) {
8478 chars_replaced += str.length;
8479 }
8480 return unicode_map[str] || str;
8481 });
8482 if (chars_replaced >= min_replacement) {
8483 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
8484 }
8485 return '';
8486 };
8487 /**
8488 * Convert a short string and split it into all possible patterns
8489 * Keep a pattern only if min_replacement is met
8490 *
8491 * 'abc'
8492 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
8493 * => ['abc-pattern','ab-c-pattern'...]
8494 */
8495 const substringsToPattern = (str, min_replacement = 1) => {
8496 min_replacement = Math.max(min_replacement, str.length - 1);
8497 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
8498 return mapSequence(sub_pat, min_replacement);
8499 }));
8500 };
8501 /**
8502 * Convert an array of sequences into a pattern
8503 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
8504 */
8505 const sequencesToPattern = (sequences, all = true) => {
8506 let min_replacement = sequences.length > 1 ? 1 : 0;
8507 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
8508 let seq = [];
8509 const len = all ? sequence.length() : sequence.length() - 1;
8510 for (let j = 0; j < len; j++) {
8511 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
8512 }
8513 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
8514 }));
8515 };
8516 /**
8517 * Return true if the sequence is already in the sequences
8518 */
8519 const inSequences = (needle_seq, sequences) => {
8520 for (const seq of sequences) {
8521 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
8522 continue;
8523 }
8524 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
8525 continue;
8526 }
8527 let needle_parts = needle_seq.parts;
8528 const filter = (part) => {
8529 for (const needle_part of needle_parts) {
8530 if (needle_part.start === part.start && needle_part.substr === part.substr) {
8531 return false;
8532 }
8533 if (part.length == 1 || needle_part.length == 1) {
8534 continue;
8535 }
8536 // check for overlapping parts
8537 // a = ['::=','==']
8538 // b = ['::','===']
8539 // a = ['r','sm']
8540 // b = ['rs','m']
8541 if (part.start < needle_part.start && part.end > needle_part.start) {
8542 return true;
8543 }
8544 if (needle_part.start < part.start && needle_part.end > part.start) {
8545 return true;
8546 }
8547 }
8548 return false;
8549 };
8550 let filtered = seq.parts.filter(filter);
8551 if (filtered.length > 0) {
8552 continue;
8553 }
8554 return true;
8555 }
8556 return false;
8557 };
8558 class Sequence {
8559 parts;
8560 substrs;
8561 start;
8562 end;
8563 constructor() {
8564 this.parts = [];
8565 this.substrs = [];
8566 this.start = 0;
8567 this.end = 0;
8568 }
8569 add(part) {
8570 if (part) {
8571 this.parts.push(part);
8572 this.substrs.push(part.substr);
8573 this.start = Math.min(part.start, this.start);
8574 this.end = Math.max(part.end, this.end);
8575 }
8576 }
8577 last() {
8578 return this.parts[this.parts.length - 1];
8579 }
8580 length() {
8581 return this.parts.length;
8582 }
8583 clone(position, last_piece) {
8584 let clone = new Sequence();
8585 let parts = JSON.parse(JSON.stringify(this.parts));
8586 let last_part = parts.pop();
8587 for (const part of parts) {
8588 clone.add(part);
8589 }
8590 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8591 let clone_last_len = last_substr.length;
8592 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8593 return clone;
8594 }
8595 }
8596 /**
8597 * Expand a regular expression pattern to include unicode variants
8598 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8599 *
8600 * Issue:
8601 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8602 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8603 *
8604 * İIJ = IIJ = ⅡJ
8605 *
8606 * 1/2/4
8607 */
8608 const getPattern = (str) => {
8609 initialize();
8610 str = asciifold(str);
8611 let pattern = '';
8612 let sequences = [new Sequence()];
8613 for (let i = 0; i < str.length; i++) {
8614 let substr = str.substring(i);
8615 let match = substr.match(multi_char_reg);
8616 const char = str.substring(i, i + 1);
8617 const match_str = match ? match[0] : null;
8618 // loop through sequences
8619 // add either the char or multi_match
8620 let overlapping = [];
8621 let added_types = new Set();
8622 for (const sequence of sequences) {
8623 const last_piece = sequence.last();
8624 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8625 // if we have a multi match
8626 if (match_str) {
8627 const len = match_str.length;
8628 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8629 added_types.add('1');
8630 }
8631 else {
8632 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8633 added_types.add('2');
8634 }
8635 }
8636 else if (match_str) {
8637 let clone = sequence.clone(i, last_piece);
8638 const len = match_str.length;
8639 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8640 overlapping.push(clone);
8641 }
8642 else {
8643 // don't add char
8644 // adding would create invalid patterns: 234 => [2,34,4]
8645 added_types.add('3');
8646 }
8647 }
8648 // if we have overlapping
8649 if (overlapping.length > 0) {
8650 // ['ii','iii'] before ['i','i','iii']
8651 overlapping = overlapping.sort((a, b) => {
8652 return a.length() - b.length();
8653 });
8654 for (let clone of overlapping) {
8655 // don't add if we already have an equivalent sequence
8656 if (inSequences(clone, sequences)) {
8657 continue;
8658 }
8659 sequences.push(clone);
8660 }
8661 continue;
8662 }
8663 // if we haven't done anything unique
8664 // clean up the patterns
8665 // helps keep patterns smaller
8666 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8667 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8668 pattern += sequencesToPattern(sequences, false);
8669 let new_seq = new Sequence();
8670 const old_seq = sequences[0];
8671 if (old_seq) {
8672 new_seq.add(old_seq.last());
8673 }
8674 sequences = [new_seq];
8675 }
8676 }
8677 pattern += sequencesToPattern(sequences, true);
8678 return pattern;
8679 };
8680
8681 //# sourceMappingURL=index.js.map
8682
8683 /***/ },
8684
8685 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8686 /*!*******************************************************************!*\
8687 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8688 \*******************************************************************/
8689 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8690
8691 "use strict";
8692 __webpack_require__.r(__webpack_exports__);
8693 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8694 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8695 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8696 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8697 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8698 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8699 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8700 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8701 /* harmony export */ });
8702 /**
8703 * Convert array of strings to a regular expression
8704 * ex ['ab','a'] => (?:ab|a)
8705 * ex ['a','b'] => [ab]
8706 */
8707 const arrayToPattern = (chars) => {
8708 chars = chars.filter(Boolean);
8709 if (chars.length < 2) {
8710 return chars[0] || '';
8711 }
8712 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8713 };
8714 const sequencePattern = (array) => {
8715 if (!hasDuplicates(array)) {
8716 return array.join('');
8717 }
8718 let pattern = '';
8719 let prev_char_count = 0;
8720 const prev_pattern = () => {
8721 if (prev_char_count > 1) {
8722 pattern += '{' + prev_char_count + '}';
8723 }
8724 };
8725 array.forEach((char, i) => {
8726 if (char === array[i - 1]) {
8727 prev_char_count++;
8728 return;
8729 }
8730 prev_pattern();
8731 pattern += char;
8732 prev_char_count = 1;
8733 });
8734 prev_pattern();
8735 return pattern;
8736 };
8737 /**
8738 * Convert array of strings to a regular expression
8739 * ex ['ab','a'] => (?:ab|a)
8740 * ex ['a','b'] => [ab]
8741 */
8742 const setToPattern = (chars) => {
8743 let array = Array.from(chars);
8744 return arrayToPattern(array);
8745 };
8746 /**
8747 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8748 */
8749 const hasDuplicates = (array) => {
8750 return (new Set(array)).size !== array.length;
8751 };
8752 /**
8753 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8754 */
8755 const escape_regex = (str) => {
8756 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8757 };
8758 /**
8759 * Return the max length of array values
8760 */
8761 const maxValueLength = (array) => {
8762 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8763 };
8764 const unicodeLength = (str) => {
8765 return Array.from(str).length;
8766 };
8767 //# sourceMappingURL=regex.js.map
8768
8769 /***/ },
8770
8771 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8772 /*!*********************************************************************!*\
8773 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8774 \*********************************************************************/
8775 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8776
8777 "use strict";
8778 __webpack_require__.r(__webpack_exports__);
8779 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8780 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8781 /* harmony export */ });
8782 /**
8783 * Get all possible combinations of substrings that add up to the given string
8784 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8785 */
8786 const allSubstrings = (input) => {
8787 if (input.length === 1)
8788 return [[input]];
8789 let result = [];
8790 const start = input.substring(1);
8791 const suba = allSubstrings(start);
8792 suba.forEach(function (subresult) {
8793 let tmp = subresult.slice(0);
8794 tmp[0] = input.charAt(0) + tmp[0];
8795 result.push(tmp);
8796 tmp = subresult.slice(0);
8797 tmp.unshift(input.charAt(0));
8798 result.push(tmp);
8799 });
8800 return result;
8801 };
8802 //# sourceMappingURL=strings.js.map
8803
8804 /***/ },
8805
8806 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8807 /*!*******************************************************!*\
8808 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8809 \*******************************************************/
8810 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8811
8812 "use strict";
8813 __webpack_require__.r(__webpack_exports__);
8814 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8815 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8816 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8817 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8818 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8819 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8820 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8821 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8822 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8823 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8824 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8825 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8826 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8827 /* harmony export */ });
8828 const KEY_A = 65;
8829 const KEY_RETURN = 13;
8830 const KEY_ESC = 27;
8831 const KEY_LEFT = 37;
8832 const KEY_UP = 38;
8833 const KEY_RIGHT = 39;
8834 const KEY_DOWN = 40;
8835 const KEY_BACKSPACE = 8;
8836 const KEY_DELETE = 46;
8837 const KEY_TAB = 9;
8838 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8839 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8840 //# sourceMappingURL=constants.js.map
8841
8842 /***/ },
8843
8844 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8845 /*!***************************************************************!*\
8846 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8847 \***************************************************************/
8848 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8849
8850 "use strict";
8851 __webpack_require__.r(__webpack_exports__);
8852 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8853 /* harmony export */ highlight: () => (/* binding */ highlight),
8854 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8855 /* harmony export */ });
8856 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8857 /**
8858 * highlight v3 | MIT license | Johann Burkard <[email protected]>
8859 * Highlights arbitrary terms in a node.
8860 *
8861 * - Modified by Marshal <[email protected]> 2011-6-24 (added regex)
8862 * - Modified by Brian Reavis <[email protected]> 2012-8-27 (cleanup)
8863 */
8864
8865 const highlight = (element, regex) => {
8866 if (regex === null)
8867 return;
8868 // convet string to regex
8869 if (typeof regex === 'string') {
8870 if (!regex.length)
8871 return;
8872 regex = new RegExp(regex, 'i');
8873 }
8874 // Wrap matching part of text node with highlighting <span>, e.g.
8875 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8876 const highlightText = (node) => {
8877 var match = node.data.match(regex);
8878 if (match && node.data.length > 0) {
8879 var spannode = document.createElement('span');
8880 spannode.className = 'highlight';
8881 var middlebit = node.splitText(match.index);
8882 middlebit.splitText(match[0].length);
8883 var middleclone = middlebit.cloneNode(true);
8884 spannode.appendChild(middleclone);
8885 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8886 return 1;
8887 }
8888 return 0;
8889 };
8890 // Recurse element node, looking for child text nodes to highlight, unless element
8891 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8892 const highlightChildren = (node) => {
8893 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8894 Array.from(node.childNodes).forEach(element => {
8895 highlightRecursive(element);
8896 });
8897 }
8898 };
8899 const highlightRecursive = (node) => {
8900 if (node.nodeType === 3) {
8901 return highlightText(node);
8902 }
8903 highlightChildren(node);
8904 return 0;
8905 };
8906 highlightRecursive(element);
8907 };
8908 /**
8909 * removeHighlight fn copied from highlight v5 and
8910 * edited to remove with(), pass js strict mode, and use without jquery
8911 */
8912 const removeHighlight = (el) => {
8913 var elements = el.querySelectorAll("span.highlight");
8914 Array.prototype.forEach.call(elements, function (el) {
8915 var parent = el.parentNode;
8916 parent.replaceChild(el.firstChild, el);
8917 parent.normalize();
8918 });
8919 };
8920 //# sourceMappingURL=highlight.js.map
8921
8922 /***/ },
8923
8924 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8925 /*!****************************************************************!*\
8926 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8927 \****************************************************************/
8928 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8929
8930 "use strict";
8931 __webpack_require__.r(__webpack_exports__);
8932 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8933 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8934 /* harmony export */ });
8935 /**
8936 * MicroEvent - to make any js object an event emitter
8937 *
8938 * - pure javascript - server compatible, browser compatible
8939 * - dont rely on the browser doms
8940 * - super simple - you get it immediatly, no mistery, no magic involved
8941 *
8942 * @author Jerome Etienne (https://github.com/jeromeetienne)
8943 */
8944 /**
8945 * Execute callback for each event in space separated list of event names
8946 *
8947 */
8948 function forEvents(events, callback) {
8949 events.split(/\s+/).forEach((event) => {
8950 callback(event);
8951 });
8952 }
8953 class MicroEvent {
8954 constructor() {
8955 this._events = {};
8956 }
8957 on(events, fct) {
8958 forEvents(events, (event) => {
8959 const event_array = this._events[event] || [];
8960 event_array.push(fct);
8961 this._events[event] = event_array;
8962 });
8963 }
8964 off(events, fct) {
8965 var n = arguments.length;
8966 if (n === 0) {
8967 this._events = {};
8968 return;
8969 }
8970 forEvents(events, (event) => {
8971 if (n === 1) {
8972 delete this._events[event];
8973 return;
8974 }
8975 const event_array = this._events[event];
8976 if (event_array === undefined)
8977 return;
8978 event_array.splice(event_array.indexOf(fct), 1);
8979 this._events[event] = event_array;
8980 });
8981 }
8982 trigger(events, ...args) {
8983 var self = this;
8984 forEvents(events, (event) => {
8985 const event_array = self._events[event];
8986 if (event_array === undefined)
8987 return;
8988 event_array.forEach(fct => {
8989 fct.apply(self, args);
8990 });
8991 });
8992 }
8993 }
8994 ;
8995 //# sourceMappingURL=microevent.js.map
8996
8997 /***/ },
8998
8999 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
9000 /*!*****************************************************************!*\
9001 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
9002 \*****************************************************************/
9003 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9004
9005 "use strict";
9006 __webpack_require__.r(__webpack_exports__);
9007 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9008 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
9009 /* harmony export */ });
9010 /**
9011 * microplugin.js
9012 * Copyright (c) 2013 Brian Reavis & contributors
9013 *
9014 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9015 * file except in compliance with the License. You may obtain a copy of the License at:
9016 * http://www.apache.org/licenses/LICENSE-2.0
9017 *
9018 * Unless required by applicable law or agreed to in writing, software distributed under
9019 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9020 * ANY KIND, either express or implied. See the License for the specific language
9021 * governing permissions and limitations under the License.
9022 *
9023 * @author Brian Reavis <[email protected]>
9024 */
9025 function MicroPlugin(Interface) {
9026 Interface.plugins = {};
9027 return class extends Interface {
9028 constructor() {
9029 super(...arguments);
9030 this.plugins = {
9031 names: [],
9032 settings: {},
9033 requested: {},
9034 loaded: {}
9035 };
9036 }
9037 /**
9038 * Registers a plugin.
9039 *
9040 * @param {function} fn
9041 */
9042 static define(name, fn) {
9043 Interface.plugins[name] = {
9044 'name': name,
9045 'fn': fn
9046 };
9047 }
9048 /**
9049 * Initializes the listed plugins (with options).
9050 * Acceptable formats:
9051 *
9052 * List (without options):
9053 * ['a', 'b', 'c']
9054 *
9055 * List (with options):
9056 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
9057 *
9058 * Hash (with options):
9059 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
9060 *
9061 * @param {array|object} plugins
9062 */
9063 initializePlugins(plugins) {
9064 var key, name;
9065 const self = this;
9066 const queue = [];
9067 if (Array.isArray(plugins)) {
9068 plugins.forEach((plugin) => {
9069 if (typeof plugin === 'string') {
9070 queue.push(plugin);
9071 }
9072 else {
9073 self.plugins.settings[plugin.name] = plugin.options;
9074 queue.push(plugin.name);
9075 }
9076 });
9077 }
9078 else if (plugins) {
9079 for (key in plugins) {
9080 if (plugins.hasOwnProperty(key)) {
9081 self.plugins.settings[key] = plugins[key];
9082 queue.push(key);
9083 }
9084 }
9085 }
9086 while (name = queue.shift()) {
9087 self.require(name);
9088 }
9089 }
9090 loadPlugin(name) {
9091 var self = this;
9092 var plugins = self.plugins;
9093 var plugin = Interface.plugins[name];
9094 if (!Interface.plugins.hasOwnProperty(name)) {
9095 throw new Error('Unable to find "' + name + '" plugin');
9096 }
9097 plugins.requested[name] = true;
9098 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
9099 plugins.names.push(name);
9100 }
9101 /**
9102 * Initializes a plugin.
9103 *
9104 */
9105 require(name) {
9106 var self = this;
9107 var plugins = self.plugins;
9108 if (!self.plugins.loaded.hasOwnProperty(name)) {
9109 if (plugins.requested[name]) {
9110 throw new Error('Plugin has circular dependency ("' + name + '")');
9111 }
9112 self.loadPlugin(name);
9113 }
9114 return plugins.loaded[name];
9115 }
9116 };
9117 }
9118 //# sourceMappingURL=microplugin.js.map
9119
9120 /***/ },
9121
9122 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
9123 /*!******************************************************!*\
9124 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
9125 \******************************************************/
9126 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9127
9128 "use strict";
9129 __webpack_require__.r(__webpack_exports__);
9130 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9131 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
9132 /* harmony export */ });
9133 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
9134 options: [],
9135 optgroups: [],
9136 plugins: [],
9137 delimiter: ',',
9138 splitOn: null, // regexp or string for splitting up values from a paste command
9139 persist: true,
9140 diacritics: true,
9141 create: null,
9142 createOnBlur: false,
9143 createFilter: null,
9144 clearAfterSelect: false,
9145 highlight: true,
9146 openOnFocus: true,
9147 shouldOpen: null,
9148 maxOptions: 50,
9149 maxItems: null,
9150 hideSelected: null,
9151 duplicates: false,
9152 addPrecedence: false,
9153 selectOnTab: false,
9154 preload: null,
9155 allowEmptyOption: false,
9156 //closeAfterSelect: false,
9157 refreshThrottle: 300,
9158 loadThrottle: 300,
9159 loadingClass: 'loading',
9160 dataAttr: null, //'data-data',
9161 optgroupField: 'optgroup',
9162 valueField: 'value',
9163 labelField: 'text',
9164 disabledField: 'disabled',
9165 optgroupLabelField: 'label',
9166 optgroupValueField: 'value',
9167 lockOptgroupOrder: false,
9168 sortField: '$order',
9169 searchField: ['text'],
9170 searchConjunction: 'and',
9171 mode: null,
9172 wrapperClass: 'ts-wrapper',
9173 controlClass: 'ts-control',
9174 dropdownClass: 'ts-dropdown',
9175 dropdownContentClass: 'ts-dropdown-content',
9176 itemClass: 'item',
9177 optionClass: 'option',
9178 dropdownParent: null,
9179 controlInput: '<input type="text" autocomplete="off" size="1" />',
9180 copyClassesToDropdown: false,
9181 placeholder: null,
9182 hidePlaceholder: null,
9183 shouldLoad: function (query) {
9184 return query.length > 0;
9185 },
9186 /*
9187 load : null, // function(query, callback) { ... }
9188 score : null, // function(search) { ... }
9189 onInitialize : null, // function() { ... }
9190 onChange : null, // function(value) { ... }
9191 onItemAdd : null, // function(value, $item) { ... }
9192 onItemRemove : null, // function(value) { ... }
9193 onClear : null, // function() { ... }
9194 onOptionAdd : null, // function(value, data) { ... }
9195 onOptionRemove : null, // function(value) { ... }
9196 onOptionClear : null, // function() { ... }
9197 onOptionGroupAdd : null, // function(id, data) { ... }
9198 onOptionGroupRemove : null, // function(id) { ... }
9199 onOptionGroupClear : null, // function() { ... }
9200 onDropdownOpen : null, // function(dropdown) { ... }
9201 onDropdownClose : null, // function(dropdown) { ... }
9202 onType : null, // function(str) { ... }
9203 onDelete : null, // function(values) { ... }
9204 */
9205 render: {
9206 /*
9207 item: null,
9208 optgroup: null,
9209 optgroup_header: null,
9210 option: null,
9211 option_create: null
9212 */
9213 }
9214 });
9215 //# sourceMappingURL=defaults.js.map
9216
9217 /***/ },
9218
9219 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
9220 /*!*********************************************************!*\
9221 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
9222 \*********************************************************/
9223 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9224
9225 "use strict";
9226 __webpack_require__.r(__webpack_exports__);
9227 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9228 /* harmony export */ "default": () => (/* binding */ getSettings)
9229 /* harmony export */ });
9230 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
9231 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
9232
9233
9234 function getSettings(input, settings_user) {
9235 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
9236 var attr_data = settings.dataAttr;
9237 var field_label = settings.labelField;
9238 var field_value = settings.valueField;
9239 var field_disabled = settings.disabledField;
9240 var field_optgroup = settings.optgroupField;
9241 var field_optgroup_label = settings.optgroupLabelField;
9242 var field_optgroup_value = settings.optgroupValueField;
9243 var tag_name = input.tagName.toLowerCase();
9244 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
9245 if (!placeholder && !settings.allowEmptyOption) {
9246 let option = input.querySelector('option[value=""]');
9247 if (option) {
9248 placeholder = option.textContent;
9249 }
9250 }
9251 var settings_element = {
9252 placeholder: placeholder,
9253 options: [],
9254 optgroups: [],
9255 items: [],
9256 maxItems: null,
9257 };
9258 /**
9259 * Initialize from a <select> element.
9260 *
9261 */
9262 var init_select = () => {
9263 var tagName;
9264 var options = settings_element.options;
9265 var optionsMap = {};
9266 var group_count = 1;
9267 let $order = 0;
9268 var readData = (el) => {
9269 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
9270 var json = attr_data && data[attr_data];
9271 if (typeof json === 'string' && json.length) {
9272 data = Object.assign(data, JSON.parse(json));
9273 }
9274 return data;
9275 };
9276 var addOption = (option, group) => {
9277 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
9278 if (value == null)
9279 return;
9280 if (!value && !settings.allowEmptyOption)
9281 return;
9282 // if the option already exists, it's probably been
9283 // duplicated in another optgroup. in this case, push
9284 // the current group to the "optgroup" property on the
9285 // existing option so that it's rendered in both places.
9286 if (optionsMap.hasOwnProperty(value)) {
9287 if (group) {
9288 var arr = optionsMap[value][field_optgroup];
9289 if (!arr) {
9290 optionsMap[value][field_optgroup] = group;
9291 }
9292 else if (!Array.isArray(arr)) {
9293 optionsMap[value][field_optgroup] = [arr, group];
9294 }
9295 else {
9296 arr.push(group);
9297 }
9298 }
9299 }
9300 else {
9301 var option_data = readData(option);
9302 option_data[field_label] = option_data[field_label] || option.textContent;
9303 option_data[field_value] = option_data[field_value] || value;
9304 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
9305 option_data[field_optgroup] = option_data[field_optgroup] || group;
9306 option_data.$option = option;
9307 option_data.$order = option_data.$order || ++$order;
9308 optionsMap[value] = option_data;
9309 options.push(option_data);
9310 }
9311 if (option.selected) {
9312 settings_element.items.push(value);
9313 }
9314 };
9315 var addGroup = (optgroup) => {
9316 var id, optgroup_data;
9317 optgroup_data = readData(optgroup);
9318 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
9319 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
9320 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
9321 optgroup_data.$order = optgroup_data.$order || ++$order;
9322 settings_element.optgroups.push(optgroup_data);
9323 id = optgroup_data[field_optgroup_value];
9324 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
9325 addOption(option, id);
9326 });
9327 };
9328 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
9329 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
9330 tagName = child.tagName.toLowerCase();
9331 if (tagName === 'optgroup') {
9332 addGroup(child);
9333 }
9334 else if (tagName === 'option') {
9335 addOption(child);
9336 }
9337 });
9338 };
9339 /**
9340 * Initialize from a <input type="text"> element.
9341 *
9342 */
9343 var init_textbox = () => {
9344 var _a, _b;
9345 const data_raw = input.getAttribute(attr_data);
9346 if (!data_raw) {
9347 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 : '';
9348 if (!settings.allowEmptyOption && !value.length)
9349 return;
9350 const values = value.split(settings.delimiter);
9351 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
9352 const option = {};
9353 option[field_label] = value;
9354 option[field_value] = value;
9355 settings_element.options.push(option);
9356 });
9357 settings_element.items = values;
9358 }
9359 else {
9360 settings_element.options = JSON.parse(data_raw);
9361 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
9362 settings_element.items.push(opt[field_value]);
9363 });
9364 }
9365 };
9366 if (tag_name === 'select') {
9367 init_select();
9368 }
9369 else {
9370 init_textbox();
9371 }
9372 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
9373 }
9374 ;
9375 //# sourceMappingURL=getSettings.js.map
9376
9377 /***/ },
9378
9379 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
9380 /*!***************************************************************************!*\
9381 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
9382 \***************************************************************************/
9383 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9384
9385 "use strict";
9386 __webpack_require__.r(__webpack_exports__);
9387 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9388 /* harmony export */ "default": () => (/* binding */ plugin)
9389 /* harmony export */ });
9390 /**
9391 * Tom Select v2.6.2
9392 * Licensed under the Apache License, Version 2.0 (the "License");
9393 */
9394
9395 /**
9396 * Converts a scalar to its best string representation
9397 * for hash keys and HTML attribute values.
9398 *
9399 * Transformations:
9400 * 'str' -> 'str'
9401 * null -> ''
9402 * undefined -> ''
9403 * true -> '1'
9404 * false -> '0'
9405 * 0 -> '0'
9406 * 1 -> '1'
9407 *
9408 */
9409
9410 /**
9411 * Iterates over arrays and hashes.
9412 *
9413 * ```
9414 * iterate(this.items, function(item, id) {
9415 * // invoked for each item
9416 * });
9417 * ```
9418 *
9419 */
9420 const iterate = (object, callback) => {
9421 if (Array.isArray(object)) {
9422 object.forEach(callback);
9423 } else {
9424 for (var key in object) {
9425 if (object.hasOwnProperty(key)) {
9426 callback(object[key], key);
9427 }
9428 }
9429 }
9430 };
9431
9432 /**
9433 * Remove css classes
9434 *
9435 */
9436 const removeClasses = (elmts, ...classes) => {
9437 var norm_classes = classesArray(classes);
9438 elmts = castAsArray(elmts);
9439 elmts.map(el => {
9440 norm_classes.map(cls => {
9441 el.classList.remove(cls);
9442 });
9443 });
9444 };
9445
9446 /**
9447 * Return arguments
9448 *
9449 */
9450 const classesArray = args => {
9451 var classes = [];
9452 iterate(args, _classes => {
9453 if (typeof _classes === 'string') {
9454 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9455 }
9456 if (Array.isArray(_classes)) {
9457 classes = classes.concat(_classes);
9458 }
9459 });
9460 return classes.filter(Boolean);
9461 };
9462
9463 /**
9464 * Create an array from arg if it's not already an array
9465 *
9466 */
9467 const castAsArray = arg => {
9468 if (!Array.isArray(arg)) {
9469 arg = [arg];
9470 }
9471 return arg;
9472 };
9473
9474 /**
9475 * Get the index of an element amongst sibling nodes of the same type
9476 *
9477 */
9478 const nodeIndex = (el, amongst) => {
9479 if (!el) return -1;
9480 amongst = amongst || el.nodeName;
9481 var i = 0;
9482 while (el = el.previousElementSibling) {
9483 if (el.matches(amongst)) {
9484 i++;
9485 }
9486 }
9487 return i;
9488 };
9489
9490 /**
9491 * Plugin: "dropdown_input" (Tom Select)
9492 * Copyright (c) contributors
9493 *
9494 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9495 * file except in compliance with the License. You may obtain a copy of the License at:
9496 * http://www.apache.org/licenses/LICENSE-2.0
9497 *
9498 * Unless required by applicable law or agreed to in writing, software distributed under
9499 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9500 * ANY KIND, either express or implied. See the License for the specific language
9501 * governing permissions and limitations under the License.
9502 *
9503 */
9504
9505 function plugin () {
9506 var self = this;
9507
9508 /**
9509 * Moves the caret to the specified index.
9510 *
9511 * The input must be moved by leaving it in place and moving the
9512 * siblings, due to the fact that focus cannot be restored once lost
9513 * on mobile webkit devices
9514 *
9515 */
9516 self.hook('instead', 'setCaret', new_pos => {
9517 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
9518 new_pos = self.items.length;
9519 } else {
9520 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
9521 if (new_pos != self.caretPos && !self.isPending) {
9522 self.controlChildren().forEach((child, j) => {
9523 if (j < new_pos) {
9524 self.control_input.insertAdjacentElement('beforebegin', child);
9525 } else {
9526 self.control.appendChild(child);
9527 }
9528 });
9529 }
9530 }
9531 self.caretPos = new_pos;
9532 });
9533 self.hook('instead', 'moveCaret', direction => {
9534 if (!self.isFocused) return;
9535
9536 // move caret before or after selected items
9537 const last_active = self.getLastActive(direction);
9538 if (last_active) {
9539 const idx = nodeIndex(last_active);
9540 self.setCaret(direction > 0 ? idx + 1 : idx);
9541 self.setActiveItem();
9542 removeClasses(last_active, 'last-active');
9543
9544 // move caret left or right of current position
9545 } else {
9546 self.setCaret(self.caretPos + direction);
9547 }
9548 });
9549 }
9550
9551
9552 //# sourceMappingURL=plugin.js.map
9553
9554
9555 /***/ },
9556
9557 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9558 /*!****************************************************************************!*\
9559 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9560 \****************************************************************************/
9561 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9562
9563 "use strict";
9564 __webpack_require__.r(__webpack_exports__);
9565 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9566 /* harmony export */ "default": () => (/* binding */ plugin)
9567 /* harmony export */ });
9568 /**
9569 * Tom Select v2.6.2
9570 * Licensed under the Apache License, Version 2.0 (the "License");
9571 */
9572
9573 /**
9574 * Converts a scalar to its best string representation
9575 * for hash keys and HTML attribute values.
9576 *
9577 * Transformations:
9578 * 'str' -> 'str'
9579 * null -> ''
9580 * undefined -> ''
9581 * true -> '1'
9582 * false -> '0'
9583 * 0 -> '0'
9584 * 1 -> '1'
9585 *
9586 */
9587
9588 /**
9589 * Add event helper
9590 *
9591 */
9592 const addEvent = (target, type, callback, options) => {
9593 target.addEventListener(type, callback, options);
9594 };
9595
9596 /**
9597 * Plugin: "change_listener" (Tom Select)
9598 * Copyright (c) contributors
9599 *
9600 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9601 * file except in compliance with the License. You may obtain a copy of the License at:
9602 * http://www.apache.org/licenses/LICENSE-2.0
9603 *
9604 * Unless required by applicable law or agreed to in writing, software distributed under
9605 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9606 * ANY KIND, either express or implied. See the License for the specific language
9607 * governing permissions and limitations under the License.
9608 *
9609 */
9610
9611 function plugin () {
9612 addEvent(this.input, 'change', () => {
9613 this.sync();
9614 });
9615 }
9616
9617
9618 //# sourceMappingURL=plugin.js.map
9619
9620
9621 /***/ },
9622
9623 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9624 /*!*****************************************************************************!*\
9625 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9626 \*****************************************************************************/
9627 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9628
9629 "use strict";
9630 __webpack_require__.r(__webpack_exports__);
9631 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9632 /* harmony export */ "default": () => (/* binding */ plugin)
9633 /* harmony export */ });
9634 /**
9635 * Tom Select v2.6.2
9636 * Licensed under the Apache License, Version 2.0 (the "License");
9637 */
9638
9639 /**
9640 * Converts a scalar to its best string representation
9641 * for hash keys and HTML attribute values.
9642 *
9643 * Transformations:
9644 * 'str' -> 'str'
9645 * null -> ''
9646 * undefined -> ''
9647 * true -> '1'
9648 * false -> '0'
9649 * 0 -> '0'
9650 * 1 -> '1'
9651 *
9652 */
9653 const hash_key = value => {
9654 if (typeof value === 'undefined' || value === null) return null;
9655 return get_hash(value);
9656 };
9657 const get_hash = value => {
9658 if (typeof value === 'boolean') return value ? '1' : '0';
9659 return value + '';
9660 };
9661
9662 /**
9663 * Prevent default
9664 *
9665 */
9666 const preventDefault = (evt, stop = false) => {
9667 if (evt) {
9668 evt.preventDefault();
9669 if (stop) {
9670 evt.stopPropagation();
9671 }
9672 }
9673 };
9674
9675 /**
9676 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9677 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9678 *
9679 * param query should be {}
9680 */
9681 const getDom = query => {
9682 if (query.jquery) {
9683 return query[0];
9684 }
9685 if (query instanceof HTMLElement) {
9686 return query;
9687 }
9688 if (isHtmlString(query)) {
9689 var tpl = document.createElement('template');
9690 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9691 return tpl.content.firstChild;
9692 }
9693 return document.querySelector(query);
9694 };
9695 const isHtmlString = arg => {
9696 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9697 return true;
9698 }
9699 return false;
9700 };
9701
9702 /**
9703 * Plugin: "checkbox_options" (Tom Select)
9704 * Copyright (c) contributors
9705 *
9706 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9707 * file except in compliance with the License. You may obtain a copy of the License at:
9708 * http://www.apache.org/licenses/LICENSE-2.0
9709 *
9710 * Unless required by applicable law or agreed to in writing, software distributed under
9711 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9712 * ANY KIND, either express or implied. See the License for the specific language
9713 * governing permissions and limitations under the License.
9714 *
9715 */
9716
9717 function plugin (userOptions) {
9718 var self = this;
9719 var orig_onOptionSelect = self.onOptionSelect;
9720 self.settings.hideSelected = false;
9721 const cbOptions = Object.assign({
9722 // so that the user may add different ones as well
9723 className: "tomselect-checkbox",
9724 // the following default to the historic plugin's values
9725 checkedClassNames: undefined,
9726 uncheckedClassNames: undefined
9727 }, userOptions);
9728 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9729 if (toCheck) {
9730 checkbox.checked = true;
9731 if (cbOptions.uncheckedClassNames) {
9732 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9733 }
9734 if (cbOptions.checkedClassNames) {
9735 checkbox.classList.add(...cbOptions.checkedClassNames);
9736 }
9737 } else {
9738 checkbox.checked = false;
9739 if (cbOptions.checkedClassNames) {
9740 checkbox.classList.remove(...cbOptions.checkedClassNames);
9741 }
9742 if (cbOptions.uncheckedClassNames) {
9743 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9744 }
9745 }
9746 };
9747
9748 // update the checkbox for an option
9749 var UpdateCheckbox = function UpdateCheckbox(option) {
9750 setTimeout(() => {
9751 var checkbox = option.querySelector('input.' + cbOptions.className);
9752 if (checkbox instanceof HTMLInputElement) {
9753 UpdateChecked(checkbox, option.classList.contains('selected'));
9754 }
9755 }, 1);
9756 };
9757
9758 // add checkbox to option template
9759 self.hook('after', 'setupTemplates', () => {
9760 var orig_render_option = self.settings.render.option;
9761 self.settings.render.option = (data, escape_html) => {
9762 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9763 var checkbox = document.createElement('input');
9764 if (cbOptions.className) {
9765 checkbox.classList.add(cbOptions.className);
9766 }
9767 checkbox.addEventListener('click', function (evt) {
9768 preventDefault(evt);
9769 });
9770 checkbox.type = 'checkbox';
9771 const hashed = hash_key(data[self.settings.valueField]);
9772 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9773 rendered.prepend(checkbox);
9774 return rendered;
9775 };
9776 });
9777
9778 // uncheck when item removed
9779 self.on('item_remove', value => {
9780 var option = self.getOption(value);
9781 if (option) {
9782 // if dropdown hasn't been opened yet, the option won't exist
9783 option.classList.remove('selected'); // selected class won't be removed yet
9784 UpdateCheckbox(option);
9785 }
9786 });
9787
9788 // check when item added
9789 self.on('item_add', value => {
9790 var option = self.getOption(value);
9791 if (option) {
9792 // if dropdown hasn't been opened yet, the option won't exist
9793 UpdateCheckbox(option);
9794 }
9795 });
9796
9797 // remove items when selected option is clicked
9798 self.hook('instead', 'onOptionSelect', (evt, option) => {
9799 if (option.classList.contains('selected')) {
9800 option.classList.remove('selected');
9801 self.removeItem(option.dataset.value);
9802 self.refreshOptions();
9803 preventDefault(evt, true);
9804 return;
9805 }
9806 orig_onOptionSelect.call(self, evt, option);
9807 UpdateCheckbox(option);
9808 });
9809 }
9810
9811
9812 //# sourceMappingURL=plugin.js.map
9813
9814
9815 /***/ },
9816
9817 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9818 /*!*************************************************************************!*\
9819 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9820 \*************************************************************************/
9821 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9822
9823 "use strict";
9824 __webpack_require__.r(__webpack_exports__);
9825 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9826 /* harmony export */ "default": () => (/* binding */ plugin)
9827 /* harmony export */ });
9828 /**
9829 * Tom Select v2.6.2
9830 * Licensed under the Apache License, Version 2.0 (the "License");
9831 */
9832
9833 /**
9834 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9835 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9836 *
9837 * param query should be {}
9838 */
9839 const getDom = query => {
9840 if (query.jquery) {
9841 return query[0];
9842 }
9843 if (query instanceof HTMLElement) {
9844 return query;
9845 }
9846 if (isHtmlString(query)) {
9847 var tpl = document.createElement('template');
9848 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9849 return tpl.content.firstChild;
9850 }
9851 return document.querySelector(query);
9852 };
9853 const isHtmlString = arg => {
9854 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9855 return true;
9856 }
9857 return false;
9858 };
9859
9860 /**
9861 * Plugin: "dropdown_header" (Tom Select)
9862 * Copyright (c) contributors
9863 *
9864 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9865 * file except in compliance with the License. You may obtain a copy of the License at:
9866 * http://www.apache.org/licenses/LICENSE-2.0
9867 *
9868 * Unless required by applicable law or agreed to in writing, software distributed under
9869 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9870 * ANY KIND, either express or implied. See the License for the specific language
9871 * governing permissions and limitations under the License.
9872 *
9873 */
9874
9875 function plugin (userOptions) {
9876 const self = this;
9877 const options = Object.assign({
9878 className: 'clear-button',
9879 title: 'Clear All',
9880 role: 'button',
9881 tabindex: 0,
9882 html: data => {
9883 return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">&times;</div>`;
9884 }
9885 }, userOptions);
9886 self.on('initialize', () => {
9887 var button = getDom(options.html(options));
9888 button.addEventListener('click', evt => {
9889 if (self.isLocked) return;
9890 self.clear();
9891 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9892 self.addItem('');
9893 }
9894 self.refreshOptions(false);
9895 evt.preventDefault();
9896 evt.stopPropagation();
9897 });
9898 self.control.appendChild(button);
9899 });
9900 }
9901
9902
9903 //# sourceMappingURL=plugin.js.map
9904
9905
9906 /***/ },
9907
9908 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9909 /*!**********************************************************************!*\
9910 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9911 \**********************************************************************/
9912 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9913
9914 "use strict";
9915 __webpack_require__.r(__webpack_exports__);
9916 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9917 /* harmony export */ "default": () => (/* binding */ plugin)
9918 /* harmony export */ });
9919 /**
9920 * Tom Select v2.6.2
9921 * Licensed under the Apache License, Version 2.0 (the "License");
9922 */
9923
9924 /**
9925 * Converts a scalar to its best string representation
9926 * for hash keys and HTML attribute values.
9927 *
9928 * Transformations:
9929 * 'str' -> 'str'
9930 * null -> ''
9931 * undefined -> ''
9932 * true -> '1'
9933 * false -> '0'
9934 * 0 -> '0'
9935 * 1 -> '1'
9936 *
9937 */
9938
9939 /**
9940 * Prevent default
9941 *
9942 */
9943 const preventDefault = (evt, stop = false) => {
9944 if (evt) {
9945 evt.preventDefault();
9946 if (stop) {
9947 evt.stopPropagation();
9948 }
9949 }
9950 };
9951
9952 /**
9953 * Add event helper
9954 *
9955 */
9956 const addEvent = (target, type, callback, options) => {
9957 target.addEventListener(type, callback, options);
9958 };
9959
9960 /**
9961 * Iterates over arrays and hashes.
9962 *
9963 * ```
9964 * iterate(this.items, function(item, id) {
9965 * // invoked for each item
9966 * });
9967 * ```
9968 *
9969 */
9970 const iterate = (object, callback) => {
9971 if (Array.isArray(object)) {
9972 object.forEach(callback);
9973 } else {
9974 for (var key in object) {
9975 if (object.hasOwnProperty(key)) {
9976 callback(object[key], key);
9977 }
9978 }
9979 }
9980 };
9981
9982 /**
9983 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9984 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9985 *
9986 * param query should be {}
9987 */
9988 const getDom = query => {
9989 if (query.jquery) {
9990 return query[0];
9991 }
9992 if (query instanceof HTMLElement) {
9993 return query;
9994 }
9995 if (isHtmlString(query)) {
9996 var tpl = document.createElement('template');
9997 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9998 return tpl.content.firstChild;
9999 }
10000 return document.querySelector(query);
10001 };
10002 const isHtmlString = arg => {
10003 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10004 return true;
10005 }
10006 return false;
10007 };
10008
10009 /**
10010 * Set attributes of an element
10011 *
10012 */
10013 const setAttr = (el, attrs) => {
10014 iterate(attrs, (val, attr) => {
10015 if (val == null) {
10016 el.removeAttribute(attr);
10017 } else {
10018 el.setAttribute(attr, '' + val);
10019 }
10020 });
10021 };
10022
10023 /**
10024 * Plugin: "drag_drop" (Tom Select)
10025 * Copyright (c) contributors
10026 *
10027 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10028 * file except in compliance with the License. You may obtain a copy of the License at:
10029 * http://www.apache.org/licenses/LICENSE-2.0
10030 *
10031 * Unless required by applicable law or agreed to in writing, software distributed under
10032 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10033 * ANY KIND, either express or implied. See the License for the specific language
10034 * governing permissions and limitations under the License.
10035 *
10036 */
10037
10038 const insertAfter = (referenceNode, newNode) => {
10039 var _referenceNode$parent;
10040 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
10041 };
10042 const insertBefore = (referenceNode, newNode) => {
10043 var _referenceNode$parent2;
10044 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
10045 };
10046 const isBefore = (referenceNode, newNode) => {
10047 do {
10048 var _newNode;
10049 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
10050 if (referenceNode == newNode) {
10051 return true;
10052 }
10053 } while (newNode && newNode.previousElementSibling);
10054 return false;
10055 };
10056 function plugin () {
10057 var self = this;
10058 if (self.settings.mode !== 'multi') return;
10059 var orig_lock = self.lock;
10060 var orig_unlock = self.unlock;
10061 let sortable = true;
10062 let drag_item;
10063
10064 /**
10065 * Add draggable attribute to item
10066 */
10067 self.hook('after', 'setupTemplates', () => {
10068 var orig_render_item = self.settings.render.item;
10069 self.settings.render.item = (data, escape) => {
10070 const item = getDom(orig_render_item.call(self, data, escape));
10071 setAttr(item, {
10072 'draggable': 'true'
10073 });
10074
10075 // prevent doc_mousedown (see tom-select.ts)
10076 const mousedown = evt => {
10077 if (!sortable) preventDefault(evt);
10078 evt.stopPropagation();
10079 };
10080 const dragStart = evt => {
10081 drag_item = item;
10082 setTimeout(() => {
10083 item.classList.add('ts-dragging');
10084 }, 0);
10085 };
10086 const dragOver = evt => {
10087 evt.preventDefault();
10088 item.classList.add('ts-drag-over');
10089 moveitem(item, drag_item);
10090 };
10091 const dragLeave = () => {
10092 item.classList.remove('ts-drag-over');
10093 };
10094 const moveitem = (targetitem, dragitem) => {
10095 if (dragitem === undefined) return;
10096 if (isBefore(dragitem, item)) {
10097 insertAfter(targetitem, dragitem);
10098 } else {
10099 insertBefore(targetitem, dragitem);
10100 }
10101 };
10102 const dragend = () => {
10103 var _drag_item;
10104 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
10105 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
10106 drag_item = undefined;
10107 var values = [];
10108 self.control.querySelectorAll(`[data-value]`).forEach(el => {
10109 if (el.dataset.value) {
10110 let value = el.dataset.value;
10111 if (value) {
10112 values.push(value);
10113 }
10114 }
10115 });
10116 self.setValue(values);
10117 };
10118 addEvent(item, 'mousedown', mousedown);
10119 addEvent(item, 'dragstart', dragStart);
10120 addEvent(item, 'dragenter', dragOver);
10121 addEvent(item, 'dragover', dragOver);
10122 addEvent(item, 'dragleave', dragLeave);
10123 addEvent(item, 'dragend', dragend);
10124 return item;
10125 };
10126 });
10127 self.hook('instead', 'lock', () => {
10128 sortable = false;
10129 return orig_lock.call(self);
10130 });
10131 self.hook('instead', 'unlock', () => {
10132 sortable = true;
10133 return orig_unlock.call(self);
10134 });
10135 }
10136
10137
10138 //# sourceMappingURL=plugin.js.map
10139
10140
10141 /***/ },
10142
10143 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
10144 /*!****************************************************************************!*\
10145 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
10146 \****************************************************************************/
10147 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10148
10149 "use strict";
10150 __webpack_require__.r(__webpack_exports__);
10151 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10152 /* harmony export */ "default": () => (/* binding */ plugin)
10153 /* harmony export */ });
10154 /**
10155 * Tom Select v2.6.2
10156 * Licensed under the Apache License, Version 2.0 (the "License");
10157 */
10158
10159 /**
10160 * Converts a scalar to its best string representation
10161 * for hash keys and HTML attribute values.
10162 *
10163 * Transformations:
10164 * 'str' -> 'str'
10165 * null -> ''
10166 * undefined -> ''
10167 * true -> '1'
10168 * false -> '0'
10169 * 0 -> '0'
10170 * 1 -> '1'
10171 *
10172 */
10173
10174 /**
10175 * Prevent default
10176 *
10177 */
10178 const preventDefault = (evt, stop = false) => {
10179 if (evt) {
10180 evt.preventDefault();
10181 if (stop) {
10182 evt.stopPropagation();
10183 }
10184 }
10185 };
10186
10187 /**
10188 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10189 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10190 *
10191 * param query should be {}
10192 */
10193 const getDom = query => {
10194 if (query.jquery) {
10195 return query[0];
10196 }
10197 if (query instanceof HTMLElement) {
10198 return query;
10199 }
10200 if (isHtmlString(query)) {
10201 var tpl = document.createElement('template');
10202 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10203 return tpl.content.firstChild;
10204 }
10205 return document.querySelector(query);
10206 };
10207 const isHtmlString = arg => {
10208 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10209 return true;
10210 }
10211 return false;
10212 };
10213
10214 /**
10215 * Plugin: "dropdown_header" (Tom Select)
10216 * Copyright (c) contributors
10217 *
10218 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10219 * file except in compliance with the License. You may obtain a copy of the License at:
10220 * http://www.apache.org/licenses/LICENSE-2.0
10221 *
10222 * Unless required by applicable law or agreed to in writing, software distributed under
10223 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10224 * ANY KIND, either express or implied. See the License for the specific language
10225 * governing permissions and limitations under the License.
10226 *
10227 */
10228
10229 function plugin (userOptions) {
10230 const self = this;
10231 const options = Object.assign({
10232 title: 'Untitled',
10233 headerClass: 'dropdown-header',
10234 titleRowClass: 'dropdown-header-title',
10235 labelClass: 'dropdown-header-label',
10236 closeClass: 'dropdown-header-close',
10237 html: data => {
10238 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
10239 }
10240 }, userOptions);
10241 self.on('initialize', () => {
10242 var header = getDom(options.html(options));
10243 var close_link = header.querySelector('.' + options.closeClass);
10244 if (close_link) {
10245 close_link.addEventListener('click', evt => {
10246 preventDefault(evt, true);
10247 self.close();
10248 });
10249 }
10250 self.dropdown.insertBefore(header, self.dropdown.firstChild);
10251 });
10252 }
10253
10254
10255 //# sourceMappingURL=plugin.js.map
10256
10257
10258 /***/ },
10259
10260 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
10261 /*!***************************************************************************!*\
10262 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
10263 \***************************************************************************/
10264 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10265
10266 "use strict";
10267 __webpack_require__.r(__webpack_exports__);
10268 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10269 /* harmony export */ "default": () => (/* binding */ plugin)
10270 /* harmony export */ });
10271 /**
10272 * Tom Select v2.6.2
10273 * Licensed under the Apache License, Version 2.0 (the "License");
10274 */
10275
10276 const KEY_ESC = 27;
10277 const KEY_TAB = 9;
10278 // ctrl key or apple key for ma
10279
10280 /**
10281 * Converts a scalar to its best string representation
10282 * for hash keys and HTML attribute values.
10283 *
10284 * Transformations:
10285 * 'str' -> 'str'
10286 * null -> ''
10287 * undefined -> ''
10288 * true -> '1'
10289 * false -> '0'
10290 * 0 -> '0'
10291 * 1 -> '1'
10292 *
10293 */
10294
10295 /**
10296 * Prevent default
10297 *
10298 */
10299 const preventDefault = (evt, stop = false) => {
10300 if (evt) {
10301 evt.preventDefault();
10302 if (stop) {
10303 evt.stopPropagation();
10304 }
10305 }
10306 };
10307
10308 /**
10309 * Add event helper
10310 *
10311 */
10312 const addEvent = (target, type, callback, options) => {
10313 target.addEventListener(type, callback, options);
10314 };
10315
10316 /**
10317 * Iterates over arrays and hashes.
10318 *
10319 * ```
10320 * iterate(this.items, function(item, id) {
10321 * // invoked for each item
10322 * });
10323 * ```
10324 *
10325 */
10326 const iterate = (object, callback) => {
10327 if (Array.isArray(object)) {
10328 object.forEach(callback);
10329 } else {
10330 for (var key in object) {
10331 if (object.hasOwnProperty(key)) {
10332 callback(object[key], key);
10333 }
10334 }
10335 }
10336 };
10337
10338 /**
10339 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10340 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10341 *
10342 * param query should be {}
10343 */
10344 const getDom = query => {
10345 if (query.jquery) {
10346 return query[0];
10347 }
10348 if (query instanceof HTMLElement) {
10349 return query;
10350 }
10351 if (isHtmlString(query)) {
10352 var tpl = document.createElement('template');
10353 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10354 return tpl.content.firstChild;
10355 }
10356 return document.querySelector(query);
10357 };
10358 const isHtmlString = arg => {
10359 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10360 return true;
10361 }
10362 return false;
10363 };
10364
10365 /**
10366 * Add css classes
10367 *
10368 */
10369 const addClasses = (elmts, ...classes) => {
10370 var norm_classes = classesArray(classes);
10371 elmts = castAsArray(elmts);
10372 elmts.map(el => {
10373 norm_classes.map(cls => {
10374 el.classList.add(cls);
10375 });
10376 });
10377 };
10378
10379 /**
10380 * Return arguments
10381 *
10382 */
10383 const classesArray = args => {
10384 var classes = [];
10385 iterate(args, _classes => {
10386 if (typeof _classes === 'string') {
10387 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10388 }
10389 if (Array.isArray(_classes)) {
10390 classes = classes.concat(_classes);
10391 }
10392 });
10393 return classes.filter(Boolean);
10394 };
10395
10396 /**
10397 * Create an array from arg if it's not already an array
10398 *
10399 */
10400 const castAsArray = arg => {
10401 if (!Array.isArray(arg)) {
10402 arg = [arg];
10403 }
10404 return arg;
10405 };
10406
10407 /**
10408 * Plugin: "dropdown_input" (Tom Select)
10409 * Copyright (c) contributors
10410 *
10411 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10412 * file except in compliance with the License. You may obtain a copy of the License at:
10413 * http://www.apache.org/licenses/LICENSE-2.0
10414 *
10415 * Unless required by applicable law or agreed to in writing, software distributed under
10416 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10417 * ANY KIND, either express or implied. See the License for the specific language
10418 * governing permissions and limitations under the License.
10419 *
10420 */
10421
10422 function plugin () {
10423 const self = this;
10424 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
10425
10426 self.hook('before', 'setup', () => {
10427 var _self$input;
10428 self.focus_node = self.control;
10429 addClasses(self.control_input, 'dropdown-input');
10430 const div = getDom('<div class="dropdown-input-wrap">');
10431 div.append(self.control_input);
10432 self.dropdown.insertBefore(div, self.dropdown.firstChild);
10433
10434 // set a placeholder in the select control
10435 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
10436 placeholder.placeholder = self.settings.placeholder || '';
10437 self.control.append(placeholder);
10438 /**
10439 * TomSelect renders a custom control with a focusable <input class="items-placeholder">.
10440 * The source <select>'s aria-label is not automatically propagated to that input,
10441 * which triggers "Missing form label" accessibility warnings.
10442 * This helper copies the label from the <select> onto the generated input.
10443 */
10444 const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label');
10445 if (!label) return;
10446 placeholder.setAttribute('aria-label', label);
10447 });
10448 self.on('initialize', () => {
10449 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
10450 self.control_input.addEventListener('keydown', evt => {
10451 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
10452 switch (evt.keyCode) {
10453 case KEY_ESC:
10454 if (self.isOpen) {
10455 preventDefault(evt, true);
10456 self.close();
10457 }
10458 self.clearActiveItems();
10459 return;
10460 case KEY_TAB:
10461 self.focus_node.tabIndex = -1;
10462 break;
10463 }
10464 return self.onKeyDown.call(self, evt);
10465 });
10466 self.on('blur', () => {
10467 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
10468 });
10469
10470 // give the control_input focus when the dropdown is open
10471 self.on('dropdown_open', () => {
10472 self.control_input.focus();
10473 });
10474
10475 // prevent onBlur from closing when focus is on the control_input
10476 const orig_onBlur = self.onBlur;
10477 self.hook('instead', 'onBlur', evt => {
10478 if (evt && evt.relatedTarget == self.control_input) return;
10479 return orig_onBlur.call(self);
10480 });
10481 addEvent(self.control_input, 'blur', () => self.onBlur());
10482
10483 // return focus to control to allow further keyboard input
10484 self.hook('before', 'close', () => {
10485 if (!self.isOpen) return;
10486 self.focus_node.focus({
10487 preventScroll: true
10488 });
10489 });
10490 });
10491 }
10492
10493
10494 //# sourceMappingURL=plugin.js.map
10495
10496
10497 /***/ },
10498
10499 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
10500 /*!***************************************************************************!*\
10501 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
10502 \***************************************************************************/
10503 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10504
10505 "use strict";
10506 __webpack_require__.r(__webpack_exports__);
10507 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10508 /* harmony export */ "default": () => (/* binding */ plugin)
10509 /* harmony export */ });
10510 /**
10511 * Tom Select v2.6.2
10512 * Licensed under the Apache License, Version 2.0 (the "License");
10513 */
10514
10515 /**
10516 * Converts a scalar to its best string representation
10517 * for hash keys and HTML attribute values.
10518 *
10519 * Transformations:
10520 * 'str' -> 'str'
10521 * null -> ''
10522 * undefined -> ''
10523 * true -> '1'
10524 * false -> '0'
10525 * 0 -> '0'
10526 * 1 -> '1'
10527 *
10528 */
10529
10530 /**
10531 * Add event helper
10532 *
10533 */
10534 const addEvent = (target, type, callback, options) => {
10535 target.addEventListener(type, callback, options);
10536 };
10537
10538 /**
10539 * Plugin: "input_autogrow" (Tom Select)
10540 *
10541 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10542 * file except in compliance with the License. You may obtain a copy of the License at:
10543 * http://www.apache.org/licenses/LICENSE-2.0
10544 *
10545 * Unless required by applicable law or agreed to in writing, software distributed under
10546 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10547 * ANY KIND, either express or implied. See the License for the specific language
10548 * governing permissions and limitations under the License.
10549 *
10550 */
10551
10552 function plugin () {
10553 var self = this;
10554 self.on('initialize', () => {
10555 var test_input = document.createElement('span');
10556 var control = self.control_input;
10557 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10558 self.wrapper.appendChild(test_input);
10559 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10560 for (const style_name of transfer_styles) {
10561 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10562 test_input.style[style_name] = control.style[style_name];
10563 }
10564
10565 /**
10566 * Set the control width
10567 *
10568 */
10569 var resize = () => {
10570 test_input.textContent = control.value;
10571 control.style.width = test_input.clientWidth + 'px';
10572 };
10573 resize();
10574 self.on('update item_add item_remove', resize);
10575 addEvent(control, 'input', resize);
10576 addEvent(control, 'keyup', resize);
10577 addEvent(control, 'blur', resize);
10578 addEvent(control, 'update', resize);
10579 });
10580 }
10581
10582
10583 //# sourceMappingURL=plugin.js.map
10584
10585
10586 /***/ },
10587
10588 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10589 /*!****************************************************************************!*\
10590 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10591 \****************************************************************************/
10592 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10593
10594 "use strict";
10595 __webpack_require__.r(__webpack_exports__);
10596 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10597 /* harmony export */ "default": () => (/* binding */ plugin)
10598 /* harmony export */ });
10599 /**
10600 * Tom Select v2.6.2
10601 * Licensed under the Apache License, Version 2.0 (the "License");
10602 */
10603
10604 /**
10605 * Plugin: "no_active_items" (Tom Select)
10606 *
10607 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10608 * file except in compliance with the License. You may obtain a copy of the License at:
10609 * http://www.apache.org/licenses/LICENSE-2.0
10610 *
10611 * Unless required by applicable law or agreed to in writing, software distributed under
10612 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10613 * ANY KIND, either express or implied. See the License for the specific language
10614 * governing permissions and limitations under the License.
10615 *
10616 */
10617
10618 function plugin () {
10619 this.hook('instead', 'setActiveItem', () => {});
10620 this.hook('instead', 'selectAll', () => {});
10621 }
10622
10623
10624 //# sourceMappingURL=plugin.js.map
10625
10626
10627 /***/ },
10628
10629 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10630 /*!********************************************************************************!*\
10631 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10632 \********************************************************************************/
10633 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10634
10635 "use strict";
10636 __webpack_require__.r(__webpack_exports__);
10637 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10638 /* harmony export */ "default": () => (/* binding */ plugin)
10639 /* harmony export */ });
10640 /**
10641 * Tom Select v2.6.2
10642 * Licensed under the Apache License, Version 2.0 (the "License");
10643 */
10644
10645 /**
10646 * Plugin: "input_autogrow" (Tom Select)
10647 *
10648 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10649 * file except in compliance with the License. You may obtain a copy of the License at:
10650 * http://www.apache.org/licenses/LICENSE-2.0
10651 *
10652 * Unless required by applicable law or agreed to in writing, software distributed under
10653 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10654 * ANY KIND, either express or implied. See the License for the specific language
10655 * governing permissions and limitations under the License.
10656 *
10657 */
10658
10659 function plugin () {
10660 var self = this;
10661 var orig_deleteSelection = self.deleteSelection;
10662 this.hook('instead', 'deleteSelection', evt => {
10663 if (self.activeItems.length) {
10664 return orig_deleteSelection.call(self, evt);
10665 }
10666 return false;
10667 });
10668 }
10669
10670
10671 //# sourceMappingURL=plugin.js.map
10672
10673
10674 /***/ },
10675
10676 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10677 /*!*****************************************************************************!*\
10678 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10679 \*****************************************************************************/
10680 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10681
10682 "use strict";
10683 __webpack_require__.r(__webpack_exports__);
10684 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10685 /* harmony export */ "default": () => (/* binding */ plugin)
10686 /* harmony export */ });
10687 /**
10688 * Tom Select v2.6.2
10689 * Licensed under the Apache License, Version 2.0 (the "License");
10690 */
10691
10692 const KEY_LEFT = 37;
10693 const KEY_RIGHT = 39;
10694 // ctrl key or apple key for ma
10695
10696 /**
10697 * Get the closest node to the evt.target matching the selector
10698 * Stops at wrapper
10699 *
10700 */
10701 const parentMatch = (target, selector, wrapper) => {
10702 while (target && target.matches) {
10703 if (target.matches(selector)) {
10704 return target;
10705 }
10706 target = target.parentNode;
10707 }
10708 };
10709
10710 /**
10711 * Get the index of an element amongst sibling nodes of the same type
10712 *
10713 */
10714 const nodeIndex = (el, amongst) => {
10715 if (!el) return -1;
10716 amongst = amongst || el.nodeName;
10717 var i = 0;
10718 while (el = el.previousElementSibling) {
10719 if (el.matches(amongst)) {
10720 i++;
10721 }
10722 }
10723 return i;
10724 };
10725
10726 /**
10727 * Plugin: "optgroup_columns" (Tom Select.js)
10728 * Copyright (c) contributors
10729 *
10730 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10731 * file except in compliance with the License. You may obtain a copy of the License at:
10732 * http://www.apache.org/licenses/LICENSE-2.0
10733 *
10734 * Unless required by applicable law or agreed to in writing, software distributed under
10735 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10736 * ANY KIND, either express or implied. See the License for the specific language
10737 * governing permissions and limitations under the License.
10738 *
10739 */
10740
10741 function plugin () {
10742 var self = this;
10743 var orig_keydown = self.onKeyDown;
10744 self.hook('instead', 'onKeyDown', evt => {
10745 var index, option, options, optgroup;
10746 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10747 return orig_keydown.call(self, evt);
10748 }
10749 self.ignoreHover = true;
10750 optgroup = parentMatch(self.activeOption, '[data-group]');
10751 index = nodeIndex(self.activeOption, '[data-selectable]');
10752 if (!optgroup) {
10753 return;
10754 }
10755 if (evt.keyCode === KEY_LEFT) {
10756 optgroup = optgroup.previousSibling;
10757 } else {
10758 optgroup = optgroup.nextSibling;
10759 }
10760 if (!optgroup) {
10761 return;
10762 }
10763 options = optgroup.querySelectorAll('[data-selectable]');
10764 option = options[Math.min(options.length - 1, index)];
10765 if (option) {
10766 self.setActiveOption(option);
10767 }
10768 });
10769 }
10770
10771
10772 //# sourceMappingURL=plugin.js.map
10773
10774
10775 /***/ },
10776
10777 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10778 /*!**************************************************************************!*\
10779 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10780 \**************************************************************************/
10781 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10782
10783 "use strict";
10784 __webpack_require__.r(__webpack_exports__);
10785 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10786 /* harmony export */ "default": () => (/* binding */ plugin)
10787 /* harmony export */ });
10788 /**
10789 * Tom Select v2.6.2
10790 * Licensed under the Apache License, Version 2.0 (the "License");
10791 */
10792
10793 /**
10794 * Converts a scalar to its best string representation
10795 * for hash keys and HTML attribute values.
10796 *
10797 * Transformations:
10798 * 'str' -> 'str'
10799 * null -> ''
10800 * undefined -> ''
10801 * true -> '1'
10802 * false -> '0'
10803 * 0 -> '0'
10804 * 1 -> '1'
10805 *
10806 */
10807
10808 /**
10809 * Prevent default
10810 *
10811 */
10812 const preventDefault = (evt, stop = false) => {
10813 if (evt) {
10814 evt.preventDefault();
10815 if (stop) {
10816 evt.stopPropagation();
10817 }
10818 }
10819 };
10820
10821 /**
10822 * Add event helper
10823 *
10824 */
10825 const addEvent = (target, type, callback, options) => {
10826 target.addEventListener(type, callback, options);
10827 };
10828
10829 /**
10830 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10831 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10832 *
10833 * param query should be {}
10834 */
10835 const getDom = query => {
10836 if (query.jquery) {
10837 return query[0];
10838 }
10839 if (query instanceof HTMLElement) {
10840 return query;
10841 }
10842 if (isHtmlString(query)) {
10843 var tpl = document.createElement('template');
10844 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10845 return tpl.content.firstChild;
10846 }
10847 return document.querySelector(query);
10848 };
10849 const isHtmlString = arg => {
10850 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10851 return true;
10852 }
10853 return false;
10854 };
10855
10856 /**
10857 * Plugin: "remove_button" (Tom Select)
10858 * Copyright (c) contributors
10859 *
10860 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10861 * file except in compliance with the License. You may obtain a copy of the License at:
10862 * http://www.apache.org/licenses/LICENSE-2.0
10863 *
10864 * Unless required by applicable law or agreed to in writing, software distributed under
10865 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10866 * ANY KIND, either express or implied. See the License for the specific language
10867 * governing permissions and limitations under the License.
10868 *
10869 */
10870
10871 function plugin (userOptions) {
10872 const self = this;
10873 const options = Object.assign({
10874 label: '×',
10875 title: 'Remove',
10876 className: 'remove',
10877 tabindex: -1,
10878 role: 'button',
10879 html: data => {
10880 var _data$tabindex;
10881 const el = document.createElement('div');
10882 el.className = data.className || '';
10883 el.title = data.title || '';
10884 el.setAttribute('role', data.role || 'button');
10885 el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1;
10886 el.textContent = data.label || '';
10887 return el;
10888 }
10889 }, userOptions);
10890 self.hook('after', 'setupTemplates', () => {
10891 var orig_render_item = self.settings.render.item;
10892 self.settings.render.item = (data, escape) => {
10893 var item = getDom(orig_render_item.call(self, data, escape));
10894 var close_button = getDom(options.html(options));
10895 item.appendChild(close_button);
10896 addEvent(close_button, 'mousedown', evt => {
10897 preventDefault(evt, true);
10898 });
10899 addEvent(close_button, 'click', evt => {
10900 if (self.isLocked) return;
10901
10902 // propagating will trigger the dropdown to show for single mode
10903 preventDefault(evt, true);
10904 if (self.isLocked) return;
10905 if (!self.shouldDelete([item], evt)) return;
10906 self.removeItem(item);
10907 self.refreshOptions(false);
10908 self.inputState();
10909 });
10910 return item;
10911 };
10912 });
10913 }
10914
10915
10916 //# sourceMappingURL=plugin.js.map
10917
10918
10919 /***/ },
10920
10921 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10922 /*!*********************************************************************************!*\
10923 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10924 \*********************************************************************************/
10925 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10926
10927 "use strict";
10928 __webpack_require__.r(__webpack_exports__);
10929 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10930 /* harmony export */ "default": () => (/* binding */ plugin)
10931 /* harmony export */ });
10932 /**
10933 * Tom Select v2.6.2
10934 * Licensed under the Apache License, Version 2.0 (the "License");
10935 */
10936
10937 /**
10938 * Plugin: "restore_on_backspace" (Tom Select)
10939 * Copyright (c) contributors
10940 *
10941 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10942 * file except in compliance with the License. You may obtain a copy of the License at:
10943 * http://www.apache.org/licenses/LICENSE-2.0
10944 *
10945 * Unless required by applicable law or agreed to in writing, software distributed under
10946 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10947 * ANY KIND, either express or implied. See the License for the specific language
10948 * governing permissions and limitations under the License.
10949 *
10950 */
10951
10952 function plugin (userOptions) {
10953 const self = this;
10954 const options = Object.assign({
10955 text: option => {
10956 return option[self.settings.labelField];
10957 }
10958 }, userOptions);
10959 self.on('item_remove', function (value) {
10960 if (!self.isFocused) {
10961 return;
10962 }
10963 if (self.control_input.value.trim() === '') {
10964 var option = self.options[value];
10965 if (option) {
10966 self.setTextboxValue(options.text.call(self, option));
10967 }
10968 }
10969 });
10970 }
10971
10972
10973 //# sourceMappingURL=plugin.js.map
10974
10975
10976 /***/ },
10977
10978 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10979 /*!***************************************************************************!*\
10980 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10981 \***************************************************************************/
10982 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10983
10984 "use strict";
10985 __webpack_require__.r(__webpack_exports__);
10986 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10987 /* harmony export */ "default": () => (/* binding */ plugin)
10988 /* harmony export */ });
10989 /**
10990 * Tom Select v2.6.2
10991 * Licensed under the Apache License, Version 2.0 (the "License");
10992 */
10993
10994 /**
10995 * Converts a scalar to its best string representation
10996 * for hash keys and HTML attribute values.
10997 *
10998 * Transformations:
10999 * 'str' -> 'str'
11000 * null -> ''
11001 * undefined -> ''
11002 * true -> '1'
11003 * false -> '0'
11004 * 0 -> '0'
11005 * 1 -> '1'
11006 *
11007 */
11008
11009 /**
11010 * Iterates over arrays and hashes.
11011 *
11012 * ```
11013 * iterate(this.items, function(item, id) {
11014 * // invoked for each item
11015 * });
11016 * ```
11017 *
11018 */
11019 const iterate = (object, callback) => {
11020 if (Array.isArray(object)) {
11021 object.forEach(callback);
11022 } else {
11023 for (var key in object) {
11024 if (object.hasOwnProperty(key)) {
11025 callback(object[key], key);
11026 }
11027 }
11028 }
11029 };
11030
11031 /**
11032 * Add css classes
11033 *
11034 */
11035 const addClasses = (elmts, ...classes) => {
11036 var norm_classes = classesArray(classes);
11037 elmts = castAsArray(elmts);
11038 elmts.map(el => {
11039 norm_classes.map(cls => {
11040 el.classList.add(cls);
11041 });
11042 });
11043 };
11044
11045 /**
11046 * Return arguments
11047 *
11048 */
11049 const classesArray = args => {
11050 var classes = [];
11051 iterate(args, _classes => {
11052 if (typeof _classes === 'string') {
11053 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
11054 }
11055 if (Array.isArray(_classes)) {
11056 classes = classes.concat(_classes);
11057 }
11058 });
11059 return classes.filter(Boolean);
11060 };
11061
11062 /**
11063 * Create an array from arg if it's not already an array
11064 *
11065 */
11066 const castAsArray = arg => {
11067 if (!Array.isArray(arg)) {
11068 arg = [arg];
11069 }
11070 return arg;
11071 };
11072
11073 /**
11074 * Plugin: "virtual_scroll" (Tom Select)
11075 * Copyright (c) contributors
11076 *
11077 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
11078 * file except in compliance with the License. You may obtain a copy of the License at:
11079 * http://www.apache.org/licenses/LICENSE-2.0
11080 *
11081 * Unless required by applicable law or agreed to in writing, software distributed under
11082 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11083 * ANY KIND, either express or implied. See the License for the specific language
11084 * governing permissions and limitations under the License.
11085 *
11086 */
11087
11088 function plugin () {
11089 const self = this;
11090 const orig_canLoad = self.canLoad;
11091 const orig_clearActiveOption = self.clearActiveOption;
11092 const orig_loadCallback = self.loadCallback;
11093 var pagination = {};
11094 var dropdown_content;
11095 var loading_more = false;
11096 var load_more_opt;
11097 var default_values = [];
11098 var default_values_loaded = false;
11099 var default_pagination;
11100 var default_options = [];
11101 var html_values = [];
11102 if (!self.settings.shouldLoadMore) {
11103 // return true if additional results should be loaded
11104 self.settings.shouldLoadMore = () => {
11105 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
11106 if (scroll_percent > 0.9) {
11107 return true;
11108 }
11109 if (self.activeOption) {
11110 var selectable = self.selectable();
11111 var index = Array.from(selectable).indexOf(self.activeOption);
11112 if (index >= selectable.length - 2) {
11113 return true;
11114 }
11115 }
11116 return false;
11117 };
11118 }
11119 if (!self.settings.firstUrl) {
11120 throw 'virtual_scroll plugin requires a firstUrl() method';
11121 }
11122
11123 // in order for virtual scrolling to work,
11124 // options need to be ordered the same way they're returned from the remote data source
11125 self.settings.sortField = [{
11126 field: '$order'
11127 }, {
11128 field: '$score'
11129 }];
11130
11131 // can we load more results for given query?
11132 const canLoadMore = query => {
11133 if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
11134 return false;
11135 }
11136 if (query in pagination && pagination[query]) {
11137 return true;
11138 }
11139 return false;
11140 };
11141 const clearFilter = (option, value) => {
11142 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
11143 return true;
11144 }
11145 return false;
11146 };
11147
11148 // set the next url that will be
11149 self.setNextUrl = (value, next_url) => {
11150 pagination[value] = next_url;
11151 };
11152
11153 // getUrl() to be used in settings.load()
11154 self.getUrl = query => {
11155 if (query in pagination) {
11156 const next_url = pagination[query];
11157 pagination[query] = false;
11158 return next_url;
11159 }
11160
11161 // if the user goes back to a previous query
11162 // we need to load the first page again
11163 self.clearPagination();
11164 return self.settings.firstUrl.call(self, query);
11165 };
11166
11167 // clear pagination
11168 self.clearPagination = () => {
11169 pagination = {};
11170 };
11171
11172 // don't clear the active option (and cause unwanted dropdown scroll)
11173 // while loading more results
11174 self.hook('instead', 'clearActiveOption', () => {
11175 if (loading_more) {
11176 return;
11177 }
11178 return orig_clearActiveOption.call(self);
11179 });
11180
11181 // override the canLoad method
11182 self.hook('instead', 'canLoad', query => {
11183 // first time the query has been seen
11184 if (!(query in pagination)) {
11185 return orig_canLoad.call(self, query);
11186 }
11187 return canLoadMore(query);
11188 });
11189
11190 // wrap the load
11191 self.hook('instead', 'loadCallback', (options, optgroups) => {
11192 if (!loading_more) {
11193 // When searching (non-empty query), keep selected items and HTML default options,
11194 // but remove preloaded remote options so they don't bleed into search results.
11195 // For empty query, use clearFilter (keeps default_values + items).
11196 const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter;
11197 self.clearOptions(activeFilter);
11198 } else if (load_more_opt) {
11199 const first_option = options[0];
11200 if (first_option !== undefined) {
11201 load_more_opt.dataset.value = first_option[self.settings.valueField];
11202 }
11203 }
11204 orig_loadCallback.call(self, options, optgroups);
11205
11206 // After the initial preload (empty query), snapshot default_values and option objects
11207 // so they can be restored when the user clears their search.
11208 if (!loading_more && !default_values_loaded) {
11209 default_values_loaded = true;
11210 if (self.lastValue === '') {
11211 default_values = Object.keys(self.options);
11212 default_pagination = pagination[''];
11213 default_options = Object.values(self.options);
11214 }
11215 }
11216 loading_more = false;
11217 });
11218
11219 // as the “loading_more” element will be removed from the dropdown,
11220 // we activate the previous option if needed
11221 // to avoid the dropdown being scrolled back to the first one
11222 self.hook('before', 'refreshOptions', () => {
11223 if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) {
11224 self.setActiveOption(self.activeOption.previousElementSibling);
11225 }
11226 });
11227
11228 // add templates to dropdown
11229 // loading_more if we have another url in the queue
11230 // no_more_results if we don't have another url in the queue
11231 self.hook('after', 'refreshOptions', () => {
11232 const query = self.lastValue;
11233 var option;
11234 if (canLoadMore(query)) {
11235 option = self.render('loading_more', {
11236 query: query
11237 });
11238 if (option) {
11239 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
11240 load_more_opt = option;
11241 }
11242 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
11243 option = self.render('no_more_results', {
11244 query: query
11245 });
11246 }
11247 if (option) {
11248 addClasses(option, self.settings.optionClass);
11249 dropdown_content.append(option);
11250 }
11251 });
11252
11253 // Restore preloaded options and pagination when clearing search
11254 const restoreDefaults = () => {
11255 if (!default_values_loaded) {
11256 return;
11257 }
11258 // Re-add preloaded option objects (clearOptions can only remove, not restore)
11259 self.addOptions(default_options);
11260 // Remove any search results that are not part of the preloaded defaults
11261 self.clearOptions(clearFilter);
11262 if (default_pagination) {
11263 pagination[''] = default_pagination;
11264 }
11265 };
11266 self.on('type', query => {
11267 if (query === '') {
11268 restoreDefaults();
11269 self.refreshOptions(false);
11270 }
11271 });
11272 self.on('dropdown_close', restoreDefaults);
11273
11274 // add scroll listener and default templates
11275 self.on('initialize', () => {
11276 html_values = Object.keys(self.options);
11277 default_values = Object.keys(self.options);
11278 dropdown_content = self.dropdown_content;
11279
11280 // default templates
11281 self.settings.render = Object.assign({}, {
11282 loading_more: () => {
11283 return `<div class="loading-more-results">Loading more results ... </div>`;
11284 },
11285 no_more_results: () => {
11286 return `<div class="no-more-results">No more results</div>`;
11287 }
11288 }, self.settings.render);
11289
11290 // watch dropdown content scroll position
11291 dropdown_content.addEventListener('scroll', () => {
11292 if (!self.settings.shouldLoadMore.call(self)) {
11293 return;
11294 }
11295
11296 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
11297 if (!canLoadMore(self.lastValue)) {
11298 return;
11299 }
11300
11301 // don't call load() too much
11302 if (loading_more) return;
11303 loading_more = true;
11304 self.load.call(self, self.lastValue);
11305 });
11306 });
11307 }
11308
11309
11310 //# sourceMappingURL=plugin.js.map
11311
11312
11313 /***/ },
11314
11315 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
11316 /*!*****************************************************************!*\
11317 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
11318 \*****************************************************************/
11319 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11320
11321 "use strict";
11322 __webpack_require__.r(__webpack_exports__);
11323 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11324 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11325 /* harmony export */ });
11326 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
11327 /* 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");
11328 /* 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");
11329 /* 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");
11330 /* 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");
11331 /* 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");
11332 /* 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");
11333 /* 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");
11334 /* 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");
11335 /* 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");
11336 /* 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");
11337 /* 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");
11338 /* 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");
11339 /* 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");
11340 /* 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");
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
11357 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
11358 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
11359 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
11360 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
11361 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
11362 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
11363 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
11364 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
11365 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
11366 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
11367 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
11368 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
11369 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
11370 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
11371 //# sourceMappingURL=tom-select.complete.js.map
11372
11373 /***/ },
11374
11375 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
11376 /*!********************************************************!*\
11377 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
11378 \********************************************************/
11379 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11380
11381 "use strict";
11382 __webpack_require__.r(__webpack_exports__);
11383 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11384 /* harmony export */ "default": () => (/* binding */ TomSelect)
11385 /* harmony export */ });
11386 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
11387 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
11388 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
11389 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
11390 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
11391 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
11392 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
11393 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
11394 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404 var instance_i = 0;
11405 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
11406 constructor(input_arg, user_settings) {
11407 super();
11408 this.order = 0;
11409 this.isOpen = false;
11410 this.isDisabled = false;
11411 this.isReadOnly = false;
11412 this.isInvalid = false; // @deprecated 1.8
11413 this.isValid = true;
11414 this.isLocked = false;
11415 this.isFocused = false;
11416 this.isInputHidden = false;
11417 this.isSetup = false;
11418 this.isDropdownContentStale = true;
11419 this.ignoreFocus = false;
11420 this.ignoreHover = false;
11421 this.hasOptions = false;
11422 this.lastValue = '';
11423 this.caretPos = 0;
11424 this.loading = 0;
11425 this.loadedSearches = {};
11426 this.activeOption = null;
11427 this.activeItems = [];
11428 this.optgroups = {};
11429 this.options = {};
11430 this.userOptions = {};
11431 this.items = [];
11432 this.refreshTimeout = null;
11433 instance_i++;
11434 var dir;
11435 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
11436 if (input.tomselect) {
11437 throw new Error('Tom Select already initialized on this element');
11438 }
11439 input.tomselect = this;
11440 // detect rtl environment
11441 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
11442 dir = computedStyle.getPropertyValue('direction');
11443 // setup default state
11444 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
11445 this.settings = settings;
11446 this.input = input;
11447 this.tabIndex = input.tabIndex || 0;
11448 this.is_select_tag = input.tagName.toLowerCase() === 'select';
11449 this.rtl = /rtl/i.test(dir);
11450 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
11451 this.isRequired = input.required;
11452 // search system
11453 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
11454 // option-dependent defaults
11455 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
11456 if (typeof settings.hideSelected !== 'boolean') {
11457 settings.hideSelected = settings.mode === 'multi';
11458 }
11459 if (typeof settings.hidePlaceholder !== 'boolean') {
11460 settings.hidePlaceholder = settings.mode !== 'multi';
11461 }
11462 // set up createFilter callback
11463 var filter = settings.createFilter;
11464 if (typeof filter !== 'function') {
11465 if (typeof filter === 'string') {
11466 filter = new RegExp(filter);
11467 }
11468 if (filter instanceof RegExp) {
11469 settings.createFilter = (input) => filter.test(input);
11470 }
11471 else {
11472 settings.createFilter = (value) => {
11473 return this.settings.duplicates || !this.options[value];
11474 };
11475 }
11476 }
11477 this.initializePlugins(settings.plugins);
11478 this.setupCallbacks();
11479 this.setupTemplates();
11480 // Create all elements
11481 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
11482 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
11483 const dropdown = this._render('dropdown');
11484 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
11485 const classes = this.input.getAttribute('class') || '';
11486 const inputMode = settings.mode;
11487 var control_input;
11488 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
11489 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
11490 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
11491 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
11492 if (settings.copyClassesToDropdown) {
11493 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
11494 }
11495 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
11496 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
11497 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
11498 // default controlInput
11499 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
11500 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
11501 // set attributes
11502 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
11503 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
11504 if (input.getAttribute(attr)) {
11505 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
11506 }
11507 });
11508 control_input.tabIndex = -1;
11509 control.appendChild(control_input);
11510 this.focus_node = control_input;
11511 // dom element
11512 }
11513 else if (settings.controlInput) {
11514 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
11515 this.focus_node = control_input;
11516 }
11517 else {
11518 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
11519 this.focus_node = control;
11520 }
11521 this.wrapper = wrapper;
11522 this.dropdown = dropdown;
11523 this.dropdown_content = dropdown_content;
11524 this.control = control;
11525 this.control_input = control_input;
11526 this.setup();
11527 }
11528 /**
11529 * set up event bindings.
11530 *
11531 */
11532 setup() {
11533 const self = this;
11534 const settings = self.settings;
11535 const control_input = self.control_input;
11536 const dropdown = self.dropdown;
11537 const dropdown_content = self.dropdown_content;
11538 const wrapper = self.wrapper;
11539 const control = self.control;
11540 const input = self.input;
11541 const focus_node = self.focus_node;
11542 const passive_event = { passive: true };
11543 const listboxId = self.inputId + '-ts-dropdown';
11544 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
11545 id: listboxId
11546 });
11547 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
11548 role: 'combobox',
11549 'aria-haspopup': 'listbox',
11550 'aria-expanded': 'false',
11551 'aria-controls': listboxId
11552 });
11553 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
11554 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
11555 const label = document.querySelector(query);
11556 const label_click = self.focus.bind(self);
11557 if (label) {
11558 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
11559 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
11560 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
11561 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
11562 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11563 }
11564 wrapper.style.width = input.style.width;
11565 wrapper.style.minWidth = input.style.minWidth;
11566 wrapper.style.maxWidth = input.style.maxWidth;
11567 if (self.plugins.names.length) {
11568 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11569 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11570 }
11571 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11572 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11573 }
11574 if (settings.placeholder) {
11575 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11576 }
11577 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11578 if (!settings.splitOn && settings.delimiter) {
11579 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11580 }
11581 // debounce user defined load() if loadThrottle > 0
11582 // after initializePlugins() so plugins can create/modify user defined loaders
11583 if (settings.load && settings.loadThrottle) {
11584 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11585 }
11586 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11587 self.ignoreHover = false;
11588 });
11589 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11590 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11591 if (target_match)
11592 self.onOptionHover(e, target_match);
11593 }, { capture: true });
11594 // clicking on an option should select it
11595 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11596 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11597 if (option) {
11598 self.onOptionSelect(evt, option);
11599 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11600 }
11601 });
11602 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11603 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11604 if (target_match && self.onItemSelect(evt, target_match)) {
11605 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11606 return;
11607 }
11608 // retain focus (see control_input mousedown)
11609 if (control_input.value != '') {
11610 return;
11611 }
11612 self.onClick();
11613 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11614 });
11615 // keydown on focus_node for arrow_down/arrow_up
11616 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11617 // keypress and input/keyup
11618 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11619 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11620 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11621 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11622 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11623 const doc_mousedown = (evt) => {
11624 // blur if target is outside of this instance
11625 // dropdown is not always inside wrapper
11626 const target = evt.composedPath()[0];
11627 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11628 if (self.isFocused) {
11629 self.blur();
11630 }
11631 self.inputState();
11632 return;
11633 }
11634 // retain focus by preventing native handling. if the
11635 // event target is the input it should not be modified.
11636 // otherwise, text selection within the input won't work.
11637 // Fixes bug #212 which is no covered by tests
11638 if (target == control_input && self.isOpen) {
11639 evt.stopPropagation();
11640 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11641 }
11642 else {
11643 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11644 }
11645 };
11646 const win_scroll = () => {
11647 if (self.isOpen) {
11648 self.positionDropdown();
11649 }
11650 };
11651 const input_invalid = () => {
11652 if (self.isValid) {
11653 self.isValid = false;
11654 self.isInvalid = true;
11655 self.refreshState();
11656 }
11657 };
11658 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid);
11659 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11660 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11661 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11662 this._destroy = () => {
11663 input.removeEventListener('invalid', input_invalid);
11664 document.removeEventListener('mousedown', doc_mousedown);
11665 window.removeEventListener('scroll', win_scroll);
11666 window.removeEventListener('resize', win_scroll);
11667 if (label)
11668 label.removeEventListener('click', label_click);
11669 };
11670 // store original html and tab index so that they can be
11671 // restored when the destroy() method is called.
11672 this.revertSettings = {
11673 innerHTML: input.innerHTML,
11674 tabIndex: input.tabIndex
11675 };
11676 input.tabIndex = -1;
11677 input.insertAdjacentElement('afterend', self.wrapper);
11678 self.sync(false);
11679 settings.items = [];
11680 delete settings.optgroups;
11681 delete settings.options;
11682 self.refreshItems();
11683 self.close(false);
11684 self.inputState();
11685 self.isSetup = true;
11686 self.on('change', this.onChange);
11687 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11688 self.trigger('initialize');
11689 // preload options
11690 if (settings.preload === true) {
11691 self.preload();
11692 }
11693 }
11694 /**
11695 * Register options and optgroups
11696 *
11697 */
11698 setupOptions(options = [], optgroups = []) {
11699 // build options table
11700 this.addOptions(options);
11701 // build optgroup table
11702 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11703 this.registerOptionGroup(optgroup);
11704 });
11705 }
11706 /**
11707 * Sets up default rendering functions.
11708 */
11709 setupTemplates() {
11710 var self = this;
11711 var field_label = self.settings.labelField;
11712 var field_optgroup = self.settings.optgroupLabelField;
11713 var templates = {
11714 'optgroup': (data) => {
11715 let optgroup = document.createElement('div');
11716 optgroup.className = 'optgroup';
11717 optgroup.appendChild(data.options);
11718 return optgroup;
11719 },
11720 'optgroup_header': (data, escape) => {
11721 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11722 },
11723 'option': (data, escape) => {
11724 return '<div>' + escape(data[field_label]) + '</div>';
11725 },
11726 'item': (data, escape) => {
11727 return '<div>' + escape(data[field_label]) + '</div>';
11728 },
11729 'option_create': (data, escape) => {
11730 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11731 },
11732 'no_results': () => {
11733 return '<div class="no-results">No results found</div>';
11734 },
11735 'loading': () => {
11736 return '<div class="spinner"></div>';
11737 },
11738 'not_loading': () => { },
11739 'dropdown': () => {
11740 return '<div></div>';
11741 }
11742 };
11743 self.settings.render = Object.assign({}, templates, self.settings.render);
11744 }
11745 /**
11746 * Maps fired events to callbacks provided
11747 * in the settings used when creating the control.
11748 */
11749 setupCallbacks() {
11750 var key, fn;
11751 var callbacks = {
11752 'initialize': 'onInitialize',
11753 'change': 'onChange',
11754 'item_add': 'onItemAdd',
11755 'item_remove': 'onItemRemove',
11756 'item_select': 'onItemSelect',
11757 'clear': 'onClear',
11758 'option_add': 'onOptionAdd',
11759 'option_remove': 'onOptionRemove',
11760 'option_clear': 'onOptionClear',
11761 'optgroup_add': 'onOptionGroupAdd',
11762 'optgroup_remove': 'onOptionGroupRemove',
11763 'optgroup_clear': 'onOptionGroupClear',
11764 'dropdown_open': 'onDropdownOpen',
11765 'dropdown_close': 'onDropdownClose',
11766 'type': 'onType',
11767 'load': 'onLoad',
11768 'focus': 'onFocus',
11769 'blur': 'onBlur'
11770 };
11771 for (key in callbacks) {
11772 fn = this.settings[callbacks[key]];
11773 if (fn)
11774 this.on(key, fn);
11775 }
11776 }
11777 /**
11778 * Sync the Tom Select instance with the original input or select
11779 *
11780 */
11781 sync(get_settings = true) {
11782 const self = this;
11783 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings;
11784 self.setupOptions(settings.options, settings.optgroups);
11785 self.setValue(settings.items || [], true); // silent prevents recursion
11786 if (self.input.disabled) {
11787 self.disable();
11788 }
11789 else if (self.input.readOnly) {
11790 self.setReadOnly(true);
11791 }
11792 else {
11793 self.enable(); //sets tabIndex
11794 }
11795 self.lastQuery = null; // so updated options will be displayed in dropdown
11796 }
11797 /**
11798 * Triggered when the main control element
11799 * has a click event.
11800 *
11801 */
11802 onClick() {
11803 var self = this;
11804 if (self.activeItems.length > 0) {
11805 self.clearActiveItems();
11806 self.focus();
11807 return;
11808 }
11809 if (self.isFocused && self.isOpen) {
11810 self.blur();
11811 }
11812 else {
11813 self.focus();
11814 }
11815 }
11816 /**
11817 * @deprecated v1.7
11818 *
11819 */
11820 onMouseDown() { }
11821 /**
11822 * Triggered when the value of the control has been changed.
11823 * This should propagate the event to the original DOM
11824 * input / select element.
11825 */
11826 onChange() {
11827 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11828 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11829 }
11830 /**
11831 * Triggered on <input> paste.
11832 *
11833 */
11834 onPaste(e) {
11835 var self = this;
11836 if (self.isInputHidden || self.isLocked) {
11837 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11838 return;
11839 }
11840 // If a regex or string is included, this will split the pasted
11841 // input and create Items for each separate value
11842 if (!self.settings.splitOn) {
11843 return;
11844 }
11845 // Wait for pasted text to be recognized in value
11846 setTimeout(() => {
11847 var pastedText = self.inputValue();
11848 if (!pastedText.match(self.settings.splitOn)) {
11849 return;
11850 }
11851 var splitInput = pastedText.trim().split(self.settings.splitOn);
11852 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11853 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11854 if (hash) {
11855 if (this.options[piece]) {
11856 self.addItem(piece);
11857 }
11858 else {
11859 self.createItem(piece);
11860 }
11861 }
11862 });
11863 }, 0);
11864 }
11865 /**
11866 * Triggered on <input> keypress.
11867 *
11868 */
11869 onKeyPress(e) {
11870 var self = this;
11871 if (self.isLocked) {
11872 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11873 return;
11874 }
11875 var character = String.fromCharCode(e.keyCode || e.which);
11876 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11877 self.createItem();
11878 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11879 return;
11880 }
11881 }
11882 /**
11883 * Triggered on <input> keydown.
11884 *
11885 */
11886 onKeyDown(e) {
11887 var self = this;
11888 self.ignoreHover = true;
11889 if (self.isLocked) {
11890 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11891 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11892 }
11893 return;
11894 }
11895 switch (e.keyCode) {
11896 // ctrl+A: select all
11897 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11898 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11899 if (self.control_input.value == '') {
11900 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11901 self.selectAll();
11902 return;
11903 }
11904 }
11905 break;
11906 // esc: close dropdown
11907 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11908 if (self.isOpen) {
11909 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11910 self.close();
11911 }
11912 self.clearActiveItems();
11913 return;
11914 // down: open dropdown or move selection down
11915 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11916 if (!self.isOpen && self.hasOptions) {
11917 self.open();
11918 }
11919 else if (self.activeOption) {
11920 let next = self.getAdjacent(self.activeOption, 1);
11921 if (next)
11922 self.setActiveOption(next);
11923 }
11924 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11925 return;
11926 // up: move selection up
11927 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11928 if (self.activeOption) {
11929 let prev = self.getAdjacent(self.activeOption, -1);
11930 if (prev)
11931 self.setActiveOption(prev);
11932 }
11933 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11934 return;
11935 // return: select active option
11936 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11937 if (self.canSelect(self.activeOption)) {
11938 self.onOptionSelect(e, self.activeOption);
11939 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11940 // if the option_create=null, the dropdown might be closed
11941 }
11942 else if (self.settings.create && self.createItem()) {
11943 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11944 // don't submit form when searching for a value
11945 }
11946 else if (document.activeElement == self.control_input && self.isOpen) {
11947 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11948 }
11949 return;
11950 // left: modifiy item selection to the left
11951 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11952 self.advanceSelection(-1, e);
11953 return;
11954 // right: modifiy item selection to the right
11955 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11956 self.advanceSelection(1, e);
11957 return;
11958 // tab: select active option and/or create item
11959 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11960 if (self.settings.selectOnTab) {
11961 if (self.canSelect(self.activeOption)) {
11962 self.onOptionSelect(e, self.activeOption);
11963 // prevent default [tab] behaviour of jump to the next field
11964 // if select isFull, then the dropdown won't be open and [tab] will work normally
11965 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11966 }
11967 else if (self.settings.create && self.createItem()) {
11968 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11969 }
11970 }
11971 return;
11972 // delete|backspace: delete items
11973 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11974 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11975 self.deleteSelection(e);
11976 return;
11977 }
11978 // don't enter text in the control_input when active items are selected
11979 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11980 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11981 }
11982 }
11983 /**
11984 * Triggered on <input> keyup.
11985 *
11986 */
11987 onInput(e) {
11988 if (this.isLocked) {
11989 return;
11990 }
11991 const value = this.inputValue();
11992 if (this.lastValue === value)
11993 return;
11994 this.lastValue = value;
11995 if (value == '') {
11996 this._onInput();
11997 return;
11998 }
11999 if (this.refreshTimeout) {
12000 window.clearTimeout(this.refreshTimeout);
12001 }
12002 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
12003 this.refreshTimeout = null;
12004 this._onInput();
12005 }, this.settings.refreshThrottle);
12006 }
12007 _onInput() {
12008 const value = this.lastValue;
12009 if (this.settings.shouldLoad.call(this, value)) {
12010 this.load(value);
12011 }
12012 this.refreshOptions();
12013 this.trigger('type', value);
12014 }
12015 /**
12016 * Triggered when the user rolls over
12017 * an option in the autocomplete dropdown menu.
12018 *
12019 */
12020 onOptionHover(evt, option) {
12021 if (this.ignoreHover)
12022 return;
12023 this.setActiveOption(option, false);
12024 }
12025 /**
12026 * Triggered on <input> focus.
12027 *
12028 */
12029 onFocus(e) {
12030 var self = this;
12031 var wasFocused = self.isFocused;
12032 if (self.isDisabled || self.isReadOnly) {
12033 self.blur();
12034 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
12035 return;
12036 }
12037 if (self.ignoreFocus)
12038 return;
12039 self.isFocused = true;
12040 if (self.settings.preload === 'focus')
12041 self.preload();
12042 if (!wasFocused)
12043 self.trigger('focus');
12044 if (!self.activeItems.length) {
12045 self.inputState();
12046 self.refreshOptions(!!self.settings.openOnFocus);
12047 }
12048 self.refreshState();
12049 }
12050 /**
12051 * Triggered on <input> blur.
12052 *
12053 */
12054 onBlur(e) {
12055 if (document.hasFocus() === false)
12056 return;
12057 var self = this;
12058 if (!self.isFocused)
12059 return;
12060 self.isFocused = false;
12061 self.ignoreFocus = false;
12062 var deactivate = () => {
12063 self.close();
12064 self.setActiveItem();
12065 self.setCaret(self.items.length);
12066 self.trigger('blur');
12067 };
12068 if (self.settings.create && self.settings.createOnBlur) {
12069 self.createItem(null, deactivate);
12070 }
12071 else {
12072 deactivate();
12073 }
12074 }
12075 /**
12076 * Triggered when the user clicks on an option
12077 * in the autocomplete dropdown menu.
12078 *
12079 */
12080 onOptionSelect(evt, option) {
12081 var value, self = this;
12082 // should not be possible to trigger a option under a disabled optgroup
12083 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
12084 return;
12085 }
12086 if (option.classList.contains('create')) {
12087 self.createItem(null, () => {
12088 if (self.settings.closeAfterSelect) {
12089 self.close();
12090 }
12091 else if (self.settings.clearAfterSelect) {
12092 self.setTextboxValue();
12093 }
12094 });
12095 }
12096 else {
12097 value = option.dataset.value;
12098 if (typeof value !== 'undefined') {
12099 self.isDropdownContentStale = self.settings.hideSelected;
12100 self.addItem(value);
12101 if (self.settings.closeAfterSelect) {
12102 self.close();
12103 }
12104 else if (self.settings.clearAfterSelect) {
12105 self.setTextboxValue();
12106 }
12107 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
12108 self.setActiveOption(option);
12109 }
12110 }
12111 }
12112 }
12113 /**
12114 * Return true if the given option can be selected
12115 *
12116 */
12117 canSelect(option) {
12118 if (this.isOpen && option && this.dropdown_content.contains(option)) {
12119 return true;
12120 }
12121 return false;
12122 }
12123 /**
12124 * Triggered when the user clicks on an item
12125 * that has been selected.
12126 *
12127 */
12128 onItemSelect(evt, item) {
12129 var self = this;
12130 if (!self.isLocked && self.settings.mode === 'multi') {
12131 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
12132 self.setActiveItem(item, evt);
12133 return true;
12134 }
12135 return false;
12136 }
12137 /**
12138 * Determines whether or not to invoke
12139 * the user-provided option provider / loader
12140 *
12141 * Note, there is a subtle difference between
12142 * this.canLoad() and this.settings.shouldLoad();
12143 *
12144 * - settings.shouldLoad() is a user-input validator.
12145 * When false is returned, the not_loading template
12146 * will be added to the dropdown
12147 *
12148 * - canLoad() is lower level validator that checks
12149 * the Tom Select instance. There is no inherent user
12150 * feedback when canLoad returns false
12151 *
12152 */
12153 canLoad(value) {
12154 if (!this.settings.load)
12155 return false;
12156 if (this.loadedSearches.hasOwnProperty(value))
12157 return false;
12158 return true;
12159 }
12160 /**
12161 * Invokes the user-provided option provider / loader.
12162 *
12163 */
12164 load(value) {
12165 const self = this;
12166 if (!self.canLoad(value))
12167 return;
12168 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
12169 self.loading++;
12170 const callback = self.loadCallback.bind(self);
12171 self.settings.load.call(self, value, callback);
12172 }
12173 /**
12174 * Invoked by the user-provided option provider
12175 *
12176 */
12177 loadCallback(options, optgroups) {
12178 const self = this;
12179 self.loading = Math.max(self.loading - 1, 0);
12180 self.isDropdownContentStale = true;
12181 self.clearActiveOption(); // when new results load, focus should be on first option
12182 self.setupOptions(options, optgroups);
12183 self.refreshOptions(self.isFocused && !self.isInputHidden);
12184 if (!self.loading) {
12185 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
12186 }
12187 self.trigger('load', options, optgroups);
12188 }
12189 preload() {
12190 var classList = this.wrapper.classList;
12191 if (classList.contains('preloaded'))
12192 return;
12193 classList.add('preloaded');
12194 this.load('');
12195 }
12196 /**
12197 * Sets the input field of the control to the specified value.
12198 *
12199 */
12200 setTextboxValue(value = '') {
12201 var input = this.control_input;
12202 var changed = input.value !== value;
12203 if (changed) {
12204 input.value = value;
12205 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
12206 this.lastValue = value;
12207 }
12208 }
12209 /**
12210 * Returns the value of the control. If multiple items
12211 * can be selected (e.g. <select multiple>), this returns
12212 * an array. If only one item can be selected, this
12213 * returns a string.
12214 *
12215 */
12216 getValue() {
12217 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
12218 return this.items;
12219 }
12220 return this.items.join(this.settings.delimiter);
12221 }
12222 /**
12223 * Resets the selected items to the given value.
12224 *
12225 */
12226 setValue(value, silent) {
12227 var events = silent ? [] : ['change'];
12228 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12229 this.clear(silent);
12230 this.addItems(value, silent);
12231 });
12232 }
12233 /**
12234 * Resets the number of max items to the given value
12235 *
12236 */
12237 setMaxItems(value) {
12238 if (value === 0)
12239 value = null; //reset to unlimited items.
12240 this.settings.maxItems = value;
12241 this.refreshState();
12242 }
12243 /**
12244 * Sets the selected item.
12245 *
12246 */
12247 setActiveItem(item, e) {
12248 var self = this;
12249 var eventName;
12250 var i, begin, end, swap;
12251 var last;
12252 if (self.settings.mode === 'single')
12253 return;
12254 // clear the active selection
12255 if (!item) {
12256 self.clearActiveItems();
12257 if (self.isFocused) {
12258 self.inputState();
12259 }
12260 return;
12261 }
12262 // modify selection
12263 eventName = e && e.type.toLowerCase();
12264 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
12265 last = self.getLastActive();
12266 begin = Array.prototype.indexOf.call(self.control.children, last);
12267 end = Array.prototype.indexOf.call(self.control.children, item);
12268 if (begin > end) {
12269 swap = begin;
12270 begin = end;
12271 end = swap;
12272 }
12273 for (i = begin; i <= end; i++) {
12274 item = self.control.children[i];
12275 if (self.activeItems.indexOf(item) === -1) {
12276 self.setActiveItemClass(item);
12277 }
12278 }
12279 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
12280 }
12281 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))) {
12282 if (item.classList.contains('active')) {
12283 self.removeActiveItem(item);
12284 }
12285 else {
12286 self.setActiveItemClass(item);
12287 }
12288 }
12289 else {
12290 self.clearActiveItems();
12291 self.setActiveItemClass(item);
12292 }
12293 // ensure control has focus
12294 self.inputState();
12295 if (!self.isFocused) {
12296 self.focus();
12297 }
12298 }
12299 /**
12300 * Set the active and last-active classes
12301 *
12302 */
12303 setActiveItemClass(item) {
12304 const self = this;
12305 const last_active = self.control.querySelector('.last-active');
12306 if (last_active)
12307 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
12308 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
12309 self.trigger('item_select', item);
12310 if (self.activeItems.indexOf(item) == -1) {
12311 self.activeItems.push(item);
12312 }
12313 }
12314 /**
12315 * Remove active item
12316 *
12317 */
12318 removeActiveItem(item) {
12319 var idx = this.activeItems.indexOf(item);
12320 this.activeItems.splice(idx, 1);
12321 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12322 }
12323 /**
12324 * Clears all the active items
12325 *
12326 */
12327 clearActiveItems() {
12328 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
12329 this.activeItems = [];
12330 }
12331 /**
12332 * Sets the selected item in the dropdown menu
12333 * of available options.
12334 *
12335 */
12336 setActiveOption(option, scroll = true) {
12337 if (option === this.activeOption) {
12338 return;
12339 }
12340 this.clearActiveOption();
12341 if (!option)
12342 return;
12343 this.activeOption = option;
12344 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
12345 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
12346 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
12347 if (scroll)
12348 this.scrollToOption(option);
12349 }
12350 /**
12351 * Sets the dropdown_content scrollTop to display the option
12352 *
12353 */
12354 scrollToOption(option, behavior) {
12355 if (!option)
12356 return;
12357 const content = this.dropdown_content;
12358 const height_menu = content.clientHeight;
12359 const scrollTop = content.scrollTop || 0;
12360 const height_item = option.offsetHeight;
12361 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
12362 if (y + height_item > height_menu + scrollTop) {
12363 this.scroll(y - height_menu + height_item, behavior);
12364 }
12365 else if (y < scrollTop) {
12366 this.scroll(y, behavior);
12367 }
12368 }
12369 /**
12370 * Scroll the dropdown to the given position
12371 *
12372 */
12373 scroll(scrollTop, behavior) {
12374 const content = this.dropdown_content;
12375 if (behavior) {
12376 content.style.scrollBehavior = behavior;
12377 }
12378 content.scrollTop = scrollTop;
12379 content.style.scrollBehavior = '';
12380 }
12381 /**
12382 * Clears the active option
12383 *
12384 */
12385 clearActiveOption() {
12386 if (this.activeOption) {
12387 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
12388 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
12389 }
12390 this.activeOption = null;
12391 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
12392 }
12393 /**
12394 * Selects all items (CTRL + A).
12395 */
12396 selectAll() {
12397 const self = this;
12398 if (self.settings.mode === 'single')
12399 return;
12400 const activeItems = self.controlChildren();
12401 if (!activeItems.length)
12402 return;
12403 self.inputState();
12404 self.close();
12405 self.activeItems = activeItems;
12406 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
12407 self.setActiveItemClass(item);
12408 });
12409 }
12410 /**
12411 * Determines if the control_input should be in a hidden or visible state
12412 *
12413 */
12414 inputState() {
12415 var self = this;
12416 if (!self.control.contains(self.control_input))
12417 return;
12418 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
12419 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
12420 self.setTextboxValue();
12421 self.isInputHidden = true;
12422 }
12423 else {
12424 if (self.settings.hidePlaceholder && self.items.length > 0) {
12425 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
12426 }
12427 self.isInputHidden = false;
12428 }
12429 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
12430 }
12431 /**
12432 * Get the input value
12433 */
12434 inputValue() {
12435 return this.control_input.value.trim();
12436 }
12437 /**
12438 * Gives the control focus.
12439 */
12440 focus() {
12441 var self = this;
12442 if (self.isDisabled || self.isReadOnly)
12443 return;
12444 self.ignoreFocus = true;
12445 const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node;
12446 focusTarget.focus();
12447 setTimeout(() => {
12448 self.ignoreFocus = false;
12449 // Fix https://github.com/orchidjs/tom-select/issues/806
12450 // Only proceed if this instance's element is still the active element. If Edge autofill
12451 // (or anything else) has moved focus to a different element in the interim, calling
12452 // onFocus() here would steal focus back and restart the cascade loop.
12453 const root = focusTarget.getRootNode();
12454 if (root.activeElement !== focusTarget) {
12455 return;
12456 }
12457 this.onFocus();
12458 }, 0);
12459 }
12460 /**
12461 * Forces the control out of focus.
12462 *
12463 */
12464 blur() {
12465 this.focus_node.blur();
12466 this.onBlur();
12467 }
12468 /**
12469 * Returns a function that scores an object
12470 * to show how good of a match it is to the
12471 * provided query.
12472 *
12473 * @return {function}
12474 */
12475 getScoreFunction(query) {
12476 return this.sifter.getScoreFunction(query, this.getSearchOptions());
12477 }
12478 /**
12479 * Returns search options for sifter (the system
12480 * for scoring and sorting results).
12481 *
12482 * @see https://github.com/orchidjs/sifter.js
12483 * @return {object}
12484 */
12485 getSearchOptions() {
12486 var settings = this.settings;
12487 var sort = settings.sortField;
12488 if (typeof settings.sortField === 'string') {
12489 sort = [{ field: settings.sortField }];
12490 }
12491 return {
12492 fields: settings.searchField,
12493 conjunction: settings.searchConjunction,
12494 sort: sort,
12495 nesting: settings.nesting
12496 };
12497 }
12498 /**
12499 * Searches through available options and returns
12500 * a sorted array of matches.
12501 *
12502 */
12503 search(query) {
12504 var result, calculateScore;
12505 var self = this;
12506 var options = this.getSearchOptions();
12507 // validate user-provided result scoring function
12508 if (self.settings.score) {
12509 calculateScore = self.settings.score.call(self, query);
12510 if (typeof calculateScore !== 'function') {
12511 throw new Error('Tom Select "score" setting must be a function that returns a function');
12512 }
12513 }
12514 // perform search
12515 if (self.isDropdownContentStale || query !== self.lastQuery) {
12516 self.lastQuery = query;
12517 // temp fix for https://github.com/orchidjs/tom-select/issues/987
12518 // UI crashed when more than 30 same chars in a row, prevent search and return empt result
12519 if (/(.)\1{15,}/.test(query)) {
12520 query = '';
12521 }
12522 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
12523 self.currentResults = result;
12524 }
12525 else {
12526 result = Object.assign({}, self.currentResults);
12527 }
12528 // filter out selected items
12529 if (self.settings.hideSelected) {
12530 result.items = result.items.filter((item) => {
12531 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
12532 return !(hashed !== null && self.items.indexOf(hashed) !== -1);
12533 });
12534 }
12535 return result;
12536 }
12537 /**
12538 * Refreshes the list of available options shown
12539 * in the autocomplete dropdown menu.
12540 *
12541 */
12542 refreshOptions(triggerDropdown = true) {
12543 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
12544 var create;
12545 const groups = {};
12546 const groups_order = [];
12547 var self = this;
12548 var query = self.inputValue();
12549 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
12550 var results = self.search(query);
12551 var active_option = null;
12552 var show_dropdown = self.settings.shouldOpen || false;
12553 var dropdown_content = self.dropdown_content;
12554 if (same_query) {
12555 active_option = self.activeOption;
12556 if (active_option) {
12557 active_group = active_option.closest('[data-group]');
12558 }
12559 }
12560 // build markup
12561 n = results.items.length;
12562 if (typeof self.settings.maxOptions === 'number') {
12563 n = Math.min(n, self.settings.maxOptions);
12564 }
12565 if (n > 0) {
12566 show_dropdown = true;
12567 }
12568 // get fragment for group and the position of the group in group_order
12569 const getGroupFragment = (optgroup, order) => {
12570 let group_order_i = groups[optgroup];
12571 if (group_order_i !== undefined) {
12572 let order_group = groups_order[group_order_i];
12573 if (order_group !== undefined) {
12574 return [group_order_i, order_group.fragment];
12575 }
12576 }
12577 let group_fragment = document.createDocumentFragment();
12578 group_order_i = groups_order.length;
12579 groups_order.push({ fragment: group_fragment, order, optgroup });
12580 return [group_order_i, group_fragment];
12581 };
12582 // render and group available options individually
12583 for (i = 0; i < n; i++) {
12584 // get option dom element
12585 let item = results.items[i];
12586 if (!item)
12587 continue;
12588 let opt_value = item.id;
12589 let option = self.options[opt_value];
12590 if (option === undefined)
12591 continue;
12592 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12593 let option_el = self.getOption(opt_hash, true);
12594 // toggle 'selected' class
12595 if (!self.settings.hideSelected) {
12596 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12597 }
12598 optgroup = option[self.settings.optgroupField] || '';
12599 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12600 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12601 optgroup = optgroups[j];
12602 let order = option.$order;
12603 let self_optgroup = self.optgroups[optgroup];
12604 if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') {
12605 var regGroup;
12606 if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) {
12607 self.registerOptionGroup(regGroup);
12608 }
12609 }
12610 self_optgroup = self.optgroups[optgroup];
12611 if (self_optgroup === undefined) {
12612 optgroup = '';
12613 }
12614 else {
12615 order = self_optgroup.$order;
12616 }
12617 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12618 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12619 if (j > 0) {
12620 option_el = option_el.cloneNode(true);
12621 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12622 option_el.classList.add('ts-cloned');
12623 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12624 // make sure we keep the activeOption in the same group
12625 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12626 if (active_group && active_group.dataset.group === optgroup.toString()) {
12627 active_option = option_el;
12628 }
12629 }
12630 }
12631 group_fragment.appendChild(option_el);
12632 if (optgroup != '') {
12633 groups[optgroup] = group_order_i;
12634 }
12635 }
12636 }
12637 // sort optgroups
12638 if (self.settings.lockOptgroupOrder) {
12639 groups_order.sort((a, b) => {
12640 return a.order - b.order;
12641 });
12642 }
12643 // render optgroup headers & join groups
12644 html = document.createDocumentFragment();
12645 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12646 let group_fragment = group_order.fragment;
12647 let optgroup = group_order.optgroup;
12648 if (!group_fragment || !group_fragment.children.length)
12649 return;
12650 let group_heading = self.optgroups[optgroup];
12651 if (group_heading !== undefined) {
12652 let group_options = document.createDocumentFragment();
12653 let header = self.render('optgroup_header', group_heading);
12654 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12655 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12656 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12657 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12658 }
12659 else {
12660 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12661 }
12662 });
12663 dropdown_content.innerHTML = '';
12664 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12665 self.isDropdownContentStale = false;
12666 // highlight matching terms inline
12667 if (self.settings.highlight) {
12668 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12669 if (results.query.length && results.tokens.length) {
12670 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12671 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12672 });
12673 }
12674 }
12675 // helper method for adding templates to dropdown
12676 var add_template = (template) => {
12677 let content = self.render(template, { input: query });
12678 if (content) {
12679 show_dropdown = true;
12680 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12681 }
12682 return content;
12683 };
12684 // add loading message
12685 if (self.loading) {
12686 add_template('loading');
12687 // invalid query
12688 }
12689 else if (!self.settings.shouldLoad.call(self, query)) {
12690 add_template('not_loading');
12691 // add no_results message
12692 }
12693 else if (results.items.length === 0) {
12694 add_template('no_results');
12695 }
12696 // add create option
12697 has_create_option = self.canCreate(query);
12698 if (has_create_option) {
12699 create = add_template('option_create');
12700 }
12701 // activate
12702 self.hasOptions = results.items.length > 0 || has_create_option;
12703 if (show_dropdown) {
12704 if (results.items.length > 0) {
12705 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12706 active_option = self.getOption(self.items[0]);
12707 }
12708 if (!dropdown_content.contains(active_option)) {
12709 let active_index = 0;
12710 if (create && !self.settings.addPrecedence) {
12711 active_index = 1;
12712 }
12713 active_option = self.selectable()[active_index];
12714 }
12715 }
12716 else if (create) {
12717 active_option = create;
12718 }
12719 if (triggerDropdown && !self.isOpen) {
12720 self.open();
12721 self.scrollToOption(active_option, 'auto');
12722 }
12723 self.setActiveOption(active_option);
12724 }
12725 else {
12726 self.clearActiveOption();
12727 if (triggerDropdown && self.isOpen) {
12728 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12729 }
12730 }
12731 }
12732 /**
12733 * Return list of selectable options
12734 *
12735 */
12736 selectable() {
12737 return this.dropdown_content.querySelectorAll('[data-selectable]');
12738 }
12739 /**
12740 * Adds an available option. If it already exists,
12741 * nothing will happen. Note: this does not refresh
12742 * the options list dropdown (use `refreshOptions`
12743 * for that).
12744 *
12745 * Usage:
12746 *
12747 * this.addOption(data)
12748 *
12749 */
12750 addOption(data, user_created = false) {
12751 const self = this;
12752 // @deprecated 1.7.7
12753 // use addOptions( array, user_created ) for adding multiple options
12754 if (Array.isArray(data)) {
12755 self.addOptions(data, user_created);
12756 return false;
12757 }
12758 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12759 if (key === null || self.options.hasOwnProperty(key)) {
12760 self.updateOption(data[self.settings.valueField], data);
12761 return false;
12762 }
12763 data.$order = data.$order || ++self.order;
12764 data.$id = self.inputId + '-opt-' + data.$order;
12765 self.options[key] = data;
12766 self.isDropdownContentStale = true;
12767 if (user_created) {
12768 self.userOptions[key] = user_created;
12769 self.trigger('option_add', key, data);
12770 }
12771 return key;
12772 }
12773 /**
12774 * Add multiple options
12775 *
12776 */
12777 addOptions(data, user_created = false) {
12778 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12779 this.addOption(dat, user_created);
12780 });
12781 }
12782 /**
12783 * @deprecated 1.7.7
12784 */
12785 registerOption(data) {
12786 return this.addOption(data);
12787 }
12788 /**
12789 * Registers an option group to the pool of option groups.
12790 *
12791 * @return {boolean|string}
12792 */
12793 registerOptionGroup(data) {
12794 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12795 if (key === null)
12796 return false;
12797 data.$order = data.$order || ++this.order;
12798 this.optgroups[key] = data;
12799 return key;
12800 }
12801 /**
12802 * Registers a new optgroup for options
12803 * to be bucketed into.
12804 *
12805 */
12806 addOptionGroup(id, data) {
12807 var hashed_id;
12808 data[this.settings.optgroupValueField] = id;
12809 if (hashed_id = this.registerOptionGroup(data)) {
12810 this.trigger('optgroup_add', hashed_id, data);
12811 }
12812 }
12813 /**
12814 * Removes an existing option group.
12815 *
12816 */
12817 removeOptionGroup(id) {
12818 if (this.optgroups.hasOwnProperty(id)) {
12819 delete this.optgroups[id];
12820 this.clearCache();
12821 this.trigger('optgroup_remove', id);
12822 }
12823 }
12824 /**
12825 * Clears all existing option groups.
12826 */
12827 clearOptionGroups() {
12828 this.optgroups = {};
12829 this.clearCache();
12830 this.trigger('optgroup_clear');
12831 }
12832 /**
12833 * Updates an option available for selection. If
12834 * it is visible in the selected items or options
12835 * dropdown, it will be re-rendered automatically.
12836 *
12837 */
12838 updateOption(value, data) {
12839 const self = this;
12840 var item_new;
12841 var index_item;
12842 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12843 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12844 // sanity checks
12845 if (value_old === null)
12846 return;
12847 const data_old = self.options[value_old];
12848 if (data_old == undefined)
12849 return;
12850 if (typeof value_new !== 'string')
12851 throw new Error('Value must be set in option data');
12852 const option = self.getOption(value_old);
12853 const item = self.getItem(value_old);
12854 data.$order = data.$order || data_old.$order;
12855 delete self.options[value_old];
12856 // invalidate render cache
12857 // don't remove existing node yet, we'll remove it after replacing it
12858 self.uncacheValue(value_new);
12859 self.options[value_new] = data;
12860 // update the option if it's in the dropdown
12861 if (option) {
12862 if (self.dropdown_content.contains(option)) {
12863 const option_new = self._render('option', data);
12864 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12865 if (self.activeOption === option) {
12866 self.setActiveOption(option_new);
12867 }
12868 }
12869 option.remove();
12870 }
12871 // update the item if we have one
12872 if (item) {
12873 index_item = self.items.indexOf(value_old);
12874 if (index_item !== -1) {
12875 self.items.splice(index_item, 1, value_new);
12876 }
12877 item_new = self._render('item', data);
12878 if (item.classList.contains('active'))
12879 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12880 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12881 }
12882 // we might have updated the sortField
12883 self.isDropdownContentStale = true;
12884 }
12885 /**
12886 * Removes a single option.
12887 *
12888 */
12889 removeOption(value, silent) {
12890 const self = this;
12891 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12892 self.uncacheValue(value);
12893 delete self.userOptions[value];
12894 delete self.options[value];
12895 self.isDropdownContentStale = true;
12896 self.trigger('option_remove', value);
12897 self.removeItem(value, silent);
12898 }
12899 /**
12900 * Clears all options.
12901 */
12902 clearOptions(filter) {
12903 const boundFilter = (filter || this.clearFilter).bind(this);
12904 this.loadedSearches = {};
12905 this.userOptions = {};
12906 this.clearCache();
12907 const selected = {};
12908 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12909 if (boundFilter(option, key)) {
12910 selected[key] = option;
12911 }
12912 });
12913 this.options = this.sifter.items = selected;
12914 this.isDropdownContentStale = true;
12915 this.trigger('option_clear');
12916 }
12917 /**
12918 * Used by clearOptions() to decide whether or not an option should be removed
12919 * Return true to keep an option, false to remove
12920 *
12921 */
12922 clearFilter(option, value) {
12923 if (this.items.indexOf(value) >= 0) {
12924 return true;
12925 }
12926 return false;
12927 }
12928 /**
12929 * Returns the dom element of the option
12930 * matching the given value.
12931 *
12932 */
12933 getOption(value, create = false) {
12934 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12935 if (hashed === null)
12936 return null;
12937 const option = this.options[hashed];
12938 if (option != undefined) {
12939 if (option.$div) {
12940 return option.$div;
12941 }
12942 if (create) {
12943 return this._render('option', option);
12944 }
12945 }
12946 return null;
12947 }
12948 /**
12949 * Returns the dom element of the next or previous dom element of the same type
12950 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12951 *
12952 */
12953 getAdjacent(option, direction, type = 'option') {
12954 var self = this, all;
12955 if (!option) {
12956 return null;
12957 }
12958 if (type == 'item') {
12959 all = self.controlChildren();
12960 }
12961 else {
12962 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12963 }
12964 for (let i = 0; i < all.length; i++) {
12965 if (all[i] != option) {
12966 continue;
12967 }
12968 if (direction > 0) {
12969 return all[i + 1];
12970 }
12971 return all[i - 1];
12972 }
12973 return null;
12974 }
12975 /**
12976 * Returns the dom element of the item
12977 * matching the given value.
12978 *
12979 */
12980 getItem(item) {
12981 if (typeof item == 'object') {
12982 return item;
12983 }
12984 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12985 return value !== null
12986 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12987 : null;
12988 }
12989 /**
12990 * "Selects" multiple items at once. Adds them to the list
12991 * at the current caret position.
12992 *
12993 */
12994 addItems(values, silent) {
12995 var self = this;
12996 var items = Array.isArray(values) ? values : [values];
12997 items = items.filter(x => self.items.indexOf(x) === -1);
12998 const last_item = items[items.length - 1];
12999 items.forEach(item => {
13000 self.isPending = (item !== last_item);
13001 self.addItem(item, silent);
13002 });
13003 }
13004 /**
13005 * "Selects" an item. Adds it to the list
13006 * at the current caret position.
13007 *
13008 */
13009 addItem(value, silent) {
13010 var events = silent ? [] : ['change', 'dropdown_close'];
13011 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
13012 var item, wasFull;
13013 const self = this;
13014 const inputMode = self.settings.mode;
13015 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
13016 if (hashed && self.items.indexOf(hashed) !== -1) {
13017 if (inputMode === 'single') {
13018 self.close();
13019 }
13020 if (inputMode === 'single' || !self.settings.duplicates) {
13021 return;
13022 }
13023 }
13024 if (hashed === null || !self.options.hasOwnProperty(hashed))
13025 return;
13026 if (inputMode === 'single')
13027 self.clear(silent);
13028 if (inputMode === 'multi' && self.isFull())
13029 return;
13030 item = self._render('item', self.options[hashed]);
13031 if (self.control.contains(item)) { // duplicates
13032 item = item.cloneNode(true);
13033 }
13034 wasFull = self.isFull();
13035 self.items.splice(self.caretPos, 0, hashed);
13036 self.insertAtCaret(item);
13037 if (self.isSetup) {
13038 // update menu / remove the option (if this is not one item being added as part of series)
13039 if (!self.isPending && self.settings.hideSelected) {
13040 let option = self.getOption(hashed);
13041 let next = self.getAdjacent(option, 1);
13042 if (next) {
13043 self.setActiveOption(next);
13044 }
13045 }
13046 //remove input value when enabled
13047 if (self.settings.clearAfterSelect) {
13048 self.setTextboxValue();
13049 }
13050 // refreshOptions after setActiveOption(),
13051 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
13052 if (!self.isPending && !self.settings.closeAfterSelect) {
13053 self.refreshOptions(self.isFocused && inputMode !== 'single');
13054 }
13055 // hide the menu if the maximum number of items have been selected or no options are left
13056 if (self.settings.closeAfterSelect != false && self.isFull()) {
13057 self.close();
13058 }
13059 else if (!self.isPending) {
13060 self.positionDropdown();
13061 }
13062 self.trigger('item_add', hashed, item);
13063 if (!self.isPending) {
13064 self.updateOriginalInput({ silent: silent });
13065 }
13066 }
13067 if (!self.isPending || (!wasFull && self.isFull())) {
13068 self.inputState();
13069 self.refreshState();
13070 }
13071 });
13072 }
13073 /**
13074 * Removes the selected item matching
13075 * the provided value.
13076 *
13077 */
13078 removeItem(item = null, silent) {
13079 const self = this;
13080 item = self.getItem(item);
13081 if (!item)
13082 return;
13083 var i, idx;
13084 const value = item.dataset.value;
13085 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
13086 item.remove();
13087 if (item.classList.contains('active')) {
13088 idx = self.activeItems.indexOf(item);
13089 self.activeItems.splice(idx, 1);
13090 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
13091 }
13092 self.items.splice(i, 1);
13093 self.isDropdownContentStale = true;
13094 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
13095 self.removeOption(value, silent);
13096 }
13097 if (i < self.caretPos) {
13098 self.setCaret(self.caretPos - 1);
13099 }
13100 self.updateOriginalInput({ silent: silent });
13101 self.refreshState();
13102 self.positionDropdown();
13103 self.trigger('item_remove', value, item);
13104 }
13105 /**
13106 * Invokes the `create` method provided in the
13107 * TomSelect options that should provide the data
13108 * for the new item, given the user input.
13109 *
13110 * Once this completes, it will be added
13111 * to the item list.
13112 *
13113 */
13114 createItem(input = null, callback = () => { }) {
13115 // triggerDropdown parameter @deprecated 2.1.1
13116 if (arguments.length === 3) {
13117 callback = arguments[2];
13118 }
13119 if (typeof callback != 'function') {
13120 callback = () => { };
13121 }
13122 var self = this;
13123 var caret = self.caretPos;
13124 var output;
13125 input = input || self.inputValue();
13126 if (!self.canCreate(input)) {
13127 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input);
13128 if (hash) {
13129 if (this.options[input]) {
13130 self.addItem(input);
13131 }
13132 }
13133 callback();
13134 return false;
13135 }
13136 self.lock();
13137 var created = false;
13138 var create = (data) => {
13139 self.unlock();
13140 if (!data || typeof data !== 'object')
13141 return callback();
13142 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
13143 if (typeof value !== 'string') {
13144 return callback();
13145 }
13146 self.setTextboxValue();
13147 self.addOption(data, true);
13148 self.setCaret(caret);
13149 self.addItem(value);
13150 callback(data);
13151 created = true;
13152 };
13153 if (typeof self.settings.create === 'function') {
13154 output = self.settings.create.call(this, input, create);
13155 }
13156 else {
13157 output = {
13158 [self.settings.labelField]: input,
13159 [self.settings.valueField]: input,
13160 };
13161 }
13162 if (!created) {
13163 create(output);
13164 }
13165 return true;
13166 }
13167 /**
13168 * Re-renders the selected item lists.
13169 */
13170 refreshItems() {
13171 var self = this;
13172 self.isDropdownContentStale = true;
13173 if (self.isSetup) {
13174 self.addItems(self.items);
13175 }
13176 self.updateOriginalInput();
13177 self.refreshState();
13178 }
13179 /**
13180 * Updates all state-dependent attributes
13181 * and CSS classes.
13182 */
13183 refreshState() {
13184 const self = this;
13185 self.refreshValidityState();
13186 const isFull = self.isFull();
13187 const isLocked = self.isLocked;
13188 self.wrapper.classList.toggle('rtl', self.rtl);
13189 const wrap_classList = self.wrapper.classList;
13190 wrap_classList.toggle('focus', self.isFocused);
13191 wrap_classList.toggle('disabled', self.isDisabled);
13192 wrap_classList.toggle('readonly', self.isReadOnly);
13193 wrap_classList.toggle('required', self.isRequired);
13194 wrap_classList.toggle('invalid', !self.isValid);
13195 wrap_classList.toggle('locked', isLocked);
13196 wrap_classList.toggle('full', isFull);
13197 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
13198 wrap_classList.toggle('dropdown-active', self.isOpen);
13199 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
13200 wrap_classList.toggle('has-items', self.items.length > 0);
13201 }
13202 /**
13203 * Update the `required` attribute of both input and control input.
13204 *
13205 * The `required` property needs to be activated on the control input
13206 * for the error to be displayed at the right place. `required` also
13207 * needs to be temporarily deactivated on the input since the input is
13208 * hidden and can't show errors.
13209 */
13210 refreshValidityState() {
13211 var self = this;
13212 if (!self.input.validity) {
13213 return;
13214 }
13215 self.isValid = self.input.validity.valid;
13216 self.isInvalid = !self.isValid;
13217 }
13218 /**
13219 * Determines whether or not more items can be added
13220 * to the control without exceeding the user-defined maximum.
13221 *
13222 * @returns {boolean}
13223 */
13224 isFull() {
13225 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
13226 }
13227 /**
13228 * Refreshes the original <select> or <input>
13229 * element to reflect the current state.
13230 *
13231 */
13232 updateOriginalInput(opts = {}) {
13233 const self = this;
13234 var option, label;
13235 const empty_option = self.input.querySelector('option[value=""]');
13236 if (self.is_select_tag) {
13237 const selected = [];
13238 const has_selected = self.input.querySelectorAll('option:checked').length;
13239 function AddSelected(option_el, value, label) {
13240 if (!option_el) {
13241 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>');
13242 }
13243 // don't move empty option from top of list
13244 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
13245 if (option_el != empty_option) {
13246 self.input.append(option_el);
13247 }
13248 selected.push(option_el);
13249 // marking empty option as selected can break validation
13250 // fixes https://github.com/orchidjs/tom-select/issues/303
13251 if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') {
13252 option_el.selected = true;
13253 }
13254 return option_el;
13255 }
13256 // unselect all selected options
13257 self.input.querySelectorAll('option:checked').forEach((option_el) => {
13258 option_el.selected = false;
13259 });
13260 // nothing selected?
13261 if (self.items.length == 0 && self.settings.mode == 'single') {
13262 AddSelected(empty_option, "", "");
13263 // order selected <option> tags for values in self.items
13264 }
13265 else {
13266 self.items.forEach((value) => {
13267 option = self.options[value];
13268 label = option[self.settings.labelField] || '';
13269 if (selected.includes(option.$option)) {
13270 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
13271 AddSelected(reuse_opt, value, label);
13272 }
13273 else {
13274 option.$option = AddSelected(option.$option, value, label);
13275 }
13276 });
13277 }
13278 }
13279 else {
13280 self.input.value = self.getValue();
13281 }
13282 if (self.isSetup) {
13283 if (!opts.silent) {
13284 self.trigger('change', self.getValue());
13285 }
13286 }
13287 }
13288 /**
13289 * Shows the autocomplete dropdown containing
13290 * the available options.
13291 */
13292 open() {
13293 var self = this;
13294 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
13295 return;
13296 self.isOpen = true;
13297 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
13298 self.refreshState();
13299 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
13300 self.positionDropdown();
13301 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
13302 self.focus();
13303 self.trigger('dropdown_open', self.dropdown);
13304 }
13305 /**
13306 * Closes the autocomplete dropdown menu.
13307 */
13308 close(setTextboxValue = true) {
13309 var self = this;
13310 var trigger = self.isOpen;
13311 if (setTextboxValue) {
13312 // before blur() to prevent form onchange event
13313 self.setTextboxValue();
13314 if (self.settings.mode === 'single' && self.items.length) {
13315 self.inputState();
13316 }
13317 }
13318 self.isOpen = false;
13319 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
13320 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
13321 if (self.settings.hideSelected) {
13322 self.clearActiveOption();
13323 }
13324 self.refreshState();
13325 if (trigger)
13326 self.trigger('dropdown_close', self.dropdown);
13327 }
13328 /**
13329 * Calculates and applies the appropriate
13330 * position of the dropdown if dropdownParent = 'body'.
13331 * Otherwise, position is determined by css
13332 */
13333 positionDropdown() {
13334 if (this.settings.dropdownParent !== 'body') {
13335 return;
13336 }
13337 var context = this.control;
13338 var rect = context.getBoundingClientRect();
13339 var top = context.offsetHeight + rect.top + window.scrollY;
13340 var left = rect.left + window.scrollX;
13341 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
13342 width: rect.width + 'px',
13343 top: top + 'px',
13344 left: left + 'px'
13345 });
13346 }
13347 /**
13348 * Resets / clears all selected items
13349 * from the control.
13350 *
13351 */
13352 clear(silent) {
13353 var self = this;
13354 if (!self.items.length)
13355 return;
13356 var items = self.controlChildren();
13357 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
13358 self.removeItem(item, true);
13359 });
13360 self.inputState();
13361 if (!silent)
13362 self.updateOriginalInput();
13363 self.trigger('clear');
13364 }
13365 /**
13366 * A helper method for inserting an element
13367 * at the current caret position.
13368 *
13369 */
13370 insertAtCaret(el) {
13371 const self = this;
13372 const caret = self.caretPos;
13373 const target = self.control;
13374 target.insertBefore(el, target.children[caret] || null);
13375 self.setCaret(caret + 1);
13376 }
13377 /**
13378 * Removes the current selected item(s).
13379 *
13380 */
13381 deleteSelection(e) {
13382 var direction, selection, caret, tail;
13383 var self = this;
13384 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
13385 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
13386 // determine items that will be removed
13387 const rm_items = [];
13388 if (self.activeItems.length) {
13389 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
13390 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
13391 if (direction > 0) {
13392 caret++;
13393 }
13394 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
13395 }
13396 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
13397 const items = self.controlChildren();
13398 let rm_item;
13399 if (direction < 0 && selection.start === 0 && selection.length === 0) {
13400 rm_item = items[self.caretPos - 1];
13401 }
13402 else if (direction > 0 && selection.start === self.inputValue().length) {
13403 rm_item = items[self.caretPos];
13404 }
13405 if (rm_item !== undefined) {
13406 rm_items.push(rm_item);
13407 }
13408 }
13409 if (!self.shouldDelete(rm_items, e)) {
13410 return false;
13411 }
13412 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
13413 // perform removal
13414 if (typeof caret !== 'undefined') {
13415 self.setCaret(caret);
13416 }
13417 while (rm_items.length) {
13418 self.removeItem(rm_items.pop());
13419 }
13420 self.inputState();
13421 self.positionDropdown();
13422 self.refreshOptions(false);
13423 return true;
13424 }
13425 /**
13426 * Return true if the items should be deleted
13427 */
13428 shouldDelete(items, evt) {
13429 const values = items.map(item => item.dataset.value);
13430 // allow the callback to abort
13431 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) {
13432 return false;
13433 }
13434 return true;
13435 }
13436 /**
13437 * Selects the previous / next item (depending on the `direction` argument).
13438 *
13439 * > 0 - right
13440 * < 0 - left
13441 *
13442 */
13443 advanceSelection(direction, e) {
13444 var last_active, adjacent, self = this;
13445 if (self.rtl)
13446 direction *= -1;
13447 if (self.inputValue().length)
13448 return;
13449 // add or remove to active items
13450 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)) {
13451 last_active = self.getLastActive(direction);
13452 if (last_active) {
13453 if (!last_active.classList.contains('active')) {
13454 adjacent = last_active;
13455 }
13456 else {
13457 adjacent = self.getAdjacent(last_active, direction, 'item');
13458 }
13459 // if no active item, get items adjacent to the control input
13460 }
13461 else if (direction > 0) {
13462 adjacent = self.control_input.nextElementSibling;
13463 }
13464 else {
13465 adjacent = self.control_input.previousElementSibling;
13466 }
13467 if (adjacent) {
13468 if (adjacent.classList.contains('active')) {
13469 self.removeActiveItem(last_active);
13470 }
13471 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
13472 }
13473 // move caret to the left or right
13474 }
13475 else {
13476 self.moveCaret(direction);
13477 }
13478 }
13479 moveCaret(direction) { }
13480 /**
13481 * Get the last active item
13482 *
13483 */
13484 getLastActive(direction) {
13485 let last_active = this.control.querySelector('.last-active');
13486 if (last_active) {
13487 return last_active;
13488 }
13489 var result = this.control.querySelectorAll('.active');
13490 if (result) {
13491 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
13492 }
13493 }
13494 /**
13495 * Moves the caret to the specified index.
13496 *
13497 * The input must be moved by leaving it in place and moving the
13498 * siblings, due to the fact that focus cannot be restored once lost
13499 * on mobile webkit devices
13500 *
13501 */
13502 setCaret(new_pos) {
13503 this.caretPos = this.items.length;
13504 }
13505 /**
13506 * Return list of item dom elements
13507 *
13508 */
13509 controlChildren() {
13510 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
13511 }
13512 /**
13513 * Disables user input on the control. Used while
13514 * items are being asynchronously created.
13515 */
13516 lock() {
13517 this.setLocked(true);
13518 }
13519 /**
13520 * Re-enables user input on the control.
13521 */
13522 unlock() {
13523 this.setLocked(false);
13524 }
13525 /**
13526 * Disable or enable user input on the control
13527 */
13528 setLocked(lock = this.isReadOnly || this.isDisabled) {
13529 this.isLocked = lock;
13530 this.refreshState();
13531 }
13532 /**
13533 * Disables user input on the control completely.
13534 * While disabled, it cannot receive focus.
13535 */
13536 disable() {
13537 this.setDisabled(true);
13538 this.close();
13539 }
13540 /**
13541 * Enables the control so that it can respond
13542 * to focus and user input.
13543 */
13544 enable() {
13545 this.setDisabled(false);
13546 }
13547 setDisabled(disabled) {
13548 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
13549 this.isDisabled = disabled;
13550 this.input.disabled = disabled;
13551 this.control_input.disabled = disabled;
13552 this.setLocked();
13553 }
13554 setReadOnly(isReadOnly) {
13555 this.isReadOnly = isReadOnly;
13556 this.input.readOnly = isReadOnly;
13557 this.control_input.readOnly = isReadOnly;
13558 this.setLocked();
13559 }
13560 /**
13561 * Completely destroys the control and
13562 * unbinds all event listeners so that it can
13563 * be garbage collected.
13564 */
13565 destroy() {
13566 var self = this;
13567 var revertSettings = self.revertSettings;
13568 self.trigger('destroy');
13569 self.off();
13570 self.wrapper.remove();
13571 self.dropdown.remove();
13572 self.input.innerHTML = revertSettings.innerHTML;
13573 self.input.tabIndex = revertSettings.tabIndex;
13574 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
13575 self._destroy();
13576 delete self.input.tomselect;
13577 }
13578 /**
13579 * A helper method for rendering "item" and
13580 * "option" templates, given the data.
13581 *
13582 */
13583 render(templateName, data) {
13584 var id, html;
13585 const self = this;
13586 if (typeof this.settings.render[templateName] !== 'function') {
13587 return null;
13588 }
13589 // render markup
13590 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
13591 if (!html) {
13592 return null;
13593 }
13594 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
13595 // add mandatory attributes
13596 if (templateName === 'option' || templateName === 'option_create') {
13597 if (data[self.settings.disabledField]) {
13598 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
13599 }
13600 else {
13601 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13602 }
13603 }
13604 else if (templateName === 'optgroup') {
13605 id = data.group[self.settings.optgroupValueField];
13606 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13607 if (data.group[self.settings.disabledField]) {
13608 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13609 }
13610 }
13611 if (templateName === 'option' || templateName === 'item') {
13612 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13613 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13614 // make sure we have some classes if a template is overwritten
13615 if (templateName === 'item') {
13616 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13617 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13618 }
13619 else {
13620 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13621 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13622 role: 'option',
13623 id: data.$id
13624 });
13625 // update cache
13626 data.$div = html;
13627 self.options[value] = data;
13628 }
13629 }
13630 return html;
13631 }
13632 /**
13633 * Type guarded rendering
13634 *
13635 */
13636 _render(templateName, data) {
13637 const html = this.render(templateName, data);
13638 if (html == null) {
13639 throw 'HTMLElement expected';
13640 }
13641 return html;
13642 }
13643 /**
13644 * Clears the render cache for a template. If
13645 * no template is given, clears all render
13646 * caches.
13647 *
13648 */
13649 clearCache() {
13650 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13651 if (option.$div) {
13652 option.$div.remove();
13653 delete option.$div;
13654 }
13655 });
13656 }
13657 /**
13658 * Removes a value from item and option caches
13659 *
13660 */
13661 uncacheValue(value) {
13662 const option_el = this.getOption(value);
13663 if (option_el)
13664 option_el.remove();
13665 }
13666 /**
13667 * Determines whether or not to display the
13668 * create item prompt, given a user input.
13669 *
13670 */
13671 canCreate(input) {
13672 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13673 }
13674 /**
13675 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13676 *
13677 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13678 *
13679 * });
13680 */
13681 hook(when, method, new_fn) {
13682 var self = this;
13683 var orig_method = self[method];
13684 self[method] = function () {
13685 var result, result_new;
13686 if (when === 'after') {
13687 result = orig_method.apply(self, arguments);
13688 }
13689 result_new = new_fn.apply(self, arguments);
13690 if (when === 'instead') {
13691 return result_new;
13692 }
13693 if (when === 'before') {
13694 result = orig_method.apply(self, arguments);
13695 }
13696 return result;
13697 };
13698 }
13699 }
13700 ;
13701 //# sourceMappingURL=tom-select.js.map
13702
13703 /***/ },
13704
13705 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13706 /*!***************************************************!*\
13707 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13708 \***************************************************/
13709 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13710
13711 "use strict";
13712 __webpack_require__.r(__webpack_exports__);
13713 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13714 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13715 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13716 /* harmony export */ append: () => (/* binding */ append),
13717 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13718 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13719 /* harmony export */ getId: () => (/* binding */ getId),
13720 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13721 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13722 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13723 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13724 /* harmony export */ iterate: () => (/* binding */ iterate),
13725 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13726 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13727 /* harmony export */ timeout: () => (/* binding */ timeout)
13728 /* harmony export */ });
13729 /**
13730 * Converts a scalar to its best string representation
13731 * for hash keys and HTML attribute values.
13732 *
13733 * Transformations:
13734 * 'str' -> 'str'
13735 * null -> ''
13736 * undefined -> ''
13737 * true -> '1'
13738 * false -> '0'
13739 * 0 -> '0'
13740 * 1 -> '1'
13741 *
13742 */
13743 const hash_key = (value) => {
13744 if (typeof value === 'undefined' || value === null)
13745 return null;
13746 return get_hash(value);
13747 };
13748 const get_hash = (value) => {
13749 if (typeof value === 'boolean')
13750 return value ? '1' : '0';
13751 return value + '';
13752 };
13753 /**
13754 * Escapes a string for use within HTML.
13755 *
13756 */
13757 const escape_html = (str) => {
13758 return (str + '')
13759 .replace(/&/g, '&amp;')
13760 .replace(/</g, '&lt;')
13761 .replace(/>/g, '&gt;')
13762 .replace(/"/g, '&quot;');
13763 };
13764 /**
13765 * use setTimeout if timeout > 0
13766 */
13767 const timeout = (fn, timeout) => {
13768 if (timeout > 0) {
13769 return window.setTimeout(fn, timeout);
13770 }
13771 fn.call(null);
13772 return null;
13773 };
13774 /**
13775 * Debounce the user provided load function
13776 *
13777 */
13778 const loadDebounce = (fn, delay) => {
13779 var timeout;
13780 return function (value, callback) {
13781 var self = this;
13782 if (timeout) {
13783 self.loading = Math.max(self.loading - 1, 0);
13784 clearTimeout(timeout);
13785 }
13786 timeout = setTimeout(function () {
13787 timeout = null;
13788 self.loadedSearches[value] = true;
13789 fn.call(self, value, callback);
13790 }, delay);
13791 };
13792 };
13793 /**
13794 * Debounce all fired events types listed in `types`
13795 * while executing the provided `fn`.
13796 *
13797 */
13798 const debounce_events = (self, types, fn) => {
13799 var type;
13800 var trigger = self.trigger;
13801 var event_args = {};
13802 // override trigger method
13803 self.trigger = function () {
13804 var type = arguments[0];
13805 if (types.indexOf(type) !== -1) {
13806 event_args[type] = arguments;
13807 }
13808 else {
13809 return trigger.apply(self, arguments);
13810 }
13811 };
13812 // invoke provided function
13813 fn.apply(self, []);
13814 self.trigger = trigger;
13815 // trigger queued events
13816 for (type of types) {
13817 if (type in event_args) {
13818 trigger.apply(self, event_args[type]);
13819 }
13820 }
13821 };
13822 /**
13823 * Determines the current selection within a text input control.
13824 * Returns an object containing:
13825 * - start
13826 * - length
13827 *
13828 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13829 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13830 */
13831 const getSelection = (input) => {
13832 return {
13833 start: input.selectionStart || 0,
13834 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13835 };
13836 };
13837 /**
13838 * Prevent default
13839 *
13840 */
13841 const preventDefault = (evt, stop = false) => {
13842 if (evt) {
13843 evt.preventDefault();
13844 if (stop) {
13845 evt.stopPropagation();
13846 }
13847 }
13848 };
13849 /**
13850 * Add event helper
13851 *
13852 */
13853 const addEvent = (target, type, callback, options) => {
13854 target.addEventListener(type, callback, options);
13855 };
13856 /**
13857 * Return true if the requested key is down
13858 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13859 * The current evt may not always set ( eg calling advanceSelection() )
13860 *
13861 */
13862 const isKeyDown = (key_name, evt) => {
13863 if (!evt) {
13864 return false;
13865 }
13866 if (!evt[key_name]) {
13867 return false;
13868 }
13869 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13870 if (count === 1) {
13871 return true;
13872 }
13873 return false;
13874 };
13875 /**
13876 * Get the id of an element
13877 * If the id attribute is not set, set the attribute with the given id
13878 *
13879 */
13880 const getId = (el, id) => {
13881 const existing_id = el.getAttribute('id');
13882 if (existing_id) {
13883 return existing_id;
13884 }
13885 el.setAttribute('id', id);
13886 return id;
13887 };
13888 /**
13889 * Returns a string with backslashes added before characters that need to be escaped.
13890 */
13891 const addSlashes = (str) => {
13892 return str.replace(/[\\"']/g, '\\$&');
13893 };
13894 /**
13895 *
13896 */
13897 const append = (parent, node) => {
13898 if (node)
13899 parent.append(node);
13900 };
13901 /**
13902 * Iterates over arrays and hashes.
13903 *
13904 * ```
13905 * iterate(this.items, function(item, id) {
13906 * // invoked for each item
13907 * });
13908 * ```
13909 *
13910 */
13911 const iterate = (object, callback) => {
13912 if (Array.isArray(object)) {
13913 object.forEach(callback);
13914 }
13915 else {
13916 for (var key in object) {
13917 if (object.hasOwnProperty(key)) {
13918 callback(object[key], key);
13919 }
13920 }
13921 }
13922 };
13923 //# sourceMappingURL=utils.js.map
13924
13925 /***/ },
13926
13927 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13928 /*!*****************************************************!*\
13929 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13930 \*****************************************************/
13931 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13932
13933 "use strict";
13934 __webpack_require__.r(__webpack_exports__);
13935 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13936 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13937 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13938 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13939 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13940 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13941 /* harmony export */ getDom: () => (/* binding */ getDom),
13942 /* harmony export */ getTail: () => (/* binding */ getTail),
13943 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13944 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13945 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13946 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13947 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13948 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13949 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13950 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13951 /* harmony export */ });
13952 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13953
13954 /**
13955 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13956 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13957 *
13958 * param query should be {}
13959 */
13960 const getDom = (query) => {
13961 if (query.jquery) {
13962 return query[0];
13963 }
13964 if (query instanceof HTMLElement) {
13965 return query;
13966 }
13967 if (isHtmlString(query)) {
13968 var tpl = document.createElement('template');
13969 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13970 return tpl.content.firstChild;
13971 }
13972 return document.querySelector(query);
13973 };
13974 const isHtmlString = (arg) => {
13975 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13976 return true;
13977 }
13978 return false;
13979 };
13980 const escapeQuery = (query) => {
13981 return query.replace(/['"\\]/g, '\\$&');
13982 };
13983 /**
13984 * Dispatch an event
13985 *
13986 */
13987 const triggerEvent = (dom_el, event_name) => {
13988 var event = document.createEvent('HTMLEvents');
13989 event.initEvent(event_name, true, false);
13990 dom_el.dispatchEvent(event);
13991 };
13992 /**
13993 * Apply CSS rules to a dom element
13994 *
13995 */
13996 const applyCSS = (dom_el, css) => {
13997 Object.assign(dom_el.style, css);
13998 };
13999 /**
14000 * Add css classes
14001 *
14002 */
14003 const addClasses = (elmts, ...classes) => {
14004 var norm_classes = classesArray(classes);
14005 elmts = castAsArray(elmts);
14006 elmts.map(el => {
14007 norm_classes.map(cls => {
14008 el.classList.add(cls);
14009 });
14010 });
14011 };
14012 /**
14013 * Remove css classes
14014 *
14015 */
14016 const removeClasses = (elmts, ...classes) => {
14017 var norm_classes = classesArray(classes);
14018 elmts = castAsArray(elmts);
14019 elmts.map(el => {
14020 norm_classes.map(cls => {
14021 el.classList.remove(cls);
14022 });
14023 });
14024 };
14025 /**
14026 * Return arguments
14027 *
14028 */
14029 const classesArray = (args) => {
14030 var classes = [];
14031 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
14032 if (typeof _classes === 'string') {
14033 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
14034 }
14035 if (Array.isArray(_classes)) {
14036 classes = classes.concat(_classes);
14037 }
14038 });
14039 return classes.filter(Boolean);
14040 };
14041 /**
14042 * Create an array from arg if it's not already an array
14043 *
14044 */
14045 const castAsArray = (arg) => {
14046 if (!Array.isArray(arg)) {
14047 arg = [arg];
14048 }
14049 return arg;
14050 };
14051 /**
14052 * Get the closest node to the evt.target matching the selector
14053 * Stops at wrapper
14054 *
14055 */
14056 const parentMatch = (target, selector, wrapper) => {
14057 if (wrapper && !wrapper.contains(target)) {
14058 return;
14059 }
14060 while (target && target.matches) {
14061 if (target.matches(selector)) {
14062 return target;
14063 }
14064 target = target.parentNode;
14065 }
14066 };
14067 /**
14068 * Get the first or last item from an array
14069 *
14070 * > 0 - right (last)
14071 * <= 0 - left (first)
14072 *
14073 */
14074 const getTail = (list, direction = 0) => {
14075 if (direction > 0) {
14076 return list[list.length - 1];
14077 }
14078 return list[0];
14079 };
14080 /**
14081 * Return true if an object is empty
14082 *
14083 */
14084 const isEmptyObject = (obj) => {
14085 return (Object.keys(obj).length === 0);
14086 };
14087 /**
14088 * Get the index of an element amongst sibling nodes of the same type
14089 *
14090 */
14091 const nodeIndex = (el, amongst) => {
14092 if (!el)
14093 return -1;
14094 amongst = amongst || el.nodeName;
14095 var i = 0;
14096 while (el = el.previousElementSibling) {
14097 if (el.matches(amongst)) {
14098 i++;
14099 }
14100 }
14101 return i;
14102 };
14103 /**
14104 * Set attributes of an element
14105 *
14106 */
14107 const setAttr = (el, attrs) => {
14108 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
14109 if (val == null) {
14110 el.removeAttribute(attr);
14111 }
14112 else {
14113 el.setAttribute(attr, '' + val);
14114 }
14115 });
14116 };
14117 /**
14118 * Replace a node
14119 */
14120 const replaceNode = (existing, replacement) => {
14121 if (existing.parentNode)
14122 existing.parentNode.replaceChild(replacement, existing);
14123 };
14124 //# sourceMappingURL=vanilla.js.map
14125
14126 /***/ }
14127
14128 /******/ });
14129 /************************************************************************/
14130 /******/ // The module cache
14131 /******/ const __webpack_module_cache__ = {};
14132 /******/
14133 /******/ // The require function
14134 /******/ function __webpack_require__(moduleId) {
14135 /******/ // Check if module is in cache
14136 /******/ const cachedModule = __webpack_module_cache__[moduleId];
14137 /******/ if (cachedModule !== undefined) {
14138 /******/ return cachedModule.exports;
14139 /******/ }
14140 /******/ // Create a new module (and put it into the cache)
14141 /******/ const module = __webpack_module_cache__[moduleId] = {
14142 /******/ id: moduleId,
14143 /******/ // no module.loaded needed
14144 /******/ exports: {}
14145 /******/ };
14146 /******/
14147 /******/ // Execute the module function
14148 /******/ if (!(moduleId in __webpack_modules__)) {
14149 /******/ delete __webpack_module_cache__[moduleId];
14150 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
14151 /******/ e.code = 'MODULE_NOT_FOUND';
14152 /******/ throw e;
14153 /******/ }
14154 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
14155 /******/
14156 /******/ // Return the exports of the module
14157 /******/ return module.exports;
14158 /******/ }
14159 /******/
14160 /************************************************************************/
14161 /******/ /* webpack/runtime/compat get default export */
14162 /******/ (() => {
14163 /******/ // getDefaultExport function for compatibility with non-harmony modules
14164 /******/ __webpack_require__.n = (module) => {
14165 /******/ const getter = module && module.__esModule ?
14166 /******/ () => (module['default']) :
14167 /******/ () => (module);
14168 /******/ __webpack_require__.d(getter, { a: getter });
14169 /******/ return getter;
14170 /******/ };
14171 /******/ })();
14172 /******/
14173 /******/ /* webpack/runtime/define property getters */
14174 /******/ (() => {
14175 /******/ // define getter/value functions for harmony exports
14176 /******/ __webpack_require__.d = (exports, definition) => {
14177 /******/ if(Array.isArray(definition)) {
14178 /******/ var i = 0;
14179 /******/ while(i < definition.length) {
14180 /******/ var key = definition[i++];
14181 /******/ var binding = definition[i++];
14182 /******/ if(!__webpack_require__.o(exports, key)) {
14183 /******/ if(binding === 0) {
14184 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
14185 /******/ } else {
14186 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
14187 /******/ }
14188 /******/ } else if(binding === 0) { i++; }
14189 /******/ }
14190 /******/ } else {
14191 /******/ for(var key in definition) {
14192 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
14193 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14194 /******/ }
14195 /******/ }
14196 /******/ }
14197 /******/ };
14198 /******/ })();
14199 /******/
14200 /******/ /* webpack/runtime/hasOwnProperty shorthand */
14201 /******/ (() => {
14202 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
14203 /******/ })();
14204 /******/
14205 /******/ /* webpack/runtime/make namespace object */
14206 /******/ (() => {
14207 /******/ // define __esModule on exports
14208 /******/ __webpack_require__.r = (exports) => {
14209 /******/ if(Symbol.toStringTag) {
14210 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14211 /******/ }
14212 /******/ Object.defineProperty(exports, '__esModule', { value: true });
14213 /******/ };
14214 /******/ })();
14215 /******/
14216 /******/ /* webpack/runtime/nonce */
14217 /******/ (() => {
14218 /******/ __webpack_require__.nc = undefined;
14219 /******/ })();
14220 /******/
14221 /************************************************************************/
14222 let __webpack_exports__ = {};
14223 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
14224 (() => {
14225 "use strict";
14226 /*!********************************************!*\
14227 !*** ./assets/src/js/admin/admin-tools.js ***!
14228 \********************************************/
14229 __webpack_require__.r(__webpack_exports__);
14230 /* 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");
14231 /* 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");
14232 /* 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");
14233 /* 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");
14234
14235
14236
14237
14238 (0,_tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__["default"])();
14239 new _tools_handle_sample_data__WEBPACK_IMPORTED_MODULE_1__["default"]().init();
14240 new _tools_reset_course_progress__WEBPACK_IMPORTED_MODULE_2__["default"]().init();
14241 new _tools_reset_item_progress__WEBPACK_IMPORTED_MODULE_3__["default"]().init();
14242 })();
14243
14244 /******/ })()
14245 ;
14246 //# sourceMappingURL=admin-tools.js.map