PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.9
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / assets / js / dist / admin / admin-order.js

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

7,340 lines 247.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ "./assets/src/js/admin/order/add-courses-to-order.js"
6 /*!***********************************************************!*\
7 !*** ./assets/src/js/admin/order/add-courses-to-order.js ***!
8 \***********************************************************/
9 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
14 /* harmony export */ });
15 /* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
16 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
17
18
19 const addCoursesToOrder = () => {
20 let elModalSearchCourses;
21 let elSearchCoursesResult;
22 let elOrderDetails, modalSearchItemsTemplate, modalContainer;
23 let elOrderModalFooter, elOrderModalBtnAdd;
24 let elListOrderItems;
25 let timeOutSearch;
26 const idModalSearchItems = '#modal-search-items';
27 const idOrderDetails = '#learn-press-order';
28 let dataSend = {
29 search: '',
30 id_not_in: '',
31 paged: 1
32 };
33 const courseIdsNewSelected = [];
34 let courseIdsAdded = [];
35 const getAllElements = () => {
36 elOrderDetails = document.querySelector('#learn-press-order');
37 modalSearchItemsTemplate = document.querySelector('#learn-press-modal-search-items');
38 modalContainer = document.querySelector('#container-modal-search-items');
39 };
40
41 /**
42 * Fetch courses from API.
43 *
44 * @param keySearch
45 * @param course_ids_exclude
46 * @param paged
47 */
48 const fetchCoursesAPI = (keySearch = '', course_ids_exclude = [], paged = 1) => {
49 let id_not_in = '';
50 if (course_ids_exclude.length > 0) {
51 id_not_in = course_ids_exclude.join(',');
52 }
53 dataSend = {
54 search: keySearch,
55 id_not_in,
56 paged
57 };
58 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.fetchCourses(keySearch, dataSend, {
59 before() {
60 elModalSearchCourses.classList.add('loading');
61 },
62 success(response) {
63 const {
64 data,
65 status,
66 message
67 } = response;
68 const {
69 courses,
70 total_pages
71 } = data;
72 if ('success' !== status) {
73 console.error(message);
74 } else {
75 if (!courses.length) {
76 elSearchCoursesResult.innerHTML = '<li class="lp-result-item">No courses found</li>';
77 return;
78 }
79 elSearchCoursesResult.innerHTML = renderSearchResult(courses);
80 const paginationHtml = renderPagination(paged, total_pages);
81 const searchNav = elModalSearchCourses.querySelector('.search-nav');
82 searchNav.innerHTML = paginationHtml;
83 }
84 },
85 error(err) {
86 console.error(err);
87 },
88 completed() {
89 elModalSearchCourses.classList.remove('loading');
90 }
91 });
92 };
93
94 /**
95 * Get list course ids added.
96 */
97 const getCoursesAdded = () => {
98 courseIdsAdded = [];
99 const orderItems = document.querySelectorAll('#learn-press-order .list-order-items tbody .order-item-row');
100 orderItems.forEach(orderItem => {
101 const orderItemId = parseInt(orderItem.getAttribute('data-id'));
102 courseIdsAdded.push(orderItemId);
103 });
104 };
105
106 /**
107 * Add courses to order.
108 * @param e
109 * @param target
110 */
111 const addCourses = (e, target) => {
112 if (!target.classList.contains('add')) {
113 return;
114 }
115 if (!target.closest(idModalSearchItems)) {
116 return;
117 }
118 elListOrderItems = elOrderDetails.querySelector('.list-order-items');
119 e.preventDefault();
120 target.disabled = true;
121 const dataSend = {
122 'lp-ajax': 'add_items_to_order',
123 order_id: document.querySelector('#post_ID').value,
124 items: courseIdsNewSelected,
125 nonce: lpDataAdmin.nonce
126 };
127 const callBack = {
128 success(response) {
129 const {
130 data,
131 messages,
132 status
133 } = response;
134 if ('error' === status) {
135 console.error(messages);
136 return;
137 }
138 const {
139 item_html,
140 order_data
141 } = data;
142 const elNoItem = elListOrderItems.querySelector('.no-order-items');
143 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpShowHideEl(elNoItem, 0);
144 elNoItem.insertAdjacentHTML('beforebegin', item_html);
145 elOrderDetails.querySelector('.order-subtotal').innerHTML = order_data.subtotal_html;
146 elOrderDetails.querySelector('.order-total').innerHTML = order_data.total_html;
147 //courseIdsAdded.push( ...courseIdsNewSelected );
148 courseIdsNewSelected.splice(0, courseIdsNewSelected.length);
149 },
150 error(err) {
151 console.error(err);
152 },
153 completed() {
154 target.disabled = false;
155 modalContainer.style.display = 'none';
156 }
157 };
158 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpAddQueryArgs(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpGetCurrentURLNoParam(), dataSend), {}, callBack);
159 };
160
161 /**
162 * Remove course from order.
163 *
164 * @param e
165 * @param target
166 */
167 const removeCourse = (e, target) => {
168 if (target.tagName !== 'SPAN') {
169 return;
170 }
171 if (!target.closest('.remove-order-item')) {
172 return;
173 }
174 e.preventDefault();
175 if (!confirm('Are you sure you want to remove this item?')) {
176 return;
177 }
178 target.disabled = true;
179 target.classList.add('dashicons-update');
180 const elItemRow = target.closest('.order-item-row');
181 const elListOrderItems = target.closest('.list-order-items');
182 const orderItemId = parseInt(elItemRow.getAttribute('data-item_id'));
183 const courseId = parseInt(elItemRow.getAttribute('data-id'));
184 const dataSend = {
185 'lp-ajax': 'remove_items_from_order',
186 order_id: document.querySelector('#post_ID').value,
187 items: orderItemId,
188 nonce: lpDataAdmin.nonce
189 };
190 const callBack = {
191 success(response) {
192 const {
193 data,
194 messages,
195 status
196 } = response;
197 if ('error' === status) {
198 console.error(messages);
199 return;
200 }
201 const {
202 item_html,
203 order_data
204 } = data;
205 const elNoItem = elListOrderItems.querySelector('.no-order-items');
206 const orderItems = elListOrderItems.querySelectorAll('.order-item-row');
207 orderItems.forEach(orderItem => {
208 orderItem.remove();
209 });
210 if (item_html.length) {
211 elNoItem.insertAdjacentHTML('beforebegin', item_html);
212 } else {
213 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpShowHideEl(elNoItem, 1);
214 }
215 courseIdsNewSelected.splice(courseIdsNewSelected.indexOf(courseId), 1);
216 //courseIdsAdded.splice( courseIdsNewSelected.indexOf( courseId ), 1 );
217 elOrderDetails.querySelector('.order-subtotal').innerHTML = order_data.subtotal_html;
218 elOrderDetails.querySelector('.order-total').innerHTML = order_data.total_html;
219 },
220 error(err) {
221 console.error(err);
222 },
223 completed() {}
224 };
225 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpAddQueryArgs(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpGetCurrentURLNoParam(), dataSend), {}, callBack);
226 };
227
228 /**
229 * Search courses before add Order.
230 *
231 * @param e
232 * @param target
233 */
234 const searchCourse = (e, target) => {
235 if ('search' !== target.name) {
236 return;
237 }
238 const elLPTarget = target.closest(idModalSearchItems);
239 if (!elLPTarget) {
240 return;
241 }
242 e.preventDefault();
243 const keyword = target.value;
244 if (!keyword || keyword && keyword.length > 2) {
245 if (undefined !== timeOutSearch) {
246 clearTimeout(timeOutSearch);
247 }
248 timeOutSearch = setTimeout(function () {
249 fetchCoursesAPI(keyword, courseIdsAdded, 1);
250 }, 800);
251 }
252 };
253
254 /**
255 * Display list courses when search done.
256 *
257 * @param courses
258 */
259 const renderSearchResult = courses => {
260 let html = '';
261 courses.forEach(course => {
262 const courseId = parseInt(course.ID);
263 const checked = courseIdsNewSelected.includes(courseId) ? 'checked' : '';
264 html += `
265 <li class="lp-result-item" data-id="${courseId}" data-type="lp_course" data-text="${course.post_title}">
266 <label>
267 <input type="checkbox" value="${courseId}" name="selectedItems[]" ${checked}>
268 <span class="lp-item-text">${course.post_title} (#${courseId})</span>
269 </label>
270 </li>`;
271 });
272 return html;
273 };
274
275 /**
276 * Render pagination.
277 *
278 * @param currentPage
279 * @param maxPage
280 */
281 const renderPagination = (currentPage, maxPage) => {
282 currentPage = parseInt(currentPage);
283 maxPage = parseInt(maxPage);
284 let html = '';
285 if (maxPage <= 1) {
286 return html;
287 }
288 const nextPage = currentPage + 1;
289 const prevPage = currentPage - 1;
290 let pages = [];
291 if (maxPage <= 9) {
292 for (let i = 1; i <= maxPage; i++) {
293 pages.push(i);
294 }
295 } else if (currentPage <= 3) {
296 // x is ...
297 pages = [1, 2, 3, 4, 5, 'x', maxPage];
298 } else if (currentPage <= 5) {
299 for (let i = 1; i <= currentPage; i++) {
300 pages.push(i);
301 }
302 for (let j = 1; j <= 2; j++) {
303 const tempPage = currentPage + j;
304 pages.push(tempPage);
305 }
306 pages.push('x');
307 pages.push(maxPage);
308 } else {
309 pages = [1, 'x'];
310 for (let k = 2; k >= 0; k--) {
311 const tempPage = currentPage - k;
312 pages.push(tempPage);
313 }
314 const currentToLast = maxPage - currentPage;
315 if (currentToLast <= 5) {
316 for (let m = currentPage + 1; m <= maxPage; m++) {
317 pages.push(m);
318 }
319 } else {
320 for (let n = 1; n <= 2; n++) {
321 const tempPage = currentPage + n;
322 pages.push(tempPage);
323 }
324 pages.push('x');
325 pages.push(maxPage);
326 }
327 }
328 const maximum = pages.length;
329 if (currentPage !== 1) {
330 html += `<a class="prev page-numbers button" href="#" data-page="${prevPage}"><</a>`;
331 }
332 for (let i = 0; i < maximum; i++) {
333 if (currentPage === parseInt(pages[i])) {
334 html += `<a aria-current="page" class="page-numbers current button disabled" data-page="${pages[i]}">
335 ${pages[i]}
336 </a>`;
337 } else if (pages[i] === 'x') {
338 html += `<span class="page-numbers dots button disabled">...</span>`;
339 } else {
340 html += `<a class="page-numbers button" href="#" data-page="${pages[i]}">${pages[i]} </a>`;
341 }
342 }
343 if (currentPage !== maxPage) {
344 html += `<a class="next page-numbers button" href="#" data-page="${nextPage}">></a>`;
345 }
346 return html;
347 };
348 const showPopupSearchCourses = () => {
349 getCoursesAdded();
350 modalContainer.style.display = 'block';
351 elOrderModalBtnAdd.style.display = 'none';
352 elSearchCoursesResult.innerHTML = '';
353 fetchCoursesAPI(dataSend.search, courseIdsAdded, dataSend.paged);
354 };
355
356 // Events.
357 document.addEventListener('click', e => {
358 const target = e.target;
359 //console.dir( target );
360 if (target.id === 'learn-press-add-order-item') {
361 e.preventDefault();
362 showPopupSearchCourses();
363 }
364 if (target.classList.contains('close') && target.closest(idModalSearchItems)) {
365 e.preventDefault();
366 elModalSearchCourses.querySelector('input[name="search"]').value = '';
367 dataSend.search = '';
368 dataSend.paged = 1;
369 modalContainer.style.display = 'none';
370 }
371 if (target.classList.contains('page-numbers')) {
372 if (target.closest(idModalSearchItems)) {
373 e.preventDefault();
374 const paged = target.getAttribute('data-page');
375 fetchCoursesAPI(dataSend.search, dataSend.id_not_in, paged);
376 }
377 }
378 if (target.name === 'selectedItems[]') {
379 if (target.closest(idModalSearchItems)) {
380 const courseId = parseInt(target.value);
381 if (target.checked) {
382 courseIdsNewSelected.push(courseId);
383 } else {
384 const index = courseIdsNewSelected.indexOf(courseId);
385 if (index > -1) {
386 courseIdsNewSelected.splice(index, 1);
387 }
388 }
389 elOrderModalBtnAdd.style.display = courseIdsNewSelected.length > 0 ? 'block' : 'none';
390 }
391 }
392 addCourses(e, target);
393 removeCourse(e, target);
394 });
395 document.addEventListener('keyup', function (e) {
396 const target = e.target;
397 searchCourse(e, target);
398 });
399 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpOnElementReady('.lp-order-detail-items', el => {
400 getAllElements();
401 if (!elOrderDetails) {
402 return;
403 }
404 modalContainer.innerHTML = modalSearchItemsTemplate.innerHTML;
405 elModalSearchCourses = modalContainer.querySelector(idModalSearchItems);
406 elSearchCoursesResult = elModalSearchCourses.querySelector('.search-results');
407 elOrderModalFooter = elModalSearchCourses.querySelector('footer');
408 elOrderModalBtnAdd = elOrderModalFooter.querySelector('.add');
409 modalContainer.style.display = 'none';
410 });
411 };
412 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (addCoursesToOrder);
413
414 /***/ },
415
416 /***/ "./assets/src/js/admin/order/export_invoice.js"
417 /*!*****************************************************!*\
418 !*** ./assets/src/js/admin/order/export_invoice.js ***!
419 \*****************************************************/
420 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
421
422 __webpack_require__.r(__webpack_exports__);
423 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
424 /* harmony export */ "default": () => (/* binding */ export_invoice)
425 /* harmony export */ });
426 /**
427 * Export invoice to PDF
428 */
429 function export_invoice() {
430 let html2pdf_obj, modal;
431 document.addEventListener('click', e => {
432 const target = e.target;
433 if (target.id === 'lp-invoice__export') {
434 html2pdf_obj.save();
435 } else if (target.id === 'lp-invoice__update') {
436 const elOption = document.querySelector('.export-options__content');
437 const fields = elOption.querySelectorAll('input');
438 const fieldNameUnChecked = [];
439 fields.forEach(field => {
440 if (!field.checked) {
441 fieldNameUnChecked.push(field.name);
442 }
443 });
444 window.localStorage.setItem('lp_invoice_un_fields', JSON.stringify(fieldNameUnChecked));
445 window.localStorage.setItem('lp_invoice_show', 1);
446 window.location.reload();
447 }
448 });
449 const exportPDF = () => {
450 const pdfOptions = {
451 margin: [0, 0, 0, 5],
452 filename: document.title,
453 image: {
454 type: 'webp'
455 },
456 html2canvas: {
457 scale: 2.5
458 },
459 jsPDF: {
460 format: 'a4',
461 orientation: 'p'
462 }
463 };
464 const html = document.querySelector('#lp-invoice__content');
465 html2pdf_obj = html2pdf().set(pdfOptions).from(html);
466 };
467 const showInfoFields = () => {
468 // Get fields name checked
469 const fieldsChecked = window.localStorage.getItem('lp_invoice_un_fields');
470 const elOptions = document.querySelector('.export-options__content');
471 const elInvoiceFields = document.querySelectorAll('.invoice-field');
472 elInvoiceFields.forEach(field => {
473 const nameClass = field.classList[1];
474 if (fieldsChecked && fieldsChecked.includes(nameClass)) {
475 field.remove();
476 const elOption = elOptions.querySelector(`[name=${nameClass}]`);
477 if (elOption) {
478 elOption.checked = false;
479 }
480 }
481 });
482 const showInvoice = parseInt(window.localStorage.getItem('lp_invoice_show'));
483 if (showInvoice === 1) {
484 modal.style.display = 'block';
485 }
486 };
487 document.addEventListener('DOMContentLoaded', () => {
488 const elExportSection = document.querySelector('#order-export__section');
489 if (!elExportSection.length) {
490 const tabs = document.querySelectorAll('.tabs');
491 const tab = document.querySelectorAll('.tab');
492 const panel = document.querySelectorAll('.panel');
493 function onTabClick(event) {
494 // deactivate existing active tabs and panel
495
496 for (let i = 0; i < tab.length; i++) {
497 tab[i].classList.remove('active');
498 }
499 for (let i = 0; i < panel.length; i++) {
500 panel[i].classList.remove('active');
501 }
502
503 // activate new tabs and panel
504 event.target.classList.add('active');
505 const classString = event.target.getAttribute('data-target');
506 document.getElementById('panels').getElementsByClassName(classString)[0].classList.add('active');
507 }
508 for (let i = 0; i < tab.length; i++) {
509 tab[i].addEventListener('click', onTabClick, false);
510 }
511
512 // Get the modal
513 modal = document.getElementById('myModal');
514 // Get the button that opens the modal
515 const btn = document.getElementById('order-export__button');
516 // Get the <span> element that closes the modal
517 const span = document.getElementsByClassName('close')[0];
518 // When the user clicks on the button, open the modal
519 btn.onclick = function () {
520 modal.style.display = 'block';
521 };
522
523 // When the user clicks on <span> (x), close the modal
524 span.onclick = function () {
525 modal.style.display = 'none';
526 window.localStorage.setItem('lp_invoice_show', 0);
527 };
528
529 // When the user clicks anywhere outside the modal, close it
530 window.onclick = function (event) {
531 if (event.target === modal) {
532 modal.style.display = 'none';
533 window.localStorage.setItem('lp_invoice_show', 0);
534 }
535 };
536 showInfoFields();
537 exportPDF();
538 }
539 });
540 }
541
542 /***/ },
543
544 /***/ "./assets/src/js/admin/utils-admin.js"
545 /*!********************************************!*\
546 !*** ./assets/src/js/admin/utils-admin.js ***!
547 \********************************************/
548 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
549
550 __webpack_require__.r(__webpack_exports__);
551 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
552 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
553 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
554 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
555 /* harmony export */ });
556 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
557 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
558 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
559 /**
560 * Library run on Admin
561 *
562 * @since 4.2.6.9
563 * @version 1.0.1
564 */
565
566
567
568 const AdminUtilsFunctions = {
569 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
570 if (!elTomSelect) {
571 return;
572 }
573 const optionDefault = {
574 plugins: {
575 remove_button: {
576 title: 'Remove this item'
577 },
578 dropdown_input: {}
579 },
580 onInitialize() {},
581 onItemAdd(e) {
582 // Get list without current item.
583 if (fetchAPI) {
584 const selectedOptions = Array.from(elTomSelect.selectedOptions);
585 const selectedValues = selectedOptions.map(option => option.value);
586 selectedValues.push(e);
587 dataSend.id_not_in = selectedValues.join(',');
588 fetchAPI('', dataSend, callBackHandleData);
589 }
590 }
591 };
592 if (fetchAPI) {
593 optionDefault.load = (keySearch, callbackTom) => {
594 const selectedOptions = Array.from(elTomSelect.selectedOptions);
595 const selectedValues = selectedOptions.map(option => option.value);
596 dataSend.id_not_in = selectedValues.join(',');
597 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
598 };
599 }
600 options = {
601 ...optionDefault,
602 ...options
603 };
604 const items_selected = options.options;
605 /*if ( options?.options?.length > 20 ) {
606 const chunkSize = 20;
607 const length = options.options.length;
608 let i = 0;
609 const chunkedOptions = { ...options };
610 chunkedOptions.options = items_selected.slice( i, chunkSize );
611 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
612 i += chunkSize;
613 const interval = setInterval( () => {
614 if ( i > ( length - 1 ) ) {
615 clearInterval( interval );
616 }
617 const optionsSlice = items_selected.slice( i, i + chunkSize );
618 i += chunkSize;
619 tomSelect.addOptions( optionsSlice );
620 tomSelect.setValue( options.items );
621 }, 200 );
622 return tomSelect;
623 }*/
624
625 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
626 },
627 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
628 return {
629 success: response => {
630 const options = callBackHandleData.success(response);
631 callbackTom(options);
632 }
633 };
634 },
635 fetchCourses(keySearch = '', dataSend = {}, callback) {
636 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
637 dataSend.search = keySearch;
638 const params = {
639 headers: {
640 'Content-Type': 'application/json',
641 'X-WP-Nonce': lpDataAdmin.nonce
642 },
643 method: 'POST',
644 body: JSON.stringify(dataSend)
645 };
646 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
647 },
648 fetchUsers(keySearch = '', dataSend = {}, callback) {
649 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
650 dataSend.search = keySearch;
651 const params = {
652 headers: {
653 'Content-Type': 'application/json',
654 'X-WP-Nonce': lpDataAdmin.nonce
655 },
656 method: 'POST',
657 body: JSON.stringify(dataSend)
658 };
659 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
660 }
661 };
662
663
664 /***/ },
665
666 /***/ "./assets/src/js/api.js"
667 /*!******************************!*\
668 !*** ./assets/src/js/api.js ***!
669 \******************************/
670 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
671
672 __webpack_require__.r(__webpack_exports__);
673 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
674 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
675 /* harmony export */ });
676 /**
677 * List API on backend
678 *
679 * @since 4.2.6
680 * @version 1.0.2
681 */
682
683 const lplistAPI = {};
684 let lp_rest_url;
685 if ('undefined' !== typeof lpDataAdmin) {
686 lp_rest_url = lpDataAdmin.lp_rest_url;
687 lplistAPI.admin = {
688 apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
689 apiAddons: lp_rest_url + 'lp/v1/addon/all',
690 apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
691 apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
692 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
693 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
694 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
695 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
696 };
697 }
698 if ('undefined' !== typeof lpData) {
699 lp_rest_url = lpData.lp_rest_url;
700 lplistAPI.frontend = {
701 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
702 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
703 // Deprecated API, don't load from v4.3.7
704 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
705 // Deprecated since 4.3.0
706 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
707 };
708 }
709 if (lp_rest_url) {
710 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
711 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
712 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
713 }
714 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
715
716 /***/ },
717
718 /***/ "./assets/src/js/utils.js"
719 /*!********************************!*\
720 !*** ./assets/src/js/utils.js ***!
721 \********************************/
722 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
723
724 __webpack_require__.r(__webpack_exports__);
725 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
726 /* harmony export */ debounce: () => (/* binding */ debounce),
727 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
728 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
729 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
730 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
731 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
732 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
733 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
734 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
735 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
736 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
737 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
738 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
739 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
740 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
741 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
742 /* harmony export */ });
743 /**
744 * Utils functions
745 *
746 * @param url
747 * @param data
748 * @param functions
749 * @since 4.2.5.1
750 * @version 1.0.6
751 */
752 const lpClassName = {
753 hidden: 'lp-hidden',
754 loading: 'loading',
755 elCollapse: 'lp-collapse',
756 elSectionToggle: '.lp-section-toggle',
757 elTriggerToggle: '.lp-trigger-toggle'
758 };
759 const lpFetchAPI = (url, data = {}, functions = {}) => {
760 if ('function' === typeof functions.before) {
761 functions.before();
762 }
763 fetch(url, {
764 method: 'GET',
765 ...data
766 }).then(response => response.json()).then(response => {
767 if ('function' === typeof functions.success) {
768 functions.success(response);
769 }
770 }).catch(err => {
771 if ('function' === typeof functions.error) {
772 functions.error(err);
773 }
774 }).finally(() => {
775 if ('function' === typeof functions.completed) {
776 functions.completed();
777 }
778 });
779 };
780
781 /**
782 * Get current URL without params.
783 *
784 * @since 4.2.5.1
785 */
786 const lpGetCurrentURLNoParam = () => {
787 let currentUrl = window.location.href;
788 const hasParams = currentUrl.includes('?');
789 if (hasParams) {
790 currentUrl = currentUrl.split('?')[0];
791 }
792 return currentUrl;
793 };
794 const lpAddQueryArgs = (endpoint, args) => {
795 const url = new URL(endpoint);
796 Object.keys(args).forEach(arg => {
797 url.searchParams.set(arg, args[arg]);
798 });
799 return url;
800 };
801
802 /**
803 * Listen element viewed.
804 *
805 * @param el
806 * @param callback
807 * @since 4.2.5.8
808 */
809 const listenElementViewed = (el, callback) => {
810 const observerSeeItem = new IntersectionObserver(function (entries) {
811 for (const entry of entries) {
812 if (entry.isIntersecting) {
813 callback(entry);
814 }
815 }
816 });
817 observerSeeItem.observe(el);
818 };
819
820 /**
821 * Listen element created.
822 *
823 * @param callback
824 * @since 4.2.5.8
825 */
826 const listenElementCreated = callback => {
827 const observerCreateItem = new MutationObserver(function (mutations) {
828 mutations.forEach(function (mutation) {
829 if (mutation.addedNodes) {
830 mutation.addedNodes.forEach(function (node) {
831 if (node.nodeType === 1) {
832 callback(node);
833 }
834 });
835 }
836 });
837 });
838 observerCreateItem.observe(document, {
839 childList: true,
840 subtree: true
841 });
842 // End.
843 };
844
845 /**
846 * Listen element created.
847 *
848 * @param selector
849 * @param callback
850 * @since 4.2.7.1
851 */
852 const lpOnElementReady = (selector, callback) => {
853 const element = document.querySelector(selector);
854 if (element) {
855 callback(element);
856 return;
857 }
858 const observer = new MutationObserver((mutations, obs) => {
859 const element = document.querySelector(selector);
860 if (element) {
861 obs.disconnect();
862 callback(element);
863 }
864 });
865 observer.observe(document.documentElement, {
866 childList: true,
867 subtree: true
868 });
869 };
870
871 // Parse JSON from string with content include LP_AJAX_START.
872 const lpAjaxParseJsonOld = data => {
873 if (typeof data !== 'string') {
874 return data;
875 }
876 const m = String.raw({
877 raw: data
878 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
879 try {
880 if (m) {
881 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
882 } else {
883 data = JSON.parse(data);
884 }
885 } catch (e) {
886 data = {};
887 }
888 return data;
889 };
890
891 // status 0: hide, 1: show
892 const lpShowHideEl = (el, status = 0) => {
893 if (!el) {
894 return;
895 }
896 if (!status) {
897 el.classList.add(lpClassName.hidden);
898 } else {
899 el.classList.remove(lpClassName.hidden);
900 }
901 };
902
903 // status 0: hide, 1: show
904 const lpSetLoadingEl = (el, status) => {
905 if (!el) {
906 return;
907 }
908 if (!status) {
909 el.classList.remove(lpClassName.loading);
910 } else {
911 el.classList.add(lpClassName.loading);
912 }
913 };
914
915 // Toggle collapse section
916 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
917 if (!elTriggerClassName) {
918 elTriggerClassName = lpClassName.elTriggerToggle;
919 }
920
921 // Exclude elements, which should not trigger the collapse toggle
922 if (elsExclude && elsExclude.length > 0) {
923 for (const elExclude of elsExclude) {
924 if (target.closest(elExclude)) {
925 return;
926 }
927 }
928 }
929 const elTrigger = target.closest(elTriggerClassName);
930 if (!elTrigger) {
931 return;
932 }
933
934 //console.log( 'elTrigger', elTrigger );
935
936 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
937 if (!elSectionToggle) {
938 return;
939 }
940 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
941 if ('function' === typeof callback) {
942 callback(elSectionToggle);
943 }
944 };
945
946 // Get data of form
947 const getDataOfForm = form => {
948 const dataSend = {};
949 const formData = new FormData(form);
950 for (const pair of formData.entries()) {
951 const key = pair[0];
952 const value = formData.getAll(key);
953 if (!dataSend.hasOwnProperty(key)) {
954 // Convert value array to string.
955 dataSend[key] = value.join(',');
956 }
957 }
958 return dataSend;
959 };
960
961 // Get field keys of form
962 const getFieldKeysOfForm = form => {
963 const keys = [];
964 const elements = form.elements;
965 for (let i = 0; i < elements.length; i++) {
966 const name = elements[i].name;
967 if (name && !keys.includes(name)) {
968 keys.push(name);
969 }
970 }
971 return keys;
972 };
973
974 // Merge data handle with data form.
975 const mergeDataWithDatForm = (elForm, dataHandle) => {
976 const dataForm = getDataOfForm(elForm);
977 const keys = getFieldKeysOfForm(elForm);
978 keys.forEach(key => {
979 if (!dataForm.hasOwnProperty(key)) {
980 delete dataHandle[key];
981 } else if (dataForm[key][0] === '') {
982 delete dataForm[key];
983 delete dataHandle[key];
984 }
985 });
986 dataHandle = {
987 ...dataHandle,
988 ...dataForm
989 };
990 return dataHandle;
991 };
992
993 /**
994 * Event trigger
995 * For each list of event handlers, listen event on document.
996 *
997 * eventName: 'click', 'change', ...
998 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
999 *
1000 * @param eventName
1001 * @param eventHandlers
1002 */
1003 const eventHandlers = (eventName, eventHandlers) => {
1004 document.addEventListener(eventName, e => {
1005 const target = e.target;
1006 let args = {
1007 e,
1008 target
1009 };
1010 eventHandlers.forEach(eventHandler => {
1011 args = {
1012 ...args,
1013 ...eventHandler
1014 };
1015
1016 //console.log( args );
1017
1018 // Check condition before call back
1019 if (eventHandler.conditionBeforeCallBack) {
1020 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1021 return;
1022 }
1023 }
1024
1025 // Special check for keydown event with checkIsEventEnter = true
1026 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1027 if (e.key !== 'Enter') {
1028 return;
1029 }
1030 }
1031 if (target.closest(eventHandler.selector)) {
1032 if (eventHandler.class) {
1033 // Call method of class, function callBack will understand exactly {this} is class object.
1034 eventHandler.class[eventHandler.callBack](args);
1035 } else {
1036 // For send args is objected, {this} is eventHandler object, not class object.
1037 eventHandler.callBack(args);
1038 }
1039 }
1040 });
1041 });
1042 };
1043
1044 /**
1045 * Debounce - delays function execution until after `wait` ms of inactivity.
1046 *
1047 * Each call resets the timer. Only the last call in a burst executes.
1048 *
1049 * USE CASES:
1050 * - Search inputs, form validation, window resize
1051 * - Multiple elements need independent timers
1052 * - When you need to call with different arguments
1053 *
1054 * EXAMPLES:
1055 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1056 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1057 *
1058 * const debouncedResize = debounce( recalculateLayout, 250 );
1059 * window.addEventListener('resize', debouncedResize);
1060 *
1061 * ⚠️ Create ONCE outside event handlers, not inside.
1062 *
1063 * @param {Function} func - Function to debounce (can be anonymous)
1064 * @param {number} wait - Milliseconds to wait (default: 500)
1065 * @return {Function} Debounced wrapper function
1066 * @since 4.3.7
1067 * @version 1.0.0
1068 */
1069 const debounce = (func, wait = 500) => {
1070 let timer;
1071 return args => {
1072 clearTimeout(timer);
1073 timer = setTimeout(() => func(args), wait);
1074 };
1075 };
1076
1077 /***/ },
1078
1079 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
1080 /*!**********************************************************!*\
1081 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
1082 \**********************************************************/
1083 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1084
1085 __webpack_require__.r(__webpack_exports__);
1086 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1087 /* harmony export */ Sifter: () => (/* binding */ Sifter),
1088 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
1089 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
1090 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
1091 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
1092 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
1093 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
1094 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
1095 /* harmony export */ });
1096 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
1097 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
1098 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
1099 /**
1100 * sifter.js
1101 * Copyright (c) 2013–2020 Brian Reavis & contributors
1102 *
1103 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
1104 * file except in compliance with the License. You may obtain a copy of the License at:
1105 * http://www.apache.org/licenses/LICENSE-2.0
1106 *
1107 * Unless required by applicable law or agreed to in writing, software distributed under
1108 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
1109 * ANY KIND, either express or implied. See the License for the specific language
1110 * governing permissions and limitations under the License.
1111 *
1112 * @author Brian Reavis <brian@thirdroute.com>
1113 */
1114
1115
1116 class Sifter {
1117 items; // []|{};
1118 settings;
1119 /**
1120 * Textually searches arrays and hashes of objects
1121 * by property (or multiple properties). Designed
1122 * specifically for autocomplete.
1123 *
1124 */
1125 constructor(items, settings) {
1126 this.items = items;
1127 this.settings = settings || { diacritics: true };
1128 }
1129 ;
1130 /**
1131 * Splits a search string into an array of individual
1132 * regexps to be used to match results.
1133 *
1134 */
1135 tokenize(query, respect_word_boundaries, weights) {
1136 if (!query || !query.length)
1137 return [];
1138 const tokens = [];
1139 const words = query.split(/\s+/);
1140 var field_regex;
1141 if (weights) {
1142 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
1143 }
1144 words.forEach((word) => {
1145 let field_match;
1146 let field = null;
1147 let regex = null;
1148 // look for "field:query" tokens
1149 if (field_regex && (field_match = word.match(field_regex))) {
1150 field = field_match[1];
1151 word = field_match[2];
1152 }
1153 if (word.length > 0) {
1154 if (this.settings.diacritics) {
1155 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
1156 }
1157 else {
1158 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
1159 }
1160 if (regex && respect_word_boundaries)
1161 regex = "\\b" + regex;
1162 }
1163 tokens.push({
1164 string: word,
1165 regex: regex ? new RegExp(regex, 'iu') : null,
1166 field: field,
1167 });
1168 });
1169 return tokens;
1170 }
1171 ;
1172 /**
1173 * Returns a function to be used to score individual results.
1174 *
1175 * Good matches will have a higher score than poor matches.
1176 * If an item is not a match, 0 will be returned by the function.
1177 *
1178 * @returns {T.ScoreFn}
1179 */
1180 getScoreFunction(query, options) {
1181 var search = this.prepareSearch(query, options);
1182 return this._getScoreFunction(search);
1183 }
1184 /**
1185 * @returns {T.ScoreFn}
1186 *
1187 */
1188 _getScoreFunction(search) {
1189 const tokens = search.tokens, token_count = tokens.length;
1190 if (!token_count) {
1191 return function () { return 0; };
1192 }
1193 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
1194 if (!field_count) {
1195 return function () { return 1; };
1196 }
1197 /**
1198 * Calculates the score of an object
1199 * against the search query.
1200 *
1201 */
1202 const scoreObject = (function () {
1203 if (field_count === 1) {
1204 return function (token, data) {
1205 const field = fields[0].field;
1206 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
1207 };
1208 }
1209 return function (token, data) {
1210 var sum = 0;
1211 // is the token specific to a field?
1212 if (token.field) {
1213 const value = getAttrFn(data, token.field);
1214 if (!token.regex && value) {
1215 sum += (1 / field_count);
1216 }
1217 else {
1218 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
1219 }
1220 }
1221 else {
1222 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
1223 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
1224 });
1225 }
1226 return sum / field_count;
1227 };
1228 })();
1229 if (token_count === 1) {
1230 return function (data) {
1231 return scoreObject(tokens[0], data);
1232 };
1233 }
1234 if (search.options.conjunction === 'and') {
1235 return function (data) {
1236 var score, sum = 0;
1237 for (let token of tokens) {
1238 score = scoreObject(token, data);
1239 if (score <= 0)
1240 return 0;
1241 sum += score;
1242 }
1243 return sum / token_count;
1244 };
1245 }
1246 else {
1247 return function (data) {
1248 var sum = 0;
1249 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
1250 sum += scoreObject(token, data);
1251 });
1252 return sum / token_count;
1253 };
1254 }
1255 }
1256 ;
1257 /**
1258 * Returns a function that can be used to compare two
1259 * results, for sorting purposes. If no sorting should
1260 * be performed, `null` will be returned.
1261 *
1262 * @return function(a,b)
1263 */
1264 getSortFunction(query, options) {
1265 var search = this.prepareSearch(query, options);
1266 return this._getSortFunction(search);
1267 }
1268 _getSortFunction(search) {
1269 var implicit_score, sort_flds = [];
1270 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
1271 if (typeof sort == 'function') {
1272 return sort.bind(this);
1273 }
1274 /**
1275 * Fetches the specified sort field value
1276 * from a search result item.
1277 *
1278 */
1279 const get_field = function (name, result) {
1280 if (name === '$score')
1281 return result.score;
1282 return search.getAttrFn(self.items[result.id], name);
1283 };
1284 // parse options
1285 if (sort) {
1286 for (let s of sort) {
1287 if (search.query || s.field !== '$score') {
1288 sort_flds.push(s);
1289 }
1290 }
1291 }
1292 // the "$score" field is implied to be the primary
1293 // sort field, unless it's manually specified
1294 if (search.query) {
1295 implicit_score = true;
1296 for (let fld of sort_flds) {
1297 if (fld.field === '$score') {
1298 implicit_score = false;
1299 break;
1300 }
1301 }
1302 if (implicit_score) {
1303 sort_flds.unshift({ field: '$score', direction: 'desc' });
1304 }
1305 // without a search.query, all items will have the same score
1306 }
1307 else {
1308 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
1309 }
1310 // build function
1311 const sort_flds_count = sort_flds.length;
1312 if (!sort_flds_count) {
1313 return null;
1314 }
1315 return function (a, b) {
1316 var result, field;
1317 for (let sort_fld of sort_flds) {
1318 field = sort_fld.field;
1319 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
1320 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
1321 if (result)
1322 return result;
1323 }
1324 return 0;
1325 };
1326 }
1327 ;
1328 /**
1329 * Parses a search query and returns an object
1330 * with tokens and fields ready to be populated
1331 * with results.
1332 *
1333 */
1334 prepareSearch(query, optsUser) {
1335 const weights = {};
1336 var options = Object.assign({}, optsUser);
1337 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
1338 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
1339 // convert fields to new format
1340 if (options.fields) {
1341 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
1342 const fields = [];
1343 options.fields.forEach((field) => {
1344 if (typeof field == 'string') {
1345 field = { field: field, weight: 1 };
1346 }
1347 fields.push(field);
1348 weights[field.field] = ('weight' in field) ? field.weight : 1;
1349 });
1350 options.fields = fields;
1351 }
1352 return {
1353 options: options,
1354 query: query.toLowerCase().trim(),
1355 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
1356 total: 0,
1357 items: [],
1358 weights: weights,
1359 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
1360 };
1361 }
1362 ;
1363 /**
1364 * Searches through all items and returns a sorted array of matches.
1365 *
1366 */
1367 search(query, options) {
1368 var self = this, score, search;
1369 search = this.prepareSearch(query, options);
1370 options = search.options;
1371 query = search.query;
1372 // generate result scoring function
1373 const fn_score = options.score || self._getScoreFunction(search);
1374 // perform search and sort
1375 if (query.length) {
1376 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
1377 score = fn_score(item);
1378 if (options.filter === false || score > 0) {
1379 search.items.push({ 'score': score, 'id': id });
1380 }
1381 });
1382 }
1383 else {
1384 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
1385 search.items.push({ 'score': 1, 'id': id });
1386 });
1387 }
1388 const fn_sort = self._getSortFunction(search);
1389 if (fn_sort)
1390 search.items.sort(fn_sort);
1391 // apply limits
1392 search.total = search.items.length;
1393 if (typeof options.limit === 'number') {
1394 search.items = search.items.slice(0, options.limit);
1395 }
1396 return search;
1397 }
1398 ;
1399 }
1400
1401
1402 //# sourceMappingURL=sifter.js.map
1403
1404 /***/ },
1405
1406 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
1407 /*!*********************************************************!*\
1408 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
1409 \*********************************************************/
1410 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1411
1412 __webpack_require__.r(__webpack_exports__);
1413
1414 //# sourceMappingURL=types.js.map
1415
1416 /***/ },
1417
1418 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
1419 /*!*********************************************************!*\
1420 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
1421 \*********************************************************/
1422 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1423
1424 __webpack_require__.r(__webpack_exports__);
1425 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1426 /* harmony export */ cmp: () => (/* binding */ cmp),
1427 /* harmony export */ getAttr: () => (/* binding */ getAttr),
1428 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
1429 /* harmony export */ iterate: () => (/* binding */ iterate),
1430 /* harmony export */ propToArray: () => (/* binding */ propToArray),
1431 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
1432 /* harmony export */ });
1433 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
1434
1435 /**
1436 * A property getter resolving dot-notation
1437 * @param {Object} obj The root object to fetch property on
1438 * @param {String} name The optionally dotted property name to fetch
1439 * @return {Object} The resolved property value
1440 */
1441 const getAttr = (obj, name) => {
1442 if (!obj)
1443 return;
1444 return obj[name];
1445 };
1446 /**
1447 * A property getter resolving dot-notation
1448 * @param {Object} obj The root object to fetch property on
1449 * @param {String} name The optionally dotted property name to fetch
1450 * @return {Object} The resolved property value
1451 */
1452 const getAttrNesting = (obj, name) => {
1453 if (!obj)
1454 return;
1455 var part, names = name.split(".");
1456 while ((part = names.shift()) && (obj = obj[part]))
1457 ;
1458 return obj;
1459 };
1460 /**
1461 * Calculates how close of a match the
1462 * given value is against a search token.
1463 *
1464 */
1465 const scoreValue = (value, token, weight) => {
1466 var score, pos;
1467 if (!value)
1468 return 0;
1469 value = value + '';
1470 if (token.regex == null)
1471 return 0;
1472 pos = value.search(token.regex);
1473 if (pos === -1)
1474 return 0;
1475 score = token.string.length / value.length;
1476 if (pos === 0)
1477 score += 0.5;
1478 return score * weight;
1479 };
1480 /**
1481 * Cast object property to an array if it exists and has a value
1482 *
1483 */
1484 const propToArray = (obj, key) => {
1485 var value = obj[key];
1486 if (typeof value == 'function')
1487 return value;
1488 if (value && !Array.isArray(value)) {
1489 obj[key] = [value];
1490 }
1491 };
1492 /**
1493 * Iterates over arrays and hashes.
1494 *
1495 * ```
1496 * iterate(this.items, function(item, id) {
1497 * // invoked for each item
1498 * });
1499 * ```
1500 *
1501 */
1502 const iterate = (object, callback) => {
1503 if (Array.isArray(object)) {
1504 object.forEach(callback);
1505 }
1506 else {
1507 for (var key in object) {
1508 if (object.hasOwnProperty(key)) {
1509 callback(object[key], key);
1510 }
1511 }
1512 }
1513 };
1514 const cmp = (a, b) => {
1515 if (typeof a === 'number' && typeof b === 'number') {
1516 return a > b ? 1 : (a < b ? -1 : 0);
1517 }
1518 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
1519 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
1520 if (a > b)
1521 return 1;
1522 if (b > a)
1523 return -1;
1524 return 0;
1525 };
1526 //# sourceMappingURL=utils.js.map
1527
1528 /***/ },
1529
1530 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
1531 /*!*******************************************************************!*\
1532 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
1533 \*******************************************************************/
1534 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1535
1536 __webpack_require__.r(__webpack_exports__);
1537 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1538 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
1539 /* harmony export */ asciifold: () => (/* binding */ asciifold),
1540 /* harmony export */ code_points: () => (/* binding */ code_points),
1541 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
1542 /* harmony export */ generateMap: () => (/* binding */ generateMap),
1543 /* harmony export */ generateSets: () => (/* binding */ generateSets),
1544 /* harmony export */ generator: () => (/* binding */ generator),
1545 /* harmony export */ getPattern: () => (/* binding */ getPattern),
1546 /* harmony export */ initialize: () => (/* binding */ initialize),
1547 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
1548 /* harmony export */ normalize: () => (/* binding */ normalize),
1549 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
1550 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
1551 /* harmony export */ });
1552 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
1553 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
1554
1555
1556 const code_points = [[0, 65535]];
1557 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
1558 let unicode_map;
1559 let multi_char_reg;
1560 const max_char_length = 3;
1561 const latin_convert = {};
1562 const latin_condensed = {
1563 '/': '⁄∕',
1564 '0': '߀',
1565 "a": "ⱥɐɑ",
1566 "aa": "",
1567 "ae": "æǽǣ",
1568 "ao": "",
1569 "au": "",
1570 "av": "ꜹꜻ",
1571 "ay": "",
1572 "b": "ƀɓƃ",
1573 "c": "ꜿƈȼↄ",
1574 "d": "đɗɖ�
1575 ƌꮷԁɦ",
1576 "e": "ɛǝᴇɇ",
1577 "f": "ꝼƒ",
1578 "g": "ǥɠꞡᵹꝿɢ",
1579 "h": "ħⱨⱶɥ",
1580 "i": "ɨı",
1581 "j": "ɉȷ",
1582 "k": "ƙⱪꝁꝃ�
1583 ",
1584 "l": "łƚɫⱡꝉꝇꞁɭ",
1585 "m": "ɱɯϻ",
1586 "n": "ꞥƞɲꞑᴎлԉ",
1587 "o": "øǿɔɵꝋꝍᴑ",
1588 "oe": "œ",
1589 "oi": "ƣ",
1590 "oo": "",
1591 "ou": "ȣ",
1592 "p": "ƥᵽꝑꝓꝕρ",
1593 "q": "ꝗꝙɋ",
1594 "r": "ɍɽꝛꞧꞃ",
1595 "s": "ßȿꞩ�
1596 ʂ",
1597 "t": "ŧƭʈⱦꞇ",
1598 "th": "þ",
1599 "tz": "",
1600 "u": "ʉ",
1601 "v": "ʋꝟʌ",
1602 "vy": "",
1603 "w": "",
1604 "y": "ƴɏỿ",
1605 "z": "ƶȥɀⱬꝣ",
1606 "hv": "ƕ"
1607 };
1608 for (let latin in latin_condensed) {
1609 let unicode = latin_condensed[latin] || '';
1610 for (let i = 0; i < unicode.length; i++) {
1611 let char = unicode.substring(i, i + 1);
1612 latin_convert[char] = latin;
1613 }
1614 }
1615 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
1616 /**
1617 * Initialize the unicode_map from the give code point ranges
1618 */
1619 const initialize = (_code_points) => {
1620 if (unicode_map !== undefined)
1621 return;
1622 unicode_map = generateMap(_code_points || code_points);
1623 };
1624 /**
1625 * Helper method for normalize a string
1626 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
1627 */
1628 const normalize = (str, form = 'NFKD') => str.normalize(form);
1629 /**
1630 * Remove accents without reordering string
1631 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
1632 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
1633 */
1634 const asciifold = (str) => {
1635 return Array.from(str).reduce(
1636 /**
1637 * @param {string} result
1638 * @param {string} char
1639 */
1640 (result, char) => {
1641 return result + _asciifold(char);
1642 }, '');
1643 };
1644 const _asciifold = (str) => {
1645 str = normalize(str)
1646 .toLowerCase()
1647 .replace(convert_pat, (/** @type {string} */ char) => {
1648 return latin_convert[char] || '';
1649 });
1650 //return str;
1651 return normalize(str, 'NFC');
1652 };
1653 /**
1654 * Generate a list of unicode variants from the list of code points
1655 */
1656 function* generator(code_points) {
1657 for (const [code_point_min, code_point_max] of code_points) {
1658 for (let i = code_point_min; i <= code_point_max; i++) {
1659 let composed = String.fromCharCode(i);
1660 let folded = asciifold(composed);
1661 if (folded == composed.toLowerCase()) {
1662 continue;
1663 }
1664 // skip when folded is a string longer than 3 characters long
1665 // bc the resulting regex patterns will be long
1666 // eg:
1667 // folded صلى الله عليه وسل�
1668 length 18 code point 65018
1669 // folded جل جلاله length 8 code point 65019
1670 if (folded.length > max_char_length) {
1671 continue;
1672 }
1673 if (folded.length == 0) {
1674 continue;
1675 }
1676 yield { folded: folded, composed: composed, code_point: i };
1677 }
1678 }
1679 }
1680 /**
1681 * Generate a unicode map from the list of code points
1682 */
1683 const generateSets = (code_points) => {
1684 const unicode_sets = {};
1685 const addMatching = (folded, to_add) => {
1686 /** @type {Set<string>} */
1687 const folded_set = unicode_sets[folded] || new Set();
1688 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
1689 if (to_add.match(patt)) {
1690 return;
1691 }
1692 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
1693 unicode_sets[folded] = folded_set;
1694 };
1695 for (let value of generator(code_points)) {
1696 addMatching(value.folded, value.folded);
1697 addMatching(value.folded, value.composed);
1698 }
1699 return unicode_sets;
1700 };
1701 /**
1702 * Generate a unicode map from the list of code points
1703 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
1704 */
1705 const generateMap = (code_points) => {
1706 const unicode_sets = generateSets(code_points);
1707 const unicode_map = {};
1708 let multi_char = [];
1709 for (let folded in unicode_sets) {
1710 let set = unicode_sets[folded];
1711 if (set) {
1712 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
1713 }
1714 if (folded.length > 1) {
1715 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
1716 }
1717 }
1718 multi_char.sort((a, b) => b.length - a.length);
1719 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
1720 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
1721 return unicode_map;
1722 };
1723 /**
1724 * Map each element of an array from its folded value to all possible unicode matches
1725 */
1726 const mapSequence = (strings, min_replacement = 1) => {
1727 let chars_replaced = 0;
1728 strings = strings.map((str) => {
1729 if (unicode_map[str]) {
1730 chars_replaced += str.length;
1731 }
1732 return unicode_map[str] || str;
1733 });
1734 if (chars_replaced >= min_replacement) {
1735 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
1736 }
1737 return '';
1738 };
1739 /**
1740 * Convert a short string and split it into all possible patterns
1741 * Keep a pattern only if min_replacement is met
1742 *
1743 * 'abc'
1744 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
1745 * => ['abc-pattern','ab-c-pattern'...]
1746 */
1747 const substringsToPattern = (str, min_replacement = 1) => {
1748 min_replacement = Math.max(min_replacement, str.length - 1);
1749 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
1750 return mapSequence(sub_pat, min_replacement);
1751 }));
1752 };
1753 /**
1754 * Convert an array of sequences into a pattern
1755 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
1756 */
1757 const sequencesToPattern = (sequences, all = true) => {
1758 let min_replacement = sequences.length > 1 ? 1 : 0;
1759 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
1760 let seq = [];
1761 const len = all ? sequence.length() : sequence.length() - 1;
1762 for (let j = 0; j < len; j++) {
1763 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
1764 }
1765 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
1766 }));
1767 };
1768 /**
1769 * Return true if the sequence is already in the sequences
1770 */
1771 const inSequences = (needle_seq, sequences) => {
1772 for (const seq of sequences) {
1773 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
1774 continue;
1775 }
1776 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
1777 continue;
1778 }
1779 let needle_parts = needle_seq.parts;
1780 const filter = (part) => {
1781 for (const needle_part of needle_parts) {
1782 if (needle_part.start === part.start && needle_part.substr === part.substr) {
1783 return false;
1784 }
1785 if (part.length == 1 || needle_part.length == 1) {
1786 continue;
1787 }
1788 // check for overlapping parts
1789 // a = ['::=','==']
1790 // b = ['::','===']
1791 // a = ['r','sm']
1792 // b = ['rs','m']
1793 if (part.start < needle_part.start && part.end > needle_part.start) {
1794 return true;
1795 }
1796 if (needle_part.start < part.start && needle_part.end > part.start) {
1797 return true;
1798 }
1799 }
1800 return false;
1801 };
1802 let filtered = seq.parts.filter(filter);
1803 if (filtered.length > 0) {
1804 continue;
1805 }
1806 return true;
1807 }
1808 return false;
1809 };
1810 class Sequence {
1811 parts;
1812 substrs;
1813 start;
1814 end;
1815 constructor() {
1816 this.parts = [];
1817 this.substrs = [];
1818 this.start = 0;
1819 this.end = 0;
1820 }
1821 add(part) {
1822 if (part) {
1823 this.parts.push(part);
1824 this.substrs.push(part.substr);
1825 this.start = Math.min(part.start, this.start);
1826 this.end = Math.max(part.end, this.end);
1827 }
1828 }
1829 last() {
1830 return this.parts[this.parts.length - 1];
1831 }
1832 length() {
1833 return this.parts.length;
1834 }
1835 clone(position, last_piece) {
1836 let clone = new Sequence();
1837 let parts = JSON.parse(JSON.stringify(this.parts));
1838 let last_part = parts.pop();
1839 for (const part of parts) {
1840 clone.add(part);
1841 }
1842 let last_substr = last_piece.substr.substring(0, position - last_part.start);
1843 let clone_last_len = last_substr.length;
1844 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
1845 return clone;
1846 }
1847 }
1848 /**
1849 * Expand a regular expression pattern to include unicode variants
1850 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁ�
1851 ⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢ�
1852 ǺǍȀȂẠẬẶḀĄȺⱯ/
1853 *
1854 * Issue:
1855 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
1856 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
1857 *
1858 * İIJ = IIJ = �
1859 �J
1860 *
1861 * 1/2/4
1862 */
1863 const getPattern = (str) => {
1864 initialize();
1865 str = asciifold(str);
1866 let pattern = '';
1867 let sequences = [new Sequence()];
1868 for (let i = 0; i < str.length; i++) {
1869 let substr = str.substring(i);
1870 let match = substr.match(multi_char_reg);
1871 const char = str.substring(i, i + 1);
1872 const match_str = match ? match[0] : null;
1873 // loop through sequences
1874 // add either the char or multi_match
1875 let overlapping = [];
1876 let added_types = new Set();
1877 for (const sequence of sequences) {
1878 const last_piece = sequence.last();
1879 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
1880 // if we have a multi match
1881 if (match_str) {
1882 const len = match_str.length;
1883 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
1884 added_types.add('1');
1885 }
1886 else {
1887 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
1888 added_types.add('2');
1889 }
1890 }
1891 else if (match_str) {
1892 let clone = sequence.clone(i, last_piece);
1893 const len = match_str.length;
1894 clone.add({ start: i, end: i + len, length: len, substr: match_str });
1895 overlapping.push(clone);
1896 }
1897 else {
1898 // don't add char
1899 // adding would create invalid patterns: 234 => [2,34,4]
1900 added_types.add('3');
1901 }
1902 }
1903 // if we have overlapping
1904 if (overlapping.length > 0) {
1905 // ['ii','iii'] before ['i','i','iii']
1906 overlapping = overlapping.sort((a, b) => {
1907 return a.length() - b.length();
1908 });
1909 for (let clone of overlapping) {
1910 // don't add if we already have an equivalent sequence
1911 if (inSequences(clone, sequences)) {
1912 continue;
1913 }
1914 sequences.push(clone);
1915 }
1916 continue;
1917 }
1918 // if we haven't done anything unique
1919 // clean up the patterns
1920 // helps keep patterns smaller
1921 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
1922 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
1923 pattern += sequencesToPattern(sequences, false);
1924 let new_seq = new Sequence();
1925 const old_seq = sequences[0];
1926 if (old_seq) {
1927 new_seq.add(old_seq.last());
1928 }
1929 sequences = [new_seq];
1930 }
1931 }
1932 pattern += sequencesToPattern(sequences, true);
1933 return pattern;
1934 };
1935
1936 //# sourceMappingURL=index.js.map
1937
1938 /***/ },
1939
1940 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
1941 /*!*******************************************************************!*\
1942 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
1943 \*******************************************************************/
1944 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1945
1946 __webpack_require__.r(__webpack_exports__);
1947 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1948 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
1949 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
1950 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
1951 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
1952 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
1953 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
1954 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
1955 /* harmony export */ });
1956 /**
1957 * Convert array of strings to a regular expression
1958 * ex ['ab','a'] => (?:ab|a)
1959 * ex ['a','b'] => [ab]
1960 */
1961 const arrayToPattern = (chars) => {
1962 chars = chars.filter(Boolean);
1963 if (chars.length < 2) {
1964 return chars[0] || '';
1965 }
1966 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
1967 };
1968 const sequencePattern = (array) => {
1969 if (!hasDuplicates(array)) {
1970 return array.join('');
1971 }
1972 let pattern = '';
1973 let prev_char_count = 0;
1974 const prev_pattern = () => {
1975 if (prev_char_count > 1) {
1976 pattern += '{' + prev_char_count + '}';
1977 }
1978 };
1979 array.forEach((char, i) => {
1980 if (char === array[i - 1]) {
1981 prev_char_count++;
1982 return;
1983 }
1984 prev_pattern();
1985 pattern += char;
1986 prev_char_count = 1;
1987 });
1988 prev_pattern();
1989 return pattern;
1990 };
1991 /**
1992 * Convert array of strings to a regular expression
1993 * ex ['ab','a'] => (?:ab|a)
1994 * ex ['a','b'] => [ab]
1995 */
1996 const setToPattern = (chars) => {
1997 let array = Array.from(chars);
1998 return arrayToPattern(array);
1999 };
2000 /**
2001 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
2002 */
2003 const hasDuplicates = (array) => {
2004 return (new Set(array)).size !== array.length;
2005 };
2006 /**
2007 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
2008 */
2009 const escape_regex = (str) => {
2010 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
2011 };
2012 /**
2013 * Return the max length of array values
2014 */
2015 const maxValueLength = (array) => {
2016 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
2017 };
2018 const unicodeLength = (str) => {
2019 return Array.from(str).length;
2020 };
2021 //# sourceMappingURL=regex.js.map
2022
2023 /***/ },
2024
2025 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
2026 /*!*********************************************************************!*\
2027 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
2028 \*********************************************************************/
2029 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2030
2031 __webpack_require__.r(__webpack_exports__);
2032 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2033 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
2034 /* harmony export */ });
2035 /**
2036 * Get all possible combinations of substrings that add up to the given string
2037 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
2038 */
2039 const allSubstrings = (input) => {
2040 if (input.length === 1)
2041 return [[input]];
2042 let result = [];
2043 const start = input.substring(1);
2044 const suba = allSubstrings(start);
2045 suba.forEach(function (subresult) {
2046 let tmp = subresult.slice(0);
2047 tmp[0] = input.charAt(0) + tmp[0];
2048 result.push(tmp);
2049 tmp = subresult.slice(0);
2050 tmp.unshift(input.charAt(0));
2051 result.push(tmp);
2052 });
2053 return result;
2054 };
2055 //# sourceMappingURL=strings.js.map
2056
2057 /***/ },
2058
2059 /***/ "./node_modules/tom-select/dist/esm/constants.js"
2060 /*!*******************************************************!*\
2061 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
2062 \*******************************************************/
2063 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2064
2065 __webpack_require__.r(__webpack_exports__);
2066 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2067 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
2068 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
2069 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
2070 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
2071 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
2072 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
2073 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
2074 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
2075 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
2076 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
2077 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
2078 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
2079 /* harmony export */ });
2080 const KEY_A = 65;
2081 const KEY_RETURN = 13;
2082 const KEY_ESC = 27;
2083 const KEY_LEFT = 37;
2084 const KEY_UP = 38;
2085 const KEY_RIGHT = 39;
2086 const KEY_DOWN = 40;
2087 const KEY_BACKSPACE = 8;
2088 const KEY_DELETE = 46;
2089 const KEY_TAB = 9;
2090 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
2091 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
2092 //# sourceMappingURL=constants.js.map
2093
2094 /***/ },
2095
2096 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
2097 /*!***************************************************************!*\
2098 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
2099 \***************************************************************/
2100 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2101
2102 __webpack_require__.r(__webpack_exports__);
2103 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2104 /* harmony export */ highlight: () => (/* binding */ highlight),
2105 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
2106 /* harmony export */ });
2107 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
2108 /**
2109 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
2110 * Highlights arbitrary terms in a node.
2111 *
2112 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
2113 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
2114 */
2115
2116 const highlight = (element, regex) => {
2117 if (regex === null)
2118 return;
2119 // convet string to regex
2120 if (typeof regex === 'string') {
2121 if (!regex.length)
2122 return;
2123 regex = new RegExp(regex, 'i');
2124 }
2125 // Wrap matching part of text node with highlighting <span>, e.g.
2126 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
2127 const highlightText = (node) => {
2128 var match = node.data.match(regex);
2129 if (match && node.data.length > 0) {
2130 var spannode = document.createElement('span');
2131 spannode.className = 'highlight';
2132 var middlebit = node.splitText(match.index);
2133 middlebit.splitText(match[0].length);
2134 var middleclone = middlebit.cloneNode(true);
2135 spannode.appendChild(middleclone);
2136 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
2137 return 1;
2138 }
2139 return 0;
2140 };
2141 // Recurse element node, looking for child text nodes to highlight, unless element
2142 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
2143 const highlightChildren = (node) => {
2144 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
2145 Array.from(node.childNodes).forEach(element => {
2146 highlightRecursive(element);
2147 });
2148 }
2149 };
2150 const highlightRecursive = (node) => {
2151 if (node.nodeType === 3) {
2152 return highlightText(node);
2153 }
2154 highlightChildren(node);
2155 return 0;
2156 };
2157 highlightRecursive(element);
2158 };
2159 /**
2160 * removeHighlight fn copied from highlight v5 and
2161 * edited to remove with(), pass js strict mode, and use without jquery
2162 */
2163 const removeHighlight = (el) => {
2164 var elements = el.querySelectorAll("span.highlight");
2165 Array.prototype.forEach.call(elements, function (el) {
2166 var parent = el.parentNode;
2167 parent.replaceChild(el.firstChild, el);
2168 parent.normalize();
2169 });
2170 };
2171 //# sourceMappingURL=highlight.js.map
2172
2173 /***/ },
2174
2175 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
2176 /*!****************************************************************!*\
2177 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
2178 \****************************************************************/
2179 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2180
2181 __webpack_require__.r(__webpack_exports__);
2182 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2183 /* harmony export */ "default": () => (/* binding */ MicroEvent)
2184 /* harmony export */ });
2185 /**
2186 * MicroEvent - to make any js object an event emitter
2187 *
2188 * - pure javascript - server compatible, browser compatible
2189 * - dont rely on the browser doms
2190 * - super simple - you get it immediatly, no mistery, no magic involved
2191 *
2192 * @author Jerome Etienne (https://github.com/jeromeetienne)
2193 */
2194 /**
2195 * Execute callback for each event in space separated list of event names
2196 *
2197 */
2198 function forEvents(events, callback) {
2199 events.split(/\s+/).forEach((event) => {
2200 callback(event);
2201 });
2202 }
2203 class MicroEvent {
2204 constructor() {
2205 this._events = {};
2206 }
2207 on(events, fct) {
2208 forEvents(events, (event) => {
2209 const event_array = this._events[event] || [];
2210 event_array.push(fct);
2211 this._events[event] = event_array;
2212 });
2213 }
2214 off(events, fct) {
2215 var n = arguments.length;
2216 if (n === 0) {
2217 this._events = {};
2218 return;
2219 }
2220 forEvents(events, (event) => {
2221 if (n === 1) {
2222 delete this._events[event];
2223 return;
2224 }
2225 const event_array = this._events[event];
2226 if (event_array === undefined)
2227 return;
2228 event_array.splice(event_array.indexOf(fct), 1);
2229 this._events[event] = event_array;
2230 });
2231 }
2232 trigger(events, ...args) {
2233 var self = this;
2234 forEvents(events, (event) => {
2235 const event_array = self._events[event];
2236 if (event_array === undefined)
2237 return;
2238 event_array.forEach(fct => {
2239 fct.apply(self, args);
2240 });
2241 });
2242 }
2243 }
2244 ;
2245 //# sourceMappingURL=microevent.js.map
2246
2247 /***/ },
2248
2249 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
2250 /*!*****************************************************************!*\
2251 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
2252 \*****************************************************************/
2253 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2254
2255 __webpack_require__.r(__webpack_exports__);
2256 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2257 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
2258 /* harmony export */ });
2259 /**
2260 * microplugin.js
2261 * Copyright (c) 2013 Brian Reavis & contributors
2262 *
2263 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2264 * file except in compliance with the License. You may obtain a copy of the License at:
2265 * http://www.apache.org/licenses/LICENSE-2.0
2266 *
2267 * Unless required by applicable law or agreed to in writing, software distributed under
2268 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2269 * ANY KIND, either express or implied. See the License for the specific language
2270 * governing permissions and limitations under the License.
2271 *
2272 * @author Brian Reavis <brian@thirdroute.com>
2273 */
2274 function MicroPlugin(Interface) {
2275 Interface.plugins = {};
2276 return class extends Interface {
2277 constructor() {
2278 super(...arguments);
2279 this.plugins = {
2280 names: [],
2281 settings: {},
2282 requested: {},
2283 loaded: {}
2284 };
2285 }
2286 /**
2287 * Registers a plugin.
2288 *
2289 * @param {function} fn
2290 */
2291 static define(name, fn) {
2292 Interface.plugins[name] = {
2293 'name': name,
2294 'fn': fn
2295 };
2296 }
2297 /**
2298 * Initializes the listed plugins (with options).
2299 * Acceptable formats:
2300 *
2301 * List (without options):
2302 * ['a', 'b', 'c']
2303 *
2304 * List (with options):
2305 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
2306 *
2307 * Hash (with options):
2308 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
2309 *
2310 * @param {array|object} plugins
2311 */
2312 initializePlugins(plugins) {
2313 var key, name;
2314 const self = this;
2315 const queue = [];
2316 if (Array.isArray(plugins)) {
2317 plugins.forEach((plugin) => {
2318 if (typeof plugin === 'string') {
2319 queue.push(plugin);
2320 }
2321 else {
2322 self.plugins.settings[plugin.name] = plugin.options;
2323 queue.push(plugin.name);
2324 }
2325 });
2326 }
2327 else if (plugins) {
2328 for (key in plugins) {
2329 if (plugins.hasOwnProperty(key)) {
2330 self.plugins.settings[key] = plugins[key];
2331 queue.push(key);
2332 }
2333 }
2334 }
2335 while (name = queue.shift()) {
2336 self.require(name);
2337 }
2338 }
2339 loadPlugin(name) {
2340 var self = this;
2341 var plugins = self.plugins;
2342 var plugin = Interface.plugins[name];
2343 if (!Interface.plugins.hasOwnProperty(name)) {
2344 throw new Error('Unable to find "' + name + '" plugin');
2345 }
2346 plugins.requested[name] = true;
2347 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
2348 plugins.names.push(name);
2349 }
2350 /**
2351 * Initializes a plugin.
2352 *
2353 */
2354 require(name) {
2355 var self = this;
2356 var plugins = self.plugins;
2357 if (!self.plugins.loaded.hasOwnProperty(name)) {
2358 if (plugins.requested[name]) {
2359 throw new Error('Plugin has circular dependency ("' + name + '")');
2360 }
2361 self.loadPlugin(name);
2362 }
2363 return plugins.loaded[name];
2364 }
2365 };
2366 }
2367 //# sourceMappingURL=microplugin.js.map
2368
2369 /***/ },
2370
2371 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
2372 /*!******************************************************!*\
2373 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
2374 \******************************************************/
2375 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2376
2377 __webpack_require__.r(__webpack_exports__);
2378 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2379 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2380 /* harmony export */ });
2381 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
2382 options: [],
2383 optgroups: [],
2384 plugins: [],
2385 delimiter: ',',
2386 splitOn: null, // regexp or string for splitting up values from a paste command
2387 persist: true,
2388 diacritics: true,
2389 create: null,
2390 createOnBlur: false,
2391 createFilter: null,
2392 highlight: true,
2393 openOnFocus: true,
2394 shouldOpen: null,
2395 maxOptions: 50,
2396 maxItems: null,
2397 hideSelected: null,
2398 duplicates: false,
2399 addPrecedence: false,
2400 selectOnTab: false,
2401 preload: null,
2402 allowEmptyOption: false,
2403 //closeAfterSelect: false,
2404 refreshThrottle: 300,
2405 loadThrottle: 300,
2406 loadingClass: 'loading',
2407 dataAttr: null, //'data-data',
2408 optgroupField: 'optgroup',
2409 valueField: 'value',
2410 labelField: 'text',
2411 disabledField: 'disabled',
2412 optgroupLabelField: 'label',
2413 optgroupValueField: 'value',
2414 lockOptgroupOrder: false,
2415 sortField: '$order',
2416 searchField: ['text'],
2417 searchConjunction: 'and',
2418 mode: null,
2419 wrapperClass: 'ts-wrapper',
2420 controlClass: 'ts-control',
2421 dropdownClass: 'ts-dropdown',
2422 dropdownContentClass: 'ts-dropdown-content',
2423 itemClass: 'item',
2424 optionClass: 'option',
2425 dropdownParent: null,
2426 controlInput: '<input type="text" autocomplete="off" size="1" />',
2427 copyClassesToDropdown: false,
2428 placeholder: null,
2429 hidePlaceholder: null,
2430 shouldLoad: function (query) {
2431 return query.length > 0;
2432 },
2433 /*
2434 load : null, // function(query, callback) { ... }
2435 score : null, // function(search) { ... }
2436 onInitialize : null, // function() { ... }
2437 onChange : null, // function(value) { ... }
2438 onItemAdd : null, // function(value, $item) { ... }
2439 onItemRemove : null, // function(value) { ... }
2440 onClear : null, // function() { ... }
2441 onOptionAdd : null, // function(value, data) { ... }
2442 onOptionRemove : null, // function(value) { ... }
2443 onOptionClear : null, // function() { ... }
2444 onOptionGroupAdd : null, // function(id, data) { ... }
2445 onOptionGroupRemove : null, // function(id) { ... }
2446 onOptionGroupClear : null, // function() { ... }
2447 onDropdownOpen : null, // function(dropdown) { ... }
2448 onDropdownClose : null, // function(dropdown) { ... }
2449 onType : null, // function(str) { ... }
2450 onDelete : null, // function(values) { ... }
2451 */
2452 render: {
2453 /*
2454 item: null,
2455 optgroup: null,
2456 optgroup_header: null,
2457 option: null,
2458 option_create: null
2459 */
2460 }
2461 });
2462 //# sourceMappingURL=defaults.js.map
2463
2464 /***/ },
2465
2466 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
2467 /*!*********************************************************!*\
2468 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
2469 \*********************************************************/
2470 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2471
2472 __webpack_require__.r(__webpack_exports__);
2473 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2474 /* harmony export */ "default": () => (/* binding */ getSettings)
2475 /* harmony export */ });
2476 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
2477 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
2478
2479
2480 function getSettings(input, settings_user) {
2481 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
2482 var attr_data = settings.dataAttr;
2483 var field_label = settings.labelField;
2484 var field_value = settings.valueField;
2485 var field_disabled = settings.disabledField;
2486 var field_optgroup = settings.optgroupField;
2487 var field_optgroup_label = settings.optgroupLabelField;
2488 var field_optgroup_value = settings.optgroupValueField;
2489 var tag_name = input.tagName.toLowerCase();
2490 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
2491 if (!placeholder && !settings.allowEmptyOption) {
2492 let option = input.querySelector('option[value=""]');
2493 if (option) {
2494 placeholder = option.textContent;
2495 }
2496 }
2497 var settings_element = {
2498 placeholder: placeholder,
2499 options: [],
2500 optgroups: [],
2501 items: [],
2502 maxItems: null,
2503 };
2504 /**
2505 * Initialize from a <select> element.
2506 *
2507 */
2508 var init_select = () => {
2509 var tagName;
2510 var options = settings_element.options;
2511 var optionsMap = {};
2512 var group_count = 1;
2513 let $order = 0;
2514 var readData = (el) => {
2515 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
2516 var json = attr_data && data[attr_data];
2517 if (typeof json === 'string' && json.length) {
2518 data = Object.assign(data, JSON.parse(json));
2519 }
2520 return data;
2521 };
2522 var addOption = (option, group) => {
2523 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
2524 if (value == null)
2525 return;
2526 if (!value && !settings.allowEmptyOption)
2527 return;
2528 // if the option already exists, it's probably been
2529 // duplicated in another optgroup. in this case, push
2530 // the current group to the "optgroup" property on the
2531 // existing option so that it's rendered in both places.
2532 if (optionsMap.hasOwnProperty(value)) {
2533 if (group) {
2534 var arr = optionsMap[value][field_optgroup];
2535 if (!arr) {
2536 optionsMap[value][field_optgroup] = group;
2537 }
2538 else if (!Array.isArray(arr)) {
2539 optionsMap[value][field_optgroup] = [arr, group];
2540 }
2541 else {
2542 arr.push(group);
2543 }
2544 }
2545 }
2546 else {
2547 var option_data = readData(option);
2548 option_data[field_label] = option_data[field_label] || option.textContent;
2549 option_data[field_value] = option_data[field_value] || value;
2550 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
2551 option_data[field_optgroup] = option_data[field_optgroup] || group;
2552 option_data.$option = option;
2553 option_data.$order = option_data.$order || ++$order;
2554 optionsMap[value] = option_data;
2555 options.push(option_data);
2556 }
2557 if (option.selected) {
2558 settings_element.items.push(value);
2559 }
2560 };
2561 var addGroup = (optgroup) => {
2562 var id, optgroup_data;
2563 optgroup_data = readData(optgroup);
2564 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
2565 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
2566 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
2567 optgroup_data.$order = optgroup_data.$order || ++$order;
2568 settings_element.optgroups.push(optgroup_data);
2569 id = optgroup_data[field_optgroup_value];
2570 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
2571 addOption(option, id);
2572 });
2573 };
2574 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
2575 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
2576 tagName = child.tagName.toLowerCase();
2577 if (tagName === 'optgroup') {
2578 addGroup(child);
2579 }
2580 else if (tagName === 'option') {
2581 addOption(child);
2582 }
2583 });
2584 };
2585 /**
2586 * Initialize from a <input type="text"> element.
2587 *
2588 */
2589 var init_textbox = () => {
2590 const data_raw = input.getAttribute(attr_data);
2591 if (!data_raw) {
2592 var value = input.value.trim() || '';
2593 if (!settings.allowEmptyOption && !value.length)
2594 return;
2595 const values = value.split(settings.delimiter);
2596 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
2597 const option = {};
2598 option[field_label] = value;
2599 option[field_value] = value;
2600 settings_element.options.push(option);
2601 });
2602 settings_element.items = values;
2603 }
2604 else {
2605 settings_element.options = JSON.parse(data_raw);
2606 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
2607 settings_element.items.push(opt[field_value]);
2608 });
2609 }
2610 };
2611 if (tag_name === 'select') {
2612 init_select();
2613 }
2614 else {
2615 init_textbox();
2616 }
2617 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
2618 }
2619 ;
2620 //# sourceMappingURL=getSettings.js.map
2621
2622 /***/ },
2623
2624 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
2625 /*!***************************************************************************!*\
2626 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
2627 \***************************************************************************/
2628 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2629
2630 __webpack_require__.r(__webpack_exports__);
2631 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2632 /* harmony export */ "default": () => (/* binding */ plugin)
2633 /* harmony export */ });
2634 /**
2635 * Tom Select v2.4.3
2636 * Licensed under the Apache License, Version 2.0 (the "License");
2637 */
2638
2639 /**
2640 * Converts a scalar to its best string representation
2641 * for hash keys and HTML attribute values.
2642 *
2643 * Transformations:
2644 * 'str' -> 'str'
2645 * null -> ''
2646 * undefined -> ''
2647 * true -> '1'
2648 * false -> '0'
2649 * 0 -> '0'
2650 * 1 -> '1'
2651 *
2652 */
2653
2654 /**
2655 * Iterates over arrays and hashes.
2656 *
2657 * ```
2658 * iterate(this.items, function(item, id) {
2659 * // invoked for each item
2660 * });
2661 * ```
2662 *
2663 */
2664 const iterate = (object, callback) => {
2665 if (Array.isArray(object)) {
2666 object.forEach(callback);
2667 } else {
2668 for (var key in object) {
2669 if (object.hasOwnProperty(key)) {
2670 callback(object[key], key);
2671 }
2672 }
2673 }
2674 };
2675
2676 /**
2677 * Remove css classes
2678 *
2679 */
2680 const removeClasses = (elmts, ...classes) => {
2681 var norm_classes = classesArray(classes);
2682 elmts = castAsArray(elmts);
2683 elmts.map(el => {
2684 norm_classes.map(cls => {
2685 el.classList.remove(cls);
2686 });
2687 });
2688 };
2689
2690 /**
2691 * Return arguments
2692 *
2693 */
2694 const classesArray = args => {
2695 var classes = [];
2696 iterate(args, _classes => {
2697 if (typeof _classes === 'string') {
2698 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
2699 }
2700 if (Array.isArray(_classes)) {
2701 classes = classes.concat(_classes);
2702 }
2703 });
2704 return classes.filter(Boolean);
2705 };
2706
2707 /**
2708 * Create an array from arg if it's not already an array
2709 *
2710 */
2711 const castAsArray = arg => {
2712 if (!Array.isArray(arg)) {
2713 arg = [arg];
2714 }
2715 return arg;
2716 };
2717
2718 /**
2719 * Get the index of an element amongst sibling nodes of the same type
2720 *
2721 */
2722 const nodeIndex = (el, amongst) => {
2723 if (!el) return -1;
2724 amongst = amongst || el.nodeName;
2725 var i = 0;
2726 while (el = el.previousElementSibling) {
2727 if (el.matches(amongst)) {
2728 i++;
2729 }
2730 }
2731 return i;
2732 };
2733
2734 /**
2735 * Plugin: "dropdown_input" (Tom Select)
2736 * Copyright (c) contributors
2737 *
2738 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2739 * file except in compliance with the License. You may obtain a copy of the License at:
2740 * http://www.apache.org/licenses/LICENSE-2.0
2741 *
2742 * Unless required by applicable law or agreed to in writing, software distributed under
2743 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2744 * ANY KIND, either express or implied. See the License for the specific language
2745 * governing permissions and limitations under the License.
2746 *
2747 */
2748
2749 function plugin () {
2750 var self = this;
2751
2752 /**
2753 * Moves the caret to the specified index.
2754 *
2755 * The input must be moved by leaving it in place and moving the
2756 * siblings, due to the fact that focus cannot be restored once lost
2757 * on mobile webkit devices
2758 *
2759 */
2760 self.hook('instead', 'setCaret', new_pos => {
2761 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
2762 new_pos = self.items.length;
2763 } else {
2764 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
2765 if (new_pos != self.caretPos && !self.isPending) {
2766 self.controlChildren().forEach((child, j) => {
2767 if (j < new_pos) {
2768 self.control_input.insertAdjacentElement('beforebegin', child);
2769 } else {
2770 self.control.appendChild(child);
2771 }
2772 });
2773 }
2774 }
2775 self.caretPos = new_pos;
2776 });
2777 self.hook('instead', 'moveCaret', direction => {
2778 if (!self.isFocused) return;
2779
2780 // move caret before or after selected items
2781 const last_active = self.getLastActive(direction);
2782 if (last_active) {
2783 const idx = nodeIndex(last_active);
2784 self.setCaret(direction > 0 ? idx + 1 : idx);
2785 self.setActiveItem();
2786 removeClasses(last_active, 'last-active');
2787
2788 // move caret left or right of current position
2789 } else {
2790 self.setCaret(self.caretPos + direction);
2791 }
2792 });
2793 }
2794
2795
2796 //# sourceMappingURL=plugin.js.map
2797
2798
2799 /***/ },
2800
2801 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
2802 /*!****************************************************************************!*\
2803 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
2804 \****************************************************************************/
2805 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2806
2807 __webpack_require__.r(__webpack_exports__);
2808 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2809 /* harmony export */ "default": () => (/* binding */ plugin)
2810 /* harmony export */ });
2811 /**
2812 * Tom Select v2.4.3
2813 * Licensed under the Apache License, Version 2.0 (the "License");
2814 */
2815
2816 /**
2817 * Converts a scalar to its best string representation
2818 * for hash keys and HTML attribute values.
2819 *
2820 * Transformations:
2821 * 'str' -> 'str'
2822 * null -> ''
2823 * undefined -> ''
2824 * true -> '1'
2825 * false -> '0'
2826 * 0 -> '0'
2827 * 1 -> '1'
2828 *
2829 */
2830
2831 /**
2832 * Add event helper
2833 *
2834 */
2835 const addEvent = (target, type, callback, options) => {
2836 target.addEventListener(type, callback, options);
2837 };
2838
2839 /**
2840 * Plugin: "change_listener" (Tom Select)
2841 * Copyright (c) contributors
2842 *
2843 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2844 * file except in compliance with the License. You may obtain a copy of the License at:
2845 * http://www.apache.org/licenses/LICENSE-2.0
2846 *
2847 * Unless required by applicable law or agreed to in writing, software distributed under
2848 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2849 * ANY KIND, either express or implied. See the License for the specific language
2850 * governing permissions and limitations under the License.
2851 *
2852 */
2853
2854 function plugin () {
2855 addEvent(this.input, 'change', () => {
2856 this.sync();
2857 });
2858 }
2859
2860
2861 //# sourceMappingURL=plugin.js.map
2862
2863
2864 /***/ },
2865
2866 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
2867 /*!*****************************************************************************!*\
2868 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
2869 \*****************************************************************************/
2870 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2871
2872 __webpack_require__.r(__webpack_exports__);
2873 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2874 /* harmony export */ "default": () => (/* binding */ plugin)
2875 /* harmony export */ });
2876 /**
2877 * Tom Select v2.4.3
2878 * Licensed under the Apache License, Version 2.0 (the "License");
2879 */
2880
2881 /**
2882 * Converts a scalar to its best string representation
2883 * for hash keys and HTML attribute values.
2884 *
2885 * Transformations:
2886 * 'str' -> 'str'
2887 * null -> ''
2888 * undefined -> ''
2889 * true -> '1'
2890 * false -> '0'
2891 * 0 -> '0'
2892 * 1 -> '1'
2893 *
2894 */
2895 const hash_key = value => {
2896 if (typeof value === 'undefined' || value === null) return null;
2897 return get_hash(value);
2898 };
2899 const get_hash = value => {
2900 if (typeof value === 'boolean') return value ? '1' : '0';
2901 return value + '';
2902 };
2903
2904 /**
2905 * Prevent default
2906 *
2907 */
2908 const preventDefault = (evt, stop = false) => {
2909 if (evt) {
2910 evt.preventDefault();
2911 if (stop) {
2912 evt.stopPropagation();
2913 }
2914 }
2915 };
2916
2917 /**
2918 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
2919 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
2920 *
2921 * param query should be {}
2922 */
2923 const getDom = query => {
2924 if (query.jquery) {
2925 return query[0];
2926 }
2927 if (query instanceof HTMLElement) {
2928 return query;
2929 }
2930 if (isHtmlString(query)) {
2931 var tpl = document.createElement('template');
2932 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
2933 return tpl.content.firstChild;
2934 }
2935 return document.querySelector(query);
2936 };
2937 const isHtmlString = arg => {
2938 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
2939 return true;
2940 }
2941 return false;
2942 };
2943
2944 /**
2945 * Plugin: "checkbox_options" (Tom Select)
2946 * Copyright (c) contributors
2947 *
2948 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2949 * file except in compliance with the License. You may obtain a copy of the License at:
2950 * http://www.apache.org/licenses/LICENSE-2.0
2951 *
2952 * Unless required by applicable law or agreed to in writing, software distributed under
2953 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2954 * ANY KIND, either express or implied. See the License for the specific language
2955 * governing permissions and limitations under the License.
2956 *
2957 */
2958
2959 function plugin (userOptions) {
2960 var self = this;
2961 var orig_onOptionSelect = self.onOptionSelect;
2962 self.settings.hideSelected = false;
2963 const cbOptions = Object.assign({
2964 // so that the user may add different ones as well
2965 className: "tomselect-checkbox",
2966 // the following default to the historic plugin's values
2967 checkedClassNames: undefined,
2968 uncheckedClassNames: undefined
2969 }, userOptions);
2970 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
2971 if (toCheck) {
2972 checkbox.checked = true;
2973 if (cbOptions.uncheckedClassNames) {
2974 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
2975 }
2976 if (cbOptions.checkedClassNames) {
2977 checkbox.classList.add(...cbOptions.checkedClassNames);
2978 }
2979 } else {
2980 checkbox.checked = false;
2981 if (cbOptions.checkedClassNames) {
2982 checkbox.classList.remove(...cbOptions.checkedClassNames);
2983 }
2984 if (cbOptions.uncheckedClassNames) {
2985 checkbox.classList.add(...cbOptions.uncheckedClassNames);
2986 }
2987 }
2988 };
2989
2990 // update the checkbox for an option
2991 var UpdateCheckbox = function UpdateCheckbox(option) {
2992 setTimeout(() => {
2993 var checkbox = option.querySelector('input.' + cbOptions.className);
2994 if (checkbox instanceof HTMLInputElement) {
2995 UpdateChecked(checkbox, option.classList.contains('selected'));
2996 }
2997 }, 1);
2998 };
2999
3000 // add checkbox to option template
3001 self.hook('after', 'setupTemplates', () => {
3002 var orig_render_option = self.settings.render.option;
3003 self.settings.render.option = (data, escape_html) => {
3004 var rendered = getDom(orig_render_option.call(self, data, escape_html));
3005 var checkbox = document.createElement('input');
3006 if (cbOptions.className) {
3007 checkbox.classList.add(cbOptions.className);
3008 }
3009 checkbox.addEventListener('click', function (evt) {
3010 preventDefault(evt);
3011 });
3012 checkbox.type = 'checkbox';
3013 const hashed = hash_key(data[self.settings.valueField]);
3014 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
3015 rendered.prepend(checkbox);
3016 return rendered;
3017 };
3018 });
3019
3020 // uncheck when item removed
3021 self.on('item_remove', value => {
3022 var option = self.getOption(value);
3023 if (option) {
3024 // if dropdown hasn't been opened yet, the option won't exist
3025 option.classList.remove('selected'); // selected class won't be removed yet
3026 UpdateCheckbox(option);
3027 }
3028 });
3029
3030 // check when item added
3031 self.on('item_add', value => {
3032 var option = self.getOption(value);
3033 if (option) {
3034 // if dropdown hasn't been opened yet, the option won't exist
3035 UpdateCheckbox(option);
3036 }
3037 });
3038
3039 // remove items when selected option is clicked
3040 self.hook('instead', 'onOptionSelect', (evt, option) => {
3041 if (option.classList.contains('selected')) {
3042 option.classList.remove('selected');
3043 self.removeItem(option.dataset.value);
3044 self.refreshOptions();
3045 preventDefault(evt, true);
3046 return;
3047 }
3048 orig_onOptionSelect.call(self, evt, option);
3049 UpdateCheckbox(option);
3050 });
3051 }
3052
3053
3054 //# sourceMappingURL=plugin.js.map
3055
3056
3057 /***/ },
3058
3059 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
3060 /*!*************************************************************************!*\
3061 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
3062 \*************************************************************************/
3063 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3064
3065 __webpack_require__.r(__webpack_exports__);
3066 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3067 /* harmony export */ "default": () => (/* binding */ plugin)
3068 /* harmony export */ });
3069 /**
3070 * Tom Select v2.4.3
3071 * Licensed under the Apache License, Version 2.0 (the "License");
3072 */
3073
3074 /**
3075 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3076 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3077 *
3078 * param query should be {}
3079 */
3080 const getDom = query => {
3081 if (query.jquery) {
3082 return query[0];
3083 }
3084 if (query instanceof HTMLElement) {
3085 return query;
3086 }
3087 if (isHtmlString(query)) {
3088 var tpl = document.createElement('template');
3089 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3090 return tpl.content.firstChild;
3091 }
3092 return document.querySelector(query);
3093 };
3094 const isHtmlString = arg => {
3095 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3096 return true;
3097 }
3098 return false;
3099 };
3100
3101 /**
3102 * Plugin: "dropdown_header" (Tom Select)
3103 * Copyright (c) contributors
3104 *
3105 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3106 * file except in compliance with the License. You may obtain a copy of the License at:
3107 * http://www.apache.org/licenses/LICENSE-2.0
3108 *
3109 * Unless required by applicable law or agreed to in writing, software distributed under
3110 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3111 * ANY KIND, either express or implied. See the License for the specific language
3112 * governing permissions and limitations under the License.
3113 *
3114 */
3115
3116 function plugin (userOptions) {
3117 const self = this;
3118 const options = Object.assign({
3119 className: 'clear-button',
3120 title: 'Clear All',
3121 html: data => {
3122 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
3123 }
3124 }, userOptions);
3125 self.on('initialize', () => {
3126 var button = getDom(options.html(options));
3127 button.addEventListener('click', evt => {
3128 if (self.isLocked) return;
3129 self.clear();
3130 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
3131 self.addItem('');
3132 }
3133 evt.preventDefault();
3134 evt.stopPropagation();
3135 });
3136 self.control.appendChild(button);
3137 });
3138 }
3139
3140
3141 //# sourceMappingURL=plugin.js.map
3142
3143
3144 /***/ },
3145
3146 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
3147 /*!**********************************************************************!*\
3148 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
3149 \**********************************************************************/
3150 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3151
3152 __webpack_require__.r(__webpack_exports__);
3153 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3154 /* harmony export */ "default": () => (/* binding */ plugin)
3155 /* harmony export */ });
3156 /**
3157 * Tom Select v2.4.3
3158 * Licensed under the Apache License, Version 2.0 (the "License");
3159 */
3160
3161 /**
3162 * Converts a scalar to its best string representation
3163 * for hash keys and HTML attribute values.
3164 *
3165 * Transformations:
3166 * 'str' -> 'str'
3167 * null -> ''
3168 * undefined -> ''
3169 * true -> '1'
3170 * false -> '0'
3171 * 0 -> '0'
3172 * 1 -> '1'
3173 *
3174 */
3175
3176 /**
3177 * Prevent default
3178 *
3179 */
3180 const preventDefault = (evt, stop = false) => {
3181 if (evt) {
3182 evt.preventDefault();
3183 if (stop) {
3184 evt.stopPropagation();
3185 }
3186 }
3187 };
3188
3189 /**
3190 * Add event helper
3191 *
3192 */
3193 const addEvent = (target, type, callback, options) => {
3194 target.addEventListener(type, callback, options);
3195 };
3196
3197 /**
3198 * Iterates over arrays and hashes.
3199 *
3200 * ```
3201 * iterate(this.items, function(item, id) {
3202 * // invoked for each item
3203 * });
3204 * ```
3205 *
3206 */
3207 const iterate = (object, callback) => {
3208 if (Array.isArray(object)) {
3209 object.forEach(callback);
3210 } else {
3211 for (var key in object) {
3212 if (object.hasOwnProperty(key)) {
3213 callback(object[key], key);
3214 }
3215 }
3216 }
3217 };
3218
3219 /**
3220 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3221 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3222 *
3223 * param query should be {}
3224 */
3225 const getDom = query => {
3226 if (query.jquery) {
3227 return query[0];
3228 }
3229 if (query instanceof HTMLElement) {
3230 return query;
3231 }
3232 if (isHtmlString(query)) {
3233 var tpl = document.createElement('template');
3234 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3235 return tpl.content.firstChild;
3236 }
3237 return document.querySelector(query);
3238 };
3239 const isHtmlString = arg => {
3240 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3241 return true;
3242 }
3243 return false;
3244 };
3245
3246 /**
3247 * Set attributes of an element
3248 *
3249 */
3250 const setAttr = (el, attrs) => {
3251 iterate(attrs, (val, attr) => {
3252 if (val == null) {
3253 el.removeAttribute(attr);
3254 } else {
3255 el.setAttribute(attr, '' + val);
3256 }
3257 });
3258 };
3259
3260 /**
3261 * Plugin: "drag_drop" (Tom Select)
3262 * Copyright (c) contributors
3263 *
3264 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3265 * file except in compliance with the License. You may obtain a copy of the License at:
3266 * http://www.apache.org/licenses/LICENSE-2.0
3267 *
3268 * Unless required by applicable law or agreed to in writing, software distributed under
3269 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3270 * ANY KIND, either express or implied. See the License for the specific language
3271 * governing permissions and limitations under the License.
3272 *
3273 */
3274
3275 const insertAfter = (referenceNode, newNode) => {
3276 var _referenceNode$parent;
3277 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
3278 };
3279 const insertBefore = (referenceNode, newNode) => {
3280 var _referenceNode$parent2;
3281 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
3282 };
3283 const isBefore = (referenceNode, newNode) => {
3284 do {
3285 var _newNode;
3286 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
3287 if (referenceNode == newNode) {
3288 return true;
3289 }
3290 } while (newNode && newNode.previousElementSibling);
3291 return false;
3292 };
3293 function plugin () {
3294 var self = this;
3295 if (self.settings.mode !== 'multi') return;
3296 var orig_lock = self.lock;
3297 var orig_unlock = self.unlock;
3298 let sortable = true;
3299 let drag_item;
3300
3301 /**
3302 * Add draggable attribute to item
3303 */
3304 self.hook('after', 'setupTemplates', () => {
3305 var orig_render_item = self.settings.render.item;
3306 self.settings.render.item = (data, escape) => {
3307 const item = getDom(orig_render_item.call(self, data, escape));
3308 setAttr(item, {
3309 'draggable': 'true'
3310 });
3311
3312 // prevent doc_mousedown (see tom-select.ts)
3313 const mousedown = evt => {
3314 if (!sortable) preventDefault(evt);
3315 evt.stopPropagation();
3316 };
3317 const dragStart = evt => {
3318 drag_item = item;
3319 setTimeout(() => {
3320 item.classList.add('ts-dragging');
3321 }, 0);
3322 };
3323 const dragOver = evt => {
3324 evt.preventDefault();
3325 item.classList.add('ts-drag-over');
3326 moveitem(item, drag_item);
3327 };
3328 const dragLeave = () => {
3329 item.classList.remove('ts-drag-over');
3330 };
3331 const moveitem = (targetitem, dragitem) => {
3332 if (dragitem === undefined) return;
3333 if (isBefore(dragitem, item)) {
3334 insertAfter(targetitem, dragitem);
3335 } else {
3336 insertBefore(targetitem, dragitem);
3337 }
3338 };
3339 const dragend = () => {
3340 var _drag_item;
3341 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
3342 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
3343 drag_item = undefined;
3344 var values = [];
3345 self.control.querySelectorAll(`[data-value]`).forEach(el => {
3346 if (el.dataset.value) {
3347 let value = el.dataset.value;
3348 if (value) {
3349 values.push(value);
3350 }
3351 }
3352 });
3353 self.setValue(values);
3354 };
3355 addEvent(item, 'mousedown', mousedown);
3356 addEvent(item, 'dragstart', dragStart);
3357 addEvent(item, 'dragenter', dragOver);
3358 addEvent(item, 'dragover', dragOver);
3359 addEvent(item, 'dragleave', dragLeave);
3360 addEvent(item, 'dragend', dragend);
3361 return item;
3362 };
3363 });
3364 self.hook('instead', 'lock', () => {
3365 sortable = false;
3366 return orig_lock.call(self);
3367 });
3368 self.hook('instead', 'unlock', () => {
3369 sortable = true;
3370 return orig_unlock.call(self);
3371 });
3372 }
3373
3374
3375 //# sourceMappingURL=plugin.js.map
3376
3377
3378 /***/ },
3379
3380 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
3381 /*!****************************************************************************!*\
3382 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
3383 \****************************************************************************/
3384 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3385
3386 __webpack_require__.r(__webpack_exports__);
3387 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3388 /* harmony export */ "default": () => (/* binding */ plugin)
3389 /* harmony export */ });
3390 /**
3391 * Tom Select v2.4.3
3392 * Licensed under the Apache License, Version 2.0 (the "License");
3393 */
3394
3395 /**
3396 * Converts a scalar to its best string representation
3397 * for hash keys and HTML attribute values.
3398 *
3399 * Transformations:
3400 * 'str' -> 'str'
3401 * null -> ''
3402 * undefined -> ''
3403 * true -> '1'
3404 * false -> '0'
3405 * 0 -> '0'
3406 * 1 -> '1'
3407 *
3408 */
3409
3410 /**
3411 * Prevent default
3412 *
3413 */
3414 const preventDefault = (evt, stop = false) => {
3415 if (evt) {
3416 evt.preventDefault();
3417 if (stop) {
3418 evt.stopPropagation();
3419 }
3420 }
3421 };
3422
3423 /**
3424 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3425 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3426 *
3427 * param query should be {}
3428 */
3429 const getDom = query => {
3430 if (query.jquery) {
3431 return query[0];
3432 }
3433 if (query instanceof HTMLElement) {
3434 return query;
3435 }
3436 if (isHtmlString(query)) {
3437 var tpl = document.createElement('template');
3438 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3439 return tpl.content.firstChild;
3440 }
3441 return document.querySelector(query);
3442 };
3443 const isHtmlString = arg => {
3444 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3445 return true;
3446 }
3447 return false;
3448 };
3449
3450 /**
3451 * Plugin: "dropdown_header" (Tom Select)
3452 * Copyright (c) contributors
3453 *
3454 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3455 * file except in compliance with the License. You may obtain a copy of the License at:
3456 * http://www.apache.org/licenses/LICENSE-2.0
3457 *
3458 * Unless required by applicable law or agreed to in writing, software distributed under
3459 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3460 * ANY KIND, either express or implied. See the License for the specific language
3461 * governing permissions and limitations under the License.
3462 *
3463 */
3464
3465 function plugin (userOptions) {
3466 const self = this;
3467 const options = Object.assign({
3468 title: 'Untitled',
3469 headerClass: 'dropdown-header',
3470 titleRowClass: 'dropdown-header-title',
3471 labelClass: 'dropdown-header-label',
3472 closeClass: 'dropdown-header-close',
3473 html: data => {
3474 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
3475 }
3476 }, userOptions);
3477 self.on('initialize', () => {
3478 var header = getDom(options.html(options));
3479 var close_link = header.querySelector('.' + options.closeClass);
3480 if (close_link) {
3481 close_link.addEventListener('click', evt => {
3482 preventDefault(evt, true);
3483 self.close();
3484 });
3485 }
3486 self.dropdown.insertBefore(header, self.dropdown.firstChild);
3487 });
3488 }
3489
3490
3491 //# sourceMappingURL=plugin.js.map
3492
3493
3494 /***/ },
3495
3496 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
3497 /*!***************************************************************************!*\
3498 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
3499 \***************************************************************************/
3500 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3501
3502 __webpack_require__.r(__webpack_exports__);
3503 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3504 /* harmony export */ "default": () => (/* binding */ plugin)
3505 /* harmony export */ });
3506 /**
3507 * Tom Select v2.4.3
3508 * Licensed under the Apache License, Version 2.0 (the "License");
3509 */
3510
3511 const KEY_ESC = 27;
3512 const KEY_TAB = 9;
3513 // ctrl key or apple key for ma
3514
3515 /**
3516 * Converts a scalar to its best string representation
3517 * for hash keys and HTML attribute values.
3518 *
3519 * Transformations:
3520 * 'str' -> 'str'
3521 * null -> ''
3522 * undefined -> ''
3523 * true -> '1'
3524 * false -> '0'
3525 * 0 -> '0'
3526 * 1 -> '1'
3527 *
3528 */
3529
3530 /**
3531 * Prevent default
3532 *
3533 */
3534 const preventDefault = (evt, stop = false) => {
3535 if (evt) {
3536 evt.preventDefault();
3537 if (stop) {
3538 evt.stopPropagation();
3539 }
3540 }
3541 };
3542
3543 /**
3544 * Add event helper
3545 *
3546 */
3547 const addEvent = (target, type, callback, options) => {
3548 target.addEventListener(type, callback, options);
3549 };
3550
3551 /**
3552 * Iterates over arrays and hashes.
3553 *
3554 * ```
3555 * iterate(this.items, function(item, id) {
3556 * // invoked for each item
3557 * });
3558 * ```
3559 *
3560 */
3561 const iterate = (object, callback) => {
3562 if (Array.isArray(object)) {
3563 object.forEach(callback);
3564 } else {
3565 for (var key in object) {
3566 if (object.hasOwnProperty(key)) {
3567 callback(object[key], key);
3568 }
3569 }
3570 }
3571 };
3572
3573 /**
3574 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3575 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3576 *
3577 * param query should be {}
3578 */
3579 const getDom = query => {
3580 if (query.jquery) {
3581 return query[0];
3582 }
3583 if (query instanceof HTMLElement) {
3584 return query;
3585 }
3586 if (isHtmlString(query)) {
3587 var tpl = document.createElement('template');
3588 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3589 return tpl.content.firstChild;
3590 }
3591 return document.querySelector(query);
3592 };
3593 const isHtmlString = arg => {
3594 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3595 return true;
3596 }
3597 return false;
3598 };
3599
3600 /**
3601 * Add css classes
3602 *
3603 */
3604 const addClasses = (elmts, ...classes) => {
3605 var norm_classes = classesArray(classes);
3606 elmts = castAsArray(elmts);
3607 elmts.map(el => {
3608 norm_classes.map(cls => {
3609 el.classList.add(cls);
3610 });
3611 });
3612 };
3613
3614 /**
3615 * Return arguments
3616 *
3617 */
3618 const classesArray = args => {
3619 var classes = [];
3620 iterate(args, _classes => {
3621 if (typeof _classes === 'string') {
3622 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
3623 }
3624 if (Array.isArray(_classes)) {
3625 classes = classes.concat(_classes);
3626 }
3627 });
3628 return classes.filter(Boolean);
3629 };
3630
3631 /**
3632 * Create an array from arg if it's not already an array
3633 *
3634 */
3635 const castAsArray = arg => {
3636 if (!Array.isArray(arg)) {
3637 arg = [arg];
3638 }
3639 return arg;
3640 };
3641
3642 /**
3643 * Plugin: "dropdown_input" (Tom Select)
3644 * Copyright (c) contributors
3645 *
3646 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3647 * file except in compliance with the License. You may obtain a copy of the License at:
3648 * http://www.apache.org/licenses/LICENSE-2.0
3649 *
3650 * Unless required by applicable law or agreed to in writing, software distributed under
3651 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3652 * ANY KIND, either express or implied. See the License for the specific language
3653 * governing permissions and limitations under the License.
3654 *
3655 */
3656
3657 function plugin () {
3658 const self = this;
3659 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
3660
3661 self.hook('before', 'setup', () => {
3662 self.focus_node = self.control;
3663 addClasses(self.control_input, 'dropdown-input');
3664 const div = getDom('<div class="dropdown-input-wrap">');
3665 div.append(self.control_input);
3666 self.dropdown.insertBefore(div, self.dropdown.firstChild);
3667
3668 // set a placeholder in the select control
3669 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
3670 placeholder.placeholder = self.settings.placeholder || '';
3671 self.control.append(placeholder);
3672 });
3673 self.on('initialize', () => {
3674 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
3675 self.control_input.addEventListener('keydown', evt => {
3676 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
3677 switch (evt.keyCode) {
3678 case KEY_ESC:
3679 if (self.isOpen) {
3680 preventDefault(evt, true);
3681 self.close();
3682 }
3683 self.clearActiveItems();
3684 return;
3685 case KEY_TAB:
3686 self.focus_node.tabIndex = -1;
3687 break;
3688 }
3689 return self.onKeyDown.call(self, evt);
3690 });
3691 self.on('blur', () => {
3692 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
3693 });
3694
3695 // give the control_input focus when the dropdown is open
3696 self.on('dropdown_open', () => {
3697 self.control_input.focus();
3698 });
3699
3700 // prevent onBlur from closing when focus is on the control_input
3701 const orig_onBlur = self.onBlur;
3702 self.hook('instead', 'onBlur', evt => {
3703 if (evt && evt.relatedTarget == self.control_input) return;
3704 return orig_onBlur.call(self);
3705 });
3706 addEvent(self.control_input, 'blur', () => self.onBlur());
3707
3708 // return focus to control to allow further keyboard input
3709 self.hook('before', 'close', () => {
3710 if (!self.isOpen) return;
3711 self.focus_node.focus({
3712 preventScroll: true
3713 });
3714 });
3715 });
3716 }
3717
3718
3719 //# sourceMappingURL=plugin.js.map
3720
3721
3722 /***/ },
3723
3724 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
3725 /*!***************************************************************************!*\
3726 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
3727 \***************************************************************************/
3728 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3729
3730 __webpack_require__.r(__webpack_exports__);
3731 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3732 /* harmony export */ "default": () => (/* binding */ plugin)
3733 /* harmony export */ });
3734 /**
3735 * Tom Select v2.4.3
3736 * Licensed under the Apache License, Version 2.0 (the "License");
3737 */
3738
3739 /**
3740 * Converts a scalar to its best string representation
3741 * for hash keys and HTML attribute values.
3742 *
3743 * Transformations:
3744 * 'str' -> 'str'
3745 * null -> ''
3746 * undefined -> ''
3747 * true -> '1'
3748 * false -> '0'
3749 * 0 -> '0'
3750 * 1 -> '1'
3751 *
3752 */
3753
3754 /**
3755 * Add event helper
3756 *
3757 */
3758 const addEvent = (target, type, callback, options) => {
3759 target.addEventListener(type, callback, options);
3760 };
3761
3762 /**
3763 * Plugin: "input_autogrow" (Tom Select)
3764 *
3765 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3766 * file except in compliance with the License. You may obtain a copy of the License at:
3767 * http://www.apache.org/licenses/LICENSE-2.0
3768 *
3769 * Unless required by applicable law or agreed to in writing, software distributed under
3770 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3771 * ANY KIND, either express or implied. See the License for the specific language
3772 * governing permissions and limitations under the License.
3773 *
3774 */
3775
3776 function plugin () {
3777 var self = this;
3778 self.on('initialize', () => {
3779 var test_input = document.createElement('span');
3780 var control = self.control_input;
3781 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
3782 self.wrapper.appendChild(test_input);
3783 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
3784 for (const style_name of transfer_styles) {
3785 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
3786 test_input.style[style_name] = control.style[style_name];
3787 }
3788
3789 /**
3790 * Set the control width
3791 *
3792 */
3793 var resize = () => {
3794 test_input.textContent = control.value;
3795 control.style.width = test_input.clientWidth + 'px';
3796 };
3797 resize();
3798 self.on('update item_add item_remove', resize);
3799 addEvent(control, 'input', resize);
3800 addEvent(control, 'keyup', resize);
3801 addEvent(control, 'blur', resize);
3802 addEvent(control, 'update', resize);
3803 });
3804 }
3805
3806
3807 //# sourceMappingURL=plugin.js.map
3808
3809
3810 /***/ },
3811
3812 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
3813 /*!****************************************************************************!*\
3814 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
3815 \****************************************************************************/
3816 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3817
3818 __webpack_require__.r(__webpack_exports__);
3819 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3820 /* harmony export */ "default": () => (/* binding */ plugin)
3821 /* harmony export */ });
3822 /**
3823 * Tom Select v2.4.3
3824 * Licensed under the Apache License, Version 2.0 (the "License");
3825 */
3826
3827 /**
3828 * Plugin: "no_active_items" (Tom Select)
3829 *
3830 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3831 * file except in compliance with the License. You may obtain a copy of the License at:
3832 * http://www.apache.org/licenses/LICENSE-2.0
3833 *
3834 * Unless required by applicable law or agreed to in writing, software distributed under
3835 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3836 * ANY KIND, either express or implied. See the License for the specific language
3837 * governing permissions and limitations under the License.
3838 *
3839 */
3840
3841 function plugin () {
3842 this.hook('instead', 'setActiveItem', () => {});
3843 this.hook('instead', 'selectAll', () => {});
3844 }
3845
3846
3847 //# sourceMappingURL=plugin.js.map
3848
3849
3850 /***/ },
3851
3852 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
3853 /*!********************************************************************************!*\
3854 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
3855 \********************************************************************************/
3856 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3857
3858 __webpack_require__.r(__webpack_exports__);
3859 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3860 /* harmony export */ "default": () => (/* binding */ plugin)
3861 /* harmony export */ });
3862 /**
3863 * Tom Select v2.4.3
3864 * Licensed under the Apache License, Version 2.0 (the "License");
3865 */
3866
3867 /**
3868 * Plugin: "input_autogrow" (Tom Select)
3869 *
3870 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3871 * file except in compliance with the License. You may obtain a copy of the License at:
3872 * http://www.apache.org/licenses/LICENSE-2.0
3873 *
3874 * Unless required by applicable law or agreed to in writing, software distributed under
3875 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3876 * ANY KIND, either express or implied. See the License for the specific language
3877 * governing permissions and limitations under the License.
3878 *
3879 */
3880
3881 function plugin () {
3882 var self = this;
3883 var orig_deleteSelection = self.deleteSelection;
3884 this.hook('instead', 'deleteSelection', evt => {
3885 if (self.activeItems.length) {
3886 return orig_deleteSelection.call(self, evt);
3887 }
3888 return false;
3889 });
3890 }
3891
3892
3893 //# sourceMappingURL=plugin.js.map
3894
3895
3896 /***/ },
3897
3898 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
3899 /*!*****************************************************************************!*\
3900 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
3901 \*****************************************************************************/
3902 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3903
3904 __webpack_require__.r(__webpack_exports__);
3905 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3906 /* harmony export */ "default": () => (/* binding */ plugin)
3907 /* harmony export */ });
3908 /**
3909 * Tom Select v2.4.3
3910 * Licensed under the Apache License, Version 2.0 (the "License");
3911 */
3912
3913 const KEY_LEFT = 37;
3914 const KEY_RIGHT = 39;
3915 // ctrl key or apple key for ma
3916
3917 /**
3918 * Get the closest node to the evt.target matching the selector
3919 * Stops at wrapper
3920 *
3921 */
3922 const parentMatch = (target, selector, wrapper) => {
3923 while (target && target.matches) {
3924 if (target.matches(selector)) {
3925 return target;
3926 }
3927 target = target.parentNode;
3928 }
3929 };
3930
3931 /**
3932 * Get the index of an element amongst sibling nodes of the same type
3933 *
3934 */
3935 const nodeIndex = (el, amongst) => {
3936 if (!el) return -1;
3937 amongst = amongst || el.nodeName;
3938 var i = 0;
3939 while (el = el.previousElementSibling) {
3940 if (el.matches(amongst)) {
3941 i++;
3942 }
3943 }
3944 return i;
3945 };
3946
3947 /**
3948 * Plugin: "optgroup_columns" (Tom Select.js)
3949 * Copyright (c) contributors
3950 *
3951 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3952 * file except in compliance with the License. You may obtain a copy of the License at:
3953 * http://www.apache.org/licenses/LICENSE-2.0
3954 *
3955 * Unless required by applicable law or agreed to in writing, software distributed under
3956 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3957 * ANY KIND, either express or implied. See the License for the specific language
3958 * governing permissions and limitations under the License.
3959 *
3960 */
3961
3962 function plugin () {
3963 var self = this;
3964 var orig_keydown = self.onKeyDown;
3965 self.hook('instead', 'onKeyDown', evt => {
3966 var index, option, options, optgroup;
3967 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
3968 return orig_keydown.call(self, evt);
3969 }
3970 self.ignoreHover = true;
3971 optgroup = parentMatch(self.activeOption, '[data-group]');
3972 index = nodeIndex(self.activeOption, '[data-selectable]');
3973 if (!optgroup) {
3974 return;
3975 }
3976 if (evt.keyCode === KEY_LEFT) {
3977 optgroup = optgroup.previousSibling;
3978 } else {
3979 optgroup = optgroup.nextSibling;
3980 }
3981 if (!optgroup) {
3982 return;
3983 }
3984 options = optgroup.querySelectorAll('[data-selectable]');
3985 option = options[Math.min(options.length - 1, index)];
3986 if (option) {
3987 self.setActiveOption(option);
3988 }
3989 });
3990 }
3991
3992
3993 //# sourceMappingURL=plugin.js.map
3994
3995
3996 /***/ },
3997
3998 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
3999 /*!**************************************************************************!*\
4000 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
4001 \**************************************************************************/
4002 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4003
4004 __webpack_require__.r(__webpack_exports__);
4005 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4006 /* harmony export */ "default": () => (/* binding */ plugin)
4007 /* harmony export */ });
4008 /**
4009 * Tom Select v2.4.3
4010 * Licensed under the Apache License, Version 2.0 (the "License");
4011 */
4012
4013 /**
4014 * Converts a scalar to its best string representation
4015 * for hash keys and HTML attribute values.
4016 *
4017 * Transformations:
4018 * 'str' -> 'str'
4019 * null -> ''
4020 * undefined -> ''
4021 * true -> '1'
4022 * false -> '0'
4023 * 0 -> '0'
4024 * 1 -> '1'
4025 *
4026 */
4027
4028 /**
4029 * Escapes a string for use within HTML.
4030 *
4031 */
4032 const escape_html = str => {
4033 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
4034 };
4035
4036 /**
4037 * Prevent default
4038 *
4039 */
4040 const preventDefault = (evt, stop = false) => {
4041 if (evt) {
4042 evt.preventDefault();
4043 if (stop) {
4044 evt.stopPropagation();
4045 }
4046 }
4047 };
4048
4049 /**
4050 * Add event helper
4051 *
4052 */
4053 const addEvent = (target, type, callback, options) => {
4054 target.addEventListener(type, callback, options);
4055 };
4056
4057 /**
4058 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
4059 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
4060 *
4061 * param query should be {}
4062 */
4063 const getDom = query => {
4064 if (query.jquery) {
4065 return query[0];
4066 }
4067 if (query instanceof HTMLElement) {
4068 return query;
4069 }
4070 if (isHtmlString(query)) {
4071 var tpl = document.createElement('template');
4072 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
4073 return tpl.content.firstChild;
4074 }
4075 return document.querySelector(query);
4076 };
4077 const isHtmlString = arg => {
4078 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
4079 return true;
4080 }
4081 return false;
4082 };
4083
4084 /**
4085 * Plugin: "remove_button" (Tom Select)
4086 * Copyright (c) contributors
4087 *
4088 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4089 * file except in compliance with the License. You may obtain a copy of the License at:
4090 * http://www.apache.org/licenses/LICENSE-2.0
4091 *
4092 * Unless required by applicable law or agreed to in writing, software distributed under
4093 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4094 * ANY KIND, either express or implied. See the License for the specific language
4095 * governing permissions and limitations under the License.
4096 *
4097 */
4098
4099 function plugin (userOptions) {
4100 const options = Object.assign({
4101 label: '&times;',
4102 title: 'Remove',
4103 className: 'remove',
4104 append: true
4105 }, userOptions);
4106
4107 //options.className = 'remove-single';
4108 var self = this;
4109
4110 // override the render method to add remove button to each item
4111 if (!options.append) {
4112 return;
4113 }
4114 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
4115 self.hook('after', 'setupTemplates', () => {
4116 var orig_render_item = self.settings.render.item;
4117 self.settings.render.item = (data, escape) => {
4118 var item = getDom(orig_render_item.call(self, data, escape));
4119 var close_button = getDom(html);
4120 item.appendChild(close_button);
4121 addEvent(close_button, 'mousedown', evt => {
4122 preventDefault(evt, true);
4123 });
4124 addEvent(close_button, 'click', evt => {
4125 if (self.isLocked) return;
4126
4127 // propagating will trigger the dropdown to show for single mode
4128 preventDefault(evt, true);
4129 if (self.isLocked) return;
4130 if (!self.shouldDelete([item], evt)) return;
4131 self.removeItem(item);
4132 self.refreshOptions(false);
4133 self.inputState();
4134 });
4135 return item;
4136 };
4137 });
4138 }
4139
4140
4141 //# sourceMappingURL=plugin.js.map
4142
4143
4144 /***/ },
4145
4146 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
4147 /*!*********************************************************************************!*\
4148 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
4149 \*********************************************************************************/
4150 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4151
4152 __webpack_require__.r(__webpack_exports__);
4153 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4154 /* harmony export */ "default": () => (/* binding */ plugin)
4155 /* harmony export */ });
4156 /**
4157 * Tom Select v2.4.3
4158 * Licensed under the Apache License, Version 2.0 (the "License");
4159 */
4160
4161 /**
4162 * Plugin: "restore_on_backspace" (Tom Select)
4163 * Copyright (c) contributors
4164 *
4165 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4166 * file except in compliance with the License. You may obtain a copy of the License at:
4167 * http://www.apache.org/licenses/LICENSE-2.0
4168 *
4169 * Unless required by applicable law or agreed to in writing, software distributed under
4170 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4171 * ANY KIND, either express or implied. See the License for the specific language
4172 * governing permissions and limitations under the License.
4173 *
4174 */
4175
4176 function plugin (userOptions) {
4177 const self = this;
4178 const options = Object.assign({
4179 text: option => {
4180 return option[self.settings.labelField];
4181 }
4182 }, userOptions);
4183 self.on('item_remove', function (value) {
4184 if (!self.isFocused) {
4185 return;
4186 }
4187 if (self.control_input.value.trim() === '') {
4188 var option = self.options[value];
4189 if (option) {
4190 self.setTextboxValue(options.text.call(self, option));
4191 }
4192 }
4193 });
4194 }
4195
4196
4197 //# sourceMappingURL=plugin.js.map
4198
4199
4200 /***/ },
4201
4202 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
4203 /*!***************************************************************************!*\
4204 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
4205 \***************************************************************************/
4206 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4207
4208 __webpack_require__.r(__webpack_exports__);
4209 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4210 /* harmony export */ "default": () => (/* binding */ plugin)
4211 /* harmony export */ });
4212 /**
4213 * Tom Select v2.4.3
4214 * Licensed under the Apache License, Version 2.0 (the "License");
4215 */
4216
4217 /**
4218 * Converts a scalar to its best string representation
4219 * for hash keys and HTML attribute values.
4220 *
4221 * Transformations:
4222 * 'str' -> 'str'
4223 * null -> ''
4224 * undefined -> ''
4225 * true -> '1'
4226 * false -> '0'
4227 * 0 -> '0'
4228 * 1 -> '1'
4229 *
4230 */
4231
4232 /**
4233 * Iterates over arrays and hashes.
4234 *
4235 * ```
4236 * iterate(this.items, function(item, id) {
4237 * // invoked for each item
4238 * });
4239 * ```
4240 *
4241 */
4242 const iterate = (object, callback) => {
4243 if (Array.isArray(object)) {
4244 object.forEach(callback);
4245 } else {
4246 for (var key in object) {
4247 if (object.hasOwnProperty(key)) {
4248 callback(object[key], key);
4249 }
4250 }
4251 }
4252 };
4253
4254 /**
4255 * Add css classes
4256 *
4257 */
4258 const addClasses = (elmts, ...classes) => {
4259 var norm_classes = classesArray(classes);
4260 elmts = castAsArray(elmts);
4261 elmts.map(el => {
4262 norm_classes.map(cls => {
4263 el.classList.add(cls);
4264 });
4265 });
4266 };
4267
4268 /**
4269 * Return arguments
4270 *
4271 */
4272 const classesArray = args => {
4273 var classes = [];
4274 iterate(args, _classes => {
4275 if (typeof _classes === 'string') {
4276 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
4277 }
4278 if (Array.isArray(_classes)) {
4279 classes = classes.concat(_classes);
4280 }
4281 });
4282 return classes.filter(Boolean);
4283 };
4284
4285 /**
4286 * Create an array from arg if it's not already an array
4287 *
4288 */
4289 const castAsArray = arg => {
4290 if (!Array.isArray(arg)) {
4291 arg = [arg];
4292 }
4293 return arg;
4294 };
4295
4296 /**
4297 * Plugin: "restore_on_backspace" (Tom Select)
4298 * Copyright (c) contributors
4299 *
4300 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4301 * file except in compliance with the License. You may obtain a copy of the License at:
4302 * http://www.apache.org/licenses/LICENSE-2.0
4303 *
4304 * Unless required by applicable law or agreed to in writing, software distributed under
4305 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4306 * ANY KIND, either express or implied. See the License for the specific language
4307 * governing permissions and limitations under the License.
4308 *
4309 */
4310
4311 function plugin () {
4312 const self = this;
4313 const orig_canLoad = self.canLoad;
4314 const orig_clearActiveOption = self.clearActiveOption;
4315 const orig_loadCallback = self.loadCallback;
4316 var pagination = {};
4317 var dropdown_content;
4318 var loading_more = false;
4319 var load_more_opt;
4320 var default_values = [];
4321 if (!self.settings.shouldLoadMore) {
4322 // return true if additional results should be loaded
4323 self.settings.shouldLoadMore = () => {
4324 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
4325 if (scroll_percent > 0.9) {
4326 return true;
4327 }
4328 if (self.activeOption) {
4329 var selectable = self.selectable();
4330 var index = Array.from(selectable).indexOf(self.activeOption);
4331 if (index >= selectable.length - 2) {
4332 return true;
4333 }
4334 }
4335 return false;
4336 };
4337 }
4338 if (!self.settings.firstUrl) {
4339 throw 'virtual_scroll plugin requires a firstUrl() method';
4340 }
4341
4342 // in order for virtual scrolling to work,
4343 // options need to be ordered the same way they're returned from the remote data source
4344 self.settings.sortField = [{
4345 field: '$order'
4346 }, {
4347 field: '$score'
4348 }];
4349
4350 // can we load more results for given query?
4351 const canLoadMore = query => {
4352 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
4353 return false;
4354 }
4355 if (query in pagination && pagination[query]) {
4356 return true;
4357 }
4358 return false;
4359 };
4360 const clearFilter = (option, value) => {
4361 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
4362 return true;
4363 }
4364 return false;
4365 };
4366
4367 // set the next url that will be
4368 self.setNextUrl = (value, next_url) => {
4369 pagination[value] = next_url;
4370 };
4371
4372 // getUrl() to be used in settings.load()
4373 self.getUrl = query => {
4374 if (query in pagination) {
4375 const next_url = pagination[query];
4376 pagination[query] = false;
4377 return next_url;
4378 }
4379
4380 // if the user goes back to a previous query
4381 // we need to load the first page again
4382 self.clearPagination();
4383 return self.settings.firstUrl.call(self, query);
4384 };
4385
4386 // clear pagination
4387 self.clearPagination = () => {
4388 pagination = {};
4389 };
4390
4391 // don't clear the active option (and cause unwanted dropdown scroll)
4392 // while loading more results
4393 self.hook('instead', 'clearActiveOption', () => {
4394 if (loading_more) {
4395 return;
4396 }
4397 return orig_clearActiveOption.call(self);
4398 });
4399
4400 // override the canLoad method
4401 self.hook('instead', 'canLoad', query => {
4402 // first time the query has been seen
4403 if (!(query in pagination)) {
4404 return orig_canLoad.call(self, query);
4405 }
4406 return canLoadMore(query);
4407 });
4408
4409 // wrap the load
4410 self.hook('instead', 'loadCallback', (options, optgroups) => {
4411 if (!loading_more) {
4412 self.clearOptions(clearFilter);
4413 } else if (load_more_opt) {
4414 const first_option = options[0];
4415 if (first_option !== undefined) {
4416 load_more_opt.dataset.value = first_option[self.settings.valueField];
4417 }
4418 }
4419 orig_loadCallback.call(self, options, optgroups);
4420 loading_more = false;
4421 });
4422
4423 // add templates to dropdown
4424 // loading_more if we have another url in the queue
4425 // no_more_results if we don't have another url in the queue
4426 self.hook('after', 'refreshOptions', () => {
4427 const query = self.lastValue;
4428 var option;
4429 if (canLoadMore(query)) {
4430 option = self.render('loading_more', {
4431 query: query
4432 });
4433 if (option) {
4434 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
4435 load_more_opt = option;
4436 }
4437 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
4438 option = self.render('no_more_results', {
4439 query: query
4440 });
4441 }
4442 if (option) {
4443 addClasses(option, self.settings.optionClass);
4444 dropdown_content.append(option);
4445 }
4446 });
4447
4448 // add scroll listener and default templates
4449 self.on('initialize', () => {
4450 default_values = Object.keys(self.options);
4451 dropdown_content = self.dropdown_content;
4452
4453 // default templates
4454 self.settings.render = Object.assign({}, {
4455 loading_more: () => {
4456 return `<div class="loading-more-results">Loading more results ... </div>`;
4457 },
4458 no_more_results: () => {
4459 return `<div class="no-more-results">No more results</div>`;
4460 }
4461 }, self.settings.render);
4462
4463 // watch dropdown content scroll position
4464 dropdown_content.addEventListener('scroll', () => {
4465 if (!self.settings.shouldLoadMore.call(self)) {
4466 return;
4467 }
4468
4469 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
4470 if (!canLoadMore(self.lastValue)) {
4471 return;
4472 }
4473
4474 // don't call load() too much
4475 if (loading_more) return;
4476 loading_more = true;
4477 self.load.call(self, self.lastValue);
4478 });
4479 });
4480 }
4481
4482
4483 //# sourceMappingURL=plugin.js.map
4484
4485
4486 /***/ },
4487
4488 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
4489 /*!*****************************************************************!*\
4490 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
4491 \*****************************************************************/
4492 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4493
4494 __webpack_require__.r(__webpack_exports__);
4495 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4496 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
4497 /* harmony export */ });
4498 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
4499 /* 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");
4500 /* 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");
4501 /* 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");
4502 /* 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");
4503 /* 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");
4504 /* 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");
4505 /* 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");
4506 /* 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");
4507 /* 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");
4508 /* 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");
4509 /* 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");
4510 /* 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");
4511 /* 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");
4512 /* 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");
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
4529 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
4530 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
4531 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
4532 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
4533 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
4534 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
4535 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
4536 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
4537 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
4538 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
4539 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
4540 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
4541 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
4542 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
4543 //# sourceMappingURL=tom-select.complete.js.map
4544
4545 /***/ },
4546
4547 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
4548 /*!********************************************************!*\
4549 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
4550 \********************************************************/
4551 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4552
4553 __webpack_require__.r(__webpack_exports__);
4554 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4555 /* harmony export */ "default": () => (/* binding */ TomSelect)
4556 /* harmony export */ });
4557 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
4558 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
4559 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
4560 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
4561 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
4562 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
4563 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
4564 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
4565 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575 var instance_i = 0;
4576 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
4577 constructor(input_arg, user_settings) {
4578 super();
4579 this.order = 0;
4580 this.isOpen = false;
4581 this.isDisabled = false;
4582 this.isReadOnly = false;
4583 this.isInvalid = false; // @deprecated 1.8
4584 this.isValid = true;
4585 this.isLocked = false;
4586 this.isFocused = false;
4587 this.isInputHidden = false;
4588 this.isSetup = false;
4589 this.ignoreFocus = false;
4590 this.ignoreHover = false;
4591 this.hasOptions = false;
4592 this.lastValue = '';
4593 this.caretPos = 0;
4594 this.loading = 0;
4595 this.loadedSearches = {};
4596 this.activeOption = null;
4597 this.activeItems = [];
4598 this.optgroups = {};
4599 this.options = {};
4600 this.userOptions = {};
4601 this.items = [];
4602 this.refreshTimeout = null;
4603 instance_i++;
4604 var dir;
4605 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
4606 if (input.tomselect) {
4607 throw new Error('Tom Select already initialized on this element');
4608 }
4609 input.tomselect = this;
4610 // detect rtl environment
4611 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
4612 dir = computedStyle.getPropertyValue('direction');
4613 // setup default state
4614 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
4615 this.settings = settings;
4616 this.input = input;
4617 this.tabIndex = input.tabIndex || 0;
4618 this.is_select_tag = input.tagName.toLowerCase() === 'select';
4619 this.rtl = /rtl/i.test(dir);
4620 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
4621 this.isRequired = input.required;
4622 // search system
4623 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
4624 // option-dependent defaults
4625 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
4626 if (typeof settings.hideSelected !== 'boolean') {
4627 settings.hideSelected = settings.mode === 'multi';
4628 }
4629 if (typeof settings.hidePlaceholder !== 'boolean') {
4630 settings.hidePlaceholder = settings.mode !== 'multi';
4631 }
4632 // set up createFilter callback
4633 var filter = settings.createFilter;
4634 if (typeof filter !== 'function') {
4635 if (typeof filter === 'string') {
4636 filter = new RegExp(filter);
4637 }
4638 if (filter instanceof RegExp) {
4639 settings.createFilter = (input) => filter.test(input);
4640 }
4641 else {
4642 settings.createFilter = (value) => {
4643 return this.settings.duplicates || !this.options[value];
4644 };
4645 }
4646 }
4647 this.initializePlugins(settings.plugins);
4648 this.setupCallbacks();
4649 this.setupTemplates();
4650 // Create all elements
4651 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
4652 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
4653 const dropdown = this._render('dropdown');
4654 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
4655 const classes = this.input.getAttribute('class') || '';
4656 const inputMode = settings.mode;
4657 var control_input;
4658 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
4659 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
4660 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
4661 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
4662 if (settings.copyClassesToDropdown) {
4663 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
4664 }
4665 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
4666 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
4667 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
4668 // default controlInput
4669 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
4670 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
4671 // set attributes
4672 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
4673 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
4674 if (input.getAttribute(attr)) {
4675 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
4676 }
4677 });
4678 control_input.tabIndex = -1;
4679 control.appendChild(control_input);
4680 this.focus_node = control_input;
4681 // dom element
4682 }
4683 else if (settings.controlInput) {
4684 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
4685 this.focus_node = control_input;
4686 }
4687 else {
4688 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
4689 this.focus_node = control;
4690 }
4691 this.wrapper = wrapper;
4692 this.dropdown = dropdown;
4693 this.dropdown_content = dropdown_content;
4694 this.control = control;
4695 this.control_input = control_input;
4696 this.setup();
4697 }
4698 /**
4699 * set up event bindings.
4700 *
4701 */
4702 setup() {
4703 const self = this;
4704 const settings = self.settings;
4705 const control_input = self.control_input;
4706 const dropdown = self.dropdown;
4707 const dropdown_content = self.dropdown_content;
4708 const wrapper = self.wrapper;
4709 const control = self.control;
4710 const input = self.input;
4711 const focus_node = self.focus_node;
4712 const passive_event = { passive: true };
4713 const listboxId = self.inputId + '-ts-dropdown';
4714 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
4715 id: listboxId
4716 });
4717 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
4718 role: 'combobox',
4719 'aria-haspopup': 'listbox',
4720 'aria-expanded': 'false',
4721 'aria-controls': listboxId
4722 });
4723 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
4724 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
4725 const label = document.querySelector(query);
4726 const label_click = self.focus.bind(self);
4727 if (label) {
4728 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
4729 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
4730 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
4731 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
4732 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
4733 }
4734 wrapper.style.width = input.style.width;
4735 if (self.plugins.names.length) {
4736 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
4737 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
4738 }
4739 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
4740 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
4741 }
4742 if (settings.placeholder) {
4743 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
4744 }
4745 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
4746 if (!settings.splitOn && settings.delimiter) {
4747 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
4748 }
4749 // debounce user defined load() if loadThrottle > 0
4750 // after initializePlugins() so plugins can create/modify user defined loaders
4751 if (settings.load && settings.loadThrottle) {
4752 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
4753 }
4754 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
4755 self.ignoreHover = false;
4756 });
4757 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
4758 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
4759 if (target_match)
4760 self.onOptionHover(e, target_match);
4761 }, { capture: true });
4762 // clicking on an option should select it
4763 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
4764 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
4765 if (option) {
4766 self.onOptionSelect(evt, option);
4767 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4768 }
4769 });
4770 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
4771 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
4772 if (target_match && self.onItemSelect(evt, target_match)) {
4773 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4774 return;
4775 }
4776 // retain focus (see control_input mousedown)
4777 if (control_input.value != '') {
4778 return;
4779 }
4780 self.onClick();
4781 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4782 });
4783 // keydown on focus_node for arrow_down/arrow_up
4784 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
4785 // keypress and input/keyup
4786 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
4787 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
4788 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
4789 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
4790 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
4791 const doc_mousedown = (evt) => {
4792 // blur if target is outside of this instance
4793 // dropdown is not always inside wrapper
4794 const target = evt.composedPath()[0];
4795 if (!wrapper.contains(target) && !dropdown.contains(target)) {
4796 if (self.isFocused) {
4797 self.blur();
4798 }
4799 self.inputState();
4800 return;
4801 }
4802 // retain focus by preventing native handling. if the
4803 // event target is the input it should not be modified.
4804 // otherwise, text selection within the input won't work.
4805 // Fixes bug #212 which is no covered by tests
4806 if (target == control_input && self.isOpen) {
4807 evt.stopPropagation();
4808 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
4809 }
4810 else {
4811 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4812 }
4813 };
4814 const win_scroll = () => {
4815 if (self.isOpen) {
4816 self.positionDropdown();
4817 }
4818 };
4819 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
4820 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
4821 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
4822 this._destroy = () => {
4823 document.removeEventListener('mousedown', doc_mousedown);
4824 window.removeEventListener('scroll', win_scroll);
4825 window.removeEventListener('resize', win_scroll);
4826 if (label)
4827 label.removeEventListener('click', label_click);
4828 };
4829 // store original html and tab index so that they can be
4830 // restored when the destroy() method is called.
4831 this.revertSettings = {
4832 innerHTML: input.innerHTML,
4833 tabIndex: input.tabIndex
4834 };
4835 input.tabIndex = -1;
4836 input.insertAdjacentElement('afterend', self.wrapper);
4837 self.sync(false);
4838 settings.items = [];
4839 delete settings.optgroups;
4840 delete settings.options;
4841 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
4842 if (self.isValid) {
4843 self.isValid = false;
4844 self.isInvalid = true;
4845 self.refreshState();
4846 }
4847 });
4848 self.updateOriginalInput();
4849 self.refreshItems();
4850 self.close(false);
4851 self.inputState();
4852 self.isSetup = true;
4853 if (input.disabled) {
4854 self.disable();
4855 }
4856 else if (input.readOnly) {
4857 self.setReadOnly(true);
4858 }
4859 else {
4860 self.enable(); //sets tabIndex
4861 }
4862 self.on('change', this.onChange);
4863 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
4864 self.trigger('initialize');
4865 // preload options
4866 if (settings.preload === true) {
4867 self.preload();
4868 }
4869 }
4870 /**
4871 * Register options and optgroups
4872 *
4873 */
4874 setupOptions(options = [], optgroups = []) {
4875 // build options table
4876 this.addOptions(options);
4877 // build optgroup table
4878 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
4879 this.registerOptionGroup(optgroup);
4880 });
4881 }
4882 /**
4883 * Sets up default rendering functions.
4884 */
4885 setupTemplates() {
4886 var self = this;
4887 var field_label = self.settings.labelField;
4888 var field_optgroup = self.settings.optgroupLabelField;
4889 var templates = {
4890 'optgroup': (data) => {
4891 let optgroup = document.createElement('div');
4892 optgroup.className = 'optgroup';
4893 optgroup.appendChild(data.options);
4894 return optgroup;
4895 },
4896 'optgroup_header': (data, escape) => {
4897 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
4898 },
4899 'option': (data, escape) => {
4900 return '<div>' + escape(data[field_label]) + '</div>';
4901 },
4902 'item': (data, escape) => {
4903 return '<div>' + escape(data[field_label]) + '</div>';
4904 },
4905 'option_create': (data, escape) => {
4906 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
4907 },
4908 'no_results': () => {
4909 return '<div class="no-results">No results found</div>';
4910 },
4911 'loading': () => {
4912 return '<div class="spinner"></div>';
4913 },
4914 'not_loading': () => { },
4915 'dropdown': () => {
4916 return '<div></div>';
4917 }
4918 };
4919 self.settings.render = Object.assign({}, templates, self.settings.render);
4920 }
4921 /**
4922 * Maps fired events to callbacks provided
4923 * in the settings used when creating the control.
4924 */
4925 setupCallbacks() {
4926 var key, fn;
4927 var callbacks = {
4928 'initialize': 'onInitialize',
4929 'change': 'onChange',
4930 'item_add': 'onItemAdd',
4931 'item_remove': 'onItemRemove',
4932 'item_select': 'onItemSelect',
4933 'clear': 'onClear',
4934 'option_add': 'onOptionAdd',
4935 'option_remove': 'onOptionRemove',
4936 'option_clear': 'onOptionClear',
4937 'optgroup_add': 'onOptionGroupAdd',
4938 'optgroup_remove': 'onOptionGroupRemove',
4939 'optgroup_clear': 'onOptionGroupClear',
4940 'dropdown_open': 'onDropdownOpen',
4941 'dropdown_close': 'onDropdownClose',
4942 'type': 'onType',
4943 'load': 'onLoad',
4944 'focus': 'onFocus',
4945 'blur': 'onBlur'
4946 };
4947 for (key in callbacks) {
4948 fn = this.settings[callbacks[key]];
4949 if (fn)
4950 this.on(key, fn);
4951 }
4952 }
4953 /**
4954 * Sync the Tom Select instance with the original input or select
4955 *
4956 */
4957 sync(get_settings = true) {
4958 const self = this;
4959 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
4960 self.setupOptions(settings.options, settings.optgroups);
4961 self.setValue(settings.items || [], true); // silent prevents recursion
4962 self.lastQuery = null; // so updated options will be displayed in dropdown
4963 }
4964 /**
4965 * Triggered when the main control element
4966 * has a click event.
4967 *
4968 */
4969 onClick() {
4970 var self = this;
4971 if (self.activeItems.length > 0) {
4972 self.clearActiveItems();
4973 self.focus();
4974 return;
4975 }
4976 if (self.isFocused && self.isOpen) {
4977 self.blur();
4978 }
4979 else {
4980 self.focus();
4981 }
4982 }
4983 /**
4984 * @deprecated v1.7
4985 *
4986 */
4987 onMouseDown() { }
4988 /**
4989 * Triggered when the value of the control has been changed.
4990 * This should propagate the event to the original DOM
4991 * input / select element.
4992 */
4993 onChange() {
4994 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
4995 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
4996 }
4997 /**
4998 * Triggered on <input> paste.
4999 *
5000 */
5001 onPaste(e) {
5002 var self = this;
5003 if (self.isInputHidden || self.isLocked) {
5004 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5005 return;
5006 }
5007 // If a regex or string is included, this will split the pasted
5008 // input and create Items for each separate value
5009 if (!self.settings.splitOn) {
5010 return;
5011 }
5012 // Wait for pasted text to be recognized in value
5013 setTimeout(() => {
5014 var pastedText = self.inputValue();
5015 if (!pastedText.match(self.settings.splitOn)) {
5016 return;
5017 }
5018 var splitInput = pastedText.trim().split(self.settings.splitOn);
5019 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
5020 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
5021 if (hash) {
5022 if (this.options[piece]) {
5023 self.addItem(piece);
5024 }
5025 else {
5026 self.createItem(piece);
5027 }
5028 }
5029 });
5030 }, 0);
5031 }
5032 /**
5033 * Triggered on <input> keypress.
5034 *
5035 */
5036 onKeyPress(e) {
5037 var self = this;
5038 if (self.isLocked) {
5039 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5040 return;
5041 }
5042 var character = String.fromCharCode(e.keyCode || e.which);
5043 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
5044 self.createItem();
5045 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5046 return;
5047 }
5048 }
5049 /**
5050 * Triggered on <input> keydown.
5051 *
5052 */
5053 onKeyDown(e) {
5054 var self = this;
5055 self.ignoreHover = true;
5056 if (self.isLocked) {
5057 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
5058 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5059 }
5060 return;
5061 }
5062 switch (e.keyCode) {
5063 // ctrl+A: select all
5064 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
5065 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
5066 if (self.control_input.value == '') {
5067 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5068 self.selectAll();
5069 return;
5070 }
5071 }
5072 break;
5073 // esc: close dropdown
5074 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
5075 if (self.isOpen) {
5076 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
5077 self.close();
5078 }
5079 self.clearActiveItems();
5080 return;
5081 // down: open dropdown or move selection down
5082 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
5083 if (!self.isOpen && self.hasOptions) {
5084 self.open();
5085 }
5086 else if (self.activeOption) {
5087 let next = self.getAdjacent(self.activeOption, 1);
5088 if (next)
5089 self.setActiveOption(next);
5090 }
5091 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5092 return;
5093 // up: move selection up
5094 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
5095 if (self.activeOption) {
5096 let prev = self.getAdjacent(self.activeOption, -1);
5097 if (prev)
5098 self.setActiveOption(prev);
5099 }
5100 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5101 return;
5102 // return: select active option
5103 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
5104 if (self.canSelect(self.activeOption)) {
5105 self.onOptionSelect(e, self.activeOption);
5106 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5107 // if the option_create=null, the dropdown might be closed
5108 }
5109 else if (self.settings.create && self.createItem()) {
5110 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5111 // don't submit form when searching for a value
5112 }
5113 else if (document.activeElement == self.control_input && self.isOpen) {
5114 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5115 }
5116 return;
5117 // left: modifiy item selection to the left
5118 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
5119 self.advanceSelection(-1, e);
5120 return;
5121 // right: modifiy item selection to the right
5122 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
5123 self.advanceSelection(1, e);
5124 return;
5125 // tab: select active option and/or create item
5126 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
5127 if (self.settings.selectOnTab) {
5128 if (self.canSelect(self.activeOption)) {
5129 self.onOptionSelect(e, self.activeOption);
5130 // prevent default [tab] behaviour of jump to the next field
5131 // if select isFull, then the dropdown won't be open and [tab] will work normally
5132 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5133 }
5134 if (self.settings.create && self.createItem()) {
5135 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5136 }
5137 }
5138 return;
5139 // delete|backspace: delete items
5140 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
5141 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
5142 self.deleteSelection(e);
5143 return;
5144 }
5145 // don't enter text in the control_input when active items are selected
5146 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
5147 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5148 }
5149 }
5150 /**
5151 * Triggered on <input> keyup.
5152 *
5153 */
5154 onInput(e) {
5155 if (this.isLocked) {
5156 return;
5157 }
5158 const value = this.inputValue();
5159 if (this.lastValue === value)
5160 return;
5161 this.lastValue = value;
5162 if (value == '') {
5163 this._onInput();
5164 return;
5165 }
5166 if (this.refreshTimeout) {
5167 window.clearTimeout(this.refreshTimeout);
5168 }
5169 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
5170 this.refreshTimeout = null;
5171 this._onInput();
5172 }, this.settings.refreshThrottle);
5173 }
5174 _onInput() {
5175 const value = this.lastValue;
5176 if (this.settings.shouldLoad.call(this, value)) {
5177 this.load(value);
5178 }
5179 this.refreshOptions();
5180 this.trigger('type', value);
5181 }
5182 /**
5183 * Triggered when the user rolls over
5184 * an option in the autocomplete dropdown menu.
5185 *
5186 */
5187 onOptionHover(evt, option) {
5188 if (this.ignoreHover)
5189 return;
5190 this.setActiveOption(option, false);
5191 }
5192 /**
5193 * Triggered on <input> focus.
5194 *
5195 */
5196 onFocus(e) {
5197 var self = this;
5198 var wasFocused = self.isFocused;
5199 if (self.isDisabled || self.isReadOnly) {
5200 self.blur();
5201 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5202 return;
5203 }
5204 if (self.ignoreFocus)
5205 return;
5206 self.isFocused = true;
5207 if (self.settings.preload === 'focus')
5208 self.preload();
5209 if (!wasFocused)
5210 self.trigger('focus');
5211 if (!self.activeItems.length) {
5212 self.inputState();
5213 self.refreshOptions(!!self.settings.openOnFocus);
5214 }
5215 self.refreshState();
5216 }
5217 /**
5218 * Triggered on <input> blur.
5219 *
5220 */
5221 onBlur(e) {
5222 if (document.hasFocus() === false)
5223 return;
5224 var self = this;
5225 if (!self.isFocused)
5226 return;
5227 self.isFocused = false;
5228 self.ignoreFocus = false;
5229 var deactivate = () => {
5230 self.close();
5231 self.setActiveItem();
5232 self.setCaret(self.items.length);
5233 self.trigger('blur');
5234 };
5235 if (self.settings.create && self.settings.createOnBlur) {
5236 self.createItem(null, deactivate);
5237 }
5238 else {
5239 deactivate();
5240 }
5241 }
5242 /**
5243 * Triggered when the user clicks on an option
5244 * in the autocomplete dropdown menu.
5245 *
5246 */
5247 onOptionSelect(evt, option) {
5248 var value, self = this;
5249 // should not be possible to trigger a option under a disabled optgroup
5250 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
5251 return;
5252 }
5253 if (option.classList.contains('create')) {
5254 self.createItem(null, () => {
5255 if (self.settings.closeAfterSelect) {
5256 self.close();
5257 }
5258 });
5259 }
5260 else {
5261 value = option.dataset.value;
5262 if (typeof value !== 'undefined') {
5263 self.lastQuery = null;
5264 self.addItem(value);
5265 if (self.settings.closeAfterSelect) {
5266 self.close();
5267 }
5268 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
5269 self.setActiveOption(option);
5270 }
5271 }
5272 }
5273 }
5274 /**
5275 * Return true if the given option can be selected
5276 *
5277 */
5278 canSelect(option) {
5279 if (this.isOpen && option && this.dropdown_content.contains(option)) {
5280 return true;
5281 }
5282 return false;
5283 }
5284 /**
5285 * Triggered when the user clicks on an item
5286 * that has been selected.
5287 *
5288 */
5289 onItemSelect(evt, item) {
5290 var self = this;
5291 if (!self.isLocked && self.settings.mode === 'multi') {
5292 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
5293 self.setActiveItem(item, evt);
5294 return true;
5295 }
5296 return false;
5297 }
5298 /**
5299 * Determines whether or not to invoke
5300 * the user-provided option provider / loader
5301 *
5302 * Note, there is a subtle difference between
5303 * this.canLoad() and this.settings.shouldLoad();
5304 *
5305 * - settings.shouldLoad() is a user-input validator.
5306 * When false is returned, the not_loading template
5307 * will be added to the dropdown
5308 *
5309 * - canLoad() is lower level validator that checks
5310 * the Tom Select instance. There is no inherent user
5311 * feedback when canLoad returns false
5312 *
5313 */
5314 canLoad(value) {
5315 if (!this.settings.load)
5316 return false;
5317 if (this.loadedSearches.hasOwnProperty(value))
5318 return false;
5319 return true;
5320 }
5321 /**
5322 * Invokes the user-provided option provider / loader.
5323 *
5324 */
5325 load(value) {
5326 const self = this;
5327 if (!self.canLoad(value))
5328 return;
5329 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
5330 self.loading++;
5331 const callback = self.loadCallback.bind(self);
5332 self.settings.load.call(self, value, callback);
5333 }
5334 /**
5335 * Invoked by the user-provided option provider
5336 *
5337 */
5338 loadCallback(options, optgroups) {
5339 const self = this;
5340 self.loading = Math.max(self.loading - 1, 0);
5341 self.lastQuery = null;
5342 self.clearActiveOption(); // when new results load, focus should be on first option
5343 self.setupOptions(options, optgroups);
5344 self.refreshOptions(self.isFocused && !self.isInputHidden);
5345 if (!self.loading) {
5346 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
5347 }
5348 self.trigger('load', options, optgroups);
5349 }
5350 preload() {
5351 var classList = this.wrapper.classList;
5352 if (classList.contains('preloaded'))
5353 return;
5354 classList.add('preloaded');
5355 this.load('');
5356 }
5357 /**
5358 * Sets the input field of the control to the specified value.
5359 *
5360 */
5361 setTextboxValue(value = '') {
5362 var input = this.control_input;
5363 var changed = input.value !== value;
5364 if (changed) {
5365 input.value = value;
5366 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
5367 this.lastValue = value;
5368 }
5369 }
5370 /**
5371 * Returns the value of the control. If multiple items
5372 * can be selected (e.g. <select multiple>), this returns
5373 * an array. If only one item can be selected, this
5374 * returns a string.
5375 *
5376 */
5377 getValue() {
5378 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
5379 return this.items;
5380 }
5381 return this.items.join(this.settings.delimiter);
5382 }
5383 /**
5384 * Resets the selected items to the given value.
5385 *
5386 */
5387 setValue(value, silent) {
5388 var events = silent ? [] : ['change'];
5389 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
5390 this.clear(silent);
5391 this.addItems(value, silent);
5392 });
5393 }
5394 /**
5395 * Resets the number of max items to the given value
5396 *
5397 */
5398 setMaxItems(value) {
5399 if (value === 0)
5400 value = null; //reset to unlimited items.
5401 this.settings.maxItems = value;
5402 this.refreshState();
5403 }
5404 /**
5405 * Sets the selected item.
5406 *
5407 */
5408 setActiveItem(item, e) {
5409 var self = this;
5410 var eventName;
5411 var i, begin, end, swap;
5412 var last;
5413 if (self.settings.mode === 'single')
5414 return;
5415 // clear the active selection
5416 if (!item) {
5417 self.clearActiveItems();
5418 if (self.isFocused) {
5419 self.inputState();
5420 }
5421 return;
5422 }
5423 // modify selection
5424 eventName = e && e.type.toLowerCase();
5425 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
5426 last = self.getLastActive();
5427 begin = Array.prototype.indexOf.call(self.control.children, last);
5428 end = Array.prototype.indexOf.call(self.control.children, item);
5429 if (begin > end) {
5430 swap = begin;
5431 begin = end;
5432 end = swap;
5433 }
5434 for (i = begin; i <= end; i++) {
5435 item = self.control.children[i];
5436 if (self.activeItems.indexOf(item) === -1) {
5437 self.setActiveItemClass(item);
5438 }
5439 }
5440 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5441 }
5442 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))) {
5443 if (item.classList.contains('active')) {
5444 self.removeActiveItem(item);
5445 }
5446 else {
5447 self.setActiveItemClass(item);
5448 }
5449 }
5450 else {
5451 self.clearActiveItems();
5452 self.setActiveItemClass(item);
5453 }
5454 // ensure control has focus
5455 self.inputState();
5456 if (!self.isFocused) {
5457 self.focus();
5458 }
5459 }
5460 /**
5461 * Set the active and last-active classes
5462 *
5463 */
5464 setActiveItemClass(item) {
5465 const self = this;
5466 const last_active = self.control.querySelector('.last-active');
5467 if (last_active)
5468 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
5469 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
5470 self.trigger('item_select', item);
5471 if (self.activeItems.indexOf(item) == -1) {
5472 self.activeItems.push(item);
5473 }
5474 }
5475 /**
5476 * Remove active item
5477 *
5478 */
5479 removeActiveItem(item) {
5480 var idx = this.activeItems.indexOf(item);
5481 this.activeItems.splice(idx, 1);
5482 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
5483 }
5484 /**
5485 * Clears all the active items
5486 *
5487 */
5488 clearActiveItems() {
5489 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
5490 this.activeItems = [];
5491 }
5492 /**
5493 * Sets the selected item in the dropdown menu
5494 * of available options.
5495 *
5496 */
5497 setActiveOption(option, scroll = true) {
5498 if (option === this.activeOption) {
5499 return;
5500 }
5501 this.clearActiveOption();
5502 if (!option)
5503 return;
5504 this.activeOption = option;
5505 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
5506 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
5507 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
5508 if (scroll)
5509 this.scrollToOption(option);
5510 }
5511 /**
5512 * Sets the dropdown_content scrollTop to display the option
5513 *
5514 */
5515 scrollToOption(option, behavior) {
5516 if (!option)
5517 return;
5518 const content = this.dropdown_content;
5519 const height_menu = content.clientHeight;
5520 const scrollTop = content.scrollTop || 0;
5521 const height_item = option.offsetHeight;
5522 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
5523 if (y + height_item > height_menu + scrollTop) {
5524 this.scroll(y - height_menu + height_item, behavior);
5525 }
5526 else if (y < scrollTop) {
5527 this.scroll(y, behavior);
5528 }
5529 }
5530 /**
5531 * Scroll the dropdown to the given position
5532 *
5533 */
5534 scroll(scrollTop, behavior) {
5535 const content = this.dropdown_content;
5536 if (behavior) {
5537 content.style.scrollBehavior = behavior;
5538 }
5539 content.scrollTop = scrollTop;
5540 content.style.scrollBehavior = '';
5541 }
5542 /**
5543 * Clears the active option
5544 *
5545 */
5546 clearActiveOption() {
5547 if (this.activeOption) {
5548 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
5549 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
5550 }
5551 this.activeOption = null;
5552 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
5553 }
5554 /**
5555 * Selects all items (CTRL + A).
5556 */
5557 selectAll() {
5558 const self = this;
5559 if (self.settings.mode === 'single')
5560 return;
5561 const activeItems = self.controlChildren();
5562 if (!activeItems.length)
5563 return;
5564 self.inputState();
5565 self.close();
5566 self.activeItems = activeItems;
5567 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
5568 self.setActiveItemClass(item);
5569 });
5570 }
5571 /**
5572 * Determines if the control_input should be in a hidden or visible state
5573 *
5574 */
5575 inputState() {
5576 var self = this;
5577 if (!self.control.contains(self.control_input))
5578 return;
5579 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
5580 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
5581 self.setTextboxValue();
5582 self.isInputHidden = true;
5583 }
5584 else {
5585 if (self.settings.hidePlaceholder && self.items.length > 0) {
5586 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
5587 }
5588 self.isInputHidden = false;
5589 }
5590 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
5591 }
5592 /**
5593 * Get the input value
5594 */
5595 inputValue() {
5596 return this.control_input.value.trim();
5597 }
5598 /**
5599 * Gives the control focus.
5600 */
5601 focus() {
5602 var self = this;
5603 if (self.isDisabled || self.isReadOnly)
5604 return;
5605 self.ignoreFocus = true;
5606 if (self.control_input.offsetWidth) {
5607 self.control_input.focus();
5608 }
5609 else {
5610 self.focus_node.focus();
5611 }
5612 setTimeout(() => {
5613 self.ignoreFocus = false;
5614 self.onFocus();
5615 }, 0);
5616 }
5617 /**
5618 * Forces the control out of focus.
5619 *
5620 */
5621 blur() {
5622 this.focus_node.blur();
5623 this.onBlur();
5624 }
5625 /**
5626 * Returns a function that scores an object
5627 * to show how good of a match it is to the
5628 * provided query.
5629 *
5630 * @return {function}
5631 */
5632 getScoreFunction(query) {
5633 return this.sifter.getScoreFunction(query, this.getSearchOptions());
5634 }
5635 /**
5636 * Returns search options for sifter (the system
5637 * for scoring and sorting results).
5638 *
5639 * @see https://github.com/orchidjs/sifter.js
5640 * @return {object}
5641 */
5642 getSearchOptions() {
5643 var settings = this.settings;
5644 var sort = settings.sortField;
5645 if (typeof settings.sortField === 'string') {
5646 sort = [{ field: settings.sortField }];
5647 }
5648 return {
5649 fields: settings.searchField,
5650 conjunction: settings.searchConjunction,
5651 sort: sort,
5652 nesting: settings.nesting
5653 };
5654 }
5655 /**
5656 * Searches through available options and returns
5657 * a sorted array of matches.
5658 *
5659 */
5660 search(query) {
5661 var result, calculateScore;
5662 var self = this;
5663 var options = this.getSearchOptions();
5664 // validate user-provided result scoring function
5665 if (self.settings.score) {
5666 calculateScore = self.settings.score.call(self, query);
5667 if (typeof calculateScore !== 'function') {
5668 throw new Error('Tom Select "score" setting must be a function that returns a function');
5669 }
5670 }
5671 // perform search
5672 if (query !== self.lastQuery) {
5673 self.lastQuery = query;
5674 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
5675 self.currentResults = result;
5676 }
5677 else {
5678 result = Object.assign({}, self.currentResults);
5679 }
5680 // filter out selected items
5681 if (self.settings.hideSelected) {
5682 result.items = result.items.filter((item) => {
5683 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
5684 return !(hashed && self.items.indexOf(hashed) !== -1);
5685 });
5686 }
5687 return result;
5688 }
5689 /**
5690 * Refreshes the list of available options shown
5691 * in the autocomplete dropdown menu.
5692 *
5693 */
5694 refreshOptions(triggerDropdown = true) {
5695 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
5696 var create;
5697 const groups = {};
5698 const groups_order = [];
5699 var self = this;
5700 var query = self.inputValue();
5701 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
5702 var results = self.search(query);
5703 var active_option = null;
5704 var show_dropdown = self.settings.shouldOpen || false;
5705 var dropdown_content = self.dropdown_content;
5706 if (same_query) {
5707 active_option = self.activeOption;
5708 if (active_option) {
5709 active_group = active_option.closest('[data-group]');
5710 }
5711 }
5712 // build markup
5713 n = results.items.length;
5714 if (typeof self.settings.maxOptions === 'number') {
5715 n = Math.min(n, self.settings.maxOptions);
5716 }
5717 if (n > 0) {
5718 show_dropdown = true;
5719 }
5720 // get fragment for group and the position of the group in group_order
5721 const getGroupFragment = (optgroup, order) => {
5722 let group_order_i = groups[optgroup];
5723 if (group_order_i !== undefined) {
5724 let order_group = groups_order[group_order_i];
5725 if (order_group !== undefined) {
5726 return [group_order_i, order_group.fragment];
5727 }
5728 }
5729 let group_fragment = document.createDocumentFragment();
5730 group_order_i = groups_order.length;
5731 groups_order.push({ fragment: group_fragment, order, optgroup });
5732 return [group_order_i, group_fragment];
5733 };
5734 // render and group available options individually
5735 for (i = 0; i < n; i++) {
5736 // get option dom element
5737 let item = results.items[i];
5738 if (!item)
5739 continue;
5740 let opt_value = item.id;
5741 let option = self.options[opt_value];
5742 if (option === undefined)
5743 continue;
5744 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
5745 let option_el = self.getOption(opt_hash, true);
5746 // toggle 'selected' class
5747 if (!self.settings.hideSelected) {
5748 option_el.classList.toggle('selected', self.items.includes(opt_hash));
5749 }
5750 optgroup = option[self.settings.optgroupField] || '';
5751 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
5752 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
5753 optgroup = optgroups[j];
5754 let order = option.$order;
5755 let self_optgroup = self.optgroups[optgroup];
5756 if (self_optgroup === undefined) {
5757 optgroup = '';
5758 }
5759 else {
5760 order = self_optgroup.$order;
5761 }
5762 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
5763 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
5764 if (j > 0) {
5765 option_el = option_el.cloneNode(true);
5766 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
5767 option_el.classList.add('ts-cloned');
5768 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
5769 // make sure we keep the activeOption in the same group
5770 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
5771 if (active_group && active_group.dataset.group === optgroup.toString()) {
5772 active_option = option_el;
5773 }
5774 }
5775 }
5776 group_fragment.appendChild(option_el);
5777 if (optgroup != '') {
5778 groups[optgroup] = group_order_i;
5779 }
5780 }
5781 }
5782 // sort optgroups
5783 if (self.settings.lockOptgroupOrder) {
5784 groups_order.sort((a, b) => {
5785 return a.order - b.order;
5786 });
5787 }
5788 // render optgroup headers & join groups
5789 html = document.createDocumentFragment();
5790 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
5791 let group_fragment = group_order.fragment;
5792 let optgroup = group_order.optgroup;
5793 if (!group_fragment || !group_fragment.children.length)
5794 return;
5795 let group_heading = self.optgroups[optgroup];
5796 if (group_heading !== undefined) {
5797 let group_options = document.createDocumentFragment();
5798 let header = self.render('optgroup_header', group_heading);
5799 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
5800 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
5801 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
5802 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
5803 }
5804 else {
5805 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
5806 }
5807 });
5808 dropdown_content.innerHTML = '';
5809 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
5810 // highlight matching terms inline
5811 if (self.settings.highlight) {
5812 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
5813 if (results.query.length && results.tokens.length) {
5814 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
5815 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
5816 });
5817 }
5818 }
5819 // helper method for adding templates to dropdown
5820 var add_template = (template) => {
5821 let content = self.render(template, { input: query });
5822 if (content) {
5823 show_dropdown = true;
5824 dropdown_content.insertBefore(content, dropdown_content.firstChild);
5825 }
5826 return content;
5827 };
5828 // add loading message
5829 if (self.loading) {
5830 add_template('loading');
5831 // invalid query
5832 }
5833 else if (!self.settings.shouldLoad.call(self, query)) {
5834 add_template('not_loading');
5835 // add no_results message
5836 }
5837 else if (results.items.length === 0) {
5838 add_template('no_results');
5839 }
5840 // add create option
5841 has_create_option = self.canCreate(query);
5842 if (has_create_option) {
5843 create = add_template('option_create');
5844 }
5845 // activate
5846 self.hasOptions = results.items.length > 0 || has_create_option;
5847 if (show_dropdown) {
5848 if (results.items.length > 0) {
5849 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
5850 active_option = self.getOption(self.items[0]);
5851 }
5852 if (!dropdown_content.contains(active_option)) {
5853 let active_index = 0;
5854 if (create && !self.settings.addPrecedence) {
5855 active_index = 1;
5856 }
5857 active_option = self.selectable()[active_index];
5858 }
5859 }
5860 else if (create) {
5861 active_option = create;
5862 }
5863 if (triggerDropdown && !self.isOpen) {
5864 self.open();
5865 self.scrollToOption(active_option, 'auto');
5866 }
5867 self.setActiveOption(active_option);
5868 }
5869 else {
5870 self.clearActiveOption();
5871 if (triggerDropdown && self.isOpen) {
5872 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
5873 }
5874 }
5875 }
5876 /**
5877 * Return list of selectable options
5878 *
5879 */
5880 selectable() {
5881 return this.dropdown_content.querySelectorAll('[data-selectable]');
5882 }
5883 /**
5884 * Adds an available option. If it already exists,
5885 * nothing will happen. Note: this does not refresh
5886 * the options list dropdown (use `refreshOptions`
5887 * for that).
5888 *
5889 * Usage:
5890 *
5891 * this.addOption(data)
5892 *
5893 */
5894 addOption(data, user_created = false) {
5895 const self = this;
5896 // @deprecated 1.7.7
5897 // use addOptions( array, user_created ) for adding multiple options
5898 if (Array.isArray(data)) {
5899 self.addOptions(data, user_created);
5900 return false;
5901 }
5902 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
5903 if (key === null || self.options.hasOwnProperty(key)) {
5904 return false;
5905 }
5906 data.$order = data.$order || ++self.order;
5907 data.$id = self.inputId + '-opt-' + data.$order;
5908 self.options[key] = data;
5909 self.lastQuery = null;
5910 if (user_created) {
5911 self.userOptions[key] = user_created;
5912 self.trigger('option_add', key, data);
5913 }
5914 return key;
5915 }
5916 /**
5917 * Add multiple options
5918 *
5919 */
5920 addOptions(data, user_created = false) {
5921 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
5922 this.addOption(dat, user_created);
5923 });
5924 }
5925 /**
5926 * @deprecated 1.7.7
5927 */
5928 registerOption(data) {
5929 return this.addOption(data);
5930 }
5931 /**
5932 * Registers an option group to the pool of option groups.
5933 *
5934 * @return {boolean|string}
5935 */
5936 registerOptionGroup(data) {
5937 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
5938 if (key === null)
5939 return false;
5940 data.$order = data.$order || ++this.order;
5941 this.optgroups[key] = data;
5942 return key;
5943 }
5944 /**
5945 * Registers a new optgroup for options
5946 * to be bucketed into.
5947 *
5948 */
5949 addOptionGroup(id, data) {
5950 var hashed_id;
5951 data[this.settings.optgroupValueField] = id;
5952 if (hashed_id = this.registerOptionGroup(data)) {
5953 this.trigger('optgroup_add', hashed_id, data);
5954 }
5955 }
5956 /**
5957 * Removes an existing option group.
5958 *
5959 */
5960 removeOptionGroup(id) {
5961 if (this.optgroups.hasOwnProperty(id)) {
5962 delete this.optgroups[id];
5963 this.clearCache();
5964 this.trigger('optgroup_remove', id);
5965 }
5966 }
5967 /**
5968 * Clears all existing option groups.
5969 */
5970 clearOptionGroups() {
5971 this.optgroups = {};
5972 this.clearCache();
5973 this.trigger('optgroup_clear');
5974 }
5975 /**
5976 * Updates an option available for selection. If
5977 * it is visible in the selected items or options
5978 * dropdown, it will be re-rendered automatically.
5979 *
5980 */
5981 updateOption(value, data) {
5982 const self = this;
5983 var item_new;
5984 var index_item;
5985 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
5986 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
5987 // sanity checks
5988 if (value_old === null)
5989 return;
5990 const data_old = self.options[value_old];
5991 if (data_old == undefined)
5992 return;
5993 if (typeof value_new !== 'string')
5994 throw new Error('Value must be set in option data');
5995 const option = self.getOption(value_old);
5996 const item = self.getItem(value_old);
5997 data.$order = data.$order || data_old.$order;
5998 delete self.options[value_old];
5999 // invalidate render cache
6000 // don't remove existing node yet, we'll remove it after replacing it
6001 self.uncacheValue(value_new);
6002 self.options[value_new] = data;
6003 // update the option if it's in the dropdown
6004 if (option) {
6005 if (self.dropdown_content.contains(option)) {
6006 const option_new = self._render('option', data);
6007 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
6008 if (self.activeOption === option) {
6009 self.setActiveOption(option_new);
6010 }
6011 }
6012 option.remove();
6013 }
6014 // update the item if we have one
6015 if (item) {
6016 index_item = self.items.indexOf(value_old);
6017 if (index_item !== -1) {
6018 self.items.splice(index_item, 1, value_new);
6019 }
6020 item_new = self._render('item', data);
6021 if (item.classList.contains('active'))
6022 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
6023 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
6024 }
6025 // invalidate last query because we might have updated the sortField
6026 self.lastQuery = null;
6027 }
6028 /**
6029 * Removes a single option.
6030 *
6031 */
6032 removeOption(value, silent) {
6033 const self = this;
6034 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
6035 self.uncacheValue(value);
6036 delete self.userOptions[value];
6037 delete self.options[value];
6038 self.lastQuery = null;
6039 self.trigger('option_remove', value);
6040 self.removeItem(value, silent);
6041 }
6042 /**
6043 * Clears all options.
6044 */
6045 clearOptions(filter) {
6046 const boundFilter = (filter || this.clearFilter).bind(this);
6047 this.loadedSearches = {};
6048 this.userOptions = {};
6049 this.clearCache();
6050 const selected = {};
6051 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
6052 if (boundFilter(option, key)) {
6053 selected[key] = option;
6054 }
6055 });
6056 this.options = this.sifter.items = selected;
6057 this.lastQuery = null;
6058 this.trigger('option_clear');
6059 }
6060 /**
6061 * Used by clearOptions() to decide whether or not an option should be removed
6062 * Return true to keep an option, false to remove
6063 *
6064 */
6065 clearFilter(option, value) {
6066 if (this.items.indexOf(value) >= 0) {
6067 return true;
6068 }
6069 return false;
6070 }
6071 /**
6072 * Returns the dom element of the option
6073 * matching the given value.
6074 *
6075 */
6076 getOption(value, create = false) {
6077 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
6078 if (hashed === null)
6079 return null;
6080 const option = this.options[hashed];
6081 if (option != undefined) {
6082 if (option.$div) {
6083 return option.$div;
6084 }
6085 if (create) {
6086 return this._render('option', option);
6087 }
6088 }
6089 return null;
6090 }
6091 /**
6092 * Returns the dom element of the next or previous dom element of the same type
6093 * Note: adjacent options may not be adjacent DOM elements (optgroups)
6094 *
6095 */
6096 getAdjacent(option, direction, type = 'option') {
6097 var self = this, all;
6098 if (!option) {
6099 return null;
6100 }
6101 if (type == 'item') {
6102 all = self.controlChildren();
6103 }
6104 else {
6105 all = self.dropdown_content.querySelectorAll('[data-selectable]');
6106 }
6107 for (let i = 0; i < all.length; i++) {
6108 if (all[i] != option) {
6109 continue;
6110 }
6111 if (direction > 0) {
6112 return all[i + 1];
6113 }
6114 return all[i - 1];
6115 }
6116 return null;
6117 }
6118 /**
6119 * Returns the dom element of the item
6120 * matching the given value.
6121 *
6122 */
6123 getItem(item) {
6124 if (typeof item == 'object') {
6125 return item;
6126 }
6127 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
6128 return value !== null
6129 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
6130 : null;
6131 }
6132 /**
6133 * "Selects" multiple items at once. Adds them to the list
6134 * at the current caret position.
6135 *
6136 */
6137 addItems(values, silent) {
6138 var self = this;
6139 var items = Array.isArray(values) ? values : [values];
6140 items = items.filter(x => self.items.indexOf(x) === -1);
6141 const last_item = items[items.length - 1];
6142 items.forEach(item => {
6143 self.isPending = (item !== last_item);
6144 self.addItem(item, silent);
6145 });
6146 }
6147 /**
6148 * "Selects" an item. Adds it to the list
6149 * at the current caret position.
6150 *
6151 */
6152 addItem(value, silent) {
6153 var events = silent ? [] : ['change', 'dropdown_close'];
6154 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
6155 var item, wasFull;
6156 const self = this;
6157 const inputMode = self.settings.mode;
6158 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
6159 if (hashed && self.items.indexOf(hashed) !== -1) {
6160 if (inputMode === 'single') {
6161 self.close();
6162 }
6163 if (inputMode === 'single' || !self.settings.duplicates) {
6164 return;
6165 }
6166 }
6167 if (hashed === null || !self.options.hasOwnProperty(hashed))
6168 return;
6169 if (inputMode === 'single')
6170 self.clear(silent);
6171 if (inputMode === 'multi' && self.isFull())
6172 return;
6173 item = self._render('item', self.options[hashed]);
6174 if (self.control.contains(item)) { // duplicates
6175 item = item.cloneNode(true);
6176 }
6177 wasFull = self.isFull();
6178 self.items.splice(self.caretPos, 0, hashed);
6179 self.insertAtCaret(item);
6180 if (self.isSetup) {
6181 // update menu / remove the option (if this is not one item being added as part of series)
6182 if (!self.isPending && self.settings.hideSelected) {
6183 let option = self.getOption(hashed);
6184 let next = self.getAdjacent(option, 1);
6185 if (next) {
6186 self.setActiveOption(next);
6187 }
6188 }
6189 // refreshOptions after setActiveOption(),
6190 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
6191 if (!self.isPending && !self.settings.closeAfterSelect) {
6192 self.refreshOptions(self.isFocused && inputMode !== 'single');
6193 }
6194 // hide the menu if the maximum number of items have been selected or no options are left
6195 if (self.settings.closeAfterSelect != false && self.isFull()) {
6196 self.close();
6197 }
6198 else if (!self.isPending) {
6199 self.positionDropdown();
6200 }
6201 self.trigger('item_add', hashed, item);
6202 if (!self.isPending) {
6203 self.updateOriginalInput({ silent: silent });
6204 }
6205 }
6206 if (!self.isPending || (!wasFull && self.isFull())) {
6207 self.inputState();
6208 self.refreshState();
6209 }
6210 });
6211 }
6212 /**
6213 * Removes the selected item matching
6214 * the provided value.
6215 *
6216 */
6217 removeItem(item = null, silent) {
6218 const self = this;
6219 item = self.getItem(item);
6220 if (!item)
6221 return;
6222 var i, idx;
6223 const value = item.dataset.value;
6224 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
6225 item.remove();
6226 if (item.classList.contains('active')) {
6227 idx = self.activeItems.indexOf(item);
6228 self.activeItems.splice(idx, 1);
6229 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
6230 }
6231 self.items.splice(i, 1);
6232 self.lastQuery = null;
6233 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
6234 self.removeOption(value, silent);
6235 }
6236 if (i < self.caretPos) {
6237 self.setCaret(self.caretPos - 1);
6238 }
6239 self.updateOriginalInput({ silent: silent });
6240 self.refreshState();
6241 self.positionDropdown();
6242 self.trigger('item_remove', value, item);
6243 }
6244 /**
6245 * Invokes the `create` method provided in the
6246 * TomSelect options that should provide the data
6247 * for the new item, given the user input.
6248 *
6249 * Once this completes, it will be added
6250 * to the item list.
6251 *
6252 */
6253 createItem(input = null, callback = () => { }) {
6254 // triggerDropdown parameter @deprecated 2.1.1
6255 if (arguments.length === 3) {
6256 callback = arguments[2];
6257 }
6258 if (typeof callback != 'function') {
6259 callback = () => { };
6260 }
6261 var self = this;
6262 var caret = self.caretPos;
6263 var output;
6264 input = input || self.inputValue();
6265 if (!self.canCreate(input)) {
6266 callback();
6267 return false;
6268 }
6269 self.lock();
6270 var created = false;
6271 var create = (data) => {
6272 self.unlock();
6273 if (!data || typeof data !== 'object')
6274 return callback();
6275 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
6276 if (typeof value !== 'string') {
6277 return callback();
6278 }
6279 self.setTextboxValue();
6280 self.addOption(data, true);
6281 self.setCaret(caret);
6282 self.addItem(value);
6283 callback(data);
6284 created = true;
6285 };
6286 if (typeof self.settings.create === 'function') {
6287 output = self.settings.create.call(this, input, create);
6288 }
6289 else {
6290 output = {
6291 [self.settings.labelField]: input,
6292 [self.settings.valueField]: input,
6293 };
6294 }
6295 if (!created) {
6296 create(output);
6297 }
6298 return true;
6299 }
6300 /**
6301 * Re-renders the selected item lists.
6302 */
6303 refreshItems() {
6304 var self = this;
6305 self.lastQuery = null;
6306 if (self.isSetup) {
6307 self.addItems(self.items);
6308 }
6309 self.updateOriginalInput();
6310 self.refreshState();
6311 }
6312 /**
6313 * Updates all state-dependent attributes
6314 * and CSS classes.
6315 */
6316 refreshState() {
6317 const self = this;
6318 self.refreshValidityState();
6319 const isFull = self.isFull();
6320 const isLocked = self.isLocked;
6321 self.wrapper.classList.toggle('rtl', self.rtl);
6322 const wrap_classList = self.wrapper.classList;
6323 wrap_classList.toggle('focus', self.isFocused);
6324 wrap_classList.toggle('disabled', self.isDisabled);
6325 wrap_classList.toggle('readonly', self.isReadOnly);
6326 wrap_classList.toggle('required', self.isRequired);
6327 wrap_classList.toggle('invalid', !self.isValid);
6328 wrap_classList.toggle('locked', isLocked);
6329 wrap_classList.toggle('full', isFull);
6330 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
6331 wrap_classList.toggle('dropdown-active', self.isOpen);
6332 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
6333 wrap_classList.toggle('has-items', self.items.length > 0);
6334 }
6335 /**
6336 * Update the `required` attribute of both input and control input.
6337 *
6338 * The `required` property needs to be activated on the control input
6339 * for the error to be displayed at the right place. `required` also
6340 * needs to be temporarily deactivated on the input since the input is
6341 * hidden and can't show errors.
6342 */
6343 refreshValidityState() {
6344 var self = this;
6345 if (!self.input.validity) {
6346 return;
6347 }
6348 self.isValid = self.input.validity.valid;
6349 self.isInvalid = !self.isValid;
6350 }
6351 /**
6352 * Determines whether or not more items can be added
6353 * to the control without exceeding the user-defined maximum.
6354 *
6355 * @returns {boolean}
6356 */
6357 isFull() {
6358 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
6359 }
6360 /**
6361 * Refreshes the original <select> or <input>
6362 * element to reflect the current state.
6363 *
6364 */
6365 updateOriginalInput(opts = {}) {
6366 const self = this;
6367 var option, label;
6368 const empty_option = self.input.querySelector('option[value=""]');
6369 if (self.is_select_tag) {
6370 const selected = [];
6371 const has_selected = self.input.querySelectorAll('option:checked').length;
6372 function AddSelected(option_el, value, label) {
6373 if (!option_el) {
6374 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>');
6375 }
6376 // don't move empty option from top of list
6377 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
6378 if (option_el != empty_option) {
6379 self.input.append(option_el);
6380 }
6381 selected.push(option_el);
6382 // marking empty option as selected can break validation
6383 // fixes https://github.com/orchidjs/tom-select/issues/303
6384 if (option_el != empty_option || has_selected > 0) {
6385 option_el.selected = true;
6386 }
6387 return option_el;
6388 }
6389 // unselect all selected options
6390 self.input.querySelectorAll('option:checked').forEach((option_el) => {
6391 option_el.selected = false;
6392 });
6393 // nothing selected?
6394 if (self.items.length == 0 && self.settings.mode == 'single') {
6395 AddSelected(empty_option, "", "");
6396 // order selected <option> tags for values in self.items
6397 }
6398 else {
6399 self.items.forEach((value) => {
6400 option = self.options[value];
6401 label = option[self.settings.labelField] || '';
6402 if (selected.includes(option.$option)) {
6403 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
6404 AddSelected(reuse_opt, value, label);
6405 }
6406 else {
6407 option.$option = AddSelected(option.$option, value, label);
6408 }
6409 });
6410 }
6411 }
6412 else {
6413 self.input.value = self.getValue();
6414 }
6415 if (self.isSetup) {
6416 if (!opts.silent) {
6417 self.trigger('change', self.getValue());
6418 }
6419 }
6420 }
6421 /**
6422 * Shows the autocomplete dropdown containing
6423 * the available options.
6424 */
6425 open() {
6426 var self = this;
6427 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
6428 return;
6429 self.isOpen = true;
6430 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
6431 self.refreshState();
6432 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
6433 self.positionDropdown();
6434 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
6435 self.focus();
6436 self.trigger('dropdown_open', self.dropdown);
6437 }
6438 /**
6439 * Closes the autocomplete dropdown menu.
6440 */
6441 close(setTextboxValue = true) {
6442 var self = this;
6443 var trigger = self.isOpen;
6444 if (setTextboxValue) {
6445 // before blur() to prevent form onchange event
6446 self.setTextboxValue();
6447 if (self.settings.mode === 'single' && self.items.length) {
6448 self.inputState();
6449 }
6450 }
6451 self.isOpen = false;
6452 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
6453 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
6454 if (self.settings.hideSelected) {
6455 self.clearActiveOption();
6456 }
6457 self.refreshState();
6458 if (trigger)
6459 self.trigger('dropdown_close', self.dropdown);
6460 }
6461 /**
6462 * Calculates and applies the appropriate
6463 * position of the dropdown if dropdownParent = 'body'.
6464 * Otherwise, position is determined by css
6465 */
6466 positionDropdown() {
6467 if (this.settings.dropdownParent !== 'body') {
6468 return;
6469 }
6470 var context = this.control;
6471 var rect = context.getBoundingClientRect();
6472 var top = context.offsetHeight + rect.top + window.scrollY;
6473 var left = rect.left + window.scrollX;
6474 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
6475 width: rect.width + 'px',
6476 top: top + 'px',
6477 left: left + 'px'
6478 });
6479 }
6480 /**
6481 * Resets / clears all selected items
6482 * from the control.
6483 *
6484 */
6485 clear(silent) {
6486 var self = this;
6487 if (!self.items.length)
6488 return;
6489 var items = self.controlChildren();
6490 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
6491 self.removeItem(item, true);
6492 });
6493 self.inputState();
6494 if (!silent)
6495 self.updateOriginalInput();
6496 self.trigger('clear');
6497 }
6498 /**
6499 * A helper method for inserting an element
6500 * at the current caret position.
6501 *
6502 */
6503 insertAtCaret(el) {
6504 const self = this;
6505 const caret = self.caretPos;
6506 const target = self.control;
6507 target.insertBefore(el, target.children[caret] || null);
6508 self.setCaret(caret + 1);
6509 }
6510 /**
6511 * Removes the current selected item(s).
6512 *
6513 */
6514 deleteSelection(e) {
6515 var direction, selection, caret, tail;
6516 var self = this;
6517 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
6518 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
6519 // determine items that will be removed
6520 const rm_items = [];
6521 if (self.activeItems.length) {
6522 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
6523 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
6524 if (direction > 0) {
6525 caret++;
6526 }
6527 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
6528 }
6529 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
6530 const items = self.controlChildren();
6531 let rm_item;
6532 if (direction < 0 && selection.start === 0 && selection.length === 0) {
6533 rm_item = items[self.caretPos - 1];
6534 }
6535 else if (direction > 0 && selection.start === self.inputValue().length) {
6536 rm_item = items[self.caretPos];
6537 }
6538 if (rm_item !== undefined) {
6539 rm_items.push(rm_item);
6540 }
6541 }
6542 if (!self.shouldDelete(rm_items, e)) {
6543 return false;
6544 }
6545 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
6546 // perform removal
6547 if (typeof caret !== 'undefined') {
6548 self.setCaret(caret);
6549 }
6550 while (rm_items.length) {
6551 self.removeItem(rm_items.pop());
6552 }
6553 self.inputState();
6554 self.positionDropdown();
6555 self.refreshOptions(false);
6556 return true;
6557 }
6558 /**
6559 * Return true if the items should be deleted
6560 */
6561 shouldDelete(items, evt) {
6562 const values = items.map(item => item.dataset.value);
6563 // allow the callback to abort
6564 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
6565 return false;
6566 }
6567 return true;
6568 }
6569 /**
6570 * Selects the previous / next item (depending on the `direction` argument).
6571 *
6572 * > 0 - right
6573 * < 0 - left
6574 *
6575 */
6576 advanceSelection(direction, e) {
6577 var last_active, adjacent, self = this;
6578 if (self.rtl)
6579 direction *= -1;
6580 if (self.inputValue().length)
6581 return;
6582 // add or remove to active items
6583 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)) {
6584 last_active = self.getLastActive(direction);
6585 if (last_active) {
6586 if (!last_active.classList.contains('active')) {
6587 adjacent = last_active;
6588 }
6589 else {
6590 adjacent = self.getAdjacent(last_active, direction, 'item');
6591 }
6592 // if no active item, get items adjacent to the control input
6593 }
6594 else if (direction > 0) {
6595 adjacent = self.control_input.nextElementSibling;
6596 }
6597 else {
6598 adjacent = self.control_input.previousElementSibling;
6599 }
6600 if (adjacent) {
6601 if (adjacent.classList.contains('active')) {
6602 self.removeActiveItem(last_active);
6603 }
6604 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
6605 }
6606 // move caret to the left or right
6607 }
6608 else {
6609 self.moveCaret(direction);
6610 }
6611 }
6612 moveCaret(direction) { }
6613 /**
6614 * Get the last active item
6615 *
6616 */
6617 getLastActive(direction) {
6618 let last_active = this.control.querySelector('.last-active');
6619 if (last_active) {
6620 return last_active;
6621 }
6622 var result = this.control.querySelectorAll('.active');
6623 if (result) {
6624 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
6625 }
6626 }
6627 /**
6628 * Moves the caret to the specified index.
6629 *
6630 * The input must be moved by leaving it in place and moving the
6631 * siblings, due to the fact that focus cannot be restored once lost
6632 * on mobile webkit devices
6633 *
6634 */
6635 setCaret(new_pos) {
6636 this.caretPos = this.items.length;
6637 }
6638 /**
6639 * Return list of item dom elements
6640 *
6641 */
6642 controlChildren() {
6643 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
6644 }
6645 /**
6646 * Disables user input on the control. Used while
6647 * items are being asynchronously created.
6648 */
6649 lock() {
6650 this.setLocked(true);
6651 }
6652 /**
6653 * Re-enables user input on the control.
6654 */
6655 unlock() {
6656 this.setLocked(false);
6657 }
6658 /**
6659 * Disable or enable user input on the control
6660 */
6661 setLocked(lock = this.isReadOnly || this.isDisabled) {
6662 this.isLocked = lock;
6663 this.refreshState();
6664 }
6665 /**
6666 * Disables user input on the control completely.
6667 * While disabled, it cannot receive focus.
6668 */
6669 disable() {
6670 this.setDisabled(true);
6671 this.close();
6672 }
6673 /**
6674 * Enables the control so that it can respond
6675 * to focus and user input.
6676 */
6677 enable() {
6678 this.setDisabled(false);
6679 }
6680 setDisabled(disabled) {
6681 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
6682 this.isDisabled = disabled;
6683 this.input.disabled = disabled;
6684 this.control_input.disabled = disabled;
6685 this.setLocked();
6686 }
6687 setReadOnly(isReadOnly) {
6688 this.isReadOnly = isReadOnly;
6689 this.input.readOnly = isReadOnly;
6690 this.control_input.readOnly = isReadOnly;
6691 this.setLocked();
6692 }
6693 /**
6694 * Completely destroys the control and
6695 * unbinds all event listeners so that it can
6696 * be garbage collected.
6697 */
6698 destroy() {
6699 var self = this;
6700 var revertSettings = self.revertSettings;
6701 self.trigger('destroy');
6702 self.off();
6703 self.wrapper.remove();
6704 self.dropdown.remove();
6705 self.input.innerHTML = revertSettings.innerHTML;
6706 self.input.tabIndex = revertSettings.tabIndex;
6707 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
6708 self._destroy();
6709 delete self.input.tomselect;
6710 }
6711 /**
6712 * A helper method for rendering "item" and
6713 * "option" templates, given the data.
6714 *
6715 */
6716 render(templateName, data) {
6717 var id, html;
6718 const self = this;
6719 if (typeof this.settings.render[templateName] !== 'function') {
6720 return null;
6721 }
6722 // render markup
6723 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
6724 if (!html) {
6725 return null;
6726 }
6727 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
6728 // add mandatory attributes
6729 if (templateName === 'option' || templateName === 'option_create') {
6730 if (data[self.settings.disabledField]) {
6731 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
6732 }
6733 else {
6734 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
6735 }
6736 }
6737 else if (templateName === 'optgroup') {
6738 id = data.group[self.settings.optgroupValueField];
6739 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
6740 if (data.group[self.settings.disabledField]) {
6741 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
6742 }
6743 }
6744 if (templateName === 'option' || templateName === 'item') {
6745 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
6746 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
6747 // make sure we have some classes if a template is overwritten
6748 if (templateName === 'item') {
6749 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
6750 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
6751 }
6752 else {
6753 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
6754 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
6755 role: 'option',
6756 id: data.$id
6757 });
6758 // update cache
6759 data.$div = html;
6760 self.options[value] = data;
6761 }
6762 }
6763 return html;
6764 }
6765 /**
6766 * Type guarded rendering
6767 *
6768 */
6769 _render(templateName, data) {
6770 const html = this.render(templateName, data);
6771 if (html == null) {
6772 throw 'HTMLElement expected';
6773 }
6774 return html;
6775 }
6776 /**
6777 * Clears the render cache for a template. If
6778 * no template is given, clears all render
6779 * caches.
6780 *
6781 */
6782 clearCache() {
6783 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
6784 if (option.$div) {
6785 option.$div.remove();
6786 delete option.$div;
6787 }
6788 });
6789 }
6790 /**
6791 * Removes a value from item and option caches
6792 *
6793 */
6794 uncacheValue(value) {
6795 const option_el = this.getOption(value);
6796 if (option_el)
6797 option_el.remove();
6798 }
6799 /**
6800 * Determines whether or not to display the
6801 * create item prompt, given a user input.
6802 *
6803 */
6804 canCreate(input) {
6805 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
6806 }
6807 /**
6808 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
6809 *
6810 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
6811 *
6812 * });
6813 */
6814 hook(when, method, new_fn) {
6815 var self = this;
6816 var orig_method = self[method];
6817 self[method] = function () {
6818 var result, result_new;
6819 if (when === 'after') {
6820 result = orig_method.apply(self, arguments);
6821 }
6822 result_new = new_fn.apply(self, arguments);
6823 if (when === 'instead') {
6824 return result_new;
6825 }
6826 if (when === 'before') {
6827 result = orig_method.apply(self, arguments);
6828 }
6829 return result;
6830 };
6831 }
6832 }
6833 ;
6834 //# sourceMappingURL=tom-select.js.map
6835
6836 /***/ },
6837
6838 /***/ "./node_modules/tom-select/dist/esm/utils.js"
6839 /*!***************************************************!*\
6840 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
6841 \***************************************************/
6842 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
6843
6844 __webpack_require__.r(__webpack_exports__);
6845 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6846 /* harmony export */ addEvent: () => (/* binding */ addEvent),
6847 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
6848 /* harmony export */ append: () => (/* binding */ append),
6849 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
6850 /* harmony export */ escape_html: () => (/* binding */ escape_html),
6851 /* harmony export */ getId: () => (/* binding */ getId),
6852 /* harmony export */ getSelection: () => (/* binding */ getSelection),
6853 /* harmony export */ get_hash: () => (/* binding */ get_hash),
6854 /* harmony export */ hash_key: () => (/* binding */ hash_key),
6855 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
6856 /* harmony export */ iterate: () => (/* binding */ iterate),
6857 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
6858 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
6859 /* harmony export */ timeout: () => (/* binding */ timeout)
6860 /* harmony export */ });
6861 /**
6862 * Converts a scalar to its best string representation
6863 * for hash keys and HTML attribute values.
6864 *
6865 * Transformations:
6866 * 'str' -> 'str'
6867 * null -> ''
6868 * undefined -> ''
6869 * true -> '1'
6870 * false -> '0'
6871 * 0 -> '0'
6872 * 1 -> '1'
6873 *
6874 */
6875 const hash_key = (value) => {
6876 if (typeof value === 'undefined' || value === null)
6877 return null;
6878 return get_hash(value);
6879 };
6880 const get_hash = (value) => {
6881 if (typeof value === 'boolean')
6882 return value ? '1' : '0';
6883 return value + '';
6884 };
6885 /**
6886 * Escapes a string for use within HTML.
6887 *
6888 */
6889 const escape_html = (str) => {
6890 return (str + '')
6891 .replace(/&/g, '&amp;')
6892 .replace(/</g, '&lt;')
6893 .replace(/>/g, '&gt;')
6894 .replace(/"/g, '&quot;');
6895 };
6896 /**
6897 * use setTimeout if timeout > 0
6898 */
6899 const timeout = (fn, timeout) => {
6900 if (timeout > 0) {
6901 return window.setTimeout(fn, timeout);
6902 }
6903 fn.call(null);
6904 return null;
6905 };
6906 /**
6907 * Debounce the user provided load function
6908 *
6909 */
6910 const loadDebounce = (fn, delay) => {
6911 var timeout;
6912 return function (value, callback) {
6913 var self = this;
6914 if (timeout) {
6915 self.loading = Math.max(self.loading - 1, 0);
6916 clearTimeout(timeout);
6917 }
6918 timeout = setTimeout(function () {
6919 timeout = null;
6920 self.loadedSearches[value] = true;
6921 fn.call(self, value, callback);
6922 }, delay);
6923 };
6924 };
6925 /**
6926 * Debounce all fired events types listed in `types`
6927 * while executing the provided `fn`.
6928 *
6929 */
6930 const debounce_events = (self, types, fn) => {
6931 var type;
6932 var trigger = self.trigger;
6933 var event_args = {};
6934 // override trigger method
6935 self.trigger = function () {
6936 var type = arguments[0];
6937 if (types.indexOf(type) !== -1) {
6938 event_args[type] = arguments;
6939 }
6940 else {
6941 return trigger.apply(self, arguments);
6942 }
6943 };
6944 // invoke provided function
6945 fn.apply(self, []);
6946 self.trigger = trigger;
6947 // trigger queued events
6948 for (type of types) {
6949 if (type in event_args) {
6950 trigger.apply(self, event_args[type]);
6951 }
6952 }
6953 };
6954 /**
6955 * Determines the current selection within a text input control.
6956 * Returns an object containing:
6957 * - start
6958 * - length
6959 *
6960 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
6961 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
6962 */
6963 const getSelection = (input) => {
6964 return {
6965 start: input.selectionStart || 0,
6966 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
6967 };
6968 };
6969 /**
6970 * Prevent default
6971 *
6972 */
6973 const preventDefault = (evt, stop = false) => {
6974 if (evt) {
6975 evt.preventDefault();
6976 if (stop) {
6977 evt.stopPropagation();
6978 }
6979 }
6980 };
6981 /**
6982 * Add event helper
6983 *
6984 */
6985 const addEvent = (target, type, callback, options) => {
6986 target.addEventListener(type, callback, options);
6987 };
6988 /**
6989 * Return true if the requested key is down
6990 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
6991 * The current evt may not always set ( eg calling advanceSelection() )
6992 *
6993 */
6994 const isKeyDown = (key_name, evt) => {
6995 if (!evt) {
6996 return false;
6997 }
6998 if (!evt[key_name]) {
6999 return false;
7000 }
7001 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
7002 if (count === 1) {
7003 return true;
7004 }
7005 return false;
7006 };
7007 /**
7008 * Get the id of an element
7009 * If the id attribute is not set, set the attribute with the given id
7010 *
7011 */
7012 const getId = (el, id) => {
7013 const existing_id = el.getAttribute('id');
7014 if (existing_id) {
7015 return existing_id;
7016 }
7017 el.setAttribute('id', id);
7018 return id;
7019 };
7020 /**
7021 * Returns a string with backslashes added before characters that need to be escaped.
7022 */
7023 const addSlashes = (str) => {
7024 return str.replace(/[\\"']/g, '\\$&');
7025 };
7026 /**
7027 *
7028 */
7029 const append = (parent, node) => {
7030 if (node)
7031 parent.append(node);
7032 };
7033 /**
7034 * Iterates over arrays and hashes.
7035 *
7036 * ```
7037 * iterate(this.items, function(item, id) {
7038 * // invoked for each item
7039 * });
7040 * ```
7041 *
7042 */
7043 const iterate = (object, callback) => {
7044 if (Array.isArray(object)) {
7045 object.forEach(callback);
7046 }
7047 else {
7048 for (var key in object) {
7049 if (object.hasOwnProperty(key)) {
7050 callback(object[key], key);
7051 }
7052 }
7053 }
7054 };
7055 //# sourceMappingURL=utils.js.map
7056
7057 /***/ },
7058
7059 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
7060 /*!*****************************************************!*\
7061 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
7062 \*****************************************************/
7063 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7064
7065 __webpack_require__.r(__webpack_exports__);
7066 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7067 /* harmony export */ addClasses: () => (/* binding */ addClasses),
7068 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
7069 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
7070 /* harmony export */ classesArray: () => (/* binding */ classesArray),
7071 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
7072 /* harmony export */ getDom: () => (/* binding */ getDom),
7073 /* harmony export */ getTail: () => (/* binding */ getTail),
7074 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
7075 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
7076 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
7077 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
7078 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
7079 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
7080 /* harmony export */ setAttr: () => (/* binding */ setAttr),
7081 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
7082 /* harmony export */ });
7083 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
7084
7085 /**
7086 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
7087 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
7088 *
7089 * param query should be {}
7090 */
7091 const getDom = (query) => {
7092 if (query.jquery) {
7093 return query[0];
7094 }
7095 if (query instanceof HTMLElement) {
7096 return query;
7097 }
7098 if (isHtmlString(query)) {
7099 var tpl = document.createElement('template');
7100 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
7101 return tpl.content.firstChild;
7102 }
7103 return document.querySelector(query);
7104 };
7105 const isHtmlString = (arg) => {
7106 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
7107 return true;
7108 }
7109 return false;
7110 };
7111 const escapeQuery = (query) => {
7112 return query.replace(/['"\\]/g, '\\$&');
7113 };
7114 /**
7115 * Dispatch an event
7116 *
7117 */
7118 const triggerEvent = (dom_el, event_name) => {
7119 var event = document.createEvent('HTMLEvents');
7120 event.initEvent(event_name, true, false);
7121 dom_el.dispatchEvent(event);
7122 };
7123 /**
7124 * Apply CSS rules to a dom element
7125 *
7126 */
7127 const applyCSS = (dom_el, css) => {
7128 Object.assign(dom_el.style, css);
7129 };
7130 /**
7131 * Add css classes
7132 *
7133 */
7134 const addClasses = (elmts, ...classes) => {
7135 var norm_classes = classesArray(classes);
7136 elmts = castAsArray(elmts);
7137 elmts.map(el => {
7138 norm_classes.map(cls => {
7139 el.classList.add(cls);
7140 });
7141 });
7142 };
7143 /**
7144 * Remove css classes
7145 *
7146 */
7147 const removeClasses = (elmts, ...classes) => {
7148 var norm_classes = classesArray(classes);
7149 elmts = castAsArray(elmts);
7150 elmts.map(el => {
7151 norm_classes.map(cls => {
7152 el.classList.remove(cls);
7153 });
7154 });
7155 };
7156 /**
7157 * Return arguments
7158 *
7159 */
7160 const classesArray = (args) => {
7161 var classes = [];
7162 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
7163 if (typeof _classes === 'string') {
7164 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
7165 }
7166 if (Array.isArray(_classes)) {
7167 classes = classes.concat(_classes);
7168 }
7169 });
7170 return classes.filter(Boolean);
7171 };
7172 /**
7173 * Create an array from arg if it's not already an array
7174 *
7175 */
7176 const castAsArray = (arg) => {
7177 if (!Array.isArray(arg)) {
7178 arg = [arg];
7179 }
7180 return arg;
7181 };
7182 /**
7183 * Get the closest node to the evt.target matching the selector
7184 * Stops at wrapper
7185 *
7186 */
7187 const parentMatch = (target, selector, wrapper) => {
7188 if (wrapper && !wrapper.contains(target)) {
7189 return;
7190 }
7191 while (target && target.matches) {
7192 if (target.matches(selector)) {
7193 return target;
7194 }
7195 target = target.parentNode;
7196 }
7197 };
7198 /**
7199 * Get the first or last item from an array
7200 *
7201 * > 0 - right (last)
7202 * <= 0 - left (first)
7203 *
7204 */
7205 const getTail = (list, direction = 0) => {
7206 if (direction > 0) {
7207 return list[list.length - 1];
7208 }
7209 return list[0];
7210 };
7211 /**
7212 * Return true if an object is empty
7213 *
7214 */
7215 const isEmptyObject = (obj) => {
7216 return (Object.keys(obj).length === 0);
7217 };
7218 /**
7219 * Get the index of an element amongst sibling nodes of the same type
7220 *
7221 */
7222 const nodeIndex = (el, amongst) => {
7223 if (!el)
7224 return -1;
7225 amongst = amongst || el.nodeName;
7226 var i = 0;
7227 while (el = el.previousElementSibling) {
7228 if (el.matches(amongst)) {
7229 i++;
7230 }
7231 }
7232 return i;
7233 };
7234 /**
7235 * Set attributes of an element
7236 *
7237 */
7238 const setAttr = (el, attrs) => {
7239 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
7240 if (val == null) {
7241 el.removeAttribute(attr);
7242 }
7243 else {
7244 el.setAttribute(attr, '' + val);
7245 }
7246 });
7247 };
7248 /**
7249 * Replace a node
7250 */
7251 const replaceNode = (existing, replacement) => {
7252 if (existing.parentNode)
7253 existing.parentNode.replaceChild(replacement, existing);
7254 };
7255 //# sourceMappingURL=vanilla.js.map
7256
7257 /***/ }
7258
7259 /******/ });
7260 /************************************************************************/
7261 /******/ // The module cache
7262 /******/ var __webpack_module_cache__ = {};
7263 /******/
7264 /******/ // The require function
7265 /******/ function __webpack_require__(moduleId) {
7266 /******/ // Check if module is in cache
7267 /******/ var cachedModule = __webpack_module_cache__[moduleId];
7268 /******/ if (cachedModule !== undefined) {
7269 /******/ return cachedModule.exports;
7270 /******/ }
7271 /******/ // Create a new module (and put it into the cache)
7272 /******/ var module = __webpack_module_cache__[moduleId] = {
7273 /******/ // no module.id needed
7274 /******/ // no module.loaded needed
7275 /******/ exports: {}
7276 /******/ };
7277 /******/
7278 /******/ // Execute the module function
7279 /******/ if (!(moduleId in __webpack_modules__)) {
7280 /******/ delete __webpack_module_cache__[moduleId];
7281 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
7282 /******/ e.code = 'MODULE_NOT_FOUND';
7283 /******/ throw e;
7284 /******/ }
7285 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
7286 /******/
7287 /******/ // Return the exports of the module
7288 /******/ return module.exports;
7289 /******/ }
7290 /******/
7291 /************************************************************************/
7292 /******/ /* webpack/runtime/define property getters */
7293 /******/ (() => {
7294 /******/ // define getter functions for harmony exports
7295 /******/ __webpack_require__.d = (exports, definition) => {
7296 /******/ for(var key in definition) {
7297 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
7298 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
7299 /******/ }
7300 /******/ }
7301 /******/ };
7302 /******/ })();
7303 /******/
7304 /******/ /* webpack/runtime/hasOwnProperty shorthand */
7305 /******/ (() => {
7306 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
7307 /******/ })();
7308 /******/
7309 /******/ /* webpack/runtime/make namespace object */
7310 /******/ (() => {
7311 /******/ // define __esModule on exports
7312 /******/ __webpack_require__.r = (exports) => {
7313 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
7314 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
7315 /******/ }
7316 /******/ Object.defineProperty(exports, '__esModule', { value: true });
7317 /******/ };
7318 /******/ })();
7319 /******/
7320 /************************************************************************/
7321 var __webpack_exports__ = {};
7322 // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
7323 (() => {
7324 /*!********************************************!*\
7325 !*** ./assets/src/js/admin/admin-order.js ***!
7326 \********************************************/
7327 __webpack_require__.r(__webpack_exports__);
7328 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
7329 /* harmony import */ var _order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./order/add-courses-to-order */ "./assets/src/js/admin/order/add-courses-to-order.js");
7330
7331
7332 //import modalSearchCourses from './order/modal-search-courses';
7333
7334 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
7335 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
7336 })();
7337
7338 /******/ })()
7339 ;
7340 //# sourceMappingURL=admin-order.js.map