PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
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 4.1.7.3.2 All 140 releases
learnpress / assets / dist / js / admin / edit-curriculum / edit-course-ai.js

edit-course-ai.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.9, at assets/dist/js/admin/edit-curriculum/edit-course-ai.js

17,251 lines 622.6 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/edit-curriculum/edit-section.js":
5 /*!*************************************************************!*\
6 !*** ./assets/src/js/admin/edit-curriculum/edit-section.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 */ addSection: () => (/* binding */ addSection),
14 /* harmony export */ cancelSectionDescription: () => (/* binding */ cancelSectionDescription),
15 /* harmony export */ cancelSectionTitle: () => (/* binding */ cancelSectionTitle),
16 /* harmony export */ changeDescription: () => (/* binding */ changeDescription),
17 /* harmony export */ changeTitle: () => (/* binding */ changeTitle),
18 /* harmony export */ changeTitleBeforeAdd: () => (/* binding */ changeTitleBeforeAdd),
19 /* harmony export */ className: () => (/* binding */ className),
20 /* harmony export */ deleteSection: () => (/* binding */ deleteSection),
21 /* harmony export */ focusTitleInput: () => (/* binding */ focusTitleInput),
22 /* harmony export */ focusTitleNewInput: () => (/* binding */ focusTitleNewInput),
23 /* harmony export */ init: () => (/* binding */ init),
24 /* harmony export */ setFocusTitleInput: () => (/* binding */ setFocusTitleInput),
25 /* harmony export */ sortAbleSection: () => (/* binding */ sortAbleSection),
26 /* harmony export */ toggleSection: () => (/* binding */ toggleSection),
27 /* harmony export */ updateSectionDescription: () => (/* binding */ updateSectionDescription),
28 /* harmony export */ updateSectionTitle: () => (/* binding */ updateSectionTitle)
29 /* harmony export */ });
30 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js");
31 /* harmony import */ var _share_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./share.js */ "./assets/src/js/admin/edit-curriculum/share.js");
32 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
33 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_2__);
34 /* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! sortablejs */ "./node_modules/sortablejs/modular/sortable.esm.js");
35
36 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
37 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
38 /**
39 * Edit Section Script on Curriculum
40 *
41 * @since 4.2.8.6
42 * @version 1.0.2
43 */
44
45
46
47 var className = _objectSpread(_objectSpread({}, _share_js__WEBPACK_IMPORTED_MODULE_1__.className), {}, {
48 elDivAddNewSection: '.add-new-section',
49 elSectionClone: '.section.clone',
50 elSectionTitleNewInput: '.lp-section-title-new-input',
51 elSectionTitleInput: '.lp-section-title-input',
52 etBtnEditTitle: '.lp-btn-edit-section-title',
53 elSectionDesInput: '.lp-section-description-input',
54 elBtnAddSection: '.lp-btn-add-section',
55 elBtnUpdateTitle: '.lp-btn-update-section-title',
56 elBtnUpdateDes: '.lp-btn-update-section-description',
57 elBtnCancelUpdateTitle: '.lp-btn-cancel-update-section-title',
58 elBtnCancelUpdateDes: '.lp-btn-cancel-update-section-description',
59 elBtnDeleteSection: '.lp-btn-delete-section',
60 elSectionDesc: '.section-description',
61 elSectionToggle: '.section-toggle',
62 elCountSections: '.count-sections'
63 });
64 var courseId = _share_js__WEBPACK_IMPORTED_MODULE_1__.courseId,
65 elEditCurriculum = _share_js__WEBPACK_IMPORTED_MODULE_1__.elEditCurriculum,
66 elCurriculumSections = _share_js__WEBPACK_IMPORTED_MODULE_1__.elCurriculumSections,
67 showToast = _share_js__WEBPACK_IMPORTED_MODULE_1__.showToast,
68 lpUtils = _share_js__WEBPACK_IMPORTED_MODULE_1__.lpUtils,
69 updateCountItems = _share_js__WEBPACK_IMPORTED_MODULE_1__.updateCountItems;
70 var idUrlHandle = 'edit-course-curriculum';
71 var init = function init() {
72 courseId = _share_js__WEBPACK_IMPORTED_MODULE_1__.courseId;
73 elEditCurriculum = _share_js__WEBPACK_IMPORTED_MODULE_1__.elEditCurriculum;
74 elCurriculumSections = _share_js__WEBPACK_IMPORTED_MODULE_1__.elCurriculumSections;
75 showToast = _share_js__WEBPACK_IMPORTED_MODULE_1__.showToast;
76 lpUtils = _share_js__WEBPACK_IMPORTED_MODULE_1__.lpUtils;
77 updateCountItems = _share_js__WEBPACK_IMPORTED_MODULE_1__.updateCountItems;
78 };
79
80 // Typing in new section title input
81 var changeTitleBeforeAdd = function changeTitleBeforeAdd(e, target) {
82 var elSectionTitleNewInput = target.closest("".concat(className.elSectionTitleNewInput));
83 if (!elSectionTitleNewInput) {
84 return;
85 }
86 var elAddNewSection = elSectionTitleNewInput.closest("".concat(className.elDivAddNewSection));
87 if (!elAddNewSection) {
88 return;
89 }
90 var elBtnAddSection = elAddNewSection.querySelector("".concat(className.elBtnAddSection));
91 var titleValue = elSectionTitleNewInput.value.trim();
92 if (titleValue.length === 0) {
93 elBtnAddSection.classList.remove('active');
94 delete _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.titleNew;
95 } else {
96 elBtnAddSection.classList.add('active');
97 _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.titleNew = 1;
98 }
99 };
100
101 // Focus on new section title input
102 var focusTitleNewInput = function focusTitleNewInput(e, target) {
103 var focusIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
104 var elSectionTitleNewInput = target.closest("".concat(className.elSectionTitleNewInput));
105 if (!elSectionTitleNewInput) {
106 return;
107 }
108 var elAddNewSection = elSectionTitleNewInput.closest("".concat(className.elDivAddNewSection));
109 if (!elAddNewSection) {
110 return;
111 }
112 if (focusIn) {
113 elAddNewSection.classList.add('focus');
114 } else {
115 elAddNewSection.classList.remove('focus');
116 }
117 };
118
119 // Add new section
120 var addSection = function addSection(e, target, callBackNest) {
121 var canHandle = false;
122 if (target.closest("".concat(className.elBtnAddSection))) {
123 canHandle = true;
124 } else if (target.closest("".concat(className.elSectionTitleNewInput)) && e.key === 'Enter') {
125 canHandle = true;
126 }
127 if (!canHandle) {
128 return;
129 }
130 var elAddNewSection = target.closest("".concat(className.elDivAddNewSection));
131 if (!elAddNewSection) {
132 return;
133 }
134 e.preventDefault();
135 var elSectionTitleNewInput = elAddNewSection.querySelector("".concat(className.elSectionTitleNewInput));
136 var titleValue = elSectionTitleNewInput.value.trim();
137 var message = elSectionTitleNewInput.dataset.messEmptyTitle;
138 if (titleValue.length === 0) {
139 showToast(message, 'error');
140 return;
141 }
142
143 // Clear input after add
144 elSectionTitleNewInput.value = '';
145 elSectionTitleNewInput.blur();
146
147 // Add and set data for new section
148 var elSectionClone = elCurriculumSections.querySelector("".concat(className.elSectionClone));
149 var newSection = elSectionClone.cloneNode(true);
150 newSection.classList.remove('clone');
151 lpUtils.lpShowHideEl(newSection, 1);
152 lpUtils.lpSetLoadingEl(newSection, 1);
153 var elSectionTitleInput = newSection.querySelector("".concat(className.elSectionTitleInput));
154 elSectionTitleInput.value = titleValue;
155 elCurriculumSections.insertAdjacentElement('beforeend', newSection);
156 // End
157
158 // Call ajax to add new section
159 var callBack = {
160 success: function success(response) {
161 var message = response.message,
162 status = response.status,
163 data = response.data;
164 if (status === 'error') {
165 newSection.remove();
166 throw message;
167 } else if (status === 'success') {
168 var section = data.section;
169 newSection.dataset.sectionId = section.section_id || '';
170 if (_share_js__WEBPACK_IMPORTED_MODULE_1__.sortAbleItem) {
171 _share_js__WEBPACK_IMPORTED_MODULE_1__.sortAbleItem();
172 }
173 if (callBackNest && typeof callBackNest.success === 'function') {
174 callBackNest.success(newSection, response);
175 }
176 }
177 showToast(message, status);
178 },
179 error: function error(_error) {
180 newSection.remove();
181 showToast(_error, 'error');
182 if (callBackNest && typeof callBackNest.error === 'function') {
183 callBackNest.error(newSection, _error);
184 }
185 },
186 completed: function completed() {
187 lpUtils.lpSetLoadingEl(newSection, 0);
188 newSection.classList.remove("".concat(className.elCollapse));
189 var elSectionDesInput = newSection.querySelector("".concat(className.elSectionDesInput));
190 elSectionDesInput.focus();
191 updateCountSections();
192 delete _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.titleNew;
193 if (callBackNest && typeof callBackNest.completed === 'function') {
194 callBackNest.completed(newSection);
195 }
196 }
197 };
198 addSectionAPI({
199 section_name: titleValue
200 }, callBack);
201 };
202 var addSectionAPI = function addSectionAPI(data, callBack) {
203 var dataSend = _objectSpread({
204 action: 'add_section',
205 course_id: courseId,
206 section_name: data.section_name || '',
207 args: {
208 id_url: idUrlHandle
209 }
210 }, data);
211 window.lpAJAXG.fetchAJAX(dataSend, callBack);
212 };
213
214 // Delete section
215 var deleteSection = function deleteSection(e, target) {
216 var elBtnDeleteSection = target.closest("".concat(className.elBtnDeleteSection));
217 if (!elBtnDeleteSection) {
218 return;
219 }
220 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
221 title: elBtnDeleteSection.dataset.title,
222 text: elBtnDeleteSection.dataset.content,
223 icon: 'warning',
224 showCloseButton: true,
225 showCancelButton: true,
226 cancelButtonText: lpDataAdmin.i18n.cancel,
227 confirmButtonText: lpDataAdmin.i18n.yes,
228 reverseButtons: true
229 }).then(function (result) {
230 if (result.isConfirmed) {
231 var elSection = elBtnDeleteSection.closest('.section');
232 var sectionId = elSection.dataset.sectionId;
233 lpUtils.lpSetLoadingEl(elSection, 1);
234
235 // Call ajax to delete section
236 var callBack = {
237 success: function success(response) {
238 var message = response.message,
239 status = response.status;
240 var content = response.data.content;
241 showToast(message, status);
242 },
243 error: function error(_error2) {
244 showToast(_error2, 'error');
245 },
246 completed: function completed() {
247 lpUtils.lpSetLoadingEl(elSection, 0);
248 elSection.remove();
249 updateCountItems(elSection);
250 updateCountSections();
251 }
252 };
253 var dataSend = {
254 action: 'delete_section',
255 course_id: courseId,
256 section_id: sectionId,
257 args: {
258 id_url: idUrlHandle
259 }
260 };
261 window.lpAJAXG.fetchAJAX(dataSend, callBack);
262 }
263 });
264 };
265
266 // Focus on new section title input
267 var focusTitleInput = function focusTitleInput(e, target) {
268 var focusIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
269 var elSectionTitleInput = target.closest("".concat(className.elSectionTitleInput));
270 if (!elSectionTitleInput) {
271 return;
272 }
273 var elSection = elSectionTitleInput.closest("".concat(className.elSection));
274 if (!elSection) {
275 return;
276 }
277 if (focusIn) {
278 elSection.classList.add('focus');
279 } else {
280 elSection.classList.remove('focus');
281 }
282 };
283
284 // Set focus on section title input
285 var setFocusTitleInput = function setFocusTitleInput(e, target) {
286 var etBtnEditTitle = target.closest("".concat(className.etBtnEditTitle));
287 if (!etBtnEditTitle) {
288 return;
289 }
290 var elSection = etBtnEditTitle.closest("".concat(className.elSection));
291 if (!elSection) {
292 return;
293 }
294 var elSectionTitleInput = elSection.querySelector("".concat(className.elSectionTitleInput));
295 elSectionTitleInput.setSelectionRange(elSectionTitleInput.value.length, elSectionTitleInput.value.length);
296 elSectionTitleInput.focus();
297 };
298
299 // Typing in description input
300 var changeTitle = function changeTitle(e, target) {
301 var elSectionTitleInput = target.closest("".concat(className.elSectionTitleInput));
302 if (!elSectionTitleInput) {
303 return;
304 }
305 var elSection = elSectionTitleInput.closest("".concat(className.elSection));
306 var titleValue = elSectionTitleInput.value.trim();
307 var titleValueOld = elSectionTitleInput.dataset.old || '';
308 if (titleValue === titleValueOld) {
309 elSection.classList.remove('editing');
310 delete _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.title;
311 } else {
312 elSection.classList.add('editing');
313 _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.title = 1;
314 }
315 };
316
317 // Update section title to server
318 var updateSectionTitle = function updateSectionTitle(e, target) {
319 var canHandle = false;
320 if (target.closest("".concat(className.elBtnUpdateTitle))) {
321 canHandle = true;
322 } else if (target.closest("".concat(className.elSectionTitleInput)) && e.key === 'Enter') {
323 canHandle = true;
324 }
325 if (!canHandle) {
326 return;
327 }
328 e.preventDefault();
329 var elSection = target.closest("".concat(className.elSection));
330 if (!elSection) {
331 return;
332 }
333 var elSectionTitleInput = elSection.querySelector("".concat(className.elSectionTitleInput));
334 if (!elSectionTitleInput) {
335 return;
336 }
337 var sectionId = elSection.dataset.sectionId;
338 var titleValue = elSectionTitleInput.value.trim();
339 var titleValueOld = elSectionTitleInput.dataset.old || '';
340 var message = elSectionTitleInput.dataset.messEmptyTitle;
341 if (titleValue.length === 0) {
342 showToast(message, 'error');
343 return;
344 }
345 if (titleValue === titleValueOld) {
346 return;
347 }
348 elSectionTitleInput.blur();
349 lpUtils.lpSetLoadingEl(elSection, 1);
350
351 // Call ajax to update section title
352 var callBack = {
353 success: function success(response) {
354 var message = response.message,
355 status = response.status;
356 showToast(message, status);
357 if (status === 'success') {
358 elSectionTitleInput.dataset.old = titleValue;
359 }
360 },
361 error: function error(_error3) {
362 showToast(_error3, 'error');
363 },
364 completed: function completed() {
365 lpUtils.lpSetLoadingEl(elSection, 0);
366 elSection.classList.remove('editing');
367 delete _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.title;
368 }
369 };
370 var dataSend = {
371 action: 'update_section',
372 course_id: courseId,
373 section_id: sectionId,
374 section_name: titleValue,
375 args: {
376 id_url: idUrlHandle
377 }
378 };
379 window.lpAJAXG.fetchAJAX(dataSend, callBack);
380 };
381
382 // Cancel updating section description
383 var cancelSectionTitle = function cancelSectionTitle(e, target) {
384 var elBtnCancelUpdateTitle = target.closest("".concat(className.elBtnCancelUpdateTitle));
385 if (!elBtnCancelUpdateTitle) {
386 return;
387 }
388 var elSection = elBtnCancelUpdateTitle.closest("".concat(className.elSection));
389 var elSectionTitleInput = elSection.querySelector("".concat(className.elSectionTitleInput));
390 elSectionTitleInput.value = elSectionTitleInput.dataset.old || ''; // Reset to old value
391 elSection.classList.remove('editing'); // Remove editing class
392 delete _share_js__WEBPACK_IMPORTED_MODULE_1__.hasChange.title;
393 };
394
395 // Update section description to server
396 var updateSectionDescription = function updateSectionDescription(e, target, callBackNest) {
397 var canHandle = false;
398 if (target.closest("".concat(className.elBtnUpdateDes))) {
399 canHandle = true;
400 } else if (target.closest("".concat(className.elSectionDesInput)) && e.key === 'Enter') {
401 canHandle = true;
402 }
403 if (!canHandle) {
404 return;
405 }
406 e.preventDefault();
407 var elSectionDesc = target.closest("".concat(className.elSectionDesc));
408 if (!elSectionDesc) {
409 return;
410 }
411 var elSectionDesInput = elSectionDesc.querySelector("".concat(className.elSectionDesInput));
412 if (!elSectionDesInput) {
413 return;
414 }
415 var elSection = elSectionDesInput.closest("".concat(className.elSection));
416 var sectionId = elSection.dataset.sectionId;
417 var descValue = elSectionDesInput.value.trim();
418 var descValueOld = elSectionDesInput.dataset.old || '';
419 if (descValue === descValueOld) {
420 return;
421 }
422 lpUtils.lpSetLoadingEl(elSection, 1);
423
424 // Call ajax to update section description
425 var callBack = {
426 success: function success(response) {
427 var message = response.message,
428 status = response.status;
429 if (callBackNest && typeof callBackNest.success === 'function') {
430 callBackNest.success(elSection, response);
431 }
432 showToast(message, status);
433 },
434 error: function error(_error4) {
435 showToast(_error4, 'error');
436 if (callBackNest && typeof callBackNest.error === 'function') {
437 callBackNest.error(elSection, _error4);
438 }
439 },
440 completed: function completed() {
441 lpUtils.lpSetLoadingEl(elSection, 0);
442 var elSectionDesc = elSectionDesInput.closest("".concat(className.elSectionDesc));
443 elSectionDesc.classList.remove('editing');
444 elSectionDesInput.dataset.old = descValue; // Update old value
445 if (callBackNest && typeof callBackNest.completed === 'function') {
446 callBackNest.completed(elSection);
447 }
448 }
449 };
450 var dataSend = {
451 action: 'update_section',
452 course_id: courseId,
453 section_id: sectionId,
454 section_description: descValue,
455 args: {
456 id_url: idUrlHandle
457 }
458 };
459 window.lpAJAXG.fetchAJAX(dataSend, callBack);
460 };
461
462 // Cancel updating section description
463 var cancelSectionDescription = function cancelSectionDescription(e, target) {
464 var elBtnCancelUpdateDes = target.closest("".concat(className.elBtnCancelUpdateDes));
465 if (!elBtnCancelUpdateDes) {
466 return;
467 }
468 var elSectionDesc = elBtnCancelUpdateDes.closest("".concat(className.elSectionDesc));
469 var elSectionDesInput = elSectionDesc.querySelector("".concat(className.elSectionDesInput));
470 elSectionDesInput.value = elSectionDesInput.dataset.old || ''; // Reset to old value
471 elSectionDesc.classList.remove('editing'); // Remove editing class
472 };
473
474 // Typing in description input
475 var changeDescription = function changeDescription(e, target) {
476 var elSectionDesInput = target.closest("".concat(className.elSectionDesInput));
477 if (!elSectionDesInput) {
478 return;
479 }
480 var elSectionDesc = elSectionDesInput.closest("".concat(className.elSectionDesc));
481 var descValue = elSectionDesInput.value.trim();
482 var descValueOld = elSectionDesInput.dataset.old || '';
483 if (descValue === descValueOld) {
484 elSectionDesc.classList.remove('editing');
485 } else {
486 elSectionDesc.classList.add('editing');
487 }
488 };
489
490 // Toggle section
491 var toggleSection = function toggleSection(e, target) {
492 var elSectionToggle = target.closest("".concat(className.elSectionToggle));
493 if (!elSectionToggle) {
494 return;
495 }
496 var elSection = elSectionToggle.closest("".concat(className.elSection));
497 var elCurriculumSections = elSection.closest("".concat(className.elCurriculumSections));
498 if (!elCurriculumSections) {
499 return;
500 }
501
502 // Toggle section
503 elSection.classList.toggle("".concat(className.elCollapse));
504
505 // Check all sections collapsed
506 checkAllSectionsCollapsed();
507 };
508
509 // Check if all sections are collapsed
510 var checkAllSectionsCollapsed = function checkAllSectionsCollapsed() {
511 var elSections = elEditCurriculum.querySelectorAll("".concat(className.elSection, ":not(.clone)"));
512 var elToggleAllSections = elEditCurriculum.querySelector("".concat(className.elToggleAllSections));
513 var isAllExpand = true;
514 elSections.forEach(function (el) {
515 if (el.classList.contains("".concat(className.elCollapse))) {
516 isAllExpand = false;
517 return false; // Break the loop
518 }
519 });
520 if (isAllExpand) {
521 elToggleAllSections.classList.remove("".concat(className.elCollapse));
522 } else {
523 elToggleAllSections.classList.add("".concat(className.elCollapse));
524 }
525 };
526
527 // Sortable sections, drag and drop to change section position
528 var sortAbleSection = function sortAbleSection() {
529 var isUpdateSectionPosition = 0;
530 var timeout;
531 new sortablejs__WEBPACK_IMPORTED_MODULE_3__["default"](elCurriculumSections, {
532 handle: '.drag',
533 animation: 150,
534 onEnd: function onEnd(evt) {
535 var target = evt.item;
536 if (!isUpdateSectionPosition) {
537 // No change in section position, do nothing
538 return;
539 }
540 var elSection = target.closest("".concat(className.elSection));
541 var elSections = elCurriculumSections.querySelectorAll("".concat(className.elSection));
542 var sectionIds = [];
543 elSections.forEach(function (elSection, index) {
544 var sectionId = elSection.dataset.sectionId;
545 sectionIds.push(sectionId);
546 });
547
548 // Call ajax to update section position
549 var callBack = {
550 success: function success(response) {
551 var message = response.message,
552 status = response.status;
553 showToast(message, status);
554 },
555 error: function error(_error5) {
556 showToast(_error5, 'error');
557 },
558 completed: function completed() {
559 lpUtils.lpSetLoadingEl(elSection, 0);
560 isUpdateSectionPosition = 0;
561 }
562 };
563 var dataSend = {
564 action: 'update_section_position',
565 course_id: courseId,
566 new_position: sectionIds,
567 args: {
568 id_url: idUrlHandle
569 }
570 };
571 clearTimeout(timeout);
572 timeout = setTimeout(function () {
573 lpUtils.lpSetLoadingEl(elSection, 1);
574 window.lpAJAXG.fetchAJAX(dataSend, callBack);
575 }, 1000);
576 },
577 onMove: function onMove(evt) {
578 clearTimeout(timeout);
579 },
580 onUpdate: function onUpdate(evt) {
581 isUpdateSectionPosition = 1;
582 }
583 });
584 };
585
586 // Update count sections, when add or delete section
587 var updateCountSections = function updateCountSections() {
588 var elCountSections = elEditCurriculum.querySelector("".concat(className.elCountSections));
589 var elSections = elCurriculumSections.querySelectorAll("".concat(className.elSection, ":not(.clone)"));
590 var sectionsCount = elSections.length;
591 elCountSections.dataset.count = sectionsCount;
592 elCountSections.querySelector('.count').textContent = sectionsCount;
593 };
594
595
596 /***/ }),
597
598 /***/ "./assets/src/js/admin/edit-curriculum/share.js":
599 /*!******************************************************!*\
600 !*** ./assets/src/js/admin/edit-curriculum/share.js ***!
601 \******************************************************/
602 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
603
604 "use strict";
605 __webpack_require__.r(__webpack_exports__);
606 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
607 /* harmony export */ className: () => (/* binding */ className),
608 /* harmony export */ courseId: () => (/* binding */ courseId),
609 /* harmony export */ elCurriculumSections: () => (/* binding */ elCurriculumSections),
610 /* harmony export */ elEditCurriculum: () => (/* binding */ elEditCurriculum),
611 /* harmony export */ hasChange: () => (/* binding */ hasChange),
612 /* harmony export */ lpUtils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_1__),
613 /* harmony export */ setVariable: () => (/* binding */ setVariable),
614 /* harmony export */ setVariables: () => (/* binding */ setVariables),
615 /* harmony export */ showToast: () => (/* binding */ showToast),
616 /* harmony export */ sortAbleItem: () => (/* binding */ sortAbleItem),
617 /* harmony export */ updateCountItems: () => (/* binding */ updateCountItems)
618 /* harmony export */ });
619 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js");
620 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils.js */ "./assets/src/js/utils.js");
621 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
622 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_2__);
623 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
624
625 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
626 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
627 /**
628 * Share variables and functions for the edit curriculum page.
629 *
630 * @since 4.2.8.6
631 * @version 1.0.1
632 */
633
634
635
636 var courseId;
637 var elEditCurriculum;
638 var elCurriculumSections;
639 var updateCountItems;
640 var sortAbleItem;
641 var hasChange;
642 var className = {
643 idElEditCurriculum: '#lp-course-edit-curriculum',
644 elCurriculumSections: '.curriculum-sections',
645 elSection: '.section',
646 elToggleAllSections: '.course-toggle-all-sections',
647 elSectionItem: '.section-item',
648 LPTarget: '.lp-target',
649 elCollapse: 'lp-collapse'
650 };
651 var argsToastify = {
652 text: '',
653 gravity: lpDataAdmin.toast.gravity,
654 // `top` or `bottom`
655 position: lpDataAdmin.toast.position,
656 // `left`, `center` or `right`
657 className: "".concat(lpDataAdmin.toast.classPrefix),
658 close: lpDataAdmin.toast.close == 1,
659 stopOnFocus: lpDataAdmin.toast.stopOnFocus == 1,
660 duration: lpDataAdmin.toast.duration
661 };
662 var showToast = function showToast(message) {
663 var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'success';
664 var toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_2___default())(_objectSpread(_objectSpread({}, argsToastify), {}, {
665 text: message,
666 className: "".concat(lpDataAdmin.toast.classPrefix, " ").concat(status)
667 }));
668 toastify.showToast();
669 };
670 var setVariables = function setVariables(variables) {
671 courseId = variables.courseId;
672 elEditCurriculum = variables.elEditCurriculum;
673 elCurriculumSections = variables.elCurriculumSections;
674 updateCountItems = variables.updateCountItems;
675 hasChange = variables.hasChange;
676 };
677 var setVariable = function setVariable(variable, value) {
678 if (variable && value !== undefined) {
679 switch (variable) {
680 case 'sortAbleItem':
681 sortAbleItem = value;
682 break;
683 }
684 }
685 };
686
687
688 /***/ }),
689
690 /***/ "./assets/src/js/utils.js":
691 /*!********************************!*\
692 !*** ./assets/src/js/utils.js ***!
693 \********************************/
694 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
695
696 "use strict";
697 __webpack_require__.r(__webpack_exports__);
698 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
699 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
700 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
701 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
702 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
703 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
704 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
705 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
706 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
707 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
708 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
709 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
710 /* harmony export */ });
711 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js");
712
713 function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
714 function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
715 function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
716 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
717 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
718 /**
719 * Utils functions
720 *
721 * @param url
722 * @param data
723 * @param functions
724 * @since 4.2.5.1
725 * @version 1.0.3
726 */
727 var lpClassName = {
728 hidden: 'lp-hidden',
729 loading: 'loading',
730 elCollapse: 'lp-collapse',
731 elSectionToggle: '.lp-section-toggle',
732 elTriggerToggle: '.lp-trigger-toggle'
733 };
734 var lpFetchAPI = function lpFetchAPI(url) {
735 var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
736 var functions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
737 if ('function' === typeof functions.before) {
738 functions.before();
739 }
740 fetch(url, _objectSpread({
741 method: 'GET'
742 }, data)).then(function (response) {
743 return response.json();
744 }).then(function (response) {
745 if ('function' === typeof functions.success) {
746 functions.success(response);
747 }
748 })["catch"](function (err) {
749 if ('function' === typeof functions.error) {
750 functions.error(err);
751 }
752 })["finally"](function () {
753 if ('function' === typeof functions.completed) {
754 functions.completed();
755 }
756 });
757 };
758
759 /**
760 * Get current URL without params.
761 *
762 * @since 4.2.5.1
763 */
764 var lpGetCurrentURLNoParam = function lpGetCurrentURLNoParam() {
765 var currentUrl = window.location.href;
766 var hasParams = currentUrl.includes('?');
767 if (hasParams) {
768 currentUrl = currentUrl.split('?')[0];
769 }
770 return currentUrl;
771 };
772 var lpAddQueryArgs = function lpAddQueryArgs(endpoint, args) {
773 var url = new URL(endpoint);
774 Object.keys(args).forEach(function (arg) {
775 url.searchParams.set(arg, args[arg]);
776 });
777 return url;
778 };
779
780 /**
781 * Listen element viewed.
782 *
783 * @param el
784 * @param callback
785 * @since 4.2.5.8
786 */
787 var listenElementViewed = function listenElementViewed(el, callback) {
788 var observerSeeItem = new IntersectionObserver(function (entries) {
789 var _iterator = _createForOfIteratorHelper(entries),
790 _step;
791 try {
792 for (_iterator.s(); !(_step = _iterator.n()).done;) {
793 var entry = _step.value;
794 if (entry.isIntersecting) {
795 callback(entry);
796 }
797 }
798 } catch (err) {
799 _iterator.e(err);
800 } finally {
801 _iterator.f();
802 }
803 });
804 observerSeeItem.observe(el);
805 };
806
807 /**
808 * Listen element created.
809 *
810 * @param callback
811 * @since 4.2.5.8
812 */
813 var listenElementCreated = function listenElementCreated(callback) {
814 var observerCreateItem = new MutationObserver(function (mutations) {
815 mutations.forEach(function (mutation) {
816 if (mutation.addedNodes) {
817 mutation.addedNodes.forEach(function (node) {
818 if (node.nodeType === 1) {
819 callback(node);
820 }
821 });
822 }
823 });
824 });
825 observerCreateItem.observe(document, {
826 childList: true,
827 subtree: true
828 });
829 // End.
830 };
831
832 /**
833 * Listen element created.
834 *
835 * @param selector
836 * @param callback
837 * @since 4.2.7.1
838 */
839 var lpOnElementReady = function lpOnElementReady(selector, callback) {
840 var element = document.querySelector(selector);
841 if (element) {
842 callback(element);
843 return;
844 }
845 var observer = new MutationObserver(function (mutations, obs) {
846 var element = document.querySelector(selector);
847 if (element) {
848 obs.disconnect();
849 callback(element);
850 }
851 });
852 observer.observe(document.documentElement, {
853 childList: true,
854 subtree: true
855 });
856 };
857
858 // Parse JSON from string with content include LP_AJAX_START.
859 var lpAjaxParseJsonOld = function lpAjaxParseJsonOld(data) {
860 if (typeof data !== 'string') {
861 return data;
862 }
863 var m = String.raw({
864 raw: data
865 }).match(/<-- LP_AJAX_START -->([^]*)<-- LP_AJAX_END -->/);
866 try {
867 if (m) {
868 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
869 } else {
870 data = JSON.parse(data);
871 }
872 } catch (e) {
873 data = {};
874 }
875 return data;
876 };
877
878 // status 0: hide, 1: show
879 var lpShowHideEl = function lpShowHideEl(el) {
880 var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
881 if (!el) {
882 return;
883 }
884 if (!status) {
885 el.classList.add(lpClassName.hidden);
886 } else {
887 el.classList.remove(lpClassName.hidden);
888 }
889 };
890
891 // status 0: hide, 1: show
892 var lpSetLoadingEl = function lpSetLoadingEl(el, status) {
893 if (!el) {
894 return;
895 }
896 if (!status) {
897 el.classList.remove(lpClassName.loading);
898 } else {
899 el.classList.add(lpClassName.loading);
900 }
901 };
902
903 // Toggle collapse section
904 var toggleCollapse = function toggleCollapse(e, target) {
905 var elTriggerClassName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
906 var elsExclude = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
907 var callback = arguments.length > 4 ? arguments[4] : undefined;
908 if (!elTriggerClassName) {
909 elTriggerClassName = lpClassName.elTriggerToggle;
910 }
911
912 // Exclude elements, which should not trigger the collapse toggle
913 if (elsExclude && elsExclude.length > 0) {
914 var _iterator2 = _createForOfIteratorHelper(elsExclude),
915 _step2;
916 try {
917 for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
918 var elExclude = _step2.value;
919 if (target.closest(elExclude)) {
920 return;
921 }
922 }
923 } catch (err) {
924 _iterator2.e(err);
925 } finally {
926 _iterator2.f();
927 }
928 }
929 var elTrigger = target.closest(elTriggerClassName);
930 if (!elTrigger) {
931 return;
932 }
933
934 //console.log( 'elTrigger', elTrigger );
935
936 var elSectionToggle = elTrigger.closest("".concat(lpClassName.elSectionToggle));
937 if (!elSectionToggle) {
938 return;
939 }
940 elSectionToggle.classList.toggle("".concat(lpClassName.elCollapse));
941 if ('function' === typeof callback) {
942 callback(elSectionToggle);
943 }
944 };
945
946
947 /***/ }),
948
949 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css":
950 /*!*****************************************************************************************!*\
951 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
952 \*****************************************************************************************/
953 /***/ ((module, __webpack_exports__, __webpack_require__) => {
954
955 "use strict";
956 __webpack_require__.r(__webpack_exports__);
957 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
958 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
959 /* harmony export */ });
960 /* 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");
961 /* 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__);
962 /* 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");
963 /* 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__);
964 // Imports
965
966
967 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()));
968 // Module
969 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
970 * Toastify js 1.12.0
971 * https://github.com/apvarun/toastify-js
972 * @license MIT licensed
973 *
974 * Copyright (C) 2018 Varun A P
975 */
976
977 .toastify {
978 padding: 12px 20px;
979 color: #ffffff;
980 display: inline-block;
981 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
982 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
983 background: linear-gradient(135deg, #73a5ff, #5477f5);
984 position: fixed;
985 opacity: 0;
986 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
987 border-radius: 2px;
988 cursor: pointer;
989 text-decoration: none;
990 max-width: calc(50% - 20px);
991 z-index: 2147483647;
992 }
993
994 .toastify.on {
995 opacity: 1;
996 }
997
998 .toast-close {
999 background: transparent;
1000 border: 0;
1001 color: white;
1002 cursor: pointer;
1003 font-family: inherit;
1004 font-size: 1em;
1005 opacity: 0.4;
1006 padding: 0 5px;
1007 }
1008
1009 .toastify-right {
1010 right: 15px;
1011 }
1012
1013 .toastify-left {
1014 left: 15px;
1015 }
1016
1017 .toastify-top {
1018 top: -150px;
1019 }
1020
1021 .toastify-bottom {
1022 bottom: -150px;
1023 }
1024
1025 .toastify-rounded {
1026 border-radius: 25px;
1027 }
1028
1029 .toastify-avatar {
1030 width: 1.5em;
1031 height: 1.5em;
1032 margin: -7px 5px;
1033 border-radius: 2px;
1034 }
1035
1036 .toastify-center {
1037 margin-left: auto;
1038 margin-right: auto;
1039 left: 0;
1040 right: 0;
1041 max-width: fit-content;
1042 max-width: -moz-fit-content;
1043 }
1044
1045 @media only screen and (max-width: 360px) {
1046 .toastify-right, .toastify-left {
1047 margin-left: auto;
1048 margin-right: auto;
1049 left: 0;
1050 right: 0;
1051 max-width: fit-content;
1052 }
1053 }
1054 `, "",{"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":""}]);
1055 // Exports
1056 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1057
1058
1059 /***/ }),
1060
1061 /***/ "./node_modules/css-loader/dist/runtime/api.js":
1062 /*!*****************************************************!*\
1063 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1064 \*****************************************************/
1065 /***/ ((module) => {
1066
1067 "use strict";
1068
1069
1070 /*
1071 MIT License http://www.opensource.org/licenses/mit-license.php
1072 Author Tobias Koppers @sokra
1073 */
1074 module.exports = function (cssWithMappingToString) {
1075 var list = [];
1076
1077 // return the list of modules as css string
1078 list.toString = function toString() {
1079 return this.map(function (item) {
1080 var content = "";
1081 var needLayer = typeof item[5] !== "undefined";
1082 if (item[4]) {
1083 content += "@supports (".concat(item[4], ") {");
1084 }
1085 if (item[2]) {
1086 content += "@media ".concat(item[2], " {");
1087 }
1088 if (needLayer) {
1089 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1090 }
1091 content += cssWithMappingToString(item);
1092 if (needLayer) {
1093 content += "}";
1094 }
1095 if (item[2]) {
1096 content += "}";
1097 }
1098 if (item[4]) {
1099 content += "}";
1100 }
1101 return content;
1102 }).join("");
1103 };
1104
1105 // import a list of modules into the list
1106 list.i = function i(modules, media, dedupe, supports, layer) {
1107 if (typeof modules === "string") {
1108 modules = [[null, modules, undefined]];
1109 }
1110 var alreadyImportedModules = {};
1111 if (dedupe) {
1112 for (var k = 0; k < this.length; k++) {
1113 var id = this[k][0];
1114 if (id != null) {
1115 alreadyImportedModules[id] = true;
1116 }
1117 }
1118 }
1119 for (var _k = 0; _k < modules.length; _k++) {
1120 var item = [].concat(modules[_k]);
1121 if (dedupe && alreadyImportedModules[item[0]]) {
1122 continue;
1123 }
1124 if (typeof layer !== "undefined") {
1125 if (typeof item[5] === "undefined") {
1126 item[5] = layer;
1127 } else {
1128 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1129 item[5] = layer;
1130 }
1131 }
1132 if (media) {
1133 if (!item[2]) {
1134 item[2] = media;
1135 } else {
1136 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1137 item[2] = media;
1138 }
1139 }
1140 if (supports) {
1141 if (!item[4]) {
1142 item[4] = "".concat(supports);
1143 } else {
1144 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1145 item[4] = supports;
1146 }
1147 }
1148 list.push(item);
1149 }
1150 };
1151 return list;
1152 };
1153
1154 /***/ }),
1155
1156 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js":
1157 /*!************************************************************!*\
1158 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1159 \************************************************************/
1160 /***/ ((module) => {
1161
1162 "use strict";
1163
1164
1165 module.exports = function (item) {
1166 var content = item[1];
1167 var cssMapping = item[3];
1168 if (!cssMapping) {
1169 return content;
1170 }
1171 if (typeof btoa === "function") {
1172 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1173 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1174 var sourceMapping = "/*# ".concat(data, " */");
1175 return [content].concat([sourceMapping]).join("\n");
1176 }
1177 return [content].join("\n");
1178 };
1179
1180 /***/ }),
1181
1182 /***/ "./node_modules/sortablejs/modular/sortable.esm.js":
1183 /*!*********************************************************!*\
1184 !*** ./node_modules/sortablejs/modular/sortable.esm.js ***!
1185 \*********************************************************/
1186 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1187
1188 "use strict";
1189 __webpack_require__.r(__webpack_exports__);
1190 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1191 /* harmony export */ MultiDrag: () => (/* binding */ MultiDragPlugin),
1192 /* harmony export */ Sortable: () => (/* binding */ Sortable),
1193 /* harmony export */ Swap: () => (/* binding */ SwapPlugin),
1194 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1195 /* harmony export */ });
1196 /**!
1197 * Sortable 1.15.6
1198 * @author RubaXa <[email protected]>
1199 * @author owenm <[email protected]>
1200 * @license MIT
1201 */
1202 function ownKeys(object, enumerableOnly) {
1203 var keys = Object.keys(object);
1204 if (Object.getOwnPropertySymbols) {
1205 var symbols = Object.getOwnPropertySymbols(object);
1206 if (enumerableOnly) {
1207 symbols = symbols.filter(function (sym) {
1208 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1209 });
1210 }
1211 keys.push.apply(keys, symbols);
1212 }
1213 return keys;
1214 }
1215 function _objectSpread2(target) {
1216 for (var i = 1; i < arguments.length; i++) {
1217 var source = arguments[i] != null ? arguments[i] : {};
1218 if (i % 2) {
1219 ownKeys(Object(source), true).forEach(function (key) {
1220 _defineProperty(target, key, source[key]);
1221 });
1222 } else if (Object.getOwnPropertyDescriptors) {
1223 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1224 } else {
1225 ownKeys(Object(source)).forEach(function (key) {
1226 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1227 });
1228 }
1229 }
1230 return target;
1231 }
1232 function _typeof(obj) {
1233 "@babel/helpers - typeof";
1234
1235 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1236 _typeof = function (obj) {
1237 return typeof obj;
1238 };
1239 } else {
1240 _typeof = function (obj) {
1241 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1242 };
1243 }
1244 return _typeof(obj);
1245 }
1246 function _defineProperty(obj, key, value) {
1247 if (key in obj) {
1248 Object.defineProperty(obj, key, {
1249 value: value,
1250 enumerable: true,
1251 configurable: true,
1252 writable: true
1253 });
1254 } else {
1255 obj[key] = value;
1256 }
1257 return obj;
1258 }
1259 function _extends() {
1260 _extends = Object.assign || function (target) {
1261 for (var i = 1; i < arguments.length; i++) {
1262 var source = arguments[i];
1263 for (var key in source) {
1264 if (Object.prototype.hasOwnProperty.call(source, key)) {
1265 target[key] = source[key];
1266 }
1267 }
1268 }
1269 return target;
1270 };
1271 return _extends.apply(this, arguments);
1272 }
1273 function _objectWithoutPropertiesLoose(source, excluded) {
1274 if (source == null) return {};
1275 var target = {};
1276 var sourceKeys = Object.keys(source);
1277 var key, i;
1278 for (i = 0; i < sourceKeys.length; i++) {
1279 key = sourceKeys[i];
1280 if (excluded.indexOf(key) >= 0) continue;
1281 target[key] = source[key];
1282 }
1283 return target;
1284 }
1285 function _objectWithoutProperties(source, excluded) {
1286 if (source == null) return {};
1287 var target = _objectWithoutPropertiesLoose(source, excluded);
1288 var key, i;
1289 if (Object.getOwnPropertySymbols) {
1290 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1291 for (i = 0; i < sourceSymbolKeys.length; i++) {
1292 key = sourceSymbolKeys[i];
1293 if (excluded.indexOf(key) >= 0) continue;
1294 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1295 target[key] = source[key];
1296 }
1297 }
1298 return target;
1299 }
1300 function _toConsumableArray(arr) {
1301 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1302 }
1303 function _arrayWithoutHoles(arr) {
1304 if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1305 }
1306 function _iterableToArray(iter) {
1307 if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1308 }
1309 function _unsupportedIterableToArray(o, minLen) {
1310 if (!o) return;
1311 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1312 var n = Object.prototype.toString.call(o).slice(8, -1);
1313 if (n === "Object" && o.constructor) n = o.constructor.name;
1314 if (n === "Map" || n === "Set") return Array.from(o);
1315 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1316 }
1317 function _arrayLikeToArray(arr, len) {
1318 if (len == null || len > arr.length) len = arr.length;
1319 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1320 return arr2;
1321 }
1322 function _nonIterableSpread() {
1323 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1324 }
1325
1326 var version = "1.15.6";
1327
1328 function userAgent(pattern) {
1329 if (typeof window !== 'undefined' && window.navigator) {
1330 return !! /*@__PURE__*/navigator.userAgent.match(pattern);
1331 }
1332 }
1333 var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
1334 var Edge = userAgent(/Edge/i);
1335 var FireFox = userAgent(/firefox/i);
1336 var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
1337 var IOS = userAgent(/iP(ad|od|hone)/i);
1338 var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
1339
1340 var captureMode = {
1341 capture: false,
1342 passive: false
1343 };
1344 function on(el, event, fn) {
1345 el.addEventListener(event, fn, !IE11OrLess && captureMode);
1346 }
1347 function off(el, event, fn) {
1348 el.removeEventListener(event, fn, !IE11OrLess && captureMode);
1349 }
1350 function matches( /**HTMLElement*/el, /**String*/selector) {
1351 if (!selector) return;
1352 selector[0] === '>' && (selector = selector.substring(1));
1353 if (el) {
1354 try {
1355 if (el.matches) {
1356 return el.matches(selector);
1357 } else if (el.msMatchesSelector) {
1358 return el.msMatchesSelector(selector);
1359 } else if (el.webkitMatchesSelector) {
1360 return el.webkitMatchesSelector(selector);
1361 }
1362 } catch (_) {
1363 return false;
1364 }
1365 }
1366 return false;
1367 }
1368 function getParentOrHost(el) {
1369 return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
1370 }
1371 function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
1372 if (el) {
1373 ctx = ctx || document;
1374 do {
1375 if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
1376 return el;
1377 }
1378 if (el === ctx) break;
1379 /* jshint boss:true */
1380 } while (el = getParentOrHost(el));
1381 }
1382 return null;
1383 }
1384 var R_SPACE = /\s+/g;
1385 function toggleClass(el, name, state) {
1386 if (el && name) {
1387 if (el.classList) {
1388 el.classList[state ? 'add' : 'remove'](name);
1389 } else {
1390 var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
1391 el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
1392 }
1393 }
1394 }
1395 function css(el, prop, val) {
1396 var style = el && el.style;
1397 if (style) {
1398 if (val === void 0) {
1399 if (document.defaultView && document.defaultView.getComputedStyle) {
1400 val = document.defaultView.getComputedStyle(el, '');
1401 } else if (el.currentStyle) {
1402 val = el.currentStyle;
1403 }
1404 return prop === void 0 ? val : val[prop];
1405 } else {
1406 if (!(prop in style) && prop.indexOf('webkit') === -1) {
1407 prop = '-webkit-' + prop;
1408 }
1409 style[prop] = val + (typeof val === 'string' ? '' : 'px');
1410 }
1411 }
1412 }
1413 function matrix(el, selfOnly) {
1414 var appliedTransforms = '';
1415 if (typeof el === 'string') {
1416 appliedTransforms = el;
1417 } else {
1418 do {
1419 var transform = css(el, 'transform');
1420 if (transform && transform !== 'none') {
1421 appliedTransforms = transform + ' ' + appliedTransforms;
1422 }
1423 /* jshint boss:true */
1424 } while (!selfOnly && (el = el.parentNode));
1425 }
1426 var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
1427 /*jshint -W056 */
1428 return matrixFn && new matrixFn(appliedTransforms);
1429 }
1430 function find(ctx, tagName, iterator) {
1431 if (ctx) {
1432 var list = ctx.getElementsByTagName(tagName),
1433 i = 0,
1434 n = list.length;
1435 if (iterator) {
1436 for (; i < n; i++) {
1437 iterator(list[i], i);
1438 }
1439 }
1440 return list;
1441 }
1442 return [];
1443 }
1444 function getWindowScrollingElement() {
1445 var scrollingElement = document.scrollingElement;
1446 if (scrollingElement) {
1447 return scrollingElement;
1448 } else {
1449 return document.documentElement;
1450 }
1451 }
1452
1453 /**
1454 * Returns the "bounding client rect" of given element
1455 * @param {HTMLElement} el The element whose boundingClientRect is wanted
1456 * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
1457 * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
1458 * @param {[Boolean]} undoScale Whether the container's scale() should be undone
1459 * @param {[HTMLElement]} container The parent the element will be placed in
1460 * @return {Object} The boundingClientRect of el, with specified adjustments
1461 */
1462 function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
1463 if (!el.getBoundingClientRect && el !== window) return;
1464 var elRect, top, left, bottom, right, height, width;
1465 if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
1466 elRect = el.getBoundingClientRect();
1467 top = elRect.top;
1468 left = elRect.left;
1469 bottom = elRect.bottom;
1470 right = elRect.right;
1471 height = elRect.height;
1472 width = elRect.width;
1473 } else {
1474 top = 0;
1475 left = 0;
1476 bottom = window.innerHeight;
1477 right = window.innerWidth;
1478 height = window.innerHeight;
1479 width = window.innerWidth;
1480 }
1481 if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
1482 // Adjust for translate()
1483 container = container || el.parentNode;
1484
1485 // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
1486 // Not needed on <= IE11
1487 if (!IE11OrLess) {
1488 do {
1489 if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
1490 var containerRect = container.getBoundingClientRect();
1491
1492 // Set relative to edges of padding box of container
1493 top -= containerRect.top + parseInt(css(container, 'border-top-width'));
1494 left -= containerRect.left + parseInt(css(container, 'border-left-width'));
1495 bottom = top + elRect.height;
1496 right = left + elRect.width;
1497 break;
1498 }
1499 /* jshint boss:true */
1500 } while (container = container.parentNode);
1501 }
1502 }
1503 if (undoScale && el !== window) {
1504 // Adjust for scale()
1505 var elMatrix = matrix(container || el),
1506 scaleX = elMatrix && elMatrix.a,
1507 scaleY = elMatrix && elMatrix.d;
1508 if (elMatrix) {
1509 top /= scaleY;
1510 left /= scaleX;
1511 width /= scaleX;
1512 height /= scaleY;
1513 bottom = top + height;
1514 right = left + width;
1515 }
1516 }
1517 return {
1518 top: top,
1519 left: left,
1520 bottom: bottom,
1521 right: right,
1522 width: width,
1523 height: height
1524 };
1525 }
1526
1527 /**
1528 * Checks if a side of an element is scrolled past a side of its parents
1529 * @param {HTMLElement} el The element who's side being scrolled out of view is in question
1530 * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
1531 * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
1532 * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
1533 */
1534 function isScrolledPast(el, elSide, parentSide) {
1535 var parent = getParentAutoScrollElement(el, true),
1536 elSideVal = getRect(el)[elSide];
1537
1538 /* jshint boss:true */
1539 while (parent) {
1540 var parentSideVal = getRect(parent)[parentSide],
1541 visible = void 0;
1542 if (parentSide === 'top' || parentSide === 'left') {
1543 visible = elSideVal >= parentSideVal;
1544 } else {
1545 visible = elSideVal <= parentSideVal;
1546 }
1547 if (!visible) return parent;
1548 if (parent === getWindowScrollingElement()) break;
1549 parent = getParentAutoScrollElement(parent, false);
1550 }
1551 return false;
1552 }
1553
1554 /**
1555 * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
1556 * and non-draggable elements
1557 * @param {HTMLElement} el The parent element
1558 * @param {Number} childNum The index of the child
1559 * @param {Object} options Parent Sortable's options
1560 * @return {HTMLElement} The child at index childNum, or null if not found
1561 */
1562 function getChild(el, childNum, options, includeDragEl) {
1563 var currentChild = 0,
1564 i = 0,
1565 children = el.children;
1566 while (i < children.length) {
1567 if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
1568 if (currentChild === childNum) {
1569 return children[i];
1570 }
1571 currentChild++;
1572 }
1573 i++;
1574 }
1575 return null;
1576 }
1577
1578 /**
1579 * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
1580 * @param {HTMLElement} el Parent element
1581 * @param {selector} selector Any other elements that should be ignored
1582 * @return {HTMLElement} The last child, ignoring ghostEl
1583 */
1584 function lastChild(el, selector) {
1585 var last = el.lastElementChild;
1586 while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
1587 last = last.previousElementSibling;
1588 }
1589 return last || null;
1590 }
1591
1592 /**
1593 * Returns the index of an element within its parent for a selected set of
1594 * elements
1595 * @param {HTMLElement} el
1596 * @param {selector} selector
1597 * @return {number}
1598 */
1599 function index(el, selector) {
1600 var index = 0;
1601 if (!el || !el.parentNode) {
1602 return -1;
1603 }
1604
1605 /* jshint boss:true */
1606 while (el = el.previousElementSibling) {
1607 if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
1608 index++;
1609 }
1610 }
1611 return index;
1612 }
1613
1614 /**
1615 * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
1616 * The value is returned in real pixels.
1617 * @param {HTMLElement} el
1618 * @return {Array} Offsets in the format of [left, top]
1619 */
1620 function getRelativeScrollOffset(el) {
1621 var offsetLeft = 0,
1622 offsetTop = 0,
1623 winScroller = getWindowScrollingElement();
1624 if (el) {
1625 do {
1626 var elMatrix = matrix(el),
1627 scaleX = elMatrix.a,
1628 scaleY = elMatrix.d;
1629 offsetLeft += el.scrollLeft * scaleX;
1630 offsetTop += el.scrollTop * scaleY;
1631 } while (el !== winScroller && (el = el.parentNode));
1632 }
1633 return [offsetLeft, offsetTop];
1634 }
1635
1636 /**
1637 * Returns the index of the object within the given array
1638 * @param {Array} arr Array that may or may not hold the object
1639 * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
1640 * @return {Number} The index of the object in the array, or -1
1641 */
1642 function indexOfObject(arr, obj) {
1643 for (var i in arr) {
1644 if (!arr.hasOwnProperty(i)) continue;
1645 for (var key in obj) {
1646 if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
1647 }
1648 }
1649 return -1;
1650 }
1651 function getParentAutoScrollElement(el, includeSelf) {
1652 // skip to window
1653 if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
1654 var elem = el;
1655 var gotSelf = false;
1656 do {
1657 // we don't need to get elem css if it isn't even overflowing in the first place (performance)
1658 if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
1659 var elemCSS = css(elem);
1660 if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
1661 if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
1662 if (gotSelf || includeSelf) return elem;
1663 gotSelf = true;
1664 }
1665 }
1666 /* jshint boss:true */
1667 } while (elem = elem.parentNode);
1668 return getWindowScrollingElement();
1669 }
1670 function extend(dst, src) {
1671 if (dst && src) {
1672 for (var key in src) {
1673 if (src.hasOwnProperty(key)) {
1674 dst[key] = src[key];
1675 }
1676 }
1677 }
1678 return dst;
1679 }
1680 function isRectEqual(rect1, rect2) {
1681 return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
1682 }
1683 var _throttleTimeout;
1684 function throttle(callback, ms) {
1685 return function () {
1686 if (!_throttleTimeout) {
1687 var args = arguments,
1688 _this = this;
1689 if (args.length === 1) {
1690 callback.call(_this, args[0]);
1691 } else {
1692 callback.apply(_this, args);
1693 }
1694 _throttleTimeout = setTimeout(function () {
1695 _throttleTimeout = void 0;
1696 }, ms);
1697 }
1698 };
1699 }
1700 function cancelThrottle() {
1701 clearTimeout(_throttleTimeout);
1702 _throttleTimeout = void 0;
1703 }
1704 function scrollBy(el, x, y) {
1705 el.scrollLeft += x;
1706 el.scrollTop += y;
1707 }
1708 function clone(el) {
1709 var Polymer = window.Polymer;
1710 var $ = window.jQuery || window.Zepto;
1711 if (Polymer && Polymer.dom) {
1712 return Polymer.dom(el).cloneNode(true);
1713 } else if ($) {
1714 return $(el).clone(true)[0];
1715 } else {
1716 return el.cloneNode(true);
1717 }
1718 }
1719 function setRect(el, rect) {
1720 css(el, 'position', 'absolute');
1721 css(el, 'top', rect.top);
1722 css(el, 'left', rect.left);
1723 css(el, 'width', rect.width);
1724 css(el, 'height', rect.height);
1725 }
1726 function unsetRect(el) {
1727 css(el, 'position', '');
1728 css(el, 'top', '');
1729 css(el, 'left', '');
1730 css(el, 'width', '');
1731 css(el, 'height', '');
1732 }
1733 function getChildContainingRectFromElement(container, options, ghostEl) {
1734 var rect = {};
1735 Array.from(container.children).forEach(function (child) {
1736 var _rect$left, _rect$top, _rect$right, _rect$bottom;
1737 if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
1738 var childRect = getRect(child);
1739 rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
1740 rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
1741 rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
1742 rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
1743 });
1744 rect.width = rect.right - rect.left;
1745 rect.height = rect.bottom - rect.top;
1746 rect.x = rect.left;
1747 rect.y = rect.top;
1748 return rect;
1749 }
1750 var expando = 'Sortable' + new Date().getTime();
1751
1752 function AnimationStateManager() {
1753 var animationStates = [],
1754 animationCallbackId;
1755 return {
1756 captureAnimationState: function captureAnimationState() {
1757 animationStates = [];
1758 if (!this.options.animation) return;
1759 var children = [].slice.call(this.el.children);
1760 children.forEach(function (child) {
1761 if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
1762 animationStates.push({
1763 target: child,
1764 rect: getRect(child)
1765 });
1766 var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
1767
1768 // If animating: compensate for current animation
1769 if (child.thisAnimationDuration) {
1770 var childMatrix = matrix(child, true);
1771 if (childMatrix) {
1772 fromRect.top -= childMatrix.f;
1773 fromRect.left -= childMatrix.e;
1774 }
1775 }
1776 child.fromRect = fromRect;
1777 });
1778 },
1779 addAnimationState: function addAnimationState(state) {
1780 animationStates.push(state);
1781 },
1782 removeAnimationState: function removeAnimationState(target) {
1783 animationStates.splice(indexOfObject(animationStates, {
1784 target: target
1785 }), 1);
1786 },
1787 animateAll: function animateAll(callback) {
1788 var _this = this;
1789 if (!this.options.animation) {
1790 clearTimeout(animationCallbackId);
1791 if (typeof callback === 'function') callback();
1792 return;
1793 }
1794 var animating = false,
1795 animationTime = 0;
1796 animationStates.forEach(function (state) {
1797 var time = 0,
1798 target = state.target,
1799 fromRect = target.fromRect,
1800 toRect = getRect(target),
1801 prevFromRect = target.prevFromRect,
1802 prevToRect = target.prevToRect,
1803 animatingRect = state.rect,
1804 targetMatrix = matrix(target, true);
1805 if (targetMatrix) {
1806 // Compensate for current animation
1807 toRect.top -= targetMatrix.f;
1808 toRect.left -= targetMatrix.e;
1809 }
1810 target.toRect = toRect;
1811 if (target.thisAnimationDuration) {
1812 // Could also check if animatingRect is between fromRect and toRect
1813 if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
1814 // Make sure animatingRect is on line between toRect & fromRect
1815 (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
1816 // If returning to same place as started from animation and on same axis
1817 time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
1818 }
1819 }
1820
1821 // if fromRect != toRect: animate
1822 if (!isRectEqual(toRect, fromRect)) {
1823 target.prevFromRect = fromRect;
1824 target.prevToRect = toRect;
1825 if (!time) {
1826 time = _this.options.animation;
1827 }
1828 _this.animate(target, animatingRect, toRect, time);
1829 }
1830 if (time) {
1831 animating = true;
1832 animationTime = Math.max(animationTime, time);
1833 clearTimeout(target.animationResetTimer);
1834 target.animationResetTimer = setTimeout(function () {
1835 target.animationTime = 0;
1836 target.prevFromRect = null;
1837 target.fromRect = null;
1838 target.prevToRect = null;
1839 target.thisAnimationDuration = null;
1840 }, time);
1841 target.thisAnimationDuration = time;
1842 }
1843 });
1844 clearTimeout(animationCallbackId);
1845 if (!animating) {
1846 if (typeof callback === 'function') callback();
1847 } else {
1848 animationCallbackId = setTimeout(function () {
1849 if (typeof callback === 'function') callback();
1850 }, animationTime);
1851 }
1852 animationStates = [];
1853 },
1854 animate: function animate(target, currentRect, toRect, duration) {
1855 if (duration) {
1856 css(target, 'transition', '');
1857 css(target, 'transform', '');
1858 var elMatrix = matrix(this.el),
1859 scaleX = elMatrix && elMatrix.a,
1860 scaleY = elMatrix && elMatrix.d,
1861 translateX = (currentRect.left - toRect.left) / (scaleX || 1),
1862 translateY = (currentRect.top - toRect.top) / (scaleY || 1);
1863 target.animatingX = !!translateX;
1864 target.animatingY = !!translateY;
1865 css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
1866 this.forRepaintDummy = repaint(target); // repaint
1867
1868 css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
1869 css(target, 'transform', 'translate3d(0,0,0)');
1870 typeof target.animated === 'number' && clearTimeout(target.animated);
1871 target.animated = setTimeout(function () {
1872 css(target, 'transition', '');
1873 css(target, 'transform', '');
1874 target.animated = false;
1875 target.animatingX = false;
1876 target.animatingY = false;
1877 }, duration);
1878 }
1879 }
1880 };
1881 }
1882 function repaint(target) {
1883 return target.offsetWidth;
1884 }
1885 function calculateRealTime(animatingRect, fromRect, toRect, options) {
1886 return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
1887 }
1888
1889 var plugins = [];
1890 var defaults = {
1891 initializeByDefault: true
1892 };
1893 var PluginManager = {
1894 mount: function mount(plugin) {
1895 // Set default static properties
1896 for (var option in defaults) {
1897 if (defaults.hasOwnProperty(option) && !(option in plugin)) {
1898 plugin[option] = defaults[option];
1899 }
1900 }
1901 plugins.forEach(function (p) {
1902 if (p.pluginName === plugin.pluginName) {
1903 throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
1904 }
1905 });
1906 plugins.push(plugin);
1907 },
1908 pluginEvent: function pluginEvent(eventName, sortable, evt) {
1909 var _this = this;
1910 this.eventCanceled = false;
1911 evt.cancel = function () {
1912 _this.eventCanceled = true;
1913 };
1914 var eventNameGlobal = eventName + 'Global';
1915 plugins.forEach(function (plugin) {
1916 if (!sortable[plugin.pluginName]) return;
1917 // Fire global events if it exists in this sortable
1918 if (sortable[plugin.pluginName][eventNameGlobal]) {
1919 sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
1920 sortable: sortable
1921 }, evt));
1922 }
1923
1924 // Only fire plugin event if plugin is enabled in this sortable,
1925 // and plugin has event defined
1926 if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
1927 sortable[plugin.pluginName][eventName](_objectSpread2({
1928 sortable: sortable
1929 }, evt));
1930 }
1931 });
1932 },
1933 initializePlugins: function initializePlugins(sortable, el, defaults, options) {
1934 plugins.forEach(function (plugin) {
1935 var pluginName = plugin.pluginName;
1936 if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
1937 var initialized = new plugin(sortable, el, sortable.options);
1938 initialized.sortable = sortable;
1939 initialized.options = sortable.options;
1940 sortable[pluginName] = initialized;
1941
1942 // Add default options from plugin
1943 _extends(defaults, initialized.defaults);
1944 });
1945 for (var option in sortable.options) {
1946 if (!sortable.options.hasOwnProperty(option)) continue;
1947 var modified = this.modifyOption(sortable, option, sortable.options[option]);
1948 if (typeof modified !== 'undefined') {
1949 sortable.options[option] = modified;
1950 }
1951 }
1952 },
1953 getEventProperties: function getEventProperties(name, sortable) {
1954 var eventProperties = {};
1955 plugins.forEach(function (plugin) {
1956 if (typeof plugin.eventProperties !== 'function') return;
1957 _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
1958 });
1959 return eventProperties;
1960 },
1961 modifyOption: function modifyOption(sortable, name, value) {
1962 var modifiedValue;
1963 plugins.forEach(function (plugin) {
1964 // Plugin must exist on the Sortable
1965 if (!sortable[plugin.pluginName]) return;
1966
1967 // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
1968 if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
1969 modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
1970 }
1971 });
1972 return modifiedValue;
1973 }
1974 };
1975
1976 function dispatchEvent(_ref) {
1977 var sortable = _ref.sortable,
1978 rootEl = _ref.rootEl,
1979 name = _ref.name,
1980 targetEl = _ref.targetEl,
1981 cloneEl = _ref.cloneEl,
1982 toEl = _ref.toEl,
1983 fromEl = _ref.fromEl,
1984 oldIndex = _ref.oldIndex,
1985 newIndex = _ref.newIndex,
1986 oldDraggableIndex = _ref.oldDraggableIndex,
1987 newDraggableIndex = _ref.newDraggableIndex,
1988 originalEvent = _ref.originalEvent,
1989 putSortable = _ref.putSortable,
1990 extraEventProperties = _ref.extraEventProperties;
1991 sortable = sortable || rootEl && rootEl[expando];
1992 if (!sortable) return;
1993 var evt,
1994 options = sortable.options,
1995 onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
1996 // Support for new CustomEvent feature
1997 if (window.CustomEvent && !IE11OrLess && !Edge) {
1998 evt = new CustomEvent(name, {
1999 bubbles: true,
2000 cancelable: true
2001 });
2002 } else {
2003 evt = document.createEvent('Event');
2004 evt.initEvent(name, true, true);
2005 }
2006 evt.to = toEl || rootEl;
2007 evt.from = fromEl || rootEl;
2008 evt.item = targetEl || rootEl;
2009 evt.clone = cloneEl;
2010 evt.oldIndex = oldIndex;
2011 evt.newIndex = newIndex;
2012 evt.oldDraggableIndex = oldDraggableIndex;
2013 evt.newDraggableIndex = newDraggableIndex;
2014 evt.originalEvent = originalEvent;
2015 evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
2016 var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
2017 for (var option in allEventProperties) {
2018 evt[option] = allEventProperties[option];
2019 }
2020 if (rootEl) {
2021 rootEl.dispatchEvent(evt);
2022 }
2023 if (options[onName]) {
2024 options[onName].call(sortable, evt);
2025 }
2026 }
2027
2028 var _excluded = ["evt"];
2029 var pluginEvent = function pluginEvent(eventName, sortable) {
2030 var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
2031 originalEvent = _ref.evt,
2032 data = _objectWithoutProperties(_ref, _excluded);
2033 PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
2034 dragEl: dragEl,
2035 parentEl: parentEl,
2036 ghostEl: ghostEl,
2037 rootEl: rootEl,
2038 nextEl: nextEl,
2039 lastDownEl: lastDownEl,
2040 cloneEl: cloneEl,
2041 cloneHidden: cloneHidden,
2042 dragStarted: moved,
2043 putSortable: putSortable,
2044 activeSortable: Sortable.active,
2045 originalEvent: originalEvent,
2046 oldIndex: oldIndex,
2047 oldDraggableIndex: oldDraggableIndex,
2048 newIndex: newIndex,
2049 newDraggableIndex: newDraggableIndex,
2050 hideGhostForTarget: _hideGhostForTarget,
2051 unhideGhostForTarget: _unhideGhostForTarget,
2052 cloneNowHidden: function cloneNowHidden() {
2053 cloneHidden = true;
2054 },
2055 cloneNowShown: function cloneNowShown() {
2056 cloneHidden = false;
2057 },
2058 dispatchSortableEvent: function dispatchSortableEvent(name) {
2059 _dispatchEvent({
2060 sortable: sortable,
2061 name: name,
2062 originalEvent: originalEvent
2063 });
2064 }
2065 }, data));
2066 };
2067 function _dispatchEvent(info) {
2068 dispatchEvent(_objectSpread2({
2069 putSortable: putSortable,
2070 cloneEl: cloneEl,
2071 targetEl: dragEl,
2072 rootEl: rootEl,
2073 oldIndex: oldIndex,
2074 oldDraggableIndex: oldDraggableIndex,
2075 newIndex: newIndex,
2076 newDraggableIndex: newDraggableIndex
2077 }, info));
2078 }
2079 var dragEl,
2080 parentEl,
2081 ghostEl,
2082 rootEl,
2083 nextEl,
2084 lastDownEl,
2085 cloneEl,
2086 cloneHidden,
2087 oldIndex,
2088 newIndex,
2089 oldDraggableIndex,
2090 newDraggableIndex,
2091 activeGroup,
2092 putSortable,
2093 awaitingDragStarted = false,
2094 ignoreNextClick = false,
2095 sortables = [],
2096 tapEvt,
2097 touchEvt,
2098 lastDx,
2099 lastDy,
2100 tapDistanceLeft,
2101 tapDistanceTop,
2102 moved,
2103 lastTarget,
2104 lastDirection,
2105 pastFirstInvertThresh = false,
2106 isCircumstantialInvert = false,
2107 targetMoveDistance,
2108 // For positioning ghost absolutely
2109 ghostRelativeParent,
2110 ghostRelativeParentInitialScroll = [],
2111 // (left, top)
2112
2113 _silent = false,
2114 savedInputChecked = [];
2115
2116 /** @const */
2117 var documentExists = typeof document !== 'undefined',
2118 PositionGhostAbsolutely = IOS,
2119 CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
2120 // This will not pass for IE9, because IE9 DnD only works on anchors
2121 supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
2122 supportCssPointerEvents = function () {
2123 if (!documentExists) return;
2124 // false when <= IE11
2125 if (IE11OrLess) {
2126 return false;
2127 }
2128 var el = document.createElement('x');
2129 el.style.cssText = 'pointer-events:auto';
2130 return el.style.pointerEvents === 'auto';
2131 }(),
2132 _detectDirection = function _detectDirection(el, options) {
2133 var elCSS = css(el),
2134 elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
2135 child1 = getChild(el, 0, options),
2136 child2 = getChild(el, 1, options),
2137 firstChildCSS = child1 && css(child1),
2138 secondChildCSS = child2 && css(child2),
2139 firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
2140 secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
2141 if (elCSS.display === 'flex') {
2142 return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
2143 }
2144 if (elCSS.display === 'grid') {
2145 return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
2146 }
2147 if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
2148 var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
2149 return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
2150 }
2151 return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
2152 },
2153 _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
2154 var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
2155 dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
2156 dragElOppLength = vertical ? dragRect.width : dragRect.height,
2157 targetS1Opp = vertical ? targetRect.left : targetRect.top,
2158 targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
2159 targetOppLength = vertical ? targetRect.width : targetRect.height;
2160 return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
2161 },
2162 /**
2163 * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
2164 * @param {Number} x X position
2165 * @param {Number} y Y position
2166 * @return {HTMLElement} Element of the first found nearest Sortable
2167 */
2168 _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
2169 var ret;
2170 sortables.some(function (sortable) {
2171 var threshold = sortable[expando].options.emptyInsertThreshold;
2172 if (!threshold || lastChild(sortable)) return;
2173 var rect = getRect(sortable),
2174 insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
2175 insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
2176 if (insideHorizontally && insideVertically) {
2177 return ret = sortable;
2178 }
2179 });
2180 return ret;
2181 },
2182 _prepareGroup = function _prepareGroup(options) {
2183 function toFn(value, pull) {
2184 return function (to, from, dragEl, evt) {
2185 var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
2186 if (value == null && (pull || sameGroup)) {
2187 // Default pull value
2188 // Default pull and put value if same group
2189 return true;
2190 } else if (value == null || value === false) {
2191 return false;
2192 } else if (pull && value === 'clone') {
2193 return value;
2194 } else if (typeof value === 'function') {
2195 return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
2196 } else {
2197 var otherGroup = (pull ? to : from).options.group.name;
2198 return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
2199 }
2200 };
2201 }
2202 var group = {};
2203 var originalGroup = options.group;
2204 if (!originalGroup || _typeof(originalGroup) != 'object') {
2205 originalGroup = {
2206 name: originalGroup
2207 };
2208 }
2209 group.name = originalGroup.name;
2210 group.checkPull = toFn(originalGroup.pull, true);
2211 group.checkPut = toFn(originalGroup.put);
2212 group.revertClone = originalGroup.revertClone;
2213 options.group = group;
2214 },
2215 _hideGhostForTarget = function _hideGhostForTarget() {
2216 if (!supportCssPointerEvents && ghostEl) {
2217 css(ghostEl, 'display', 'none');
2218 }
2219 },
2220 _unhideGhostForTarget = function _unhideGhostForTarget() {
2221 if (!supportCssPointerEvents && ghostEl) {
2222 css(ghostEl, 'display', '');
2223 }
2224 };
2225
2226 // #1184 fix - Prevent click event on fallback if dragged but item not changed position
2227 if (documentExists && !ChromeForAndroid) {
2228 document.addEventListener('click', function (evt) {
2229 if (ignoreNextClick) {
2230 evt.preventDefault();
2231 evt.stopPropagation && evt.stopPropagation();
2232 evt.stopImmediatePropagation && evt.stopImmediatePropagation();
2233 ignoreNextClick = false;
2234 return false;
2235 }
2236 }, true);
2237 }
2238 var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
2239 if (dragEl) {
2240 evt = evt.touches ? evt.touches[0] : evt;
2241 var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
2242 if (nearest) {
2243 // Create imitation event
2244 var event = {};
2245 for (var i in evt) {
2246 if (evt.hasOwnProperty(i)) {
2247 event[i] = evt[i];
2248 }
2249 }
2250 event.target = event.rootEl = nearest;
2251 event.preventDefault = void 0;
2252 event.stopPropagation = void 0;
2253 nearest[expando]._onDragOver(event);
2254 }
2255 }
2256 };
2257 var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
2258 if (dragEl) {
2259 dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
2260 }
2261 };
2262
2263 /**
2264 * @class Sortable
2265 * @param {HTMLElement} el
2266 * @param {Object} [options]
2267 */
2268 function Sortable(el, options) {
2269 if (!(el && el.nodeType && el.nodeType === 1)) {
2270 throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
2271 }
2272 this.el = el; // root element
2273 this.options = options = _extends({}, options);
2274
2275 // Export instance
2276 el[expando] = this;
2277 var defaults = {
2278 group: null,
2279 sort: true,
2280 disabled: false,
2281 store: null,
2282 handle: null,
2283 draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
2284 swapThreshold: 1,
2285 // percentage; 0 <= x <= 1
2286 invertSwap: false,
2287 // invert always
2288 invertedSwapThreshold: null,
2289 // will be set to same as swapThreshold if default
2290 removeCloneOnHide: true,
2291 direction: function direction() {
2292 return _detectDirection(el, this.options);
2293 },
2294 ghostClass: 'sortable-ghost',
2295 chosenClass: 'sortable-chosen',
2296 dragClass: 'sortable-drag',
2297 ignore: 'a, img',
2298 filter: null,
2299 preventOnFilter: true,
2300 animation: 0,
2301 easing: null,
2302 setData: function setData(dataTransfer, dragEl) {
2303 dataTransfer.setData('Text', dragEl.textContent);
2304 },
2305 dropBubble: false,
2306 dragoverBubble: false,
2307 dataIdAttr: 'data-id',
2308 delay: 0,
2309 delayOnTouchOnly: false,
2310 touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
2311 forceFallback: false,
2312 fallbackClass: 'sortable-fallback',
2313 fallbackOnBody: false,
2314 fallbackTolerance: 0,
2315 fallbackOffset: {
2316 x: 0,
2317 y: 0
2318 },
2319 // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
2320 supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
2321 emptyInsertThreshold: 5
2322 };
2323 PluginManager.initializePlugins(this, el, defaults);
2324
2325 // Set default options
2326 for (var name in defaults) {
2327 !(name in options) && (options[name] = defaults[name]);
2328 }
2329 _prepareGroup(options);
2330
2331 // Bind all private methods
2332 for (var fn in this) {
2333 if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2334 this[fn] = this[fn].bind(this);
2335 }
2336 }
2337
2338 // Setup drag mode
2339 this.nativeDraggable = options.forceFallback ? false : supportDraggable;
2340 if (this.nativeDraggable) {
2341 // Touch start threshold cannot be greater than the native dragstart threshold
2342 this.options.touchStartThreshold = 1;
2343 }
2344
2345 // Bind events
2346 if (options.supportPointer) {
2347 on(el, 'pointerdown', this._onTapStart);
2348 } else {
2349 on(el, 'mousedown', this._onTapStart);
2350 on(el, 'touchstart', this._onTapStart);
2351 }
2352 if (this.nativeDraggable) {
2353 on(el, 'dragover', this);
2354 on(el, 'dragenter', this);
2355 }
2356 sortables.push(this.el);
2357
2358 // Restore sorting
2359 options.store && options.store.get && this.sort(options.store.get(this) || []);
2360
2361 // Add animation state manager
2362 _extends(this, AnimationStateManager());
2363 }
2364 Sortable.prototype = /** @lends Sortable.prototype */{
2365 constructor: Sortable,
2366 _isOutsideThisEl: function _isOutsideThisEl(target) {
2367 if (!this.el.contains(target) && target !== this.el) {
2368 lastTarget = null;
2369 }
2370 },
2371 _getDirection: function _getDirection(evt, target) {
2372 return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
2373 },
2374 _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
2375 if (!evt.cancelable) return;
2376 var _this = this,
2377 el = this.el,
2378 options = this.options,
2379 preventOnFilter = options.preventOnFilter,
2380 type = evt.type,
2381 touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
2382 target = (touch || evt).target,
2383 originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
2384 filter = options.filter;
2385 _saveInputCheckedState(el);
2386
2387 // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
2388 if (dragEl) {
2389 return;
2390 }
2391 if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
2392 return; // only left button and enabled
2393 }
2394
2395 // cancel dnd if original target is content editable
2396 if (originalTarget.isContentEditable) {
2397 return;
2398 }
2399
2400 // Safari ignores further event handling after mousedown
2401 if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
2402 return;
2403 }
2404 target = closest(target, options.draggable, el, false);
2405 if (target && target.animated) {
2406 return;
2407 }
2408 if (lastDownEl === target) {
2409 // Ignoring duplicate `down`
2410 return;
2411 }
2412
2413 // Get the index of the dragged element within its parent
2414 oldIndex = index(target);
2415 oldDraggableIndex = index(target, options.draggable);
2416
2417 // Check filter
2418 if (typeof filter === 'function') {
2419 if (filter.call(this, evt, target, this)) {
2420 _dispatchEvent({
2421 sortable: _this,
2422 rootEl: originalTarget,
2423 name: 'filter',
2424 targetEl: target,
2425 toEl: el,
2426 fromEl: el
2427 });
2428 pluginEvent('filter', _this, {
2429 evt: evt
2430 });
2431 preventOnFilter && evt.preventDefault();
2432 return; // cancel dnd
2433 }
2434 } else if (filter) {
2435 filter = filter.split(',').some(function (criteria) {
2436 criteria = closest(originalTarget, criteria.trim(), el, false);
2437 if (criteria) {
2438 _dispatchEvent({
2439 sortable: _this,
2440 rootEl: criteria,
2441 name: 'filter',
2442 targetEl: target,
2443 fromEl: el,
2444 toEl: el
2445 });
2446 pluginEvent('filter', _this, {
2447 evt: evt
2448 });
2449 return true;
2450 }
2451 });
2452 if (filter) {
2453 preventOnFilter && evt.preventDefault();
2454 return; // cancel dnd
2455 }
2456 }
2457 if (options.handle && !closest(originalTarget, options.handle, el, false)) {
2458 return;
2459 }
2460
2461 // Prepare `dragstart`
2462 this._prepareDragStart(evt, touch, target);
2463 },
2464 _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
2465 var _this = this,
2466 el = _this.el,
2467 options = _this.options,
2468 ownerDocument = el.ownerDocument,
2469 dragStartFn;
2470 if (target && !dragEl && target.parentNode === el) {
2471 var dragRect = getRect(target);
2472 rootEl = el;
2473 dragEl = target;
2474 parentEl = dragEl.parentNode;
2475 nextEl = dragEl.nextSibling;
2476 lastDownEl = target;
2477 activeGroup = options.group;
2478 Sortable.dragged = dragEl;
2479 tapEvt = {
2480 target: dragEl,
2481 clientX: (touch || evt).clientX,
2482 clientY: (touch || evt).clientY
2483 };
2484 tapDistanceLeft = tapEvt.clientX - dragRect.left;
2485 tapDistanceTop = tapEvt.clientY - dragRect.top;
2486 this._lastX = (touch || evt).clientX;
2487 this._lastY = (touch || evt).clientY;
2488 dragEl.style['will-change'] = 'all';
2489 dragStartFn = function dragStartFn() {
2490 pluginEvent('delayEnded', _this, {
2491 evt: evt
2492 });
2493 if (Sortable.eventCanceled) {
2494 _this._onDrop();
2495 return;
2496 }
2497 // Delayed drag has been triggered
2498 // we can re-enable the events: touchmove/mousemove
2499 _this._disableDelayedDragEvents();
2500 if (!FireFox && _this.nativeDraggable) {
2501 dragEl.draggable = true;
2502 }
2503
2504 // Bind the events: dragstart/dragend
2505 _this._triggerDragStart(evt, touch);
2506
2507 // Drag start event
2508 _dispatchEvent({
2509 sortable: _this,
2510 name: 'choose',
2511 originalEvent: evt
2512 });
2513
2514 // Chosen item
2515 toggleClass(dragEl, options.chosenClass, true);
2516 };
2517
2518 // Disable "draggable"
2519 options.ignore.split(',').forEach(function (criteria) {
2520 find(dragEl, criteria.trim(), _disableDraggable);
2521 });
2522 on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
2523 on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
2524 on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
2525 if (options.supportPointer) {
2526 on(ownerDocument, 'pointerup', _this._onDrop);
2527 // Native D&D triggers pointercancel
2528 !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
2529 } else {
2530 on(ownerDocument, 'mouseup', _this._onDrop);
2531 on(ownerDocument, 'touchend', _this._onDrop);
2532 on(ownerDocument, 'touchcancel', _this._onDrop);
2533 }
2534
2535 // Make dragEl draggable (must be before delay for FireFox)
2536 if (FireFox && this.nativeDraggable) {
2537 this.options.touchStartThreshold = 4;
2538 dragEl.draggable = true;
2539 }
2540 pluginEvent('delayStart', this, {
2541 evt: evt
2542 });
2543
2544 // Delay is impossible for native DnD in Edge or IE
2545 if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
2546 if (Sortable.eventCanceled) {
2547 this._onDrop();
2548 return;
2549 }
2550 // If the user moves the pointer or let go the click or touch
2551 // before the delay has been reached:
2552 // disable the delayed drag
2553 if (options.supportPointer) {
2554 on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
2555 on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
2556 } else {
2557 on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
2558 on(ownerDocument, 'touchend', _this._disableDelayedDrag);
2559 on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
2560 }
2561 on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
2562 on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
2563 options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
2564 _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
2565 } else {
2566 dragStartFn();
2567 }
2568 }
2569 },
2570 _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
2571 var touch = e.touches ? e.touches[0] : e;
2572 if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
2573 this._disableDelayedDrag();
2574 }
2575 },
2576 _disableDelayedDrag: function _disableDelayedDrag() {
2577 dragEl && _disableDraggable(dragEl);
2578 clearTimeout(this._dragStartTimer);
2579 this._disableDelayedDragEvents();
2580 },
2581 _disableDelayedDragEvents: function _disableDelayedDragEvents() {
2582 var ownerDocument = this.el.ownerDocument;
2583 off(ownerDocument, 'mouseup', this._disableDelayedDrag);
2584 off(ownerDocument, 'touchend', this._disableDelayedDrag);
2585 off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
2586 off(ownerDocument, 'pointerup', this._disableDelayedDrag);
2587 off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
2588 off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
2589 off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
2590 off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
2591 },
2592 _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
2593 touch = touch || evt.pointerType == 'touch' && evt;
2594 if (!this.nativeDraggable || touch) {
2595 if (this.options.supportPointer) {
2596 on(document, 'pointermove', this._onTouchMove);
2597 } else if (touch) {
2598 on(document, 'touchmove', this._onTouchMove);
2599 } else {
2600 on(document, 'mousemove', this._onTouchMove);
2601 }
2602 } else {
2603 on(dragEl, 'dragend', this);
2604 on(rootEl, 'dragstart', this._onDragStart);
2605 }
2606 try {
2607 if (document.selection) {
2608 _nextTick(function () {
2609 document.selection.empty();
2610 });
2611 } else {
2612 window.getSelection().removeAllRanges();
2613 }
2614 } catch (err) {}
2615 },
2616 _dragStarted: function _dragStarted(fallback, evt) {
2617 awaitingDragStarted = false;
2618 if (rootEl && dragEl) {
2619 pluginEvent('dragStarted', this, {
2620 evt: evt
2621 });
2622 if (this.nativeDraggable) {
2623 on(document, 'dragover', _checkOutsideTargetEl);
2624 }
2625 var options = this.options;
2626
2627 // Apply effect
2628 !fallback && toggleClass(dragEl, options.dragClass, false);
2629 toggleClass(dragEl, options.ghostClass, true);
2630 Sortable.active = this;
2631 fallback && this._appendGhost();
2632
2633 // Drag start event
2634 _dispatchEvent({
2635 sortable: this,
2636 name: 'start',
2637 originalEvent: evt
2638 });
2639 } else {
2640 this._nulling();
2641 }
2642 },
2643 _emulateDragOver: function _emulateDragOver() {
2644 if (touchEvt) {
2645 this._lastX = touchEvt.clientX;
2646 this._lastY = touchEvt.clientY;
2647 _hideGhostForTarget();
2648 var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
2649 var parent = target;
2650 while (target && target.shadowRoot) {
2651 target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
2652 if (target === parent) break;
2653 parent = target;
2654 }
2655 dragEl.parentNode[expando]._isOutsideThisEl(target);
2656 if (parent) {
2657 do {
2658 if (parent[expando]) {
2659 var inserted = void 0;
2660 inserted = parent[expando]._onDragOver({
2661 clientX: touchEvt.clientX,
2662 clientY: touchEvt.clientY,
2663 target: target,
2664 rootEl: parent
2665 });
2666 if (inserted && !this.options.dragoverBubble) {
2667 break;
2668 }
2669 }
2670 target = parent; // store last element
2671 }
2672 /* jshint boss:true */ while (parent = getParentOrHost(parent));
2673 }
2674 _unhideGhostForTarget();
2675 }
2676 },
2677 _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
2678 if (tapEvt) {
2679 var options = this.options,
2680 fallbackTolerance = options.fallbackTolerance,
2681 fallbackOffset = options.fallbackOffset,
2682 touch = evt.touches ? evt.touches[0] : evt,
2683 ghostMatrix = ghostEl && matrix(ghostEl, true),
2684 scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
2685 scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
2686 relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
2687 dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
2688 dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
2689
2690 // only set the status to dragging, when we are actually dragging
2691 if (!Sortable.active && !awaitingDragStarted) {
2692 if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
2693 return;
2694 }
2695 this._onDragStart(evt, true);
2696 }
2697 if (ghostEl) {
2698 if (ghostMatrix) {
2699 ghostMatrix.e += dx - (lastDx || 0);
2700 ghostMatrix.f += dy - (lastDy || 0);
2701 } else {
2702 ghostMatrix = {
2703 a: 1,
2704 b: 0,
2705 c: 0,
2706 d: 1,
2707 e: dx,
2708 f: dy
2709 };
2710 }
2711 var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
2712 css(ghostEl, 'webkitTransform', cssMatrix);
2713 css(ghostEl, 'mozTransform', cssMatrix);
2714 css(ghostEl, 'msTransform', cssMatrix);
2715 css(ghostEl, 'transform', cssMatrix);
2716 lastDx = dx;
2717 lastDy = dy;
2718 touchEvt = touch;
2719 }
2720 evt.cancelable && evt.preventDefault();
2721 }
2722 },
2723 _appendGhost: function _appendGhost() {
2724 // Bug if using scale(): https://stackoverflow.com/questions/2637058
2725 // Not being adjusted for
2726 if (!ghostEl) {
2727 var container = this.options.fallbackOnBody ? document.body : rootEl,
2728 rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
2729 options = this.options;
2730
2731 // Position absolutely
2732 if (PositionGhostAbsolutely) {
2733 // Get relatively positioned parent
2734 ghostRelativeParent = container;
2735 while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
2736 ghostRelativeParent = ghostRelativeParent.parentNode;
2737 }
2738 if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
2739 if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
2740 rect.top += ghostRelativeParent.scrollTop;
2741 rect.left += ghostRelativeParent.scrollLeft;
2742 } else {
2743 ghostRelativeParent = getWindowScrollingElement();
2744 }
2745 ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
2746 }
2747 ghostEl = dragEl.cloneNode(true);
2748 toggleClass(ghostEl, options.ghostClass, false);
2749 toggleClass(ghostEl, options.fallbackClass, true);
2750 toggleClass(ghostEl, options.dragClass, true);
2751 css(ghostEl, 'transition', '');
2752 css(ghostEl, 'transform', '');
2753 css(ghostEl, 'box-sizing', 'border-box');
2754 css(ghostEl, 'margin', 0);
2755 css(ghostEl, 'top', rect.top);
2756 css(ghostEl, 'left', rect.left);
2757 css(ghostEl, 'width', rect.width);
2758 css(ghostEl, 'height', rect.height);
2759 css(ghostEl, 'opacity', '0.8');
2760 css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
2761 css(ghostEl, 'zIndex', '100000');
2762 css(ghostEl, 'pointerEvents', 'none');
2763 Sortable.ghost = ghostEl;
2764 container.appendChild(ghostEl);
2765
2766 // Set transform-origin
2767 css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
2768 }
2769 },
2770 _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
2771 var _this = this;
2772 var dataTransfer = evt.dataTransfer;
2773 var options = _this.options;
2774 pluginEvent('dragStart', this, {
2775 evt: evt
2776 });
2777 if (Sortable.eventCanceled) {
2778 this._onDrop();
2779 return;
2780 }
2781 pluginEvent('setupClone', this);
2782 if (!Sortable.eventCanceled) {
2783 cloneEl = clone(dragEl);
2784 cloneEl.removeAttribute("id");
2785 cloneEl.draggable = false;
2786 cloneEl.style['will-change'] = '';
2787 this._hideClone();
2788 toggleClass(cloneEl, this.options.chosenClass, false);
2789 Sortable.clone = cloneEl;
2790 }
2791
2792 // #1143: IFrame support workaround
2793 _this.cloneId = _nextTick(function () {
2794 pluginEvent('clone', _this);
2795 if (Sortable.eventCanceled) return;
2796 if (!_this.options.removeCloneOnHide) {
2797 rootEl.insertBefore(cloneEl, dragEl);
2798 }
2799 _this._hideClone();
2800 _dispatchEvent({
2801 sortable: _this,
2802 name: 'clone'
2803 });
2804 });
2805 !fallback && toggleClass(dragEl, options.dragClass, true);
2806
2807 // Set proper drop events
2808 if (fallback) {
2809 ignoreNextClick = true;
2810 _this._loopId = setInterval(_this._emulateDragOver, 50);
2811 } else {
2812 // Undo what was set in _prepareDragStart before drag started
2813 off(document, 'mouseup', _this._onDrop);
2814 off(document, 'touchend', _this._onDrop);
2815 off(document, 'touchcancel', _this._onDrop);
2816 if (dataTransfer) {
2817 dataTransfer.effectAllowed = 'move';
2818 options.setData && options.setData.call(_this, dataTransfer, dragEl);
2819 }
2820 on(document, 'drop', _this);
2821
2822 // #1276 fix:
2823 css(dragEl, 'transform', 'translateZ(0)');
2824 }
2825 awaitingDragStarted = true;
2826 _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
2827 on(document, 'selectstart', _this);
2828 moved = true;
2829 window.getSelection().removeAllRanges();
2830 if (Safari) {
2831 css(document.body, 'user-select', 'none');
2832 }
2833 },
2834 // Returns true - if no further action is needed (either inserted or another condition)
2835 _onDragOver: function _onDragOver( /**Event*/evt) {
2836 var el = this.el,
2837 target = evt.target,
2838 dragRect,
2839 targetRect,
2840 revert,
2841 options = this.options,
2842 group = options.group,
2843 activeSortable = Sortable.active,
2844 isOwner = activeGroup === group,
2845 canSort = options.sort,
2846 fromSortable = putSortable || activeSortable,
2847 vertical,
2848 _this = this,
2849 completedFired = false;
2850 if (_silent) return;
2851 function dragOverEvent(name, extra) {
2852 pluginEvent(name, _this, _objectSpread2({
2853 evt: evt,
2854 isOwner: isOwner,
2855 axis: vertical ? 'vertical' : 'horizontal',
2856 revert: revert,
2857 dragRect: dragRect,
2858 targetRect: targetRect,
2859 canSort: canSort,
2860 fromSortable: fromSortable,
2861 target: target,
2862 completed: completed,
2863 onMove: function onMove(target, after) {
2864 return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
2865 },
2866 changed: changed
2867 }, extra));
2868 }
2869
2870 // Capture animation state
2871 function capture() {
2872 dragOverEvent('dragOverAnimationCapture');
2873 _this.captureAnimationState();
2874 if (_this !== fromSortable) {
2875 fromSortable.captureAnimationState();
2876 }
2877 }
2878
2879 // Return invocation when dragEl is inserted (or completed)
2880 function completed(insertion) {
2881 dragOverEvent('dragOverCompleted', {
2882 insertion: insertion
2883 });
2884 if (insertion) {
2885 // Clones must be hidden before folding animation to capture dragRectAbsolute properly
2886 if (isOwner) {
2887 activeSortable._hideClone();
2888 } else {
2889 activeSortable._showClone(_this);
2890 }
2891 if (_this !== fromSortable) {
2892 // Set ghost class to new sortable's ghost class
2893 toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
2894 toggleClass(dragEl, options.ghostClass, true);
2895 }
2896 if (putSortable !== _this && _this !== Sortable.active) {
2897 putSortable = _this;
2898 } else if (_this === Sortable.active && putSortable) {
2899 putSortable = null;
2900 }
2901
2902 // Animation
2903 if (fromSortable === _this) {
2904 _this._ignoreWhileAnimating = target;
2905 }
2906 _this.animateAll(function () {
2907 dragOverEvent('dragOverAnimationComplete');
2908 _this._ignoreWhileAnimating = null;
2909 });
2910 if (_this !== fromSortable) {
2911 fromSortable.animateAll();
2912 fromSortable._ignoreWhileAnimating = null;
2913 }
2914 }
2915
2916 // Null lastTarget if it is not inside a previously swapped element
2917 if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
2918 lastTarget = null;
2919 }
2920
2921 // no bubbling and not fallback
2922 if (!options.dragoverBubble && !evt.rootEl && target !== document) {
2923 dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
2924
2925 // Do not detect for empty insert if already inserted
2926 !insertion && nearestEmptyInsertDetectEvent(evt);
2927 }
2928 !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
2929 return completedFired = true;
2930 }
2931
2932 // Call when dragEl has been inserted
2933 function changed() {
2934 newIndex = index(dragEl);
2935 newDraggableIndex = index(dragEl, options.draggable);
2936 _dispatchEvent({
2937 sortable: _this,
2938 name: 'change',
2939 toEl: el,
2940 newIndex: newIndex,
2941 newDraggableIndex: newDraggableIndex,
2942 originalEvent: evt
2943 });
2944 }
2945 if (evt.preventDefault !== void 0) {
2946 evt.cancelable && evt.preventDefault();
2947 }
2948 target = closest(target, options.draggable, el, true);
2949 dragOverEvent('dragOver');
2950 if (Sortable.eventCanceled) return completedFired;
2951 if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
2952 return completed(false);
2953 }
2954 ignoreNextClick = false;
2955 if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
2956 : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
2957 vertical = this._getDirection(evt, target) === 'vertical';
2958 dragRect = getRect(dragEl);
2959 dragOverEvent('dragOverValid');
2960 if (Sortable.eventCanceled) return completedFired;
2961 if (revert) {
2962 parentEl = rootEl; // actualization
2963 capture();
2964 this._hideClone();
2965 dragOverEvent('revert');
2966 if (!Sortable.eventCanceled) {
2967 if (nextEl) {
2968 rootEl.insertBefore(dragEl, nextEl);
2969 } else {
2970 rootEl.appendChild(dragEl);
2971 }
2972 }
2973 return completed(true);
2974 }
2975 var elLastChild = lastChild(el, options.draggable);
2976 if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
2977 // Insert to end of list
2978
2979 // If already at end of list: Do not insert
2980 if (elLastChild === dragEl) {
2981 return completed(false);
2982 }
2983
2984 // if there is a last element, it is the target
2985 if (elLastChild && el === evt.target) {
2986 target = elLastChild;
2987 }
2988 if (target) {
2989 targetRect = getRect(target);
2990 }
2991 if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
2992 capture();
2993 if (elLastChild && elLastChild.nextSibling) {
2994 // the last draggable element is not the last node
2995 el.insertBefore(dragEl, elLastChild.nextSibling);
2996 } else {
2997 el.appendChild(dragEl);
2998 }
2999 parentEl = el; // actualization
3000
3001 changed();
3002 return completed(true);
3003 }
3004 } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
3005 // Insert to start of list
3006 var firstChild = getChild(el, 0, options, true);
3007 if (firstChild === dragEl) {
3008 return completed(false);
3009 }
3010 target = firstChild;
3011 targetRect = getRect(target);
3012 if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
3013 capture();
3014 el.insertBefore(dragEl, firstChild);
3015 parentEl = el; // actualization
3016
3017 changed();
3018 return completed(true);
3019 }
3020 } else if (target.parentNode === el) {
3021 targetRect = getRect(target);
3022 var direction = 0,
3023 targetBeforeFirstSwap,
3024 differentLevel = dragEl.parentNode !== el,
3025 differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
3026 side1 = vertical ? 'top' : 'left',
3027 scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
3028 scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
3029 if (lastTarget !== target) {
3030 targetBeforeFirstSwap = targetRect[side1];
3031 pastFirstInvertThresh = false;
3032 isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
3033 }
3034 direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
3035 var sibling;
3036 if (direction !== 0) {
3037 // Check if target is beside dragEl in respective direction (ignoring hidden elements)
3038 var dragIndex = index(dragEl);
3039 do {
3040 dragIndex -= direction;
3041 sibling = parentEl.children[dragIndex];
3042 } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
3043 }
3044 // If dragEl is already beside target: Do not insert
3045 if (direction === 0 || sibling === target) {
3046 return completed(false);
3047 }
3048 lastTarget = target;
3049 lastDirection = direction;
3050 var nextSibling = target.nextElementSibling,
3051 after = false;
3052 after = direction === 1;
3053 var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
3054 if (moveVector !== false) {
3055 if (moveVector === 1 || moveVector === -1) {
3056 after = moveVector === 1;
3057 }
3058 _silent = true;
3059 setTimeout(_unsilent, 30);
3060 capture();
3061 if (after && !nextSibling) {
3062 el.appendChild(dragEl);
3063 } else {
3064 target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
3065 }
3066
3067 // Undo chrome's scroll adjustment (has no effect on other browsers)
3068 if (scrolledPastTop) {
3069 scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
3070 }
3071 parentEl = dragEl.parentNode; // actualization
3072
3073 // must be done before animation
3074 if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
3075 targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
3076 }
3077 changed();
3078 return completed(true);
3079 }
3080 }
3081 if (el.contains(dragEl)) {
3082 return completed(false);
3083 }
3084 }
3085 return false;
3086 },
3087 _ignoreWhileAnimating: null,
3088 _offMoveEvents: function _offMoveEvents() {
3089 off(document, 'mousemove', this._onTouchMove);
3090 off(document, 'touchmove', this._onTouchMove);
3091 off(document, 'pointermove', this._onTouchMove);
3092 off(document, 'dragover', nearestEmptyInsertDetectEvent);
3093 off(document, 'mousemove', nearestEmptyInsertDetectEvent);
3094 off(document, 'touchmove', nearestEmptyInsertDetectEvent);
3095 },
3096 _offUpEvents: function _offUpEvents() {
3097 var ownerDocument = this.el.ownerDocument;
3098 off(ownerDocument, 'mouseup', this._onDrop);
3099 off(ownerDocument, 'touchend', this._onDrop);
3100 off(ownerDocument, 'pointerup', this._onDrop);
3101 off(ownerDocument, 'pointercancel', this._onDrop);
3102 off(ownerDocument, 'touchcancel', this._onDrop);
3103 off(document, 'selectstart', this);
3104 },
3105 _onDrop: function _onDrop( /**Event*/evt) {
3106 var el = this.el,
3107 options = this.options;
3108
3109 // Get the index of the dragged element within its parent
3110 newIndex = index(dragEl);
3111 newDraggableIndex = index(dragEl, options.draggable);
3112 pluginEvent('drop', this, {
3113 evt: evt
3114 });
3115 parentEl = dragEl && dragEl.parentNode;
3116
3117 // Get again after plugin event
3118 newIndex = index(dragEl);
3119 newDraggableIndex = index(dragEl, options.draggable);
3120 if (Sortable.eventCanceled) {
3121 this._nulling();
3122 return;
3123 }
3124 awaitingDragStarted = false;
3125 isCircumstantialInvert = false;
3126 pastFirstInvertThresh = false;
3127 clearInterval(this._loopId);
3128 clearTimeout(this._dragStartTimer);
3129 _cancelNextTick(this.cloneId);
3130 _cancelNextTick(this._dragStartId);
3131
3132 // Unbind events
3133 if (this.nativeDraggable) {
3134 off(document, 'drop', this);
3135 off(el, 'dragstart', this._onDragStart);
3136 }
3137 this._offMoveEvents();
3138 this._offUpEvents();
3139 if (Safari) {
3140 css(document.body, 'user-select', '');
3141 }
3142 css(dragEl, 'transform', '');
3143 if (evt) {
3144 if (moved) {
3145 evt.cancelable && evt.preventDefault();
3146 !options.dropBubble && evt.stopPropagation();
3147 }
3148 ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
3149 if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
3150 // Remove clone(s)
3151 cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
3152 }
3153 if (dragEl) {
3154 if (this.nativeDraggable) {
3155 off(dragEl, 'dragend', this);
3156 }
3157 _disableDraggable(dragEl);
3158 dragEl.style['will-change'] = '';
3159
3160 // Remove classes
3161 // ghostClass is added in dragStarted
3162 if (moved && !awaitingDragStarted) {
3163 toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
3164 }
3165 toggleClass(dragEl, this.options.chosenClass, false);
3166
3167 // Drag stop event
3168 _dispatchEvent({
3169 sortable: this,
3170 name: 'unchoose',
3171 toEl: parentEl,
3172 newIndex: null,
3173 newDraggableIndex: null,
3174 originalEvent: evt
3175 });
3176 if (rootEl !== parentEl) {
3177 if (newIndex >= 0) {
3178 // Add event
3179 _dispatchEvent({
3180 rootEl: parentEl,
3181 name: 'add',
3182 toEl: parentEl,
3183 fromEl: rootEl,
3184 originalEvent: evt
3185 });
3186
3187 // Remove event
3188 _dispatchEvent({
3189 sortable: this,
3190 name: 'remove',
3191 toEl: parentEl,
3192 originalEvent: evt
3193 });
3194
3195 // drag from one list and drop into another
3196 _dispatchEvent({
3197 rootEl: parentEl,
3198 name: 'sort',
3199 toEl: parentEl,
3200 fromEl: rootEl,
3201 originalEvent: evt
3202 });
3203 _dispatchEvent({
3204 sortable: this,
3205 name: 'sort',
3206 toEl: parentEl,
3207 originalEvent: evt
3208 });
3209 }
3210 putSortable && putSortable.save();
3211 } else {
3212 if (newIndex !== oldIndex) {
3213 if (newIndex >= 0) {
3214 // drag & drop within the same list
3215 _dispatchEvent({
3216 sortable: this,
3217 name: 'update',
3218 toEl: parentEl,
3219 originalEvent: evt
3220 });
3221 _dispatchEvent({
3222 sortable: this,
3223 name: 'sort',
3224 toEl: parentEl,
3225 originalEvent: evt
3226 });
3227 }
3228 }
3229 }
3230 if (Sortable.active) {
3231 /* jshint eqnull:true */
3232 if (newIndex == null || newIndex === -1) {
3233 newIndex = oldIndex;
3234 newDraggableIndex = oldDraggableIndex;
3235 }
3236 _dispatchEvent({
3237 sortable: this,
3238 name: 'end',
3239 toEl: parentEl,
3240 originalEvent: evt
3241 });
3242
3243 // Save sorting
3244 this.save();
3245 }
3246 }
3247 }
3248 this._nulling();
3249 },
3250 _nulling: function _nulling() {
3251 pluginEvent('nulling', this);
3252 rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
3253 savedInputChecked.forEach(function (el) {
3254 el.checked = true;
3255 });
3256 savedInputChecked.length = lastDx = lastDy = 0;
3257 },
3258 handleEvent: function handleEvent( /**Event*/evt) {
3259 switch (evt.type) {
3260 case 'drop':
3261 case 'dragend':
3262 this._onDrop(evt);
3263 break;
3264 case 'dragenter':
3265 case 'dragover':
3266 if (dragEl) {
3267 this._onDragOver(evt);
3268 _globalDragOver(evt);
3269 }
3270 break;
3271 case 'selectstart':
3272 evt.preventDefault();
3273 break;
3274 }
3275 },
3276 /**
3277 * Serializes the item into an array of string.
3278 * @returns {String[]}
3279 */
3280 toArray: function toArray() {
3281 var order = [],
3282 el,
3283 children = this.el.children,
3284 i = 0,
3285 n = children.length,
3286 options = this.options;
3287 for (; i < n; i++) {
3288 el = children[i];
3289 if (closest(el, options.draggable, this.el, false)) {
3290 order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
3291 }
3292 }
3293 return order;
3294 },
3295 /**
3296 * Sorts the elements according to the array.
3297 * @param {String[]} order order of the items
3298 */
3299 sort: function sort(order, useAnimation) {
3300 var items = {},
3301 rootEl = this.el;
3302 this.toArray().forEach(function (id, i) {
3303 var el = rootEl.children[i];
3304 if (closest(el, this.options.draggable, rootEl, false)) {
3305 items[id] = el;
3306 }
3307 }, this);
3308 useAnimation && this.captureAnimationState();
3309 order.forEach(function (id) {
3310 if (items[id]) {
3311 rootEl.removeChild(items[id]);
3312 rootEl.appendChild(items[id]);
3313 }
3314 });
3315 useAnimation && this.animateAll();
3316 },
3317 /**
3318 * Save the current sorting
3319 */
3320 save: function save() {
3321 var store = this.options.store;
3322 store && store.set && store.set(this);
3323 },
3324 /**
3325 * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
3326 * @param {HTMLElement} el
3327 * @param {String} [selector] default: `options.draggable`
3328 * @returns {HTMLElement|null}
3329 */
3330 closest: function closest$1(el, selector) {
3331 return closest(el, selector || this.options.draggable, this.el, false);
3332 },
3333 /**
3334 * Set/get option
3335 * @param {string} name
3336 * @param {*} [value]
3337 * @returns {*}
3338 */
3339 option: function option(name, value) {
3340 var options = this.options;
3341 if (value === void 0) {
3342 return options[name];
3343 } else {
3344 var modifiedValue = PluginManager.modifyOption(this, name, value);
3345 if (typeof modifiedValue !== 'undefined') {
3346 options[name] = modifiedValue;
3347 } else {
3348 options[name] = value;
3349 }
3350 if (name === 'group') {
3351 _prepareGroup(options);
3352 }
3353 }
3354 },
3355 /**
3356 * Destroy
3357 */
3358 destroy: function destroy() {
3359 pluginEvent('destroy', this);
3360 var el = this.el;
3361 el[expando] = null;
3362 off(el, 'mousedown', this._onTapStart);
3363 off(el, 'touchstart', this._onTapStart);
3364 off(el, 'pointerdown', this._onTapStart);
3365 if (this.nativeDraggable) {
3366 off(el, 'dragover', this);
3367 off(el, 'dragenter', this);
3368 }
3369 // Remove draggable attributes
3370 Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
3371 el.removeAttribute('draggable');
3372 });
3373 this._onDrop();
3374 this._disableDelayedDragEvents();
3375 sortables.splice(sortables.indexOf(this.el), 1);
3376 this.el = el = null;
3377 },
3378 _hideClone: function _hideClone() {
3379 if (!cloneHidden) {
3380 pluginEvent('hideClone', this);
3381 if (Sortable.eventCanceled) return;
3382 css(cloneEl, 'display', 'none');
3383 if (this.options.removeCloneOnHide && cloneEl.parentNode) {
3384 cloneEl.parentNode.removeChild(cloneEl);
3385 }
3386 cloneHidden = true;
3387 }
3388 },
3389 _showClone: function _showClone(putSortable) {
3390 if (putSortable.lastPutMode !== 'clone') {
3391 this._hideClone();
3392 return;
3393 }
3394 if (cloneHidden) {
3395 pluginEvent('showClone', this);
3396 if (Sortable.eventCanceled) return;
3397
3398 // show clone at dragEl or original position
3399 if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
3400 rootEl.insertBefore(cloneEl, dragEl);
3401 } else if (nextEl) {
3402 rootEl.insertBefore(cloneEl, nextEl);
3403 } else {
3404 rootEl.appendChild(cloneEl);
3405 }
3406 if (this.options.group.revertClone) {
3407 this.animate(dragEl, cloneEl);
3408 }
3409 css(cloneEl, 'display', '');
3410 cloneHidden = false;
3411 }
3412 }
3413 };
3414 function _globalDragOver( /**Event*/evt) {
3415 if (evt.dataTransfer) {
3416 evt.dataTransfer.dropEffect = 'move';
3417 }
3418 evt.cancelable && evt.preventDefault();
3419 }
3420 function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
3421 var evt,
3422 sortable = fromEl[expando],
3423 onMoveFn = sortable.options.onMove,
3424 retVal;
3425 // Support for new CustomEvent feature
3426 if (window.CustomEvent && !IE11OrLess && !Edge) {
3427 evt = new CustomEvent('move', {
3428 bubbles: true,
3429 cancelable: true
3430 });
3431 } else {
3432 evt = document.createEvent('Event');
3433 evt.initEvent('move', true, true);
3434 }
3435 evt.to = toEl;
3436 evt.from = fromEl;
3437 evt.dragged = dragEl;
3438 evt.draggedRect = dragRect;
3439 evt.related = targetEl || toEl;
3440 evt.relatedRect = targetRect || getRect(toEl);
3441 evt.willInsertAfter = willInsertAfter;
3442 evt.originalEvent = originalEvent;
3443 fromEl.dispatchEvent(evt);
3444 if (onMoveFn) {
3445 retVal = onMoveFn.call(sortable, evt, originalEvent);
3446 }
3447 return retVal;
3448 }
3449 function _disableDraggable(el) {
3450 el.draggable = false;
3451 }
3452 function _unsilent() {
3453 _silent = false;
3454 }
3455 function _ghostIsFirst(evt, vertical, sortable) {
3456 var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
3457 var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
3458 var spacer = 10;
3459 return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
3460 }
3461 function _ghostIsLast(evt, vertical, sortable) {
3462 var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
3463 var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
3464 var spacer = 10;
3465 return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
3466 }
3467 function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
3468 var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
3469 targetLength = vertical ? targetRect.height : targetRect.width,
3470 targetS1 = vertical ? targetRect.top : targetRect.left,
3471 targetS2 = vertical ? targetRect.bottom : targetRect.right,
3472 invert = false;
3473 if (!invertSwap) {
3474 // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
3475 if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
3476 // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
3477 // check if past first invert threshold on side opposite of lastDirection
3478 if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
3479 // past first invert threshold, do not restrict inverted threshold to dragEl shadow
3480 pastFirstInvertThresh = true;
3481 }
3482 if (!pastFirstInvertThresh) {
3483 // dragEl shadow (target move distance shadow)
3484 if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
3485 : mouseOnAxis > targetS2 - targetMoveDistance) {
3486 return -lastDirection;
3487 }
3488 } else {
3489 invert = true;
3490 }
3491 } else {
3492 // Regular
3493 if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
3494 return _getInsertDirection(target);
3495 }
3496 }
3497 }
3498 invert = invert || invertSwap;
3499 if (invert) {
3500 // Invert of regular
3501 if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
3502 return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
3503 }
3504 }
3505 return 0;
3506 }
3507
3508 /**
3509 * Gets the direction dragEl must be swapped relative to target in order to make it
3510 * seem that dragEl has been "inserted" into that element's position
3511 * @param {HTMLElement} target The target whose position dragEl is being inserted at
3512 * @return {Number} Direction dragEl must be swapped
3513 */
3514 function _getInsertDirection(target) {
3515 if (index(dragEl) < index(target)) {
3516 return 1;
3517 } else {
3518 return -1;
3519 }
3520 }
3521
3522 /**
3523 * Generate id
3524 * @param {HTMLElement} el
3525 * @returns {String}
3526 * @private
3527 */
3528 function _generateId(el) {
3529 var str = el.tagName + el.className + el.src + el.href + el.textContent,
3530 i = str.length,
3531 sum = 0;
3532 while (i--) {
3533 sum += str.charCodeAt(i);
3534 }
3535 return sum.toString(36);
3536 }
3537 function _saveInputCheckedState(root) {
3538 savedInputChecked.length = 0;
3539 var inputs = root.getElementsByTagName('input');
3540 var idx = inputs.length;
3541 while (idx--) {
3542 var el = inputs[idx];
3543 el.checked && savedInputChecked.push(el);
3544 }
3545 }
3546 function _nextTick(fn) {
3547 return setTimeout(fn, 0);
3548 }
3549 function _cancelNextTick(id) {
3550 return clearTimeout(id);
3551 }
3552
3553 // Fixed #973:
3554 if (documentExists) {
3555 on(document, 'touchmove', function (evt) {
3556 if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
3557 evt.preventDefault();
3558 }
3559 });
3560 }
3561
3562 // Export utils
3563 Sortable.utils = {
3564 on: on,
3565 off: off,
3566 css: css,
3567 find: find,
3568 is: function is(el, selector) {
3569 return !!closest(el, selector, el, false);
3570 },
3571 extend: extend,
3572 throttle: throttle,
3573 closest: closest,
3574 toggleClass: toggleClass,
3575 clone: clone,
3576 index: index,
3577 nextTick: _nextTick,
3578 cancelNextTick: _cancelNextTick,
3579 detectDirection: _detectDirection,
3580 getChild: getChild,
3581 expando: expando
3582 };
3583
3584 /**
3585 * Get the Sortable instance of an element
3586 * @param {HTMLElement} element The element
3587 * @return {Sortable|undefined} The instance of Sortable
3588 */
3589 Sortable.get = function (element) {
3590 return element[expando];
3591 };
3592
3593 /**
3594 * Mount a plugin to Sortable
3595 * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
3596 */
3597 Sortable.mount = function () {
3598 for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
3599 plugins[_key] = arguments[_key];
3600 }
3601 if (plugins[0].constructor === Array) plugins = plugins[0];
3602 plugins.forEach(function (plugin) {
3603 if (!plugin.prototype || !plugin.prototype.constructor) {
3604 throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
3605 }
3606 if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
3607 PluginManager.mount(plugin);
3608 });
3609 };
3610
3611 /**
3612 * Create sortable instance
3613 * @param {HTMLElement} el
3614 * @param {Object} [options]
3615 */
3616 Sortable.create = function (el, options) {
3617 return new Sortable(el, options);
3618 };
3619
3620 // Export
3621 Sortable.version = version;
3622
3623 var autoScrolls = [],
3624 scrollEl,
3625 scrollRootEl,
3626 scrolling = false,
3627 lastAutoScrollX,
3628 lastAutoScrollY,
3629 touchEvt$1,
3630 pointerElemChangedInterval;
3631 function AutoScrollPlugin() {
3632 function AutoScroll() {
3633 this.defaults = {
3634 scroll: true,
3635 forceAutoScrollFallback: false,
3636 scrollSensitivity: 30,
3637 scrollSpeed: 10,
3638 bubbleScroll: true
3639 };
3640
3641 // Bind all private methods
3642 for (var fn in this) {
3643 if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
3644 this[fn] = this[fn].bind(this);
3645 }
3646 }
3647 }
3648 AutoScroll.prototype = {
3649 dragStarted: function dragStarted(_ref) {
3650 var originalEvent = _ref.originalEvent;
3651 if (this.sortable.nativeDraggable) {
3652 on(document, 'dragover', this._handleAutoScroll);
3653 } else {
3654 if (this.options.supportPointer) {
3655 on(document, 'pointermove', this._handleFallbackAutoScroll);
3656 } else if (originalEvent.touches) {
3657 on(document, 'touchmove', this._handleFallbackAutoScroll);
3658 } else {
3659 on(document, 'mousemove', this._handleFallbackAutoScroll);
3660 }
3661 }
3662 },
3663 dragOverCompleted: function dragOverCompleted(_ref2) {
3664 var originalEvent = _ref2.originalEvent;
3665 // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
3666 if (!this.options.dragOverBubble && !originalEvent.rootEl) {
3667 this._handleAutoScroll(originalEvent);
3668 }
3669 },
3670 drop: function drop() {
3671 if (this.sortable.nativeDraggable) {
3672 off(document, 'dragover', this._handleAutoScroll);
3673 } else {
3674 off(document, 'pointermove', this._handleFallbackAutoScroll);
3675 off(document, 'touchmove', this._handleFallbackAutoScroll);
3676 off(document, 'mousemove', this._handleFallbackAutoScroll);
3677 }
3678 clearPointerElemChangedInterval();
3679 clearAutoScrolls();
3680 cancelThrottle();
3681 },
3682 nulling: function nulling() {
3683 touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
3684 autoScrolls.length = 0;
3685 },
3686 _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
3687 this._handleAutoScroll(evt, true);
3688 },
3689 _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
3690 var _this = this;
3691 var x = (evt.touches ? evt.touches[0] : evt).clientX,
3692 y = (evt.touches ? evt.touches[0] : evt).clientY,
3693 elem = document.elementFromPoint(x, y);
3694 touchEvt$1 = evt;
3695
3696 // IE does not seem to have native autoscroll,
3697 // Edge's autoscroll seems too conditional,
3698 // MACOS Safari does not have autoscroll,
3699 // Firefox and Chrome are good
3700 if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
3701 autoScroll(evt, this.options, elem, fallback);
3702
3703 // Listener for pointer element change
3704 var ogElemScroller = getParentAutoScrollElement(elem, true);
3705 if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
3706 pointerElemChangedInterval && clearPointerElemChangedInterval();
3707 // Detect for pointer elem change, emulating native DnD behaviour
3708 pointerElemChangedInterval = setInterval(function () {
3709 var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
3710 if (newElem !== ogElemScroller) {
3711 ogElemScroller = newElem;
3712 clearAutoScrolls();
3713 }
3714 autoScroll(evt, _this.options, newElem, fallback);
3715 }, 10);
3716 lastAutoScrollX = x;
3717 lastAutoScrollY = y;
3718 }
3719 } else {
3720 // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
3721 if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
3722 clearAutoScrolls();
3723 return;
3724 }
3725 autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
3726 }
3727 }
3728 };
3729 return _extends(AutoScroll, {
3730 pluginName: 'scroll',
3731 initializeByDefault: true
3732 });
3733 }
3734 function clearAutoScrolls() {
3735 autoScrolls.forEach(function (autoScroll) {
3736 clearInterval(autoScroll.pid);
3737 });
3738 autoScrolls = [];
3739 }
3740 function clearPointerElemChangedInterval() {
3741 clearInterval(pointerElemChangedInterval);
3742 }
3743 var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
3744 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
3745 if (!options.scroll) return;
3746 var x = (evt.touches ? evt.touches[0] : evt).clientX,
3747 y = (evt.touches ? evt.touches[0] : evt).clientY,
3748 sens = options.scrollSensitivity,
3749 speed = options.scrollSpeed,
3750 winScroller = getWindowScrollingElement();
3751 var scrollThisInstance = false,
3752 scrollCustomFn;
3753
3754 // New scroll root, set scrollEl
3755 if (scrollRootEl !== rootEl) {
3756 scrollRootEl = rootEl;
3757 clearAutoScrolls();
3758 scrollEl = options.scroll;
3759 scrollCustomFn = options.scrollFn;
3760 if (scrollEl === true) {
3761 scrollEl = getParentAutoScrollElement(rootEl, true);
3762 }
3763 }
3764 var layersOut = 0;
3765 var currentParent = scrollEl;
3766 do {
3767 var el = currentParent,
3768 rect = getRect(el),
3769 top = rect.top,
3770 bottom = rect.bottom,
3771 left = rect.left,
3772 right = rect.right,
3773 width = rect.width,
3774 height = rect.height,
3775 canScrollX = void 0,
3776 canScrollY = void 0,
3777 scrollWidth = el.scrollWidth,
3778 scrollHeight = el.scrollHeight,
3779 elCSS = css(el),
3780 scrollPosX = el.scrollLeft,
3781 scrollPosY = el.scrollTop;
3782 if (el === winScroller) {
3783 canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
3784 canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
3785 } else {
3786 canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
3787 canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
3788 }
3789 var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
3790 var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
3791 if (!autoScrolls[layersOut]) {
3792 for (var i = 0; i <= layersOut; i++) {
3793 if (!autoScrolls[i]) {
3794 autoScrolls[i] = {};
3795 }
3796 }
3797 }
3798 if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
3799 autoScrolls[layersOut].el = el;
3800 autoScrolls[layersOut].vx = vx;
3801 autoScrolls[layersOut].vy = vy;
3802 clearInterval(autoScrolls[layersOut].pid);
3803 if (vx != 0 || vy != 0) {
3804 scrollThisInstance = true;
3805 /* jshint loopfunc:true */
3806 autoScrolls[layersOut].pid = setInterval(function () {
3807 // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
3808 if (isFallback && this.layer === 0) {
3809 Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
3810 }
3811 var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
3812 var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
3813 if (typeof scrollCustomFn === 'function') {
3814 if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
3815 return;
3816 }
3817 }
3818 scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
3819 }.bind({
3820 layer: layersOut
3821 }), 24);
3822 }
3823 }
3824 layersOut++;
3825 } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
3826 scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
3827 }, 30);
3828
3829 var drop = function drop(_ref) {
3830 var originalEvent = _ref.originalEvent,
3831 putSortable = _ref.putSortable,
3832 dragEl = _ref.dragEl,
3833 activeSortable = _ref.activeSortable,
3834 dispatchSortableEvent = _ref.dispatchSortableEvent,
3835 hideGhostForTarget = _ref.hideGhostForTarget,
3836 unhideGhostForTarget = _ref.unhideGhostForTarget;
3837 if (!originalEvent) return;
3838 var toSortable = putSortable || activeSortable;
3839 hideGhostForTarget();
3840 var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
3841 var target = document.elementFromPoint(touch.clientX, touch.clientY);
3842 unhideGhostForTarget();
3843 if (toSortable && !toSortable.el.contains(target)) {
3844 dispatchSortableEvent('spill');
3845 this.onSpill({
3846 dragEl: dragEl,
3847 putSortable: putSortable
3848 });
3849 }
3850 };
3851 function Revert() {}
3852 Revert.prototype = {
3853 startIndex: null,
3854 dragStart: function dragStart(_ref2) {
3855 var oldDraggableIndex = _ref2.oldDraggableIndex;
3856 this.startIndex = oldDraggableIndex;
3857 },
3858 onSpill: function onSpill(_ref3) {
3859 var dragEl = _ref3.dragEl,
3860 putSortable = _ref3.putSortable;
3861 this.sortable.captureAnimationState();
3862 if (putSortable) {
3863 putSortable.captureAnimationState();
3864 }
3865 var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
3866 if (nextSibling) {
3867 this.sortable.el.insertBefore(dragEl, nextSibling);
3868 } else {
3869 this.sortable.el.appendChild(dragEl);
3870 }
3871 this.sortable.animateAll();
3872 if (putSortable) {
3873 putSortable.animateAll();
3874 }
3875 },
3876 drop: drop
3877 };
3878 _extends(Revert, {
3879 pluginName: 'revertOnSpill'
3880 });
3881 function Remove() {}
3882 Remove.prototype = {
3883 onSpill: function onSpill(_ref4) {
3884 var dragEl = _ref4.dragEl,
3885 putSortable = _ref4.putSortable;
3886 var parentSortable = putSortable || this.sortable;
3887 parentSortable.captureAnimationState();
3888 dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
3889 parentSortable.animateAll();
3890 },
3891 drop: drop
3892 };
3893 _extends(Remove, {
3894 pluginName: 'removeOnSpill'
3895 });
3896
3897 var lastSwapEl;
3898 function SwapPlugin() {
3899 function Swap() {
3900 this.defaults = {
3901 swapClass: 'sortable-swap-highlight'
3902 };
3903 }
3904 Swap.prototype = {
3905 dragStart: function dragStart(_ref) {
3906 var dragEl = _ref.dragEl;
3907 lastSwapEl = dragEl;
3908 },
3909 dragOverValid: function dragOverValid(_ref2) {
3910 var completed = _ref2.completed,
3911 target = _ref2.target,
3912 onMove = _ref2.onMove,
3913 activeSortable = _ref2.activeSortable,
3914 changed = _ref2.changed,
3915 cancel = _ref2.cancel;
3916 if (!activeSortable.options.swap) return;
3917 var el = this.sortable.el,
3918 options = this.options;
3919 if (target && target !== el) {
3920 var prevSwapEl = lastSwapEl;
3921 if (onMove(target) !== false) {
3922 toggleClass(target, options.swapClass, true);
3923 lastSwapEl = target;
3924 } else {
3925 lastSwapEl = null;
3926 }
3927 if (prevSwapEl && prevSwapEl !== lastSwapEl) {
3928 toggleClass(prevSwapEl, options.swapClass, false);
3929 }
3930 }
3931 changed();
3932 completed(true);
3933 cancel();
3934 },
3935 drop: function drop(_ref3) {
3936 var activeSortable = _ref3.activeSortable,
3937 putSortable = _ref3.putSortable,
3938 dragEl = _ref3.dragEl;
3939 var toSortable = putSortable || this.sortable;
3940 var options = this.options;
3941 lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
3942 if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
3943 if (dragEl !== lastSwapEl) {
3944 toSortable.captureAnimationState();
3945 if (toSortable !== activeSortable) activeSortable.captureAnimationState();
3946 swapNodes(dragEl, lastSwapEl);
3947 toSortable.animateAll();
3948 if (toSortable !== activeSortable) activeSortable.animateAll();
3949 }
3950 }
3951 },
3952 nulling: function nulling() {
3953 lastSwapEl = null;
3954 }
3955 };
3956 return _extends(Swap, {
3957 pluginName: 'swap',
3958 eventProperties: function eventProperties() {
3959 return {
3960 swapItem: lastSwapEl
3961 };
3962 }
3963 });
3964 }
3965 function swapNodes(n1, n2) {
3966 var p1 = n1.parentNode,
3967 p2 = n2.parentNode,
3968 i1,
3969 i2;
3970 if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
3971 i1 = index(n1);
3972 i2 = index(n2);
3973 if (p1.isEqualNode(p2) && i1 < i2) {
3974 i2++;
3975 }
3976 p1.insertBefore(n2, p1.children[i1]);
3977 p2.insertBefore(n1, p2.children[i2]);
3978 }
3979
3980 var multiDragElements = [],
3981 multiDragClones = [],
3982 lastMultiDragSelect,
3983 // for selection with modifier key down (SHIFT)
3984 multiDragSortable,
3985 initialFolding = false,
3986 // Initial multi-drag fold when drag started
3987 folding = false,
3988 // Folding any other time
3989 dragStarted = false,
3990 dragEl$1,
3991 clonesFromRect,
3992 clonesHidden;
3993 function MultiDragPlugin() {
3994 function MultiDrag(sortable) {
3995 // Bind all private methods
3996 for (var fn in this) {
3997 if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
3998 this[fn] = this[fn].bind(this);
3999 }
4000 }
4001 if (!sortable.options.avoidImplicitDeselect) {
4002 if (sortable.options.supportPointer) {
4003 on(document, 'pointerup', this._deselectMultiDrag);
4004 } else {
4005 on(document, 'mouseup', this._deselectMultiDrag);
4006 on(document, 'touchend', this._deselectMultiDrag);
4007 }
4008 }
4009 on(document, 'keydown', this._checkKeyDown);
4010 on(document, 'keyup', this._checkKeyUp);
4011 this.defaults = {
4012 selectedClass: 'sortable-selected',
4013 multiDragKey: null,
4014 avoidImplicitDeselect: false,
4015 setData: function setData(dataTransfer, dragEl) {
4016 var data = '';
4017 if (multiDragElements.length && multiDragSortable === sortable) {
4018 multiDragElements.forEach(function (multiDragElement, i) {
4019 data += (!i ? '' : ', ') + multiDragElement.textContent;
4020 });
4021 } else {
4022 data = dragEl.textContent;
4023 }
4024 dataTransfer.setData('Text', data);
4025 }
4026 };
4027 }
4028 MultiDrag.prototype = {
4029 multiDragKeyDown: false,
4030 isMultiDrag: false,
4031 delayStartGlobal: function delayStartGlobal(_ref) {
4032 var dragged = _ref.dragEl;
4033 dragEl$1 = dragged;
4034 },
4035 delayEnded: function delayEnded() {
4036 this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
4037 },
4038 setupClone: function setupClone(_ref2) {
4039 var sortable = _ref2.sortable,
4040 cancel = _ref2.cancel;
4041 if (!this.isMultiDrag) return;
4042 for (var i = 0; i < multiDragElements.length; i++) {
4043 multiDragClones.push(clone(multiDragElements[i]));
4044 multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
4045 multiDragClones[i].draggable = false;
4046 multiDragClones[i].style['will-change'] = '';
4047 toggleClass(multiDragClones[i], this.options.selectedClass, false);
4048 multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
4049 }
4050 sortable._hideClone();
4051 cancel();
4052 },
4053 clone: function clone(_ref3) {
4054 var sortable = _ref3.sortable,
4055 rootEl = _ref3.rootEl,
4056 dispatchSortableEvent = _ref3.dispatchSortableEvent,
4057 cancel = _ref3.cancel;
4058 if (!this.isMultiDrag) return;
4059 if (!this.options.removeCloneOnHide) {
4060 if (multiDragElements.length && multiDragSortable === sortable) {
4061 insertMultiDragClones(true, rootEl);
4062 dispatchSortableEvent('clone');
4063 cancel();
4064 }
4065 }
4066 },
4067 showClone: function showClone(_ref4) {
4068 var cloneNowShown = _ref4.cloneNowShown,
4069 rootEl = _ref4.rootEl,
4070 cancel = _ref4.cancel;
4071 if (!this.isMultiDrag) return;
4072 insertMultiDragClones(false, rootEl);
4073 multiDragClones.forEach(function (clone) {
4074 css(clone, 'display', '');
4075 });
4076 cloneNowShown();
4077 clonesHidden = false;
4078 cancel();
4079 },
4080 hideClone: function hideClone(_ref5) {
4081 var _this = this;
4082 var sortable = _ref5.sortable,
4083 cloneNowHidden = _ref5.cloneNowHidden,
4084 cancel = _ref5.cancel;
4085 if (!this.isMultiDrag) return;
4086 multiDragClones.forEach(function (clone) {
4087 css(clone, 'display', 'none');
4088 if (_this.options.removeCloneOnHide && clone.parentNode) {
4089 clone.parentNode.removeChild(clone);
4090 }
4091 });
4092 cloneNowHidden();
4093 clonesHidden = true;
4094 cancel();
4095 },
4096 dragStartGlobal: function dragStartGlobal(_ref6) {
4097 var sortable = _ref6.sortable;
4098 if (!this.isMultiDrag && multiDragSortable) {
4099 multiDragSortable.multiDrag._deselectMultiDrag();
4100 }
4101 multiDragElements.forEach(function (multiDragElement) {
4102 multiDragElement.sortableIndex = index(multiDragElement);
4103 });
4104
4105 // Sort multi-drag elements
4106 multiDragElements = multiDragElements.sort(function (a, b) {
4107 return a.sortableIndex - b.sortableIndex;
4108 });
4109 dragStarted = true;
4110 },
4111 dragStarted: function dragStarted(_ref7) {
4112 var _this2 = this;
4113 var sortable = _ref7.sortable;
4114 if (!this.isMultiDrag) return;
4115 if (this.options.sort) {
4116 // Capture rects,
4117 // hide multi drag elements (by positioning them absolute),
4118 // set multi drag elements rects to dragRect,
4119 // show multi drag elements,
4120 // animate to rects,
4121 // unset rects & remove from DOM
4122
4123 sortable.captureAnimationState();
4124 if (this.options.animation) {
4125 multiDragElements.forEach(function (multiDragElement) {
4126 if (multiDragElement === dragEl$1) return;
4127 css(multiDragElement, 'position', 'absolute');
4128 });
4129 var dragRect = getRect(dragEl$1, false, true, true);
4130 multiDragElements.forEach(function (multiDragElement) {
4131 if (multiDragElement === dragEl$1) return;
4132 setRect(multiDragElement, dragRect);
4133 });
4134 folding = true;
4135 initialFolding = true;
4136 }
4137 }
4138 sortable.animateAll(function () {
4139 folding = false;
4140 initialFolding = false;
4141 if (_this2.options.animation) {
4142 multiDragElements.forEach(function (multiDragElement) {
4143 unsetRect(multiDragElement);
4144 });
4145 }
4146
4147 // Remove all auxiliary multidrag items from el, if sorting enabled
4148 if (_this2.options.sort) {
4149 removeMultiDragElements();
4150 }
4151 });
4152 },
4153 dragOver: function dragOver(_ref8) {
4154 var target = _ref8.target,
4155 completed = _ref8.completed,
4156 cancel = _ref8.cancel;
4157 if (folding && ~multiDragElements.indexOf(target)) {
4158 completed(false);
4159 cancel();
4160 }
4161 },
4162 revert: function revert(_ref9) {
4163 var fromSortable = _ref9.fromSortable,
4164 rootEl = _ref9.rootEl,
4165 sortable = _ref9.sortable,
4166 dragRect = _ref9.dragRect;
4167 if (multiDragElements.length > 1) {
4168 // Setup unfold animation
4169 multiDragElements.forEach(function (multiDragElement) {
4170 sortable.addAnimationState({
4171 target: multiDragElement,
4172 rect: folding ? getRect(multiDragElement) : dragRect
4173 });
4174 unsetRect(multiDragElement);
4175 multiDragElement.fromRect = dragRect;
4176 fromSortable.removeAnimationState(multiDragElement);
4177 });
4178 folding = false;
4179 insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
4180 }
4181 },
4182 dragOverCompleted: function dragOverCompleted(_ref10) {
4183 var sortable = _ref10.sortable,
4184 isOwner = _ref10.isOwner,
4185 insertion = _ref10.insertion,
4186 activeSortable = _ref10.activeSortable,
4187 parentEl = _ref10.parentEl,
4188 putSortable = _ref10.putSortable;
4189 var options = this.options;
4190 if (insertion) {
4191 // Clones must be hidden before folding animation to capture dragRectAbsolute properly
4192 if (isOwner) {
4193 activeSortable._hideClone();
4194 }
4195 initialFolding = false;
4196 // If leaving sort:false root, or already folding - Fold to new location
4197 if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
4198 // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
4199 var dragRectAbsolute = getRect(dragEl$1, false, true, true);
4200 multiDragElements.forEach(function (multiDragElement) {
4201 if (multiDragElement === dragEl$1) return;
4202 setRect(multiDragElement, dragRectAbsolute);
4203
4204 // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
4205 // while folding, and so that we can capture them again because old sortable will no longer be fromSortable
4206 parentEl.appendChild(multiDragElement);
4207 });
4208 folding = true;
4209 }
4210
4211 // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
4212 if (!isOwner) {
4213 // Only remove if not folding (folding will remove them anyways)
4214 if (!folding) {
4215 removeMultiDragElements();
4216 }
4217 if (multiDragElements.length > 1) {
4218 var clonesHiddenBefore = clonesHidden;
4219 activeSortable._showClone(sortable);
4220
4221 // Unfold animation for clones if showing from hidden
4222 if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
4223 multiDragClones.forEach(function (clone) {
4224 activeSortable.addAnimationState({
4225 target: clone,
4226 rect: clonesFromRect
4227 });
4228 clone.fromRect = clonesFromRect;
4229 clone.thisAnimationDuration = null;
4230 });
4231 }
4232 } else {
4233 activeSortable._showClone(sortable);
4234 }
4235 }
4236 }
4237 },
4238 dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
4239 var dragRect = _ref11.dragRect,
4240 isOwner = _ref11.isOwner,
4241 activeSortable = _ref11.activeSortable;
4242 multiDragElements.forEach(function (multiDragElement) {
4243 multiDragElement.thisAnimationDuration = null;
4244 });
4245 if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
4246 clonesFromRect = _extends({}, dragRect);
4247 var dragMatrix = matrix(dragEl$1, true);
4248 clonesFromRect.top -= dragMatrix.f;
4249 clonesFromRect.left -= dragMatrix.e;
4250 }
4251 },
4252 dragOverAnimationComplete: function dragOverAnimationComplete() {
4253 if (folding) {
4254 folding = false;
4255 removeMultiDragElements();
4256 }
4257 },
4258 drop: function drop(_ref12) {
4259 var evt = _ref12.originalEvent,
4260 rootEl = _ref12.rootEl,
4261 parentEl = _ref12.parentEl,
4262 sortable = _ref12.sortable,
4263 dispatchSortableEvent = _ref12.dispatchSortableEvent,
4264 oldIndex = _ref12.oldIndex,
4265 putSortable = _ref12.putSortable;
4266 var toSortable = putSortable || this.sortable;
4267 if (!evt) return;
4268 var options = this.options,
4269 children = parentEl.children;
4270
4271 // Multi-drag selection
4272 if (!dragStarted) {
4273 if (options.multiDragKey && !this.multiDragKeyDown) {
4274 this._deselectMultiDrag();
4275 }
4276 toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
4277 if (!~multiDragElements.indexOf(dragEl$1)) {
4278 multiDragElements.push(dragEl$1);
4279 dispatchEvent({
4280 sortable: sortable,
4281 rootEl: rootEl,
4282 name: 'select',
4283 targetEl: dragEl$1,
4284 originalEvent: evt
4285 });
4286
4287 // Modifier activated, select from last to dragEl
4288 if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
4289 var lastIndex = index(lastMultiDragSelect),
4290 currentIndex = index(dragEl$1);
4291 if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
4292 (function () {
4293 // Must include lastMultiDragSelect (select it), in case modified selection from no selection
4294 // (but previous selection existed)
4295 var n, i;
4296 if (currentIndex > lastIndex) {
4297 i = lastIndex;
4298 n = currentIndex;
4299 } else {
4300 i = currentIndex;
4301 n = lastIndex + 1;
4302 }
4303 var filter = options.filter;
4304 for (; i < n; i++) {
4305 if (~multiDragElements.indexOf(children[i])) continue;
4306 // Check if element is draggable
4307 if (!closest(children[i], options.draggable, parentEl, false)) continue;
4308 // Check if element is filtered
4309 var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
4310 return closest(children[i], criteria.trim(), parentEl, false);
4311 }));
4312 if (filtered) continue;
4313 toggleClass(children[i], options.selectedClass, true);
4314 multiDragElements.push(children[i]);
4315 dispatchEvent({
4316 sortable: sortable,
4317 rootEl: rootEl,
4318 name: 'select',
4319 targetEl: children[i],
4320 originalEvent: evt
4321 });
4322 }
4323 })();
4324 }
4325 } else {
4326 lastMultiDragSelect = dragEl$1;
4327 }
4328 multiDragSortable = toSortable;
4329 } else {
4330 multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
4331 lastMultiDragSelect = null;
4332 dispatchEvent({
4333 sortable: sortable,
4334 rootEl: rootEl,
4335 name: 'deselect',
4336 targetEl: dragEl$1,
4337 originalEvent: evt
4338 });
4339 }
4340 }
4341
4342 // Multi-drag drop
4343 if (dragStarted && this.isMultiDrag) {
4344 folding = false;
4345 // Do not "unfold" after around dragEl if reverted
4346 if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
4347 var dragRect = getRect(dragEl$1),
4348 multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
4349 if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
4350 toSortable.captureAnimationState();
4351 if (!initialFolding) {
4352 if (options.animation) {
4353 dragEl$1.fromRect = dragRect;
4354 multiDragElements.forEach(function (multiDragElement) {
4355 multiDragElement.thisAnimationDuration = null;
4356 if (multiDragElement !== dragEl$1) {
4357 var rect = folding ? getRect(multiDragElement) : dragRect;
4358 multiDragElement.fromRect = rect;
4359
4360 // Prepare unfold animation
4361 toSortable.addAnimationState({
4362 target: multiDragElement,
4363 rect: rect
4364 });
4365 }
4366 });
4367 }
4368
4369 // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
4370 // properly they must all be removed
4371 removeMultiDragElements();
4372 multiDragElements.forEach(function (multiDragElement) {
4373 if (children[multiDragIndex]) {
4374 parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
4375 } else {
4376 parentEl.appendChild(multiDragElement);
4377 }
4378 multiDragIndex++;
4379 });
4380
4381 // If initial folding is done, the elements may have changed position because they are now
4382 // unfolding around dragEl, even though dragEl may not have his index changed, so update event
4383 // must be fired here as Sortable will not.
4384 if (oldIndex === index(dragEl$1)) {
4385 var update = false;
4386 multiDragElements.forEach(function (multiDragElement) {
4387 if (multiDragElement.sortableIndex !== index(multiDragElement)) {
4388 update = true;
4389 return;
4390 }
4391 });
4392 if (update) {
4393 dispatchSortableEvent('update');
4394 dispatchSortableEvent('sort');
4395 }
4396 }
4397 }
4398
4399 // Must be done after capturing individual rects (scroll bar)
4400 multiDragElements.forEach(function (multiDragElement) {
4401 unsetRect(multiDragElement);
4402 });
4403 toSortable.animateAll();
4404 }
4405 multiDragSortable = toSortable;
4406 }
4407
4408 // Remove clones if necessary
4409 if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
4410 multiDragClones.forEach(function (clone) {
4411 clone.parentNode && clone.parentNode.removeChild(clone);
4412 });
4413 }
4414 },
4415 nullingGlobal: function nullingGlobal() {
4416 this.isMultiDrag = dragStarted = false;
4417 multiDragClones.length = 0;
4418 },
4419 destroyGlobal: function destroyGlobal() {
4420 this._deselectMultiDrag();
4421 off(document, 'pointerup', this._deselectMultiDrag);
4422 off(document, 'mouseup', this._deselectMultiDrag);
4423 off(document, 'touchend', this._deselectMultiDrag);
4424 off(document, 'keydown', this._checkKeyDown);
4425 off(document, 'keyup', this._checkKeyUp);
4426 },
4427 _deselectMultiDrag: function _deselectMultiDrag(evt) {
4428 if (typeof dragStarted !== "undefined" && dragStarted) return;
4429
4430 // Only deselect if selection is in this sortable
4431 if (multiDragSortable !== this.sortable) return;
4432
4433 // Only deselect if target is not item in this sortable
4434 if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
4435
4436 // Only deselect if left click
4437 if (evt && evt.button !== 0) return;
4438 while (multiDragElements.length) {
4439 var el = multiDragElements[0];
4440 toggleClass(el, this.options.selectedClass, false);
4441 multiDragElements.shift();
4442 dispatchEvent({
4443 sortable: this.sortable,
4444 rootEl: this.sortable.el,
4445 name: 'deselect',
4446 targetEl: el,
4447 originalEvent: evt
4448 });
4449 }
4450 },
4451 _checkKeyDown: function _checkKeyDown(evt) {
4452 if (evt.key === this.options.multiDragKey) {
4453 this.multiDragKeyDown = true;
4454 }
4455 },
4456 _checkKeyUp: function _checkKeyUp(evt) {
4457 if (evt.key === this.options.multiDragKey) {
4458 this.multiDragKeyDown = false;
4459 }
4460 }
4461 };
4462 return _extends(MultiDrag, {
4463 // Static methods & properties
4464 pluginName: 'multiDrag',
4465 utils: {
4466 /**
4467 * Selects the provided multi-drag item
4468 * @param {HTMLElement} el The element to be selected
4469 */
4470 select: function select(el) {
4471 var sortable = el.parentNode[expando];
4472 if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
4473 if (multiDragSortable && multiDragSortable !== sortable) {
4474 multiDragSortable.multiDrag._deselectMultiDrag();
4475 multiDragSortable = sortable;
4476 }
4477 toggleClass(el, sortable.options.selectedClass, true);
4478 multiDragElements.push(el);
4479 },
4480 /**
4481 * Deselects the provided multi-drag item
4482 * @param {HTMLElement} el The element to be deselected
4483 */
4484 deselect: function deselect(el) {
4485 var sortable = el.parentNode[expando],
4486 index = multiDragElements.indexOf(el);
4487 if (!sortable || !sortable.options.multiDrag || !~index) return;
4488 toggleClass(el, sortable.options.selectedClass, false);
4489 multiDragElements.splice(index, 1);
4490 }
4491 },
4492 eventProperties: function eventProperties() {
4493 var _this3 = this;
4494 var oldIndicies = [],
4495 newIndicies = [];
4496 multiDragElements.forEach(function (multiDragElement) {
4497 oldIndicies.push({
4498 multiDragElement: multiDragElement,
4499 index: multiDragElement.sortableIndex
4500 });
4501
4502 // multiDragElements will already be sorted if folding
4503 var newIndex;
4504 if (folding && multiDragElement !== dragEl$1) {
4505 newIndex = -1;
4506 } else if (folding) {
4507 newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
4508 } else {
4509 newIndex = index(multiDragElement);
4510 }
4511 newIndicies.push({
4512 multiDragElement: multiDragElement,
4513 index: newIndex
4514 });
4515 });
4516 return {
4517 items: _toConsumableArray(multiDragElements),
4518 clones: [].concat(multiDragClones),
4519 oldIndicies: oldIndicies,
4520 newIndicies: newIndicies
4521 };
4522 },
4523 optionListeners: {
4524 multiDragKey: function multiDragKey(key) {
4525 key = key.toLowerCase();
4526 if (key === 'ctrl') {
4527 key = 'Control';
4528 } else if (key.length > 1) {
4529 key = key.charAt(0).toUpperCase() + key.substr(1);
4530 }
4531 return key;
4532 }
4533 }
4534 });
4535 }
4536 function insertMultiDragElements(clonesInserted, rootEl) {
4537 multiDragElements.forEach(function (multiDragElement, i) {
4538 var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
4539 if (target) {
4540 rootEl.insertBefore(multiDragElement, target);
4541 } else {
4542 rootEl.appendChild(multiDragElement);
4543 }
4544 });
4545 }
4546
4547 /**
4548 * Insert multi-drag clones
4549 * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
4550 * @param {HTMLElement} rootEl
4551 */
4552 function insertMultiDragClones(elementsInserted, rootEl) {
4553 multiDragClones.forEach(function (clone, i) {
4554 var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
4555 if (target) {
4556 rootEl.insertBefore(clone, target);
4557 } else {
4558 rootEl.appendChild(clone);
4559 }
4560 });
4561 }
4562 function removeMultiDragElements() {
4563 multiDragElements.forEach(function (multiDragElement) {
4564 if (multiDragElement === dragEl$1) return;
4565 multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
4566 });
4567 }
4568
4569 Sortable.mount(new AutoScrollPlugin());
4570 Sortable.mount(Remove, Revert);
4571
4572 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Sortable);
4573
4574
4575
4576 /***/ }),
4577
4578 /***/ "./node_modules/toastify-js/src/toastify.css":
4579 /*!***************************************************!*\
4580 !*** ./node_modules/toastify-js/src/toastify.css ***!
4581 \***************************************************/
4582 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4583
4584 "use strict";
4585 __webpack_require__.r(__webpack_exports__);
4586 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4587 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
4588 /* harmony export */ });
4589 /* 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");
4590 /* 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__);
4591 /* 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");
4592 /* 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__);
4593 /* 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");
4594 /* 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__);
4595 /* 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");
4596 /* 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__);
4597 /* 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");
4598 /* 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__);
4599 /* 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");
4600 /* 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__);
4601 /* 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");
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613 var options = {};
4614
4615 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
4616 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
4617
4618 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
4619
4620 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
4621 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
4622
4623 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);
4624
4625
4626
4627
4628 /* 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);
4629
4630
4631 /***/ }),
4632
4633 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
4634 /*!****************************************************************************!*\
4635 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
4636 \****************************************************************************/
4637 /***/ ((module) => {
4638
4639 "use strict";
4640
4641
4642 var stylesInDOM = [];
4643 function getIndexByIdentifier(identifier) {
4644 var result = -1;
4645 for (var i = 0; i < stylesInDOM.length; i++) {
4646 if (stylesInDOM[i].identifier === identifier) {
4647 result = i;
4648 break;
4649 }
4650 }
4651 return result;
4652 }
4653 function modulesToDom(list, options) {
4654 var idCountMap = {};
4655 var identifiers = [];
4656 for (var i = 0; i < list.length; i++) {
4657 var item = list[i];
4658 var id = options.base ? item[0] + options.base : item[0];
4659 var count = idCountMap[id] || 0;
4660 var identifier = "".concat(id, " ").concat(count);
4661 idCountMap[id] = count + 1;
4662 var indexByIdentifier = getIndexByIdentifier(identifier);
4663 var obj = {
4664 css: item[1],
4665 media: item[2],
4666 sourceMap: item[3],
4667 supports: item[4],
4668 layer: item[5]
4669 };
4670 if (indexByIdentifier !== -1) {
4671 stylesInDOM[indexByIdentifier].references++;
4672 stylesInDOM[indexByIdentifier].updater(obj);
4673 } else {
4674 var updater = addElementStyle(obj, options);
4675 options.byIndex = i;
4676 stylesInDOM.splice(i, 0, {
4677 identifier: identifier,
4678 updater: updater,
4679 references: 1
4680 });
4681 }
4682 identifiers.push(identifier);
4683 }
4684 return identifiers;
4685 }
4686 function addElementStyle(obj, options) {
4687 var api = options.domAPI(options);
4688 api.update(obj);
4689 var updater = function updater(newObj) {
4690 if (newObj) {
4691 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
4692 return;
4693 }
4694 api.update(obj = newObj);
4695 } else {
4696 api.remove();
4697 }
4698 };
4699 return updater;
4700 }
4701 module.exports = function (list, options) {
4702 options = options || {};
4703 list = list || [];
4704 var lastIdentifiers = modulesToDom(list, options);
4705 return function update(newList) {
4706 newList = newList || [];
4707 for (var i = 0; i < lastIdentifiers.length; i++) {
4708 var identifier = lastIdentifiers[i];
4709 var index = getIndexByIdentifier(identifier);
4710 stylesInDOM[index].references--;
4711 }
4712 var newLastIdentifiers = modulesToDom(newList, options);
4713 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
4714 var _identifier = lastIdentifiers[_i];
4715 var _index = getIndexByIdentifier(_identifier);
4716 if (stylesInDOM[_index].references === 0) {
4717 stylesInDOM[_index].updater();
4718 stylesInDOM.splice(_index, 1);
4719 }
4720 }
4721 lastIdentifiers = newLastIdentifiers;
4722 };
4723 };
4724
4725 /***/ }),
4726
4727 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js":
4728 /*!********************************************************************!*\
4729 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
4730 \********************************************************************/
4731 /***/ ((module) => {
4732
4733 "use strict";
4734
4735
4736 var memo = {};
4737
4738 /* istanbul ignore next */
4739 function getTarget(target) {
4740 if (typeof memo[target] === "undefined") {
4741 var styleTarget = document.querySelector(target);
4742
4743 // Special case to return head of iframe instead of iframe itself
4744 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
4745 try {
4746 // This will throw an exception if access to iframe is blocked
4747 // due to cross-origin restrictions
4748 styleTarget = styleTarget.contentDocument.head;
4749 } catch (e) {
4750 // istanbul ignore next
4751 styleTarget = null;
4752 }
4753 }
4754 memo[target] = styleTarget;
4755 }
4756 return memo[target];
4757 }
4758
4759 /* istanbul ignore next */
4760 function insertBySelector(insert, style) {
4761 var target = getTarget(insert);
4762 if (!target) {
4763 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
4764 }
4765 target.appendChild(style);
4766 }
4767 module.exports = insertBySelector;
4768
4769 /***/ }),
4770
4771 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js":
4772 /*!**********************************************************************!*\
4773 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
4774 \**********************************************************************/
4775 /***/ ((module) => {
4776
4777 "use strict";
4778
4779
4780 /* istanbul ignore next */
4781 function insertStyleElement(options) {
4782 var element = document.createElement("style");
4783 options.setAttributes(element, options.attributes);
4784 options.insert(element, options.options);
4785 return element;
4786 }
4787 module.exports = insertStyleElement;
4788
4789 /***/ }),
4790
4791 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js":
4792 /*!**********************************************************************************!*\
4793 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
4794 \**********************************************************************************/
4795 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4796
4797 "use strict";
4798
4799
4800 /* istanbul ignore next */
4801 function setAttributesWithoutAttributes(styleElement) {
4802 var nonce = true ? __webpack_require__.nc : 0;
4803 if (nonce) {
4804 styleElement.setAttribute("nonce", nonce);
4805 }
4806 }
4807 module.exports = setAttributesWithoutAttributes;
4808
4809 /***/ }),
4810
4811 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js":
4812 /*!***************************************************************!*\
4813 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
4814 \***************************************************************/
4815 /***/ ((module) => {
4816
4817 "use strict";
4818
4819
4820 /* istanbul ignore next */
4821 function apply(styleElement, options, obj) {
4822 var css = "";
4823 if (obj.supports) {
4824 css += "@supports (".concat(obj.supports, ") {");
4825 }
4826 if (obj.media) {
4827 css += "@media ".concat(obj.media, " {");
4828 }
4829 var needLayer = typeof obj.layer !== "undefined";
4830 if (needLayer) {
4831 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
4832 }
4833 css += obj.css;
4834 if (needLayer) {
4835 css += "}";
4836 }
4837 if (obj.media) {
4838 css += "}";
4839 }
4840 if (obj.supports) {
4841 css += "}";
4842 }
4843 var sourceMap = obj.sourceMap;
4844 if (sourceMap && typeof btoa !== "undefined") {
4845 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
4846 }
4847
4848 // For old IE
4849 /* istanbul ignore if */
4850 options.styleTagTransform(css, styleElement, options.options);
4851 }
4852 function removeStyleElement(styleElement) {
4853 // istanbul ignore if
4854 if (styleElement.parentNode === null) {
4855 return false;
4856 }
4857 styleElement.parentNode.removeChild(styleElement);
4858 }
4859
4860 /* istanbul ignore next */
4861 function domAPI(options) {
4862 if (typeof document === "undefined") {
4863 return {
4864 update: function update() {},
4865 remove: function remove() {}
4866 };
4867 }
4868 var styleElement = options.insertStyleElement(options);
4869 return {
4870 update: function update(obj) {
4871 apply(styleElement, options, obj);
4872 },
4873 remove: function remove() {
4874 removeStyleElement(styleElement);
4875 }
4876 };
4877 }
4878 module.exports = domAPI;
4879
4880 /***/ }),
4881
4882 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js":
4883 /*!*********************************************************************!*\
4884 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
4885 \*********************************************************************/
4886 /***/ ((module) => {
4887
4888 "use strict";
4889
4890
4891 /* istanbul ignore next */
4892 function styleTagTransform(css, styleElement) {
4893 if (styleElement.styleSheet) {
4894 styleElement.styleSheet.cssText = css;
4895 } else {
4896 while (styleElement.firstChild) {
4897 styleElement.removeChild(styleElement.firstChild);
4898 }
4899 styleElement.appendChild(document.createTextNode(css));
4900 }
4901 }
4902 module.exports = styleTagTransform;
4903
4904 /***/ }),
4905
4906 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js":
4907 /*!**********************************************************!*\
4908 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
4909 \**********************************************************/
4910 /***/ (function(module) {
4911
4912 /*!
4913 * sweetalert2 v11.22.5
4914 * Released under the MIT License.
4915 */
4916 (function (global, factory) {
4917 true ? module.exports = factory() :
4918 0;
4919 })(this, (function () { 'use strict';
4920
4921 function _assertClassBrand(e, t, n) {
4922 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
4923 throw new TypeError("Private element is not present on this object");
4924 }
4925 function _checkPrivateRedeclaration(e, t) {
4926 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
4927 }
4928 function _classPrivateFieldGet2(s, a) {
4929 return s.get(_assertClassBrand(s, a));
4930 }
4931 function _classPrivateFieldInitSpec(e, t, a) {
4932 _checkPrivateRedeclaration(e, t), t.set(e, a);
4933 }
4934 function _classPrivateFieldSet2(s, a, r) {
4935 return s.set(_assertClassBrand(s, a), r), r;
4936 }
4937
4938 const RESTORE_FOCUS_TIMEOUT = 100;
4939
4940 /** @type {GlobalState} */
4941 const globalState = {};
4942 const focusPreviousActiveElement = () => {
4943 if (globalState.previousActiveElement instanceof HTMLElement) {
4944 globalState.previousActiveElement.focus();
4945 globalState.previousActiveElement = null;
4946 } else if (document.body) {
4947 document.body.focus();
4948 }
4949 };
4950
4951 /**
4952 * Restore previous active (focused) element
4953 *
4954 * @param {boolean} returnFocus
4955 * @returns {Promise<void>}
4956 */
4957 const restoreActiveElement = returnFocus => {
4958 return new Promise(resolve => {
4959 if (!returnFocus) {
4960 return resolve();
4961 }
4962 const x = window.scrollX;
4963 const y = window.scrollY;
4964 globalState.restoreFocusTimeout = setTimeout(() => {
4965 focusPreviousActiveElement();
4966 resolve();
4967 }, RESTORE_FOCUS_TIMEOUT); // issues/900
4968
4969 window.scrollTo(x, y);
4970 });
4971 };
4972
4973 const swalPrefix = 'swal2-';
4974
4975 /**
4976 * @typedef {Record<SwalClass, string>} SwalClasses
4977 */
4978
4979 /**
4980 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
4981 * @typedef {Record<SwalIcon, string>} SwalIcons
4982 */
4983
4984 /** @type {SwalClass[]} */
4985 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'];
4986 const swalClasses = classNames.reduce((acc, className) => {
4987 acc[className] = swalPrefix + className;
4988 return acc;
4989 }, /** @type {SwalClasses} */{});
4990
4991 /** @type {SwalIcon[]} */
4992 const icons = ['success', 'warning', 'info', 'question', 'error'];
4993 const iconTypes = icons.reduce((acc, icon) => {
4994 acc[icon] = swalPrefix + icon;
4995 return acc;
4996 }, /** @type {SwalIcons} */{});
4997
4998 const consolePrefix = 'SweetAlert2:';
4999
5000 /**
5001 * Capitalize the first letter of a string
5002 *
5003 * @param {string} str
5004 * @returns {string}
5005 */
5006 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
5007
5008 /**
5009 * Standardize console warnings
5010 *
5011 * @param {string | string[]} message
5012 */
5013 const warn = message => {
5014 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
5015 };
5016
5017 /**
5018 * Standardize console errors
5019 *
5020 * @param {string} message
5021 */
5022 const error = message => {
5023 console.error(`${consolePrefix} ${message}`);
5024 };
5025
5026 /**
5027 * Private global state for `warnOnce`
5028 *
5029 * @type {string[]}
5030 * @private
5031 */
5032 const previousWarnOnceMessages = [];
5033
5034 /**
5035 * Show a console warning, but only if it hasn't already been shown
5036 *
5037 * @param {string} message
5038 */
5039 const warnOnce = message => {
5040 if (!previousWarnOnceMessages.includes(message)) {
5041 previousWarnOnceMessages.push(message);
5042 warn(message);
5043 }
5044 };
5045
5046 /**
5047 * Show a one-time console warning about deprecated params/methods
5048 *
5049 * @param {string} deprecatedParam
5050 * @param {string?} useInstead
5051 */
5052 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
5053 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
5054 };
5055
5056 /**
5057 * If `arg` is a function, call it (with no arguments or context) and return the result.
5058 * Otherwise, just pass the value through
5059 *
5060 * @param {Function | any} arg
5061 * @returns {any}
5062 */
5063 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
5064
5065 /**
5066 * @param {any} arg
5067 * @returns {boolean}
5068 */
5069 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
5070
5071 /**
5072 * @param {any} arg
5073 * @returns {Promise<any>}
5074 */
5075 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
5076
5077 /**
5078 * @param {any} arg
5079 * @returns {boolean}
5080 */
5081 const isPromise = arg => arg && Promise.resolve(arg) === arg;
5082
5083 /**
5084 * Gets the popup container which contains the backdrop and the popup itself.
5085 *
5086 * @returns {HTMLElement | null}
5087 */
5088 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
5089
5090 /**
5091 * @param {string} selectorString
5092 * @returns {HTMLElement | null}
5093 */
5094 const elementBySelector = selectorString => {
5095 const container = getContainer();
5096 return container ? container.querySelector(selectorString) : null;
5097 };
5098
5099 /**
5100 * @param {string} className
5101 * @returns {HTMLElement | null}
5102 */
5103 const elementByClass = className => {
5104 return elementBySelector(`.${className}`);
5105 };
5106
5107 /**
5108 * @returns {HTMLElement | null}
5109 */
5110 const getPopup = () => elementByClass(swalClasses.popup);
5111
5112 /**
5113 * @returns {HTMLElement | null}
5114 */
5115 const getIcon = () => elementByClass(swalClasses.icon);
5116
5117 /**
5118 * @returns {HTMLElement | null}
5119 */
5120 const getIconContent = () => elementByClass(swalClasses['icon-content']);
5121
5122 /**
5123 * @returns {HTMLElement | null}
5124 */
5125 const getTitle = () => elementByClass(swalClasses.title);
5126
5127 /**
5128 * @returns {HTMLElement | null}
5129 */
5130 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
5131
5132 /**
5133 * @returns {HTMLElement | null}
5134 */
5135 const getImage = () => elementByClass(swalClasses.image);
5136
5137 /**
5138 * @returns {HTMLElement | null}
5139 */
5140 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
5141
5142 /**
5143 * @returns {HTMLElement | null}
5144 */
5145 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
5146
5147 /**
5148 * @returns {HTMLButtonElement | null}
5149 */
5150 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
5151
5152 /**
5153 * @returns {HTMLButtonElement | null}
5154 */
5155 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
5156
5157 /**
5158 * @returns {HTMLButtonElement | null}
5159 */
5160 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
5161
5162 /**
5163 * @returns {HTMLElement | null}
5164 */
5165 const getInputLabel = () => elementByClass(swalClasses['input-label']);
5166
5167 /**
5168 * @returns {HTMLElement | null}
5169 */
5170 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
5171
5172 /**
5173 * @returns {HTMLElement | null}
5174 */
5175 const getActions = () => elementByClass(swalClasses.actions);
5176
5177 /**
5178 * @returns {HTMLElement | null}
5179 */
5180 const getFooter = () => elementByClass(swalClasses.footer);
5181
5182 /**
5183 * @returns {HTMLElement | null}
5184 */
5185 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
5186
5187 /**
5188 * @returns {HTMLElement | null}
5189 */
5190 const getCloseButton = () => elementByClass(swalClasses.close);
5191
5192 // https://github.com/jkup/focusable/blob/master/index.js
5193 const focusable = `
5194 a[href],
5195 area[href],
5196 input:not([disabled]),
5197 select:not([disabled]),
5198 textarea:not([disabled]),
5199 button:not([disabled]),
5200 iframe,
5201 object,
5202 embed,
5203 [tabindex="0"],
5204 [contenteditable],
5205 audio[controls],
5206 video[controls],
5207 summary
5208 `;
5209 /**
5210 * @returns {HTMLElement[]}
5211 */
5212 const getFocusableElements = () => {
5213 const popup = getPopup();
5214 if (!popup) {
5215 return [];
5216 }
5217 /** @type {NodeListOf<HTMLElement>} */
5218 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
5219 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
5220 // sort according to tabindex
5221 .sort((a, b) => {
5222 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
5223 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
5224 if (tabindexA > tabindexB) {
5225 return 1;
5226 } else if (tabindexA < tabindexB) {
5227 return -1;
5228 }
5229 return 0;
5230 });
5231
5232 /** @type {NodeListOf<HTMLElement>} */
5233 const otherFocusableElements = popup.querySelectorAll(focusable);
5234 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
5235 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
5236 };
5237
5238 /**
5239 * @returns {boolean}
5240 */
5241 const isModal = () => {
5242 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
5243 };
5244
5245 /**
5246 * @returns {boolean}
5247 */
5248 const isToast = () => {
5249 const popup = getPopup();
5250 if (!popup) {
5251 return false;
5252 }
5253 return hasClass(popup, swalClasses.toast);
5254 };
5255
5256 /**
5257 * @returns {boolean}
5258 */
5259 const isLoading = () => {
5260 const popup = getPopup();
5261 if (!popup) {
5262 return false;
5263 }
5264 return popup.hasAttribute('data-loading');
5265 };
5266
5267 /**
5268 * Securely set innerHTML of an element
5269 * https://github.com/sweetalert2/sweetalert2/issues/1926
5270 *
5271 * @param {HTMLElement} elem
5272 * @param {string} html
5273 */
5274 const setInnerHtml = (elem, html) => {
5275 elem.textContent = '';
5276 if (html) {
5277 const parser = new DOMParser();
5278 const parsed = parser.parseFromString(html, `text/html`);
5279 const head = parsed.querySelector('head');
5280 if (head) {
5281 Array.from(head.childNodes).forEach(child => {
5282 elem.appendChild(child);
5283 });
5284 }
5285 const body = parsed.querySelector('body');
5286 if (body) {
5287 Array.from(body.childNodes).forEach(child => {
5288 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
5289 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
5290 } else {
5291 elem.appendChild(child);
5292 }
5293 });
5294 }
5295 }
5296 };
5297
5298 /**
5299 * @param {HTMLElement} elem
5300 * @param {string} className
5301 * @returns {boolean}
5302 */
5303 const hasClass = (elem, className) => {
5304 if (!className) {
5305 return false;
5306 }
5307 const classList = className.split(/\s+/);
5308 for (let i = 0; i < classList.length; i++) {
5309 if (!elem.classList.contains(classList[i])) {
5310 return false;
5311 }
5312 }
5313 return true;
5314 };
5315
5316 /**
5317 * @param {HTMLElement} elem
5318 * @param {SweetAlertOptions} params
5319 */
5320 const removeCustomClasses = (elem, params) => {
5321 Array.from(elem.classList).forEach(className => {
5322 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
5323 elem.classList.remove(className);
5324 }
5325 });
5326 };
5327
5328 /**
5329 * @param {HTMLElement} elem
5330 * @param {SweetAlertOptions} params
5331 * @param {string} className
5332 */
5333 const applyCustomClass = (elem, params, className) => {
5334 removeCustomClasses(elem, params);
5335 if (!params.customClass) {
5336 return;
5337 }
5338 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
5339 if (!customClass) {
5340 return;
5341 }
5342 if (typeof customClass !== 'string' && !customClass.forEach) {
5343 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
5344 return;
5345 }
5346 addClass(elem, customClass);
5347 };
5348
5349 /**
5350 * @param {HTMLElement} popup
5351 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
5352 * @returns {HTMLInputElement | null}
5353 */
5354 const getInput$1 = (popup, inputClass) => {
5355 if (!inputClass) {
5356 return null;
5357 }
5358 switch (inputClass) {
5359 case 'select':
5360 case 'textarea':
5361 case 'file':
5362 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
5363 case 'checkbox':
5364 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
5365 case 'radio':
5366 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
5367 case 'range':
5368 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
5369 default:
5370 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
5371 }
5372 };
5373
5374 /**
5375 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
5376 */
5377 const focusInput = input => {
5378 input.focus();
5379
5380 // place cursor at end of text in text input
5381 if (input.type !== 'file') {
5382 // http://stackoverflow.com/a/2345915
5383 const val = input.value;
5384 input.value = '';
5385 input.value = val;
5386 }
5387 };
5388
5389 /**
5390 * @param {HTMLElement | HTMLElement[] | null} target
5391 * @param {string | string[] | readonly string[] | undefined} classList
5392 * @param {boolean} condition
5393 */
5394 const toggleClass = (target, classList, condition) => {
5395 if (!target || !classList) {
5396 return;
5397 }
5398 if (typeof classList === 'string') {
5399 classList = classList.split(/\s+/).filter(Boolean);
5400 }
5401 classList.forEach(className => {
5402 if (Array.isArray(target)) {
5403 target.forEach(elem => {
5404 if (condition) {
5405 elem.classList.add(className);
5406 } else {
5407 elem.classList.remove(className);
5408 }
5409 });
5410 } else {
5411 if (condition) {
5412 target.classList.add(className);
5413 } else {
5414 target.classList.remove(className);
5415 }
5416 }
5417 });
5418 };
5419
5420 /**
5421 * @param {HTMLElement | HTMLElement[] | null} target
5422 * @param {string | string[] | readonly string[] | undefined} classList
5423 */
5424 const addClass = (target, classList) => {
5425 toggleClass(target, classList, true);
5426 };
5427
5428 /**
5429 * @param {HTMLElement | HTMLElement[] | null} target
5430 * @param {string | string[] | readonly string[] | undefined} classList
5431 */
5432 const removeClass = (target, classList) => {
5433 toggleClass(target, classList, false);
5434 };
5435
5436 /**
5437 * Get direct child of an element by class name
5438 *
5439 * @param {HTMLElement} elem
5440 * @param {string} className
5441 * @returns {HTMLElement | undefined}
5442 */
5443 const getDirectChildByClass = (elem, className) => {
5444 const children = Array.from(elem.children);
5445 for (let i = 0; i < children.length; i++) {
5446 const child = children[i];
5447 if (child instanceof HTMLElement && hasClass(child, className)) {
5448 return child;
5449 }
5450 }
5451 };
5452
5453 /**
5454 * @param {HTMLElement} elem
5455 * @param {string} property
5456 * @param {*} value
5457 */
5458 const applyNumericalStyle = (elem, property, value) => {
5459 if (value === `${parseInt(value)}`) {
5460 value = parseInt(value);
5461 }
5462 if (value || parseInt(value) === 0) {
5463 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : value);
5464 } else {
5465 elem.style.removeProperty(property);
5466 }
5467 };
5468
5469 /**
5470 * @param {HTMLElement | null} elem
5471 * @param {string} display
5472 */
5473 const show = (elem, display = 'flex') => {
5474 if (!elem) {
5475 return;
5476 }
5477 elem.style.display = display;
5478 };
5479
5480 /**
5481 * @param {HTMLElement | null} elem
5482 */
5483 const hide = elem => {
5484 if (!elem) {
5485 return;
5486 }
5487 elem.style.display = 'none';
5488 };
5489
5490 /**
5491 * @param {HTMLElement | null} elem
5492 * @param {string} display
5493 */
5494 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
5495 if (!elem) {
5496 return;
5497 }
5498 new MutationObserver(() => {
5499 toggle(elem, elem.innerHTML, display);
5500 }).observe(elem, {
5501 childList: true,
5502 subtree: true
5503 });
5504 };
5505
5506 /**
5507 * @param {HTMLElement} parent
5508 * @param {string} selector
5509 * @param {string} property
5510 * @param {string} value
5511 */
5512 const setStyle = (parent, selector, property, value) => {
5513 /** @type {HTMLElement | null} */
5514 const el = parent.querySelector(selector);
5515 if (el) {
5516 el.style.setProperty(property, value);
5517 }
5518 };
5519
5520 /**
5521 * @param {HTMLElement} elem
5522 * @param {any} condition
5523 * @param {string} display
5524 */
5525 const toggle = (elem, condition, display = 'flex') => {
5526 if (condition) {
5527 show(elem, display);
5528 } else {
5529 hide(elem);
5530 }
5531 };
5532
5533 /**
5534 * borrowed from jquery $(elem).is(':visible') implementation
5535 *
5536 * @param {HTMLElement | null} elem
5537 * @returns {boolean}
5538 */
5539 const isVisible$1 = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
5540
5541 /**
5542 * @returns {boolean}
5543 */
5544 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
5545
5546 /**
5547 * @param {HTMLElement} elem
5548 * @returns {boolean}
5549 */
5550 const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight);
5551
5552 /**
5553 * @param {HTMLElement} element
5554 * @param {HTMLElement} stopElement
5555 * @returns {boolean}
5556 */
5557 const selfOrParentIsScrollable = (element, stopElement) => {
5558 let parent = element;
5559 while (parent && parent !== stopElement) {
5560 if (isScrollable(parent)) {
5561 return true;
5562 }
5563 parent = parent.parentElement;
5564 }
5565 return false;
5566 };
5567
5568 /**
5569 * borrowed from https://stackoverflow.com/a/46352119
5570 *
5571 * @param {HTMLElement} elem
5572 * @returns {boolean}
5573 */
5574 const hasCssAnimation = elem => {
5575 const style = window.getComputedStyle(elem);
5576 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
5577 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
5578 return animDuration > 0 || transDuration > 0;
5579 };
5580
5581 /**
5582 * @param {number} timer
5583 * @param {boolean} reset
5584 */
5585 const animateTimerProgressBar = (timer, reset = false) => {
5586 const timerProgressBar = getTimerProgressBar();
5587 if (!timerProgressBar) {
5588 return;
5589 }
5590 if (isVisible$1(timerProgressBar)) {
5591 if (reset) {
5592 timerProgressBar.style.transition = 'none';
5593 timerProgressBar.style.width = '100%';
5594 }
5595 setTimeout(() => {
5596 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
5597 timerProgressBar.style.width = '0%';
5598 }, 10);
5599 }
5600 };
5601 const stopTimerProgressBar = () => {
5602 const timerProgressBar = getTimerProgressBar();
5603 if (!timerProgressBar) {
5604 return;
5605 }
5606 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
5607 timerProgressBar.style.removeProperty('transition');
5608 timerProgressBar.style.width = '100%';
5609 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
5610 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
5611 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
5612 };
5613
5614 /**
5615 * Detect Node env
5616 *
5617 * @returns {boolean}
5618 */
5619 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
5620
5621 const sweetHTML = `
5622 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
5623 <button type="button" class="${swalClasses.close}"></button>
5624 <ul class="${swalClasses['progress-steps']}"></ul>
5625 <div class="${swalClasses.icon}"></div>
5626 <img class="${swalClasses.image}" />
5627 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
5628 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
5629 <input class="${swalClasses.input}" id="${swalClasses.input}" />
5630 <input type="file" class="${swalClasses.file}" />
5631 <div class="${swalClasses.range}">
5632 <input type="range" />
5633 <output></output>
5634 </div>
5635 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
5636 <div class="${swalClasses.radio}"></div>
5637 <label class="${swalClasses.checkbox}">
5638 <input type="checkbox" id="${swalClasses.checkbox}" />
5639 <span class="${swalClasses.label}"></span>
5640 </label>
5641 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
5642 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
5643 <div class="${swalClasses.actions}">
5644 <div class="${swalClasses.loader}"></div>
5645 <button type="button" class="${swalClasses.confirm}"></button>
5646 <button type="button" class="${swalClasses.deny}"></button>
5647 <button type="button" class="${swalClasses.cancel}"></button>
5648 </div>
5649 <div class="${swalClasses.footer}"></div>
5650 <div class="${swalClasses['timer-progress-bar-container']}">
5651 <div class="${swalClasses['timer-progress-bar']}"></div>
5652 </div>
5653 </div>
5654 `.replace(/(^|\n)\s*/g, '');
5655
5656 /**
5657 * @returns {boolean}
5658 */
5659 const resetOldContainer = () => {
5660 const oldContainer = getContainer();
5661 if (!oldContainer) {
5662 return false;
5663 }
5664 oldContainer.remove();
5665 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]);
5666 return true;
5667 };
5668 const resetValidationMessage$1 = () => {
5669 globalState.currentInstance.resetValidationMessage();
5670 };
5671 const addInputChangeListeners = () => {
5672 const popup = getPopup();
5673 const input = getDirectChildByClass(popup, swalClasses.input);
5674 const file = getDirectChildByClass(popup, swalClasses.file);
5675 /** @type {HTMLInputElement} */
5676 const range = popup.querySelector(`.${swalClasses.range} input`);
5677 /** @type {HTMLOutputElement} */
5678 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
5679 const select = getDirectChildByClass(popup, swalClasses.select);
5680 /** @type {HTMLInputElement} */
5681 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
5682 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
5683 input.oninput = resetValidationMessage$1;
5684 file.onchange = resetValidationMessage$1;
5685 select.onchange = resetValidationMessage$1;
5686 checkbox.onchange = resetValidationMessage$1;
5687 textarea.oninput = resetValidationMessage$1;
5688 range.oninput = () => {
5689 resetValidationMessage$1();
5690 rangeOutput.value = range.value;
5691 };
5692 range.onchange = () => {
5693 resetValidationMessage$1();
5694 rangeOutput.value = range.value;
5695 };
5696 };
5697
5698 /**
5699 * @param {string | HTMLElement} target
5700 * @returns {HTMLElement}
5701 */
5702 const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;
5703
5704 /**
5705 * @param {SweetAlertOptions} params
5706 */
5707 const setupAccessibility = params => {
5708 const popup = getPopup();
5709 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
5710 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
5711 if (!params.toast) {
5712 popup.setAttribute('aria-modal', 'true');
5713 }
5714 };
5715
5716 /**
5717 * @param {HTMLElement} targetElement
5718 */
5719 const setupRTL = targetElement => {
5720 if (window.getComputedStyle(targetElement).direction === 'rtl') {
5721 addClass(getContainer(), swalClasses.rtl);
5722 }
5723 };
5724
5725 /**
5726 * Add modal + backdrop + no-war message for Russians to DOM
5727 *
5728 * @param {SweetAlertOptions} params
5729 */
5730 const init = params => {
5731 // Clean up the old popup container if it exists
5732 const oldContainerExisted = resetOldContainer();
5733 if (isNodeEnv()) {
5734 error('SweetAlert2 requires document to initialize');
5735 return;
5736 }
5737 const container = document.createElement('div');
5738 container.className = swalClasses.container;
5739 if (oldContainerExisted) {
5740 addClass(container, swalClasses['no-transition']);
5741 }
5742 setInnerHtml(container, sweetHTML);
5743 container.dataset['swal2Theme'] = params.theme;
5744 const targetElement = getTarget(params.target);
5745 targetElement.appendChild(container);
5746 if (params.topLayer) {
5747 container.setAttribute('popover', '');
5748 container.showPopover();
5749 }
5750 setupAccessibility(params);
5751 setupRTL(targetElement);
5752 addInputChangeListeners();
5753 };
5754
5755 /**
5756 * @param {HTMLElement | object | string} param
5757 * @param {HTMLElement} target
5758 */
5759 const parseHtmlToContainer = (param, target) => {
5760 // DOM element
5761 if (param instanceof HTMLElement) {
5762 target.appendChild(param);
5763 }
5764
5765 // Object
5766 else if (typeof param === 'object') {
5767 handleObject(param, target);
5768 }
5769
5770 // Plain string
5771 else if (param) {
5772 setInnerHtml(target, param);
5773 }
5774 };
5775
5776 /**
5777 * @param {any} param
5778 * @param {HTMLElement} target
5779 */
5780 const handleObject = (param, target) => {
5781 // JQuery element(s)
5782 if (param.jquery) {
5783 handleJqueryElem(target, param);
5784 }
5785
5786 // For other objects use their string representation
5787 else {
5788 setInnerHtml(target, param.toString());
5789 }
5790 };
5791
5792 /**
5793 * @param {HTMLElement} target
5794 * @param {any} elem
5795 */
5796 const handleJqueryElem = (target, elem) => {
5797 target.textContent = '';
5798 if (0 in elem) {
5799 for (let i = 0; i in elem; i++) {
5800 target.appendChild(elem[i].cloneNode(true));
5801 }
5802 } else {
5803 target.appendChild(elem.cloneNode(true));
5804 }
5805 };
5806
5807 /**
5808 * @param {SweetAlert} instance
5809 * @param {SweetAlertOptions} params
5810 */
5811 const renderActions = (instance, params) => {
5812 const actions = getActions();
5813 const loader = getLoader();
5814 if (!actions || !loader) {
5815 return;
5816 }
5817
5818 // Actions (buttons) wrapper
5819 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
5820 hide(actions);
5821 } else {
5822 show(actions);
5823 }
5824
5825 // Custom class
5826 applyCustomClass(actions, params, 'actions');
5827
5828 // Render all the buttons
5829 renderButtons(actions, loader, params);
5830
5831 // Loader
5832 setInnerHtml(loader, params.loaderHtml || '');
5833 applyCustomClass(loader, params, 'loader');
5834 };
5835
5836 /**
5837 * @param {HTMLElement} actions
5838 * @param {HTMLElement} loader
5839 * @param {SweetAlertOptions} params
5840 */
5841 function renderButtons(actions, loader, params) {
5842 const confirmButton = getConfirmButton();
5843 const denyButton = getDenyButton();
5844 const cancelButton = getCancelButton();
5845 if (!confirmButton || !denyButton || !cancelButton) {
5846 return;
5847 }
5848
5849 // Render buttons
5850 renderButton(confirmButton, 'confirm', params);
5851 renderButton(denyButton, 'deny', params);
5852 renderButton(cancelButton, 'cancel', params);
5853 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
5854 if (params.reverseButtons) {
5855 if (params.toast) {
5856 actions.insertBefore(cancelButton, confirmButton);
5857 actions.insertBefore(denyButton, confirmButton);
5858 } else {
5859 actions.insertBefore(cancelButton, loader);
5860 actions.insertBefore(denyButton, loader);
5861 actions.insertBefore(confirmButton, loader);
5862 }
5863 }
5864 }
5865
5866 /**
5867 * @param {HTMLElement} confirmButton
5868 * @param {HTMLElement} denyButton
5869 * @param {HTMLElement} cancelButton
5870 * @param {SweetAlertOptions} params
5871 */
5872 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
5873 if (!params.buttonsStyling) {
5874 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
5875 return;
5876 }
5877 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
5878
5879 // Apply custom background colors to action buttons
5880 if (params.confirmButtonColor) {
5881 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
5882 }
5883 if (params.denyButtonColor) {
5884 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
5885 }
5886 if (params.cancelButtonColor) {
5887 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
5888 }
5889
5890 // Apply the outline color to action buttons
5891 applyOutlineColor(confirmButton);
5892 applyOutlineColor(denyButton);
5893 applyOutlineColor(cancelButton);
5894 }
5895
5896 /**
5897 * @param {HTMLElement} button
5898 */
5899 function applyOutlineColor(button) {
5900 const buttonStyle = window.getComputedStyle(button);
5901 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
5902 // If the button already has a custom outline color, no need to change it
5903 return;
5904 }
5905 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
5906 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
5907 }
5908
5909 /**
5910 * @param {HTMLElement} button
5911 * @param {'confirm' | 'deny' | 'cancel'} buttonType
5912 * @param {SweetAlertOptions} params
5913 */
5914 function renderButton(button, buttonType, params) {
5915 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
5916 toggle(button, params[`show${buttonName}Button`], 'inline-block');
5917 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
5918 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
5919
5920 // Add buttons custom classes
5921 button.className = swalClasses[buttonType];
5922 applyCustomClass(button, params, `${buttonType}Button`);
5923 }
5924
5925 /**
5926 * @param {SweetAlert} instance
5927 * @param {SweetAlertOptions} params
5928 */
5929 const renderCloseButton = (instance, params) => {
5930 const closeButton = getCloseButton();
5931 if (!closeButton) {
5932 return;
5933 }
5934 setInnerHtml(closeButton, params.closeButtonHtml || '');
5935
5936 // Custom class
5937 applyCustomClass(closeButton, params, 'closeButton');
5938 toggle(closeButton, params.showCloseButton);
5939 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
5940 };
5941
5942 /**
5943 * @param {SweetAlert} instance
5944 * @param {SweetAlertOptions} params
5945 */
5946 const renderContainer = (instance, params) => {
5947 const container = getContainer();
5948 if (!container) {
5949 return;
5950 }
5951 handleBackdropParam(container, params.backdrop);
5952 handlePositionParam(container, params.position);
5953 handleGrowParam(container, params.grow);
5954
5955 // Custom class
5956 applyCustomClass(container, params, 'container');
5957 };
5958
5959 /**
5960 * @param {HTMLElement} container
5961 * @param {SweetAlertOptions['backdrop']} backdrop
5962 */
5963 function handleBackdropParam(container, backdrop) {
5964 if (typeof backdrop === 'string') {
5965 container.style.background = backdrop;
5966 } else if (!backdrop) {
5967 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
5968 }
5969 }
5970
5971 /**
5972 * @param {HTMLElement} container
5973 * @param {SweetAlertOptions['position']} position
5974 */
5975 function handlePositionParam(container, position) {
5976 if (!position) {
5977 return;
5978 }
5979 if (position in swalClasses) {
5980 addClass(container, swalClasses[position]);
5981 } else {
5982 warn('The "position" parameter is not valid, defaulting to "center"');
5983 addClass(container, swalClasses.center);
5984 }
5985 }
5986
5987 /**
5988 * @param {HTMLElement} container
5989 * @param {SweetAlertOptions['grow']} grow
5990 */
5991 function handleGrowParam(container, grow) {
5992 if (!grow) {
5993 return;
5994 }
5995 addClass(container, swalClasses[`grow-${grow}`]);
5996 }
5997
5998 /**
5999 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
6000 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
6001 * This is the approach that Babel will probably take to implement private methods/fields
6002 * https://github.com/tc39/proposal-private-methods
6003 * https://github.com/babel/babel/pull/7555
6004 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
6005 * then we can use that language feature.
6006 */
6007
6008 var privateProps = {
6009 innerParams: new WeakMap(),
6010 domCache: new WeakMap()
6011 };
6012
6013 /// <reference path="../../../../sweetalert2.d.ts"/>
6014
6015
6016 /** @type {InputClass[]} */
6017 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
6018
6019 /**
6020 * @param {SweetAlert} instance
6021 * @param {SweetAlertOptions} params
6022 */
6023 const renderInput = (instance, params) => {
6024 const popup = getPopup();
6025 if (!popup) {
6026 return;
6027 }
6028 const innerParams = privateProps.innerParams.get(instance);
6029 const rerender = !innerParams || params.input !== innerParams.input;
6030 inputClasses.forEach(inputClass => {
6031 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
6032 if (!inputContainer) {
6033 return;
6034 }
6035
6036 // set attributes
6037 setAttributes(inputClass, params.inputAttributes);
6038
6039 // set class
6040 inputContainer.className = swalClasses[inputClass];
6041 if (rerender) {
6042 hide(inputContainer);
6043 }
6044 });
6045 if (params.input) {
6046 if (rerender) {
6047 showInput(params);
6048 }
6049 // set custom class
6050 setCustomClass(params);
6051 }
6052 };
6053
6054 /**
6055 * @param {SweetAlertOptions} params
6056 */
6057 const showInput = params => {
6058 if (!params.input) {
6059 return;
6060 }
6061 if (!renderInputType[params.input]) {
6062 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
6063 return;
6064 }
6065 const inputContainer = getInputContainer(params.input);
6066 if (!inputContainer) {
6067 return;
6068 }
6069 const input = renderInputType[params.input](inputContainer, params);
6070 show(inputContainer);
6071
6072 // input autofocus
6073 if (params.inputAutoFocus) {
6074 setTimeout(() => {
6075 focusInput(input);
6076 });
6077 }
6078 };
6079
6080 /**
6081 * @param {HTMLInputElement} input
6082 */
6083 const removeAttributes = input => {
6084 for (let i = 0; i < input.attributes.length; i++) {
6085 const attrName = input.attributes[i].name;
6086 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
6087 input.removeAttribute(attrName);
6088 }
6089 }
6090 };
6091
6092 /**
6093 * @param {InputClass} inputClass
6094 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
6095 */
6096 const setAttributes = (inputClass, inputAttributes) => {
6097 const popup = getPopup();
6098 if (!popup) {
6099 return;
6100 }
6101 const input = getInput$1(popup, inputClass);
6102 if (!input) {
6103 return;
6104 }
6105 removeAttributes(input);
6106 for (const attr in inputAttributes) {
6107 input.setAttribute(attr, inputAttributes[attr]);
6108 }
6109 };
6110
6111 /**
6112 * @param {SweetAlertOptions} params
6113 */
6114 const setCustomClass = params => {
6115 if (!params.input) {
6116 return;
6117 }
6118 const inputContainer = getInputContainer(params.input);
6119 if (inputContainer) {
6120 applyCustomClass(inputContainer, params, 'input');
6121 }
6122 };
6123
6124 /**
6125 * @param {HTMLInputElement | HTMLTextAreaElement} input
6126 * @param {SweetAlertOptions} params
6127 */
6128 const setInputPlaceholder = (input, params) => {
6129 if (!input.placeholder && params.inputPlaceholder) {
6130 input.placeholder = params.inputPlaceholder;
6131 }
6132 };
6133
6134 /**
6135 * @param {Input} input
6136 * @param {Input} prependTo
6137 * @param {SweetAlertOptions} params
6138 */
6139 const setInputLabel = (input, prependTo, params) => {
6140 if (params.inputLabel) {
6141 const label = document.createElement('label');
6142 const labelClass = swalClasses['input-label'];
6143 label.setAttribute('for', input.id);
6144 label.className = labelClass;
6145 if (typeof params.customClass === 'object') {
6146 addClass(label, params.customClass.inputLabel);
6147 }
6148 label.innerText = params.inputLabel;
6149 prependTo.insertAdjacentElement('beforebegin', label);
6150 }
6151 };
6152
6153 /**
6154 * @param {SweetAlertInput} inputType
6155 * @returns {HTMLElement | undefined}
6156 */
6157 const getInputContainer = inputType => {
6158 const popup = getPopup();
6159 if (!popup) {
6160 return;
6161 }
6162 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
6163 };
6164
6165 /**
6166 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
6167 * @param {SweetAlertOptions['inputValue']} inputValue
6168 */
6169 const checkAndSetInputValue = (input, inputValue) => {
6170 if (['string', 'number'].includes(typeof inputValue)) {
6171 input.value = `${inputValue}`;
6172 } else if (!isPromise(inputValue)) {
6173 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
6174 }
6175 };
6176
6177 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
6178 const renderInputType = {};
6179
6180 /**
6181 * @param {HTMLInputElement} input
6182 * @param {SweetAlertOptions} params
6183 * @returns {HTMLInputElement}
6184 */
6185 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} */
6186 (input, params) => {
6187 checkAndSetInputValue(input, params.inputValue);
6188 setInputLabel(input, input, params);
6189 setInputPlaceholder(input, params);
6190 input.type = params.input;
6191 return input;
6192 };
6193
6194 /**
6195 * @param {HTMLInputElement} input
6196 * @param {SweetAlertOptions} params
6197 * @returns {HTMLInputElement}
6198 */
6199 renderInputType.file = (input, params) => {
6200 setInputLabel(input, input, params);
6201 setInputPlaceholder(input, params);
6202 return input;
6203 };
6204
6205 /**
6206 * @param {HTMLInputElement} range
6207 * @param {SweetAlertOptions} params
6208 * @returns {HTMLInputElement}
6209 */
6210 renderInputType.range = (range, params) => {
6211 const rangeInput = range.querySelector('input');
6212 const rangeOutput = range.querySelector('output');
6213 checkAndSetInputValue(rangeInput, params.inputValue);
6214 rangeInput.type = params.input;
6215 checkAndSetInputValue(rangeOutput, params.inputValue);
6216 setInputLabel(rangeInput, range, params);
6217 return range;
6218 };
6219
6220 /**
6221 * @param {HTMLSelectElement} select
6222 * @param {SweetAlertOptions} params
6223 * @returns {HTMLSelectElement}
6224 */
6225 renderInputType.select = (select, params) => {
6226 select.textContent = '';
6227 if (params.inputPlaceholder) {
6228 const placeholder = document.createElement('option');
6229 setInnerHtml(placeholder, params.inputPlaceholder);
6230 placeholder.value = '';
6231 placeholder.disabled = true;
6232 placeholder.selected = true;
6233 select.appendChild(placeholder);
6234 }
6235 setInputLabel(select, select, params);
6236 return select;
6237 };
6238
6239 /**
6240 * @param {HTMLInputElement} radio
6241 * @returns {HTMLInputElement}
6242 */
6243 renderInputType.radio = radio => {
6244 radio.textContent = '';
6245 return radio;
6246 };
6247
6248 /**
6249 * @param {HTMLLabelElement} checkboxContainer
6250 * @param {SweetAlertOptions} params
6251 * @returns {HTMLInputElement}
6252 */
6253 renderInputType.checkbox = (checkboxContainer, params) => {
6254 const checkbox = getInput$1(getPopup(), 'checkbox');
6255 checkbox.value = '1';
6256 checkbox.checked = Boolean(params.inputValue);
6257 const label = checkboxContainer.querySelector('span');
6258 setInnerHtml(label, params.inputPlaceholder || params.inputLabel);
6259 return checkbox;
6260 };
6261
6262 /**
6263 * @param {HTMLTextAreaElement} textarea
6264 * @param {SweetAlertOptions} params
6265 * @returns {HTMLTextAreaElement}
6266 */
6267 renderInputType.textarea = (textarea, params) => {
6268 checkAndSetInputValue(textarea, params.inputValue);
6269 setInputPlaceholder(textarea, params);
6270 setInputLabel(textarea, textarea, params);
6271
6272 /**
6273 * @param {HTMLElement} el
6274 * @returns {number}
6275 */
6276 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
6277
6278 // https://github.com/sweetalert2/sweetalert2/issues/2291
6279 setTimeout(() => {
6280 // https://github.com/sweetalert2/sweetalert2/issues/1699
6281 if ('MutationObserver' in window) {
6282 const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
6283 const textareaResizeHandler = () => {
6284 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
6285 if (!document.body.contains(textarea)) {
6286 return;
6287 }
6288 const textareaWidth = textarea.offsetWidth + getMargin(textarea);
6289 if (textareaWidth > initialPopupWidth) {
6290 getPopup().style.width = `${textareaWidth}px`;
6291 } else {
6292 applyNumericalStyle(getPopup(), 'width', params.width);
6293 }
6294 };
6295 new MutationObserver(textareaResizeHandler).observe(textarea, {
6296 attributes: true,
6297 attributeFilter: ['style']
6298 });
6299 }
6300 });
6301 return textarea;
6302 };
6303
6304 /**
6305 * @param {SweetAlert} instance
6306 * @param {SweetAlertOptions} params
6307 */
6308 const renderContent = (instance, params) => {
6309 const htmlContainer = getHtmlContainer();
6310 if (!htmlContainer) {
6311 return;
6312 }
6313 showWhenInnerHtmlPresent(htmlContainer);
6314 applyCustomClass(htmlContainer, params, 'htmlContainer');
6315
6316 // Content as HTML
6317 if (params.html) {
6318 parseHtmlToContainer(params.html, htmlContainer);
6319 show(htmlContainer, 'block');
6320 }
6321
6322 // Content as plain text
6323 else if (params.text) {
6324 htmlContainer.textContent = params.text;
6325 show(htmlContainer, 'block');
6326 }
6327
6328 // No content
6329 else {
6330 hide(htmlContainer);
6331 }
6332 renderInput(instance, params);
6333 };
6334
6335 /**
6336 * @param {SweetAlert} instance
6337 * @param {SweetAlertOptions} params
6338 */
6339 const renderFooter = (instance, params) => {
6340 const footer = getFooter();
6341 if (!footer) {
6342 return;
6343 }
6344 showWhenInnerHtmlPresent(footer);
6345 toggle(footer, params.footer, 'block');
6346 if (params.footer) {
6347 parseHtmlToContainer(params.footer, footer);
6348 }
6349
6350 // Custom class
6351 applyCustomClass(footer, params, 'footer');
6352 };
6353
6354 /**
6355 * @param {SweetAlert} instance
6356 * @param {SweetAlertOptions} params
6357 */
6358 const renderIcon = (instance, params) => {
6359 const innerParams = privateProps.innerParams.get(instance);
6360 const icon = getIcon();
6361 if (!icon) {
6362 return;
6363 }
6364
6365 // if the given icon already rendered, apply the styling without re-rendering the icon
6366 if (innerParams && params.icon === innerParams.icon) {
6367 // Custom or default content
6368 setContent(icon, params);
6369 applyStyles(icon, params);
6370 return;
6371 }
6372 if (!params.icon && !params.iconHtml) {
6373 hide(icon);
6374 return;
6375 }
6376 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
6377 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
6378 hide(icon);
6379 return;
6380 }
6381 show(icon);
6382
6383 // Custom or default content
6384 setContent(icon, params);
6385 applyStyles(icon, params);
6386
6387 // Animate icon
6388 addClass(icon, params.showClass && params.showClass.icon);
6389
6390 // Re-adjust the success icon on system theme change
6391 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
6392 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
6393 };
6394
6395 /**
6396 * @param {HTMLElement} icon
6397 * @param {SweetAlertOptions} params
6398 */
6399 const applyStyles = (icon, params) => {
6400 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
6401 if (params.icon !== iconType) {
6402 removeClass(icon, iconClassName);
6403 }
6404 }
6405 addClass(icon, params.icon && iconTypes[params.icon]);
6406
6407 // Icon color
6408 setColor(icon, params);
6409
6410 // Success icon background color
6411 adjustSuccessIconBackgroundColor();
6412
6413 // Custom class
6414 applyCustomClass(icon, params, 'icon');
6415 };
6416
6417 // Adjust success icon background color to match the popup background color
6418 const adjustSuccessIconBackgroundColor = () => {
6419 const popup = getPopup();
6420 if (!popup) {
6421 return;
6422 }
6423 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
6424 /** @type {NodeListOf<HTMLElement>} */
6425 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
6426 for (let i = 0; i < successIconParts.length; i++) {
6427 successIconParts[i].style.backgroundColor = popupBackgroundColor;
6428 }
6429 };
6430
6431 /**
6432 *
6433 * @param {SweetAlertOptions} params
6434 * @returns {string}
6435 */
6436 const successIconHtml = params => `
6437 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
6438 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
6439 <div class="swal2-success-ring"></div>
6440 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
6441 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
6442 `;
6443 const errorIconHtml = `
6444 <span class="swal2-x-mark">
6445 <span class="swal2-x-mark-line-left"></span>
6446 <span class="swal2-x-mark-line-right"></span>
6447 </span>
6448 `;
6449
6450 /**
6451 * @param {HTMLElement} icon
6452 * @param {SweetAlertOptions} params
6453 */
6454 const setContent = (icon, params) => {
6455 if (!params.icon && !params.iconHtml) {
6456 return;
6457 }
6458 let oldContent = icon.innerHTML;
6459 let newContent = '';
6460 if (params.iconHtml) {
6461 newContent = iconContent(params.iconHtml);
6462 } else if (params.icon === 'success') {
6463 newContent = successIconHtml(params);
6464 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
6465 } else if (params.icon === 'error') {
6466 newContent = errorIconHtml;
6467 } else if (params.icon) {
6468 const defaultIconHtml = {
6469 question: '?',
6470 warning: '!',
6471 info: 'i'
6472 };
6473 newContent = iconContent(defaultIconHtml[params.icon]);
6474 }
6475 if (oldContent.trim() !== newContent.trim()) {
6476 setInnerHtml(icon, newContent);
6477 }
6478 };
6479
6480 /**
6481 * @param {HTMLElement} icon
6482 * @param {SweetAlertOptions} params
6483 */
6484 const setColor = (icon, params) => {
6485 if (!params.iconColor) {
6486 return;
6487 }
6488 icon.style.color = params.iconColor;
6489 icon.style.borderColor = params.iconColor;
6490 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
6491 setStyle(icon, sel, 'background-color', params.iconColor);
6492 }
6493 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
6494 };
6495
6496 /**
6497 * @param {string} content
6498 * @returns {string}
6499 */
6500 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
6501
6502 /**
6503 * @param {SweetAlert} instance
6504 * @param {SweetAlertOptions} params
6505 */
6506 const renderImage = (instance, params) => {
6507 const image = getImage();
6508 if (!image) {
6509 return;
6510 }
6511 if (!params.imageUrl) {
6512 hide(image);
6513 return;
6514 }
6515 show(image, '');
6516
6517 // Src, alt
6518 image.setAttribute('src', params.imageUrl);
6519 image.setAttribute('alt', params.imageAlt || '');
6520
6521 // Width, height
6522 applyNumericalStyle(image, 'width', params.imageWidth);
6523 applyNumericalStyle(image, 'height', params.imageHeight);
6524
6525 // Class
6526 image.className = swalClasses.image;
6527 applyCustomClass(image, params, 'image');
6528 };
6529
6530 let dragging = false;
6531 let mousedownX = 0;
6532 let mousedownY = 0;
6533 let initialX = 0;
6534 let initialY = 0;
6535
6536 /**
6537 * @param {HTMLElement} popup
6538 */
6539 const addDraggableListeners = popup => {
6540 popup.addEventListener('mousedown', down);
6541 document.body.addEventListener('mousemove', move);
6542 popup.addEventListener('mouseup', up);
6543 popup.addEventListener('touchstart', down);
6544 document.body.addEventListener('touchmove', move);
6545 popup.addEventListener('touchend', up);
6546 };
6547
6548 /**
6549 * @param {HTMLElement} popup
6550 */
6551 const removeDraggableListeners = popup => {
6552 popup.removeEventListener('mousedown', down);
6553 document.body.removeEventListener('mousemove', move);
6554 popup.removeEventListener('mouseup', up);
6555 popup.removeEventListener('touchstart', down);
6556 document.body.removeEventListener('touchmove', move);
6557 popup.removeEventListener('touchend', up);
6558 };
6559
6560 /**
6561 * @param {MouseEvent | TouchEvent} event
6562 */
6563 const down = event => {
6564 const popup = getPopup();
6565 if (event.target === popup || getIcon().contains(/** @type {HTMLElement} */event.target)) {
6566 dragging = true;
6567 const clientXY = getClientXY(event);
6568 mousedownX = clientXY.clientX;
6569 mousedownY = clientXY.clientY;
6570 initialX = parseInt(popup.style.insetInlineStart) || 0;
6571 initialY = parseInt(popup.style.insetBlockStart) || 0;
6572 addClass(popup, 'swal2-dragging');
6573 }
6574 };
6575
6576 /**
6577 * @param {MouseEvent | TouchEvent} event
6578 */
6579 const move = event => {
6580 const popup = getPopup();
6581 if (dragging) {
6582 let {
6583 clientX,
6584 clientY
6585 } = getClientXY(event);
6586 popup.style.insetInlineStart = `${initialX + (clientX - mousedownX)}px`;
6587 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
6588 }
6589 };
6590 const up = () => {
6591 const popup = getPopup();
6592 dragging = false;
6593 removeClass(popup, 'swal2-dragging');
6594 };
6595
6596 /**
6597 * @param {MouseEvent | TouchEvent} event
6598 * @returns {{ clientX: number, clientY: number }}
6599 */
6600 const getClientXY = event => {
6601 let clientX = 0,
6602 clientY = 0;
6603 if (event.type.startsWith('mouse')) {
6604 clientX = /** @type {MouseEvent} */event.clientX;
6605 clientY = /** @type {MouseEvent} */event.clientY;
6606 } else if (event.type.startsWith('touch')) {
6607 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
6608 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
6609 }
6610 return {
6611 clientX,
6612 clientY
6613 };
6614 };
6615
6616 /**
6617 * @param {SweetAlert} instance
6618 * @param {SweetAlertOptions} params
6619 */
6620 const renderPopup = (instance, params) => {
6621 const container = getContainer();
6622 const popup = getPopup();
6623 if (!container || !popup) {
6624 return;
6625 }
6626
6627 // Width
6628 // https://github.com/sweetalert2/sweetalert2/issues/2170
6629 if (params.toast) {
6630 applyNumericalStyle(container, 'width', params.width);
6631 popup.style.width = '100%';
6632 const loader = getLoader();
6633 if (loader) {
6634 popup.insertBefore(loader, getIcon());
6635 }
6636 } else {
6637 applyNumericalStyle(popup, 'width', params.width);
6638 }
6639
6640 // Padding
6641 applyNumericalStyle(popup, 'padding', params.padding);
6642
6643 // Color
6644 if (params.color) {
6645 popup.style.color = params.color;
6646 }
6647
6648 // Background
6649 if (params.background) {
6650 popup.style.background = params.background;
6651 }
6652 hide(getValidationMessage());
6653
6654 // Classes
6655 addClasses$1(popup, params);
6656 if (params.draggable && !params.toast) {
6657 addClass(popup, swalClasses.draggable);
6658 addDraggableListeners(popup);
6659 } else {
6660 removeClass(popup, swalClasses.draggable);
6661 removeDraggableListeners(popup);
6662 }
6663 };
6664
6665 /**
6666 * @param {HTMLElement} popup
6667 * @param {SweetAlertOptions} params
6668 */
6669 const addClasses$1 = (popup, params) => {
6670 const showClass = params.showClass || {};
6671 // Default Class + showClass when updating Swal.update({})
6672 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
6673 if (params.toast) {
6674 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
6675 addClass(popup, swalClasses.toast);
6676 } else {
6677 addClass(popup, swalClasses.modal);
6678 }
6679
6680 // Custom class
6681 applyCustomClass(popup, params, 'popup');
6682 // TODO: remove in the next major
6683 if (typeof params.customClass === 'string') {
6684 addClass(popup, params.customClass);
6685 }
6686
6687 // Icon class (#1842)
6688 if (params.icon) {
6689 addClass(popup, swalClasses[`icon-${params.icon}`]);
6690 }
6691 };
6692
6693 /**
6694 * @param {SweetAlert} instance
6695 * @param {SweetAlertOptions} params
6696 */
6697 const renderProgressSteps = (instance, params) => {
6698 const progressStepsContainer = getProgressSteps();
6699 if (!progressStepsContainer) {
6700 return;
6701 }
6702 const {
6703 progressSteps,
6704 currentProgressStep
6705 } = params;
6706 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
6707 hide(progressStepsContainer);
6708 return;
6709 }
6710 show(progressStepsContainer);
6711 progressStepsContainer.textContent = '';
6712 if (currentProgressStep >= progressSteps.length) {
6713 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
6714 }
6715 progressSteps.forEach((step, index) => {
6716 const stepEl = createStepElement(step);
6717 progressStepsContainer.appendChild(stepEl);
6718 if (index === currentProgressStep) {
6719 addClass(stepEl, swalClasses['active-progress-step']);
6720 }
6721 if (index !== progressSteps.length - 1) {
6722 const lineEl = createLineElement(params);
6723 progressStepsContainer.appendChild(lineEl);
6724 }
6725 });
6726 };
6727
6728 /**
6729 * @param {string} step
6730 * @returns {HTMLLIElement}
6731 */
6732 const createStepElement = step => {
6733 const stepEl = document.createElement('li');
6734 addClass(stepEl, swalClasses['progress-step']);
6735 setInnerHtml(stepEl, step);
6736 return stepEl;
6737 };
6738
6739 /**
6740 * @param {SweetAlertOptions} params
6741 * @returns {HTMLLIElement}
6742 */
6743 const createLineElement = params => {
6744 const lineEl = document.createElement('li');
6745 addClass(lineEl, swalClasses['progress-step-line']);
6746 if (params.progressStepsDistance) {
6747 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
6748 }
6749 return lineEl;
6750 };
6751
6752 /**
6753 * @param {SweetAlert} instance
6754 * @param {SweetAlertOptions} params
6755 */
6756 const renderTitle = (instance, params) => {
6757 const title = getTitle();
6758 if (!title) {
6759 return;
6760 }
6761 showWhenInnerHtmlPresent(title);
6762 toggle(title, params.title || params.titleText, 'block');
6763 if (params.title) {
6764 parseHtmlToContainer(params.title, title);
6765 }
6766 if (params.titleText) {
6767 title.innerText = params.titleText;
6768 }
6769
6770 // Custom class
6771 applyCustomClass(title, params, 'title');
6772 };
6773
6774 /**
6775 * @param {SweetAlert} instance
6776 * @param {SweetAlertOptions} params
6777 */
6778 const render = (instance, params) => {
6779 renderPopup(instance, params);
6780 renderContainer(instance, params);
6781 renderProgressSteps(instance, params);
6782 renderIcon(instance, params);
6783 renderImage(instance, params);
6784 renderTitle(instance, params);
6785 renderCloseButton(instance, params);
6786 renderContent(instance, params);
6787 renderActions(instance, params);
6788 renderFooter(instance, params);
6789 const popup = getPopup();
6790 if (typeof params.didRender === 'function' && popup) {
6791 params.didRender(popup);
6792 }
6793 globalState.eventEmitter.emit('didRender', popup);
6794 };
6795
6796 /*
6797 * Global function to determine if SweetAlert2 popup is shown
6798 */
6799 const isVisible = () => {
6800 return isVisible$1(getPopup());
6801 };
6802
6803 /*
6804 * Global function to click 'Confirm' button
6805 */
6806 const clickConfirm = () => {
6807 var _dom$getConfirmButton;
6808 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
6809 };
6810
6811 /*
6812 * Global function to click 'Deny' button
6813 */
6814 const clickDeny = () => {
6815 var _dom$getDenyButton;
6816 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
6817 };
6818
6819 /*
6820 * Global function to click 'Cancel' button
6821 */
6822 const clickCancel = () => {
6823 var _dom$getCancelButton;
6824 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
6825 };
6826
6827 /** @typedef {'cancel' | 'backdrop' | 'close' | 'esc' | 'timer'} DismissReason */
6828
6829 /** @type {Record<DismissReason, DismissReason>} */
6830 const DismissReason = Object.freeze({
6831 cancel: 'cancel',
6832 backdrop: 'backdrop',
6833 close: 'close',
6834 esc: 'esc',
6835 timer: 'timer'
6836 });
6837
6838 /**
6839 * @param {GlobalState} globalState
6840 */
6841 const removeKeydownHandler = globalState => {
6842 if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
6843 globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
6844 capture: globalState.keydownListenerCapture
6845 });
6846 globalState.keydownHandlerAdded = false;
6847 }
6848 };
6849
6850 /**
6851 * @param {GlobalState} globalState
6852 * @param {SweetAlertOptions} innerParams
6853 * @param {*} dismissWith
6854 */
6855 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
6856 removeKeydownHandler(globalState);
6857 if (!innerParams.toast) {
6858 globalState.keydownHandler = e => keydownHandler(innerParams, e, dismissWith);
6859 globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
6860 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
6861 globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
6862 capture: globalState.keydownListenerCapture
6863 });
6864 globalState.keydownHandlerAdded = true;
6865 }
6866 };
6867
6868 /**
6869 * @param {number} index
6870 * @param {number} increment
6871 */
6872 const setFocus = (index, increment) => {
6873 var _dom$getPopup;
6874 const focusableElements = getFocusableElements();
6875 // search for visible elements and select the next possible match
6876 if (focusableElements.length) {
6877 index = index + increment;
6878
6879 // shift + tab when .swal2-popup is focused
6880 if (index === -2) {
6881 index = focusableElements.length - 1;
6882 }
6883
6884 // rollover to first item
6885 if (index === focusableElements.length) {
6886 index = 0;
6887
6888 // go to last item
6889 } else if (index === -1) {
6890 index = focusableElements.length - 1;
6891 }
6892 focusableElements[index].focus();
6893 return;
6894 }
6895 // no visible focusable elements, focus the popup
6896 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
6897 };
6898 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
6899 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
6900
6901 /**
6902 * @param {SweetAlertOptions} innerParams
6903 * @param {KeyboardEvent} event
6904 * @param {Function} dismissWith
6905 */
6906 const keydownHandler = (innerParams, event, dismissWith) => {
6907 if (!innerParams) {
6908 return; // This instance has already been destroyed
6909 }
6910
6911 // Ignore keydown during IME composition
6912 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
6913 // https://github.com/sweetalert2/sweetalert2/issues/720
6914 // https://github.com/sweetalert2/sweetalert2/issues/2406
6915 if (event.isComposing || event.keyCode === 229) {
6916 return;
6917 }
6918 if (innerParams.stopKeydownPropagation) {
6919 event.stopPropagation();
6920 }
6921
6922 // ENTER
6923 if (event.key === 'Enter') {
6924 handleEnter(event, innerParams);
6925 }
6926
6927 // TAB
6928 else if (event.key === 'Tab') {
6929 handleTab(event);
6930 }
6931
6932 // ARROWS - switch focus between buttons
6933 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
6934 handleArrows(event.key);
6935 }
6936
6937 // ESC
6938 else if (event.key === 'Escape') {
6939 handleEsc(event, innerParams, dismissWith);
6940 }
6941 };
6942
6943 /**
6944 * @param {KeyboardEvent} event
6945 * @param {SweetAlertOptions} innerParams
6946 */
6947 const handleEnter = (event, innerParams) => {
6948 // https://github.com/sweetalert2/sweetalert2/issues/2386
6949 if (!callIfFunction(innerParams.allowEnterKey)) {
6950 return;
6951 }
6952 const input = getInput$1(getPopup(), innerParams.input);
6953 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
6954 if (['textarea', 'file'].includes(innerParams.input)) {
6955 return; // do not submit
6956 }
6957 clickConfirm();
6958 event.preventDefault();
6959 }
6960 };
6961
6962 /**
6963 * @param {KeyboardEvent} event
6964 */
6965 const handleTab = event => {
6966 const targetElement = event.target;
6967 const focusableElements = getFocusableElements();
6968 let btnIndex = -1;
6969 for (let i = 0; i < focusableElements.length; i++) {
6970 if (targetElement === focusableElements[i]) {
6971 btnIndex = i;
6972 break;
6973 }
6974 }
6975
6976 // Cycle to the next button
6977 if (!event.shiftKey) {
6978 setFocus(btnIndex, 1);
6979 }
6980
6981 // Cycle to the prev button
6982 else {
6983 setFocus(btnIndex, -1);
6984 }
6985 event.stopPropagation();
6986 event.preventDefault();
6987 };
6988
6989 /**
6990 * @param {string} key
6991 */
6992 const handleArrows = key => {
6993 const actions = getActions();
6994 const confirmButton = getConfirmButton();
6995 const denyButton = getDenyButton();
6996 const cancelButton = getCancelButton();
6997 if (!actions || !confirmButton || !denyButton || !cancelButton) {
6998 return;
6999 }
7000 /** @type HTMLElement[] */
7001 const buttons = [confirmButton, denyButton, cancelButton];
7002 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
7003 return;
7004 }
7005 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
7006 let buttonToFocus = document.activeElement;
7007 if (!buttonToFocus) {
7008 return;
7009 }
7010 for (let i = 0; i < actions.children.length; i++) {
7011 buttonToFocus = buttonToFocus[sibling];
7012 if (!buttonToFocus) {
7013 return;
7014 }
7015 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
7016 break;
7017 }
7018 }
7019 if (buttonToFocus instanceof HTMLButtonElement) {
7020 buttonToFocus.focus();
7021 }
7022 };
7023
7024 /**
7025 * @param {KeyboardEvent} event
7026 * @param {SweetAlertOptions} innerParams
7027 * @param {Function} dismissWith
7028 */
7029 const handleEsc = (event, innerParams, dismissWith) => {
7030 event.preventDefault();
7031 if (callIfFunction(innerParams.allowEscapeKey)) {
7032 dismissWith(DismissReason.esc);
7033 }
7034 };
7035
7036 /**
7037 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
7038 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
7039 * This is the approach that Babel will probably take to implement private methods/fields
7040 * https://github.com/tc39/proposal-private-methods
7041 * https://github.com/babel/babel/pull/7555
7042 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
7043 * then we can use that language feature.
7044 */
7045
7046 var privateMethods = {
7047 swalPromiseResolve: new WeakMap(),
7048 swalPromiseReject: new WeakMap()
7049 };
7050
7051 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
7052 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
7053 // elements not within the active modal dialog will not be surfaced if a user opens a screen
7054 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
7055
7056 const setAriaHidden = () => {
7057 const container = getContainer();
7058 const bodyChildren = Array.from(document.body.children);
7059 bodyChildren.forEach(el => {
7060 if (el.contains(container)) {
7061 return;
7062 }
7063 if (el.hasAttribute('aria-hidden')) {
7064 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
7065 }
7066 el.setAttribute('aria-hidden', 'true');
7067 });
7068 };
7069 const unsetAriaHidden = () => {
7070 const bodyChildren = Array.from(document.body.children);
7071 bodyChildren.forEach(el => {
7072 if (el.hasAttribute('data-previous-aria-hidden')) {
7073 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
7074 el.removeAttribute('data-previous-aria-hidden');
7075 } else {
7076 el.removeAttribute('aria-hidden');
7077 }
7078 });
7079 };
7080
7081 // @ts-ignore
7082 const isSafariOrIOS = typeof window !== 'undefined' && !!window.GestureEvent; // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
7083
7084 /**
7085 * Fix iOS scrolling
7086 * http://stackoverflow.com/q/39626302
7087 */
7088 const iOSfix = () => {
7089 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
7090 const offset = document.body.scrollTop;
7091 document.body.style.top = `${offset * -1}px`;
7092 addClass(document.body, swalClasses.iosfix);
7093 lockBodyScroll();
7094 }
7095 };
7096
7097 /**
7098 * https://github.com/sweetalert2/sweetalert2/issues/1246
7099 */
7100 const lockBodyScroll = () => {
7101 const container = getContainer();
7102 if (!container) {
7103 return;
7104 }
7105 /** @type {boolean} */
7106 let preventTouchMove;
7107 /**
7108 * @param {TouchEvent} event
7109 */
7110 container.ontouchstart = event => {
7111 preventTouchMove = shouldPreventTouchMove(event);
7112 };
7113 /**
7114 * @param {TouchEvent} event
7115 */
7116 container.ontouchmove = event => {
7117 if (preventTouchMove) {
7118 event.preventDefault();
7119 event.stopPropagation();
7120 }
7121 };
7122 };
7123
7124 /**
7125 * @param {TouchEvent} event
7126 * @returns {boolean}
7127 */
7128 const shouldPreventTouchMove = event => {
7129 const target = event.target;
7130 const container = getContainer();
7131 const htmlContainer = getHtmlContainer();
7132 if (!container || !htmlContainer) {
7133 return false;
7134 }
7135 if (isStylus(event) || isZoom(event)) {
7136 return false;
7137 }
7138 if (target === container) {
7139 return true;
7140 }
7141 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
7142 // #2823
7143 target.tagName !== 'INPUT' &&
7144 // #1603
7145 target.tagName !== 'TEXTAREA' &&
7146 // #2266
7147 !(isScrollable(htmlContainer) &&
7148 // #1944
7149 htmlContainer.contains(target))) {
7150 return true;
7151 }
7152 return false;
7153 };
7154
7155 /**
7156 * https://github.com/sweetalert2/sweetalert2/issues/1786
7157 *
7158 * @param {*} event
7159 * @returns {boolean}
7160 */
7161 const isStylus = event => {
7162 return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';
7163 };
7164
7165 /**
7166 * https://github.com/sweetalert2/sweetalert2/issues/1891
7167 *
7168 * @param {TouchEvent} event
7169 * @returns {boolean}
7170 */
7171 const isZoom = event => {
7172 return event.touches && event.touches.length > 1;
7173 };
7174 const undoIOSfix = () => {
7175 if (hasClass(document.body, swalClasses.iosfix)) {
7176 const offset = parseInt(document.body.style.top, 10);
7177 removeClass(document.body, swalClasses.iosfix);
7178 document.body.style.top = '';
7179 document.body.scrollTop = offset * -1;
7180 }
7181 };
7182
7183 /**
7184 * Measure scrollbar width for padding body during modal show/hide
7185 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
7186 *
7187 * @returns {number}
7188 */
7189 const measureScrollbar = () => {
7190 const scrollDiv = document.createElement('div');
7191 scrollDiv.className = swalClasses['scrollbar-measure'];
7192 document.body.appendChild(scrollDiv);
7193 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
7194 document.body.removeChild(scrollDiv);
7195 return scrollbarWidth;
7196 };
7197
7198 /**
7199 * Remember state in cases where opening and handling a modal will fiddle with it.
7200 * @type {number | null}
7201 */
7202 let previousBodyPadding = null;
7203
7204 /**
7205 * @param {string} initialBodyOverflow
7206 */
7207 const replaceScrollbarWithPadding = initialBodyOverflow => {
7208 // for queues, do not do this more than once
7209 if (previousBodyPadding !== null) {
7210 return;
7211 }
7212 // if the body has overflow
7213 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
7214 ) {
7215 // add padding so the content doesn't shift after removal of scrollbar
7216 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
7217 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
7218 }
7219 };
7220 const undoReplaceScrollbarWithPadding = () => {
7221 if (previousBodyPadding !== null) {
7222 document.body.style.paddingRight = `${previousBodyPadding}px`;
7223 previousBodyPadding = null;
7224 }
7225 };
7226
7227 /**
7228 * @param {SweetAlert} instance
7229 * @param {HTMLElement} container
7230 * @param {boolean} returnFocus
7231 * @param {Function} didClose
7232 */
7233 function removePopupAndResetState(instance, container, returnFocus, didClose) {
7234 if (isToast()) {
7235 triggerDidCloseAndDispose(instance, didClose);
7236 } else {
7237 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
7238 removeKeydownHandler(globalState);
7239 }
7240
7241 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
7242 // for some reason removing the container in Safari will scroll the document to bottom
7243 if (isSafariOrIOS) {
7244 container.setAttribute('style', 'display:none !important');
7245 container.removeAttribute('class');
7246 container.innerHTML = '';
7247 } else {
7248 container.remove();
7249 }
7250 if (isModal()) {
7251 undoReplaceScrollbarWithPadding();
7252 undoIOSfix();
7253 unsetAriaHidden();
7254 }
7255 removeBodyClasses();
7256 }
7257
7258 /**
7259 * Remove SweetAlert2 classes from body
7260 */
7261 function removeBodyClasses() {
7262 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
7263 }
7264
7265 /**
7266 * Instance method to close sweetAlert
7267 *
7268 * @param {any} resolveValue
7269 */
7270 function close(resolveValue) {
7271 resolveValue = prepareResolveValue(resolveValue);
7272 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
7273 const didClose = triggerClosePopup(this);
7274 if (this.isAwaitingPromise) {
7275 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
7276 if (!resolveValue.isDismissed) {
7277 handleAwaitingPromise(this);
7278 swalPromiseResolve(resolveValue);
7279 }
7280 } else if (didClose) {
7281 // Resolve Swal promise
7282 swalPromiseResolve(resolveValue);
7283 }
7284 }
7285 const triggerClosePopup = instance => {
7286 const popup = getPopup();
7287 if (!popup) {
7288 return false;
7289 }
7290 const innerParams = privateProps.innerParams.get(instance);
7291 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
7292 return false;
7293 }
7294 removeClass(popup, innerParams.showClass.popup);
7295 addClass(popup, innerParams.hideClass.popup);
7296 const backdrop = getContainer();
7297 removeClass(backdrop, innerParams.showClass.backdrop);
7298 addClass(backdrop, innerParams.hideClass.backdrop);
7299 handlePopupAnimation(instance, popup, innerParams);
7300 return true;
7301 };
7302
7303 /**
7304 * @param {any} error
7305 */
7306 function rejectPromise(error) {
7307 const rejectPromise = privateMethods.swalPromiseReject.get(this);
7308 handleAwaitingPromise(this);
7309 if (rejectPromise) {
7310 // Reject Swal promise
7311 rejectPromise(error);
7312 }
7313 }
7314
7315 /**
7316 * @param {SweetAlert} instance
7317 */
7318 const handleAwaitingPromise = instance => {
7319 if (instance.isAwaitingPromise) {
7320 delete instance.isAwaitingPromise;
7321 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
7322 if (!privateProps.innerParams.get(instance)) {
7323 instance._destroy();
7324 }
7325 }
7326 };
7327
7328 /**
7329 * @param {any} resolveValue
7330 * @returns {SweetAlertResult}
7331 */
7332 const prepareResolveValue = resolveValue => {
7333 // When user calls Swal.close()
7334 if (typeof resolveValue === 'undefined') {
7335 return {
7336 isConfirmed: false,
7337 isDenied: false,
7338 isDismissed: true
7339 };
7340 }
7341 return Object.assign({
7342 isConfirmed: false,
7343 isDenied: false,
7344 isDismissed: false
7345 }, resolveValue);
7346 };
7347
7348 /**
7349 * @param {SweetAlert} instance
7350 * @param {HTMLElement} popup
7351 * @param {SweetAlertOptions} innerParams
7352 */
7353 const handlePopupAnimation = (instance, popup, innerParams) => {
7354 var _globalState$eventEmi;
7355 const container = getContainer();
7356 // If animation is supported, animate
7357 const animationIsSupported = hasCssAnimation(popup);
7358 if (typeof innerParams.willClose === 'function') {
7359 innerParams.willClose(popup);
7360 }
7361 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
7362 if (animationIsSupported) {
7363 animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
7364 } else {
7365 // Otherwise, remove immediately
7366 removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
7367 }
7368 };
7369
7370 /**
7371 * @param {SweetAlert} instance
7372 * @param {HTMLElement} popup
7373 * @param {HTMLElement} container
7374 * @param {boolean} returnFocus
7375 * @param {Function} didClose
7376 */
7377 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
7378 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
7379 /**
7380 * @param {AnimationEvent | TransitionEvent} e
7381 */
7382 const swalCloseAnimationFinished = function (e) {
7383 if (e.target === popup) {
7384 var _globalState$swalClos;
7385 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
7386 delete globalState.swalCloseEventFinishedCallback;
7387 popup.removeEventListener('animationend', swalCloseAnimationFinished);
7388 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
7389 }
7390 };
7391 popup.addEventListener('animationend', swalCloseAnimationFinished);
7392 popup.addEventListener('transitionend', swalCloseAnimationFinished);
7393 };
7394
7395 /**
7396 * @param {SweetAlert} instance
7397 * @param {Function} didClose
7398 */
7399 const triggerDidCloseAndDispose = (instance, didClose) => {
7400 setTimeout(() => {
7401 var _globalState$eventEmi2;
7402 if (typeof didClose === 'function') {
7403 didClose.bind(instance.params)();
7404 }
7405 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
7406 // instance might have been destroyed already
7407 if (instance._destroy) {
7408 instance._destroy();
7409 }
7410 });
7411 };
7412
7413 /**
7414 * Shows loader (spinner), this is useful with AJAX requests.
7415 * By default the loader be shown instead of the "Confirm" button.
7416 *
7417 * @param {HTMLButtonElement | null} [buttonToReplace]
7418 */
7419 const showLoading = buttonToReplace => {
7420 let popup = getPopup();
7421 if (!popup) {
7422 new Swal();
7423 }
7424 popup = getPopup();
7425 if (!popup) {
7426 return;
7427 }
7428 const loader = getLoader();
7429 if (isToast()) {
7430 hide(getIcon());
7431 } else {
7432 replaceButton(popup, buttonToReplace);
7433 }
7434 show(loader);
7435 popup.setAttribute('data-loading', 'true');
7436 popup.setAttribute('aria-busy', 'true');
7437 popup.focus();
7438 };
7439
7440 /**
7441 * @param {HTMLElement} popup
7442 * @param {HTMLButtonElement | null} [buttonToReplace]
7443 */
7444 const replaceButton = (popup, buttonToReplace) => {
7445 const actions = getActions();
7446 const loader = getLoader();
7447 if (!actions || !loader) {
7448 return;
7449 }
7450 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
7451 buttonToReplace = getConfirmButton();
7452 }
7453 show(actions);
7454 if (buttonToReplace) {
7455 hide(buttonToReplace);
7456 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
7457 actions.insertBefore(loader, buttonToReplace);
7458 }
7459 addClass([popup, actions], swalClasses.loading);
7460 };
7461
7462 /**
7463 * @param {SweetAlert} instance
7464 * @param {SweetAlertOptions} params
7465 */
7466 const handleInputOptionsAndValue = (instance, params) => {
7467 if (params.input === 'select' || params.input === 'radio') {
7468 handleInputOptions(instance, params);
7469 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
7470 showLoading(getConfirmButton());
7471 handleInputValue(instance, params);
7472 }
7473 };
7474
7475 /**
7476 * @param {SweetAlert} instance
7477 * @param {SweetAlertOptions} innerParams
7478 * @returns {SweetAlertInputValue}
7479 */
7480 const getInputValue = (instance, innerParams) => {
7481 const input = instance.getInput();
7482 if (!input) {
7483 return null;
7484 }
7485 switch (innerParams.input) {
7486 case 'checkbox':
7487 return getCheckboxValue(input);
7488 case 'radio':
7489 return getRadioValue(input);
7490 case 'file':
7491 return getFileValue(input);
7492 default:
7493 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
7494 }
7495 };
7496
7497 /**
7498 * @param {HTMLInputElement} input
7499 * @returns {number}
7500 */
7501 const getCheckboxValue = input => input.checked ? 1 : 0;
7502
7503 /**
7504 * @param {HTMLInputElement} input
7505 * @returns {string | null}
7506 */
7507 const getRadioValue = input => input.checked ? input.value : null;
7508
7509 /**
7510 * @param {HTMLInputElement} input
7511 * @returns {FileList | File | null}
7512 */
7513 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
7514
7515 /**
7516 * @param {SweetAlert} instance
7517 * @param {SweetAlertOptions} params
7518 */
7519 const handleInputOptions = (instance, params) => {
7520 const popup = getPopup();
7521 if (!popup) {
7522 return;
7523 }
7524 /**
7525 * @param {Record<string, any>} inputOptions
7526 */
7527 const processInputOptions = inputOptions => {
7528 if (params.input === 'select') {
7529 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
7530 } else if (params.input === 'radio') {
7531 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
7532 }
7533 };
7534 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
7535 showLoading(getConfirmButton());
7536 asPromise(params.inputOptions).then(inputOptions => {
7537 instance.hideLoading();
7538 processInputOptions(inputOptions);
7539 });
7540 } else if (typeof params.inputOptions === 'object') {
7541 processInputOptions(params.inputOptions);
7542 } else {
7543 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
7544 }
7545 };
7546
7547 /**
7548 * @param {SweetAlert} instance
7549 * @param {SweetAlertOptions} params
7550 */
7551 const handleInputValue = (instance, params) => {
7552 const input = instance.getInput();
7553 if (!input) {
7554 return;
7555 }
7556 hide(input);
7557 asPromise(params.inputValue).then(inputValue => {
7558 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
7559 show(input);
7560 input.focus();
7561 instance.hideLoading();
7562 }).catch(err => {
7563 error(`Error in inputValue promise: ${err}`);
7564 input.value = '';
7565 show(input);
7566 input.focus();
7567 instance.hideLoading();
7568 });
7569 };
7570
7571 /**
7572 * @param {HTMLElement} popup
7573 * @param {InputOptionFlattened[]} inputOptions
7574 * @param {SweetAlertOptions} params
7575 */
7576 function populateSelectOptions(popup, inputOptions, params) {
7577 const select = getDirectChildByClass(popup, swalClasses.select);
7578 if (!select) {
7579 return;
7580 }
7581 /**
7582 * @param {HTMLElement} parent
7583 * @param {string} optionLabel
7584 * @param {string} optionValue
7585 */
7586 const renderOption = (parent, optionLabel, optionValue) => {
7587 const option = document.createElement('option');
7588 option.value = optionValue;
7589 setInnerHtml(option, optionLabel);
7590 option.selected = isSelected(optionValue, params.inputValue);
7591 parent.appendChild(option);
7592 };
7593 inputOptions.forEach(inputOption => {
7594 const optionValue = inputOption[0];
7595 const optionLabel = inputOption[1];
7596 // <optgroup> spec:
7597 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
7598 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
7599 // check whether this is a <optgroup>
7600 if (Array.isArray(optionLabel)) {
7601 // if it is an array, then it is an <optgroup>
7602 const optgroup = document.createElement('optgroup');
7603 optgroup.label = optionValue;
7604 optgroup.disabled = false; // not configurable for now
7605 select.appendChild(optgroup);
7606 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
7607 } else {
7608 // case of <option>
7609 renderOption(select, optionLabel, optionValue);
7610 }
7611 });
7612 select.focus();
7613 }
7614
7615 /**
7616 * @param {HTMLElement} popup
7617 * @param {InputOptionFlattened[]} inputOptions
7618 * @param {SweetAlertOptions} params
7619 */
7620 function populateRadioOptions(popup, inputOptions, params) {
7621 const radio = getDirectChildByClass(popup, swalClasses.radio);
7622 if (!radio) {
7623 return;
7624 }
7625 inputOptions.forEach(inputOption => {
7626 const radioValue = inputOption[0];
7627 const radioLabel = inputOption[1];
7628 const radioInput = document.createElement('input');
7629 const radioLabelElement = document.createElement('label');
7630 radioInput.type = 'radio';
7631 radioInput.name = swalClasses.radio;
7632 radioInput.value = radioValue;
7633 if (isSelected(radioValue, params.inputValue)) {
7634 radioInput.checked = true;
7635 }
7636 const label = document.createElement('span');
7637 setInnerHtml(label, radioLabel);
7638 label.className = swalClasses.label;
7639 radioLabelElement.appendChild(radioInput);
7640 radioLabelElement.appendChild(label);
7641 radio.appendChild(radioLabelElement);
7642 });
7643 const radios = radio.querySelectorAll('input');
7644 if (radios.length) {
7645 radios[0].focus();
7646 }
7647 }
7648
7649 /**
7650 * Converts `inputOptions` into an array of `[value, label]`s
7651 *
7652 * @param {Record<string, any>} inputOptions
7653 * @typedef {string[]} InputOptionFlattened
7654 * @returns {InputOptionFlattened[]}
7655 */
7656 const formatInputOptions = inputOptions => {
7657 /** @type {InputOptionFlattened[]} */
7658 const result = [];
7659 if (inputOptions instanceof Map) {
7660 inputOptions.forEach((value, key) => {
7661 let valueFormatted = value;
7662 if (typeof valueFormatted === 'object') {
7663 // case of <optgroup>
7664 valueFormatted = formatInputOptions(valueFormatted);
7665 }
7666 result.push([key, valueFormatted]);
7667 });
7668 } else {
7669 Object.keys(inputOptions).forEach(key => {
7670 let valueFormatted = inputOptions[key];
7671 if (typeof valueFormatted === 'object') {
7672 // case of <optgroup>
7673 valueFormatted = formatInputOptions(valueFormatted);
7674 }
7675 result.push([key, valueFormatted]);
7676 });
7677 }
7678 return result;
7679 };
7680
7681 /**
7682 * @param {string} optionValue
7683 * @param {SweetAlertInputValue} inputValue
7684 * @returns {boolean}
7685 */
7686 const isSelected = (optionValue, inputValue) => {
7687 return !!inputValue && inputValue.toString() === optionValue.toString();
7688 };
7689
7690 /**
7691 * @param {SweetAlert} instance
7692 */
7693 const handleConfirmButtonClick = instance => {
7694 const innerParams = privateProps.innerParams.get(instance);
7695 instance.disableButtons();
7696 if (innerParams.input) {
7697 handleConfirmOrDenyWithInput(instance, 'confirm');
7698 } else {
7699 confirm(instance, true);
7700 }
7701 };
7702
7703 /**
7704 * @param {SweetAlert} instance
7705 */
7706 const handleDenyButtonClick = instance => {
7707 const innerParams = privateProps.innerParams.get(instance);
7708 instance.disableButtons();
7709 if (innerParams.returnInputValueOnDeny) {
7710 handleConfirmOrDenyWithInput(instance, 'deny');
7711 } else {
7712 deny(instance, false);
7713 }
7714 };
7715
7716 /**
7717 * @param {SweetAlert} instance
7718 * @param {Function} dismissWith
7719 */
7720 const handleCancelButtonClick = (instance, dismissWith) => {
7721 instance.disableButtons();
7722 dismissWith(DismissReason.cancel);
7723 };
7724
7725 /**
7726 * @param {SweetAlert} instance
7727 * @param {'confirm' | 'deny'} type
7728 */
7729 const handleConfirmOrDenyWithInput = (instance, type) => {
7730 const innerParams = privateProps.innerParams.get(instance);
7731 if (!innerParams.input) {
7732 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
7733 return;
7734 }
7735 const input = instance.getInput();
7736 const inputValue = getInputValue(instance, innerParams);
7737 if (innerParams.inputValidator) {
7738 handleInputValidator(instance, inputValue, type);
7739 } else if (input && !input.checkValidity()) {
7740 instance.enableButtons();
7741 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
7742 } else if (type === 'deny') {
7743 deny(instance, inputValue);
7744 } else {
7745 confirm(instance, inputValue);
7746 }
7747 };
7748
7749 /**
7750 * @param {SweetAlert} instance
7751 * @param {SweetAlertInputValue} inputValue
7752 * @param {'confirm' | 'deny'} type
7753 */
7754 const handleInputValidator = (instance, inputValue, type) => {
7755 const innerParams = privateProps.innerParams.get(instance);
7756 instance.disableInput();
7757 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
7758 validationPromise.then(validationMessage => {
7759 instance.enableButtons();
7760 instance.enableInput();
7761 if (validationMessage) {
7762 instance.showValidationMessage(validationMessage);
7763 } else if (type === 'deny') {
7764 deny(instance, inputValue);
7765 } else {
7766 confirm(instance, inputValue);
7767 }
7768 });
7769 };
7770
7771 /**
7772 * @param {SweetAlert} instance
7773 * @param {any} value
7774 */
7775 const deny = (instance, value) => {
7776 const innerParams = privateProps.innerParams.get(instance || undefined);
7777 if (innerParams.showLoaderOnDeny) {
7778 showLoading(getDenyButton());
7779 }
7780 if (innerParams.preDeny) {
7781 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
7782 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
7783 preDenyPromise.then(preDenyValue => {
7784 if (preDenyValue === false) {
7785 instance.hideLoading();
7786 handleAwaitingPromise(instance);
7787 } else {
7788 instance.close({
7789 isDenied: true,
7790 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
7791 });
7792 }
7793 }).catch(error => rejectWith(instance || undefined, error));
7794 } else {
7795 instance.close({
7796 isDenied: true,
7797 value
7798 });
7799 }
7800 };
7801
7802 /**
7803 * @param {SweetAlert} instance
7804 * @param {any} value
7805 */
7806 const succeedWith = (instance, value) => {
7807 instance.close({
7808 isConfirmed: true,
7809 value
7810 });
7811 };
7812
7813 /**
7814 *
7815 * @param {SweetAlert} instance
7816 * @param {string} error
7817 */
7818 const rejectWith = (instance, error) => {
7819 instance.rejectPromise(error);
7820 };
7821
7822 /**
7823 *
7824 * @param {SweetAlert} instance
7825 * @param {any} value
7826 */
7827 const confirm = (instance, value) => {
7828 const innerParams = privateProps.innerParams.get(instance || undefined);
7829 if (innerParams.showLoaderOnConfirm) {
7830 showLoading();
7831 }
7832 if (innerParams.preConfirm) {
7833 instance.resetValidationMessage();
7834 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
7835 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
7836 preConfirmPromise.then(preConfirmValue => {
7837 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
7838 instance.hideLoading();
7839 handleAwaitingPromise(instance);
7840 } else {
7841 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
7842 }
7843 }).catch(error => rejectWith(instance || undefined, error));
7844 } else {
7845 succeedWith(instance, value);
7846 }
7847 };
7848
7849 /**
7850 * Hides loader and shows back the button which was hidden by .showLoading()
7851 */
7852 function hideLoading() {
7853 // do nothing if popup is closed
7854 const innerParams = privateProps.innerParams.get(this);
7855 if (!innerParams) {
7856 return;
7857 }
7858 const domCache = privateProps.domCache.get(this);
7859 hide(domCache.loader);
7860 if (isToast()) {
7861 if (innerParams.icon) {
7862 show(getIcon());
7863 }
7864 } else {
7865 showRelatedButton(domCache);
7866 }
7867 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
7868 domCache.popup.removeAttribute('aria-busy');
7869 domCache.popup.removeAttribute('data-loading');
7870 domCache.confirmButton.disabled = false;
7871 domCache.denyButton.disabled = false;
7872 domCache.cancelButton.disabled = false;
7873 }
7874 const showRelatedButton = domCache => {
7875 const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute('data-button-to-replace'));
7876 if (buttonToReplace.length) {
7877 show(buttonToReplace[0], 'inline-block');
7878 } else if (allButtonsAreHidden()) {
7879 hide(domCache.actions);
7880 }
7881 };
7882
7883 /**
7884 * Gets the input DOM node, this method works with input parameter.
7885 *
7886 * @returns {HTMLInputElement | null}
7887 */
7888 function getInput() {
7889 const innerParams = privateProps.innerParams.get(this);
7890 const domCache = privateProps.domCache.get(this);
7891 if (!domCache) {
7892 return null;
7893 }
7894 return getInput$1(domCache.popup, innerParams.input);
7895 }
7896
7897 /**
7898 * @param {SweetAlert} instance
7899 * @param {string[]} buttons
7900 * @param {boolean} disabled
7901 */
7902 function setButtonsDisabled(instance, buttons, disabled) {
7903 const domCache = privateProps.domCache.get(instance);
7904 buttons.forEach(button => {
7905 domCache[button].disabled = disabled;
7906 });
7907 }
7908
7909 /**
7910 * @param {HTMLInputElement | null} input
7911 * @param {boolean} disabled
7912 */
7913 function setInputDisabled(input, disabled) {
7914 const popup = getPopup();
7915 if (!popup || !input) {
7916 return;
7917 }
7918 if (input.type === 'radio') {
7919 /** @type {NodeListOf<HTMLInputElement>} */
7920 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
7921 for (let i = 0; i < radios.length; i++) {
7922 radios[i].disabled = disabled;
7923 }
7924 } else {
7925 input.disabled = disabled;
7926 }
7927 }
7928
7929 /**
7930 * Enable all the buttons
7931 * @this {SweetAlert}
7932 */
7933 function enableButtons() {
7934 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
7935 }
7936
7937 /**
7938 * Disable all the buttons
7939 * @this {SweetAlert}
7940 */
7941 function disableButtons() {
7942 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
7943 }
7944
7945 /**
7946 * Enable the input field
7947 * @this {SweetAlert}
7948 */
7949 function enableInput() {
7950 setInputDisabled(this.getInput(), false);
7951 }
7952
7953 /**
7954 * Disable the input field
7955 * @this {SweetAlert}
7956 */
7957 function disableInput() {
7958 setInputDisabled(this.getInput(), true);
7959 }
7960
7961 /**
7962 * Show block with validation message
7963 *
7964 * @param {string} error
7965 * @this {SweetAlert}
7966 */
7967 function showValidationMessage(error) {
7968 const domCache = privateProps.domCache.get(this);
7969 const params = privateProps.innerParams.get(this);
7970 setInnerHtml(domCache.validationMessage, error);
7971 domCache.validationMessage.className = swalClasses['validation-message'];
7972 if (params.customClass && params.customClass.validationMessage) {
7973 addClass(domCache.validationMessage, params.customClass.validationMessage);
7974 }
7975 show(domCache.validationMessage);
7976 const input = this.getInput();
7977 if (input) {
7978 input.setAttribute('aria-invalid', 'true');
7979 input.setAttribute('aria-describedby', swalClasses['validation-message']);
7980 focusInput(input);
7981 addClass(input, swalClasses.inputerror);
7982 }
7983 }
7984
7985 /**
7986 * Hide block with validation message
7987 *
7988 * @this {SweetAlert}
7989 */
7990 function resetValidationMessage() {
7991 const domCache = privateProps.domCache.get(this);
7992 if (domCache.validationMessage) {
7993 hide(domCache.validationMessage);
7994 }
7995 const input = this.getInput();
7996 if (input) {
7997 input.removeAttribute('aria-invalid');
7998 input.removeAttribute('aria-describedby');
7999 removeClass(input, swalClasses.inputerror);
8000 }
8001 }
8002
8003 const defaultParams = {
8004 title: '',
8005 titleText: '',
8006 text: '',
8007 html: '',
8008 footer: '',
8009 icon: undefined,
8010 iconColor: undefined,
8011 iconHtml: undefined,
8012 template: undefined,
8013 toast: false,
8014 draggable: false,
8015 animation: true,
8016 theme: 'light',
8017 showClass: {
8018 popup: 'swal2-show',
8019 backdrop: 'swal2-backdrop-show',
8020 icon: 'swal2-icon-show'
8021 },
8022 hideClass: {
8023 popup: 'swal2-hide',
8024 backdrop: 'swal2-backdrop-hide',
8025 icon: 'swal2-icon-hide'
8026 },
8027 customClass: {},
8028 target: 'body',
8029 color: undefined,
8030 backdrop: true,
8031 heightAuto: true,
8032 allowOutsideClick: true,
8033 allowEscapeKey: true,
8034 allowEnterKey: true,
8035 stopKeydownPropagation: true,
8036 keydownListenerCapture: false,
8037 showConfirmButton: true,
8038 showDenyButton: false,
8039 showCancelButton: false,
8040 preConfirm: undefined,
8041 preDeny: undefined,
8042 confirmButtonText: 'OK',
8043 confirmButtonAriaLabel: '',
8044 confirmButtonColor: undefined,
8045 denyButtonText: 'No',
8046 denyButtonAriaLabel: '',
8047 denyButtonColor: undefined,
8048 cancelButtonText: 'Cancel',
8049 cancelButtonAriaLabel: '',
8050 cancelButtonColor: undefined,
8051 buttonsStyling: true,
8052 reverseButtons: false,
8053 focusConfirm: true,
8054 focusDeny: false,
8055 focusCancel: false,
8056 returnFocus: true,
8057 showCloseButton: false,
8058 closeButtonHtml: '&times;',
8059 closeButtonAriaLabel: 'Close this dialog',
8060 loaderHtml: '',
8061 showLoaderOnConfirm: false,
8062 showLoaderOnDeny: false,
8063 imageUrl: undefined,
8064 imageWidth: undefined,
8065 imageHeight: undefined,
8066 imageAlt: '',
8067 timer: undefined,
8068 timerProgressBar: false,
8069 width: undefined,
8070 padding: undefined,
8071 background: undefined,
8072 input: undefined,
8073 inputPlaceholder: '',
8074 inputLabel: '',
8075 inputValue: '',
8076 inputOptions: {},
8077 inputAutoFocus: true,
8078 inputAutoTrim: true,
8079 inputAttributes: {},
8080 inputValidator: undefined,
8081 returnInputValueOnDeny: false,
8082 validationMessage: undefined,
8083 grow: false,
8084 position: 'center',
8085 progressSteps: [],
8086 currentProgressStep: undefined,
8087 progressStepsDistance: undefined,
8088 willOpen: undefined,
8089 didOpen: undefined,
8090 didRender: undefined,
8091 willClose: undefined,
8092 didClose: undefined,
8093 didDestroy: undefined,
8094 scrollbarPadding: true,
8095 topLayer: false
8096 };
8097 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'];
8098
8099 /** @type {Record<string, string | undefined>} */
8100 const deprecatedParams = {
8101 allowEnterKey: undefined
8102 };
8103 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
8104
8105 /**
8106 * Is valid parameter
8107 *
8108 * @param {string} paramName
8109 * @returns {boolean}
8110 */
8111 const isValidParameter = paramName => {
8112 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
8113 };
8114
8115 /**
8116 * Is valid parameter for Swal.update() method
8117 *
8118 * @param {string} paramName
8119 * @returns {boolean}
8120 */
8121 const isUpdatableParameter = paramName => {
8122 return updatableParams.indexOf(paramName) !== -1;
8123 };
8124
8125 /**
8126 * Is deprecated parameter
8127 *
8128 * @param {string} paramName
8129 * @returns {string | undefined}
8130 */
8131 const isDeprecatedParameter = paramName => {
8132 return deprecatedParams[paramName];
8133 };
8134
8135 /**
8136 * @param {string} param
8137 */
8138 const checkIfParamIsValid = param => {
8139 if (!isValidParameter(param)) {
8140 warn(`Unknown parameter "${param}"`);
8141 }
8142 };
8143
8144 /**
8145 * @param {string} param
8146 */
8147 const checkIfToastParamIsValid = param => {
8148 if (toastIncompatibleParams.includes(param)) {
8149 warn(`The parameter "${param}" is incompatible with toasts`);
8150 }
8151 };
8152
8153 /**
8154 * @param {string} param
8155 */
8156 const checkIfParamIsDeprecated = param => {
8157 const isDeprecated = isDeprecatedParameter(param);
8158 if (isDeprecated) {
8159 warnAboutDeprecation(param, isDeprecated);
8160 }
8161 };
8162
8163 /**
8164 * Show relevant warnings for given params
8165 *
8166 * @param {SweetAlertOptions} params
8167 */
8168 const showWarningsForParams = params => {
8169 if (params.backdrop === false && params.allowOutsideClick) {
8170 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
8171 }
8172 if (params.theme && !['light', 'dark', 'auto', 'minimal', 'borderless', 'embed-iframe', 'bulma', 'bulma-light', 'bulma-dark'].includes(params.theme)) {
8173 warn(`Invalid theme "${params.theme}"`);
8174 }
8175 for (const param in params) {
8176 checkIfParamIsValid(param);
8177 if (params.toast) {
8178 checkIfToastParamIsValid(param);
8179 }
8180 checkIfParamIsDeprecated(param);
8181 }
8182 };
8183
8184 /**
8185 * Updates popup parameters.
8186 *
8187 * @param {SweetAlertOptions} params
8188 */
8189 function update(params) {
8190 const container = getContainer();
8191 const popup = getPopup();
8192 const innerParams = privateProps.innerParams.get(this);
8193 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
8194 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.`);
8195 return;
8196 }
8197 const validUpdatableParams = filterValidParams(params);
8198 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
8199 showWarningsForParams(updatedParams);
8200 container.dataset['swal2Theme'] = updatedParams.theme;
8201 render(this, updatedParams);
8202 privateProps.innerParams.set(this, updatedParams);
8203 Object.defineProperties(this, {
8204 params: {
8205 value: Object.assign({}, this.params, params),
8206 writable: false,
8207 enumerable: true
8208 }
8209 });
8210 }
8211
8212 /**
8213 * @param {SweetAlertOptions} params
8214 * @returns {SweetAlertOptions}
8215 */
8216 const filterValidParams = params => {
8217 const validUpdatableParams = {};
8218 Object.keys(params).forEach(param => {
8219 if (isUpdatableParameter(param)) {
8220 validUpdatableParams[param] = params[param];
8221 } else {
8222 warn(`Invalid parameter to update: ${param}`);
8223 }
8224 });
8225 return validUpdatableParams;
8226 };
8227
8228 /**
8229 * Dispose the current SweetAlert2 instance
8230 */
8231 function _destroy() {
8232 const domCache = privateProps.domCache.get(this);
8233 const innerParams = privateProps.innerParams.get(this);
8234 if (!innerParams) {
8235 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
8236 return; // This instance has already been destroyed
8237 }
8238
8239 // Check if there is another Swal closing
8240 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
8241 globalState.swalCloseEventFinishedCallback();
8242 delete globalState.swalCloseEventFinishedCallback;
8243 }
8244 if (typeof innerParams.didDestroy === 'function') {
8245 innerParams.didDestroy();
8246 }
8247 globalState.eventEmitter.emit('didDestroy');
8248 disposeSwal(this);
8249 }
8250
8251 /**
8252 * @param {SweetAlert} instance
8253 */
8254 const disposeSwal = instance => {
8255 disposeWeakMaps(instance);
8256 // Unset this.params so GC will dispose it (#1569)
8257 delete instance.params;
8258 // Unset globalState props so GC will dispose globalState (#1569)
8259 delete globalState.keydownHandler;
8260 delete globalState.keydownTarget;
8261 // Unset currentInstance
8262 delete globalState.currentInstance;
8263 };
8264
8265 /**
8266 * @param {SweetAlert} instance
8267 */
8268 const disposeWeakMaps = instance => {
8269 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
8270 if (instance.isAwaitingPromise) {
8271 unsetWeakMaps(privateProps, instance);
8272 instance.isAwaitingPromise = true;
8273 } else {
8274 unsetWeakMaps(privateMethods, instance);
8275 unsetWeakMaps(privateProps, instance);
8276 delete instance.isAwaitingPromise;
8277 // Unset instance methods
8278 delete instance.disableButtons;
8279 delete instance.enableButtons;
8280 delete instance.getInput;
8281 delete instance.disableInput;
8282 delete instance.enableInput;
8283 delete instance.hideLoading;
8284 delete instance.disableLoading;
8285 delete instance.showValidationMessage;
8286 delete instance.resetValidationMessage;
8287 delete instance.close;
8288 delete instance.closePopup;
8289 delete instance.closeModal;
8290 delete instance.closeToast;
8291 delete instance.rejectPromise;
8292 delete instance.update;
8293 delete instance._destroy;
8294 }
8295 };
8296
8297 /**
8298 * @param {object} obj
8299 * @param {SweetAlert} instance
8300 */
8301 const unsetWeakMaps = (obj, instance) => {
8302 for (const i in obj) {
8303 obj[i].delete(instance);
8304 }
8305 };
8306
8307 var instanceMethods = /*#__PURE__*/Object.freeze({
8308 __proto__: null,
8309 _destroy: _destroy,
8310 close: close,
8311 closeModal: close,
8312 closePopup: close,
8313 closeToast: close,
8314 disableButtons: disableButtons,
8315 disableInput: disableInput,
8316 disableLoading: hideLoading,
8317 enableButtons: enableButtons,
8318 enableInput: enableInput,
8319 getInput: getInput,
8320 handleAwaitingPromise: handleAwaitingPromise,
8321 hideLoading: hideLoading,
8322 rejectPromise: rejectPromise,
8323 resetValidationMessage: resetValidationMessage,
8324 showValidationMessage: showValidationMessage,
8325 update: update
8326 });
8327
8328 /**
8329 * @param {SweetAlertOptions} innerParams
8330 * @param {DomCache} domCache
8331 * @param {Function} dismissWith
8332 */
8333 const handlePopupClick = (innerParams, domCache, dismissWith) => {
8334 if (innerParams.toast) {
8335 handleToastClick(innerParams, domCache, dismissWith);
8336 } else {
8337 // Ignore click events that had mousedown on the popup but mouseup on the container
8338 // This can happen when the user drags a slider
8339 handleModalMousedown(domCache);
8340
8341 // Ignore click events that had mousedown on the container but mouseup on the popup
8342 handleContainerMousedown(domCache);
8343 handleModalClick(innerParams, domCache, dismissWith);
8344 }
8345 };
8346
8347 /**
8348 * @param {SweetAlertOptions} innerParams
8349 * @param {DomCache} domCache
8350 * @param {Function} dismissWith
8351 */
8352 const handleToastClick = (innerParams, domCache, dismissWith) => {
8353 // Closing toast by internal click
8354 domCache.popup.onclick = () => {
8355 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
8356 return;
8357 }
8358 dismissWith(DismissReason.close);
8359 };
8360 };
8361
8362 /**
8363 * @param {SweetAlertOptions} innerParams
8364 * @returns {boolean}
8365 */
8366 const isAnyButtonShown = innerParams => {
8367 return !!(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
8368 };
8369 let ignoreOutsideClick = false;
8370
8371 /**
8372 * @param {DomCache} domCache
8373 */
8374 const handleModalMousedown = domCache => {
8375 domCache.popup.onmousedown = () => {
8376 domCache.container.onmouseup = function (e) {
8377 domCache.container.onmouseup = () => {};
8378 // We only check if the mouseup target is the container because usually it doesn't
8379 // have any other direct children aside of the popup
8380 if (e.target === domCache.container) {
8381 ignoreOutsideClick = true;
8382 }
8383 };
8384 };
8385 };
8386
8387 /**
8388 * @param {DomCache} domCache
8389 */
8390 const handleContainerMousedown = domCache => {
8391 domCache.container.onmousedown = e => {
8392 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
8393 if (e.target === domCache.container) {
8394 e.preventDefault();
8395 }
8396 domCache.popup.onmouseup = function (e) {
8397 domCache.popup.onmouseup = () => {};
8398 // We also need to check if the mouseup target is a child of the popup
8399 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
8400 ignoreOutsideClick = true;
8401 }
8402 };
8403 };
8404 };
8405
8406 /**
8407 * @param {SweetAlertOptions} innerParams
8408 * @param {DomCache} domCache
8409 * @param {Function} dismissWith
8410 */
8411 const handleModalClick = (innerParams, domCache, dismissWith) => {
8412 domCache.container.onclick = e => {
8413 if (ignoreOutsideClick) {
8414 ignoreOutsideClick = false;
8415 return;
8416 }
8417 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
8418 dismissWith(DismissReason.backdrop);
8419 }
8420 };
8421 };
8422
8423 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
8424 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
8425 const argsToParams = args => {
8426 const params = {};
8427 if (typeof args[0] === 'object' && !isElement(args[0])) {
8428 Object.assign(params, args[0]);
8429 } else {
8430 ['title', 'html', 'icon'].forEach((name, index) => {
8431 const arg = args[index];
8432 if (typeof arg === 'string' || isElement(arg)) {
8433 params[name] = arg;
8434 } else if (arg !== undefined) {
8435 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
8436 }
8437 });
8438 }
8439 return params;
8440 };
8441
8442 /**
8443 * Main method to create a new SweetAlert2 popup
8444 *
8445 * @param {...SweetAlertOptions} args
8446 * @returns {Promise<SweetAlertResult>}
8447 */
8448 function fire(...args) {
8449 return new this(...args);
8450 }
8451
8452 /**
8453 * Returns an extended version of `Swal` containing `params` as defaults.
8454 * Useful for reusing Swal configuration.
8455 *
8456 * For example:
8457 *
8458 * Before:
8459 * const textPromptOptions = { input: 'text', showCancelButton: true }
8460 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
8461 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
8462 *
8463 * After:
8464 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
8465 * const {value: firstName} = await TextPrompt('What is your first name?')
8466 * const {value: lastName} = await TextPrompt('What is your last name?')
8467 *
8468 * @param {SweetAlertOptions} mixinParams
8469 * @returns {SweetAlert}
8470 */
8471 function mixin(mixinParams) {
8472 class MixinSwal extends this {
8473 _main(params, priorityMixinParams) {
8474 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
8475 }
8476 }
8477 // @ts-ignore
8478 return MixinSwal;
8479 }
8480
8481 /**
8482 * If `timer` parameter is set, returns number of milliseconds of timer remained.
8483 * Otherwise, returns undefined.
8484 *
8485 * @returns {number | undefined}
8486 */
8487 const getTimerLeft = () => {
8488 return globalState.timeout && globalState.timeout.getTimerLeft();
8489 };
8490
8491 /**
8492 * Stop timer. Returns number of milliseconds of timer remained.
8493 * If `timer` parameter isn't set, returns undefined.
8494 *
8495 * @returns {number | undefined}
8496 */
8497 const stopTimer = () => {
8498 if (globalState.timeout) {
8499 stopTimerProgressBar();
8500 return globalState.timeout.stop();
8501 }
8502 };
8503
8504 /**
8505 * Resume timer. Returns number of milliseconds of timer remained.
8506 * If `timer` parameter isn't set, returns undefined.
8507 *
8508 * @returns {number | undefined}
8509 */
8510 const resumeTimer = () => {
8511 if (globalState.timeout) {
8512 const remaining = globalState.timeout.start();
8513 animateTimerProgressBar(remaining);
8514 return remaining;
8515 }
8516 };
8517
8518 /**
8519 * Resume timer. Returns number of milliseconds of timer remained.
8520 * If `timer` parameter isn't set, returns undefined.
8521 *
8522 * @returns {number | undefined}
8523 */
8524 const toggleTimer = () => {
8525 const timer = globalState.timeout;
8526 return timer && (timer.running ? stopTimer() : resumeTimer());
8527 };
8528
8529 /**
8530 * Increase timer. Returns number of milliseconds of an updated timer.
8531 * If `timer` parameter isn't set, returns undefined.
8532 *
8533 * @param {number} ms
8534 * @returns {number | undefined}
8535 */
8536 const increaseTimer = ms => {
8537 if (globalState.timeout) {
8538 const remaining = globalState.timeout.increase(ms);
8539 animateTimerProgressBar(remaining, true);
8540 return remaining;
8541 }
8542 };
8543
8544 /**
8545 * Check if timer is running. Returns true if timer is running
8546 * or false if timer is paused or stopped.
8547 * If `timer` parameter isn't set, returns undefined
8548 *
8549 * @returns {boolean}
8550 */
8551 const isTimerRunning = () => {
8552 return !!(globalState.timeout && globalState.timeout.isRunning());
8553 };
8554
8555 let bodyClickListenerAdded = false;
8556 const clickHandlers = {};
8557
8558 /**
8559 * @param {string} attr
8560 */
8561 function bindClickHandler(attr = 'data-swal-template') {
8562 clickHandlers[attr] = this;
8563 if (!bodyClickListenerAdded) {
8564 document.body.addEventListener('click', bodyClickListener);
8565 bodyClickListenerAdded = true;
8566 }
8567 }
8568 const bodyClickListener = event => {
8569 for (let el = event.target; el && el !== document; el = el.parentNode) {
8570 for (const attr in clickHandlers) {
8571 const template = el.getAttribute(attr);
8572 if (template) {
8573 clickHandlers[attr].fire({
8574 template
8575 });
8576 return;
8577 }
8578 }
8579 }
8580 };
8581
8582 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
8583
8584 class EventEmitter {
8585 constructor() {
8586 /** @type {Events} */
8587 this.events = {};
8588 }
8589
8590 /**
8591 * @param {string} eventName
8592 * @returns {EventHandlers}
8593 */
8594 _getHandlersByEventName(eventName) {
8595 if (typeof this.events[eventName] === 'undefined') {
8596 // not Set because we need to keep the FIFO order
8597 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
8598 this.events[eventName] = [];
8599 }
8600 return this.events[eventName];
8601 }
8602
8603 /**
8604 * @param {string} eventName
8605 * @param {EventHandler} eventHandler
8606 */
8607 on(eventName, eventHandler) {
8608 const currentHandlers = this._getHandlersByEventName(eventName);
8609 if (!currentHandlers.includes(eventHandler)) {
8610 currentHandlers.push(eventHandler);
8611 }
8612 }
8613
8614 /**
8615 * @param {string} eventName
8616 * @param {EventHandler} eventHandler
8617 */
8618 once(eventName, eventHandler) {
8619 /**
8620 * @param {Array} args
8621 */
8622 const onceFn = (...args) => {
8623 this.removeListener(eventName, onceFn);
8624 eventHandler.apply(this, args);
8625 };
8626 this.on(eventName, onceFn);
8627 }
8628
8629 /**
8630 * @param {string} eventName
8631 * @param {Array} args
8632 */
8633 emit(eventName, ...args) {
8634 this._getHandlersByEventName(eventName).forEach(
8635 /**
8636 * @param {EventHandler} eventHandler
8637 */
8638 eventHandler => {
8639 try {
8640 eventHandler.apply(this, args);
8641 } catch (error) {
8642 console.error(error);
8643 }
8644 });
8645 }
8646
8647 /**
8648 * @param {string} eventName
8649 * @param {EventHandler} eventHandler
8650 */
8651 removeListener(eventName, eventHandler) {
8652 const currentHandlers = this._getHandlersByEventName(eventName);
8653 const index = currentHandlers.indexOf(eventHandler);
8654 if (index > -1) {
8655 currentHandlers.splice(index, 1);
8656 }
8657 }
8658
8659 /**
8660 * @param {string} eventName
8661 */
8662 removeAllListeners(eventName) {
8663 if (this.events[eventName] !== undefined) {
8664 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
8665 this.events[eventName].length = 0;
8666 }
8667 }
8668 reset() {
8669 this.events = {};
8670 }
8671 }
8672
8673 globalState.eventEmitter = new EventEmitter();
8674
8675 /**
8676 * @param {string} eventName
8677 * @param {EventHandler} eventHandler
8678 */
8679 const on = (eventName, eventHandler) => {
8680 globalState.eventEmitter.on(eventName, eventHandler);
8681 };
8682
8683 /**
8684 * @param {string} eventName
8685 * @param {EventHandler} eventHandler
8686 */
8687 const once = (eventName, eventHandler) => {
8688 globalState.eventEmitter.once(eventName, eventHandler);
8689 };
8690
8691 /**
8692 * @param {string} [eventName]
8693 * @param {EventHandler} [eventHandler]
8694 */
8695 const off = (eventName, eventHandler) => {
8696 // Remove all handlers for all events
8697 if (!eventName) {
8698 globalState.eventEmitter.reset();
8699 return;
8700 }
8701 if (eventHandler) {
8702 // Remove a specific handler
8703 globalState.eventEmitter.removeListener(eventName, eventHandler);
8704 } else {
8705 // Remove all handlers for a specific event
8706 globalState.eventEmitter.removeAllListeners(eventName);
8707 }
8708 };
8709
8710 var staticMethods = /*#__PURE__*/Object.freeze({
8711 __proto__: null,
8712 argsToParams: argsToParams,
8713 bindClickHandler: bindClickHandler,
8714 clickCancel: clickCancel,
8715 clickConfirm: clickConfirm,
8716 clickDeny: clickDeny,
8717 enableLoading: showLoading,
8718 fire: fire,
8719 getActions: getActions,
8720 getCancelButton: getCancelButton,
8721 getCloseButton: getCloseButton,
8722 getConfirmButton: getConfirmButton,
8723 getContainer: getContainer,
8724 getDenyButton: getDenyButton,
8725 getFocusableElements: getFocusableElements,
8726 getFooter: getFooter,
8727 getHtmlContainer: getHtmlContainer,
8728 getIcon: getIcon,
8729 getIconContent: getIconContent,
8730 getImage: getImage,
8731 getInputLabel: getInputLabel,
8732 getLoader: getLoader,
8733 getPopup: getPopup,
8734 getProgressSteps: getProgressSteps,
8735 getTimerLeft: getTimerLeft,
8736 getTimerProgressBar: getTimerProgressBar,
8737 getTitle: getTitle,
8738 getValidationMessage: getValidationMessage,
8739 increaseTimer: increaseTimer,
8740 isDeprecatedParameter: isDeprecatedParameter,
8741 isLoading: isLoading,
8742 isTimerRunning: isTimerRunning,
8743 isUpdatableParameter: isUpdatableParameter,
8744 isValidParameter: isValidParameter,
8745 isVisible: isVisible,
8746 mixin: mixin,
8747 off: off,
8748 on: on,
8749 once: once,
8750 resumeTimer: resumeTimer,
8751 showLoading: showLoading,
8752 stopTimer: stopTimer,
8753 toggleTimer: toggleTimer
8754 });
8755
8756 class Timer {
8757 /**
8758 * @param {Function} callback
8759 * @param {number} delay
8760 */
8761 constructor(callback, delay) {
8762 this.callback = callback;
8763 this.remaining = delay;
8764 this.running = false;
8765 this.start();
8766 }
8767
8768 /**
8769 * @returns {number}
8770 */
8771 start() {
8772 if (!this.running) {
8773 this.running = true;
8774 this.started = new Date();
8775 this.id = setTimeout(this.callback, this.remaining);
8776 }
8777 return this.remaining;
8778 }
8779
8780 /**
8781 * @returns {number}
8782 */
8783 stop() {
8784 if (this.started && this.running) {
8785 this.running = false;
8786 clearTimeout(this.id);
8787 this.remaining -= new Date().getTime() - this.started.getTime();
8788 }
8789 return this.remaining;
8790 }
8791
8792 /**
8793 * @param {number} n
8794 * @returns {number}
8795 */
8796 increase(n) {
8797 const running = this.running;
8798 if (running) {
8799 this.stop();
8800 }
8801 this.remaining += n;
8802 if (running) {
8803 this.start();
8804 }
8805 return this.remaining;
8806 }
8807
8808 /**
8809 * @returns {number}
8810 */
8811 getTimerLeft() {
8812 if (this.running) {
8813 this.stop();
8814 this.start();
8815 }
8816 return this.remaining;
8817 }
8818
8819 /**
8820 * @returns {boolean}
8821 */
8822 isRunning() {
8823 return this.running;
8824 }
8825 }
8826
8827 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
8828
8829 /**
8830 * @param {SweetAlertOptions} params
8831 * @returns {SweetAlertOptions}
8832 */
8833 const getTemplateParams = params => {
8834 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
8835 if (!template) {
8836 return {};
8837 }
8838 /** @type {DocumentFragment} */
8839 const templateContent = template.content;
8840 showWarningsForElements(templateContent);
8841 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
8842 return result;
8843 };
8844
8845 /**
8846 * @param {DocumentFragment} templateContent
8847 * @returns {Record<string, any>}
8848 */
8849 const getSwalParams = templateContent => {
8850 /** @type {Record<string, any>} */
8851 const result = {};
8852 /** @type {HTMLElement[]} */
8853 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
8854 swalParams.forEach(param => {
8855 showWarningsForAttributes(param, ['name', 'value']);
8856 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
8857 const value = param.getAttribute('value');
8858 if (!paramName || !value) {
8859 return;
8860 }
8861 if (typeof defaultParams[paramName] === 'boolean') {
8862 result[paramName] = value !== 'false';
8863 } else if (typeof defaultParams[paramName] === 'object') {
8864 result[paramName] = JSON.parse(value);
8865 } else {
8866 result[paramName] = value;
8867 }
8868 });
8869 return result;
8870 };
8871
8872 /**
8873 * @param {DocumentFragment} templateContent
8874 * @returns {Record<string, any>}
8875 */
8876 const getSwalFunctionParams = templateContent => {
8877 /** @type {Record<string, any>} */
8878 const result = {};
8879 /** @type {HTMLElement[]} */
8880 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
8881 swalFunctions.forEach(param => {
8882 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
8883 const value = param.getAttribute('value');
8884 if (!paramName || !value) {
8885 return;
8886 }
8887 result[paramName] = new Function(`return ${value}`)();
8888 });
8889 return result;
8890 };
8891
8892 /**
8893 * @param {DocumentFragment} templateContent
8894 * @returns {Record<string, any>}
8895 */
8896 const getSwalButtons = templateContent => {
8897 /** @type {Record<string, any>} */
8898 const result = {};
8899 /** @type {HTMLElement[]} */
8900 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
8901 swalButtons.forEach(button => {
8902 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
8903 const type = button.getAttribute('type');
8904 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
8905 return;
8906 }
8907 result[`${type}ButtonText`] = button.innerHTML;
8908 result[`show${capitalizeFirstLetter(type)}Button`] = true;
8909 if (button.hasAttribute('color')) {
8910 result[`${type}ButtonColor`] = button.getAttribute('color');
8911 }
8912 if (button.hasAttribute('aria-label')) {
8913 result[`${type}ButtonAriaLabel`] = button.getAttribute('aria-label');
8914 }
8915 });
8916 return result;
8917 };
8918
8919 /**
8920 * @param {DocumentFragment} templateContent
8921 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
8922 */
8923 const getSwalImage = templateContent => {
8924 const result = {};
8925 /** @type {HTMLElement | null} */
8926 const image = templateContent.querySelector('swal-image');
8927 if (image) {
8928 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
8929 if (image.hasAttribute('src')) {
8930 result.imageUrl = image.getAttribute('src') || undefined;
8931 }
8932 if (image.hasAttribute('width')) {
8933 result.imageWidth = image.getAttribute('width') || undefined;
8934 }
8935 if (image.hasAttribute('height')) {
8936 result.imageHeight = image.getAttribute('height') || undefined;
8937 }
8938 if (image.hasAttribute('alt')) {
8939 result.imageAlt = image.getAttribute('alt') || undefined;
8940 }
8941 }
8942 return result;
8943 };
8944
8945 /**
8946 * @param {DocumentFragment} templateContent
8947 * @returns {Record<string, any>}
8948 */
8949 const getSwalIcon = templateContent => {
8950 const result = {};
8951 /** @type {HTMLElement | null} */
8952 const icon = templateContent.querySelector('swal-icon');
8953 if (icon) {
8954 showWarningsForAttributes(icon, ['type', 'color']);
8955 if (icon.hasAttribute('type')) {
8956 result.icon = icon.getAttribute('type');
8957 }
8958 if (icon.hasAttribute('color')) {
8959 result.iconColor = icon.getAttribute('color');
8960 }
8961 result.iconHtml = icon.innerHTML;
8962 }
8963 return result;
8964 };
8965
8966 /**
8967 * @param {DocumentFragment} templateContent
8968 * @returns {Record<string, any>}
8969 */
8970 const getSwalInput = templateContent => {
8971 /** @type {Record<string, any>} */
8972 const result = {};
8973 /** @type {HTMLElement | null} */
8974 const input = templateContent.querySelector('swal-input');
8975 if (input) {
8976 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
8977 result.input = input.getAttribute('type') || 'text';
8978 if (input.hasAttribute('label')) {
8979 result.inputLabel = input.getAttribute('label');
8980 }
8981 if (input.hasAttribute('placeholder')) {
8982 result.inputPlaceholder = input.getAttribute('placeholder');
8983 }
8984 if (input.hasAttribute('value')) {
8985 result.inputValue = input.getAttribute('value');
8986 }
8987 }
8988 /** @type {HTMLElement[]} */
8989 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
8990 if (inputOptions.length) {
8991 result.inputOptions = {};
8992 inputOptions.forEach(option => {
8993 showWarningsForAttributes(option, ['value']);
8994 const optionValue = option.getAttribute('value');
8995 if (!optionValue) {
8996 return;
8997 }
8998 const optionName = option.innerHTML;
8999 result.inputOptions[optionValue] = optionName;
9000 });
9001 }
9002 return result;
9003 };
9004
9005 /**
9006 * @param {DocumentFragment} templateContent
9007 * @param {string[]} paramNames
9008 * @returns {Record<string, any>}
9009 */
9010 const getSwalStringParams = (templateContent, paramNames) => {
9011 /** @type {Record<string, any>} */
9012 const result = {};
9013 for (const i in paramNames) {
9014 const paramName = paramNames[i];
9015 /** @type {HTMLElement | null} */
9016 const tag = templateContent.querySelector(paramName);
9017 if (tag) {
9018 showWarningsForAttributes(tag, []);
9019 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
9020 }
9021 }
9022 return result;
9023 };
9024
9025 /**
9026 * @param {DocumentFragment} templateContent
9027 */
9028 const showWarningsForElements = templateContent => {
9029 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
9030 Array.from(templateContent.children).forEach(el => {
9031 const tagName = el.tagName.toLowerCase();
9032 if (!allowedElements.includes(tagName)) {
9033 warn(`Unrecognized element <${tagName}>`);
9034 }
9035 });
9036 };
9037
9038 /**
9039 * @param {HTMLElement} el
9040 * @param {string[]} allowedAttributes
9041 */
9042 const showWarningsForAttributes = (el, allowedAttributes) => {
9043 Array.from(el.attributes).forEach(attribute => {
9044 if (allowedAttributes.indexOf(attribute.name) === -1) {
9045 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.'}`]);
9046 }
9047 });
9048 };
9049
9050 const SHOW_CLASS_TIMEOUT = 10;
9051
9052 /**
9053 * Open popup, add necessary classes and styles, fix scrollbar
9054 *
9055 * @param {SweetAlertOptions} params
9056 */
9057 const openPopup = params => {
9058 const container = getContainer();
9059 const popup = getPopup();
9060 if (typeof params.willOpen === 'function') {
9061 params.willOpen(popup);
9062 }
9063 globalState.eventEmitter.emit('willOpen', popup);
9064 const bodyStyles = window.getComputedStyle(document.body);
9065 const initialBodyOverflow = bodyStyles.overflowY;
9066 addClasses(container, popup, params);
9067
9068 // scrolling is 'hidden' until animation is done, after that 'auto'
9069 setTimeout(() => {
9070 setScrollingVisibility(container, popup);
9071 }, SHOW_CLASS_TIMEOUT);
9072 if (isModal()) {
9073 fixScrollContainer(container, params.scrollbarPadding, initialBodyOverflow);
9074 setAriaHidden();
9075 }
9076 if (!isToast() && !globalState.previousActiveElement) {
9077 globalState.previousActiveElement = document.activeElement;
9078 }
9079 if (typeof params.didOpen === 'function') {
9080 setTimeout(() => params.didOpen(popup));
9081 }
9082 globalState.eventEmitter.emit('didOpen', popup);
9083 removeClass(container, swalClasses['no-transition']);
9084 };
9085
9086 /**
9087 * @param {AnimationEvent} event
9088 */
9089 const swalOpenAnimationFinished = event => {
9090 const popup = getPopup();
9091 if (event.target !== popup) {
9092 return;
9093 }
9094 const container = getContainer();
9095 popup.removeEventListener('animationend', swalOpenAnimationFinished);
9096 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
9097 container.style.overflowY = 'auto';
9098 };
9099
9100 /**
9101 * @param {HTMLElement} container
9102 * @param {HTMLElement} popup
9103 */
9104 const setScrollingVisibility = (container, popup) => {
9105 if (hasCssAnimation(popup)) {
9106 container.style.overflowY = 'hidden';
9107 popup.addEventListener('animationend', swalOpenAnimationFinished);
9108 popup.addEventListener('transitionend', swalOpenAnimationFinished);
9109 } else {
9110 container.style.overflowY = 'auto';
9111 }
9112 };
9113
9114 /**
9115 * @param {HTMLElement} container
9116 * @param {boolean} scrollbarPadding
9117 * @param {string} initialBodyOverflow
9118 */
9119 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
9120 iOSfix();
9121 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
9122 replaceScrollbarWithPadding(initialBodyOverflow);
9123 }
9124
9125 // sweetalert2/issues/1247
9126 setTimeout(() => {
9127 container.scrollTop = 0;
9128 });
9129 };
9130
9131 /**
9132 * @param {HTMLElement} container
9133 * @param {HTMLElement} popup
9134 * @param {SweetAlertOptions} params
9135 */
9136 const addClasses = (container, popup, params) => {
9137 addClass(container, params.showClass.backdrop);
9138 if (params.animation) {
9139 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
9140 popup.style.setProperty('opacity', '0', 'important');
9141 show(popup, 'grid');
9142 setTimeout(() => {
9143 // Animate popup right after showing it
9144 addClass(popup, params.showClass.popup);
9145 // and remove the opacity workaround
9146 popup.style.removeProperty('opacity');
9147 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
9148 } else {
9149 show(popup, 'grid');
9150 }
9151 addClass([document.documentElement, document.body], swalClasses.shown);
9152 if (params.heightAuto && params.backdrop && !params.toast) {
9153 addClass([document.documentElement, document.body], swalClasses['height-auto']);
9154 }
9155 };
9156
9157 var defaultInputValidators = {
9158 /**
9159 * @param {string} string
9160 * @param {string} [validationMessage]
9161 * @returns {Promise<string | void>}
9162 */
9163 email: (string, validationMessage) => {
9164 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
9165 },
9166 /**
9167 * @param {string} string
9168 * @param {string} [validationMessage]
9169 * @returns {Promise<string | void>}
9170 */
9171 url: (string, validationMessage) => {
9172 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
9173 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');
9174 }
9175 };
9176
9177 /**
9178 * @param {SweetAlertOptions} params
9179 */
9180 function setDefaultInputValidators(params) {
9181 // Use default `inputValidator` for supported input types if not provided
9182 if (params.inputValidator) {
9183 return;
9184 }
9185 if (params.input === 'email') {
9186 params.inputValidator = defaultInputValidators['email'];
9187 }
9188 if (params.input === 'url') {
9189 params.inputValidator = defaultInputValidators['url'];
9190 }
9191 }
9192
9193 /**
9194 * @param {SweetAlertOptions} params
9195 */
9196 function validateCustomTargetElement(params) {
9197 // Determine if the custom target element is valid
9198 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
9199 warn('Target parameter is not valid, defaulting to "body"');
9200 params.target = 'body';
9201 }
9202 }
9203
9204 /**
9205 * Set type, text and actions on popup
9206 *
9207 * @param {SweetAlertOptions} params
9208 */
9209 function setParameters(params) {
9210 setDefaultInputValidators(params);
9211
9212 // showLoaderOnConfirm && preConfirm
9213 if (params.showLoaderOnConfirm && !params.preConfirm) {
9214 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');
9215 }
9216 validateCustomTargetElement(params);
9217
9218 // Replace newlines with <br> in title
9219 if (typeof params.title === 'string') {
9220 params.title = params.title.split('\n').join('<br />');
9221 }
9222 init(params);
9223 }
9224
9225 /** @type {SweetAlert} */
9226 let currentInstance;
9227 var _promise = /*#__PURE__*/new WeakMap();
9228 class SweetAlert {
9229 /**
9230 * @param {...any} args
9231 * @this {SweetAlert}
9232 */
9233 constructor(...args) {
9234 /**
9235 * @type {Promise<SweetAlertResult>}
9236 */
9237 _classPrivateFieldInitSpec(this, _promise, void 0);
9238 // Prevent run in Node env
9239 if (typeof window === 'undefined') {
9240 return;
9241 }
9242 currentInstance = this;
9243
9244 // @ts-ignore
9245 const outerParams = Object.freeze(this.constructor.argsToParams(args));
9246
9247 /** @type {Readonly<SweetAlertOptions>} */
9248 this.params = outerParams;
9249
9250 /** @type {boolean} */
9251 this.isAwaitingPromise = false;
9252 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
9253 }
9254 _main(userParams, mixinParams = {}) {
9255 showWarningsForParams(Object.assign({}, mixinParams, userParams));
9256 if (globalState.currentInstance) {
9257 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
9258 const {
9259 isAwaitingPromise
9260 } = globalState.currentInstance;
9261 globalState.currentInstance._destroy();
9262 if (!isAwaitingPromise) {
9263 swalPromiseResolve({
9264 isDismissed: true
9265 });
9266 }
9267 if (isModal()) {
9268 unsetAriaHidden();
9269 }
9270 }
9271 globalState.currentInstance = currentInstance;
9272 const innerParams = prepareParams(userParams, mixinParams);
9273 setParameters(innerParams);
9274 Object.freeze(innerParams);
9275
9276 // clear the previous timer
9277 if (globalState.timeout) {
9278 globalState.timeout.stop();
9279 delete globalState.timeout;
9280 }
9281
9282 // clear the restore focus timeout
9283 clearTimeout(globalState.restoreFocusTimeout);
9284 const domCache = populateDomCache(currentInstance);
9285 render(currentInstance, innerParams);
9286 privateProps.innerParams.set(currentInstance, innerParams);
9287 return swalPromise(currentInstance, domCache, innerParams);
9288 }
9289
9290 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
9291 then(onFulfilled) {
9292 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
9293 }
9294 finally(onFinally) {
9295 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
9296 }
9297 }
9298
9299 /**
9300 * @param {SweetAlert} instance
9301 * @param {DomCache} domCache
9302 * @param {SweetAlertOptions} innerParams
9303 * @returns {Promise}
9304 */
9305 const swalPromise = (instance, domCache, innerParams) => {
9306 return new Promise((resolve, reject) => {
9307 // functions to handle all closings/dismissals
9308 /**
9309 * @param {DismissReason} dismiss
9310 */
9311 const dismissWith = dismiss => {
9312 instance.close({
9313 isDismissed: true,
9314 dismiss
9315 });
9316 };
9317 privateMethods.swalPromiseResolve.set(instance, resolve);
9318 privateMethods.swalPromiseReject.set(instance, reject);
9319 domCache.confirmButton.onclick = () => {
9320 handleConfirmButtonClick(instance);
9321 };
9322 domCache.denyButton.onclick = () => {
9323 handleDenyButtonClick(instance);
9324 };
9325 domCache.cancelButton.onclick = () => {
9326 handleCancelButtonClick(instance, dismissWith);
9327 };
9328 domCache.closeButton.onclick = () => {
9329 dismissWith(DismissReason.close);
9330 };
9331 handlePopupClick(innerParams, domCache, dismissWith);
9332 addKeydownHandler(globalState, innerParams, dismissWith);
9333 handleInputOptionsAndValue(instance, innerParams);
9334 openPopup(innerParams);
9335 setupTimer(globalState, innerParams, dismissWith);
9336 initFocus(domCache, innerParams);
9337
9338 // Scroll container to top on open (#1247, #1946)
9339 setTimeout(() => {
9340 domCache.container.scrollTop = 0;
9341 });
9342 });
9343 };
9344
9345 /**
9346 * @param {SweetAlertOptions} userParams
9347 * @param {SweetAlertOptions} mixinParams
9348 * @returns {SweetAlertOptions}
9349 */
9350 const prepareParams = (userParams, mixinParams) => {
9351 const templateParams = getTemplateParams(userParams);
9352 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
9353 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
9354 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
9355 if (params.animation === false) {
9356 params.showClass = {
9357 backdrop: 'swal2-noanimation'
9358 };
9359 params.hideClass = {};
9360 }
9361 return params;
9362 };
9363
9364 /**
9365 * @param {SweetAlert} instance
9366 * @returns {DomCache}
9367 */
9368 const populateDomCache = instance => {
9369 const domCache = {
9370 popup: getPopup(),
9371 container: getContainer(),
9372 actions: getActions(),
9373 confirmButton: getConfirmButton(),
9374 denyButton: getDenyButton(),
9375 cancelButton: getCancelButton(),
9376 loader: getLoader(),
9377 closeButton: getCloseButton(),
9378 validationMessage: getValidationMessage(),
9379 progressSteps: getProgressSteps()
9380 };
9381 privateProps.domCache.set(instance, domCache);
9382 return domCache;
9383 };
9384
9385 /**
9386 * @param {GlobalState} globalState
9387 * @param {SweetAlertOptions} innerParams
9388 * @param {Function} dismissWith
9389 */
9390 const setupTimer = (globalState, innerParams, dismissWith) => {
9391 const timerProgressBar = getTimerProgressBar();
9392 hide(timerProgressBar);
9393 if (innerParams.timer) {
9394 globalState.timeout = new Timer(() => {
9395 dismissWith('timer');
9396 delete globalState.timeout;
9397 }, innerParams.timer);
9398 if (innerParams.timerProgressBar) {
9399 show(timerProgressBar);
9400 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
9401 setTimeout(() => {
9402 if (globalState.timeout && globalState.timeout.running) {
9403 // timer can be already stopped or unset at this point
9404 animateTimerProgressBar(innerParams.timer);
9405 }
9406 });
9407 }
9408 }
9409 };
9410
9411 /**
9412 * Initialize focus in the popup:
9413 *
9414 * 1. If `toast` is `true`, don't steal focus from the document.
9415 * 2. Else if there is an [autofocus] element, focus it.
9416 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
9417 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
9418 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
9419 * 6. Else focus the first focusable element in a popup (if any).
9420 *
9421 * @param {DomCache} domCache
9422 * @param {SweetAlertOptions} innerParams
9423 */
9424 const initFocus = (domCache, innerParams) => {
9425 if (innerParams.toast) {
9426 return;
9427 }
9428 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
9429 if (!callIfFunction(innerParams.allowEnterKey)) {
9430 warnAboutDeprecation('allowEnterKey');
9431 blurActiveElement();
9432 return;
9433 }
9434 if (focusAutofocus(domCache)) {
9435 return;
9436 }
9437 if (focusButton(domCache, innerParams)) {
9438 return;
9439 }
9440 setFocus(-1, 1);
9441 };
9442
9443 /**
9444 * @param {DomCache} domCache
9445 * @returns {boolean}
9446 */
9447 const focusAutofocus = domCache => {
9448 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
9449 for (const autofocusElement of autofocusElements) {
9450 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
9451 autofocusElement.focus();
9452 return true;
9453 }
9454 }
9455 return false;
9456 };
9457
9458 /**
9459 * @param {DomCache} domCache
9460 * @param {SweetAlertOptions} innerParams
9461 * @returns {boolean}
9462 */
9463 const focusButton = (domCache, innerParams) => {
9464 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
9465 domCache.denyButton.focus();
9466 return true;
9467 }
9468 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
9469 domCache.cancelButton.focus();
9470 return true;
9471 }
9472 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
9473 domCache.confirmButton.focus();
9474 return true;
9475 }
9476 return false;
9477 };
9478 const blurActiveElement = () => {
9479 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
9480 document.activeElement.blur();
9481 }
9482 };
9483
9484 // Assign instance methods from src/instanceMethods/*.js to prototype
9485 SweetAlert.prototype.disableButtons = disableButtons;
9486 SweetAlert.prototype.enableButtons = enableButtons;
9487 SweetAlert.prototype.getInput = getInput;
9488 SweetAlert.prototype.disableInput = disableInput;
9489 SweetAlert.prototype.enableInput = enableInput;
9490 SweetAlert.prototype.hideLoading = hideLoading;
9491 SweetAlert.prototype.disableLoading = hideLoading;
9492 SweetAlert.prototype.showValidationMessage = showValidationMessage;
9493 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
9494 SweetAlert.prototype.close = close;
9495 SweetAlert.prototype.closePopup = close;
9496 SweetAlert.prototype.closeModal = close;
9497 SweetAlert.prototype.closeToast = close;
9498 SweetAlert.prototype.rejectPromise = rejectPromise;
9499 SweetAlert.prototype.update = update;
9500 SweetAlert.prototype._destroy = _destroy;
9501
9502 // Assign static methods from src/staticMethods/*.js to constructor
9503 Object.assign(SweetAlert, staticMethods);
9504
9505 // Proxy to instance methods to constructor, for now, for backwards compatibility
9506 Object.keys(instanceMethods).forEach(key => {
9507 /**
9508 * @param {...any} args
9509 * @returns {any | undefined}
9510 */
9511 SweetAlert[key] = function (...args) {
9512 if (currentInstance && currentInstance[key]) {
9513 return currentInstance[key](...args);
9514 }
9515 return null;
9516 };
9517 });
9518 SweetAlert.DismissReason = DismissReason;
9519 SweetAlert.version = '11.22.5';
9520
9521 const Swal = SweetAlert;
9522 // @ts-ignore
9523 Swal.default = Swal;
9524
9525 return Swal;
9526
9527 }));
9528 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
9529 "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.1s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px $swal2-outline-color;--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-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;word-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:scale(0.7)}45%{transform:scale(1.05)}80%{transform:scale(0.95)}100%{transform:scale(1)}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(0.5);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}}");
9530
9531 /***/ }),
9532
9533 /***/ "./node_modules/toastify-js/src/toastify.js":
9534 /*!**************************************************!*\
9535 !*** ./node_modules/toastify-js/src/toastify.js ***!
9536 \**************************************************/
9537 /***/ (function(module) {
9538
9539 /*!
9540 * Toastify js 1.12.0
9541 * https://github.com/apvarun/toastify-js
9542 * @license MIT licensed
9543 *
9544 * Copyright (C) 2018 Varun A P
9545 */
9546 (function(root, factory) {
9547 if ( true && module.exports) {
9548 module.exports = factory();
9549 } else {
9550 root.Toastify = factory();
9551 }
9552 })(this, function(global) {
9553 // Object initialization
9554 var Toastify = function(options) {
9555 // Returning a new init object
9556 return new Toastify.lib.init(options);
9557 },
9558 // Library version
9559 version = "1.12.0";
9560
9561 // Set the default global options
9562 Toastify.defaults = {
9563 oldestFirst: true,
9564 text: "Toastify is awesome!",
9565 node: undefined,
9566 duration: 3000,
9567 selector: undefined,
9568 callback: function () {
9569 },
9570 destination: undefined,
9571 newWindow: false,
9572 close: false,
9573 gravity: "toastify-top",
9574 positionLeft: false,
9575 position: '',
9576 backgroundColor: '',
9577 avatar: "",
9578 className: "",
9579 stopOnFocus: true,
9580 onClick: function () {
9581 },
9582 offset: {x: 0, y: 0},
9583 escapeMarkup: true,
9584 ariaLive: 'polite',
9585 style: {background: ''}
9586 };
9587
9588 // Defining the prototype of the object
9589 Toastify.lib = Toastify.prototype = {
9590 toastify: version,
9591
9592 constructor: Toastify,
9593
9594 // Initializing the object with required parameters
9595 init: function(options) {
9596 // Verifying and validating the input object
9597 if (!options) {
9598 options = {};
9599 }
9600
9601 // Creating the options object
9602 this.options = {};
9603
9604 this.toastElement = null;
9605
9606 // Validating the options
9607 this.options.text = options.text || Toastify.defaults.text; // Display message
9608 this.options.node = options.node || Toastify.defaults.node; // Display content as node
9609 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
9610 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
9611 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
9612 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
9613 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
9614 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
9615 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
9616 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
9617 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
9618 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
9619 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
9620 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
9621 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
9622 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
9623 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
9624 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
9625 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
9626 this.options.style = options.style || Toastify.defaults.style;
9627 if(options.backgroundColor) {
9628 this.options.style.background = options.backgroundColor;
9629 }
9630
9631 // Returning the current object for chaining functions
9632 return this;
9633 },
9634
9635 // Building the DOM element
9636 buildToast: function() {
9637 // Validating if the options are defined
9638 if (!this.options) {
9639 throw "Toastify is not initialized";
9640 }
9641
9642 // Creating the DOM object
9643 var divElement = document.createElement("div");
9644 divElement.className = "toastify on " + this.options.className;
9645
9646 // Positioning toast to left or right or center
9647 if (!!this.options.position) {
9648 divElement.className += " toastify-" + this.options.position;
9649 } else {
9650 // To be depreciated in further versions
9651 if (this.options.positionLeft === true) {
9652 divElement.className += " toastify-left";
9653 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
9654 } else {
9655 // Default position
9656 divElement.className += " toastify-right";
9657 }
9658 }
9659
9660 // Assigning gravity of element
9661 divElement.className += " " + this.options.gravity;
9662
9663 if (this.options.backgroundColor) {
9664 // This is being deprecated in favor of using the style HTML DOM property
9665 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
9666 }
9667
9668 // Loop through our style object and apply styles to divElement
9669 for (var property in this.options.style) {
9670 divElement.style[property] = this.options.style[property];
9671 }
9672
9673 // Announce the toast to screen readers
9674 if (this.options.ariaLive) {
9675 divElement.setAttribute('aria-live', this.options.ariaLive)
9676 }
9677
9678 // Adding the toast message/node
9679 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
9680 // If we have a valid node, we insert it
9681 divElement.appendChild(this.options.node)
9682 } else {
9683 if (this.options.escapeMarkup) {
9684 divElement.innerText = this.options.text;
9685 } else {
9686 divElement.innerHTML = this.options.text;
9687 }
9688
9689 if (this.options.avatar !== "") {
9690 var avatarElement = document.createElement("img");
9691 avatarElement.src = this.options.avatar;
9692
9693 avatarElement.className = "toastify-avatar";
9694
9695 if (this.options.position == "left" || this.options.positionLeft === true) {
9696 // Adding close icon on the left of content
9697 divElement.appendChild(avatarElement);
9698 } else {
9699 // Adding close icon on the right of content
9700 divElement.insertAdjacentElement("afterbegin", avatarElement);
9701 }
9702 }
9703 }
9704
9705 // Adding a close icon to the toast
9706 if (this.options.close === true) {
9707 // Create a span for close element
9708 var closeElement = document.createElement("button");
9709 closeElement.type = "button";
9710 closeElement.setAttribute("aria-label", "Close");
9711 closeElement.className = "toast-close";
9712 closeElement.innerHTML = "&#10006;";
9713
9714 // Triggering the removal of toast from DOM on close click
9715 closeElement.addEventListener(
9716 "click",
9717 function(event) {
9718 event.stopPropagation();
9719 this.removeElement(this.toastElement);
9720 window.clearTimeout(this.toastElement.timeOutValue);
9721 }.bind(this)
9722 );
9723
9724 //Calculating screen width
9725 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
9726
9727 // Adding the close icon to the toast element
9728 // Display on the right if screen width is less than or equal to 360px
9729 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
9730 // Adding close icon on the left of content
9731 divElement.insertAdjacentElement("afterbegin", closeElement);
9732 } else {
9733 // Adding close icon on the right of content
9734 divElement.appendChild(closeElement);
9735 }
9736 }
9737
9738 // Clear timeout while toast is focused
9739 if (this.options.stopOnFocus && this.options.duration > 0) {
9740 var self = this;
9741 // stop countdown
9742 divElement.addEventListener(
9743 "mouseover",
9744 function(event) {
9745 window.clearTimeout(divElement.timeOutValue);
9746 }
9747 )
9748 // add back the timeout
9749 divElement.addEventListener(
9750 "mouseleave",
9751 function() {
9752 divElement.timeOutValue = window.setTimeout(
9753 function() {
9754 // Remove the toast from DOM
9755 self.removeElement(divElement);
9756 },
9757 self.options.duration
9758 )
9759 }
9760 )
9761 }
9762
9763 // Adding an on-click destination path
9764 if (typeof this.options.destination !== "undefined") {
9765 divElement.addEventListener(
9766 "click",
9767 function(event) {
9768 event.stopPropagation();
9769 if (this.options.newWindow === true) {
9770 window.open(this.options.destination, "_blank");
9771 } else {
9772 window.location = this.options.destination;
9773 }
9774 }.bind(this)
9775 );
9776 }
9777
9778 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
9779 divElement.addEventListener(
9780 "click",
9781 function(event) {
9782 event.stopPropagation();
9783 this.options.onClick();
9784 }.bind(this)
9785 );
9786 }
9787
9788 // Adding offset
9789 if(typeof this.options.offset === "object") {
9790
9791 var x = getAxisOffsetAValue("x", this.options);
9792 var y = getAxisOffsetAValue("y", this.options);
9793
9794 var xOffset = this.options.position == "left" ? x : "-" + x;
9795 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
9796
9797 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
9798
9799 }
9800
9801 // Returning the generated element
9802 return divElement;
9803 },
9804
9805 // Displaying the toast
9806 showToast: function() {
9807 // Creating the DOM object for the toast
9808 this.toastElement = this.buildToast();
9809
9810 // Getting the root element to with the toast needs to be added
9811 var rootElement;
9812 if (typeof this.options.selector === "string") {
9813 rootElement = document.getElementById(this.options.selector);
9814 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
9815 rootElement = this.options.selector;
9816 } else {
9817 rootElement = document.body;
9818 }
9819
9820 // Validating if root element is present in DOM
9821 if (!rootElement) {
9822 throw "Root element is not defined";
9823 }
9824
9825 // Adding the DOM element
9826 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
9827 rootElement.insertBefore(this.toastElement, elementToInsert);
9828
9829 // Repositioning the toasts in case multiple toasts are present
9830 Toastify.reposition();
9831
9832 if (this.options.duration > 0) {
9833 this.toastElement.timeOutValue = window.setTimeout(
9834 function() {
9835 // Remove the toast from DOM
9836 this.removeElement(this.toastElement);
9837 }.bind(this),
9838 this.options.duration
9839 ); // Binding `this` for function invocation
9840 }
9841
9842 // Supporting function chaining
9843 return this;
9844 },
9845
9846 hideToast: function() {
9847 if (this.toastElement.timeOutValue) {
9848 clearTimeout(this.toastElement.timeOutValue);
9849 }
9850 this.removeElement(this.toastElement);
9851 },
9852
9853 // Removing the element from the DOM
9854 removeElement: function(toastElement) {
9855 // Hiding the element
9856 // toastElement.classList.remove("on");
9857 toastElement.className = toastElement.className.replace(" on", "");
9858
9859 // Removing the element from DOM after transition end
9860 window.setTimeout(
9861 function() {
9862 // remove options node if any
9863 if (this.options.node && this.options.node.parentNode) {
9864 this.options.node.parentNode.removeChild(this.options.node);
9865 }
9866
9867 // Remove the element from the DOM, only when the parent node was not removed before.
9868 if (toastElement.parentNode) {
9869 toastElement.parentNode.removeChild(toastElement);
9870 }
9871
9872 // Calling the callback function
9873 this.options.callback.call(toastElement);
9874
9875 // Repositioning the toasts again
9876 Toastify.reposition();
9877 }.bind(this),
9878 400
9879 ); // Binding `this` for function invocation
9880 },
9881 };
9882
9883 // Positioning the toasts on the DOM
9884 Toastify.reposition = function() {
9885
9886 // Top margins with gravity
9887 var topLeftOffsetSize = {
9888 top: 15,
9889 bottom: 15,
9890 };
9891 var topRightOffsetSize = {
9892 top: 15,
9893 bottom: 15,
9894 };
9895 var offsetSize = {
9896 top: 15,
9897 bottom: 15,
9898 };
9899
9900 // Get all toast messages on the DOM
9901 var allToasts = document.getElementsByClassName("toastify");
9902
9903 var classUsed;
9904
9905 // Modifying the position of each toast element
9906 for (var i = 0; i < allToasts.length; i++) {
9907 // Getting the applied gravity
9908 if (containsClass(allToasts[i], "toastify-top") === true) {
9909 classUsed = "toastify-top";
9910 } else {
9911 classUsed = "toastify-bottom";
9912 }
9913
9914 var height = allToasts[i].offsetHeight;
9915 classUsed = classUsed.substr(9, classUsed.length-1)
9916 // Spacing between toasts
9917 var offset = 15;
9918
9919 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
9920
9921 // Show toast in center if screen with less than or equal to 360px
9922 if (width <= 360) {
9923 // Setting the position
9924 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
9925
9926 offsetSize[classUsed] += height + offset;
9927 } else {
9928 if (containsClass(allToasts[i], "toastify-left") === true) {
9929 // Setting the position
9930 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
9931
9932 topLeftOffsetSize[classUsed] += height + offset;
9933 } else {
9934 // Setting the position
9935 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
9936
9937 topRightOffsetSize[classUsed] += height + offset;
9938 }
9939 }
9940 }
9941
9942 // Supporting function chaining
9943 return this;
9944 };
9945
9946 // Helper function to get offset.
9947 function getAxisOffsetAValue(axis, options) {
9948
9949 if(options.offset[axis]) {
9950 if(isNaN(options.offset[axis])) {
9951 return options.offset[axis];
9952 }
9953 else {
9954 return options.offset[axis] + 'px';
9955 }
9956 }
9957
9958 return '0px';
9959
9960 }
9961
9962 function containsClass(elem, yourClass) {
9963 if (!elem || typeof yourClass !== "string") {
9964 return false;
9965 } else if (
9966 elem.className &&
9967 elem.className
9968 .trim()
9969 .split(/\s+/gi)
9970 .indexOf(yourClass) > -1
9971 ) {
9972 return true;
9973 } else {
9974 return false;
9975 }
9976 }
9977
9978 // Setting up the prototype for the init object
9979 Toastify.lib.init.prototype = Toastify.lib;
9980
9981 // Returning the Toastify function to be assigned to the window object/module
9982 return Toastify;
9983 });
9984
9985
9986 /***/ }),
9987
9988 /***/ "./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js":
9989 /*!*********************************************************************!*\
9990 !*** ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js ***!
9991 \*********************************************************************/
9992 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9993
9994 "use strict";
9995 __webpack_require__.r(__webpack_exports__);
9996 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9997 /* harmony export */ "default": () => (/* binding */ _arrayLikeToArray)
9998 /* harmony export */ });
9999 function _arrayLikeToArray(r, a) {
10000 (null == a || a > r.length) && (a = r.length);
10001 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10002 return n;
10003 }
10004
10005
10006 /***/ }),
10007
10008 /***/ "./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js":
10009 /*!*******************************************************************!*\
10010 !*** ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js ***!
10011 \*******************************************************************/
10012 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10013
10014 "use strict";
10015 __webpack_require__.r(__webpack_exports__);
10016 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10017 /* harmony export */ "default": () => (/* binding */ _arrayWithHoles)
10018 /* harmony export */ });
10019 function _arrayWithHoles(r) {
10020 if (Array.isArray(r)) return r;
10021 }
10022
10023
10024 /***/ }),
10025
10026 /***/ "./node_modules/@babel/runtime/helpers/esm/classCallCheck.js":
10027 /*!*******************************************************************!*\
10028 !*** ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js ***!
10029 \*******************************************************************/
10030 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10031
10032 "use strict";
10033 __webpack_require__.r(__webpack_exports__);
10034 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10035 /* harmony export */ "default": () => (/* binding */ _classCallCheck)
10036 /* harmony export */ });
10037 function _classCallCheck(a, n) {
10038 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
10039 }
10040
10041
10042 /***/ }),
10043
10044 /***/ "./node_modules/@babel/runtime/helpers/esm/createClass.js":
10045 /*!****************************************************************!*\
10046 !*** ./node_modules/@babel/runtime/helpers/esm/createClass.js ***!
10047 \****************************************************************/
10048 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10049
10050 "use strict";
10051 __webpack_require__.r(__webpack_exports__);
10052 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10053 /* harmony export */ "default": () => (/* binding */ _createClass)
10054 /* harmony export */ });
10055 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
10056
10057 function _defineProperties(e, r) {
10058 for (var t = 0; t < r.length; t++) {
10059 var o = r[t];
10060 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(o.key), o);
10061 }
10062 }
10063 function _createClass(e, r, t) {
10064 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
10065 writable: !1
10066 }), e;
10067 }
10068
10069
10070 /***/ }),
10071
10072 /***/ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js":
10073 /*!*******************************************************************!*\
10074 !*** ./node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
10075 \*******************************************************************/
10076 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10077
10078 "use strict";
10079 __webpack_require__.r(__webpack_exports__);
10080 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10081 /* harmony export */ "default": () => (/* binding */ _defineProperty)
10082 /* harmony export */ });
10083 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
10084
10085 function _defineProperty(e, r, t) {
10086 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
10087 value: t,
10088 enumerable: !0,
10089 configurable: !0,
10090 writable: !0
10091 }) : e[r] = t, e;
10092 }
10093
10094
10095 /***/ }),
10096
10097 /***/ "./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js":
10098 /*!*************************************************************************!*\
10099 !*** ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js ***!
10100 \*************************************************************************/
10101 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10102
10103 "use strict";
10104 __webpack_require__.r(__webpack_exports__);
10105 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10106 /* harmony export */ "default": () => (/* binding */ _iterableToArrayLimit)
10107 /* harmony export */ });
10108 function _iterableToArrayLimit(r, l) {
10109 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
10110 if (null != t) {
10111 var e,
10112 n,
10113 i,
10114 u,
10115 a = [],
10116 f = !0,
10117 o = !1;
10118 try {
10119 if (i = (t = t.call(r)).next, 0 === l) {
10120 if (Object(t) !== t) return;
10121 f = !1;
10122 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
10123 } catch (r) {
10124 o = !0, n = r;
10125 } finally {
10126 try {
10127 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
10128 } finally {
10129 if (o) throw n;
10130 }
10131 }
10132 return a;
10133 }
10134 }
10135
10136
10137 /***/ }),
10138
10139 /***/ "./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js":
10140 /*!********************************************************************!*\
10141 !*** ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js ***!
10142 \********************************************************************/
10143 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10144
10145 "use strict";
10146 __webpack_require__.r(__webpack_exports__);
10147 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10148 /* harmony export */ "default": () => (/* binding */ _nonIterableRest)
10149 /* harmony export */ });
10150 function _nonIterableRest() {
10151 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10152 }
10153
10154
10155 /***/ }),
10156
10157 /***/ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js":
10158 /*!******************************************************************!*\
10159 !*** ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js ***!
10160 \******************************************************************/
10161 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10162
10163 "use strict";
10164 __webpack_require__.r(__webpack_exports__);
10165 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10166 /* harmony export */ "default": () => (/* binding */ _slicedToArray)
10167 /* harmony export */ });
10168 /* harmony import */ var _arrayWithHoles_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayWithHoles.js */ "./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js");
10169 /* harmony import */ var _iterableToArrayLimit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./iterableToArrayLimit.js */ "./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js");
10170 /* harmony import */ var _unsupportedIterableToArray_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js");
10171 /* harmony import */ var _nonIterableRest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nonIterableRest.js */ "./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js");
10172
10173
10174
10175
10176 function _slicedToArray(r, e) {
10177 return (0,_arrayWithHoles_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r) || (0,_iterableToArrayLimit_js__WEBPACK_IMPORTED_MODULE_1__["default"])(r, e) || (0,_unsupportedIterableToArray_js__WEBPACK_IMPORTED_MODULE_2__["default"])(r, e) || (0,_nonIterableRest_js__WEBPACK_IMPORTED_MODULE_3__["default"])();
10178 }
10179
10180
10181 /***/ }),
10182
10183 /***/ "./node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
10184 /*!****************************************************************!*\
10185 !*** ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
10186 \****************************************************************/
10187 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10188
10189 "use strict";
10190 __webpack_require__.r(__webpack_exports__);
10191 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10192 /* harmony export */ "default": () => (/* binding */ toPrimitive)
10193 /* harmony export */ });
10194 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/esm/typeof.js");
10195
10196 function toPrimitive(t, r) {
10197 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
10198 var e = t[Symbol.toPrimitive];
10199 if (void 0 !== e) {
10200 var i = e.call(t, r || "default");
10201 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
10202 throw new TypeError("@@toPrimitive must return a primitive value.");
10203 }
10204 return ("string" === r ? String : Number)(t);
10205 }
10206
10207
10208 /***/ }),
10209
10210 /***/ "./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
10211 /*!******************************************************************!*\
10212 !*** ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
10213 \******************************************************************/
10214 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10215
10216 "use strict";
10217 __webpack_require__.r(__webpack_exports__);
10218 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10219 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
10220 /* harmony export */ });
10221 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/esm/typeof.js");
10222 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
10223
10224
10225 function toPropertyKey(t) {
10226 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
10227 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
10228 }
10229
10230
10231 /***/ }),
10232
10233 /***/ "./node_modules/@babel/runtime/helpers/esm/typeof.js":
10234 /*!***********************************************************!*\
10235 !*** ./node_modules/@babel/runtime/helpers/esm/typeof.js ***!
10236 \***********************************************************/
10237 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10238
10239 "use strict";
10240 __webpack_require__.r(__webpack_exports__);
10241 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10242 /* harmony export */ "default": () => (/* binding */ _typeof)
10243 /* harmony export */ });
10244 function _typeof(o) {
10245 "@babel/helpers - typeof";
10246
10247 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
10248 return typeof o;
10249 } : function (o) {
10250 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
10251 }, _typeof(o);
10252 }
10253
10254
10255 /***/ }),
10256
10257 /***/ "./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js":
10258 /*!*******************************************************************************!*\
10259 !*** ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js ***!
10260 \*******************************************************************************/
10261 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10262
10263 "use strict";
10264 __webpack_require__.r(__webpack_exports__);
10265 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10266 /* harmony export */ "default": () => (/* binding */ _unsupportedIterableToArray)
10267 /* harmony export */ });
10268 /* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js");
10269
10270 function _unsupportedIterableToArray(r, a) {
10271 if (r) {
10272 if ("string" == typeof r) return (0,_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r, a);
10273 var t = {}.toString.call(r).slice(8, -1);
10274 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? (0,_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r, a) : void 0;
10275 }
10276 }
10277
10278
10279 /***/ }),
10280
10281 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js":
10282 /*!**********************************************************!*\
10283 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
10284 \**********************************************************/
10285 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10286
10287 "use strict";
10288 __webpack_require__.r(__webpack_exports__);
10289 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10290 /* harmony export */ Sifter: () => (/* binding */ Sifter),
10291 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
10292 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
10293 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
10294 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
10295 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
10296 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
10297 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
10298 /* harmony export */ });
10299 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
10300 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10301 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
10302 /**
10303 * sifter.js
10304 * Copyright (c) 2013–2020 Brian Reavis & contributors
10305 *
10306 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10307 * file except in compliance with the License. You may obtain a copy of the License at:
10308 * http://www.apache.org/licenses/LICENSE-2.0
10309 *
10310 * Unless required by applicable law or agreed to in writing, software distributed under
10311 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10312 * ANY KIND, either express or implied. See the License for the specific language
10313 * governing permissions and limitations under the License.
10314 *
10315 * @author Brian Reavis <[email protected]>
10316 */
10317
10318
10319 class Sifter {
10320 items; // []|{};
10321 settings;
10322 /**
10323 * Textually searches arrays and hashes of objects
10324 * by property (or multiple properties). Designed
10325 * specifically for autocomplete.
10326 *
10327 */
10328 constructor(items, settings) {
10329 this.items = items;
10330 this.settings = settings || { diacritics: true };
10331 }
10332 ;
10333 /**
10334 * Splits a search string into an array of individual
10335 * regexps to be used to match results.
10336 *
10337 */
10338 tokenize(query, respect_word_boundaries, weights) {
10339 if (!query || !query.length)
10340 return [];
10341 const tokens = [];
10342 const words = query.split(/\s+/);
10343 var field_regex;
10344 if (weights) {
10345 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
10346 }
10347 words.forEach((word) => {
10348 let field_match;
10349 let field = null;
10350 let regex = null;
10351 // look for "field:query" tokens
10352 if (field_regex && (field_match = word.match(field_regex))) {
10353 field = field_match[1];
10354 word = field_match[2];
10355 }
10356 if (word.length > 0) {
10357 if (this.settings.diacritics) {
10358 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
10359 }
10360 else {
10361 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
10362 }
10363 if (regex && respect_word_boundaries)
10364 regex = "\\b" + regex;
10365 }
10366 tokens.push({
10367 string: word,
10368 regex: regex ? new RegExp(regex, 'iu') : null,
10369 field: field,
10370 });
10371 });
10372 return tokens;
10373 }
10374 ;
10375 /**
10376 * Returns a function to be used to score individual results.
10377 *
10378 * Good matches will have a higher score than poor matches.
10379 * If an item is not a match, 0 will be returned by the function.
10380 *
10381 * @returns {T.ScoreFn}
10382 */
10383 getScoreFunction(query, options) {
10384 var search = this.prepareSearch(query, options);
10385 return this._getScoreFunction(search);
10386 }
10387 /**
10388 * @returns {T.ScoreFn}
10389 *
10390 */
10391 _getScoreFunction(search) {
10392 const tokens = search.tokens, token_count = tokens.length;
10393 if (!token_count) {
10394 return function () { return 0; };
10395 }
10396 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
10397 if (!field_count) {
10398 return function () { return 1; };
10399 }
10400 /**
10401 * Calculates the score of an object
10402 * against the search query.
10403 *
10404 */
10405 const scoreObject = (function () {
10406 if (field_count === 1) {
10407 return function (token, data) {
10408 const field = fields[0].field;
10409 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
10410 };
10411 }
10412 return function (token, data) {
10413 var sum = 0;
10414 // is the token specific to a field?
10415 if (token.field) {
10416 const value = getAttrFn(data, token.field);
10417 if (!token.regex && value) {
10418 sum += (1 / field_count);
10419 }
10420 else {
10421 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
10422 }
10423 }
10424 else {
10425 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
10426 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
10427 });
10428 }
10429 return sum / field_count;
10430 };
10431 })();
10432 if (token_count === 1) {
10433 return function (data) {
10434 return scoreObject(tokens[0], data);
10435 };
10436 }
10437 if (search.options.conjunction === 'and') {
10438 return function (data) {
10439 var score, sum = 0;
10440 for (let token of tokens) {
10441 score = scoreObject(token, data);
10442 if (score <= 0)
10443 return 0;
10444 sum += score;
10445 }
10446 return sum / token_count;
10447 };
10448 }
10449 else {
10450 return function (data) {
10451 var sum = 0;
10452 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
10453 sum += scoreObject(token, data);
10454 });
10455 return sum / token_count;
10456 };
10457 }
10458 }
10459 ;
10460 /**
10461 * Returns a function that can be used to compare two
10462 * results, for sorting purposes. If no sorting should
10463 * be performed, `null` will be returned.
10464 *
10465 * @return function(a,b)
10466 */
10467 getSortFunction(query, options) {
10468 var search = this.prepareSearch(query, options);
10469 return this._getSortFunction(search);
10470 }
10471 _getSortFunction(search) {
10472 var implicit_score, sort_flds = [];
10473 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
10474 if (typeof sort == 'function') {
10475 return sort.bind(this);
10476 }
10477 /**
10478 * Fetches the specified sort field value
10479 * from a search result item.
10480 *
10481 */
10482 const get_field = function (name, result) {
10483 if (name === '$score')
10484 return result.score;
10485 return search.getAttrFn(self.items[result.id], name);
10486 };
10487 // parse options
10488 if (sort) {
10489 for (let s of sort) {
10490 if (search.query || s.field !== '$score') {
10491 sort_flds.push(s);
10492 }
10493 }
10494 }
10495 // the "$score" field is implied to be the primary
10496 // sort field, unless it's manually specified
10497 if (search.query) {
10498 implicit_score = true;
10499 for (let fld of sort_flds) {
10500 if (fld.field === '$score') {
10501 implicit_score = false;
10502 break;
10503 }
10504 }
10505 if (implicit_score) {
10506 sort_flds.unshift({ field: '$score', direction: 'desc' });
10507 }
10508 // without a search.query, all items will have the same score
10509 }
10510 else {
10511 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
10512 }
10513 // build function
10514 const sort_flds_count = sort_flds.length;
10515 if (!sort_flds_count) {
10516 return null;
10517 }
10518 return function (a, b) {
10519 var result, field;
10520 for (let sort_fld of sort_flds) {
10521 field = sort_fld.field;
10522 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
10523 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
10524 if (result)
10525 return result;
10526 }
10527 return 0;
10528 };
10529 }
10530 ;
10531 /**
10532 * Parses a search query and returns an object
10533 * with tokens and fields ready to be populated
10534 * with results.
10535 *
10536 */
10537 prepareSearch(query, optsUser) {
10538 const weights = {};
10539 var options = Object.assign({}, optsUser);
10540 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
10541 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
10542 // convert fields to new format
10543 if (options.fields) {
10544 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
10545 const fields = [];
10546 options.fields.forEach((field) => {
10547 if (typeof field == 'string') {
10548 field = { field: field, weight: 1 };
10549 }
10550 fields.push(field);
10551 weights[field.field] = ('weight' in field) ? field.weight : 1;
10552 });
10553 options.fields = fields;
10554 }
10555 return {
10556 options: options,
10557 query: query.toLowerCase().trim(),
10558 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
10559 total: 0,
10560 items: [],
10561 weights: weights,
10562 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
10563 };
10564 }
10565 ;
10566 /**
10567 * Searches through all items and returns a sorted array of matches.
10568 *
10569 */
10570 search(query, options) {
10571 var self = this, score, search;
10572 search = this.prepareSearch(query, options);
10573 options = search.options;
10574 query = search.query;
10575 // generate result scoring function
10576 const fn_score = options.score || self._getScoreFunction(search);
10577 // perform search and sort
10578 if (query.length) {
10579 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
10580 score = fn_score(item);
10581 if (options.filter === false || score > 0) {
10582 search.items.push({ 'score': score, 'id': id });
10583 }
10584 });
10585 }
10586 else {
10587 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
10588 search.items.push({ 'score': 1, 'id': id });
10589 });
10590 }
10591 const fn_sort = self._getSortFunction(search);
10592 if (fn_sort)
10593 search.items.sort(fn_sort);
10594 // apply limits
10595 search.total = search.items.length;
10596 if (typeof options.limit === 'number') {
10597 search.items = search.items.slice(0, options.limit);
10598 }
10599 return search;
10600 }
10601 ;
10602 }
10603
10604
10605 //# sourceMappingURL=sifter.js.map
10606
10607 /***/ }),
10608
10609 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js":
10610 /*!*********************************************************!*\
10611 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
10612 \*********************************************************/
10613 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10614
10615 "use strict";
10616 __webpack_require__.r(__webpack_exports__);
10617
10618 //# sourceMappingURL=types.js.map
10619
10620 /***/ }),
10621
10622 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js":
10623 /*!*********************************************************!*\
10624 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
10625 \*********************************************************/
10626 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10627
10628 "use strict";
10629 __webpack_require__.r(__webpack_exports__);
10630 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10631 /* harmony export */ cmp: () => (/* binding */ cmp),
10632 /* harmony export */ getAttr: () => (/* binding */ getAttr),
10633 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
10634 /* harmony export */ iterate: () => (/* binding */ iterate),
10635 /* harmony export */ propToArray: () => (/* binding */ propToArray),
10636 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
10637 /* harmony export */ });
10638 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10639
10640 /**
10641 * A property getter resolving dot-notation
10642 * @param {Object} obj The root object to fetch property on
10643 * @param {String} name The optionally dotted property name to fetch
10644 * @return {Object} The resolved property value
10645 */
10646 const getAttr = (obj, name) => {
10647 if (!obj)
10648 return;
10649 return obj[name];
10650 };
10651 /**
10652 * A property getter resolving dot-notation
10653 * @param {Object} obj The root object to fetch property on
10654 * @param {String} name The optionally dotted property name to fetch
10655 * @return {Object} The resolved property value
10656 */
10657 const getAttrNesting = (obj, name) => {
10658 if (!obj)
10659 return;
10660 var part, names = name.split(".");
10661 while ((part = names.shift()) && (obj = obj[part]))
10662 ;
10663 return obj;
10664 };
10665 /**
10666 * Calculates how close of a match the
10667 * given value is against a search token.
10668 *
10669 */
10670 const scoreValue = (value, token, weight) => {
10671 var score, pos;
10672 if (!value)
10673 return 0;
10674 value = value + '';
10675 if (token.regex == null)
10676 return 0;
10677 pos = value.search(token.regex);
10678 if (pos === -1)
10679 return 0;
10680 score = token.string.length / value.length;
10681 if (pos === 0)
10682 score += 0.5;
10683 return score * weight;
10684 };
10685 /**
10686 * Cast object property to an array if it exists and has a value
10687 *
10688 */
10689 const propToArray = (obj, key) => {
10690 var value = obj[key];
10691 if (typeof value == 'function')
10692 return value;
10693 if (value && !Array.isArray(value)) {
10694 obj[key] = [value];
10695 }
10696 };
10697 /**
10698 * Iterates over arrays and hashes.
10699 *
10700 * ```
10701 * iterate(this.items, function(item, id) {
10702 * // invoked for each item
10703 * });
10704 * ```
10705 *
10706 */
10707 const iterate = (object, callback) => {
10708 if (Array.isArray(object)) {
10709 object.forEach(callback);
10710 }
10711 else {
10712 for (var key in object) {
10713 if (object.hasOwnProperty(key)) {
10714 callback(object[key], key);
10715 }
10716 }
10717 }
10718 };
10719 const cmp = (a, b) => {
10720 if (typeof a === 'number' && typeof b === 'number') {
10721 return a > b ? 1 : (a < b ? -1 : 0);
10722 }
10723 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
10724 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
10725 if (a > b)
10726 return 1;
10727 if (b > a)
10728 return -1;
10729 return 0;
10730 };
10731 //# sourceMappingURL=utils.js.map
10732
10733 /***/ }),
10734
10735 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js":
10736 /*!*******************************************************************!*\
10737 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
10738 \*******************************************************************/
10739 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
10740
10741 "use strict";
10742 __webpack_require__.r(__webpack_exports__);
10743 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10744 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
10745 /* harmony export */ asciifold: () => (/* binding */ asciifold),
10746 /* harmony export */ code_points: () => (/* binding */ code_points),
10747 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
10748 /* harmony export */ generateMap: () => (/* binding */ generateMap),
10749 /* harmony export */ generateSets: () => (/* binding */ generateSets),
10750 /* harmony export */ generator: () => (/* binding */ generator),
10751 /* harmony export */ getPattern: () => (/* binding */ getPattern),
10752 /* harmony export */ initialize: () => (/* binding */ initialize),
10753 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
10754 /* harmony export */ normalize: () => (/* binding */ normalize),
10755 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
10756 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
10757 /* harmony export */ });
10758 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
10759 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
10760
10761
10762 const code_points = [[0, 65535]];
10763 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
10764 let unicode_map;
10765 let multi_char_reg;
10766 const max_char_length = 3;
10767 const latin_convert = {};
10768 const latin_condensed = {
10769 '/': '⁄∕',
10770 '0': '߀',
10771 "a": "ⱥɐɑ",
10772 "aa": "ꜳ",
10773 "ae": "æǽǣ",
10774 "ao": "ꜵ",
10775 "au": "ꜷ",
10776 "av": "ꜹꜻ",
10777 "ay": "ꜽ",
10778 "b": "ƀɓƃ",
10779 "c": "ꜿƈȼↄ",
10780 "d": "đɗɖᴅƌꮷԁɦ",
10781 "e": "ɛǝᴇɇ",
10782 "f": "ꝼƒ",
10783 "g": "ǥɠꞡᵹꝿɢ",
10784 "h": "ħⱨⱶɥ",
10785 "i": "ɨı",
10786 "j": "ɉȷ",
10787 "k": "ƙⱪꝁꝃꝅꞣ",
10788 "l": "łƚɫⱡꝉꝇꞁɭ",
10789 "m": "ɱɯϻ",
10790 "n": "ꞥƞɲꞑᴎлԉ",
10791 "o": "øǿɔɵꝋꝍᴑ",
10792 "oe": "œ",
10793 "oi": "ƣ",
10794 "oo": "ꝏ",
10795 "ou": "ȣ",
10796 "p": "ƥᵽꝑꝓꝕρ",
10797 "q": "ꝗꝙɋ",
10798 "r": "ɍɽꝛꞧꞃ",
10799 "s": "ßȿꞩꞅʂ",
10800 "t": "ŧƭʈⱦꞇ",
10801 "th": "þ",
10802 "tz": "ꜩ",
10803 "u": "ʉ",
10804 "v": "ʋꝟʌ",
10805 "vy": "ꝡ",
10806 "w": "ⱳ",
10807 "y": "ƴɏỿ",
10808 "z": "ƶȥɀⱬꝣ",
10809 "hv": "ƕ"
10810 };
10811 for (let latin in latin_condensed) {
10812 let unicode = latin_condensed[latin] || '';
10813 for (let i = 0; i < unicode.length; i++) {
10814 let char = unicode.substring(i, i + 1);
10815 latin_convert[char] = latin;
10816 }
10817 }
10818 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
10819 /**
10820 * Initialize the unicode_map from the give code point ranges
10821 */
10822 const initialize = (_code_points) => {
10823 if (unicode_map !== undefined)
10824 return;
10825 unicode_map = generateMap(_code_points || code_points);
10826 };
10827 /**
10828 * Helper method for normalize a string
10829 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
10830 */
10831 const normalize = (str, form = 'NFKD') => str.normalize(form);
10832 /**
10833 * Remove accents without reordering string
10834 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
10835 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
10836 */
10837 const asciifold = (str) => {
10838 return Array.from(str).reduce(
10839 /**
10840 * @param {string} result
10841 * @param {string} char
10842 */
10843 (result, char) => {
10844 return result + _asciifold(char);
10845 }, '');
10846 };
10847 const _asciifold = (str) => {
10848 str = normalize(str)
10849 .toLowerCase()
10850 .replace(convert_pat, (/** @type {string} */ char) => {
10851 return latin_convert[char] || '';
10852 });
10853 //return str;
10854 return normalize(str, 'NFC');
10855 };
10856 /**
10857 * Generate a list of unicode variants from the list of code points
10858 */
10859 function* generator(code_points) {
10860 for (const [code_point_min, code_point_max] of code_points) {
10861 for (let i = code_point_min; i <= code_point_max; i++) {
10862 let composed = String.fromCharCode(i);
10863 let folded = asciifold(composed);
10864 if (folded == composed.toLowerCase()) {
10865 continue;
10866 }
10867 // skip when folded is a string longer than 3 characters long
10868 // bc the resulting regex patterns will be long
10869 // eg:
10870 // folded صلى الله عليه وسلم length 18 code point 65018
10871 // folded جل جلاله length 8 code point 65019
10872 if (folded.length > max_char_length) {
10873 continue;
10874 }
10875 if (folded.length == 0) {
10876 continue;
10877 }
10878 yield { folded: folded, composed: composed, code_point: i };
10879 }
10880 }
10881 }
10882 /**
10883 * Generate a unicode map from the list of code points
10884 */
10885 const generateSets = (code_points) => {
10886 const unicode_sets = {};
10887 const addMatching = (folded, to_add) => {
10888 /** @type {Set<string>} */
10889 const folded_set = unicode_sets[folded] || new Set();
10890 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
10891 if (to_add.match(patt)) {
10892 return;
10893 }
10894 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
10895 unicode_sets[folded] = folded_set;
10896 };
10897 for (let value of generator(code_points)) {
10898 addMatching(value.folded, value.folded);
10899 addMatching(value.folded, value.composed);
10900 }
10901 return unicode_sets;
10902 };
10903 /**
10904 * Generate a unicode map from the list of code points
10905 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
10906 */
10907 const generateMap = (code_points) => {
10908 const unicode_sets = generateSets(code_points);
10909 const unicode_map = {};
10910 let multi_char = [];
10911 for (let folded in unicode_sets) {
10912 let set = unicode_sets[folded];
10913 if (set) {
10914 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
10915 }
10916 if (folded.length > 1) {
10917 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
10918 }
10919 }
10920 multi_char.sort((a, b) => b.length - a.length);
10921 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
10922 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
10923 return unicode_map;
10924 };
10925 /**
10926 * Map each element of an array from its folded value to all possible unicode matches
10927 */
10928 const mapSequence = (strings, min_replacement = 1) => {
10929 let chars_replaced = 0;
10930 strings = strings.map((str) => {
10931 if (unicode_map[str]) {
10932 chars_replaced += str.length;
10933 }
10934 return unicode_map[str] || str;
10935 });
10936 if (chars_replaced >= min_replacement) {
10937 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
10938 }
10939 return '';
10940 };
10941 /**
10942 * Convert a short string and split it into all possible patterns
10943 * Keep a pattern only if min_replacement is met
10944 *
10945 * 'abc'
10946 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
10947 * => ['abc-pattern','ab-c-pattern'...]
10948 */
10949 const substringsToPattern = (str, min_replacement = 1) => {
10950 min_replacement = Math.max(min_replacement, str.length - 1);
10951 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
10952 return mapSequence(sub_pat, min_replacement);
10953 }));
10954 };
10955 /**
10956 * Convert an array of sequences into a pattern
10957 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
10958 */
10959 const sequencesToPattern = (sequences, all = true) => {
10960 let min_replacement = sequences.length > 1 ? 1 : 0;
10961 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
10962 let seq = [];
10963 const len = all ? sequence.length() : sequence.length() - 1;
10964 for (let j = 0; j < len; j++) {
10965 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
10966 }
10967 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
10968 }));
10969 };
10970 /**
10971 * Return true if the sequence is already in the sequences
10972 */
10973 const inSequences = (needle_seq, sequences) => {
10974 for (const seq of sequences) {
10975 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
10976 continue;
10977 }
10978 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
10979 continue;
10980 }
10981 let needle_parts = needle_seq.parts;
10982 const filter = (part) => {
10983 for (const needle_part of needle_parts) {
10984 if (needle_part.start === part.start && needle_part.substr === part.substr) {
10985 return false;
10986 }
10987 if (part.length == 1 || needle_part.length == 1) {
10988 continue;
10989 }
10990 // check for overlapping parts
10991 // a = ['::=','==']
10992 // b = ['::','===']
10993 // a = ['r','sm']
10994 // b = ['rs','m']
10995 if (part.start < needle_part.start && part.end > needle_part.start) {
10996 return true;
10997 }
10998 if (needle_part.start < part.start && needle_part.end > part.start) {
10999 return true;
11000 }
11001 }
11002 return false;
11003 };
11004 let filtered = seq.parts.filter(filter);
11005 if (filtered.length > 0) {
11006 continue;
11007 }
11008 return true;
11009 }
11010 return false;
11011 };
11012 class Sequence {
11013 parts;
11014 substrs;
11015 start;
11016 end;
11017 constructor() {
11018 this.parts = [];
11019 this.substrs = [];
11020 this.start = 0;
11021 this.end = 0;
11022 }
11023 add(part) {
11024 if (part) {
11025 this.parts.push(part);
11026 this.substrs.push(part.substr);
11027 this.start = Math.min(part.start, this.start);
11028 this.end = Math.max(part.end, this.end);
11029 }
11030 }
11031 last() {
11032 return this.parts[this.parts.length - 1];
11033 }
11034 length() {
11035 return this.parts.length;
11036 }
11037 clone(position, last_piece) {
11038 let clone = new Sequence();
11039 let parts = JSON.parse(JSON.stringify(this.parts));
11040 let last_part = parts.pop();
11041 for (const part of parts) {
11042 clone.add(part);
11043 }
11044 let last_substr = last_piece.substr.substring(0, position - last_part.start);
11045 let clone_last_len = last_substr.length;
11046 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
11047 return clone;
11048 }
11049 }
11050 /**
11051 * Expand a regular expression pattern to include unicode variants
11052 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
11053 *
11054 * Issue:
11055 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
11056 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
11057 *
11058 * İIJ = IIJ = ⅡJ
11059 *
11060 * 1/2/4
11061 */
11062 const getPattern = (str) => {
11063 initialize();
11064 str = asciifold(str);
11065 let pattern = '';
11066 let sequences = [new Sequence()];
11067 for (let i = 0; i < str.length; i++) {
11068 let substr = str.substring(i);
11069 let match = substr.match(multi_char_reg);
11070 const char = str.substring(i, i + 1);
11071 const match_str = match ? match[0] : null;
11072 // loop through sequences
11073 // add either the char or multi_match
11074 let overlapping = [];
11075 let added_types = new Set();
11076 for (const sequence of sequences) {
11077 const last_piece = sequence.last();
11078 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
11079 // if we have a multi match
11080 if (match_str) {
11081 const len = match_str.length;
11082 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
11083 added_types.add('1');
11084 }
11085 else {
11086 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
11087 added_types.add('2');
11088 }
11089 }
11090 else if (match_str) {
11091 let clone = sequence.clone(i, last_piece);
11092 const len = match_str.length;
11093 clone.add({ start: i, end: i + len, length: len, substr: match_str });
11094 overlapping.push(clone);
11095 }
11096 else {
11097 // don't add char
11098 // adding would create invalid patterns: 234 => [2,34,4]
11099 added_types.add('3');
11100 }
11101 }
11102 // if we have overlapping
11103 if (overlapping.length > 0) {
11104 // ['ii','iii'] before ['i','i','iii']
11105 overlapping = overlapping.sort((a, b) => {
11106 return a.length() - b.length();
11107 });
11108 for (let clone of overlapping) {
11109 // don't add if we already have an equivalent sequence
11110 if (inSequences(clone, sequences)) {
11111 continue;
11112 }
11113 sequences.push(clone);
11114 }
11115 continue;
11116 }
11117 // if we haven't done anything unique
11118 // clean up the patterns
11119 // helps keep patterns smaller
11120 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
11121 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
11122 pattern += sequencesToPattern(sequences, false);
11123 let new_seq = new Sequence();
11124 const old_seq = sequences[0];
11125 if (old_seq) {
11126 new_seq.add(old_seq.last());
11127 }
11128 sequences = [new_seq];
11129 }
11130 }
11131 pattern += sequencesToPattern(sequences, true);
11132 return pattern;
11133 };
11134
11135 //# sourceMappingURL=index.js.map
11136
11137 /***/ }),
11138
11139 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js":
11140 /*!*******************************************************************!*\
11141 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
11142 \*******************************************************************/
11143 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11144
11145 "use strict";
11146 __webpack_require__.r(__webpack_exports__);
11147 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11148 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
11149 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
11150 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
11151 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
11152 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
11153 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
11154 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
11155 /* harmony export */ });
11156 /**
11157 * Convert array of strings to a regular expression
11158 * ex ['ab','a'] => (?:ab|a)
11159 * ex ['a','b'] => [ab]
11160 */
11161 const arrayToPattern = (chars) => {
11162 chars = chars.filter(Boolean);
11163 if (chars.length < 2) {
11164 return chars[0] || '';
11165 }
11166 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
11167 };
11168 const sequencePattern = (array) => {
11169 if (!hasDuplicates(array)) {
11170 return array.join('');
11171 }
11172 let pattern = '';
11173 let prev_char_count = 0;
11174 const prev_pattern = () => {
11175 if (prev_char_count > 1) {
11176 pattern += '{' + prev_char_count + '}';
11177 }
11178 };
11179 array.forEach((char, i) => {
11180 if (char === array[i - 1]) {
11181 prev_char_count++;
11182 return;
11183 }
11184 prev_pattern();
11185 pattern += char;
11186 prev_char_count = 1;
11187 });
11188 prev_pattern();
11189 return pattern;
11190 };
11191 /**
11192 * Convert array of strings to a regular expression
11193 * ex ['ab','a'] => (?:ab|a)
11194 * ex ['a','b'] => [ab]
11195 */
11196 const setToPattern = (chars) => {
11197 let array = Array.from(chars);
11198 return arrayToPattern(array);
11199 };
11200 /**
11201 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
11202 */
11203 const hasDuplicates = (array) => {
11204 return (new Set(array)).size !== array.length;
11205 };
11206 /**
11207 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
11208 */
11209 const escape_regex = (str) => {
11210 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
11211 };
11212 /**
11213 * Return the max length of array values
11214 */
11215 const maxValueLength = (array) => {
11216 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
11217 };
11218 const unicodeLength = (str) => {
11219 return Array.from(str).length;
11220 };
11221 //# sourceMappingURL=regex.js.map
11222
11223 /***/ }),
11224
11225 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js":
11226 /*!*********************************************************************!*\
11227 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
11228 \*********************************************************************/
11229 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11230
11231 "use strict";
11232 __webpack_require__.r(__webpack_exports__);
11233 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11234 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
11235 /* harmony export */ });
11236 /**
11237 * Get all possible combinations of substrings that add up to the given string
11238 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
11239 */
11240 const allSubstrings = (input) => {
11241 if (input.length === 1)
11242 return [[input]];
11243 let result = [];
11244 const start = input.substring(1);
11245 const suba = allSubstrings(start);
11246 suba.forEach(function (subresult) {
11247 let tmp = subresult.slice(0);
11248 tmp[0] = input.charAt(0) + tmp[0];
11249 result.push(tmp);
11250 tmp = subresult.slice(0);
11251 tmp.unshift(input.charAt(0));
11252 result.push(tmp);
11253 });
11254 return result;
11255 };
11256 //# sourceMappingURL=strings.js.map
11257
11258 /***/ }),
11259
11260 /***/ "./node_modules/tom-select/dist/esm/constants.js":
11261 /*!*******************************************************!*\
11262 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
11263 \*******************************************************/
11264 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11265
11266 "use strict";
11267 __webpack_require__.r(__webpack_exports__);
11268 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11269 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
11270 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
11271 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
11272 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
11273 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
11274 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
11275 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
11276 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
11277 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
11278 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
11279 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
11280 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
11281 /* harmony export */ });
11282 const KEY_A = 65;
11283 const KEY_RETURN = 13;
11284 const KEY_ESC = 27;
11285 const KEY_LEFT = 37;
11286 const KEY_UP = 38;
11287 const KEY_RIGHT = 39;
11288 const KEY_DOWN = 40;
11289 const KEY_BACKSPACE = 8;
11290 const KEY_DELETE = 46;
11291 const KEY_TAB = 9;
11292 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
11293 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
11294 //# sourceMappingURL=constants.js.map
11295
11296 /***/ }),
11297
11298 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js":
11299 /*!***************************************************************!*\
11300 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
11301 \***************************************************************/
11302 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11303
11304 "use strict";
11305 __webpack_require__.r(__webpack_exports__);
11306 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11307 /* harmony export */ highlight: () => (/* binding */ highlight),
11308 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
11309 /* harmony export */ });
11310 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
11311 /**
11312 * highlight v3 | MIT license | Johann Burkard <[email protected]>
11313 * Highlights arbitrary terms in a node.
11314 *
11315 * - Modified by Marshal <[email protected]> 2011-6-24 (added regex)
11316 * - Modified by Brian Reavis <[email protected]> 2012-8-27 (cleanup)
11317 */
11318
11319 const highlight = (element, regex) => {
11320 if (regex === null)
11321 return;
11322 // convet string to regex
11323 if (typeof regex === 'string') {
11324 if (!regex.length)
11325 return;
11326 regex = new RegExp(regex, 'i');
11327 }
11328 // Wrap matching part of text node with highlighting <span>, e.g.
11329 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
11330 const highlightText = (node) => {
11331 var match = node.data.match(regex);
11332 if (match && node.data.length > 0) {
11333 var spannode = document.createElement('span');
11334 spannode.className = 'highlight';
11335 var middlebit = node.splitText(match.index);
11336 middlebit.splitText(match[0].length);
11337 var middleclone = middlebit.cloneNode(true);
11338 spannode.appendChild(middleclone);
11339 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
11340 return 1;
11341 }
11342 return 0;
11343 };
11344 // Recurse element node, looking for child text nodes to highlight, unless element
11345 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
11346 const highlightChildren = (node) => {
11347 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
11348 Array.from(node.childNodes).forEach(element => {
11349 highlightRecursive(element);
11350 });
11351 }
11352 };
11353 const highlightRecursive = (node) => {
11354 if (node.nodeType === 3) {
11355 return highlightText(node);
11356 }
11357 highlightChildren(node);
11358 return 0;
11359 };
11360 highlightRecursive(element);
11361 };
11362 /**
11363 * removeHighlight fn copied from highlight v5 and
11364 * edited to remove with(), pass js strict mode, and use without jquery
11365 */
11366 const removeHighlight = (el) => {
11367 var elements = el.querySelectorAll("span.highlight");
11368 Array.prototype.forEach.call(elements, function (el) {
11369 var parent = el.parentNode;
11370 parent.replaceChild(el.firstChild, el);
11371 parent.normalize();
11372 });
11373 };
11374 //# sourceMappingURL=highlight.js.map
11375
11376 /***/ }),
11377
11378 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js":
11379 /*!****************************************************************!*\
11380 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
11381 \****************************************************************/
11382 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11383
11384 "use strict";
11385 __webpack_require__.r(__webpack_exports__);
11386 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11387 /* harmony export */ "default": () => (/* binding */ MicroEvent)
11388 /* harmony export */ });
11389 /**
11390 * MicroEvent - to make any js object an event emitter
11391 *
11392 * - pure javascript - server compatible, browser compatible
11393 * - dont rely on the browser doms
11394 * - super simple - you get it immediatly, no mistery, no magic involved
11395 *
11396 * @author Jerome Etienne (https://github.com/jeromeetienne)
11397 */
11398 /**
11399 * Execute callback for each event in space separated list of event names
11400 *
11401 */
11402 function forEvents(events, callback) {
11403 events.split(/\s+/).forEach((event) => {
11404 callback(event);
11405 });
11406 }
11407 class MicroEvent {
11408 constructor() {
11409 this._events = {};
11410 }
11411 on(events, fct) {
11412 forEvents(events, (event) => {
11413 const event_array = this._events[event] || [];
11414 event_array.push(fct);
11415 this._events[event] = event_array;
11416 });
11417 }
11418 off(events, fct) {
11419 var n = arguments.length;
11420 if (n === 0) {
11421 this._events = {};
11422 return;
11423 }
11424 forEvents(events, (event) => {
11425 if (n === 1) {
11426 delete this._events[event];
11427 return;
11428 }
11429 const event_array = this._events[event];
11430 if (event_array === undefined)
11431 return;
11432 event_array.splice(event_array.indexOf(fct), 1);
11433 this._events[event] = event_array;
11434 });
11435 }
11436 trigger(events, ...args) {
11437 var self = this;
11438 forEvents(events, (event) => {
11439 const event_array = self._events[event];
11440 if (event_array === undefined)
11441 return;
11442 event_array.forEach(fct => {
11443 fct.apply(self, args);
11444 });
11445 });
11446 }
11447 }
11448 ;
11449 //# sourceMappingURL=microevent.js.map
11450
11451 /***/ }),
11452
11453 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js":
11454 /*!*****************************************************************!*\
11455 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
11456 \*****************************************************************/
11457 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11458
11459 "use strict";
11460 __webpack_require__.r(__webpack_exports__);
11461 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11462 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
11463 /* harmony export */ });
11464 /**
11465 * microplugin.js
11466 * Copyright (c) 2013 Brian Reavis & contributors
11467 *
11468 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
11469 * file except in compliance with the License. You may obtain a copy of the License at:
11470 * http://www.apache.org/licenses/LICENSE-2.0
11471 *
11472 * Unless required by applicable law or agreed to in writing, software distributed under
11473 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11474 * ANY KIND, either express or implied. See the License for the specific language
11475 * governing permissions and limitations under the License.
11476 *
11477 * @author Brian Reavis <[email protected]>
11478 */
11479 function MicroPlugin(Interface) {
11480 Interface.plugins = {};
11481 return class extends Interface {
11482 constructor() {
11483 super(...arguments);
11484 this.plugins = {
11485 names: [],
11486 settings: {},
11487 requested: {},
11488 loaded: {}
11489 };
11490 }
11491 /**
11492 * Registers a plugin.
11493 *
11494 * @param {function} fn
11495 */
11496 static define(name, fn) {
11497 Interface.plugins[name] = {
11498 'name': name,
11499 'fn': fn
11500 };
11501 }
11502 /**
11503 * Initializes the listed plugins (with options).
11504 * Acceptable formats:
11505 *
11506 * List (without options):
11507 * ['a', 'b', 'c']
11508 *
11509 * List (with options):
11510 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
11511 *
11512 * Hash (with options):
11513 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
11514 *
11515 * @param {array|object} plugins
11516 */
11517 initializePlugins(plugins) {
11518 var key, name;
11519 const self = this;
11520 const queue = [];
11521 if (Array.isArray(plugins)) {
11522 plugins.forEach((plugin) => {
11523 if (typeof plugin === 'string') {
11524 queue.push(plugin);
11525 }
11526 else {
11527 self.plugins.settings[plugin.name] = plugin.options;
11528 queue.push(plugin.name);
11529 }
11530 });
11531 }
11532 else if (plugins) {
11533 for (key in plugins) {
11534 if (plugins.hasOwnProperty(key)) {
11535 self.plugins.settings[key] = plugins[key];
11536 queue.push(key);
11537 }
11538 }
11539 }
11540 while (name = queue.shift()) {
11541 self.require(name);
11542 }
11543 }
11544 loadPlugin(name) {
11545 var self = this;
11546 var plugins = self.plugins;
11547 var plugin = Interface.plugins[name];
11548 if (!Interface.plugins.hasOwnProperty(name)) {
11549 throw new Error('Unable to find "' + name + '" plugin');
11550 }
11551 plugins.requested[name] = true;
11552 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
11553 plugins.names.push(name);
11554 }
11555 /**
11556 * Initializes a plugin.
11557 *
11558 */
11559 require(name) {
11560 var self = this;
11561 var plugins = self.plugins;
11562 if (!self.plugins.loaded.hasOwnProperty(name)) {
11563 if (plugins.requested[name]) {
11564 throw new Error('Plugin has circular dependency ("' + name + '")');
11565 }
11566 self.loadPlugin(name);
11567 }
11568 return plugins.loaded[name];
11569 }
11570 };
11571 }
11572 //# sourceMappingURL=microplugin.js.map
11573
11574 /***/ }),
11575
11576 /***/ "./node_modules/tom-select/dist/esm/defaults.js":
11577 /*!******************************************************!*\
11578 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
11579 \******************************************************/
11580 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11581
11582 "use strict";
11583 __webpack_require__.r(__webpack_exports__);
11584 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11585 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11586 /* harmony export */ });
11587 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
11588 options: [],
11589 optgroups: [],
11590 plugins: [],
11591 delimiter: ',',
11592 splitOn: null, // regexp or string for splitting up values from a paste command
11593 persist: true,
11594 diacritics: true,
11595 create: null,
11596 createOnBlur: false,
11597 createFilter: null,
11598 highlight: true,
11599 openOnFocus: true,
11600 shouldOpen: null,
11601 maxOptions: 50,
11602 maxItems: null,
11603 hideSelected: null,
11604 duplicates: false,
11605 addPrecedence: false,
11606 selectOnTab: false,
11607 preload: null,
11608 allowEmptyOption: false,
11609 //closeAfterSelect: false,
11610 refreshThrottle: 300,
11611 loadThrottle: 300,
11612 loadingClass: 'loading',
11613 dataAttr: null, //'data-data',
11614 optgroupField: 'optgroup',
11615 valueField: 'value',
11616 labelField: 'text',
11617 disabledField: 'disabled',
11618 optgroupLabelField: 'label',
11619 optgroupValueField: 'value',
11620 lockOptgroupOrder: false,
11621 sortField: '$order',
11622 searchField: ['text'],
11623 searchConjunction: 'and',
11624 mode: null,
11625 wrapperClass: 'ts-wrapper',
11626 controlClass: 'ts-control',
11627 dropdownClass: 'ts-dropdown',
11628 dropdownContentClass: 'ts-dropdown-content',
11629 itemClass: 'item',
11630 optionClass: 'option',
11631 dropdownParent: null,
11632 controlInput: '<input type="text" autocomplete="off" size="1" />',
11633 copyClassesToDropdown: false,
11634 placeholder: null,
11635 hidePlaceholder: null,
11636 shouldLoad: function (query) {
11637 return query.length > 0;
11638 },
11639 /*
11640 load : null, // function(query, callback) { ... }
11641 score : null, // function(search) { ... }
11642 onInitialize : null, // function() { ... }
11643 onChange : null, // function(value) { ... }
11644 onItemAdd : null, // function(value, $item) { ... }
11645 onItemRemove : null, // function(value) { ... }
11646 onClear : null, // function() { ... }
11647 onOptionAdd : null, // function(value, data) { ... }
11648 onOptionRemove : null, // function(value) { ... }
11649 onOptionClear : null, // function() { ... }
11650 onOptionGroupAdd : null, // function(id, data) { ... }
11651 onOptionGroupRemove : null, // function(id) { ... }
11652 onOptionGroupClear : null, // function() { ... }
11653 onDropdownOpen : null, // function(dropdown) { ... }
11654 onDropdownClose : null, // function(dropdown) { ... }
11655 onType : null, // function(str) { ... }
11656 onDelete : null, // function(values) { ... }
11657 */
11658 render: {
11659 /*
11660 item: null,
11661 optgroup: null,
11662 optgroup_header: null,
11663 option: null,
11664 option_create: null
11665 */
11666 }
11667 });
11668 //# sourceMappingURL=defaults.js.map
11669
11670 /***/ }),
11671
11672 /***/ "./node_modules/tom-select/dist/esm/getSettings.js":
11673 /*!*********************************************************!*\
11674 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
11675 \*********************************************************/
11676 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11677
11678 "use strict";
11679 __webpack_require__.r(__webpack_exports__);
11680 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11681 /* harmony export */ "default": () => (/* binding */ getSettings)
11682 /* harmony export */ });
11683 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
11684 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
11685
11686
11687 function getSettings(input, settings_user) {
11688 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
11689 var attr_data = settings.dataAttr;
11690 var field_label = settings.labelField;
11691 var field_value = settings.valueField;
11692 var field_disabled = settings.disabledField;
11693 var field_optgroup = settings.optgroupField;
11694 var field_optgroup_label = settings.optgroupLabelField;
11695 var field_optgroup_value = settings.optgroupValueField;
11696 var tag_name = input.tagName.toLowerCase();
11697 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
11698 if (!placeholder && !settings.allowEmptyOption) {
11699 let option = input.querySelector('option[value=""]');
11700 if (option) {
11701 placeholder = option.textContent;
11702 }
11703 }
11704 var settings_element = {
11705 placeholder: placeholder,
11706 options: [],
11707 optgroups: [],
11708 items: [],
11709 maxItems: null,
11710 };
11711 /**
11712 * Initialize from a <select> element.
11713 *
11714 */
11715 var init_select = () => {
11716 var tagName;
11717 var options = settings_element.options;
11718 var optionsMap = {};
11719 var group_count = 1;
11720 let $order = 0;
11721 var readData = (el) => {
11722 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
11723 var json = attr_data && data[attr_data];
11724 if (typeof json === 'string' && json.length) {
11725 data = Object.assign(data, JSON.parse(json));
11726 }
11727 return data;
11728 };
11729 var addOption = (option, group) => {
11730 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
11731 if (value == null)
11732 return;
11733 if (!value && !settings.allowEmptyOption)
11734 return;
11735 // if the option already exists, it's probably been
11736 // duplicated in another optgroup. in this case, push
11737 // the current group to the "optgroup" property on the
11738 // existing option so that it's rendered in both places.
11739 if (optionsMap.hasOwnProperty(value)) {
11740 if (group) {
11741 var arr = optionsMap[value][field_optgroup];
11742 if (!arr) {
11743 optionsMap[value][field_optgroup] = group;
11744 }
11745 else if (!Array.isArray(arr)) {
11746 optionsMap[value][field_optgroup] = [arr, group];
11747 }
11748 else {
11749 arr.push(group);
11750 }
11751 }
11752 }
11753 else {
11754 var option_data = readData(option);
11755 option_data[field_label] = option_data[field_label] || option.textContent;
11756 option_data[field_value] = option_data[field_value] || value;
11757 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
11758 option_data[field_optgroup] = option_data[field_optgroup] || group;
11759 option_data.$option = option;
11760 option_data.$order = option_data.$order || ++$order;
11761 optionsMap[value] = option_data;
11762 options.push(option_data);
11763 }
11764 if (option.selected) {
11765 settings_element.items.push(value);
11766 }
11767 };
11768 var addGroup = (optgroup) => {
11769 var id, optgroup_data;
11770 optgroup_data = readData(optgroup);
11771 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
11772 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
11773 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
11774 optgroup_data.$order = optgroup_data.$order || ++$order;
11775 settings_element.optgroups.push(optgroup_data);
11776 id = optgroup_data[field_optgroup_value];
11777 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
11778 addOption(option, id);
11779 });
11780 };
11781 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
11782 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
11783 tagName = child.tagName.toLowerCase();
11784 if (tagName === 'optgroup') {
11785 addGroup(child);
11786 }
11787 else if (tagName === 'option') {
11788 addOption(child);
11789 }
11790 });
11791 };
11792 /**
11793 * Initialize from a <input type="text"> element.
11794 *
11795 */
11796 var init_textbox = () => {
11797 const data_raw = input.getAttribute(attr_data);
11798 if (!data_raw) {
11799 var value = input.value.trim() || '';
11800 if (!settings.allowEmptyOption && !value.length)
11801 return;
11802 const values = value.split(settings.delimiter);
11803 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
11804 const option = {};
11805 option[field_label] = value;
11806 option[field_value] = value;
11807 settings_element.options.push(option);
11808 });
11809 settings_element.items = values;
11810 }
11811 else {
11812 settings_element.options = JSON.parse(data_raw);
11813 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
11814 settings_element.items.push(opt[field_value]);
11815 });
11816 }
11817 };
11818 if (tag_name === 'select') {
11819 init_select();
11820 }
11821 else {
11822 init_textbox();
11823 }
11824 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
11825 }
11826 ;
11827 //# sourceMappingURL=getSettings.js.map
11828
11829 /***/ }),
11830
11831 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js":
11832 /*!***************************************************************************!*\
11833 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
11834 \***************************************************************************/
11835 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
11836
11837 "use strict";
11838 __webpack_require__.r(__webpack_exports__);
11839 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11840 /* harmony export */ "default": () => (/* binding */ plugin)
11841 /* harmony export */ });
11842 /**
11843 * Tom Select v2.4.3
11844 * Licensed under the Apache License, Version 2.0 (the "License");
11845 */
11846
11847 /**
11848 * Converts a scalar to its best string representation
11849 * for hash keys and HTML attribute values.
11850 *
11851 * Transformations:
11852 * 'str' -> 'str'
11853 * null -> ''
11854 * undefined -> ''
11855 * true -> '1'
11856 * false -> '0'
11857 * 0 -> '0'
11858 * 1 -> '1'
11859 *
11860 */
11861
11862 /**
11863 * Iterates over arrays and hashes.
11864 *
11865 * ```
11866 * iterate(this.items, function(item, id) {
11867 * // invoked for each item
11868 * });
11869 * ```
11870 *
11871 */
11872 const iterate = (object, callback) => {
11873 if (Array.isArray(object)) {
11874 object.forEach(callback);
11875 } else {
11876 for (var key in object) {
11877 if (object.hasOwnProperty(key)) {
11878 callback(object[key], key);
11879 }
11880 }
11881 }
11882 };
11883
11884 /**
11885 * Remove css classes
11886 *
11887 */
11888 const removeClasses = (elmts, ...classes) => {
11889 var norm_classes = classesArray(classes);
11890 elmts = castAsArray(elmts);
11891 elmts.map(el => {
11892 norm_classes.map(cls => {
11893 el.classList.remove(cls);
11894 });
11895 });
11896 };
11897
11898 /**
11899 * Return arguments
11900 *
11901 */
11902 const classesArray = args => {
11903 var classes = [];
11904 iterate(args, _classes => {
11905 if (typeof _classes === 'string') {
11906 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
11907 }
11908 if (Array.isArray(_classes)) {
11909 classes = classes.concat(_classes);
11910 }
11911 });
11912 return classes.filter(Boolean);
11913 };
11914
11915 /**
11916 * Create an array from arg if it's not already an array
11917 *
11918 */
11919 const castAsArray = arg => {
11920 if (!Array.isArray(arg)) {
11921 arg = [arg];
11922 }
11923 return arg;
11924 };
11925
11926 /**
11927 * Get the index of an element amongst sibling nodes of the same type
11928 *
11929 */
11930 const nodeIndex = (el, amongst) => {
11931 if (!el) return -1;
11932 amongst = amongst || el.nodeName;
11933 var i = 0;
11934 while (el = el.previousElementSibling) {
11935 if (el.matches(amongst)) {
11936 i++;
11937 }
11938 }
11939 return i;
11940 };
11941
11942 /**
11943 * Plugin: "dropdown_input" (Tom Select)
11944 * Copyright (c) contributors
11945 *
11946 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
11947 * file except in compliance with the License. You may obtain a copy of the License at:
11948 * http://www.apache.org/licenses/LICENSE-2.0
11949 *
11950 * Unless required by applicable law or agreed to in writing, software distributed under
11951 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11952 * ANY KIND, either express or implied. See the License for the specific language
11953 * governing permissions and limitations under the License.
11954 *
11955 */
11956
11957 function plugin () {
11958 var self = this;
11959
11960 /**
11961 * Moves the caret to the specified index.
11962 *
11963 * The input must be moved by leaving it in place and moving the
11964 * siblings, due to the fact that focus cannot be restored once lost
11965 * on mobile webkit devices
11966 *
11967 */
11968 self.hook('instead', 'setCaret', new_pos => {
11969 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
11970 new_pos = self.items.length;
11971 } else {
11972 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
11973 if (new_pos != self.caretPos && !self.isPending) {
11974 self.controlChildren().forEach((child, j) => {
11975 if (j < new_pos) {
11976 self.control_input.insertAdjacentElement('beforebegin', child);
11977 } else {
11978 self.control.appendChild(child);
11979 }
11980 });
11981 }
11982 }
11983 self.caretPos = new_pos;
11984 });
11985 self.hook('instead', 'moveCaret', direction => {
11986 if (!self.isFocused) return;
11987
11988 // move caret before or after selected items
11989 const last_active = self.getLastActive(direction);
11990 if (last_active) {
11991 const idx = nodeIndex(last_active);
11992 self.setCaret(direction > 0 ? idx + 1 : idx);
11993 self.setActiveItem();
11994 removeClasses(last_active, 'last-active');
11995
11996 // move caret left or right of current position
11997 } else {
11998 self.setCaret(self.caretPos + direction);
11999 }
12000 });
12001 }
12002
12003
12004 //# sourceMappingURL=plugin.js.map
12005
12006
12007 /***/ }),
12008
12009 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js":
12010 /*!****************************************************************************!*\
12011 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
12012 \****************************************************************************/
12013 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12014
12015 "use strict";
12016 __webpack_require__.r(__webpack_exports__);
12017 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12018 /* harmony export */ "default": () => (/* binding */ plugin)
12019 /* harmony export */ });
12020 /**
12021 * Tom Select v2.4.3
12022 * Licensed under the Apache License, Version 2.0 (the "License");
12023 */
12024
12025 /**
12026 * Converts a scalar to its best string representation
12027 * for hash keys and HTML attribute values.
12028 *
12029 * Transformations:
12030 * 'str' -> 'str'
12031 * null -> ''
12032 * undefined -> ''
12033 * true -> '1'
12034 * false -> '0'
12035 * 0 -> '0'
12036 * 1 -> '1'
12037 *
12038 */
12039
12040 /**
12041 * Add event helper
12042 *
12043 */
12044 const addEvent = (target, type, callback, options) => {
12045 target.addEventListener(type, callback, options);
12046 };
12047
12048 /**
12049 * Plugin: "change_listener" (Tom Select)
12050 * Copyright (c) contributors
12051 *
12052 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12053 * file except in compliance with the License. You may obtain a copy of the License at:
12054 * http://www.apache.org/licenses/LICENSE-2.0
12055 *
12056 * Unless required by applicable law or agreed to in writing, software distributed under
12057 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12058 * ANY KIND, either express or implied. See the License for the specific language
12059 * governing permissions and limitations under the License.
12060 *
12061 */
12062
12063 function plugin () {
12064 addEvent(this.input, 'change', () => {
12065 this.sync();
12066 });
12067 }
12068
12069
12070 //# sourceMappingURL=plugin.js.map
12071
12072
12073 /***/ }),
12074
12075 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js":
12076 /*!*****************************************************************************!*\
12077 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
12078 \*****************************************************************************/
12079 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12080
12081 "use strict";
12082 __webpack_require__.r(__webpack_exports__);
12083 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12084 /* harmony export */ "default": () => (/* binding */ plugin)
12085 /* harmony export */ });
12086 /**
12087 * Tom Select v2.4.3
12088 * Licensed under the Apache License, Version 2.0 (the "License");
12089 */
12090
12091 /**
12092 * Converts a scalar to its best string representation
12093 * for hash keys and HTML attribute values.
12094 *
12095 * Transformations:
12096 * 'str' -> 'str'
12097 * null -> ''
12098 * undefined -> ''
12099 * true -> '1'
12100 * false -> '0'
12101 * 0 -> '0'
12102 * 1 -> '1'
12103 *
12104 */
12105 const hash_key = value => {
12106 if (typeof value === 'undefined' || value === null) return null;
12107 return get_hash(value);
12108 };
12109 const get_hash = value => {
12110 if (typeof value === 'boolean') return value ? '1' : '0';
12111 return value + '';
12112 };
12113
12114 /**
12115 * Prevent default
12116 *
12117 */
12118 const preventDefault = (evt, stop = false) => {
12119 if (evt) {
12120 evt.preventDefault();
12121 if (stop) {
12122 evt.stopPropagation();
12123 }
12124 }
12125 };
12126
12127 /**
12128 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
12129 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
12130 *
12131 * param query should be {}
12132 */
12133 const getDom = query => {
12134 if (query.jquery) {
12135 return query[0];
12136 }
12137 if (query instanceof HTMLElement) {
12138 return query;
12139 }
12140 if (isHtmlString(query)) {
12141 var tpl = document.createElement('template');
12142 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
12143 return tpl.content.firstChild;
12144 }
12145 return document.querySelector(query);
12146 };
12147 const isHtmlString = arg => {
12148 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
12149 return true;
12150 }
12151 return false;
12152 };
12153
12154 /**
12155 * Plugin: "checkbox_options" (Tom Select)
12156 * Copyright (c) contributors
12157 *
12158 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12159 * file except in compliance with the License. You may obtain a copy of the License at:
12160 * http://www.apache.org/licenses/LICENSE-2.0
12161 *
12162 * Unless required by applicable law or agreed to in writing, software distributed under
12163 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12164 * ANY KIND, either express or implied. See the License for the specific language
12165 * governing permissions and limitations under the License.
12166 *
12167 */
12168
12169 function plugin (userOptions) {
12170 var self = this;
12171 var orig_onOptionSelect = self.onOptionSelect;
12172 self.settings.hideSelected = false;
12173 const cbOptions = Object.assign({
12174 // so that the user may add different ones as well
12175 className: "tomselect-checkbox",
12176 // the following default to the historic plugin's values
12177 checkedClassNames: undefined,
12178 uncheckedClassNames: undefined
12179 }, userOptions);
12180 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
12181 if (toCheck) {
12182 checkbox.checked = true;
12183 if (cbOptions.uncheckedClassNames) {
12184 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
12185 }
12186 if (cbOptions.checkedClassNames) {
12187 checkbox.classList.add(...cbOptions.checkedClassNames);
12188 }
12189 } else {
12190 checkbox.checked = false;
12191 if (cbOptions.checkedClassNames) {
12192 checkbox.classList.remove(...cbOptions.checkedClassNames);
12193 }
12194 if (cbOptions.uncheckedClassNames) {
12195 checkbox.classList.add(...cbOptions.uncheckedClassNames);
12196 }
12197 }
12198 };
12199
12200 // update the checkbox for an option
12201 var UpdateCheckbox = function UpdateCheckbox(option) {
12202 setTimeout(() => {
12203 var checkbox = option.querySelector('input.' + cbOptions.className);
12204 if (checkbox instanceof HTMLInputElement) {
12205 UpdateChecked(checkbox, option.classList.contains('selected'));
12206 }
12207 }, 1);
12208 };
12209
12210 // add checkbox to option template
12211 self.hook('after', 'setupTemplates', () => {
12212 var orig_render_option = self.settings.render.option;
12213 self.settings.render.option = (data, escape_html) => {
12214 var rendered = getDom(orig_render_option.call(self, data, escape_html));
12215 var checkbox = document.createElement('input');
12216 if (cbOptions.className) {
12217 checkbox.classList.add(cbOptions.className);
12218 }
12219 checkbox.addEventListener('click', function (evt) {
12220 preventDefault(evt);
12221 });
12222 checkbox.type = 'checkbox';
12223 const hashed = hash_key(data[self.settings.valueField]);
12224 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
12225 rendered.prepend(checkbox);
12226 return rendered;
12227 };
12228 });
12229
12230 // uncheck when item removed
12231 self.on('item_remove', value => {
12232 var option = self.getOption(value);
12233 if (option) {
12234 // if dropdown hasn't been opened yet, the option won't exist
12235 option.classList.remove('selected'); // selected class won't be removed yet
12236 UpdateCheckbox(option);
12237 }
12238 });
12239
12240 // check when item added
12241 self.on('item_add', value => {
12242 var option = self.getOption(value);
12243 if (option) {
12244 // if dropdown hasn't been opened yet, the option won't exist
12245 UpdateCheckbox(option);
12246 }
12247 });
12248
12249 // remove items when selected option is clicked
12250 self.hook('instead', 'onOptionSelect', (evt, option) => {
12251 if (option.classList.contains('selected')) {
12252 option.classList.remove('selected');
12253 self.removeItem(option.dataset.value);
12254 self.refreshOptions();
12255 preventDefault(evt, true);
12256 return;
12257 }
12258 orig_onOptionSelect.call(self, evt, option);
12259 UpdateCheckbox(option);
12260 });
12261 }
12262
12263
12264 //# sourceMappingURL=plugin.js.map
12265
12266
12267 /***/ }),
12268
12269 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js":
12270 /*!*************************************************************************!*\
12271 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
12272 \*************************************************************************/
12273 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12274
12275 "use strict";
12276 __webpack_require__.r(__webpack_exports__);
12277 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12278 /* harmony export */ "default": () => (/* binding */ plugin)
12279 /* harmony export */ });
12280 /**
12281 * Tom Select v2.4.3
12282 * Licensed under the Apache License, Version 2.0 (the "License");
12283 */
12284
12285 /**
12286 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
12287 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
12288 *
12289 * param query should be {}
12290 */
12291 const getDom = query => {
12292 if (query.jquery) {
12293 return query[0];
12294 }
12295 if (query instanceof HTMLElement) {
12296 return query;
12297 }
12298 if (isHtmlString(query)) {
12299 var tpl = document.createElement('template');
12300 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
12301 return tpl.content.firstChild;
12302 }
12303 return document.querySelector(query);
12304 };
12305 const isHtmlString = arg => {
12306 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
12307 return true;
12308 }
12309 return false;
12310 };
12311
12312 /**
12313 * Plugin: "dropdown_header" (Tom Select)
12314 * Copyright (c) contributors
12315 *
12316 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12317 * file except in compliance with the License. You may obtain a copy of the License at:
12318 * http://www.apache.org/licenses/LICENSE-2.0
12319 *
12320 * Unless required by applicable law or agreed to in writing, software distributed under
12321 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12322 * ANY KIND, either express or implied. See the License for the specific language
12323 * governing permissions and limitations under the License.
12324 *
12325 */
12326
12327 function plugin (userOptions) {
12328 const self = this;
12329 const options = Object.assign({
12330 className: 'clear-button',
12331 title: 'Clear All',
12332 html: data => {
12333 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
12334 }
12335 }, userOptions);
12336 self.on('initialize', () => {
12337 var button = getDom(options.html(options));
12338 button.addEventListener('click', evt => {
12339 if (self.isLocked) return;
12340 self.clear();
12341 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
12342 self.addItem('');
12343 }
12344 evt.preventDefault();
12345 evt.stopPropagation();
12346 });
12347 self.control.appendChild(button);
12348 });
12349 }
12350
12351
12352 //# sourceMappingURL=plugin.js.map
12353
12354
12355 /***/ }),
12356
12357 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js":
12358 /*!**********************************************************************!*\
12359 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
12360 \**********************************************************************/
12361 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12362
12363 "use strict";
12364 __webpack_require__.r(__webpack_exports__);
12365 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12366 /* harmony export */ "default": () => (/* binding */ plugin)
12367 /* harmony export */ });
12368 /**
12369 * Tom Select v2.4.3
12370 * Licensed under the Apache License, Version 2.0 (the "License");
12371 */
12372
12373 /**
12374 * Converts a scalar to its best string representation
12375 * for hash keys and HTML attribute values.
12376 *
12377 * Transformations:
12378 * 'str' -> 'str'
12379 * null -> ''
12380 * undefined -> ''
12381 * true -> '1'
12382 * false -> '0'
12383 * 0 -> '0'
12384 * 1 -> '1'
12385 *
12386 */
12387
12388 /**
12389 * Prevent default
12390 *
12391 */
12392 const preventDefault = (evt, stop = false) => {
12393 if (evt) {
12394 evt.preventDefault();
12395 if (stop) {
12396 evt.stopPropagation();
12397 }
12398 }
12399 };
12400
12401 /**
12402 * Add event helper
12403 *
12404 */
12405 const addEvent = (target, type, callback, options) => {
12406 target.addEventListener(type, callback, options);
12407 };
12408
12409 /**
12410 * Iterates over arrays and hashes.
12411 *
12412 * ```
12413 * iterate(this.items, function(item, id) {
12414 * // invoked for each item
12415 * });
12416 * ```
12417 *
12418 */
12419 const iterate = (object, callback) => {
12420 if (Array.isArray(object)) {
12421 object.forEach(callback);
12422 } else {
12423 for (var key in object) {
12424 if (object.hasOwnProperty(key)) {
12425 callback(object[key], key);
12426 }
12427 }
12428 }
12429 };
12430
12431 /**
12432 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
12433 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
12434 *
12435 * param query should be {}
12436 */
12437 const getDom = query => {
12438 if (query.jquery) {
12439 return query[0];
12440 }
12441 if (query instanceof HTMLElement) {
12442 return query;
12443 }
12444 if (isHtmlString(query)) {
12445 var tpl = document.createElement('template');
12446 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
12447 return tpl.content.firstChild;
12448 }
12449 return document.querySelector(query);
12450 };
12451 const isHtmlString = arg => {
12452 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
12453 return true;
12454 }
12455 return false;
12456 };
12457
12458 /**
12459 * Set attributes of an element
12460 *
12461 */
12462 const setAttr = (el, attrs) => {
12463 iterate(attrs, (val, attr) => {
12464 if (val == null) {
12465 el.removeAttribute(attr);
12466 } else {
12467 el.setAttribute(attr, '' + val);
12468 }
12469 });
12470 };
12471
12472 /**
12473 * Plugin: "drag_drop" (Tom Select)
12474 * Copyright (c) contributors
12475 *
12476 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12477 * file except in compliance with the License. You may obtain a copy of the License at:
12478 * http://www.apache.org/licenses/LICENSE-2.0
12479 *
12480 * Unless required by applicable law or agreed to in writing, software distributed under
12481 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12482 * ANY KIND, either express or implied. See the License for the specific language
12483 * governing permissions and limitations under the License.
12484 *
12485 */
12486
12487 const insertAfter = (referenceNode, newNode) => {
12488 var _referenceNode$parent;
12489 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
12490 };
12491 const insertBefore = (referenceNode, newNode) => {
12492 var _referenceNode$parent2;
12493 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
12494 };
12495 const isBefore = (referenceNode, newNode) => {
12496 do {
12497 var _newNode;
12498 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
12499 if (referenceNode == newNode) {
12500 return true;
12501 }
12502 } while (newNode && newNode.previousElementSibling);
12503 return false;
12504 };
12505 function plugin () {
12506 var self = this;
12507 if (self.settings.mode !== 'multi') return;
12508 var orig_lock = self.lock;
12509 var orig_unlock = self.unlock;
12510 let sortable = true;
12511 let drag_item;
12512
12513 /**
12514 * Add draggable attribute to item
12515 */
12516 self.hook('after', 'setupTemplates', () => {
12517 var orig_render_item = self.settings.render.item;
12518 self.settings.render.item = (data, escape) => {
12519 const item = getDom(orig_render_item.call(self, data, escape));
12520 setAttr(item, {
12521 'draggable': 'true'
12522 });
12523
12524 // prevent doc_mousedown (see tom-select.ts)
12525 const mousedown = evt => {
12526 if (!sortable) preventDefault(evt);
12527 evt.stopPropagation();
12528 };
12529 const dragStart = evt => {
12530 drag_item = item;
12531 setTimeout(() => {
12532 item.classList.add('ts-dragging');
12533 }, 0);
12534 };
12535 const dragOver = evt => {
12536 evt.preventDefault();
12537 item.classList.add('ts-drag-over');
12538 moveitem(item, drag_item);
12539 };
12540 const dragLeave = () => {
12541 item.classList.remove('ts-drag-over');
12542 };
12543 const moveitem = (targetitem, dragitem) => {
12544 if (dragitem === undefined) return;
12545 if (isBefore(dragitem, item)) {
12546 insertAfter(targetitem, dragitem);
12547 } else {
12548 insertBefore(targetitem, dragitem);
12549 }
12550 };
12551 const dragend = () => {
12552 var _drag_item;
12553 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
12554 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
12555 drag_item = undefined;
12556 var values = [];
12557 self.control.querySelectorAll(`[data-value]`).forEach(el => {
12558 if (el.dataset.value) {
12559 let value = el.dataset.value;
12560 if (value) {
12561 values.push(value);
12562 }
12563 }
12564 });
12565 self.setValue(values);
12566 };
12567 addEvent(item, 'mousedown', mousedown);
12568 addEvent(item, 'dragstart', dragStart);
12569 addEvent(item, 'dragenter', dragOver);
12570 addEvent(item, 'dragover', dragOver);
12571 addEvent(item, 'dragleave', dragLeave);
12572 addEvent(item, 'dragend', dragend);
12573 return item;
12574 };
12575 });
12576 self.hook('instead', 'lock', () => {
12577 sortable = false;
12578 return orig_lock.call(self);
12579 });
12580 self.hook('instead', 'unlock', () => {
12581 sortable = true;
12582 return orig_unlock.call(self);
12583 });
12584 }
12585
12586
12587 //# sourceMappingURL=plugin.js.map
12588
12589
12590 /***/ }),
12591
12592 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js":
12593 /*!****************************************************************************!*\
12594 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
12595 \****************************************************************************/
12596 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12597
12598 "use strict";
12599 __webpack_require__.r(__webpack_exports__);
12600 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12601 /* harmony export */ "default": () => (/* binding */ plugin)
12602 /* harmony export */ });
12603 /**
12604 * Tom Select v2.4.3
12605 * Licensed under the Apache License, Version 2.0 (the "License");
12606 */
12607
12608 /**
12609 * Converts a scalar to its best string representation
12610 * for hash keys and HTML attribute values.
12611 *
12612 * Transformations:
12613 * 'str' -> 'str'
12614 * null -> ''
12615 * undefined -> ''
12616 * true -> '1'
12617 * false -> '0'
12618 * 0 -> '0'
12619 * 1 -> '1'
12620 *
12621 */
12622
12623 /**
12624 * Prevent default
12625 *
12626 */
12627 const preventDefault = (evt, stop = false) => {
12628 if (evt) {
12629 evt.preventDefault();
12630 if (stop) {
12631 evt.stopPropagation();
12632 }
12633 }
12634 };
12635
12636 /**
12637 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
12638 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
12639 *
12640 * param query should be {}
12641 */
12642 const getDom = query => {
12643 if (query.jquery) {
12644 return query[0];
12645 }
12646 if (query instanceof HTMLElement) {
12647 return query;
12648 }
12649 if (isHtmlString(query)) {
12650 var tpl = document.createElement('template');
12651 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
12652 return tpl.content.firstChild;
12653 }
12654 return document.querySelector(query);
12655 };
12656 const isHtmlString = arg => {
12657 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
12658 return true;
12659 }
12660 return false;
12661 };
12662
12663 /**
12664 * Plugin: "dropdown_header" (Tom Select)
12665 * Copyright (c) contributors
12666 *
12667 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12668 * file except in compliance with the License. You may obtain a copy of the License at:
12669 * http://www.apache.org/licenses/LICENSE-2.0
12670 *
12671 * Unless required by applicable law or agreed to in writing, software distributed under
12672 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12673 * ANY KIND, either express or implied. See the License for the specific language
12674 * governing permissions and limitations under the License.
12675 *
12676 */
12677
12678 function plugin (userOptions) {
12679 const self = this;
12680 const options = Object.assign({
12681 title: 'Untitled',
12682 headerClass: 'dropdown-header',
12683 titleRowClass: 'dropdown-header-title',
12684 labelClass: 'dropdown-header-label',
12685 closeClass: 'dropdown-header-close',
12686 html: data => {
12687 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
12688 }
12689 }, userOptions);
12690 self.on('initialize', () => {
12691 var header = getDom(options.html(options));
12692 var close_link = header.querySelector('.' + options.closeClass);
12693 if (close_link) {
12694 close_link.addEventListener('click', evt => {
12695 preventDefault(evt, true);
12696 self.close();
12697 });
12698 }
12699 self.dropdown.insertBefore(header, self.dropdown.firstChild);
12700 });
12701 }
12702
12703
12704 //# sourceMappingURL=plugin.js.map
12705
12706
12707 /***/ }),
12708
12709 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js":
12710 /*!***************************************************************************!*\
12711 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
12712 \***************************************************************************/
12713 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12714
12715 "use strict";
12716 __webpack_require__.r(__webpack_exports__);
12717 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12718 /* harmony export */ "default": () => (/* binding */ plugin)
12719 /* harmony export */ });
12720 /**
12721 * Tom Select v2.4.3
12722 * Licensed under the Apache License, Version 2.0 (the "License");
12723 */
12724
12725 const KEY_ESC = 27;
12726 const KEY_TAB = 9;
12727 // ctrl key or apple key for ma
12728
12729 /**
12730 * Converts a scalar to its best string representation
12731 * for hash keys and HTML attribute values.
12732 *
12733 * Transformations:
12734 * 'str' -> 'str'
12735 * null -> ''
12736 * undefined -> ''
12737 * true -> '1'
12738 * false -> '0'
12739 * 0 -> '0'
12740 * 1 -> '1'
12741 *
12742 */
12743
12744 /**
12745 * Prevent default
12746 *
12747 */
12748 const preventDefault = (evt, stop = false) => {
12749 if (evt) {
12750 evt.preventDefault();
12751 if (stop) {
12752 evt.stopPropagation();
12753 }
12754 }
12755 };
12756
12757 /**
12758 * Add event helper
12759 *
12760 */
12761 const addEvent = (target, type, callback, options) => {
12762 target.addEventListener(type, callback, options);
12763 };
12764
12765 /**
12766 * Iterates over arrays and hashes.
12767 *
12768 * ```
12769 * iterate(this.items, function(item, id) {
12770 * // invoked for each item
12771 * });
12772 * ```
12773 *
12774 */
12775 const iterate = (object, callback) => {
12776 if (Array.isArray(object)) {
12777 object.forEach(callback);
12778 } else {
12779 for (var key in object) {
12780 if (object.hasOwnProperty(key)) {
12781 callback(object[key], key);
12782 }
12783 }
12784 }
12785 };
12786
12787 /**
12788 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
12789 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
12790 *
12791 * param query should be {}
12792 */
12793 const getDom = query => {
12794 if (query.jquery) {
12795 return query[0];
12796 }
12797 if (query instanceof HTMLElement) {
12798 return query;
12799 }
12800 if (isHtmlString(query)) {
12801 var tpl = document.createElement('template');
12802 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
12803 return tpl.content.firstChild;
12804 }
12805 return document.querySelector(query);
12806 };
12807 const isHtmlString = arg => {
12808 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
12809 return true;
12810 }
12811 return false;
12812 };
12813
12814 /**
12815 * Add css classes
12816 *
12817 */
12818 const addClasses = (elmts, ...classes) => {
12819 var norm_classes = classesArray(classes);
12820 elmts = castAsArray(elmts);
12821 elmts.map(el => {
12822 norm_classes.map(cls => {
12823 el.classList.add(cls);
12824 });
12825 });
12826 };
12827
12828 /**
12829 * Return arguments
12830 *
12831 */
12832 const classesArray = args => {
12833 var classes = [];
12834 iterate(args, _classes => {
12835 if (typeof _classes === 'string') {
12836 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
12837 }
12838 if (Array.isArray(_classes)) {
12839 classes = classes.concat(_classes);
12840 }
12841 });
12842 return classes.filter(Boolean);
12843 };
12844
12845 /**
12846 * Create an array from arg if it's not already an array
12847 *
12848 */
12849 const castAsArray = arg => {
12850 if (!Array.isArray(arg)) {
12851 arg = [arg];
12852 }
12853 return arg;
12854 };
12855
12856 /**
12857 * Plugin: "dropdown_input" (Tom Select)
12858 * Copyright (c) contributors
12859 *
12860 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12861 * file except in compliance with the License. You may obtain a copy of the License at:
12862 * http://www.apache.org/licenses/LICENSE-2.0
12863 *
12864 * Unless required by applicable law or agreed to in writing, software distributed under
12865 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12866 * ANY KIND, either express or implied. See the License for the specific language
12867 * governing permissions and limitations under the License.
12868 *
12869 */
12870
12871 function plugin () {
12872 const self = this;
12873 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
12874
12875 self.hook('before', 'setup', () => {
12876 self.focus_node = self.control;
12877 addClasses(self.control_input, 'dropdown-input');
12878 const div = getDom('<div class="dropdown-input-wrap">');
12879 div.append(self.control_input);
12880 self.dropdown.insertBefore(div, self.dropdown.firstChild);
12881
12882 // set a placeholder in the select control
12883 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
12884 placeholder.placeholder = self.settings.placeholder || '';
12885 self.control.append(placeholder);
12886 });
12887 self.on('initialize', () => {
12888 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
12889 self.control_input.addEventListener('keydown', evt => {
12890 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
12891 switch (evt.keyCode) {
12892 case KEY_ESC:
12893 if (self.isOpen) {
12894 preventDefault(evt, true);
12895 self.close();
12896 }
12897 self.clearActiveItems();
12898 return;
12899 case KEY_TAB:
12900 self.focus_node.tabIndex = -1;
12901 break;
12902 }
12903 return self.onKeyDown.call(self, evt);
12904 });
12905 self.on('blur', () => {
12906 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
12907 });
12908
12909 // give the control_input focus when the dropdown is open
12910 self.on('dropdown_open', () => {
12911 self.control_input.focus();
12912 });
12913
12914 // prevent onBlur from closing when focus is on the control_input
12915 const orig_onBlur = self.onBlur;
12916 self.hook('instead', 'onBlur', evt => {
12917 if (evt && evt.relatedTarget == self.control_input) return;
12918 return orig_onBlur.call(self);
12919 });
12920 addEvent(self.control_input, 'blur', () => self.onBlur());
12921
12922 // return focus to control to allow further keyboard input
12923 self.hook('before', 'close', () => {
12924 if (!self.isOpen) return;
12925 self.focus_node.focus({
12926 preventScroll: true
12927 });
12928 });
12929 });
12930 }
12931
12932
12933 //# sourceMappingURL=plugin.js.map
12934
12935
12936 /***/ }),
12937
12938 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js":
12939 /*!***************************************************************************!*\
12940 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
12941 \***************************************************************************/
12942 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
12943
12944 "use strict";
12945 __webpack_require__.r(__webpack_exports__);
12946 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12947 /* harmony export */ "default": () => (/* binding */ plugin)
12948 /* harmony export */ });
12949 /**
12950 * Tom Select v2.4.3
12951 * Licensed under the Apache License, Version 2.0 (the "License");
12952 */
12953
12954 /**
12955 * Converts a scalar to its best string representation
12956 * for hash keys and HTML attribute values.
12957 *
12958 * Transformations:
12959 * 'str' -> 'str'
12960 * null -> ''
12961 * undefined -> ''
12962 * true -> '1'
12963 * false -> '0'
12964 * 0 -> '0'
12965 * 1 -> '1'
12966 *
12967 */
12968
12969 /**
12970 * Add event helper
12971 *
12972 */
12973 const addEvent = (target, type, callback, options) => {
12974 target.addEventListener(type, callback, options);
12975 };
12976
12977 /**
12978 * Plugin: "input_autogrow" (Tom Select)
12979 *
12980 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
12981 * file except in compliance with the License. You may obtain a copy of the License at:
12982 * http://www.apache.org/licenses/LICENSE-2.0
12983 *
12984 * Unless required by applicable law or agreed to in writing, software distributed under
12985 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12986 * ANY KIND, either express or implied. See the License for the specific language
12987 * governing permissions and limitations under the License.
12988 *
12989 */
12990
12991 function plugin () {
12992 var self = this;
12993 self.on('initialize', () => {
12994 var test_input = document.createElement('span');
12995 var control = self.control_input;
12996 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
12997 self.wrapper.appendChild(test_input);
12998 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
12999 for (const style_name of transfer_styles) {
13000 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
13001 test_input.style[style_name] = control.style[style_name];
13002 }
13003
13004 /**
13005 * Set the control width
13006 *
13007 */
13008 var resize = () => {
13009 test_input.textContent = control.value;
13010 control.style.width = test_input.clientWidth + 'px';
13011 };
13012 resize();
13013 self.on('update item_add item_remove', resize);
13014 addEvent(control, 'input', resize);
13015 addEvent(control, 'keyup', resize);
13016 addEvent(control, 'blur', resize);
13017 addEvent(control, 'update', resize);
13018 });
13019 }
13020
13021
13022 //# sourceMappingURL=plugin.js.map
13023
13024
13025 /***/ }),
13026
13027 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js":
13028 /*!****************************************************************************!*\
13029 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
13030 \****************************************************************************/
13031 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13032
13033 "use strict";
13034 __webpack_require__.r(__webpack_exports__);
13035 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13036 /* harmony export */ "default": () => (/* binding */ plugin)
13037 /* harmony export */ });
13038 /**
13039 * Tom Select v2.4.3
13040 * Licensed under the Apache License, Version 2.0 (the "License");
13041 */
13042
13043 /**
13044 * Plugin: "no_active_items" (Tom Select)
13045 *
13046 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
13047 * file except in compliance with the License. You may obtain a copy of the License at:
13048 * http://www.apache.org/licenses/LICENSE-2.0
13049 *
13050 * Unless required by applicable law or agreed to in writing, software distributed under
13051 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13052 * ANY KIND, either express or implied. See the License for the specific language
13053 * governing permissions and limitations under the License.
13054 *
13055 */
13056
13057 function plugin () {
13058 this.hook('instead', 'setActiveItem', () => {});
13059 this.hook('instead', 'selectAll', () => {});
13060 }
13061
13062
13063 //# sourceMappingURL=plugin.js.map
13064
13065
13066 /***/ }),
13067
13068 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js":
13069 /*!********************************************************************************!*\
13070 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
13071 \********************************************************************************/
13072 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13073
13074 "use strict";
13075 __webpack_require__.r(__webpack_exports__);
13076 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13077 /* harmony export */ "default": () => (/* binding */ plugin)
13078 /* harmony export */ });
13079 /**
13080 * Tom Select v2.4.3
13081 * Licensed under the Apache License, Version 2.0 (the "License");
13082 */
13083
13084 /**
13085 * Plugin: "input_autogrow" (Tom Select)
13086 *
13087 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
13088 * file except in compliance with the License. You may obtain a copy of the License at:
13089 * http://www.apache.org/licenses/LICENSE-2.0
13090 *
13091 * Unless required by applicable law or agreed to in writing, software distributed under
13092 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13093 * ANY KIND, either express or implied. See the License for the specific language
13094 * governing permissions and limitations under the License.
13095 *
13096 */
13097
13098 function plugin () {
13099 var self = this;
13100 var orig_deleteSelection = self.deleteSelection;
13101 this.hook('instead', 'deleteSelection', evt => {
13102 if (self.activeItems.length) {
13103 return orig_deleteSelection.call(self, evt);
13104 }
13105 return false;
13106 });
13107 }
13108
13109
13110 //# sourceMappingURL=plugin.js.map
13111
13112
13113 /***/ }),
13114
13115 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js":
13116 /*!*****************************************************************************!*\
13117 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
13118 \*****************************************************************************/
13119 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13120
13121 "use strict";
13122 __webpack_require__.r(__webpack_exports__);
13123 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13124 /* harmony export */ "default": () => (/* binding */ plugin)
13125 /* harmony export */ });
13126 /**
13127 * Tom Select v2.4.3
13128 * Licensed under the Apache License, Version 2.0 (the "License");
13129 */
13130
13131 const KEY_LEFT = 37;
13132 const KEY_RIGHT = 39;
13133 // ctrl key or apple key for ma
13134
13135 /**
13136 * Get the closest node to the evt.target matching the selector
13137 * Stops at wrapper
13138 *
13139 */
13140 const parentMatch = (target, selector, wrapper) => {
13141 while (target && target.matches) {
13142 if (target.matches(selector)) {
13143 return target;
13144 }
13145 target = target.parentNode;
13146 }
13147 };
13148
13149 /**
13150 * Get the index of an element amongst sibling nodes of the same type
13151 *
13152 */
13153 const nodeIndex = (el, amongst) => {
13154 if (!el) return -1;
13155 amongst = amongst || el.nodeName;
13156 var i = 0;
13157 while (el = el.previousElementSibling) {
13158 if (el.matches(amongst)) {
13159 i++;
13160 }
13161 }
13162 return i;
13163 };
13164
13165 /**
13166 * Plugin: "optgroup_columns" (Tom Select.js)
13167 * Copyright (c) contributors
13168 *
13169 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
13170 * file except in compliance with the License. You may obtain a copy of the License at:
13171 * http://www.apache.org/licenses/LICENSE-2.0
13172 *
13173 * Unless required by applicable law or agreed to in writing, software distributed under
13174 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13175 * ANY KIND, either express or implied. See the License for the specific language
13176 * governing permissions and limitations under the License.
13177 *
13178 */
13179
13180 function plugin () {
13181 var self = this;
13182 var orig_keydown = self.onKeyDown;
13183 self.hook('instead', 'onKeyDown', evt => {
13184 var index, option, options, optgroup;
13185 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
13186 return orig_keydown.call(self, evt);
13187 }
13188 self.ignoreHover = true;
13189 optgroup = parentMatch(self.activeOption, '[data-group]');
13190 index = nodeIndex(self.activeOption, '[data-selectable]');
13191 if (!optgroup) {
13192 return;
13193 }
13194 if (evt.keyCode === KEY_LEFT) {
13195 optgroup = optgroup.previousSibling;
13196 } else {
13197 optgroup = optgroup.nextSibling;
13198 }
13199 if (!optgroup) {
13200 return;
13201 }
13202 options = optgroup.querySelectorAll('[data-selectable]');
13203 option = options[Math.min(options.length - 1, index)];
13204 if (option) {
13205 self.setActiveOption(option);
13206 }
13207 });
13208 }
13209
13210
13211 //# sourceMappingURL=plugin.js.map
13212
13213
13214 /***/ }),
13215
13216 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js":
13217 /*!**************************************************************************!*\
13218 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
13219 \**************************************************************************/
13220 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13221
13222 "use strict";
13223 __webpack_require__.r(__webpack_exports__);
13224 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13225 /* harmony export */ "default": () => (/* binding */ plugin)
13226 /* harmony export */ });
13227 /**
13228 * Tom Select v2.4.3
13229 * Licensed under the Apache License, Version 2.0 (the "License");
13230 */
13231
13232 /**
13233 * Converts a scalar to its best string representation
13234 * for hash keys and HTML attribute values.
13235 *
13236 * Transformations:
13237 * 'str' -> 'str'
13238 * null -> ''
13239 * undefined -> ''
13240 * true -> '1'
13241 * false -> '0'
13242 * 0 -> '0'
13243 * 1 -> '1'
13244 *
13245 */
13246
13247 /**
13248 * Escapes a string for use within HTML.
13249 *
13250 */
13251 const escape_html = str => {
13252 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
13253 };
13254
13255 /**
13256 * Prevent default
13257 *
13258 */
13259 const preventDefault = (evt, stop = false) => {
13260 if (evt) {
13261 evt.preventDefault();
13262 if (stop) {
13263 evt.stopPropagation();
13264 }
13265 }
13266 };
13267
13268 /**
13269 * Add event helper
13270 *
13271 */
13272 const addEvent = (target, type, callback, options) => {
13273 target.addEventListener(type, callback, options);
13274 };
13275
13276 /**
13277 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13278 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13279 *
13280 * param query should be {}
13281 */
13282 const getDom = query => {
13283 if (query.jquery) {
13284 return query[0];
13285 }
13286 if (query instanceof HTMLElement) {
13287 return query;
13288 }
13289 if (isHtmlString(query)) {
13290 var tpl = document.createElement('template');
13291 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13292 return tpl.content.firstChild;
13293 }
13294 return document.querySelector(query);
13295 };
13296 const isHtmlString = arg => {
13297 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13298 return true;
13299 }
13300 return false;
13301 };
13302
13303 /**
13304 * Plugin: "remove_button" (Tom Select)
13305 * Copyright (c) contributors
13306 *
13307 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
13308 * file except in compliance with the License. You may obtain a copy of the License at:
13309 * http://www.apache.org/licenses/LICENSE-2.0
13310 *
13311 * Unless required by applicable law or agreed to in writing, software distributed under
13312 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13313 * ANY KIND, either express or implied. See the License for the specific language
13314 * governing permissions and limitations under the License.
13315 *
13316 */
13317
13318 function plugin (userOptions) {
13319 const options = Object.assign({
13320 label: '&times;',
13321 title: 'Remove',
13322 className: 'remove',
13323 append: true
13324 }, userOptions);
13325
13326 //options.className = 'remove-single';
13327 var self = this;
13328
13329 // override the render method to add remove button to each item
13330 if (!options.append) {
13331 return;
13332 }
13333 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
13334 self.hook('after', 'setupTemplates', () => {
13335 var orig_render_item = self.settings.render.item;
13336 self.settings.render.item = (data, escape) => {
13337 var item = getDom(orig_render_item.call(self, data, escape));
13338 var close_button = getDom(html);
13339 item.appendChild(close_button);
13340 addEvent(close_button, 'mousedown', evt => {
13341 preventDefault(evt, true);
13342 });
13343 addEvent(close_button, 'click', evt => {
13344 if (self.isLocked) return;
13345
13346 // propagating will trigger the dropdown to show for single mode
13347 preventDefault(evt, true);
13348 if (self.isLocked) return;
13349 if (!self.shouldDelete([item], evt)) return;
13350 self.removeItem(item);
13351 self.refreshOptions(false);
13352 self.inputState();
13353 });
13354 return item;
13355 };
13356 });
13357 }
13358
13359
13360 //# sourceMappingURL=plugin.js.map
13361
13362
13363 /***/ }),
13364
13365 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js":
13366 /*!*********************************************************************************!*\
13367 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
13368 \*********************************************************************************/
13369 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13370
13371 "use strict";
13372 __webpack_require__.r(__webpack_exports__);
13373 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13374 /* harmony export */ "default": () => (/* binding */ plugin)
13375 /* harmony export */ });
13376 /**
13377 * Tom Select v2.4.3
13378 * Licensed under the Apache License, Version 2.0 (the "License");
13379 */
13380
13381 /**
13382 * Plugin: "restore_on_backspace" (Tom Select)
13383 * Copyright (c) contributors
13384 *
13385 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
13386 * file except in compliance with the License. You may obtain a copy of the License at:
13387 * http://www.apache.org/licenses/LICENSE-2.0
13388 *
13389 * Unless required by applicable law or agreed to in writing, software distributed under
13390 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13391 * ANY KIND, either express or implied. See the License for the specific language
13392 * governing permissions and limitations under the License.
13393 *
13394 */
13395
13396 function plugin (userOptions) {
13397 const self = this;
13398 const options = Object.assign({
13399 text: option => {
13400 return option[self.settings.labelField];
13401 }
13402 }, userOptions);
13403 self.on('item_remove', function (value) {
13404 if (!self.isFocused) {
13405 return;
13406 }
13407 if (self.control_input.value.trim() === '') {
13408 var option = self.options[value];
13409 if (option) {
13410 self.setTextboxValue(options.text.call(self, option));
13411 }
13412 }
13413 });
13414 }
13415
13416
13417 //# sourceMappingURL=plugin.js.map
13418
13419
13420 /***/ }),
13421
13422 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js":
13423 /*!***************************************************************************!*\
13424 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
13425 \***************************************************************************/
13426 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13427
13428 "use strict";
13429 __webpack_require__.r(__webpack_exports__);
13430 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13431 /* harmony export */ "default": () => (/* binding */ plugin)
13432 /* harmony export */ });
13433 /**
13434 * Tom Select v2.4.3
13435 * Licensed under the Apache License, Version 2.0 (the "License");
13436 */
13437
13438 /**
13439 * Converts a scalar to its best string representation
13440 * for hash keys and HTML attribute values.
13441 *
13442 * Transformations:
13443 * 'str' -> 'str'
13444 * null -> ''
13445 * undefined -> ''
13446 * true -> '1'
13447 * false -> '0'
13448 * 0 -> '0'
13449 * 1 -> '1'
13450 *
13451 */
13452
13453 /**
13454 * Iterates over arrays and hashes.
13455 *
13456 * ```
13457 * iterate(this.items, function(item, id) {
13458 * // invoked for each item
13459 * });
13460 * ```
13461 *
13462 */
13463 const iterate = (object, callback) => {
13464 if (Array.isArray(object)) {
13465 object.forEach(callback);
13466 } else {
13467 for (var key in object) {
13468 if (object.hasOwnProperty(key)) {
13469 callback(object[key], key);
13470 }
13471 }
13472 }
13473 };
13474
13475 /**
13476 * Add css classes
13477 *
13478 */
13479 const addClasses = (elmts, ...classes) => {
13480 var norm_classes = classesArray(classes);
13481 elmts = castAsArray(elmts);
13482 elmts.map(el => {
13483 norm_classes.map(cls => {
13484 el.classList.add(cls);
13485 });
13486 });
13487 };
13488
13489 /**
13490 * Return arguments
13491 *
13492 */
13493 const classesArray = args => {
13494 var classes = [];
13495 iterate(args, _classes => {
13496 if (typeof _classes === 'string') {
13497 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13498 }
13499 if (Array.isArray(_classes)) {
13500 classes = classes.concat(_classes);
13501 }
13502 });
13503 return classes.filter(Boolean);
13504 };
13505
13506 /**
13507 * Create an array from arg if it's not already an array
13508 *
13509 */
13510 const castAsArray = arg => {
13511 if (!Array.isArray(arg)) {
13512 arg = [arg];
13513 }
13514 return arg;
13515 };
13516
13517 /**
13518 * Plugin: "restore_on_backspace" (Tom Select)
13519 * Copyright (c) contributors
13520 *
13521 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
13522 * file except in compliance with the License. You may obtain a copy of the License at:
13523 * http://www.apache.org/licenses/LICENSE-2.0
13524 *
13525 * Unless required by applicable law or agreed to in writing, software distributed under
13526 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13527 * ANY KIND, either express or implied. See the License for the specific language
13528 * governing permissions and limitations under the License.
13529 *
13530 */
13531
13532 function plugin () {
13533 const self = this;
13534 const orig_canLoad = self.canLoad;
13535 const orig_clearActiveOption = self.clearActiveOption;
13536 const orig_loadCallback = self.loadCallback;
13537 var pagination = {};
13538 var dropdown_content;
13539 var loading_more = false;
13540 var load_more_opt;
13541 var default_values = [];
13542 if (!self.settings.shouldLoadMore) {
13543 // return true if additional results should be loaded
13544 self.settings.shouldLoadMore = () => {
13545 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
13546 if (scroll_percent > 0.9) {
13547 return true;
13548 }
13549 if (self.activeOption) {
13550 var selectable = self.selectable();
13551 var index = Array.from(selectable).indexOf(self.activeOption);
13552 if (index >= selectable.length - 2) {
13553 return true;
13554 }
13555 }
13556 return false;
13557 };
13558 }
13559 if (!self.settings.firstUrl) {
13560 throw 'virtual_scroll plugin requires a firstUrl() method';
13561 }
13562
13563 // in order for virtual scrolling to work,
13564 // options need to be ordered the same way they're returned from the remote data source
13565 self.settings.sortField = [{
13566 field: '$order'
13567 }, {
13568 field: '$score'
13569 }];
13570
13571 // can we load more results for given query?
13572 const canLoadMore = query => {
13573 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
13574 return false;
13575 }
13576 if (query in pagination && pagination[query]) {
13577 return true;
13578 }
13579 return false;
13580 };
13581 const clearFilter = (option, value) => {
13582 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
13583 return true;
13584 }
13585 return false;
13586 };
13587
13588 // set the next url that will be
13589 self.setNextUrl = (value, next_url) => {
13590 pagination[value] = next_url;
13591 };
13592
13593 // getUrl() to be used in settings.load()
13594 self.getUrl = query => {
13595 if (query in pagination) {
13596 const next_url = pagination[query];
13597 pagination[query] = false;
13598 return next_url;
13599 }
13600
13601 // if the user goes back to a previous query
13602 // we need to load the first page again
13603 self.clearPagination();
13604 return self.settings.firstUrl.call(self, query);
13605 };
13606
13607 // clear pagination
13608 self.clearPagination = () => {
13609 pagination = {};
13610 };
13611
13612 // don't clear the active option (and cause unwanted dropdown scroll)
13613 // while loading more results
13614 self.hook('instead', 'clearActiveOption', () => {
13615 if (loading_more) {
13616 return;
13617 }
13618 return orig_clearActiveOption.call(self);
13619 });
13620
13621 // override the canLoad method
13622 self.hook('instead', 'canLoad', query => {
13623 // first time the query has been seen
13624 if (!(query in pagination)) {
13625 return orig_canLoad.call(self, query);
13626 }
13627 return canLoadMore(query);
13628 });
13629
13630 // wrap the load
13631 self.hook('instead', 'loadCallback', (options, optgroups) => {
13632 if (!loading_more) {
13633 self.clearOptions(clearFilter);
13634 } else if (load_more_opt) {
13635 const first_option = options[0];
13636 if (first_option !== undefined) {
13637 load_more_opt.dataset.value = first_option[self.settings.valueField];
13638 }
13639 }
13640 orig_loadCallback.call(self, options, optgroups);
13641 loading_more = false;
13642 });
13643
13644 // add templates to dropdown
13645 // loading_more if we have another url in the queue
13646 // no_more_results if we don't have another url in the queue
13647 self.hook('after', 'refreshOptions', () => {
13648 const query = self.lastValue;
13649 var option;
13650 if (canLoadMore(query)) {
13651 option = self.render('loading_more', {
13652 query: query
13653 });
13654 if (option) {
13655 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
13656 load_more_opt = option;
13657 }
13658 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
13659 option = self.render('no_more_results', {
13660 query: query
13661 });
13662 }
13663 if (option) {
13664 addClasses(option, self.settings.optionClass);
13665 dropdown_content.append(option);
13666 }
13667 });
13668
13669 // add scroll listener and default templates
13670 self.on('initialize', () => {
13671 default_values = Object.keys(self.options);
13672 dropdown_content = self.dropdown_content;
13673
13674 // default templates
13675 self.settings.render = Object.assign({}, {
13676 loading_more: () => {
13677 return `<div class="loading-more-results">Loading more results ... </div>`;
13678 },
13679 no_more_results: () => {
13680 return `<div class="no-more-results">No more results</div>`;
13681 }
13682 }, self.settings.render);
13683
13684 // watch dropdown content scroll position
13685 dropdown_content.addEventListener('scroll', () => {
13686 if (!self.settings.shouldLoadMore.call(self)) {
13687 return;
13688 }
13689
13690 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
13691 if (!canLoadMore(self.lastValue)) {
13692 return;
13693 }
13694
13695 // don't call load() too much
13696 if (loading_more) return;
13697 loading_more = true;
13698 self.load.call(self, self.lastValue);
13699 });
13700 });
13701 }
13702
13703
13704 //# sourceMappingURL=plugin.js.map
13705
13706
13707 /***/ }),
13708
13709 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js":
13710 /*!*****************************************************************!*\
13711 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
13712 \*****************************************************************/
13713 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13714
13715 "use strict";
13716 __webpack_require__.r(__webpack_exports__);
13717 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13718 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
13719 /* harmony export */ });
13720 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
13721 /* 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");
13722 /* 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");
13723 /* 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");
13724 /* 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");
13725 /* 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");
13726 /* 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");
13727 /* 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");
13728 /* 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");
13729 /* 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");
13730 /* 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");
13731 /* 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");
13732 /* 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");
13733 /* 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");
13734 /* 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");
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
13751 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
13752 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
13753 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
13754 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
13755 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
13756 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
13757 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
13758 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
13759 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
13760 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
13761 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
13762 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
13763 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
13764 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
13765 //# sourceMappingURL=tom-select.complete.js.map
13766
13767 /***/ }),
13768
13769 /***/ "./node_modules/tom-select/dist/esm/tom-select.js":
13770 /*!********************************************************!*\
13771 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
13772 \********************************************************/
13773 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
13774
13775 "use strict";
13776 __webpack_require__.r(__webpack_exports__);
13777 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13778 /* harmony export */ "default": () => (/* binding */ TomSelect)
13779 /* harmony export */ });
13780 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
13781 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
13782 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
13783 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
13784 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
13785 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
13786 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
13787 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13788 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798 var instance_i = 0;
13799 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
13800 constructor(input_arg, user_settings) {
13801 super();
13802 this.order = 0;
13803 this.isOpen = false;
13804 this.isDisabled = false;
13805 this.isReadOnly = false;
13806 this.isInvalid = false; // @deprecated 1.8
13807 this.isValid = true;
13808 this.isLocked = false;
13809 this.isFocused = false;
13810 this.isInputHidden = false;
13811 this.isSetup = false;
13812 this.ignoreFocus = false;
13813 this.ignoreHover = false;
13814 this.hasOptions = false;
13815 this.lastValue = '';
13816 this.caretPos = 0;
13817 this.loading = 0;
13818 this.loadedSearches = {};
13819 this.activeOption = null;
13820 this.activeItems = [];
13821 this.optgroups = {};
13822 this.options = {};
13823 this.userOptions = {};
13824 this.items = [];
13825 this.refreshTimeout = null;
13826 instance_i++;
13827 var dir;
13828 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
13829 if (input.tomselect) {
13830 throw new Error('Tom Select already initialized on this element');
13831 }
13832 input.tomselect = this;
13833 // detect rtl environment
13834 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
13835 dir = computedStyle.getPropertyValue('direction');
13836 // setup default state
13837 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
13838 this.settings = settings;
13839 this.input = input;
13840 this.tabIndex = input.tabIndex || 0;
13841 this.is_select_tag = input.tagName.toLowerCase() === 'select';
13842 this.rtl = /rtl/i.test(dir);
13843 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
13844 this.isRequired = input.required;
13845 // search system
13846 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
13847 // option-dependent defaults
13848 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
13849 if (typeof settings.hideSelected !== 'boolean') {
13850 settings.hideSelected = settings.mode === 'multi';
13851 }
13852 if (typeof settings.hidePlaceholder !== 'boolean') {
13853 settings.hidePlaceholder = settings.mode !== 'multi';
13854 }
13855 // set up createFilter callback
13856 var filter = settings.createFilter;
13857 if (typeof filter !== 'function') {
13858 if (typeof filter === 'string') {
13859 filter = new RegExp(filter);
13860 }
13861 if (filter instanceof RegExp) {
13862 settings.createFilter = (input) => filter.test(input);
13863 }
13864 else {
13865 settings.createFilter = (value) => {
13866 return this.settings.duplicates || !this.options[value];
13867 };
13868 }
13869 }
13870 this.initializePlugins(settings.plugins);
13871 this.setupCallbacks();
13872 this.setupTemplates();
13873 // Create all elements
13874 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
13875 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
13876 const dropdown = this._render('dropdown');
13877 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
13878 const classes = this.input.getAttribute('class') || '';
13879 const inputMode = settings.mode;
13880 var control_input;
13881 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
13882 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
13883 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
13884 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
13885 if (settings.copyClassesToDropdown) {
13886 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
13887 }
13888 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
13889 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
13890 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
13891 // default controlInput
13892 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
13893 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
13894 // set attributes
13895 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
13896 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
13897 if (input.getAttribute(attr)) {
13898 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
13899 }
13900 });
13901 control_input.tabIndex = -1;
13902 control.appendChild(control_input);
13903 this.focus_node = control_input;
13904 // dom element
13905 }
13906 else if (settings.controlInput) {
13907 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
13908 this.focus_node = control_input;
13909 }
13910 else {
13911 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
13912 this.focus_node = control;
13913 }
13914 this.wrapper = wrapper;
13915 this.dropdown = dropdown;
13916 this.dropdown_content = dropdown_content;
13917 this.control = control;
13918 this.control_input = control_input;
13919 this.setup();
13920 }
13921 /**
13922 * set up event bindings.
13923 *
13924 */
13925 setup() {
13926 const self = this;
13927 const settings = self.settings;
13928 const control_input = self.control_input;
13929 const dropdown = self.dropdown;
13930 const dropdown_content = self.dropdown_content;
13931 const wrapper = self.wrapper;
13932 const control = self.control;
13933 const input = self.input;
13934 const focus_node = self.focus_node;
13935 const passive_event = { passive: true };
13936 const listboxId = self.inputId + '-ts-dropdown';
13937 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
13938 id: listboxId
13939 });
13940 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
13941 role: 'combobox',
13942 'aria-haspopup': 'listbox',
13943 'aria-expanded': 'false',
13944 'aria-controls': listboxId
13945 });
13946 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
13947 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
13948 const label = document.querySelector(query);
13949 const label_click = self.focus.bind(self);
13950 if (label) {
13951 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
13952 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
13953 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
13954 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
13955 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
13956 }
13957 wrapper.style.width = input.style.width;
13958 if (self.plugins.names.length) {
13959 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
13960 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
13961 }
13962 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
13963 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
13964 }
13965 if (settings.placeholder) {
13966 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
13967 }
13968 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
13969 if (!settings.splitOn && settings.delimiter) {
13970 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
13971 }
13972 // debounce user defined load() if loadThrottle > 0
13973 // after initializePlugins() so plugins can create/modify user defined loaders
13974 if (settings.load && settings.loadThrottle) {
13975 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
13976 }
13977 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
13978 self.ignoreHover = false;
13979 });
13980 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
13981 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
13982 if (target_match)
13983 self.onOptionHover(e, target_match);
13984 }, { capture: true });
13985 // clicking on an option should select it
13986 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
13987 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
13988 if (option) {
13989 self.onOptionSelect(evt, option);
13990 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
13991 }
13992 });
13993 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
13994 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
13995 if (target_match && self.onItemSelect(evt, target_match)) {
13996 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
13997 return;
13998 }
13999 // retain focus (see control_input mousedown)
14000 if (control_input.value != '') {
14001 return;
14002 }
14003 self.onClick();
14004 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
14005 });
14006 // keydown on focus_node for arrow_down/arrow_up
14007 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
14008 // keypress and input/keyup
14009 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
14010 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
14011 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
14012 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
14013 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
14014 const doc_mousedown = (evt) => {
14015 // blur if target is outside of this instance
14016 // dropdown is not always inside wrapper
14017 const target = evt.composedPath()[0];
14018 if (!wrapper.contains(target) && !dropdown.contains(target)) {
14019 if (self.isFocused) {
14020 self.blur();
14021 }
14022 self.inputState();
14023 return;
14024 }
14025 // retain focus by preventing native handling. if the
14026 // event target is the input it should not be modified.
14027 // otherwise, text selection within the input won't work.
14028 // Fixes bug #212 which is no covered by tests
14029 if (target == control_input && self.isOpen) {
14030 evt.stopPropagation();
14031 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
14032 }
14033 else {
14034 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
14035 }
14036 };
14037 const win_scroll = () => {
14038 if (self.isOpen) {
14039 self.positionDropdown();
14040 }
14041 };
14042 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
14043 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
14044 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
14045 this._destroy = () => {
14046 document.removeEventListener('mousedown', doc_mousedown);
14047 window.removeEventListener('scroll', win_scroll);
14048 window.removeEventListener('resize', win_scroll);
14049 if (label)
14050 label.removeEventListener('click', label_click);
14051 };
14052 // store original html and tab index so that they can be
14053 // restored when the destroy() method is called.
14054 this.revertSettings = {
14055 innerHTML: input.innerHTML,
14056 tabIndex: input.tabIndex
14057 };
14058 input.tabIndex = -1;
14059 input.insertAdjacentElement('afterend', self.wrapper);
14060 self.sync(false);
14061 settings.items = [];
14062 delete settings.optgroups;
14063 delete settings.options;
14064 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
14065 if (self.isValid) {
14066 self.isValid = false;
14067 self.isInvalid = true;
14068 self.refreshState();
14069 }
14070 });
14071 self.updateOriginalInput();
14072 self.refreshItems();
14073 self.close(false);
14074 self.inputState();
14075 self.isSetup = true;
14076 if (input.disabled) {
14077 self.disable();
14078 }
14079 else if (input.readOnly) {
14080 self.setReadOnly(true);
14081 }
14082 else {
14083 self.enable(); //sets tabIndex
14084 }
14085 self.on('change', this.onChange);
14086 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
14087 self.trigger('initialize');
14088 // preload options
14089 if (settings.preload === true) {
14090 self.preload();
14091 }
14092 }
14093 /**
14094 * Register options and optgroups
14095 *
14096 */
14097 setupOptions(options = [], optgroups = []) {
14098 // build options table
14099 this.addOptions(options);
14100 // build optgroup table
14101 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
14102 this.registerOptionGroup(optgroup);
14103 });
14104 }
14105 /**
14106 * Sets up default rendering functions.
14107 */
14108 setupTemplates() {
14109 var self = this;
14110 var field_label = self.settings.labelField;
14111 var field_optgroup = self.settings.optgroupLabelField;
14112 var templates = {
14113 'optgroup': (data) => {
14114 let optgroup = document.createElement('div');
14115 optgroup.className = 'optgroup';
14116 optgroup.appendChild(data.options);
14117 return optgroup;
14118 },
14119 'optgroup_header': (data, escape) => {
14120 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
14121 },
14122 'option': (data, escape) => {
14123 return '<div>' + escape(data[field_label]) + '</div>';
14124 },
14125 'item': (data, escape) => {
14126 return '<div>' + escape(data[field_label]) + '</div>';
14127 },
14128 'option_create': (data, escape) => {
14129 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
14130 },
14131 'no_results': () => {
14132 return '<div class="no-results">No results found</div>';
14133 },
14134 'loading': () => {
14135 return '<div class="spinner"></div>';
14136 },
14137 'not_loading': () => { },
14138 'dropdown': () => {
14139 return '<div></div>';
14140 }
14141 };
14142 self.settings.render = Object.assign({}, templates, self.settings.render);
14143 }
14144 /**
14145 * Maps fired events to callbacks provided
14146 * in the settings used when creating the control.
14147 */
14148 setupCallbacks() {
14149 var key, fn;
14150 var callbacks = {
14151 'initialize': 'onInitialize',
14152 'change': 'onChange',
14153 'item_add': 'onItemAdd',
14154 'item_remove': 'onItemRemove',
14155 'item_select': 'onItemSelect',
14156 'clear': 'onClear',
14157 'option_add': 'onOptionAdd',
14158 'option_remove': 'onOptionRemove',
14159 'option_clear': 'onOptionClear',
14160 'optgroup_add': 'onOptionGroupAdd',
14161 'optgroup_remove': 'onOptionGroupRemove',
14162 'optgroup_clear': 'onOptionGroupClear',
14163 'dropdown_open': 'onDropdownOpen',
14164 'dropdown_close': 'onDropdownClose',
14165 'type': 'onType',
14166 'load': 'onLoad',
14167 'focus': 'onFocus',
14168 'blur': 'onBlur'
14169 };
14170 for (key in callbacks) {
14171 fn = this.settings[callbacks[key]];
14172 if (fn)
14173 this.on(key, fn);
14174 }
14175 }
14176 /**
14177 * Sync the Tom Select instance with the original input or select
14178 *
14179 */
14180 sync(get_settings = true) {
14181 const self = this;
14182 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
14183 self.setupOptions(settings.options, settings.optgroups);
14184 self.setValue(settings.items || [], true); // silent prevents recursion
14185 self.lastQuery = null; // so updated options will be displayed in dropdown
14186 }
14187 /**
14188 * Triggered when the main control element
14189 * has a click event.
14190 *
14191 */
14192 onClick() {
14193 var self = this;
14194 if (self.activeItems.length > 0) {
14195 self.clearActiveItems();
14196 self.focus();
14197 return;
14198 }
14199 if (self.isFocused && self.isOpen) {
14200 self.blur();
14201 }
14202 else {
14203 self.focus();
14204 }
14205 }
14206 /**
14207 * @deprecated v1.7
14208 *
14209 */
14210 onMouseDown() { }
14211 /**
14212 * Triggered when the value of the control has been changed.
14213 * This should propagate the event to the original DOM
14214 * input / select element.
14215 */
14216 onChange() {
14217 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
14218 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
14219 }
14220 /**
14221 * Triggered on <input> paste.
14222 *
14223 */
14224 onPaste(e) {
14225 var self = this;
14226 if (self.isInputHidden || self.isLocked) {
14227 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14228 return;
14229 }
14230 // If a regex or string is included, this will split the pasted
14231 // input and create Items for each separate value
14232 if (!self.settings.splitOn) {
14233 return;
14234 }
14235 // Wait for pasted text to be recognized in value
14236 setTimeout(() => {
14237 var pastedText = self.inputValue();
14238 if (!pastedText.match(self.settings.splitOn)) {
14239 return;
14240 }
14241 var splitInput = pastedText.trim().split(self.settings.splitOn);
14242 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
14243 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
14244 if (hash) {
14245 if (this.options[piece]) {
14246 self.addItem(piece);
14247 }
14248 else {
14249 self.createItem(piece);
14250 }
14251 }
14252 });
14253 }, 0);
14254 }
14255 /**
14256 * Triggered on <input> keypress.
14257 *
14258 */
14259 onKeyPress(e) {
14260 var self = this;
14261 if (self.isLocked) {
14262 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14263 return;
14264 }
14265 var character = String.fromCharCode(e.keyCode || e.which);
14266 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
14267 self.createItem();
14268 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14269 return;
14270 }
14271 }
14272 /**
14273 * Triggered on <input> keydown.
14274 *
14275 */
14276 onKeyDown(e) {
14277 var self = this;
14278 self.ignoreHover = true;
14279 if (self.isLocked) {
14280 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
14281 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14282 }
14283 return;
14284 }
14285 switch (e.keyCode) {
14286 // ctrl+A: select all
14287 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
14288 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
14289 if (self.control_input.value == '') {
14290 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14291 self.selectAll();
14292 return;
14293 }
14294 }
14295 break;
14296 // esc: close dropdown
14297 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
14298 if (self.isOpen) {
14299 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
14300 self.close();
14301 }
14302 self.clearActiveItems();
14303 return;
14304 // down: open dropdown or move selection down
14305 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
14306 if (!self.isOpen && self.hasOptions) {
14307 self.open();
14308 }
14309 else if (self.activeOption) {
14310 let next = self.getAdjacent(self.activeOption, 1);
14311 if (next)
14312 self.setActiveOption(next);
14313 }
14314 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14315 return;
14316 // up: move selection up
14317 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
14318 if (self.activeOption) {
14319 let prev = self.getAdjacent(self.activeOption, -1);
14320 if (prev)
14321 self.setActiveOption(prev);
14322 }
14323 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14324 return;
14325 // return: select active option
14326 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
14327 if (self.canSelect(self.activeOption)) {
14328 self.onOptionSelect(e, self.activeOption);
14329 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14330 // if the option_create=null, the dropdown might be closed
14331 }
14332 else if (self.settings.create && self.createItem()) {
14333 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14334 // don't submit form when searching for a value
14335 }
14336 else if (document.activeElement == self.control_input && self.isOpen) {
14337 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14338 }
14339 return;
14340 // left: modifiy item selection to the left
14341 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
14342 self.advanceSelection(-1, e);
14343 return;
14344 // right: modifiy item selection to the right
14345 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
14346 self.advanceSelection(1, e);
14347 return;
14348 // tab: select active option and/or create item
14349 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
14350 if (self.settings.selectOnTab) {
14351 if (self.canSelect(self.activeOption)) {
14352 self.onOptionSelect(e, self.activeOption);
14353 // prevent default [tab] behaviour of jump to the next field
14354 // if select isFull, then the dropdown won't be open and [tab] will work normally
14355 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14356 }
14357 if (self.settings.create && self.createItem()) {
14358 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14359 }
14360 }
14361 return;
14362 // delete|backspace: delete items
14363 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
14364 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
14365 self.deleteSelection(e);
14366 return;
14367 }
14368 // don't enter text in the control_input when active items are selected
14369 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
14370 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14371 }
14372 }
14373 /**
14374 * Triggered on <input> keyup.
14375 *
14376 */
14377 onInput(e) {
14378 if (this.isLocked) {
14379 return;
14380 }
14381 const value = this.inputValue();
14382 if (this.lastValue === value)
14383 return;
14384 this.lastValue = value;
14385 if (value == '') {
14386 this._onInput();
14387 return;
14388 }
14389 if (this.refreshTimeout) {
14390 window.clearTimeout(this.refreshTimeout);
14391 }
14392 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
14393 this.refreshTimeout = null;
14394 this._onInput();
14395 }, this.settings.refreshThrottle);
14396 }
14397 _onInput() {
14398 const value = this.lastValue;
14399 if (this.settings.shouldLoad.call(this, value)) {
14400 this.load(value);
14401 }
14402 this.refreshOptions();
14403 this.trigger('type', value);
14404 }
14405 /**
14406 * Triggered when the user rolls over
14407 * an option in the autocomplete dropdown menu.
14408 *
14409 */
14410 onOptionHover(evt, option) {
14411 if (this.ignoreHover)
14412 return;
14413 this.setActiveOption(option, false);
14414 }
14415 /**
14416 * Triggered on <input> focus.
14417 *
14418 */
14419 onFocus(e) {
14420 var self = this;
14421 var wasFocused = self.isFocused;
14422 if (self.isDisabled || self.isReadOnly) {
14423 self.blur();
14424 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14425 return;
14426 }
14427 if (self.ignoreFocus)
14428 return;
14429 self.isFocused = true;
14430 if (self.settings.preload === 'focus')
14431 self.preload();
14432 if (!wasFocused)
14433 self.trigger('focus');
14434 if (!self.activeItems.length) {
14435 self.inputState();
14436 self.refreshOptions(!!self.settings.openOnFocus);
14437 }
14438 self.refreshState();
14439 }
14440 /**
14441 * Triggered on <input> blur.
14442 *
14443 */
14444 onBlur(e) {
14445 if (document.hasFocus() === false)
14446 return;
14447 var self = this;
14448 if (!self.isFocused)
14449 return;
14450 self.isFocused = false;
14451 self.ignoreFocus = false;
14452 var deactivate = () => {
14453 self.close();
14454 self.setActiveItem();
14455 self.setCaret(self.items.length);
14456 self.trigger('blur');
14457 };
14458 if (self.settings.create && self.settings.createOnBlur) {
14459 self.createItem(null, deactivate);
14460 }
14461 else {
14462 deactivate();
14463 }
14464 }
14465 /**
14466 * Triggered when the user clicks on an option
14467 * in the autocomplete dropdown menu.
14468 *
14469 */
14470 onOptionSelect(evt, option) {
14471 var value, self = this;
14472 // should not be possible to trigger a option under a disabled optgroup
14473 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
14474 return;
14475 }
14476 if (option.classList.contains('create')) {
14477 self.createItem(null, () => {
14478 if (self.settings.closeAfterSelect) {
14479 self.close();
14480 }
14481 });
14482 }
14483 else {
14484 value = option.dataset.value;
14485 if (typeof value !== 'undefined') {
14486 self.lastQuery = null;
14487 self.addItem(value);
14488 if (self.settings.closeAfterSelect) {
14489 self.close();
14490 }
14491 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
14492 self.setActiveOption(option);
14493 }
14494 }
14495 }
14496 }
14497 /**
14498 * Return true if the given option can be selected
14499 *
14500 */
14501 canSelect(option) {
14502 if (this.isOpen && option && this.dropdown_content.contains(option)) {
14503 return true;
14504 }
14505 return false;
14506 }
14507 /**
14508 * Triggered when the user clicks on an item
14509 * that has been selected.
14510 *
14511 */
14512 onItemSelect(evt, item) {
14513 var self = this;
14514 if (!self.isLocked && self.settings.mode === 'multi') {
14515 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
14516 self.setActiveItem(item, evt);
14517 return true;
14518 }
14519 return false;
14520 }
14521 /**
14522 * Determines whether or not to invoke
14523 * the user-provided option provider / loader
14524 *
14525 * Note, there is a subtle difference between
14526 * this.canLoad() and this.settings.shouldLoad();
14527 *
14528 * - settings.shouldLoad() is a user-input validator.
14529 * When false is returned, the not_loading template
14530 * will be added to the dropdown
14531 *
14532 * - canLoad() is lower level validator that checks
14533 * the Tom Select instance. There is no inherent user
14534 * feedback when canLoad returns false
14535 *
14536 */
14537 canLoad(value) {
14538 if (!this.settings.load)
14539 return false;
14540 if (this.loadedSearches.hasOwnProperty(value))
14541 return false;
14542 return true;
14543 }
14544 /**
14545 * Invokes the user-provided option provider / loader.
14546 *
14547 */
14548 load(value) {
14549 const self = this;
14550 if (!self.canLoad(value))
14551 return;
14552 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
14553 self.loading++;
14554 const callback = self.loadCallback.bind(self);
14555 self.settings.load.call(self, value, callback);
14556 }
14557 /**
14558 * Invoked by the user-provided option provider
14559 *
14560 */
14561 loadCallback(options, optgroups) {
14562 const self = this;
14563 self.loading = Math.max(self.loading - 1, 0);
14564 self.lastQuery = null;
14565 self.clearActiveOption(); // when new results load, focus should be on first option
14566 self.setupOptions(options, optgroups);
14567 self.refreshOptions(self.isFocused && !self.isInputHidden);
14568 if (!self.loading) {
14569 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
14570 }
14571 self.trigger('load', options, optgroups);
14572 }
14573 preload() {
14574 var classList = this.wrapper.classList;
14575 if (classList.contains('preloaded'))
14576 return;
14577 classList.add('preloaded');
14578 this.load('');
14579 }
14580 /**
14581 * Sets the input field of the control to the specified value.
14582 *
14583 */
14584 setTextboxValue(value = '') {
14585 var input = this.control_input;
14586 var changed = input.value !== value;
14587 if (changed) {
14588 input.value = value;
14589 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
14590 this.lastValue = value;
14591 }
14592 }
14593 /**
14594 * Returns the value of the control. If multiple items
14595 * can be selected (e.g. <select multiple>), this returns
14596 * an array. If only one item can be selected, this
14597 * returns a string.
14598 *
14599 */
14600 getValue() {
14601 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
14602 return this.items;
14603 }
14604 return this.items.join(this.settings.delimiter);
14605 }
14606 /**
14607 * Resets the selected items to the given value.
14608 *
14609 */
14610 setValue(value, silent) {
14611 var events = silent ? [] : ['change'];
14612 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
14613 this.clear(silent);
14614 this.addItems(value, silent);
14615 });
14616 }
14617 /**
14618 * Resets the number of max items to the given value
14619 *
14620 */
14621 setMaxItems(value) {
14622 if (value === 0)
14623 value = null; //reset to unlimited items.
14624 this.settings.maxItems = value;
14625 this.refreshState();
14626 }
14627 /**
14628 * Sets the selected item.
14629 *
14630 */
14631 setActiveItem(item, e) {
14632 var self = this;
14633 var eventName;
14634 var i, begin, end, swap;
14635 var last;
14636 if (self.settings.mode === 'single')
14637 return;
14638 // clear the active selection
14639 if (!item) {
14640 self.clearActiveItems();
14641 if (self.isFocused) {
14642 self.inputState();
14643 }
14644 return;
14645 }
14646 // modify selection
14647 eventName = e && e.type.toLowerCase();
14648 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
14649 last = self.getLastActive();
14650 begin = Array.prototype.indexOf.call(self.control.children, last);
14651 end = Array.prototype.indexOf.call(self.control.children, item);
14652 if (begin > end) {
14653 swap = begin;
14654 begin = end;
14655 end = swap;
14656 }
14657 for (i = begin; i <= end; i++) {
14658 item = self.control.children[i];
14659 if (self.activeItems.indexOf(item) === -1) {
14660 self.setActiveItemClass(item);
14661 }
14662 }
14663 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
14664 }
14665 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))) {
14666 if (item.classList.contains('active')) {
14667 self.removeActiveItem(item);
14668 }
14669 else {
14670 self.setActiveItemClass(item);
14671 }
14672 }
14673 else {
14674 self.clearActiveItems();
14675 self.setActiveItemClass(item);
14676 }
14677 // ensure control has focus
14678 self.inputState();
14679 if (!self.isFocused) {
14680 self.focus();
14681 }
14682 }
14683 /**
14684 * Set the active and last-active classes
14685 *
14686 */
14687 setActiveItemClass(item) {
14688 const self = this;
14689 const last_active = self.control.querySelector('.last-active');
14690 if (last_active)
14691 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
14692 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
14693 self.trigger('item_select', item);
14694 if (self.activeItems.indexOf(item) == -1) {
14695 self.activeItems.push(item);
14696 }
14697 }
14698 /**
14699 * Remove active item
14700 *
14701 */
14702 removeActiveItem(item) {
14703 var idx = this.activeItems.indexOf(item);
14704 this.activeItems.splice(idx, 1);
14705 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
14706 }
14707 /**
14708 * Clears all the active items
14709 *
14710 */
14711 clearActiveItems() {
14712 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
14713 this.activeItems = [];
14714 }
14715 /**
14716 * Sets the selected item in the dropdown menu
14717 * of available options.
14718 *
14719 */
14720 setActiveOption(option, scroll = true) {
14721 if (option === this.activeOption) {
14722 return;
14723 }
14724 this.clearActiveOption();
14725 if (!option)
14726 return;
14727 this.activeOption = option;
14728 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
14729 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
14730 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
14731 if (scroll)
14732 this.scrollToOption(option);
14733 }
14734 /**
14735 * Sets the dropdown_content scrollTop to display the option
14736 *
14737 */
14738 scrollToOption(option, behavior) {
14739 if (!option)
14740 return;
14741 const content = this.dropdown_content;
14742 const height_menu = content.clientHeight;
14743 const scrollTop = content.scrollTop || 0;
14744 const height_item = option.offsetHeight;
14745 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
14746 if (y + height_item > height_menu + scrollTop) {
14747 this.scroll(y - height_menu + height_item, behavior);
14748 }
14749 else if (y < scrollTop) {
14750 this.scroll(y, behavior);
14751 }
14752 }
14753 /**
14754 * Scroll the dropdown to the given position
14755 *
14756 */
14757 scroll(scrollTop, behavior) {
14758 const content = this.dropdown_content;
14759 if (behavior) {
14760 content.style.scrollBehavior = behavior;
14761 }
14762 content.scrollTop = scrollTop;
14763 content.style.scrollBehavior = '';
14764 }
14765 /**
14766 * Clears the active option
14767 *
14768 */
14769 clearActiveOption() {
14770 if (this.activeOption) {
14771 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
14772 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
14773 }
14774 this.activeOption = null;
14775 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
14776 }
14777 /**
14778 * Selects all items (CTRL + A).
14779 */
14780 selectAll() {
14781 const self = this;
14782 if (self.settings.mode === 'single')
14783 return;
14784 const activeItems = self.controlChildren();
14785 if (!activeItems.length)
14786 return;
14787 self.inputState();
14788 self.close();
14789 self.activeItems = activeItems;
14790 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
14791 self.setActiveItemClass(item);
14792 });
14793 }
14794 /**
14795 * Determines if the control_input should be in a hidden or visible state
14796 *
14797 */
14798 inputState() {
14799 var self = this;
14800 if (!self.control.contains(self.control_input))
14801 return;
14802 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
14803 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
14804 self.setTextboxValue();
14805 self.isInputHidden = true;
14806 }
14807 else {
14808 if (self.settings.hidePlaceholder && self.items.length > 0) {
14809 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
14810 }
14811 self.isInputHidden = false;
14812 }
14813 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
14814 }
14815 /**
14816 * Get the input value
14817 */
14818 inputValue() {
14819 return this.control_input.value.trim();
14820 }
14821 /**
14822 * Gives the control focus.
14823 */
14824 focus() {
14825 var self = this;
14826 if (self.isDisabled || self.isReadOnly)
14827 return;
14828 self.ignoreFocus = true;
14829 if (self.control_input.offsetWidth) {
14830 self.control_input.focus();
14831 }
14832 else {
14833 self.focus_node.focus();
14834 }
14835 setTimeout(() => {
14836 self.ignoreFocus = false;
14837 self.onFocus();
14838 }, 0);
14839 }
14840 /**
14841 * Forces the control out of focus.
14842 *
14843 */
14844 blur() {
14845 this.focus_node.blur();
14846 this.onBlur();
14847 }
14848 /**
14849 * Returns a function that scores an object
14850 * to show how good of a match it is to the
14851 * provided query.
14852 *
14853 * @return {function}
14854 */
14855 getScoreFunction(query) {
14856 return this.sifter.getScoreFunction(query, this.getSearchOptions());
14857 }
14858 /**
14859 * Returns search options for sifter (the system
14860 * for scoring and sorting results).
14861 *
14862 * @see https://github.com/orchidjs/sifter.js
14863 * @return {object}
14864 */
14865 getSearchOptions() {
14866 var settings = this.settings;
14867 var sort = settings.sortField;
14868 if (typeof settings.sortField === 'string') {
14869 sort = [{ field: settings.sortField }];
14870 }
14871 return {
14872 fields: settings.searchField,
14873 conjunction: settings.searchConjunction,
14874 sort: sort,
14875 nesting: settings.nesting
14876 };
14877 }
14878 /**
14879 * Searches through available options and returns
14880 * a sorted array of matches.
14881 *
14882 */
14883 search(query) {
14884 var result, calculateScore;
14885 var self = this;
14886 var options = this.getSearchOptions();
14887 // validate user-provided result scoring function
14888 if (self.settings.score) {
14889 calculateScore = self.settings.score.call(self, query);
14890 if (typeof calculateScore !== 'function') {
14891 throw new Error('Tom Select "score" setting must be a function that returns a function');
14892 }
14893 }
14894 // perform search
14895 if (query !== self.lastQuery) {
14896 self.lastQuery = query;
14897 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
14898 self.currentResults = result;
14899 }
14900 else {
14901 result = Object.assign({}, self.currentResults);
14902 }
14903 // filter out selected items
14904 if (self.settings.hideSelected) {
14905 result.items = result.items.filter((item) => {
14906 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
14907 return !(hashed && self.items.indexOf(hashed) !== -1);
14908 });
14909 }
14910 return result;
14911 }
14912 /**
14913 * Refreshes the list of available options shown
14914 * in the autocomplete dropdown menu.
14915 *
14916 */
14917 refreshOptions(triggerDropdown = true) {
14918 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
14919 var create;
14920 const groups = {};
14921 const groups_order = [];
14922 var self = this;
14923 var query = self.inputValue();
14924 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
14925 var results = self.search(query);
14926 var active_option = null;
14927 var show_dropdown = self.settings.shouldOpen || false;
14928 var dropdown_content = self.dropdown_content;
14929 if (same_query) {
14930 active_option = self.activeOption;
14931 if (active_option) {
14932 active_group = active_option.closest('[data-group]');
14933 }
14934 }
14935 // build markup
14936 n = results.items.length;
14937 if (typeof self.settings.maxOptions === 'number') {
14938 n = Math.min(n, self.settings.maxOptions);
14939 }
14940 if (n > 0) {
14941 show_dropdown = true;
14942 }
14943 // get fragment for group and the position of the group in group_order
14944 const getGroupFragment = (optgroup, order) => {
14945 let group_order_i = groups[optgroup];
14946 if (group_order_i !== undefined) {
14947 let order_group = groups_order[group_order_i];
14948 if (order_group !== undefined) {
14949 return [group_order_i, order_group.fragment];
14950 }
14951 }
14952 let group_fragment = document.createDocumentFragment();
14953 group_order_i = groups_order.length;
14954 groups_order.push({ fragment: group_fragment, order, optgroup });
14955 return [group_order_i, group_fragment];
14956 };
14957 // render and group available options individually
14958 for (i = 0; i < n; i++) {
14959 // get option dom element
14960 let item = results.items[i];
14961 if (!item)
14962 continue;
14963 let opt_value = item.id;
14964 let option = self.options[opt_value];
14965 if (option === undefined)
14966 continue;
14967 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
14968 let option_el = self.getOption(opt_hash, true);
14969 // toggle 'selected' class
14970 if (!self.settings.hideSelected) {
14971 option_el.classList.toggle('selected', self.items.includes(opt_hash));
14972 }
14973 optgroup = option[self.settings.optgroupField] || '';
14974 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
14975 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
14976 optgroup = optgroups[j];
14977 let order = option.$order;
14978 let self_optgroup = self.optgroups[optgroup];
14979 if (self_optgroup === undefined) {
14980 optgroup = '';
14981 }
14982 else {
14983 order = self_optgroup.$order;
14984 }
14985 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
14986 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
14987 if (j > 0) {
14988 option_el = option_el.cloneNode(true);
14989 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
14990 option_el.classList.add('ts-cloned');
14991 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
14992 // make sure we keep the activeOption in the same group
14993 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
14994 if (active_group && active_group.dataset.group === optgroup.toString()) {
14995 active_option = option_el;
14996 }
14997 }
14998 }
14999 group_fragment.appendChild(option_el);
15000 if (optgroup != '') {
15001 groups[optgroup] = group_order_i;
15002 }
15003 }
15004 }
15005 // sort optgroups
15006 if (self.settings.lockOptgroupOrder) {
15007 groups_order.sort((a, b) => {
15008 return a.order - b.order;
15009 });
15010 }
15011 // render optgroup headers & join groups
15012 html = document.createDocumentFragment();
15013 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
15014 let group_fragment = group_order.fragment;
15015 let optgroup = group_order.optgroup;
15016 if (!group_fragment || !group_fragment.children.length)
15017 return;
15018 let group_heading = self.optgroups[optgroup];
15019 if (group_heading !== undefined) {
15020 let group_options = document.createDocumentFragment();
15021 let header = self.render('optgroup_header', group_heading);
15022 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
15023 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
15024 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
15025 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
15026 }
15027 else {
15028 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
15029 }
15030 });
15031 dropdown_content.innerHTML = '';
15032 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
15033 // highlight matching terms inline
15034 if (self.settings.highlight) {
15035 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
15036 if (results.query.length && results.tokens.length) {
15037 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
15038 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
15039 });
15040 }
15041 }
15042 // helper method for adding templates to dropdown
15043 var add_template = (template) => {
15044 let content = self.render(template, { input: query });
15045 if (content) {
15046 show_dropdown = true;
15047 dropdown_content.insertBefore(content, dropdown_content.firstChild);
15048 }
15049 return content;
15050 };
15051 // add loading message
15052 if (self.loading) {
15053 add_template('loading');
15054 // invalid query
15055 }
15056 else if (!self.settings.shouldLoad.call(self, query)) {
15057 add_template('not_loading');
15058 // add no_results message
15059 }
15060 else if (results.items.length === 0) {
15061 add_template('no_results');
15062 }
15063 // add create option
15064 has_create_option = self.canCreate(query);
15065 if (has_create_option) {
15066 create = add_template('option_create');
15067 }
15068 // activate
15069 self.hasOptions = results.items.length > 0 || has_create_option;
15070 if (show_dropdown) {
15071 if (results.items.length > 0) {
15072 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
15073 active_option = self.getOption(self.items[0]);
15074 }
15075 if (!dropdown_content.contains(active_option)) {
15076 let active_index = 0;
15077 if (create && !self.settings.addPrecedence) {
15078 active_index = 1;
15079 }
15080 active_option = self.selectable()[active_index];
15081 }
15082 }
15083 else if (create) {
15084 active_option = create;
15085 }
15086 if (triggerDropdown && !self.isOpen) {
15087 self.open();
15088 self.scrollToOption(active_option, 'auto');
15089 }
15090 self.setActiveOption(active_option);
15091 }
15092 else {
15093 self.clearActiveOption();
15094 if (triggerDropdown && self.isOpen) {
15095 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
15096 }
15097 }
15098 }
15099 /**
15100 * Return list of selectable options
15101 *
15102 */
15103 selectable() {
15104 return this.dropdown_content.querySelectorAll('[data-selectable]');
15105 }
15106 /**
15107 * Adds an available option. If it already exists,
15108 * nothing will happen. Note: this does not refresh
15109 * the options list dropdown (use `refreshOptions`
15110 * for that).
15111 *
15112 * Usage:
15113 *
15114 * this.addOption(data)
15115 *
15116 */
15117 addOption(data, user_created = false) {
15118 const self = this;
15119 // @deprecated 1.7.7
15120 // use addOptions( array, user_created ) for adding multiple options
15121 if (Array.isArray(data)) {
15122 self.addOptions(data, user_created);
15123 return false;
15124 }
15125 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
15126 if (key === null || self.options.hasOwnProperty(key)) {
15127 return false;
15128 }
15129 data.$order = data.$order || ++self.order;
15130 data.$id = self.inputId + '-opt-' + data.$order;
15131 self.options[key] = data;
15132 self.lastQuery = null;
15133 if (user_created) {
15134 self.userOptions[key] = user_created;
15135 self.trigger('option_add', key, data);
15136 }
15137 return key;
15138 }
15139 /**
15140 * Add multiple options
15141 *
15142 */
15143 addOptions(data, user_created = false) {
15144 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
15145 this.addOption(dat, user_created);
15146 });
15147 }
15148 /**
15149 * @deprecated 1.7.7
15150 */
15151 registerOption(data) {
15152 return this.addOption(data);
15153 }
15154 /**
15155 * Registers an option group to the pool of option groups.
15156 *
15157 * @return {boolean|string}
15158 */
15159 registerOptionGroup(data) {
15160 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
15161 if (key === null)
15162 return false;
15163 data.$order = data.$order || ++this.order;
15164 this.optgroups[key] = data;
15165 return key;
15166 }
15167 /**
15168 * Registers a new optgroup for options
15169 * to be bucketed into.
15170 *
15171 */
15172 addOptionGroup(id, data) {
15173 var hashed_id;
15174 data[this.settings.optgroupValueField] = id;
15175 if (hashed_id = this.registerOptionGroup(data)) {
15176 this.trigger('optgroup_add', hashed_id, data);
15177 }
15178 }
15179 /**
15180 * Removes an existing option group.
15181 *
15182 */
15183 removeOptionGroup(id) {
15184 if (this.optgroups.hasOwnProperty(id)) {
15185 delete this.optgroups[id];
15186 this.clearCache();
15187 this.trigger('optgroup_remove', id);
15188 }
15189 }
15190 /**
15191 * Clears all existing option groups.
15192 */
15193 clearOptionGroups() {
15194 this.optgroups = {};
15195 this.clearCache();
15196 this.trigger('optgroup_clear');
15197 }
15198 /**
15199 * Updates an option available for selection. If
15200 * it is visible in the selected items or options
15201 * dropdown, it will be re-rendered automatically.
15202 *
15203 */
15204 updateOption(value, data) {
15205 const self = this;
15206 var item_new;
15207 var index_item;
15208 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
15209 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
15210 // sanity checks
15211 if (value_old === null)
15212 return;
15213 const data_old = self.options[value_old];
15214 if (data_old == undefined)
15215 return;
15216 if (typeof value_new !== 'string')
15217 throw new Error('Value must be set in option data');
15218 const option = self.getOption(value_old);
15219 const item = self.getItem(value_old);
15220 data.$order = data.$order || data_old.$order;
15221 delete self.options[value_old];
15222 // invalidate render cache
15223 // don't remove existing node yet, we'll remove it after replacing it
15224 self.uncacheValue(value_new);
15225 self.options[value_new] = data;
15226 // update the option if it's in the dropdown
15227 if (option) {
15228 if (self.dropdown_content.contains(option)) {
15229 const option_new = self._render('option', data);
15230 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
15231 if (self.activeOption === option) {
15232 self.setActiveOption(option_new);
15233 }
15234 }
15235 option.remove();
15236 }
15237 // update the item if we have one
15238 if (item) {
15239 index_item = self.items.indexOf(value_old);
15240 if (index_item !== -1) {
15241 self.items.splice(index_item, 1, value_new);
15242 }
15243 item_new = self._render('item', data);
15244 if (item.classList.contains('active'))
15245 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
15246 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
15247 }
15248 // invalidate last query because we might have updated the sortField
15249 self.lastQuery = null;
15250 }
15251 /**
15252 * Removes a single option.
15253 *
15254 */
15255 removeOption(value, silent) {
15256 const self = this;
15257 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
15258 self.uncacheValue(value);
15259 delete self.userOptions[value];
15260 delete self.options[value];
15261 self.lastQuery = null;
15262 self.trigger('option_remove', value);
15263 self.removeItem(value, silent);
15264 }
15265 /**
15266 * Clears all options.
15267 */
15268 clearOptions(filter) {
15269 const boundFilter = (filter || this.clearFilter).bind(this);
15270 this.loadedSearches = {};
15271 this.userOptions = {};
15272 this.clearCache();
15273 const selected = {};
15274 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
15275 if (boundFilter(option, key)) {
15276 selected[key] = option;
15277 }
15278 });
15279 this.options = this.sifter.items = selected;
15280 this.lastQuery = null;
15281 this.trigger('option_clear');
15282 }
15283 /**
15284 * Used by clearOptions() to decide whether or not an option should be removed
15285 * Return true to keep an option, false to remove
15286 *
15287 */
15288 clearFilter(option, value) {
15289 if (this.items.indexOf(value) >= 0) {
15290 return true;
15291 }
15292 return false;
15293 }
15294 /**
15295 * Returns the dom element of the option
15296 * matching the given value.
15297 *
15298 */
15299 getOption(value, create = false) {
15300 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
15301 if (hashed === null)
15302 return null;
15303 const option = this.options[hashed];
15304 if (option != undefined) {
15305 if (option.$div) {
15306 return option.$div;
15307 }
15308 if (create) {
15309 return this._render('option', option);
15310 }
15311 }
15312 return null;
15313 }
15314 /**
15315 * Returns the dom element of the next or previous dom element of the same type
15316 * Note: adjacent options may not be adjacent DOM elements (optgroups)
15317 *
15318 */
15319 getAdjacent(option, direction, type = 'option') {
15320 var self = this, all;
15321 if (!option) {
15322 return null;
15323 }
15324 if (type == 'item') {
15325 all = self.controlChildren();
15326 }
15327 else {
15328 all = self.dropdown_content.querySelectorAll('[data-selectable]');
15329 }
15330 for (let i = 0; i < all.length; i++) {
15331 if (all[i] != option) {
15332 continue;
15333 }
15334 if (direction > 0) {
15335 return all[i + 1];
15336 }
15337 return all[i - 1];
15338 }
15339 return null;
15340 }
15341 /**
15342 * Returns the dom element of the item
15343 * matching the given value.
15344 *
15345 */
15346 getItem(item) {
15347 if (typeof item == 'object') {
15348 return item;
15349 }
15350 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
15351 return value !== null
15352 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
15353 : null;
15354 }
15355 /**
15356 * "Selects" multiple items at once. Adds them to the list
15357 * at the current caret position.
15358 *
15359 */
15360 addItems(values, silent) {
15361 var self = this;
15362 var items = Array.isArray(values) ? values : [values];
15363 items = items.filter(x => self.items.indexOf(x) === -1);
15364 const last_item = items[items.length - 1];
15365 items.forEach(item => {
15366 self.isPending = (item !== last_item);
15367 self.addItem(item, silent);
15368 });
15369 }
15370 /**
15371 * "Selects" an item. Adds it to the list
15372 * at the current caret position.
15373 *
15374 */
15375 addItem(value, silent) {
15376 var events = silent ? [] : ['change', 'dropdown_close'];
15377 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
15378 var item, wasFull;
15379 const self = this;
15380 const inputMode = self.settings.mode;
15381 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
15382 if (hashed && self.items.indexOf(hashed) !== -1) {
15383 if (inputMode === 'single') {
15384 self.close();
15385 }
15386 if (inputMode === 'single' || !self.settings.duplicates) {
15387 return;
15388 }
15389 }
15390 if (hashed === null || !self.options.hasOwnProperty(hashed))
15391 return;
15392 if (inputMode === 'single')
15393 self.clear(silent);
15394 if (inputMode === 'multi' && self.isFull())
15395 return;
15396 item = self._render('item', self.options[hashed]);
15397 if (self.control.contains(item)) { // duplicates
15398 item = item.cloneNode(true);
15399 }
15400 wasFull = self.isFull();
15401 self.items.splice(self.caretPos, 0, hashed);
15402 self.insertAtCaret(item);
15403 if (self.isSetup) {
15404 // update menu / remove the option (if this is not one item being added as part of series)
15405 if (!self.isPending && self.settings.hideSelected) {
15406 let option = self.getOption(hashed);
15407 let next = self.getAdjacent(option, 1);
15408 if (next) {
15409 self.setActiveOption(next);
15410 }
15411 }
15412 // refreshOptions after setActiveOption(),
15413 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
15414 if (!self.isPending && !self.settings.closeAfterSelect) {
15415 self.refreshOptions(self.isFocused && inputMode !== 'single');
15416 }
15417 // hide the menu if the maximum number of items have been selected or no options are left
15418 if (self.settings.closeAfterSelect != false && self.isFull()) {
15419 self.close();
15420 }
15421 else if (!self.isPending) {
15422 self.positionDropdown();
15423 }
15424 self.trigger('item_add', hashed, item);
15425 if (!self.isPending) {
15426 self.updateOriginalInput({ silent: silent });
15427 }
15428 }
15429 if (!self.isPending || (!wasFull && self.isFull())) {
15430 self.inputState();
15431 self.refreshState();
15432 }
15433 });
15434 }
15435 /**
15436 * Removes the selected item matching
15437 * the provided value.
15438 *
15439 */
15440 removeItem(item = null, silent) {
15441 const self = this;
15442 item = self.getItem(item);
15443 if (!item)
15444 return;
15445 var i, idx;
15446 const value = item.dataset.value;
15447 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
15448 item.remove();
15449 if (item.classList.contains('active')) {
15450 idx = self.activeItems.indexOf(item);
15451 self.activeItems.splice(idx, 1);
15452 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
15453 }
15454 self.items.splice(i, 1);
15455 self.lastQuery = null;
15456 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
15457 self.removeOption(value, silent);
15458 }
15459 if (i < self.caretPos) {
15460 self.setCaret(self.caretPos - 1);
15461 }
15462 self.updateOriginalInput({ silent: silent });
15463 self.refreshState();
15464 self.positionDropdown();
15465 self.trigger('item_remove', value, item);
15466 }
15467 /**
15468 * Invokes the `create` method provided in the
15469 * TomSelect options that should provide the data
15470 * for the new item, given the user input.
15471 *
15472 * Once this completes, it will be added
15473 * to the item list.
15474 *
15475 */
15476 createItem(input = null, callback = () => { }) {
15477 // triggerDropdown parameter @deprecated 2.1.1
15478 if (arguments.length === 3) {
15479 callback = arguments[2];
15480 }
15481 if (typeof callback != 'function') {
15482 callback = () => { };
15483 }
15484 var self = this;
15485 var caret = self.caretPos;
15486 var output;
15487 input = input || self.inputValue();
15488 if (!self.canCreate(input)) {
15489 callback();
15490 return false;
15491 }
15492 self.lock();
15493 var created = false;
15494 var create = (data) => {
15495 self.unlock();
15496 if (!data || typeof data !== 'object')
15497 return callback();
15498 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
15499 if (typeof value !== 'string') {
15500 return callback();
15501 }
15502 self.setTextboxValue();
15503 self.addOption(data, true);
15504 self.setCaret(caret);
15505 self.addItem(value);
15506 callback(data);
15507 created = true;
15508 };
15509 if (typeof self.settings.create === 'function') {
15510 output = self.settings.create.call(this, input, create);
15511 }
15512 else {
15513 output = {
15514 [self.settings.labelField]: input,
15515 [self.settings.valueField]: input,
15516 };
15517 }
15518 if (!created) {
15519 create(output);
15520 }
15521 return true;
15522 }
15523 /**
15524 * Re-renders the selected item lists.
15525 */
15526 refreshItems() {
15527 var self = this;
15528 self.lastQuery = null;
15529 if (self.isSetup) {
15530 self.addItems(self.items);
15531 }
15532 self.updateOriginalInput();
15533 self.refreshState();
15534 }
15535 /**
15536 * Updates all state-dependent attributes
15537 * and CSS classes.
15538 */
15539 refreshState() {
15540 const self = this;
15541 self.refreshValidityState();
15542 const isFull = self.isFull();
15543 const isLocked = self.isLocked;
15544 self.wrapper.classList.toggle('rtl', self.rtl);
15545 const wrap_classList = self.wrapper.classList;
15546 wrap_classList.toggle('focus', self.isFocused);
15547 wrap_classList.toggle('disabled', self.isDisabled);
15548 wrap_classList.toggle('readonly', self.isReadOnly);
15549 wrap_classList.toggle('required', self.isRequired);
15550 wrap_classList.toggle('invalid', !self.isValid);
15551 wrap_classList.toggle('locked', isLocked);
15552 wrap_classList.toggle('full', isFull);
15553 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
15554 wrap_classList.toggle('dropdown-active', self.isOpen);
15555 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
15556 wrap_classList.toggle('has-items', self.items.length > 0);
15557 }
15558 /**
15559 * Update the `required` attribute of both input and control input.
15560 *
15561 * The `required` property needs to be activated on the control input
15562 * for the error to be displayed at the right place. `required` also
15563 * needs to be temporarily deactivated on the input since the input is
15564 * hidden and can't show errors.
15565 */
15566 refreshValidityState() {
15567 var self = this;
15568 if (!self.input.validity) {
15569 return;
15570 }
15571 self.isValid = self.input.validity.valid;
15572 self.isInvalid = !self.isValid;
15573 }
15574 /**
15575 * Determines whether or not more items can be added
15576 * to the control without exceeding the user-defined maximum.
15577 *
15578 * @returns {boolean}
15579 */
15580 isFull() {
15581 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
15582 }
15583 /**
15584 * Refreshes the original <select> or <input>
15585 * element to reflect the current state.
15586 *
15587 */
15588 updateOriginalInput(opts = {}) {
15589 const self = this;
15590 var option, label;
15591 const empty_option = self.input.querySelector('option[value=""]');
15592 if (self.is_select_tag) {
15593 const selected = [];
15594 const has_selected = self.input.querySelectorAll('option:checked').length;
15595 function AddSelected(option_el, value, label) {
15596 if (!option_el) {
15597 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>');
15598 }
15599 // don't move empty option from top of list
15600 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
15601 if (option_el != empty_option) {
15602 self.input.append(option_el);
15603 }
15604 selected.push(option_el);
15605 // marking empty option as selected can break validation
15606 // fixes https://github.com/orchidjs/tom-select/issues/303
15607 if (option_el != empty_option || has_selected > 0) {
15608 option_el.selected = true;
15609 }
15610 return option_el;
15611 }
15612 // unselect all selected options
15613 self.input.querySelectorAll('option:checked').forEach((option_el) => {
15614 option_el.selected = false;
15615 });
15616 // nothing selected?
15617 if (self.items.length == 0 && self.settings.mode == 'single') {
15618 AddSelected(empty_option, "", "");
15619 // order selected <option> tags for values in self.items
15620 }
15621 else {
15622 self.items.forEach((value) => {
15623 option = self.options[value];
15624 label = option[self.settings.labelField] || '';
15625 if (selected.includes(option.$option)) {
15626 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
15627 AddSelected(reuse_opt, value, label);
15628 }
15629 else {
15630 option.$option = AddSelected(option.$option, value, label);
15631 }
15632 });
15633 }
15634 }
15635 else {
15636 self.input.value = self.getValue();
15637 }
15638 if (self.isSetup) {
15639 if (!opts.silent) {
15640 self.trigger('change', self.getValue());
15641 }
15642 }
15643 }
15644 /**
15645 * Shows the autocomplete dropdown containing
15646 * the available options.
15647 */
15648 open() {
15649 var self = this;
15650 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
15651 return;
15652 self.isOpen = true;
15653 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
15654 self.refreshState();
15655 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
15656 self.positionDropdown();
15657 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
15658 self.focus();
15659 self.trigger('dropdown_open', self.dropdown);
15660 }
15661 /**
15662 * Closes the autocomplete dropdown menu.
15663 */
15664 close(setTextboxValue = true) {
15665 var self = this;
15666 var trigger = self.isOpen;
15667 if (setTextboxValue) {
15668 // before blur() to prevent form onchange event
15669 self.setTextboxValue();
15670 if (self.settings.mode === 'single' && self.items.length) {
15671 self.inputState();
15672 }
15673 }
15674 self.isOpen = false;
15675 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
15676 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
15677 if (self.settings.hideSelected) {
15678 self.clearActiveOption();
15679 }
15680 self.refreshState();
15681 if (trigger)
15682 self.trigger('dropdown_close', self.dropdown);
15683 }
15684 /**
15685 * Calculates and applies the appropriate
15686 * position of the dropdown if dropdownParent = 'body'.
15687 * Otherwise, position is determined by css
15688 */
15689 positionDropdown() {
15690 if (this.settings.dropdownParent !== 'body') {
15691 return;
15692 }
15693 var context = this.control;
15694 var rect = context.getBoundingClientRect();
15695 var top = context.offsetHeight + rect.top + window.scrollY;
15696 var left = rect.left + window.scrollX;
15697 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
15698 width: rect.width + 'px',
15699 top: top + 'px',
15700 left: left + 'px'
15701 });
15702 }
15703 /**
15704 * Resets / clears all selected items
15705 * from the control.
15706 *
15707 */
15708 clear(silent) {
15709 var self = this;
15710 if (!self.items.length)
15711 return;
15712 var items = self.controlChildren();
15713 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
15714 self.removeItem(item, true);
15715 });
15716 self.inputState();
15717 if (!silent)
15718 self.updateOriginalInput();
15719 self.trigger('clear');
15720 }
15721 /**
15722 * A helper method for inserting an element
15723 * at the current caret position.
15724 *
15725 */
15726 insertAtCaret(el) {
15727 const self = this;
15728 const caret = self.caretPos;
15729 const target = self.control;
15730 target.insertBefore(el, target.children[caret] || null);
15731 self.setCaret(caret + 1);
15732 }
15733 /**
15734 * Removes the current selected item(s).
15735 *
15736 */
15737 deleteSelection(e) {
15738 var direction, selection, caret, tail;
15739 var self = this;
15740 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
15741 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
15742 // determine items that will be removed
15743 const rm_items = [];
15744 if (self.activeItems.length) {
15745 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
15746 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
15747 if (direction > 0) {
15748 caret++;
15749 }
15750 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
15751 }
15752 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
15753 const items = self.controlChildren();
15754 let rm_item;
15755 if (direction < 0 && selection.start === 0 && selection.length === 0) {
15756 rm_item = items[self.caretPos - 1];
15757 }
15758 else if (direction > 0 && selection.start === self.inputValue().length) {
15759 rm_item = items[self.caretPos];
15760 }
15761 if (rm_item !== undefined) {
15762 rm_items.push(rm_item);
15763 }
15764 }
15765 if (!self.shouldDelete(rm_items, e)) {
15766 return false;
15767 }
15768 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
15769 // perform removal
15770 if (typeof caret !== 'undefined') {
15771 self.setCaret(caret);
15772 }
15773 while (rm_items.length) {
15774 self.removeItem(rm_items.pop());
15775 }
15776 self.inputState();
15777 self.positionDropdown();
15778 self.refreshOptions(false);
15779 return true;
15780 }
15781 /**
15782 * Return true if the items should be deleted
15783 */
15784 shouldDelete(items, evt) {
15785 const values = items.map(item => item.dataset.value);
15786 // allow the callback to abort
15787 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
15788 return false;
15789 }
15790 return true;
15791 }
15792 /**
15793 * Selects the previous / next item (depending on the `direction` argument).
15794 *
15795 * > 0 - right
15796 * < 0 - left
15797 *
15798 */
15799 advanceSelection(direction, e) {
15800 var last_active, adjacent, self = this;
15801 if (self.rtl)
15802 direction *= -1;
15803 if (self.inputValue().length)
15804 return;
15805 // add or remove to active items
15806 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)) {
15807 last_active = self.getLastActive(direction);
15808 if (last_active) {
15809 if (!last_active.classList.contains('active')) {
15810 adjacent = last_active;
15811 }
15812 else {
15813 adjacent = self.getAdjacent(last_active, direction, 'item');
15814 }
15815 // if no active item, get items adjacent to the control input
15816 }
15817 else if (direction > 0) {
15818 adjacent = self.control_input.nextElementSibling;
15819 }
15820 else {
15821 adjacent = self.control_input.previousElementSibling;
15822 }
15823 if (adjacent) {
15824 if (adjacent.classList.contains('active')) {
15825 self.removeActiveItem(last_active);
15826 }
15827 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
15828 }
15829 // move caret to the left or right
15830 }
15831 else {
15832 self.moveCaret(direction);
15833 }
15834 }
15835 moveCaret(direction) { }
15836 /**
15837 * Get the last active item
15838 *
15839 */
15840 getLastActive(direction) {
15841 let last_active = this.control.querySelector('.last-active');
15842 if (last_active) {
15843 return last_active;
15844 }
15845 var result = this.control.querySelectorAll('.active');
15846 if (result) {
15847 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
15848 }
15849 }
15850 /**
15851 * Moves the caret to the specified index.
15852 *
15853 * The input must be moved by leaving it in place and moving the
15854 * siblings, due to the fact that focus cannot be restored once lost
15855 * on mobile webkit devices
15856 *
15857 */
15858 setCaret(new_pos) {
15859 this.caretPos = this.items.length;
15860 }
15861 /**
15862 * Return list of item dom elements
15863 *
15864 */
15865 controlChildren() {
15866 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
15867 }
15868 /**
15869 * Disables user input on the control. Used while
15870 * items are being asynchronously created.
15871 */
15872 lock() {
15873 this.setLocked(true);
15874 }
15875 /**
15876 * Re-enables user input on the control.
15877 */
15878 unlock() {
15879 this.setLocked(false);
15880 }
15881 /**
15882 * Disable or enable user input on the control
15883 */
15884 setLocked(lock = this.isReadOnly || this.isDisabled) {
15885 this.isLocked = lock;
15886 this.refreshState();
15887 }
15888 /**
15889 * Disables user input on the control completely.
15890 * While disabled, it cannot receive focus.
15891 */
15892 disable() {
15893 this.setDisabled(true);
15894 this.close();
15895 }
15896 /**
15897 * Enables the control so that it can respond
15898 * to focus and user input.
15899 */
15900 enable() {
15901 this.setDisabled(false);
15902 }
15903 setDisabled(disabled) {
15904 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
15905 this.isDisabled = disabled;
15906 this.input.disabled = disabled;
15907 this.control_input.disabled = disabled;
15908 this.setLocked();
15909 }
15910 setReadOnly(isReadOnly) {
15911 this.isReadOnly = isReadOnly;
15912 this.input.readOnly = isReadOnly;
15913 this.control_input.readOnly = isReadOnly;
15914 this.setLocked();
15915 }
15916 /**
15917 * Completely destroys the control and
15918 * unbinds all event listeners so that it can
15919 * be garbage collected.
15920 */
15921 destroy() {
15922 var self = this;
15923 var revertSettings = self.revertSettings;
15924 self.trigger('destroy');
15925 self.off();
15926 self.wrapper.remove();
15927 self.dropdown.remove();
15928 self.input.innerHTML = revertSettings.innerHTML;
15929 self.input.tabIndex = revertSettings.tabIndex;
15930 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
15931 self._destroy();
15932 delete self.input.tomselect;
15933 }
15934 /**
15935 * A helper method for rendering "item" and
15936 * "option" templates, given the data.
15937 *
15938 */
15939 render(templateName, data) {
15940 var id, html;
15941 const self = this;
15942 if (typeof this.settings.render[templateName] !== 'function') {
15943 return null;
15944 }
15945 // render markup
15946 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
15947 if (!html) {
15948 return null;
15949 }
15950 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
15951 // add mandatory attributes
15952 if (templateName === 'option' || templateName === 'option_create') {
15953 if (data[self.settings.disabledField]) {
15954 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
15955 }
15956 else {
15957 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
15958 }
15959 }
15960 else if (templateName === 'optgroup') {
15961 id = data.group[self.settings.optgroupValueField];
15962 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
15963 if (data.group[self.settings.disabledField]) {
15964 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
15965 }
15966 }
15967 if (templateName === 'option' || templateName === 'item') {
15968 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
15969 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
15970 // make sure we have some classes if a template is overwritten
15971 if (templateName === 'item') {
15972 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
15973 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
15974 }
15975 else {
15976 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
15977 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
15978 role: 'option',
15979 id: data.$id
15980 });
15981 // update cache
15982 data.$div = html;
15983 self.options[value] = data;
15984 }
15985 }
15986 return html;
15987 }
15988 /**
15989 * Type guarded rendering
15990 *
15991 */
15992 _render(templateName, data) {
15993 const html = this.render(templateName, data);
15994 if (html == null) {
15995 throw 'HTMLElement expected';
15996 }
15997 return html;
15998 }
15999 /**
16000 * Clears the render cache for a template. If
16001 * no template is given, clears all render
16002 * caches.
16003 *
16004 */
16005 clearCache() {
16006 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
16007 if (option.$div) {
16008 option.$div.remove();
16009 delete option.$div;
16010 }
16011 });
16012 }
16013 /**
16014 * Removes a value from item and option caches
16015 *
16016 */
16017 uncacheValue(value) {
16018 const option_el = this.getOption(value);
16019 if (option_el)
16020 option_el.remove();
16021 }
16022 /**
16023 * Determines whether or not to display the
16024 * create item prompt, given a user input.
16025 *
16026 */
16027 canCreate(input) {
16028 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
16029 }
16030 /**
16031 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
16032 *
16033 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
16034 *
16035 * });
16036 */
16037 hook(when, method, new_fn) {
16038 var self = this;
16039 var orig_method = self[method];
16040 self[method] = function () {
16041 var result, result_new;
16042 if (when === 'after') {
16043 result = orig_method.apply(self, arguments);
16044 }
16045 result_new = new_fn.apply(self, arguments);
16046 if (when === 'instead') {
16047 return result_new;
16048 }
16049 if (when === 'before') {
16050 result = orig_method.apply(self, arguments);
16051 }
16052 return result;
16053 };
16054 }
16055 }
16056 ;
16057 //# sourceMappingURL=tom-select.js.map
16058
16059 /***/ }),
16060
16061 /***/ "./node_modules/tom-select/dist/esm/utils.js":
16062 /*!***************************************************!*\
16063 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
16064 \***************************************************/
16065 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
16066
16067 "use strict";
16068 __webpack_require__.r(__webpack_exports__);
16069 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
16070 /* harmony export */ addEvent: () => (/* binding */ addEvent),
16071 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
16072 /* harmony export */ append: () => (/* binding */ append),
16073 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
16074 /* harmony export */ escape_html: () => (/* binding */ escape_html),
16075 /* harmony export */ getId: () => (/* binding */ getId),
16076 /* harmony export */ getSelection: () => (/* binding */ getSelection),
16077 /* harmony export */ get_hash: () => (/* binding */ get_hash),
16078 /* harmony export */ hash_key: () => (/* binding */ hash_key),
16079 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
16080 /* harmony export */ iterate: () => (/* binding */ iterate),
16081 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
16082 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
16083 /* harmony export */ timeout: () => (/* binding */ timeout)
16084 /* harmony export */ });
16085 /**
16086 * Converts a scalar to its best string representation
16087 * for hash keys and HTML attribute values.
16088 *
16089 * Transformations:
16090 * 'str' -> 'str'
16091 * null -> ''
16092 * undefined -> ''
16093 * true -> '1'
16094 * false -> '0'
16095 * 0 -> '0'
16096 * 1 -> '1'
16097 *
16098 */
16099 const hash_key = (value) => {
16100 if (typeof value === 'undefined' || value === null)
16101 return null;
16102 return get_hash(value);
16103 };
16104 const get_hash = (value) => {
16105 if (typeof value === 'boolean')
16106 return value ? '1' : '0';
16107 return value + '';
16108 };
16109 /**
16110 * Escapes a string for use within HTML.
16111 *
16112 */
16113 const escape_html = (str) => {
16114 return (str + '')
16115 .replace(/&/g, '&amp;')
16116 .replace(/</g, '&lt;')
16117 .replace(/>/g, '&gt;')
16118 .replace(/"/g, '&quot;');
16119 };
16120 /**
16121 * use setTimeout if timeout > 0
16122 */
16123 const timeout = (fn, timeout) => {
16124 if (timeout > 0) {
16125 return window.setTimeout(fn, timeout);
16126 }
16127 fn.call(null);
16128 return null;
16129 };
16130 /**
16131 * Debounce the user provided load function
16132 *
16133 */
16134 const loadDebounce = (fn, delay) => {
16135 var timeout;
16136 return function (value, callback) {
16137 var self = this;
16138 if (timeout) {
16139 self.loading = Math.max(self.loading - 1, 0);
16140 clearTimeout(timeout);
16141 }
16142 timeout = setTimeout(function () {
16143 timeout = null;
16144 self.loadedSearches[value] = true;
16145 fn.call(self, value, callback);
16146 }, delay);
16147 };
16148 };
16149 /**
16150 * Debounce all fired events types listed in `types`
16151 * while executing the provided `fn`.
16152 *
16153 */
16154 const debounce_events = (self, types, fn) => {
16155 var type;
16156 var trigger = self.trigger;
16157 var event_args = {};
16158 // override trigger method
16159 self.trigger = function () {
16160 var type = arguments[0];
16161 if (types.indexOf(type) !== -1) {
16162 event_args[type] = arguments;
16163 }
16164 else {
16165 return trigger.apply(self, arguments);
16166 }
16167 };
16168 // invoke provided function
16169 fn.apply(self, []);
16170 self.trigger = trigger;
16171 // trigger queued events
16172 for (type of types) {
16173 if (type in event_args) {
16174 trigger.apply(self, event_args[type]);
16175 }
16176 }
16177 };
16178 /**
16179 * Determines the current selection within a text input control.
16180 * Returns an object containing:
16181 * - start
16182 * - length
16183 *
16184 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
16185 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
16186 */
16187 const getSelection = (input) => {
16188 return {
16189 start: input.selectionStart || 0,
16190 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
16191 };
16192 };
16193 /**
16194 * Prevent default
16195 *
16196 */
16197 const preventDefault = (evt, stop = false) => {
16198 if (evt) {
16199 evt.preventDefault();
16200 if (stop) {
16201 evt.stopPropagation();
16202 }
16203 }
16204 };
16205 /**
16206 * Add event helper
16207 *
16208 */
16209 const addEvent = (target, type, callback, options) => {
16210 target.addEventListener(type, callback, options);
16211 };
16212 /**
16213 * Return true if the requested key is down
16214 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
16215 * The current evt may not always set ( eg calling advanceSelection() )
16216 *
16217 */
16218 const isKeyDown = (key_name, evt) => {
16219 if (!evt) {
16220 return false;
16221 }
16222 if (!evt[key_name]) {
16223 return false;
16224 }
16225 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
16226 if (count === 1) {
16227 return true;
16228 }
16229 return false;
16230 };
16231 /**
16232 * Get the id of an element
16233 * If the id attribute is not set, set the attribute with the given id
16234 *
16235 */
16236 const getId = (el, id) => {
16237 const existing_id = el.getAttribute('id');
16238 if (existing_id) {
16239 return existing_id;
16240 }
16241 el.setAttribute('id', id);
16242 return id;
16243 };
16244 /**
16245 * Returns a string with backslashes added before characters that need to be escaped.
16246 */
16247 const addSlashes = (str) => {
16248 return str.replace(/[\\"']/g, '\\$&');
16249 };
16250 /**
16251 *
16252 */
16253 const append = (parent, node) => {
16254 if (node)
16255 parent.append(node);
16256 };
16257 /**
16258 * Iterates over arrays and hashes.
16259 *
16260 * ```
16261 * iterate(this.items, function(item, id) {
16262 * // invoked for each item
16263 * });
16264 * ```
16265 *
16266 */
16267 const iterate = (object, callback) => {
16268 if (Array.isArray(object)) {
16269 object.forEach(callback);
16270 }
16271 else {
16272 for (var key in object) {
16273 if (object.hasOwnProperty(key)) {
16274 callback(object[key], key);
16275 }
16276 }
16277 }
16278 };
16279 //# sourceMappingURL=utils.js.map
16280
16281 /***/ }),
16282
16283 /***/ "./node_modules/tom-select/dist/esm/vanilla.js":
16284 /*!*****************************************************!*\
16285 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
16286 \*****************************************************/
16287 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
16288
16289 "use strict";
16290 __webpack_require__.r(__webpack_exports__);
16291 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
16292 /* harmony export */ addClasses: () => (/* binding */ addClasses),
16293 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
16294 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
16295 /* harmony export */ classesArray: () => (/* binding */ classesArray),
16296 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
16297 /* harmony export */ getDom: () => (/* binding */ getDom),
16298 /* harmony export */ getTail: () => (/* binding */ getTail),
16299 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
16300 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
16301 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
16302 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
16303 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
16304 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
16305 /* harmony export */ setAttr: () => (/* binding */ setAttr),
16306 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
16307 /* harmony export */ });
16308 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
16309
16310 /**
16311 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
16312 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
16313 *
16314 * param query should be {}
16315 */
16316 const getDom = (query) => {
16317 if (query.jquery) {
16318 return query[0];
16319 }
16320 if (query instanceof HTMLElement) {
16321 return query;
16322 }
16323 if (isHtmlString(query)) {
16324 var tpl = document.createElement('template');
16325 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
16326 return tpl.content.firstChild;
16327 }
16328 return document.querySelector(query);
16329 };
16330 const isHtmlString = (arg) => {
16331 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
16332 return true;
16333 }
16334 return false;
16335 };
16336 const escapeQuery = (query) => {
16337 return query.replace(/['"\\]/g, '\\$&');
16338 };
16339 /**
16340 * Dispatch an event
16341 *
16342 */
16343 const triggerEvent = (dom_el, event_name) => {
16344 var event = document.createEvent('HTMLEvents');
16345 event.initEvent(event_name, true, false);
16346 dom_el.dispatchEvent(event);
16347 };
16348 /**
16349 * Apply CSS rules to a dom element
16350 *
16351 */
16352 const applyCSS = (dom_el, css) => {
16353 Object.assign(dom_el.style, css);
16354 };
16355 /**
16356 * Add css classes
16357 *
16358 */
16359 const addClasses = (elmts, ...classes) => {
16360 var norm_classes = classesArray(classes);
16361 elmts = castAsArray(elmts);
16362 elmts.map(el => {
16363 norm_classes.map(cls => {
16364 el.classList.add(cls);
16365 });
16366 });
16367 };
16368 /**
16369 * Remove css classes
16370 *
16371 */
16372 const removeClasses = (elmts, ...classes) => {
16373 var norm_classes = classesArray(classes);
16374 elmts = castAsArray(elmts);
16375 elmts.map(el => {
16376 norm_classes.map(cls => {
16377 el.classList.remove(cls);
16378 });
16379 });
16380 };
16381 /**
16382 * Return arguments
16383 *
16384 */
16385 const classesArray = (args) => {
16386 var classes = [];
16387 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
16388 if (typeof _classes === 'string') {
16389 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
16390 }
16391 if (Array.isArray(_classes)) {
16392 classes = classes.concat(_classes);
16393 }
16394 });
16395 return classes.filter(Boolean);
16396 };
16397 /**
16398 * Create an array from arg if it's not already an array
16399 *
16400 */
16401 const castAsArray = (arg) => {
16402 if (!Array.isArray(arg)) {
16403 arg = [arg];
16404 }
16405 return arg;
16406 };
16407 /**
16408 * Get the closest node to the evt.target matching the selector
16409 * Stops at wrapper
16410 *
16411 */
16412 const parentMatch = (target, selector, wrapper) => {
16413 if (wrapper && !wrapper.contains(target)) {
16414 return;
16415 }
16416 while (target && target.matches) {
16417 if (target.matches(selector)) {
16418 return target;
16419 }
16420 target = target.parentNode;
16421 }
16422 };
16423 /**
16424 * Get the first or last item from an array
16425 *
16426 * > 0 - right (last)
16427 * <= 0 - left (first)
16428 *
16429 */
16430 const getTail = (list, direction = 0) => {
16431 if (direction > 0) {
16432 return list[list.length - 1];
16433 }
16434 return list[0];
16435 };
16436 /**
16437 * Return true if an object is empty
16438 *
16439 */
16440 const isEmptyObject = (obj) => {
16441 return (Object.keys(obj).length === 0);
16442 };
16443 /**
16444 * Get the index of an element amongst sibling nodes of the same type
16445 *
16446 */
16447 const nodeIndex = (el, amongst) => {
16448 if (!el)
16449 return -1;
16450 amongst = amongst || el.nodeName;
16451 var i = 0;
16452 while (el = el.previousElementSibling) {
16453 if (el.matches(amongst)) {
16454 i++;
16455 }
16456 }
16457 return i;
16458 };
16459 /**
16460 * Set attributes of an element
16461 *
16462 */
16463 const setAttr = (el, attrs) => {
16464 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
16465 if (val == null) {
16466 el.removeAttribute(attr);
16467 }
16468 else {
16469 el.setAttribute(attr, '' + val);
16470 }
16471 });
16472 };
16473 /**
16474 * Replace a node
16475 */
16476 const replaceNode = (existing, replacement) => {
16477 if (existing.parentNode)
16478 existing.parentNode.replaceChild(replacement, existing);
16479 };
16480 //# sourceMappingURL=vanilla.js.map
16481
16482 /***/ })
16483
16484 /******/ });
16485 /************************************************************************/
16486 /******/ // The module cache
16487 /******/ var __webpack_module_cache__ = {};
16488 /******/
16489 /******/ // The require function
16490 /******/ function __webpack_require__(moduleId) {
16491 /******/ // Check if module is in cache
16492 /******/ var cachedModule = __webpack_module_cache__[moduleId];
16493 /******/ if (cachedModule !== undefined) {
16494 /******/ return cachedModule.exports;
16495 /******/ }
16496 /******/ // Create a new module (and put it into the cache)
16497 /******/ var module = __webpack_module_cache__[moduleId] = {
16498 /******/ id: moduleId,
16499 /******/ // no module.loaded needed
16500 /******/ exports: {}
16501 /******/ };
16502 /******/
16503 /******/ // Execute the module function
16504 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
16505 /******/
16506 /******/ // Return the exports of the module
16507 /******/ return module.exports;
16508 /******/ }
16509 /******/
16510 /************************************************************************/
16511 /******/ /* webpack/runtime/compat get default export */
16512 /******/ (() => {
16513 /******/ // getDefaultExport function for compatibility with non-harmony modules
16514 /******/ __webpack_require__.n = (module) => {
16515 /******/ var getter = module && module.__esModule ?
16516 /******/ () => (module['default']) :
16517 /******/ () => (module);
16518 /******/ __webpack_require__.d(getter, { a: getter });
16519 /******/ return getter;
16520 /******/ };
16521 /******/ })();
16522 /******/
16523 /******/ /* webpack/runtime/define property getters */
16524 /******/ (() => {
16525 /******/ // define getter functions for harmony exports
16526 /******/ __webpack_require__.d = (exports, definition) => {
16527 /******/ for(var key in definition) {
16528 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
16529 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
16530 /******/ }
16531 /******/ }
16532 /******/ };
16533 /******/ })();
16534 /******/
16535 /******/ /* webpack/runtime/hasOwnProperty shorthand */
16536 /******/ (() => {
16537 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
16538 /******/ })();
16539 /******/
16540 /******/ /* webpack/runtime/make namespace object */
16541 /******/ (() => {
16542 /******/ // define __esModule on exports
16543 /******/ __webpack_require__.r = (exports) => {
16544 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
16545 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16546 /******/ }
16547 /******/ Object.defineProperty(exports, '__esModule', { value: true });
16548 /******/ };
16549 /******/ })();
16550 /******/
16551 /******/ /* webpack/runtime/nonce */
16552 /******/ (() => {
16553 /******/ __webpack_require__.nc = undefined;
16554 /******/ })();
16555 /******/
16556 /************************************************************************/
16557 var __webpack_exports__ = {};
16558 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
16559 (() => {
16560 "use strict";
16561 /*!***************************************************************!*\
16562 !*** ./assets/src/js/admin/edit-curriculum/edit-course-ai.js ***!
16563 \***************************************************************/
16564 __webpack_require__.r(__webpack_exports__);
16565 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
16566 /* harmony export */ CourseAI: () => (/* binding */ CourseAI)
16567 /* harmony export */ });
16568 /* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/esm/classCallCheck.js");
16569 /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/esm/createClass.js");
16570 /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js");
16571 /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
16572 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
16573 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
16574 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_5__);
16575 /* harmony import */ var _edit_section_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./edit-section.js */ "./assets/src/js/admin/edit-curriculum/edit-section.js");
16576 /* harmony import */ var _share_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./share.js */ "./assets/src/js/admin/edit-curriculum/share.js");
16577
16578
16579
16580
16581 /**
16582 *
16583 * @since 4.2.8.6
16584 * @version 1.3.2
16585 */
16586
16587
16588
16589
16590
16591 var buildSelectOptions = function buildSelectOptions(options) {
16592 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
16593 var html = "<option value=\"\">".concat(defaultValue, "</option>");
16594 for (var _i = 0, _Object$entries = Object.entries(options); _i < _Object$entries.length; _i++) {
16595 var _Object$entries$_i = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_3__["default"])(_Object$entries[_i], 2),
16596 key = _Object$entries$_i[0],
16597 value = _Object$entries$_i[1];
16598 html += "<option value=\"".concat(key, "\">").concat(value, "</option>");
16599 }
16600 return html;
16601 };
16602 var CourseAI = /*#__PURE__*/function () {
16603 function CourseAI() {
16604 (0,_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__["default"])(this, CourseAI);
16605 (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2__["default"])(this, "tomSelect", function () {
16606 var tomSelectNodes = document.querySelectorAll('select.lp-tom-select');
16607 tomSelectNodes.forEach(function (tomSelectNode) {
16608 if (tomSelectNode.tomselect) {
16609 tomSelectNode.tomselect.destroy();
16610 }
16611 var settings = {
16612 maxOptions: null,
16613 plugins: tomSelectNode.multiple ? ['no_backspace_delete', 'remove_button', 'dropdown_input', 'change_listener'] : ['dropdown_input']
16614 };
16615 new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"](tomSelectNode, settings);
16616 });
16617 });
16618 this.init();
16619 }
16620 return (0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(CourseAI, [{
16621 key: "showPopupCreateTitle",
16622 value: function showPopupCreateTitle() {
16623 var _this = this;
16624 var _lpCourseAiModalData = lpCourseAiModalData,
16625 i18n = _lpCourseAiModalData.i18n,
16626 options = _lpCourseAiModalData.options;
16627 var modalHtml = "\n\t\t\t<div class=\"modal-content\">\n\t\t\t\t<div class=\"input-section\">\n\t\t\t\t\t<h3>".concat(i18n.describeCourseAbout, "</h3>\n\t\t\t\t\t<textarea id=\"swal-course-topic\" placeholder=\"e.g. A course to teach how to use LearnPress\"></textarea>\n\t\t\t\t\t<h3>").concat(i18n.describeCourseGoals, "</h3>\n\t\t\t\t\t<textarea id=\"swal-course-goals\" placeholder=\"e.g. A course for beginners to learn WordPress\"></textarea>\n\t\t\t\t\t<h3>").concat(i18n.audience, "</h3>\n\t\t\t\t\t<select id=\"swal-audience\" multiple>").concat(buildSelectOptions(options.audience), "</select>\n\t\t\t\t\t<h3>").concat(i18n.tone, "</h3>\n\t\t\t\t\t<select id=\"swal-tone\" multiple>").concat(buildSelectOptions(options.tone), "</select>\n\t\t\t\t\t<h3>").concat(i18n.outputLanguage, "</h3>\n\t\t\t\t\t<select id=\"swal-language\">").concat(buildSelectOptions(options.language), "</select>\n\t\t\t\t\t<div class=\"outputs-control\">\n\t\t\t\t\t\t<h3>").concat(i18n.outputs, "</h3>\n\t\t\t\t\t\t<div class=\"outputs-control-content\">\n\t\t\t\t\t\t<div class=\"output-number-selector\">\n\t\t\t\t\t\t\t<button id=\"lp-ai-minus-output-button\" type=\"button\">-</button>\n\t\t\t\t\t\t\t<span id=\"lp-ai-output-count\">02</span>\n\t\t\t\t\t\t\t<button id=\"lp-ai-plus-output-button\" type=\"button\">+</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t<div class=\"output-section\">\n\t\t\t\t\t<div class=\"output-header\">\n\t\t\t\t\t\t<h3>Output</h3>\n\t\t\t\t\t\t<div class=\"header-icons\">\n\t\t\t\t\t\t\t<button class=\"icon-button\">\n\t\t\t\t\t\t\t\t<img width=\"18\" height=\"18\" src=\"https://cdn-icons-png.flaticon.com/512/6808/6808309.png\" alt=\"Maximize\"/>\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"output-item\" id=\"lp-ai-output-prompt\">\n\t\t\t\t\t\t<p class=\"prompt\">").concat(i18n.prompt || 'Prompt:', "</p>\n\t\t\t\t\t\t<textarea class=\"prompt-text\" rows=\"6\" id=\"lp-ai-output-prompt-desc\" placeholder=\"e.g. A course to teach how to use LearnPress\"></textarea>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div id=\"lp-ai-output-suggestion\"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t");
16628 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire({
16629 title: i18n.createCourseTitle,
16630 html: modalHtml,
16631 showConfirmButton: true,
16632 confirmButtonText: i18n.generate,
16633 customClass: {
16634 popup: 'create-course-modal',
16635 confirmButton: 'generate-button',
16636 actions: 'input-section'
16637 },
16638 width: '1000px',
16639 showCloseButton: true,
16640 didOpen: function didOpen() {
16641 var audienceSelect = new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"]('#swal-audience', {
16642 plugins: ['remove_button']
16643 });
16644 var toneSelect = new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"]('#swal-tone', {
16645 plugins: ['remove_button']
16646 });
16647 var languageSelect = new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"]('#swal-language', {});
16648 try {
16649 var savedAudience = localStorage.getItem('lp_ai_audience');
16650 if (savedAudience) {
16651 audienceSelect.setValue(JSON.parse(savedAudience));
16652 }
16653 var savedTone = localStorage.getItem('lp_ai_tone');
16654 if (savedTone) {
16655 toneSelect.setValue(savedTone);
16656 }
16657 var savedLang = localStorage.getItem('lp_ai_lang');
16658 if (savedLang) {
16659 languageSelect.setValue(savedLang);
16660 }
16661 } catch (e) {
16662 console.error('Lỗi khi tải cài đặt AI từ localStorage:', e);
16663 }
16664 var countEl = document.getElementById('lp-ai-output-count');
16665 document.getElementById('lp-ai-minus-output-button').addEventListener('click', function () {
16666 var count = parseInt(countEl.textContent, 10);
16667 if (count > 1) count--;
16668 countEl.textContent = count.toString().padStart(2, '0');
16669 });
16670 document.getElementById('lp-ai-plus-output-button').addEventListener('click', function () {
16671 var count = parseInt(countEl.textContent, 10);
16672 if (count < 10) count++;
16673 countEl.textContent = count.toString().padStart(2, '0');
16674 });
16675 var actionsContainer = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getActions();
16676 var inputSection = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getPopup().querySelector('.outputs-control-content');
16677 if (actionsContainer && inputSection) {
16678 inputSection.appendChild(actionsContainer);
16679 }
16680 },
16681 preConfirm: function preConfirm() {
16682 var _popup$querySelector$, _popup$querySelector, _popup$querySelector2, _popup$querySelector3;
16683 var confirmButton = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getConfirmButton();
16684 if (confirmButton) {
16685 confirmButton.disabled = true;
16686 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().showLoading();
16687 }
16688 var popup = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getPopup();
16689 var formData = {
16690 topic: popup.querySelector('#swal-course-topic').value,
16691 goal: popup.querySelector('#swal-course-goals').value,
16692 audience: (_popup$querySelector$ = (_popup$querySelector = popup.querySelector('#swal-audience')) === null || _popup$querySelector === void 0 || (_popup$querySelector = _popup$querySelector.tomselect) === null || _popup$querySelector === void 0 ? void 0 : _popup$querySelector.getValue()) !== null && _popup$querySelector$ !== void 0 ? _popup$querySelector$ : [],
16693 tone: (_popup$querySelector2 = popup.querySelector('#swal-tone')) === null || _popup$querySelector2 === void 0 || (_popup$querySelector2 = _popup$querySelector2.tomselect) === null || _popup$querySelector2 === void 0 ? void 0 : _popup$querySelector2.getValue(),
16694 lang: [(_popup$querySelector3 = popup.querySelector('#swal-language')) === null || _popup$querySelector3 === void 0 || (_popup$querySelector3 = _popup$querySelector3.tomselect) === null || _popup$querySelector3 === void 0 ? void 0 : _popup$querySelector3.getValue()],
16695 outputs: parseInt(popup.querySelector('#lp-ai-output-count').textContent, 10)
16696 };
16697 try {
16698 localStorage.setItem('lp_ai_audience', JSON.stringify(formData.audience));
16699 localStorage.setItem('lp_ai_tone', formData.tone);
16700 localStorage.setItem('lp_ai_lang', formData.lang);
16701 } catch (e) {
16702 console.error('Lỗi khi lưu cài đặt AI vào localStorage:', e);
16703 }
16704 _this.generateContent('course-title', formData, _this.showResultPopup, _this.applyTitleAI)["catch"](function (err) {
16705 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().showValidationMessage("Request failed: ".concat(err.message));
16706 });
16707 return false;
16708 }
16709 }).then(function (result) {});
16710 }
16711 }, {
16712 key: "applyTitleAI",
16713 value: function applyTitleAI(_ref) {
16714 var text = _ref.text;
16715 var titleNode = document.querySelector('#post-body-content #title');
16716 var titleLabelNode = document.querySelector('#post-body-content #title-prompt-text');
16717 if (titleLabelNode) {
16718 titleLabelNode.classList.add('screen-reader-text');
16719 }
16720 if (titleNode) {
16721 titleNode.value = text.trim();
16722 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire({
16723 title: lpCourseAiModalData.i18n.applied,
16724 icon: 'success',
16725 timer: 1000,
16726 showConfirmButton: false
16727 });
16728 }
16729 }
16730
16731 // For Description
16732 }, {
16733 key: "showPopupCreateDescription",
16734 value: function showPopupCreateDescription() {
16735 var _this2 = this;
16736 var _lpCourseAiModalData2 = lpCourseAiModalData,
16737 i18n = _lpCourseAiModalData2.i18n,
16738 options = _lpCourseAiModalData2.options;
16739 var modalHtml = "\n\t\t\t<div class=\"modal-content\">\n\t\t\t\t<div class=\"input-section\">\n\t\t\t\t\t<h3>".concat(i18n.describeCourseStandOut, "</h3>\n\t\t\t\t\t<textarea id=\"swal-course-desc\" placeholder=\"e.g. A course to teach how to use LearnPress\"></textarea>\n\n\t\t\t\t\t<h3>").concat(i18n.audience, "</h3>\n\t\t\t\t\t<select id=\"swal-audience\" multiple>").concat(buildSelectOptions(options.audience), "</select>\n\t\t\t\t\t<h3>").concat(i18n.tone, "</h3>\n\t\t\t\t\t<select id=\"swal-tone\" multiple>").concat(buildSelectOptions(options.tone), "</select>\n\t\t\t\t\t<h3>").concat(i18n.outputLanguage, "</h3>\n\t\t\t\t\t<select id=\"swal-language\">").concat(buildSelectOptions(options.language), "</select>\n\t\t\t\t\t<div class=\"outputs-control\">\n\t\t\t\t\t\t<h3>").concat(i18n.outputs, "</h3>\n\t\t\t\t\t\t<div class=\"outputs-control-content\">\n\t\t\t\t\t\t<div class=\"output-number-selector\">\n\t\t\t\t\t\t\t<button id=\"lp-ai-minus-output-button\" type=\"button\">-</button>\n\t\t\t\t\t\t\t<span id=\"lp-ai-output-count\">02</span>\n\t\t\t\t\t\t\t<button id=\"lp-ai-plus-output-button\" type=\"button\">+</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t<div class=\"output-section\">\n\t\t\t\t\t<div class=\"output-header\">\n\t\t\t\t\t\t<h3>Output</h3>\n\t\t\t\t\t\t<div class=\"header-icons\">\n\t\t\t\t\t\t\t<button class=\"icon-button\">\n\t\t\t\t\t\t\t\t<img width=\"18\" height=\"18\" src=\"https://cdn-icons-png.flaticon.com/512/6808/6808309.png\" alt=\"Maximize\"/>\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"output-item\" id=\"lp-ai-output-prompt\">\n\t\t\t\t\t\t<p class=\"prompt\">").concat(i18n.prompt || 'Prompt:', "</p>\n\t\t\t\t\t\t<textarea class=\"prompt-text\" rows=\"6\" id=\"lp-ai-output-prompt-desc\" placeholder=\"e.g. A course to teach how to use LearnPress\"></textarea>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div id=\"lp-ai-output-suggestion\"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t");
16740 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire({
16741 title: i18n.createCourseDescription,
16742 html: modalHtml,
16743 showConfirmButton: true,
16744 confirmButtonText: i18n.generate,
16745 customClass: {
16746 popup: 'create-course-modal',
16747 confirmButton: 'generate-button',
16748 actions: 'input-section'
16749 },
16750 width: '1000px',
16751 showCloseButton: true,
16752 didOpen: function didOpen() {
16753 var audienceSelect = new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"]('#swal-audience', {
16754 plugins: ['remove_button']
16755 });
16756 var toneSelect = new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"]('#swal-tone', {
16757 plugins: ['remove_button']
16758 });
16759 var languageSelect = new tom_select__WEBPACK_IMPORTED_MODULE_4__["default"]('#swal-language', {});
16760 try {
16761 var savedAudience = localStorage.getItem('lp_ai_audience');
16762 if (savedAudience) {
16763 audienceSelect.setValue(JSON.parse(savedAudience));
16764 }
16765 var savedTone = localStorage.getItem('lp_ai_tone');
16766 if (savedTone) {
16767 toneSelect.setValue(savedTone);
16768 }
16769 var savedLang = localStorage.getItem('lp_ai_lang');
16770 if (savedLang) {
16771 languageSelect.setValue(savedLang);
16772 }
16773 } catch (e) {
16774 console.error('Lỗi khi tải cài đặt AI từ localStorage:', e);
16775 }
16776 var countEl = document.getElementById('lp-ai-output-count');
16777 document.getElementById('lp-ai-minus-output-button').addEventListener('click', function () {
16778 var count = parseInt(countEl.textContent, 10);
16779 if (count > 1) count--;
16780 countEl.textContent = count.toString().padStart(2, '0');
16781 });
16782 document.getElementById('lp-ai-plus-output-button').addEventListener('click', function () {
16783 var count = parseInt(countEl.textContent, 10);
16784 if (count < 10) count++;
16785 countEl.textContent = count.toString().padStart(2, '0');
16786 });
16787 var actionsContainer = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getActions();
16788 var inputSection = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getPopup().querySelector('.outputs-control-content');
16789 if (actionsContainer && inputSection) {
16790 inputSection.appendChild(actionsContainer);
16791 }
16792 },
16793 preConfirm: function preConfirm() {
16794 var _popup$querySelector$2, _popup$querySelector4, _popup$querySelector5, _popup$querySelector6, _titleCourse$value;
16795 var confirmButton = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getConfirmButton();
16796 if (confirmButton) {
16797 confirmButton.disabled = true;
16798 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().showLoading();
16799 }
16800 var popup = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getPopup();
16801 var titleCourse = document.querySelector('#post-body-content #title');
16802 var formData = {
16803 topic: popup.querySelector('#swal-course-desc').value,
16804 audience: (_popup$querySelector$2 = (_popup$querySelector4 = popup.querySelector('#swal-audience')) === null || _popup$querySelector4 === void 0 || (_popup$querySelector4 = _popup$querySelector4.tomselect) === null || _popup$querySelector4 === void 0 ? void 0 : _popup$querySelector4.getValue()) !== null && _popup$querySelector$2 !== void 0 ? _popup$querySelector$2 : [],
16805 tone: (_popup$querySelector5 = popup.querySelector('#swal-tone')) === null || _popup$querySelector5 === void 0 || (_popup$querySelector5 = _popup$querySelector5.tomselect) === null || _popup$querySelector5 === void 0 ? void 0 : _popup$querySelector5.getValue(),
16806 lang: [(_popup$querySelector6 = popup.querySelector('#swal-language')) === null || _popup$querySelector6 === void 0 || (_popup$querySelector6 = _popup$querySelector6.tomselect) === null || _popup$querySelector6 === void 0 ? void 0 : _popup$querySelector6.getValue()],
16807 outputs: parseInt(popup.querySelector('#lp-ai-output-count').textContent, 10),
16808 title: (_titleCourse$value = titleCourse.value) !== null && _titleCourse$value !== void 0 ? _titleCourse$value : ""
16809 };
16810 try {
16811 localStorage.setItem('lp_ai_audience', JSON.stringify(formData.audience));
16812 localStorage.setItem('lp_ai_tone', formData.tone);
16813 localStorage.setItem('lp_ai_lang', formData.lang);
16814 } catch (e) {
16815 console.error('Lỗi khi lưu cài đặt AI vào localStorage:', e);
16816 }
16817 _this2.generateContent('course-description', formData, _this2.showResultPopup, _this2.applyDescriptionAI)["catch"](function (err) {
16818 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().showValidationMessage("Request failed: ".concat(err.message));
16819 });
16820 return false;
16821 }
16822 }).then(function (result) {});
16823 }
16824 }, {
16825 key: "applyDescriptionAI",
16826 value: function applyDescriptionAI(_ref2) {
16827 var text = _ref2.text;
16828 if (window.tinymce && tinymce.activeEditor) {
16829 tinymce.activeEditor.setContent(text.trim());
16830 } else {
16831 console.warn('tinymce.activeEditor editor not found');
16832 }
16833 if (window.tinymce) {
16834 var editor = tinymce.get('content') || tinymce.get('post_content');
16835 if (editor) {
16836 editor.setContent(text.trim());
16837 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire({
16838 title: lpCourseAiModalData.i18n.applied,
16839 icon: 'success',
16840 timer: 1000,
16841 showConfirmButton: false
16842 });
16843 } else {
16844 console.warn('TinyMCE editor not found');
16845 }
16846 } else {
16847 console.warn('TinyMCE is not loaded');
16848 }
16849 }
16850
16851 // // For Feature Image
16852 // showPopupFeatureImage() {
16853 // const { i18n, options, modelImage } = lpCourseAiModalData;
16854 // let sizeSelector = `<label>${i18n.sizeImage}</label><select id="swal-image-size">${buildSelectOptions(options.imageSize)}</select>`;
16855 // let qualitySelector = modelImage === 'dall-e-3' ? `<label>${i18n.qualityImage}</label><select id="swal-image-quality">${buildSelectOptions(options.imageQuality)}</select>` : '';
16856 //
16857 // Swal.fire({
16858 // title: i18n.createFeaturedImage,
16859 // html: `
16860 // <div class="lp-ai-modal-form">
16861 // <label>${i18n.style}</label>
16862 // <select id="swal-image-style" multiple>${buildSelectOptions(options.imageStyle)}</select>
16863 // <label>${i18n.imagesOrIcons}</label>
16864 // <textarea id="swal-image-desc" class="swal2-textarea" placeholder="e.g. a computer, a lightbulb icon"></textarea>
16865 // ${sizeSelector}
16866 // ${qualitySelector}
16867 // </div>
16868 // `,
16869 // confirmButtonText: i18n.generate,
16870 // customClass: { popup: 'lp-ai-sweetalert' },
16871 // width: '800px',
16872 // showCloseButton: true,
16873 // didOpen: () => {
16874 // new TomSelect('#swal-image-style', { plugins: ['remove_button'] });
16875 // new TomSelect('#swal-image-size', {});
16876 // if (modelImage === 'dall-e-3') {
16877 // new TomSelect('#swal-image-quality', {});
16878 // }
16879 // },
16880 // preConfirm: () => {
16881 // const popup = Swal.getPopup();
16882 // const data = {
16883 // topic: popup.querySelector('#swal-image-desc').value,
16884 // style: new TomSelect(popup.querySelector('#swal-image-style')).getValue(),
16885 // size: [new TomSelect(popup.querySelector('#swal-image-size')).getValue()],
16886 // title: document.querySelector('#post-body-content #title').value ?? '',
16887 // };
16888 // if (modelImage === 'dall-e-3') {
16889 // data.quality = [new TomSelect(popup.querySelector('#swal-image-quality')).getValue()];
16890 // }
16891 // return data;
16892 // }
16893 // }).then((result) => {
16894 // if (result.isConfirmed) {
16895 // this.generateContent('course-feature-image', result.value, this.showImageResultsPopup, this.applyFeatureImageAI);
16896 // }
16897 // });
16898 // }
16899 //
16900 // applyFeatureImageAI(image_url) {
16901 // const { i18n, nonce } = lpCourseAiModalData;
16902 // Swal.fire({
16903 // title: i18n.generating,
16904 // text: i18n.pleaseWait,
16905 // allowOutsideClick: false,
16906 // didOpen: () => Swal.showLoading()
16907 // });
16908 //
16909 // const post_id = document.querySelector('#post_ID')?.value || 0;
16910 //
16911 // const formData = new FormData();
16912 // formData.append('action', 'lp_ajax');
16913 // formData.append('lp-load-ajax', 'save_feature_image');
16914 // formData.append('nonce', nonce);
16915 // formData.append('image_url', image_url);
16916 // formData.append('post_id', post_id);
16917 //
16918 // fetch(lpCourseAiModalData.ajaxUrl, {
16919 // method: 'POST',
16920 // body: formData,
16921 // })
16922 // .then(response => response.json())
16923 // .then(res => {
16924 // if (res.success) {
16925 // Swal.fire({ title: i18n.applied, text: 'Reloading page...', icon: 'success', timer: 1500, showConfirmButton: false })
16926 // .then(() => location.reload());
16927 // } else {
16928 // Swal.fire(i18n.errorOccurred, res.data.message || 'Unknown error', 'error');
16929 // }
16930 // })
16931 // .catch(err => {
16932 // Swal.fire(i18n.errorOccurred, err.message, 'error');
16933 // });
16934 // }
16935
16936 // For Curriculum
16937 // showPopupCreateCurriculum() {
16938 // const { i18n, options } = lpCourseAiModalData;
16939 //
16940 // Swal.fire({
16941 // title: i18n.createCourseCurriculum,
16942 // html: `
16943 // <div class="lp-ai-modal-form lp-ai-modal-grid">
16944 // <div><label>${i18n.sections}</label><input type="number" id="swal-curriculum-sections" class="swal2-input" value="3"></div>
16945 // <div><label>${i18n.lessonsPerSection}</label><input type="number" id="swal-curriculum-lessons" class="swal2-input" value="5"></div>
16946 // <div><label>${i18n.levels}</label><select id="swal-curriculum-levels">${buildSelectOptions(options.levels)}</select></div>
16947 // <div><label>${i18n.outputLanguage}</label><select id="swal-language">${buildSelectOptions(options.language)}</select></div>
16948 // <div class="full-width"><label>${i18n.specificKeyTopics}</label><textarea id="swal-curriculum-topics" class="swal2-textarea" placeholder="e.g. Common mistakes, best practices"></textarea></div>
16949 // </div>
16950 // `,
16951 // confirmButtonText: i18n.generate,
16952 // customClass: { popup: 'lp-ai-sweetalert' },
16953 // width: '800px',
16954 // showCloseButton: true,
16955 // didOpen: () => {
16956 // new TomSelect('#swal-curriculum-levels', {});
16957 // new TomSelect('#swal-language', {});
16958 // },
16959 // preConfirm: () => {
16960 // const popup = Swal.getPopup();
16961 //
16962 // const getSelectValue = (selector) => {
16963 // const el = popup.querySelector(selector);
16964 // return el && el.tomselect ? el.tomselect.getValue() : [];
16965 // };
16966 //
16967 // return {
16968 // topic: popup.querySelector('#swal-course-topic').value,
16969 // goal: popup.querySelector('#swal-course-goals').value,
16970 // audience: getSelectValue('#swal-audience'),
16971 // tone: getSelectValue('#swal-tone'),
16972 // lang: getSelectValue('#swal-language'),
16973 // };
16974 // }
16975 //
16976 // }).then((result) => {
16977 // if (result?.isConfirmed) {
16978 // this.generateContent('course-curriculum', result.value, this.showCurriculumResultsPopup, this.applyCurriculumAI);
16979 // }
16980 // });
16981 // }
16982
16983 // async applyCurriculumAI({ dataLessonsStr }) {
16984 // const elEditCurriculum = document.querySelector(lpEditCurriculumShare.className.idElEditCurriculum);
16985 // const dataSend = window.lpAJAXG.getDataSetCurrent(document.querySelector(lpEditCurriculumShare.className.LPTarget));
16986 //
16987 // if (!elEditCurriculum) {
16988 // console.error('Curriculum container not found');
16989 // return;
16990 // }
16991 //
16992 // Swal.fire({ title: lpCourseAiModalData.i18n.applied, icon: 'success', timer: 1000, showConfirmButton: false });
16993 //
16994 // lpEditCurriculumShare.setVariables({
16995 // elEditCurriculum,
16996 // courseId: dataSend.args.course_id,
16997 // elCurriculumSections: elEditCurriculum.querySelector(lpEditCurriculumShare.className.elCurriculumSections),
16998 // });
16999 // sectionEdit.init();
17000 //
17001 // try {
17002 // const curriculumData = JSON.parse(dataLessonsStr);
17003 //
17004 // for (const sectionData of (curriculumData.sections || [])) {
17005 // // const sectionEl = await sectionEdit.addSectionFromData(sectionData.section_title);
17006 // //
17007 // // if (sectionEl && sectionData.lessons?.length > 0) {
17008 // // sectionData.lessons.forEach(lesson => {
17009 // // sectionEdit.addLessonFromData(sectionEl, lesson.lesson_title);
17010 // // });
17011 // // }
17012 // }
17013 //
17014 // } catch (e) {
17015 // console.error('JSON parse error:', e);
17016 // }
17017 // }
17018 //
17019 // // Generic Content Generation using AJAX
17020 }, {
17021 key: "generateContent",
17022 value: function generateContent(type, formData, resultsCallback, applyCallback) {
17023 var _this3 = this;
17024 var _lpCourseAiModalData3 = lpCourseAiModalData,
17025 i18n = _lpCourseAiModalData3.i18n,
17026 nonce = _lpCourseAiModalData3.nonce;
17027 var isImage = type === 'course-feature-image';
17028 var ajaxAction = isImage ? 'create_course_feature_image' : 'generate_text';
17029 var data = new FormData();
17030 data.append('action', 'lp_ajax');
17031 data.append('lp-load-ajax', ajaxAction);
17032 data.append('nonce', nonce);
17033 data.append('type', type);
17034 var _loop = function _loop(key) {
17035 if (Array.isArray(formData[key])) {
17036 formData[key].forEach(function (value) {
17037 return data.append("".concat(key, "[]"), value);
17038 });
17039 } else {
17040 data.append(key, formData[key]);
17041 }
17042 };
17043 for (var key in formData) {
17044 _loop(key);
17045 }
17046 return fetch(lpCourseAiModalData.ajaxUrl, {
17047 method: 'POST',
17048 body: data
17049 }).then(function (response) {
17050 return response.json();
17051 }).then(function (res) {
17052 if (res.success) {
17053 var responseData = res.data.data;
17054 var callbackData = {
17055 prompt: responseData.prompt,
17056 content: isImage ? responseData.urls : responseData.content,
17057 extraData: isImage ? null : responseData.sections
17058 };
17059 resultsCallback.call(_this3, type, callbackData, applyCallback);
17060 } else {
17061 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire(i18n.errorOccurred, res.data.message || 'Unknown error', 'error');
17062 }
17063 })["catch"](function (err) {
17064 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire(i18n.errorOccurred, err.message, 'error');
17065 });
17066 }
17067
17068 // Generic Popups for Results
17069 }, {
17070 key: "showResultPopup",
17071 value: function showResultPopup(type, callbackData, applyCallback) {
17072 var _this4 = this;
17073 var prompt = callbackData.prompt,
17074 content = callbackData.content,
17075 extraData = callbackData.extraData;
17076 var _lpCourseAiModalData4 = lpCourseAiModalData,
17077 i18n = _lpCourseAiModalData4.i18n;
17078 var promptTextarea = document.querySelector('#lp-ai-output-prompt-desc');
17079 if (promptTextarea && prompt) {
17080 promptTextarea.value = prompt;
17081
17082 // add btn re-generate
17083 var outputPromptElm = document.querySelector('#lp-ai-output-prompt');
17084 if (!document.querySelector('#reGenerateBtn')) {
17085 var reBtn = document.createElement('button');
17086 reBtn.textContent = 'Re-generate';
17087 reBtn.id = 'reGenerateBtn';
17088 reBtn.classList.add('generate-button');
17089 reBtn.addEventListener('click', function () {
17090 var popup = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getPopup();
17091 var formData = {
17092 outputs: parseInt(popup.querySelector('#lp-ai-output-count').textContent, 10),
17093 prompt: promptTextarea.value
17094 };
17095 _this4.generateContent(type, formData, _this4.showResultPopup, applyCallback)["catch"](function (err) {
17096 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().showValidationMessage("Request failed: ".concat(err.message));
17097 });
17098 });
17099 outputPromptElm.appendChild(reBtn);
17100 }
17101 }
17102 var resultsHtml = content.map(function (item, index) {
17103 return "\n <div class=\"output-item output-suggestion\">\n <textarea>".concat(item, "</textarea>\n <div class=\"output-actions\">\n <button type=\"button\" class=\"action-button copy-button\">").concat(i18n.copy, "</button>\n <button type=\"button\" class=\"action-button apply-button\" data-index=\"").concat(index, "\">").concat(i18n.apply, "</button>\n </div>\n </div>\n ");
17104 }).join('');
17105 var suggestionContainer = document.querySelector('#lp-ai-output-suggestion');
17106 if (suggestionContainer) {
17107 suggestionContainer.innerHTML = resultsHtml;
17108 suggestionContainer.querySelectorAll('.apply-button').forEach(function (button) {
17109 button.addEventListener('click', function (e) {
17110 var target = e.currentTarget;
17111 var index = target.getAttribute('data-index');
17112 var text = target.closest('.output-item').querySelector('textarea').value;
17113 var applyData = {
17114 text: text,
17115 index: index,
17116 extraData: extraData
17117 };
17118 applyCallback.call(_this4, applyData);
17119 });
17120 });
17121 suggestionContainer.querySelectorAll('.copy-button').forEach(function (button) {
17122 button.addEventListener('click', function (e) {
17123 var textToCopy = e.currentTarget.closest('.output-item').querySelector('textarea').value;
17124 navigator.clipboard.writeText(textToCopy).then(function () {
17125 sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().fire({
17126 title: lpCourseAiModalData.i18n.copied,
17127 icon: 'success',
17128 timer: 1000,
17129 showConfirmButton: false
17130 });
17131 });
17132 });
17133 });
17134 }
17135 var confirmButton = sweetalert2__WEBPACK_IMPORTED_MODULE_5___default().getConfirmButton();
17136 if (confirmButton) {
17137 confirmButton.disabled = false;
17138 }
17139 }
17140
17141 // showImageResultsPopup(urls, applyCallback) {
17142 // const { i18n } = lpCourseAiModalData;
17143 // let resultsHtml = urls.map(url => `
17144 // <div class="output-placeholder" style="background-image: url('${url}');">
17145 // <div class="output-actions">
17146 // <button class="action-button" data-apply-url="${url}">Apply</button>
17147 // </div>
17148 // </div>
17149 // `).join('');
17150 //
17151 // Swal.fire({
17152 // title: i18n.results,
17153 // html: `<div class="lp-ai-image-results-wrapper">${resultsHtml}</div>`,
17154 // showConfirmButton: false,
17155 // showCloseButton: true,
17156 // width: '800px',
17157 // customClass: { popup: 'lp-ai-sweetalert' },
17158 // didOpen: (popup) => {
17159 // popup.addEventListener('click', (e) => {
17160 // if (e.target.matches('[data-apply-url]')) {
17161 // applyCallback.call(this, e.target.getAttribute('data-apply-url'));
17162 // }
17163 // });
17164 // }
17165 // });
17166 // }
17167 }, {
17168 key: "showCurriculumResultsPopup",
17169 value: function showCurriculumResultsPopup(contentArray, applyCallback, sectionsData) {
17170 var _this5 = this;
17171 this.showResultsPopup(contentArray, function (_ref3) {
17172 var index = _ref3.index;
17173 applyCallback.call(_this5, {
17174 dataLessonsStr: sectionsData[index]
17175 });
17176 });
17177 }
17178
17179 // Main Init and Events
17180 }, {
17181 key: "init",
17182 value: function init() {
17183 this.tomSelect();
17184 this.addAIBtns();
17185 this.events();
17186 }
17187 }, {
17188 key: "addAIBtns",
17189 value: function addAIBtns() {
17190 var __ = wp.i18n.__ || function (text) {
17191 return text;
17192 };
17193 var titleWrap = document.querySelector('body.post-type-lp_course #titlewrap');
17194 if (titleWrap && !document.getElementById('lp-edit-ai-course-title')) {
17195 titleWrap.insertAdjacentHTML('afterend', "<button type=\"button\" class=\"button\" id=\"lp-edit-ai-course-title\">".concat(__('Edit with AI', 'learnpress'), "</button>"));
17196 }
17197 var btnAddMedia = document.querySelector('body.post-type-lp_course #insert-media-button');
17198 if (btnAddMedia && !document.getElementById('lp-edit-ai-course-description')) {
17199 btnAddMedia.insertAdjacentHTML('afterend', "<button type=\"button\" class=\"button\" id=\"lp-edit-ai-course-description\">".concat(__('Edit with AI', 'learnpress'), "</button>"));
17200 }
17201 var btnAddFeatureImage = document.querySelector('body.post-type-lp_course #set-post-thumbnail');
17202 if (btnAddFeatureImage && !document.getElementById('lp-edit-ai-course-feature-image')) {
17203 btnAddFeatureImage.insertAdjacentHTML('afterend', "<button type=\"button\" class=\"button\" id=\"lp-edit-ai-course-feature-image\">".concat(__('Edit with AI', 'learnpress'), "</button>"));
17204 }
17205 var editorBox = document.querySelector('#course-editor');
17206 if (editorBox) {
17207 setTimeout(function () {
17208 if (!editorBox.querySelector('#lp-edit-ai-course-curriculum')) {
17209 var handleActions = editorBox.querySelector('.handle-actions');
17210 if (handleActions) {
17211 var btn = document.createElement('button');
17212 btn.type = 'button';
17213 btn.className = 'button';
17214 btn.id = 'lp-edit-ai-course-curriculum';
17215 btn.textContent = __('Edit with AI', 'learnpress');
17216 handleActions.prepend(btn);
17217 }
17218 }
17219 }, 1500);
17220 }
17221 }
17222 }, {
17223 key: "events",
17224 value: function events() {
17225 var _this6 = this;
17226 document.addEventListener('click', function (e) {
17227 var target = e.target;
17228 var actions = {
17229 'lp-edit-ai-course-title': _this6.showPopupCreateTitle,
17230 'lp-edit-ai-course-description': _this6.showPopupCreateDescription
17231 // 'lp-edit-ai-course-feature-image': this.showPopupFeatureImage,
17232 //'lp-edit-ai-course-curriculum': this.showPopupCreateCurriculum,
17233 };
17234 if (actions[target.id]) {
17235 e.preventDefault();
17236 actions[target.id].call(_this6);
17237 }
17238 });
17239 }
17240 }]);
17241 }();
17242 document.addEventListener('DOMContentLoaded', function () {
17243 if (typeof lpCourseAiModalData !== 'undefined') {
17244 new CourseAI();
17245 }
17246 });
17247 })();
17248
17249 /******/ })()
17250 ;
17251 //# sourceMappingURL=edit-course-ai.js.map