PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 All 142 releases
learnpress / assets / js / dist / admin / admin.js

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

8,939 lines 304.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/admin/init-tom-select.js"
5 /*!************************************************!*\
6 !*** ./assets/src/js/admin/init-tom-select.js ***!
7 \************************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ initElsTomSelect: () => (/* binding */ initElsTomSelect),
14 /* harmony export */ initTomSelect: () => (/* binding */ initTomSelect),
15 /* harmony export */ searchUserOnListPost: () => (/* binding */ searchUserOnListPost)
16 /* harmony export */ });
17 /* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
18
19
20 /**
21 * Handle data response from API for tom-select
22 *
23 * @param {*} response
24 * @param {*} tomSelectEl
25 * @param dataStruct
26 * @param fetchAPI
27 * @param customOptions
28 * @param {*} callBack
29 */
30 const handleResponse = (response, tomSelectEl, dataStruct, fetchAPI, customOptions = {}, callBack) => {
31 if (!response || !tomSelectEl || !dataStruct || !fetchAPI || !callBack) {
32 return;
33 }
34
35 //Function format render data
36 const getTextOption = data => {
37 if (!dataStruct.keyGetValue?.text || !dataStruct.keyGetValue.key_render) {
38 return;
39 }
40 let text = dataStruct.keyGetValue.text;
41 for (const [key, value] of Object.entries(dataStruct.keyGetValue.key_render)) {
42 text = text.replace(new RegExp(`{{${value}}}`, 'g'), data[value]);
43 }
44 return text;
45 };
46
47 // Get default item tom-select
48 const defaultIds = tomSelectEl.dataset?.saved ? JSON.parse(tomSelectEl.dataset.saved) : 0;
49 let options = [];
50
51 // Format response data set option tom-select
52 if (response.data[dataStruct.dataType].length > 0) {
53 options = response.data[dataStruct.dataType].map(item => ({
54 value: item[dataStruct.keyGetValue.value],
55 text: getTextOption(item)
56 }));
57 }
58
59 // Setting option tom-select
60 const settingOption = {
61 items: defaultIds,
62 render: {
63 item(data, escape) {
64 return `` + `<li data-id="${data.value}">
65 <div class="item">${data.text}</div>
66 </li>`;
67 }
68 },
69 onChange: data => {
70 if (data.length < 1) {
71 tomSelectEl.value = '';
72 }
73 },
74 ...customOptions,
75 options
76 };
77 if (null != tomSelectEl.tomSelectInstance) {
78 tomSelectEl.tomSelectInstance.addOptions(options);
79 return options;
80 }
81 tomSelectEl.tomSelectInstance = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.buildTomSelect(tomSelectEl, settingOption, fetchAPI, {}, callBack);
82 return options;
83 };
84
85 //Init Tom-select with available options
86 const initTomSelectWithOption = (tomSelectEl, settingTomSelect = {}) => {
87 if (!tomSelectEl) {
88 return null;
89 }
90 if (null != tomSelectEl.tomSelectInstance) {
91 return null;
92 }
93 tomSelectEl.tomSelectInstance = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.buildTomSelect(tomSelectEl, settingTomSelect);
94 };
95
96 // Init Tom-select
97 const initTomSelect = (tomSelectEl, customOptions = {}, customParams = {}) => {
98 var _dataStruct$dataSendA, _dataStruct$urlApi;
99 if (!tomSelectEl) {
100 return;
101 }
102 if (tomSelectEl.classList.contains('loaded')) {
103 return;
104 }
105 tomSelectEl.classList.add('loaded');
106 const defaultIds = tomSelectEl.dataset?.saved ? JSON.parse(tomSelectEl.dataset.saved) : 0;
107 const dataStruct = tomSelectEl?.dataset?.struct ? JSON.parse(tomSelectEl.dataset.struct) : '';
108 if (!dataStruct) {
109 initTomSelectWithOption(tomSelectEl);
110 return;
111 }
112 const getParentElByTagName = (tag, el) => {
113 const newEl = el.parentElement;
114 if (newEl.tagName.toLowerCase() === tag) {
115 return newEl;
116 }
117 if (newEl.tagName.toLowerCase() === 'html') {
118 return false;
119 }
120 return getParentElByTagName(tag, newEl);
121 };
122 const formParent = getParentElByTagName('form', tomSelectEl);
123 if (formParent) {
124 const elInput = formParent.querySelector('input[name="' + tomSelectEl.getAttribute('name') + '"]');
125 if (elInput) {
126 elInput.remove();
127 }
128 }
129 const dataSendApi = (_dataStruct$dataSendA = dataStruct.dataSendApi) !== null && _dataStruct$dataSendA !== void 0 ? _dataStruct$dataSendA : '';
130 const urlApi = (_dataStruct$urlApi = dataStruct.urlApi) !== null && _dataStruct$urlApi !== void 0 ? _dataStruct$urlApi : '';
131 const settingTomSelect = {
132 ...dataStruct.setting,
133 ...customOptions
134 };
135 if (!urlApi) {
136 initTomSelectWithOption(tomSelectEl, settingTomSelect);
137 return;
138 }
139 const fetchFunction = (keySearch = '', customParams, callback) => {
140 const url = urlApi;
141 const dataSend = {
142 current_ids: defaultIds,
143 ...dataSendApi,
144 ...customParams
145 };
146 dataSend.search = keySearch;
147 const params = {
148 headers: {
149 'Content-Type': 'application/json',
150 'X-WP-Nonce': lpData.nonce
151 },
152 method: 'POST',
153 body: JSON.stringify(dataSend)
154 };
155 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, callback);
156 };
157 const callBackApi = {
158 success: response => {
159 handleResponse(response, tomSelectEl, dataStruct, fetchFunction, settingTomSelect, callBackApi);
160 }
161 };
162
163 // Fetch data for first load tom-select
164 // Get ids selected, and show list without ids selected with limit.
165 let idNotIn = [];
166 if (typeof defaultIds === 'object') {
167 idNotIn = Object.entries(defaultIds).map(([key, value]) => ({
168 key,
169 value
170 }));
171 }
172 if (dataSendApi?.id_not_in) {
173 idNotIn = [...idNotIn, ...dataSendApi.id_not_in];
174 }
175 customParams.id_not_in = idNotIn.join(',');
176 fetchFunction('', customParams, callBackApi);
177 };
178
179 // Init Tom-select user in admin
180 const searchUserOnListPost = () => {
181 if (lpData.show_search_author_field === '0') {
182 return;
183 }
184 const elPostFilter = document.querySelector('#posts-filter');
185 if (!elPostFilter) {
186 return;
187 }
188 let elSearchPost = elPostFilter.querySelector('.search-box');
189 if (!elSearchPost) {
190 elPostFilter.insertAdjacentHTML('afterbegin', lpData.show_search_author_field);
191 elSearchPost = elPostFilter.querySelector('.search-box');
192 }
193 if (!elSearchPost) {
194 return;
195 }
196 const selectNew = elSearchPost.querySelector('select#author');
197 if (selectNew) {
198 return;
199 }
200 const createSelectUserHtml = () => {
201 let defaultId = '';
202 const authorIdFilter = lpData.urlParams.author;
203 if (authorIdFilter) {
204 defaultId = JSON.stringify(authorIdFilter);
205 }
206 const dataStruct = {
207 urlApi: _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiSearchUsers,
208 dataType: 'users',
209 keyGetValue: {
210 value: 'ID',
211 text: '{{display_name}}(#{{ID}}) - {{user_email}}',
212 key_render: {
213 display_name: 'display_name',
214 user_email: 'user_email',
215 ID: 'ID'
216 }
217 },
218 setting: {
219 placeholder: lpData.i18n.select_user
220 }
221 };
222 const dataStructJson = JSON.stringify(dataStruct);
223 const htmlSelectUser = `` + `<select data-struct='${dataStructJson}' style='display:none;' data-saved='${defaultId}'
224 id="author" name="author" class="select lp-tom-select">` + `</select>`;
225 const elInputSearch = elSearchPost.querySelector('input[name="s"]');
226 if (elInputSearch) {
227 elInputSearch.insertAdjacentHTML('afterend', htmlSelectUser);
228 }
229
230 // Remove input hide default of WP.
231 const elInputAuthor = elPostFilter.querySelector('input[name="author"]');
232 if (elInputAuthor) {
233 elInputAuthor.remove();
234 }
235 };
236 createSelectUserHtml();
237 };
238 const initElsTomSelect = () => {
239 const tomSelectEls = document.querySelectorAll('select.lp-tom-select:not(.loaded)');
240 if (tomSelectEls.length) {
241 tomSelectEls.forEach(tomSelectEl => {
242 // Not build elements tom-select in Widget left classic of WordPress.
243 if (tomSelectEl.closest('.widget-liquid-left')) {
244 return;
245 }
246 initTomSelect(tomSelectEl);
247 });
248 }
249 };
250
251
252 /***/ },
253
254 /***/ "./assets/src/js/admin/share/dropdown-pages.js"
255 /*!*****************************************************!*\
256 !*** ./assets/src/js/admin/share/dropdown-pages.js ***!
257 \*****************************************************/
258 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
259
260 "use strict";
261 __webpack_require__.r(__webpack_exports__);
262 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
263 /* harmony export */ DropdownPages: () => (/* binding */ DropdownPages)
264 /* harmony export */ });
265 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
266 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
267 /**
268 * Dropdown Pages
269 *
270 * @since 4.2.5.1
271 * @version 1.0.0
272 */
273
274
275 class DropdownPages {
276 static selectors = {
277 elDropdown: '.learn-press-dropdown-pages',
278 elSelect: 'select',
279 elListWrap: '.list-pages-wrapper',
280 elActions: '.quick-add-page-actions',
281 elForm: '.quick-add-page-inline',
282 elButtonQuickAdd: '.button-quick-add-page',
283 elInput: '.quick-add-page-inline input[type="text"]',
284 elButtonSubmit: '.quick-add-page-inline button',
285 elButtonCancel: '.quick-add-page-inline a'
286 };
287 constructor() {
288 this.elDropdowns = [];
289 }
290 init() {
291 this.elDropdowns = document.querySelectorAll(DropdownPages.selectors.elDropdown);
292 if (!this.elDropdowns.length) {
293 return;
294 }
295 this.events();
296 }
297 events() {
298 // Check and attach events only once
299 if (DropdownPages._loadedEvents) {
300 return;
301 }
302 DropdownPages._loadedEvents = this;
303
304 // Change events
305 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('change', [{
306 selector: DropdownPages.selectors.elDropdown,
307 class: this,
308 callBack: this.handleChangeSelect.name
309 }]);
310
311 // Click events
312 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
313 selector: DropdownPages.selectors.elButtonSubmit,
314 class: this,
315 callBack: this.handleSubmit.name
316 }, {
317 selector: DropdownPages.selectors.elButtonCancel,
318 class: this,
319 callBack: this.handleCancel.name
320 }, {
321 selector: DropdownPages.selectors.elButtonQuickAdd,
322 class: this,
323 callBack: this.handleQuickAdd.name
324 }]);
325
326 // Keydown events
327 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keydown', [{
328 selector: DropdownPages.selectors.elInput,
329 class: this,
330 callBack: this.handleInputEnter.name,
331 checkIsEventEnter: true
332 }, {
333 selector: DropdownPages.selectors.elInput,
334 class: this,
335 callBack: this.handleInputEscape.name
336 }]);
337 }
338 handleChangeSelect(args) {
339 const {
340 e
341 } = args;
342 const elSelect = e.target;
343 if (!elSelect.matches(DropdownPages.selectors.elSelect)) {
344 return;
345 }
346 const elDropdown = elSelect.closest(DropdownPages.selectors.elDropdown);
347 if (!elDropdown) {
348 return;
349 }
350 const elActions = elDropdown.querySelector(DropdownPages.selectors.elActions);
351 if (elActions) {
352 elActions.classList.add('hide-if-js');
353 }
354 if (parseInt(elSelect.value, 10)) {
355 if (elActions) {
356 const editLink = elActions.querySelector('a.edit-page');
357 const viewLink = elActions.querySelector('a.view-page');
358 if (editLink) {
359 editLink.href = `post.php?post=${elSelect.value}&action=edit`;
360 }
361 if (viewLink) {
362 viewLink.href = `${window.lpGlobalSettings.siteurl}?page_id=${elSelect.value}`;
363 }
364 elActions.classList.remove('hide-if-js');
365 }
366 elSelect.setAttribute('data-selected', elSelect.value);
367 }
368 }
369 openQuickAddForm(elDropdown) {
370 const elListWrap = elDropdown.querySelector(DropdownPages.selectors.elListWrap);
371 const elForm = elDropdown.querySelector(DropdownPages.selectors.elForm);
372 if (elListWrap) {
373 elListWrap.classList.add('hide-if-js');
374 }
375 if (elForm) {
376 elForm.classList.remove('hide-if-js');
377 const elInput = elForm.querySelector('input');
378 if (elInput) {
379 elInput.value = '';
380 elInput.focus();
381 }
382 }
383 }
384 handleSubmit(args) {
385 const {
386 e
387 } = args;
388 e.preventDefault();
389 const elButton = e.target.closest(DropdownPages.selectors.elButtonSubmit);
390 if (!elButton) {
391 return;
392 }
393 const elForm = elButton.closest(DropdownPages.selectors.elForm);
394 if (!elForm) {
395 return;
396 }
397 const elDropdown = elForm.closest(DropdownPages.selectors.elDropdown);
398 if (!elDropdown) {
399 return;
400 }
401 const elInput = elForm.querySelector('input');
402 const elListWrap = elDropdown.querySelector(DropdownPages.selectors.elListWrap);
403 const pageName = elInput ? elInput.value.trim() : '';
404 if (!pageName) {
405 alert('Please enter the name of page');
406 if (elInput) {
407 elInput.focus();
408 }
409 return;
410 }
411 elButton.disabled = true;
412 let fieldName = '';
413 const elFieldName = elDropdown.querySelector('select');
414 fieldName = elFieldName ? elFieldName.name : '';
415 if (!window.lpGlobalSettings || !window.lpGlobalSettings.ajax || !window.lpDataAdmin || !window.lpDataAdmin.nonce) {
416 elButton.disabled = false;
417 return;
418 }
419 const formData = new FormData();
420 formData.append('action', 'learnpress_create_page');
421 formData.append('page_name', pageName);
422 formData.append('field_name', fieldName);
423 formData.append('nonce', window.lpDataAdmin.nonce);
424 fetch(window.lpGlobalSettings.ajax, {
425 method: 'POST',
426 body: formData
427 }).then(response => response.json()).then(response => {
428 const {
429 message,
430 status,
431 data
432 } = response;
433 if (status === 'success') {
434 elForm.classList.add('hide-if-js');
435 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, 'success');
436 setTimeout(() => {
437 window.location.reload();
438 }, 1000);
439 } else {
440 throw new Error(message);
441 }
442 }).catch(error => {
443 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
444 }).finally(() => {
445 elButton.disabled = false;
446 if (elListWrap) {
447 elListWrap.classList.remove('hide-if-js');
448 }
449 });
450 }
451 addNewPageToList(args) {
452 const {
453 ID,
454 name,
455 positions
456 } = args;
457 const option = document.createElement('option');
458 option.value = ID;
459 option.textContent = name;
460 const position = positions.indexOf(ID + '');
461 document.querySelectorAll(`${DropdownPages.selectors.elDropdown} ${DropdownPages.selectors.elSelect}`).forEach(select => {
462 const newOption = option.cloneNode(true);
463 if (position === 0) {
464 const options = select.querySelectorAll('option');
465 for (const opt of options) {
466 if (parseInt(opt.value, 10)) {
467 opt.before(newOption);
468 break;
469 }
470 }
471 } else if (position === positions.length - 1) {
472 select.appendChild(newOption);
473 } else {
474 const prevOption = select.querySelector(`option[value="${positions[position - 1]}"]`);
475 if (prevOption) {
476 prevOption.after(newOption);
477 } else {
478 select.appendChild(newOption);
479 }
480 }
481 });
482 }
483 handleCancel(args) {
484 const {
485 e
486 } = args;
487 e.preventDefault();
488 const elCancel = e.target.closest(DropdownPages.selectors.elButtonCancel);
489 if (!elCancel) {
490 return;
491 }
492 const elForm = elCancel.closest(DropdownPages.selectors.elForm);
493 if (!elForm) {
494 return;
495 }
496 const elDropdown = elForm.closest(DropdownPages.selectors.elDropdown);
497 if (!elDropdown) {
498 return;
499 }
500 const elSelect = elDropdown.querySelector(DropdownPages.selectors.elSelect);
501 const elListWrap = elDropdown.querySelector(DropdownPages.selectors.elListWrap);
502 const selected = elSelect ? elSelect.getAttribute('data-selected') : '';
503 elForm.classList.add('hide-if-js');
504 if (elSelect) {
505 elSelect.value = selected + '';
506 elSelect.removeAttribute('disabled');
507 elSelect.dispatchEvent(new Event('change', {
508 bubbles: true
509 }));
510 }
511 if (elListWrap) {
512 elListWrap.classList.remove('hide-if-js');
513 }
514 }
515 handleQuickAdd(args) {
516 const {
517 e
518 } = args;
519 const elButton = e.target.closest(DropdownPages.selectors.elButtonQuickAdd);
520 if (!elButton) {
521 return;
522 }
523 const elDropdown = elButton.closest(DropdownPages.selectors.elDropdown);
524 if (!elDropdown) {
525 return;
526 }
527 this.openQuickAddForm(elDropdown);
528 }
529 handleInputEnter(args) {
530 const {
531 e
532 } = args;
533 e.preventDefault();
534 const elInput = e.target;
535 const elForm = elInput.closest(DropdownPages.selectors.elForm);
536 if (!elForm) {
537 return;
538 }
539 const elButton = elForm.querySelector('button');
540 if (elButton) {
541 elButton.click();
542 }
543 }
544 handleInputEscape(args) {
545 const {
546 e
547 } = args;
548 if (e.key !== 'Escape') {
549 return;
550 }
551 const elInput = e.target;
552 const elForm = elInput.closest(DropdownPages.selectors.elForm);
553 if (!elForm) {
554 return;
555 }
556 const elCancel = elForm.querySelector('a');
557 if (elCancel) {
558 elCancel.click();
559 }
560 }
561 }
562
563 /***/ },
564
565 /***/ "./assets/src/js/admin/utils-admin.js"
566 /*!********************************************!*\
567 !*** ./assets/src/js/admin/utils-admin.js ***!
568 \********************************************/
569 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
570
571 "use strict";
572 __webpack_require__.r(__webpack_exports__);
573 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
574 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
575 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
576 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
577 /* harmony export */ });
578 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
579 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
580 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
581 /**
582 * Library run on Admin
583 *
584 * @since 4.2.6.9
585 * @version 1.0.1
586 */
587
588
589
590 const AdminUtilsFunctions = {
591 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
592 if (!elTomSelect) {
593 return;
594 }
595 const optionDefault = {
596 plugins: {
597 remove_button: {
598 title: 'Remove this item'
599 },
600 dropdown_input: {}
601 },
602 onInitialize() {},
603 onItemAdd(e) {
604 // Get list without current item.
605 if (fetchAPI) {
606 const selectedOptions = Array.from(elTomSelect.selectedOptions);
607 const selectedValues = selectedOptions.map(option => option.value);
608 selectedValues.push(e);
609 dataSend.id_not_in = selectedValues.join(',');
610 fetchAPI('', dataSend, callBackHandleData);
611 }
612 }
613 };
614 if (fetchAPI) {
615 optionDefault.load = (keySearch, callbackTom) => {
616 const selectedOptions = Array.from(elTomSelect.selectedOptions);
617 const selectedValues = selectedOptions.map(option => option.value);
618 dataSend.id_not_in = selectedValues.join(',');
619 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
620 };
621 }
622 options = {
623 ...optionDefault,
624 ...options
625 };
626 const items_selected = options.options;
627 /*if ( options?.options?.length > 20 ) {
628 const chunkSize = 20;
629 const length = options.options.length;
630 let i = 0;
631 const chunkedOptions = { ...options };
632 chunkedOptions.options = items_selected.slice( i, chunkSize );
633 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
634 i += chunkSize;
635 const interval = setInterval( () => {
636 if ( i > ( length - 1 ) ) {
637 clearInterval( interval );
638 }
639 const optionsSlice = items_selected.slice( i, i + chunkSize );
640 i += chunkSize;
641 tomSelect.addOptions( optionsSlice );
642 tomSelect.setValue( options.items );
643 }, 200 );
644 return tomSelect;
645 }*/
646
647 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
648 },
649 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
650 return {
651 success: response => {
652 const options = callBackHandleData.success(response);
653 callbackTom(options);
654 }
655 };
656 },
657 fetchCourses(keySearch = '', dataSend = {}, callback) {
658 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
659 dataSend.search = keySearch;
660 const params = {
661 headers: {
662 'Content-Type': 'application/json',
663 'X-WP-Nonce': lpDataAdmin.nonce
664 },
665 method: 'POST',
666 body: JSON.stringify(dataSend)
667 };
668 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
669 },
670 fetchUsers(keySearch = '', dataSend = {}, callback) {
671 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
672 dataSend.search = keySearch;
673 const params = {
674 headers: {
675 'Content-Type': 'application/json',
676 'X-WP-Nonce': lpDataAdmin.nonce
677 },
678 method: 'POST',
679 body: JSON.stringify(dataSend)
680 };
681 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
682 }
683 };
684
685
686 /***/ },
687
688 /***/ "./assets/src/js/api.js"
689 /*!******************************!*\
690 !*** ./assets/src/js/api.js ***!
691 \******************************/
692 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
693
694 "use strict";
695 __webpack_require__.r(__webpack_exports__);
696 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
697 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
698 /* harmony export */ });
699 /**
700 * List API on backend
701 *
702 * @since 4.2.6
703 * @version 1.0.2
704 */
705
706 const lplistAPI = {};
707 let lp_rest_url;
708 if ('undefined' !== typeof lpDataAdmin) {
709 lp_rest_url = lpDataAdmin.lp_rest_url;
710 lplistAPI.admin = {
711 // apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
712 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
713 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
714 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
715 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
716 };
717 }
718 if ('undefined' !== typeof lpData) {
719 lp_rest_url = lpData.lp_rest_url;
720 lplistAPI.frontend = {
721 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
722 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
723 // Deprecated API, don't load from v4.3.7
724 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
725 // Deprecated since 4.3.0
726 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
727 };
728 }
729 if (lp_rest_url) {
730 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
731 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
732 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
733 }
734 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
735
736 /***/ },
737
738 /***/ "./assets/src/js/lpToastify.js"
739 /*!*************************************!*\
740 !*** ./assets/src/js/lpToastify.js ***!
741 \*************************************/
742 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
743
744 "use strict";
745 __webpack_require__.r(__webpack_exports__);
746 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
747 /* harmony export */ show: () => (/* binding */ show)
748 /* harmony export */ });
749 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
750 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
751 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
752 /**
753 * Utils functions
754 *
755 * @param url
756 * @param data
757 * @param functions
758 * @since 4.3.0
759 * @version 1.0.0
760 */
761
762
763 const argsToastify = {
764 text: '',
765 gravity: lpData.toast.gravity,
766 // `top` or `bottom`
767 position: lpData.toast.position,
768 // `left`, `center` or `right`
769 className: `${lpData.toast.classPrefix}`,
770 close: lpData.toast.close == 1,
771 stopOnFocus: lpData.toast.stopOnFocus == 1,
772 duration: lpData.toast.duration
773 };
774 const show = (message, status = 'success', argsCustom) => {
775 let args = argsToastify;
776 if (argsCustom) {
777 args = {
778 ...args,
779 ...argsCustom
780 };
781 }
782 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
783 ...args,
784 text: message,
785 className: `${lpData.toast.classPrefix} ${status}`
786 });
787 toastify.showToast();
788 };
789
790 /***/ },
791
792 /***/ "./assets/src/js/utils.js"
793 /*!********************************!*\
794 !*** ./assets/src/js/utils.js ***!
795 \********************************/
796 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
797
798 "use strict";
799 __webpack_require__.r(__webpack_exports__);
800 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
801 /* harmony export */ debounce: () => (/* binding */ debounce),
802 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
803 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
804 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
805 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
806 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
807 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
808 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
809 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
810 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
811 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
812 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
813 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
814 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
815 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
816 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
817 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
818 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
819 /* harmony export */ });
820 /**
821 * Utils functions
822 *
823 * @param url
824 * @param data
825 * @param functions
826 * @since 4.2.5.1
827 * @version 1.0.7
828 */
829 const lpClassName = {
830 hidden: 'lp-hidden',
831 loading: 'loading',
832 elCollapse: 'lp-collapse',
833 elSectionToggle: '.lp-section-toggle',
834 elTriggerToggle: '.lp-trigger-toggle',
835 elBtnFullScreen: '.lp-btn-full-screen-view',
836 elFullScreen: 'lp-full-screen-view',
837 elBtnFullScreenClose: 'lp-full-screen-view__close'
838 };
839 const lpFetchAPI = (url, data = {}, functions = {}) => {
840 if ('function' === typeof functions.before) {
841 functions.before();
842 }
843 fetch(url, {
844 method: 'GET',
845 ...data
846 }).then(response => response.json()).then(response => {
847 if ('function' === typeof functions.success) {
848 functions.success(response);
849 }
850 }).catch(err => {
851 if ('function' === typeof functions.error) {
852 functions.error(err);
853 }
854 }).finally(() => {
855 if ('function' === typeof functions.completed) {
856 functions.completed();
857 }
858 });
859 };
860
861 /**
862 * Get current URL without params.
863 *
864 * @since 4.2.5.1
865 */
866 const lpGetCurrentURLNoParam = () => {
867 let currentUrl = window.location.href;
868 const hasParams = currentUrl.includes('?');
869 if (hasParams) {
870 currentUrl = currentUrl.split('?')[0];
871 }
872 return currentUrl;
873 };
874 const lpAddQueryArgs = (endpoint, args) => {
875 const url = new URL(endpoint);
876 Object.keys(args).forEach(arg => {
877 url.searchParams.set(arg, args[arg]);
878 });
879 return url;
880 };
881
882 /**
883 * Listen element viewed.
884 *
885 * @param el
886 * @param callback
887 * @since 4.2.5.8
888 */
889 const listenElementViewed = (el, callback) => {
890 const observerSeeItem = new IntersectionObserver(function (entries) {
891 for (const entry of entries) {
892 if (entry.isIntersecting) {
893 callback(entry);
894 }
895 }
896 });
897 observerSeeItem.observe(el);
898 };
899
900 /**
901 * Listen element created.
902 *
903 * @param callback
904 * @since 4.2.5.8
905 */
906 const listenElementCreated = callback => {
907 const observerCreateItem = new MutationObserver(function (mutations) {
908 mutations.forEach(function (mutation) {
909 if (mutation.addedNodes) {
910 mutation.addedNodes.forEach(function (node) {
911 if (node.nodeType === 1) {
912 callback(node);
913 }
914 });
915 }
916 });
917 });
918 observerCreateItem.observe(document, {
919 childList: true,
920 subtree: true
921 });
922 // End.
923 };
924
925 /**
926 * Listen element created.
927 *
928 * @param selector
929 * @param callback
930 * @since 4.2.7.1
931 */
932 const lpOnElementReady = (selector, callback) => {
933 const element = document.querySelector(selector);
934 if (element) {
935 callback(element);
936 return;
937 }
938 const observer = new MutationObserver((mutations, obs) => {
939 const element = document.querySelector(selector);
940 if (element) {
941 obs.disconnect();
942 callback(element);
943 }
944 });
945 observer.observe(document.documentElement, {
946 childList: true,
947 subtree: true
948 });
949 };
950
951 // Parse JSON from string with content include LP_AJAX_START.
952 const lpAjaxParseJsonOld = data => {
953 if (typeof data !== 'string') {
954 return data;
955 }
956 const m = String.raw({
957 raw: data
958 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
959 try {
960 if (m) {
961 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
962 } else {
963 data = JSON.parse(data);
964 }
965 } catch (e) {
966 data = {};
967 }
968 return data;
969 };
970
971 // status 0: hide, 1: show
972 const lpShowHideEl = (el, status = 0) => {
973 if (!el) {
974 return;
975 }
976 if (!status) {
977 el.classList.add(lpClassName.hidden);
978 } else {
979 el.classList.remove(lpClassName.hidden);
980 }
981 };
982
983 // status 0: hide, 1: show
984 const lpSetLoadingEl = (el, status) => {
985 if (!el) {
986 return;
987 }
988 if (!status) {
989 el.classList.remove(lpClassName.loading);
990 } else {
991 el.classList.add(lpClassName.loading);
992 }
993 };
994
995 // Toggle collapse section
996 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
997 if (!elTriggerClassName) {
998 elTriggerClassName = lpClassName.elTriggerToggle;
999 }
1000
1001 // Exclude elements, which should not trigger the collapse toggle
1002 if (elsExclude && elsExclude.length > 0) {
1003 for (const elExclude of elsExclude) {
1004 if (target.closest(elExclude)) {
1005 return;
1006 }
1007 }
1008 }
1009 const elTrigger = target.closest(elTriggerClassName);
1010 if (!elTrigger) {
1011 return;
1012 }
1013
1014 //console.log( 'elTrigger', elTrigger );
1015
1016 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1017 if (!elSectionToggle) {
1018 return;
1019 }
1020 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1021 if ('function' === typeof callback) {
1022 callback(elSectionToggle);
1023 }
1024 };
1025
1026 // Get data of form
1027 const getDataOfForm = form => {
1028 const dataSend = {};
1029 const formData = new FormData(form);
1030 for (const pair of formData.entries()) {
1031 const key = pair[0];
1032 const value = formData.getAll(key);
1033 if (!dataSend.hasOwnProperty(key)) {
1034 // Convert value array to string.
1035 dataSend[key] = value.join(',');
1036 }
1037 }
1038 return dataSend;
1039 };
1040
1041 // Get field keys of form
1042 const getFieldKeysOfForm = form => {
1043 const keys = [];
1044 const elements = form.elements;
1045 for (let i = 0; i < elements.length; i++) {
1046 const name = elements[i].name;
1047 if (name && !keys.includes(name)) {
1048 keys.push(name);
1049 }
1050 }
1051 return keys;
1052 };
1053
1054 // Merge data handle with data form.
1055 const mergeDataWithDatForm = (elForm, dataHandle) => {
1056 const dataForm = getDataOfForm(elForm);
1057 const keys = getFieldKeysOfForm(elForm);
1058 keys.forEach(key => {
1059 if (!dataForm.hasOwnProperty(key)) {
1060 delete dataHandle[key];
1061 } else if (dataForm[key][0] === '') {
1062 delete dataForm[key];
1063 delete dataHandle[key];
1064 }
1065 });
1066 dataHandle = {
1067 ...dataHandle,
1068 ...dataForm
1069 };
1070 return dataHandle;
1071 };
1072
1073 /**
1074 * Event trigger
1075 * For each list of event handlers, listen event on document.
1076 *
1077 * eventName: 'click', 'change', ...
1078 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1079 *
1080 * @param eventName
1081 * @param eventHandlers
1082 */
1083 const eventHandlers = (eventName, eventHandlers) => {
1084 document.addEventListener(eventName, e => {
1085 const target = e.target;
1086 let args = {
1087 e,
1088 target
1089 };
1090 eventHandlers.forEach(eventHandler => {
1091 args = {
1092 ...args,
1093 ...eventHandler
1094 };
1095
1096 //console.log( args );
1097
1098 // Check condition before call back
1099 if (eventHandler.conditionBeforeCallBack) {
1100 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1101 return;
1102 }
1103 }
1104
1105 // Special check for keydown event with checkIsEventEnter = true
1106 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1107 if (e.key !== 'Enter') {
1108 return;
1109 }
1110 }
1111 if (target.closest(eventHandler.selector)) {
1112 if (eventHandler.class) {
1113 // Call method of class, function callBack will understand exactly {this} is class object.
1114 eventHandler.class[eventHandler.callBack](args);
1115 } else {
1116 // For send args is objected, {this} is eventHandler object, not class object.
1117 eventHandler.callBack(args);
1118 }
1119 }
1120 });
1121 });
1122 };
1123
1124 /**
1125 * Debounce - delays function execution until after `wait` ms of inactivity.
1126 *
1127 * Each call resets the timer. Only the last call in a burst executes.
1128 *
1129 * USE CASES:
1130 * - Search inputs, form validation, window resize
1131 * - Multiple elements need independent timers
1132 * - When you need to call with different arguments
1133 *
1134 * EXAMPLES:
1135 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1136 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1137 *
1138 * const debouncedResize = debounce( recalculateLayout, 250 );
1139 * window.addEventListener('resize', debouncedResize);
1140 *
1141 * ⚠️ Create ONCE outside event handlers, not inside.
1142 *
1143 * @param {Function} func - Function to debounce (can be anonymous)
1144 * @param {number} wait - Milliseconds to wait (default: 500)
1145 * @return {Function} Debounced wrapper function
1146 * @since 4.3.7
1147 * @version 1.0.0
1148 */
1149 const debounce = (func, wait = 500) => {
1150 let timer;
1151 return args => {
1152 clearTimeout(timer);
1153 timer = setTimeout(() => func(args), wait);
1154 };
1155 };
1156
1157 /**
1158 * Initialize lp-toggle-enable components.
1159 *
1160 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1161 * Reads initial state from `data-enabled` attribute ("true"/"false").
1162 * Calls `data-on-toggle` callback (if provided via options) on state change.
1163 *
1164 * HTML structure:
1165 * <label class="lp-toggle-enable" data-enabled="true">
1166 * <input type="checkbox" class="lp-toggle-enable__input" />
1167 * <span class="lp-toggle-enable__track"></span>
1168 * </label>
1169 *
1170 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1171 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1172 * @since 4.4.5
1173 * @version 1.0.0
1174 */
1175 window.lpToggleEnableInit = 0;
1176 const toggleEnable = (onToggle = null) => {
1177 if (window.lpToggleEnableInit) {
1178 return;
1179 }
1180 window.lpToggleEnableInit = 1;
1181 const selector = '.lp-toggle-enable';
1182 const updateUI = (toggle, isEnabled) => {
1183 toggle.classList.toggle('is-enabled', isEnabled);
1184 const input = toggle.querySelector('.lp-toggle-enable__input');
1185 if (input) {
1186 input.checked = isEnabled;
1187 input.value = isEnabled ? '1' : '0';
1188 }
1189 };
1190
1191 // Delegate click handling via eventHandlers.
1192 eventHandlers('click', [{
1193 selector,
1194 callBack: args => {
1195 const {
1196 e,
1197 target
1198 } = args;
1199 const toggle = target.closest(selector);
1200 if (!toggle || toggle.classList.contains('is-disabled')) {
1201 return;
1202 }
1203 e.preventDefault();
1204 const isEnabled = !toggle.classList.contains('is-enabled');
1205 updateUI(toggle, isEnabled);
1206 if ('function' === typeof onToggle) {
1207 onToggle(toggle, isEnabled);
1208 }
1209 }
1210 }]);
1211 };
1212
1213 /**
1214 * Initialize custom fullscreen view buttons.
1215 *
1216 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1217 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1218 * target element. Falls back to the button's parent element when
1219 * `data-target` is not provided.
1220 *
1221 * @since 4.4.5
1222 * @version 1.0.0
1223 */
1224 window.lpFullScreenViewInit = 0;
1225 const fullScreenView = () => {
1226 if (window.lpFullScreenViewInit) {
1227 return;
1228 }
1229 window.lpFullScreenViewInit = 1;
1230 let lastScrollY = 0;
1231 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1232 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1233 if (isFullscreen) {
1234 elTarget.classList.remove(lpClassName.elFullScreen);
1235 document.documentElement.classList.remove('lp-full-screen-active');
1236 window.scrollTo(0, lastScrollY);
1237 } else {
1238 lastScrollY = window.scrollY;
1239 elTarget.classList.add(lpClassName.elFullScreen);
1240 document.documentElement.classList.add('lp-full-screen-active');
1241 }
1242 if (!isFullscreen) {
1243 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1244 const closeButton = document.createElement('button');
1245 closeButton.type = 'button';
1246 closeButton.className = lpClassName.elBtnFullScreenClose;
1247 closeButton.setAttribute('aria-label', 'Close');
1248 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1249 closeButton.addEventListener('click', e => {
1250 e.preventDefault();
1251 lpToggleFullscreenView(elTarget);
1252 });
1253 elTarget.appendChild(closeButton);
1254 }
1255 } else {
1256 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1257 if (closeButton) {
1258 closeButton.remove();
1259 }
1260 }
1261 };
1262 eventHandlers('click', [{
1263 selector: lpClassName.elBtnFullScreen,
1264 callBack: args => {
1265 const {
1266 e,
1267 target
1268 } = args;
1269 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1270 if (!elBtnFullScreen) {
1271 console.log('No full screen button found');
1272 return;
1273 }
1274 e.preventDefault();
1275 let elTarget = null;
1276 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
1277 console.log(targetSelector);
1278 if (targetSelector) {
1279 elTarget = document.querySelector(targetSelector);
1280 }
1281 if (!elTarget) {
1282 console.log('No target element found');
1283 return;
1284 }
1285 lpToggleFullscreenView(elTarget, elBtnFullScreen);
1286 }
1287 }]);
1288 };
1289
1290 /***/ },
1291
1292 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1293 /*!*****************************************************************************************!*\
1294 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1295 \*****************************************************************************************/
1296 (module, __webpack_exports__, __webpack_require__) {
1297
1298 "use strict";
1299 __webpack_require__.r(__webpack_exports__);
1300 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1301 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1302 /* harmony export */ });
1303 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
1304 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
1305 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
1306 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
1307 // Imports
1308
1309
1310 var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
1311 // Module
1312 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1313 * Toastify js 1.12.0
1314 * https://github.com/apvarun/toastify-js
1315 * @license MIT licensed
1316 *
1317 * Copyright (C) 2018 Varun A P
1318 */
1319
1320 .toastify {
1321 padding: 12px 20px;
1322 color: #ffffff;
1323 display: inline-block;
1324 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1325 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1326 background: linear-gradient(135deg, #73a5ff, #5477f5);
1327 position: fixed;
1328 opacity: 0;
1329 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1330 border-radius: 2px;
1331 cursor: pointer;
1332 text-decoration: none;
1333 max-width: calc(50% - 20px);
1334 z-index: 2147483647;
1335 }
1336
1337 .toastify.on {
1338 opacity: 1;
1339 }
1340
1341 .toast-close {
1342 background: transparent;
1343 border: 0;
1344 color: white;
1345 cursor: pointer;
1346 font-family: inherit;
1347 font-size: 1em;
1348 opacity: 0.4;
1349 padding: 0 5px;
1350 }
1351
1352 .toastify-right {
1353 right: 15px;
1354 }
1355
1356 .toastify-left {
1357 left: 15px;
1358 }
1359
1360 .toastify-top {
1361 top: -150px;
1362 }
1363
1364 .toastify-bottom {
1365 bottom: -150px;
1366 }
1367
1368 .toastify-rounded {
1369 border-radius: 25px;
1370 }
1371
1372 .toastify-avatar {
1373 width: 1.5em;
1374 height: 1.5em;
1375 margin: -7px 5px;
1376 border-radius: 2px;
1377 }
1378
1379 .toastify-center {
1380 margin-left: auto;
1381 margin-right: auto;
1382 left: 0;
1383 right: 0;
1384 max-width: fit-content;
1385 max-width: -moz-fit-content;
1386 }
1387
1388 @media only screen and (max-width: 360px) {
1389 .toastify-right, .toastify-left {
1390 margin-left: auto;
1391 margin-right: auto;
1392 left: 0;
1393 right: 0;
1394 max-width: fit-content;
1395 }
1396 }
1397 `, "",{"version":3,"sources":["webpack://./node_modules/toastify-js/src/toastify.css"],"names":[],"mappings":"AAAA;;;;;;EAME;;AAEF;IACI,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,uFAAuF;IACvF,6DAA6D;IAC7D,qDAAqD;IACrD,eAAe;IACf,UAAU;IACV,wDAAwD;IACxD,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,2BAA2B;IAC3B,mBAAmB;AACvB;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,uBAAuB;IACvB,SAAS;IACT,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,cAAc;AAClB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,sBAAsB;IACtB,2BAA2B;AAC/B;;AAEA;IACI;QACI,iBAAiB;QACjB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,sBAAsB;IAC1B;AACJ","sourcesContent":["/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n"],"sourceRoot":""}]);
1398 // Exports
1399 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1400
1401
1402 /***/ },
1403
1404 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1405 /*!*****************************************************!*\
1406 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1407 \*****************************************************/
1408 (module) {
1409
1410 "use strict";
1411
1412
1413 /*
1414 MIT License http://www.opensource.org/licenses/mit-license.php
1415 Author Tobias Koppers @sokra
1416 */
1417 module.exports = function (cssWithMappingToString) {
1418 var list = [];
1419
1420 // return the list of modules as css string
1421 list.toString = function toString() {
1422 return this.map(function (item) {
1423 var content = "";
1424 var needLayer = typeof item[5] !== "undefined";
1425 if (item[4]) {
1426 content += "@supports (".concat(item[4], ") {");
1427 }
1428 if (item[2]) {
1429 content += "@media ".concat(item[2], " {");
1430 }
1431 if (needLayer) {
1432 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1433 }
1434 content += cssWithMappingToString(item);
1435 if (needLayer) {
1436 content += "}";
1437 }
1438 if (item[2]) {
1439 content += "}";
1440 }
1441 if (item[4]) {
1442 content += "}";
1443 }
1444 return content;
1445 }).join("");
1446 };
1447
1448 // import a list of modules into the list
1449 list.i = function i(modules, media, dedupe, supports, layer) {
1450 if (typeof modules === "string") {
1451 modules = [[null, modules, undefined]];
1452 }
1453 var alreadyImportedModules = {};
1454 if (dedupe) {
1455 for (var k = 0; k < this.length; k++) {
1456 var id = this[k][0];
1457 if (id != null) {
1458 alreadyImportedModules[id] = true;
1459 }
1460 }
1461 }
1462 for (var _k = 0; _k < modules.length; _k++) {
1463 var item = [].concat(modules[_k]);
1464 if (dedupe && alreadyImportedModules[item[0]]) {
1465 continue;
1466 }
1467 if (typeof layer !== "undefined") {
1468 if (typeof item[5] === "undefined") {
1469 item[5] = layer;
1470 } else {
1471 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1472 item[5] = layer;
1473 }
1474 }
1475 if (media) {
1476 if (!item[2]) {
1477 item[2] = media;
1478 } else {
1479 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1480 item[2] = media;
1481 }
1482 }
1483 if (supports) {
1484 if (!item[4]) {
1485 item[4] = "".concat(supports);
1486 } else {
1487 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1488 item[4] = supports;
1489 }
1490 }
1491 list.push(item);
1492 }
1493 };
1494 return list;
1495 };
1496
1497 /***/ },
1498
1499 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1500 /*!************************************************************!*\
1501 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1502 \************************************************************/
1503 (module) {
1504
1505 "use strict";
1506
1507
1508 module.exports = function (item) {
1509 var content = item[1];
1510 var cssMapping = item[3];
1511 if (!cssMapping) {
1512 return content;
1513 }
1514 if (typeof btoa === "function") {
1515 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1516 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1517 var sourceMapping = "/*# ".concat(data, " */");
1518 return [content].concat([sourceMapping]).join("\n");
1519 }
1520 return [content].join("\n");
1521 };
1522
1523 /***/ },
1524
1525 /***/ "./node_modules/toastify-js/src/toastify.css"
1526 /*!***************************************************!*\
1527 !*** ./node_modules/toastify-js/src/toastify.css ***!
1528 \***************************************************/
1529 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1530
1531 "use strict";
1532 __webpack_require__.r(__webpack_exports__);
1533 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1534 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1535 /* harmony export */ });
1536 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
1537 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
1538 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");
1539 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);
1540 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");
1541 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);
1542 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");
1543 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);
1544 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");
1545 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);
1546 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");
1547 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);
1548 /* harmony import */ var _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./toastify.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css");
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560 var options = {};
1561
1562 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1563 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1564
1565 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1566
1567 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1568 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1569
1570 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
1571
1572
1573
1574
1575 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
1576
1577
1578 /***/ },
1579
1580 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1581 /*!****************************************************************************!*\
1582 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1583 \****************************************************************************/
1584 (module) {
1585
1586 "use strict";
1587
1588
1589 var stylesInDOM = [];
1590 function getIndexByIdentifier(identifier) {
1591 var result = -1;
1592 for (var i = 0; i < stylesInDOM.length; i++) {
1593 if (stylesInDOM[i].identifier === identifier) {
1594 result = i;
1595 break;
1596 }
1597 }
1598 return result;
1599 }
1600 function modulesToDom(list, options) {
1601 var idCountMap = {};
1602 var identifiers = [];
1603 for (var i = 0; i < list.length; i++) {
1604 var item = list[i];
1605 var id = options.base ? item[0] + options.base : item[0];
1606 var count = idCountMap[id] || 0;
1607 var identifier = "".concat(id, " ").concat(count);
1608 idCountMap[id] = count + 1;
1609 var indexByIdentifier = getIndexByIdentifier(identifier);
1610 var obj = {
1611 css: item[1],
1612 media: item[2],
1613 sourceMap: item[3],
1614 supports: item[4],
1615 layer: item[5]
1616 };
1617 if (indexByIdentifier !== -1) {
1618 stylesInDOM[indexByIdentifier].references++;
1619 stylesInDOM[indexByIdentifier].updater(obj);
1620 } else {
1621 var updater = addElementStyle(obj, options);
1622 options.byIndex = i;
1623 stylesInDOM.splice(i, 0, {
1624 identifier: identifier,
1625 updater: updater,
1626 references: 1
1627 });
1628 }
1629 identifiers.push(identifier);
1630 }
1631 return identifiers;
1632 }
1633 function addElementStyle(obj, options) {
1634 var api = options.domAPI(options);
1635 api.update(obj);
1636 var updater = function updater(newObj) {
1637 if (newObj) {
1638 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1639 return;
1640 }
1641 api.update(obj = newObj);
1642 } else {
1643 api.remove();
1644 }
1645 };
1646 return updater;
1647 }
1648 module.exports = function (list, options) {
1649 options = options || {};
1650 list = list || [];
1651 var lastIdentifiers = modulesToDom(list, options);
1652 return function update(newList) {
1653 newList = newList || [];
1654 for (var i = 0; i < lastIdentifiers.length; i++) {
1655 var identifier = lastIdentifiers[i];
1656 var index = getIndexByIdentifier(identifier);
1657 stylesInDOM[index].references--;
1658 }
1659 var newLastIdentifiers = modulesToDom(newList, options);
1660 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1661 var _identifier = lastIdentifiers[_i];
1662 var _index = getIndexByIdentifier(_identifier);
1663 if (stylesInDOM[_index].references === 0) {
1664 stylesInDOM[_index].updater();
1665 stylesInDOM.splice(_index, 1);
1666 }
1667 }
1668 lastIdentifiers = newLastIdentifiers;
1669 };
1670 };
1671
1672 /***/ },
1673
1674 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1675 /*!********************************************************************!*\
1676 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1677 \********************************************************************/
1678 (module) {
1679
1680 "use strict";
1681
1682
1683 var memo = {};
1684
1685 /* istanbul ignore next */
1686 function getTarget(target) {
1687 if (typeof memo[target] === "undefined") {
1688 var styleTarget = document.querySelector(target);
1689
1690 // Special case to return head of iframe instead of iframe itself
1691 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1692 try {
1693 // This will throw an exception if access to iframe is blocked
1694 // due to cross-origin restrictions
1695 styleTarget = styleTarget.contentDocument.head;
1696 } catch (e) {
1697 // istanbul ignore next
1698 styleTarget = null;
1699 }
1700 }
1701 memo[target] = styleTarget;
1702 }
1703 return memo[target];
1704 }
1705
1706 /* istanbul ignore next */
1707 function insertBySelector(insert, style) {
1708 var target = getTarget(insert);
1709 if (!target) {
1710 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1711 }
1712 target.appendChild(style);
1713 }
1714 module.exports = insertBySelector;
1715
1716 /***/ },
1717
1718 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1719 /*!**********************************************************************!*\
1720 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1721 \**********************************************************************/
1722 (module) {
1723
1724 "use strict";
1725
1726
1727 /* istanbul ignore next */
1728 function insertStyleElement(options) {
1729 var element = document.createElement("style");
1730 options.setAttributes(element, options.attributes);
1731 options.insert(element, options.options);
1732 return element;
1733 }
1734 module.exports = insertStyleElement;
1735
1736 /***/ },
1737
1738 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1739 /*!**********************************************************************************!*\
1740 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1741 \**********************************************************************************/
1742 (module, __unused_webpack_exports, __webpack_require__) {
1743
1744 "use strict";
1745
1746
1747 /* istanbul ignore next */
1748 function setAttributesWithoutAttributes(styleElement) {
1749 var nonce = true ? __webpack_require__.nc : 0;
1750 if (nonce) {
1751 styleElement.setAttribute("nonce", nonce);
1752 }
1753 }
1754 module.exports = setAttributesWithoutAttributes;
1755
1756 /***/ },
1757
1758 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1759 /*!***************************************************************!*\
1760 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1761 \***************************************************************/
1762 (module) {
1763
1764 "use strict";
1765
1766
1767 /* istanbul ignore next */
1768 function apply(styleElement, options, obj) {
1769 var css = "";
1770 if (obj.supports) {
1771 css += "@supports (".concat(obj.supports, ") {");
1772 }
1773 if (obj.media) {
1774 css += "@media ".concat(obj.media, " {");
1775 }
1776 var needLayer = typeof obj.layer !== "undefined";
1777 if (needLayer) {
1778 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1779 }
1780 css += obj.css;
1781 if (needLayer) {
1782 css += "}";
1783 }
1784 if (obj.media) {
1785 css += "}";
1786 }
1787 if (obj.supports) {
1788 css += "}";
1789 }
1790 var sourceMap = obj.sourceMap;
1791 if (sourceMap && typeof btoa !== "undefined") {
1792 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1793 }
1794
1795 // For old IE
1796 /* istanbul ignore if */
1797 options.styleTagTransform(css, styleElement, options.options);
1798 }
1799 function removeStyleElement(styleElement) {
1800 // istanbul ignore if
1801 if (styleElement.parentNode === null) {
1802 return false;
1803 }
1804 styleElement.parentNode.removeChild(styleElement);
1805 }
1806
1807 /* istanbul ignore next */
1808 function domAPI(options) {
1809 if (typeof document === "undefined") {
1810 return {
1811 update: function update() {},
1812 remove: function remove() {}
1813 };
1814 }
1815 var styleElement = options.insertStyleElement(options);
1816 return {
1817 update: function update(obj) {
1818 apply(styleElement, options, obj);
1819 },
1820 remove: function remove() {
1821 removeStyleElement(styleElement);
1822 }
1823 };
1824 }
1825 module.exports = domAPI;
1826
1827 /***/ },
1828
1829 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1830 /*!*********************************************************************!*\
1831 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1832 \*********************************************************************/
1833 (module) {
1834
1835 "use strict";
1836
1837
1838 /* istanbul ignore next */
1839 function styleTagTransform(css, styleElement) {
1840 if (styleElement.styleSheet) {
1841 styleElement.styleSheet.cssText = css;
1842 } else {
1843 while (styleElement.firstChild) {
1844 styleElement.removeChild(styleElement.firstChild);
1845 }
1846 styleElement.appendChild(document.createTextNode(css));
1847 }
1848 }
1849 module.exports = styleTagTransform;
1850
1851 /***/ },
1852
1853 /***/ "./node_modules/toastify-js/src/toastify.js"
1854 /*!**************************************************!*\
1855 !*** ./node_modules/toastify-js/src/toastify.js ***!
1856 \**************************************************/
1857 (module) {
1858
1859 /*!
1860 * Toastify js 1.12.0
1861 * https://github.com/apvarun/toastify-js
1862 * @license MIT licensed
1863 *
1864 * Copyright (C) 2018 Varun A P
1865 */
1866 (function(root, factory) {
1867 if ( true && module.exports) {
1868 module.exports = factory();
1869 } else {
1870 root.Toastify = factory();
1871 }
1872 })(this, function(global) {
1873 // Object initialization
1874 var Toastify = function(options) {
1875 // Returning a new init object
1876 return new Toastify.lib.init(options);
1877 },
1878 // Library version
1879 version = "1.12.0";
1880
1881 // Set the default global options
1882 Toastify.defaults = {
1883 oldestFirst: true,
1884 text: "Toastify is awesome!",
1885 node: undefined,
1886 duration: 3000,
1887 selector: undefined,
1888 callback: function () {
1889 },
1890 destination: undefined,
1891 newWindow: false,
1892 close: false,
1893 gravity: "toastify-top",
1894 positionLeft: false,
1895 position: '',
1896 backgroundColor: '',
1897 avatar: "",
1898 className: "",
1899 stopOnFocus: true,
1900 onClick: function () {
1901 },
1902 offset: {x: 0, y: 0},
1903 escapeMarkup: true,
1904 ariaLive: 'polite',
1905 style: {background: ''}
1906 };
1907
1908 // Defining the prototype of the object
1909 Toastify.lib = Toastify.prototype = {
1910 toastify: version,
1911
1912 constructor: Toastify,
1913
1914 // Initializing the object with required parameters
1915 init: function(options) {
1916 // Verifying and validating the input object
1917 if (!options) {
1918 options = {};
1919 }
1920
1921 // Creating the options object
1922 this.options = {};
1923
1924 this.toastElement = null;
1925
1926 // Validating the options
1927 this.options.text = options.text || Toastify.defaults.text; // Display message
1928 this.options.node = options.node || Toastify.defaults.node; // Display content as node
1929 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
1930 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
1931 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
1932 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
1933 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
1934 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
1935 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
1936 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
1937 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
1938 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
1939 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
1940 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
1941 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
1942 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
1943 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
1944 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
1945 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
1946 this.options.style = options.style || Toastify.defaults.style;
1947 if(options.backgroundColor) {
1948 this.options.style.background = options.backgroundColor;
1949 }
1950
1951 // Returning the current object for chaining functions
1952 return this;
1953 },
1954
1955 // Building the DOM element
1956 buildToast: function() {
1957 // Validating if the options are defined
1958 if (!this.options) {
1959 throw "Toastify is not initialized";
1960 }
1961
1962 // Creating the DOM object
1963 var divElement = document.createElement("div");
1964 divElement.className = "toastify on " + this.options.className;
1965
1966 // Positioning toast to left or right or center
1967 if (!!this.options.position) {
1968 divElement.className += " toastify-" + this.options.position;
1969 } else {
1970 // To be depreciated in further versions
1971 if (this.options.positionLeft === true) {
1972 divElement.className += " toastify-left";
1973 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
1974 } else {
1975 // Default position
1976 divElement.className += " toastify-right";
1977 }
1978 }
1979
1980 // Assigning gravity of element
1981 divElement.className += " " + this.options.gravity;
1982
1983 if (this.options.backgroundColor) {
1984 // This is being deprecated in favor of using the style HTML DOM property
1985 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
1986 }
1987
1988 // Loop through our style object and apply styles to divElement
1989 for (var property in this.options.style) {
1990 divElement.style[property] = this.options.style[property];
1991 }
1992
1993 // Announce the toast to screen readers
1994 if (this.options.ariaLive) {
1995 divElement.setAttribute('aria-live', this.options.ariaLive)
1996 }
1997
1998 // Adding the toast message/node
1999 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
2000 // If we have a valid node, we insert it
2001 divElement.appendChild(this.options.node)
2002 } else {
2003 if (this.options.escapeMarkup) {
2004 divElement.innerText = this.options.text;
2005 } else {
2006 divElement.innerHTML = this.options.text;
2007 }
2008
2009 if (this.options.avatar !== "") {
2010 var avatarElement = document.createElement("img");
2011 avatarElement.src = this.options.avatar;
2012
2013 avatarElement.className = "toastify-avatar";
2014
2015 if (this.options.position == "left" || this.options.positionLeft === true) {
2016 // Adding close icon on the left of content
2017 divElement.appendChild(avatarElement);
2018 } else {
2019 // Adding close icon on the right of content
2020 divElement.insertAdjacentElement("afterbegin", avatarElement);
2021 }
2022 }
2023 }
2024
2025 // Adding a close icon to the toast
2026 if (this.options.close === true) {
2027 // Create a span for close element
2028 var closeElement = document.createElement("button");
2029 closeElement.type = "button";
2030 closeElement.setAttribute("aria-label", "Close");
2031 closeElement.className = "toast-close";
2032 closeElement.innerHTML = "&#10006;";
2033
2034 // Triggering the removal of toast from DOM on close click
2035 closeElement.addEventListener(
2036 "click",
2037 function(event) {
2038 event.stopPropagation();
2039 this.removeElement(this.toastElement);
2040 window.clearTimeout(this.toastElement.timeOutValue);
2041 }.bind(this)
2042 );
2043
2044 //Calculating screen width
2045 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
2046
2047 // Adding the close icon to the toast element
2048 // Display on the right if screen width is less than or equal to 360px
2049 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
2050 // Adding close icon on the left of content
2051 divElement.insertAdjacentElement("afterbegin", closeElement);
2052 } else {
2053 // Adding close icon on the right of content
2054 divElement.appendChild(closeElement);
2055 }
2056 }
2057
2058 // Clear timeout while toast is focused
2059 if (this.options.stopOnFocus && this.options.duration > 0) {
2060 var self = this;
2061 // stop countdown
2062 divElement.addEventListener(
2063 "mouseover",
2064 function(event) {
2065 window.clearTimeout(divElement.timeOutValue);
2066 }
2067 )
2068 // add back the timeout
2069 divElement.addEventListener(
2070 "mouseleave",
2071 function() {
2072 divElement.timeOutValue = window.setTimeout(
2073 function() {
2074 // Remove the toast from DOM
2075 self.removeElement(divElement);
2076 },
2077 self.options.duration
2078 )
2079 }
2080 )
2081 }
2082
2083 // Adding an on-click destination path
2084 if (typeof this.options.destination !== "undefined") {
2085 divElement.addEventListener(
2086 "click",
2087 function(event) {
2088 event.stopPropagation();
2089 if (this.options.newWindow === true) {
2090 window.open(this.options.destination, "_blank");
2091 } else {
2092 window.location = this.options.destination;
2093 }
2094 }.bind(this)
2095 );
2096 }
2097
2098 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
2099 divElement.addEventListener(
2100 "click",
2101 function(event) {
2102 event.stopPropagation();
2103 this.options.onClick();
2104 }.bind(this)
2105 );
2106 }
2107
2108 // Adding offset
2109 if(typeof this.options.offset === "object") {
2110
2111 var x = getAxisOffsetAValue("x", this.options);
2112 var y = getAxisOffsetAValue("y", this.options);
2113
2114 var xOffset = this.options.position == "left" ? x : "-" + x;
2115 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
2116
2117 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
2118
2119 }
2120
2121 // Returning the generated element
2122 return divElement;
2123 },
2124
2125 // Displaying the toast
2126 showToast: function() {
2127 // Creating the DOM object for the toast
2128 this.toastElement = this.buildToast();
2129
2130 // Getting the root element to with the toast needs to be added
2131 var rootElement;
2132 if (typeof this.options.selector === "string") {
2133 rootElement = document.getElementById(this.options.selector);
2134 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
2135 rootElement = this.options.selector;
2136 } else {
2137 rootElement = document.body;
2138 }
2139
2140 // Validating if root element is present in DOM
2141 if (!rootElement) {
2142 throw "Root element is not defined";
2143 }
2144
2145 // Adding the DOM element
2146 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
2147 rootElement.insertBefore(this.toastElement, elementToInsert);
2148
2149 // Repositioning the toasts in case multiple toasts are present
2150 Toastify.reposition();
2151
2152 if (this.options.duration > 0) {
2153 this.toastElement.timeOutValue = window.setTimeout(
2154 function() {
2155 // Remove the toast from DOM
2156 this.removeElement(this.toastElement);
2157 }.bind(this),
2158 this.options.duration
2159 ); // Binding `this` for function invocation
2160 }
2161
2162 // Supporting function chaining
2163 return this;
2164 },
2165
2166 hideToast: function() {
2167 if (this.toastElement.timeOutValue) {
2168 clearTimeout(this.toastElement.timeOutValue);
2169 }
2170 this.removeElement(this.toastElement);
2171 },
2172
2173 // Removing the element from the DOM
2174 removeElement: function(toastElement) {
2175 // Hiding the element
2176 // toastElement.classList.remove("on");
2177 toastElement.className = toastElement.className.replace(" on", "");
2178
2179 // Removing the element from DOM after transition end
2180 window.setTimeout(
2181 function() {
2182 // remove options node if any
2183 if (this.options.node && this.options.node.parentNode) {
2184 this.options.node.parentNode.removeChild(this.options.node);
2185 }
2186
2187 // Remove the element from the DOM, only when the parent node was not removed before.
2188 if (toastElement.parentNode) {
2189 toastElement.parentNode.removeChild(toastElement);
2190 }
2191
2192 // Calling the callback function
2193 this.options.callback.call(toastElement);
2194
2195 // Repositioning the toasts again
2196 Toastify.reposition();
2197 }.bind(this),
2198 400
2199 ); // Binding `this` for function invocation
2200 },
2201 };
2202
2203 // Positioning the toasts on the DOM
2204 Toastify.reposition = function() {
2205
2206 // Top margins with gravity
2207 var topLeftOffsetSize = {
2208 top: 15,
2209 bottom: 15,
2210 };
2211 var topRightOffsetSize = {
2212 top: 15,
2213 bottom: 15,
2214 };
2215 var offsetSize = {
2216 top: 15,
2217 bottom: 15,
2218 };
2219
2220 // Get all toast messages on the DOM
2221 var allToasts = document.getElementsByClassName("toastify");
2222
2223 var classUsed;
2224
2225 // Modifying the position of each toast element
2226 for (var i = 0; i < allToasts.length; i++) {
2227 // Getting the applied gravity
2228 if (containsClass(allToasts[i], "toastify-top") === true) {
2229 classUsed = "toastify-top";
2230 } else {
2231 classUsed = "toastify-bottom";
2232 }
2233
2234 var height = allToasts[i].offsetHeight;
2235 classUsed = classUsed.substr(9, classUsed.length-1)
2236 // Spacing between toasts
2237 var offset = 15;
2238
2239 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
2240
2241 // Show toast in center if screen with less than or equal to 360px
2242 if (width <= 360) {
2243 // Setting the position
2244 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
2245
2246 offsetSize[classUsed] += height + offset;
2247 } else {
2248 if (containsClass(allToasts[i], "toastify-left") === true) {
2249 // Setting the position
2250 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
2251
2252 topLeftOffsetSize[classUsed] += height + offset;
2253 } else {
2254 // Setting the position
2255 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
2256
2257 topRightOffsetSize[classUsed] += height + offset;
2258 }
2259 }
2260 }
2261
2262 // Supporting function chaining
2263 return this;
2264 };
2265
2266 // Helper function to get offset.
2267 function getAxisOffsetAValue(axis, options) {
2268
2269 if(options.offset[axis]) {
2270 if(isNaN(options.offset[axis])) {
2271 return options.offset[axis];
2272 }
2273 else {
2274 return options.offset[axis] + 'px';
2275 }
2276 }
2277
2278 return '0px';
2279
2280 }
2281
2282 function containsClass(elem, yourClass) {
2283 if (!elem || typeof yourClass !== "string") {
2284 return false;
2285 } else if (
2286 elem.className &&
2287 elem.className
2288 .trim()
2289 .split(/\s+/gi)
2290 .indexOf(yourClass) > -1
2291 ) {
2292 return true;
2293 } else {
2294 return false;
2295 }
2296 }
2297
2298 // Setting up the prototype for the init object
2299 Toastify.lib.init.prototype = Toastify.lib;
2300
2301 // Returning the Toastify function to be assigned to the window object/module
2302 return Toastify;
2303 });
2304
2305
2306 /***/ },
2307
2308 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
2309 /*!**********************************************************!*\
2310 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
2311 \**********************************************************/
2312 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2313
2314 "use strict";
2315 __webpack_require__.r(__webpack_exports__);
2316 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2317 /* harmony export */ Sifter: () => (/* binding */ Sifter),
2318 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
2319 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
2320 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
2321 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
2322 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
2323 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
2324 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
2325 /* harmony export */ });
2326 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
2327 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
2328 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
2329 /**
2330 * sifter.js
2331 * Copyright (c) 2013–2020 Brian Reavis & contributors
2332 *
2333 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2334 * file except in compliance with the License. You may obtain a copy of the License at:
2335 * http://www.apache.org/licenses/LICENSE-2.0
2336 *
2337 * Unless required by applicable law or agreed to in writing, software distributed under
2338 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2339 * ANY KIND, either express or implied. See the License for the specific language
2340 * governing permissions and limitations under the License.
2341 *
2342 * @author Brian Reavis <[email protected]>
2343 */
2344
2345
2346 class Sifter {
2347 items; // []|{};
2348 settings;
2349 /**
2350 * Textually searches arrays and hashes of objects
2351 * by property (or multiple properties). Designed
2352 * specifically for autocomplete.
2353 *
2354 */
2355 constructor(items, settings) {
2356 this.items = items;
2357 this.settings = settings || { diacritics: true };
2358 }
2359 ;
2360 /**
2361 * Splits a search string into an array of individual
2362 * regexps to be used to match results.
2363 *
2364 */
2365 tokenize(query, respect_word_boundaries, weights) {
2366 if (!query || !query.length)
2367 return [];
2368 const tokens = [];
2369 const words = query.split(/\s+/);
2370 var field_regex;
2371 if (weights) {
2372 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
2373 }
2374 words.forEach((word) => {
2375 let field_match;
2376 let field = null;
2377 let regex = null;
2378 // look for "field:query" tokens
2379 if (field_regex && (field_match = word.match(field_regex))) {
2380 field = field_match[1];
2381 word = field_match[2];
2382 }
2383 if (word.length > 0) {
2384 if (this.settings.diacritics) {
2385 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
2386 }
2387 else {
2388 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
2389 }
2390 if (regex && respect_word_boundaries)
2391 regex = "\\b" + regex;
2392 }
2393 tokens.push({
2394 string: word,
2395 regex: regex ? new RegExp(regex, 'iu') : null,
2396 field: field,
2397 });
2398 });
2399 return tokens;
2400 }
2401 ;
2402 /**
2403 * Returns a function to be used to score individual results.
2404 *
2405 * Good matches will have a higher score than poor matches.
2406 * If an item is not a match, 0 will be returned by the function.
2407 *
2408 * @returns {T.ScoreFn}
2409 */
2410 getScoreFunction(query, options) {
2411 var search = this.prepareSearch(query, options);
2412 return this._getScoreFunction(search);
2413 }
2414 /**
2415 * @returns {T.ScoreFn}
2416 *
2417 */
2418 _getScoreFunction(search) {
2419 const tokens = search.tokens, token_count = tokens.length;
2420 if (!token_count) {
2421 return function () { return 0; };
2422 }
2423 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
2424 if (!field_count) {
2425 return function () { return 1; };
2426 }
2427 /**
2428 * Calculates the score of an object
2429 * against the search query.
2430 *
2431 */
2432 const scoreObject = (function () {
2433 if (field_count === 1) {
2434 return function (token, data) {
2435 const field = fields[0].field;
2436 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
2437 };
2438 }
2439 return function (token, data) {
2440 var sum = 0;
2441 // is the token specific to a field?
2442 if (token.field) {
2443 const value = getAttrFn(data, token.field);
2444 if (!token.regex && value) {
2445 sum += (1 / field_count);
2446 }
2447 else {
2448 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
2449 }
2450 }
2451 else {
2452 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
2453 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
2454 });
2455 }
2456 return sum / field_count;
2457 };
2458 })();
2459 if (token_count === 1) {
2460 return function (data) {
2461 return scoreObject(tokens[0], data);
2462 };
2463 }
2464 if (search.options.conjunction === 'and') {
2465 return function (data) {
2466 var score, sum = 0;
2467 for (let token of tokens) {
2468 score = scoreObject(token, data);
2469 if (score <= 0)
2470 return 0;
2471 sum += score;
2472 }
2473 return sum / token_count;
2474 };
2475 }
2476 else {
2477 return function (data) {
2478 var sum = 0;
2479 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
2480 sum += scoreObject(token, data);
2481 });
2482 return sum / token_count;
2483 };
2484 }
2485 }
2486 ;
2487 /**
2488 * Returns a function that can be used to compare two
2489 * results, for sorting purposes. If no sorting should
2490 * be performed, `null` will be returned.
2491 *
2492 * @return function(a,b)
2493 */
2494 getSortFunction(query, options) {
2495 var search = this.prepareSearch(query, options);
2496 return this._getSortFunction(search);
2497 }
2498 _getSortFunction(search) {
2499 var implicit_score, sort_flds = [];
2500 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
2501 if (typeof sort == 'function') {
2502 return sort.bind(this);
2503 }
2504 /**
2505 * Fetches the specified sort field value
2506 * from a search result item.
2507 *
2508 */
2509 const get_field = function (name, result) {
2510 if (name === '$score')
2511 return result.score;
2512 return search.getAttrFn(self.items[result.id], name);
2513 };
2514 // parse options
2515 if (sort) {
2516 for (let s of sort) {
2517 if (search.query || s.field !== '$score') {
2518 sort_flds.push(s);
2519 }
2520 }
2521 }
2522 // the "$score" field is implied to be the primary
2523 // sort field, unless it's manually specified
2524 if (search.query) {
2525 implicit_score = true;
2526 for (let fld of sort_flds) {
2527 if (fld.field === '$score') {
2528 implicit_score = false;
2529 break;
2530 }
2531 }
2532 if (implicit_score) {
2533 sort_flds.unshift({ field: '$score', direction: 'desc' });
2534 }
2535 // without a search.query, all items will have the same score
2536 }
2537 else {
2538 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
2539 }
2540 // build function
2541 const sort_flds_count = sort_flds.length;
2542 if (!sort_flds_count) {
2543 return null;
2544 }
2545 return function (a, b) {
2546 var result, field;
2547 for (let sort_fld of sort_flds) {
2548 field = sort_fld.field;
2549 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
2550 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
2551 if (result)
2552 return result;
2553 }
2554 return 0;
2555 };
2556 }
2557 ;
2558 /**
2559 * Parses a search query and returns an object
2560 * with tokens and fields ready to be populated
2561 * with results.
2562 *
2563 */
2564 prepareSearch(query, optsUser) {
2565 const weights = {};
2566 var options = Object.assign({}, optsUser);
2567 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
2568 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
2569 // convert fields to new format
2570 if (options.fields) {
2571 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
2572 const fields = [];
2573 options.fields.forEach((field) => {
2574 if (typeof field == 'string') {
2575 field = { field: field, weight: 1 };
2576 }
2577 fields.push(field);
2578 weights[field.field] = ('weight' in field) ? field.weight : 1;
2579 });
2580 options.fields = fields;
2581 }
2582 return {
2583 options: options,
2584 query: query.toLowerCase().trim(),
2585 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
2586 total: 0,
2587 items: [],
2588 weights: weights,
2589 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
2590 };
2591 }
2592 ;
2593 /**
2594 * Searches through all items and returns a sorted array of matches.
2595 *
2596 */
2597 search(query, options) {
2598 var self = this, score, search;
2599 search = this.prepareSearch(query, options);
2600 options = search.options;
2601 query = search.query;
2602 // generate result scoring function
2603 const fn_score = options.score || self._getScoreFunction(search);
2604 // perform search and sort
2605 if (query.length) {
2606 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
2607 score = fn_score(item);
2608 if (options.filter === false || score > 0) {
2609 search.items.push({ 'score': score, 'id': id });
2610 }
2611 });
2612 }
2613 else {
2614 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
2615 search.items.push({ 'score': 1, 'id': id });
2616 });
2617 }
2618 const fn_sort = self._getSortFunction(search);
2619 if (fn_sort)
2620 search.items.sort(fn_sort);
2621 // apply limits
2622 search.total = search.items.length;
2623 if (typeof options.limit === 'number') {
2624 search.items = search.items.slice(0, options.limit);
2625 }
2626 return search;
2627 }
2628 ;
2629 }
2630
2631
2632 //# sourceMappingURL=sifter.js.map
2633
2634 /***/ },
2635
2636 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
2637 /*!*********************************************************!*\
2638 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
2639 \*********************************************************/
2640 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2641
2642 "use strict";
2643 __webpack_require__.r(__webpack_exports__);
2644
2645 //# sourceMappingURL=types.js.map
2646
2647 /***/ },
2648
2649 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
2650 /*!*********************************************************!*\
2651 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
2652 \*********************************************************/
2653 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2654
2655 "use strict";
2656 __webpack_require__.r(__webpack_exports__);
2657 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2658 /* harmony export */ cmp: () => (/* binding */ cmp),
2659 /* harmony export */ getAttr: () => (/* binding */ getAttr),
2660 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
2661 /* harmony export */ iterate: () => (/* binding */ iterate),
2662 /* harmony export */ propToArray: () => (/* binding */ propToArray),
2663 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
2664 /* harmony export */ });
2665 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
2666
2667 /**
2668 * A property getter resolving dot-notation
2669 * @param {Object} obj The root object to fetch property on
2670 * @param {String} name The optionally dotted property name to fetch
2671 * @return {Object} The resolved property value
2672 */
2673 const getAttr = (obj, name) => {
2674 if (!obj)
2675 return;
2676 return obj[name];
2677 };
2678 /**
2679 * A property getter resolving dot-notation
2680 * @param {Object} obj The root object to fetch property on
2681 * @param {String} name The optionally dotted property name to fetch
2682 * @return {Object} The resolved property value
2683 */
2684 const getAttrNesting = (obj, name) => {
2685 if (!obj)
2686 return;
2687 var part, names = name.split(".");
2688 while ((part = names.shift()) && (obj = obj[part]))
2689 ;
2690 return obj;
2691 };
2692 /**
2693 * Calculates how close of a match the
2694 * given value is against a search token.
2695 *
2696 */
2697 const scoreValue = (value, token, weight) => {
2698 var score, pos;
2699 if (!value)
2700 return 0;
2701 value = value + '';
2702 if (token.regex == null)
2703 return 0;
2704 pos = value.search(token.regex);
2705 if (pos === -1)
2706 return 0;
2707 score = token.string.length / value.length;
2708 if (pos === 0)
2709 score += 0.5;
2710 return score * weight;
2711 };
2712 /**
2713 * Cast object property to an array if it exists and has a value
2714 *
2715 */
2716 const propToArray = (obj, key) => {
2717 var value = obj[key];
2718 if (typeof value == 'function')
2719 return value;
2720 if (value && !Array.isArray(value)) {
2721 obj[key] = [value];
2722 }
2723 };
2724 /**
2725 * Iterates over arrays and hashes.
2726 *
2727 * ```
2728 * iterate(this.items, function(item, id) {
2729 * // invoked for each item
2730 * });
2731 * ```
2732 *
2733 */
2734 const iterate = (object, callback) => {
2735 if (Array.isArray(object)) {
2736 object.forEach(callback);
2737 }
2738 else {
2739 for (var key in object) {
2740 if (object.hasOwnProperty(key)) {
2741 callback(object[key], key);
2742 }
2743 }
2744 }
2745 };
2746 const cmp = (a, b) => {
2747 if (typeof a === 'number' && typeof b === 'number') {
2748 return a > b ? 1 : (a < b ? -1 : 0);
2749 }
2750 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
2751 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
2752 if (a > b)
2753 return 1;
2754 if (b > a)
2755 return -1;
2756 return 0;
2757 };
2758 //# sourceMappingURL=utils.js.map
2759
2760 /***/ },
2761
2762 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
2763 /*!*******************************************************************!*\
2764 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
2765 \*******************************************************************/
2766 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2767
2768 "use strict";
2769 __webpack_require__.r(__webpack_exports__);
2770 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2771 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
2772 /* harmony export */ asciifold: () => (/* binding */ asciifold),
2773 /* harmony export */ code_points: () => (/* binding */ code_points),
2774 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
2775 /* harmony export */ generateMap: () => (/* binding */ generateMap),
2776 /* harmony export */ generateSets: () => (/* binding */ generateSets),
2777 /* harmony export */ generator: () => (/* binding */ generator),
2778 /* harmony export */ getPattern: () => (/* binding */ getPattern),
2779 /* harmony export */ initialize: () => (/* binding */ initialize),
2780 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
2781 /* harmony export */ normalize: () => (/* binding */ normalize),
2782 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
2783 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
2784 /* harmony export */ });
2785 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
2786 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
2787
2788
2789 const code_points = [[0, 65535]];
2790 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
2791 let unicode_map;
2792 let multi_char_reg;
2793 const max_char_length = 3;
2794 const latin_convert = {};
2795 const latin_condensed = {
2796 '/': '⁄∕',
2797 '0': '߀',
2798 "a": "ⱥɐɑ",
2799 "aa": "ꜳ",
2800 "ae": "æǽǣ",
2801 "ao": "ꜵ",
2802 "au": "ꜷ",
2803 "av": "ꜹꜻ",
2804 "ay": "ꜽ",
2805 "b": "ƀɓƃ",
2806 "c": "ꜿƈȼↄ",
2807 "d": "đɗɖ�
2808 ƌꮷԁɦ",
2809 "e": "ɛǝᴇɇ",
2810 "f": "ꝼƒ",
2811 "g": "ǥɠꞡᵹꝿɢ",
2812 "h": "ħⱨⱶɥ",
2813 "i": "ɨı",
2814 "j": "ɉȷ",
2815 "k": "ƙⱪꝁꝃ�
2816 ꞣ",
2817 "l": "łƚɫⱡꝉꝇꞁɭ",
2818 "m": "ɱɯϻ",
2819 "n": "ꞥƞɲꞑᴎлԉ",
2820 "o": "øǿɔɵꝋꝍᴑ",
2821 "oe": "œ",
2822 "oi": "ƣ",
2823 "oo": "ꝏ",
2824 "ou": "ȣ",
2825 "p": "ƥᵽꝑꝓꝕρ",
2826 "q": "ꝗꝙɋ",
2827 "r": "ɍɽꝛꞧꞃ",
2828 "s": "ßȿꞩ�
2829 ʂ",
2830 "t": "ŧƭʈⱦꞇ",
2831 "th": "þ",
2832 "tz": "ꜩ",
2833 "u": "ʉ",
2834 "v": "ʋꝟʌ",
2835 "vy": "ꝡ",
2836 "w": "ⱳ",
2837 "y": "ƴɏỿ",
2838 "z": "ƶȥɀⱬꝣ",
2839 "hv": "ƕ"
2840 };
2841 for (let latin in latin_condensed) {
2842 let unicode = latin_condensed[latin] || '';
2843 for (let i = 0; i < unicode.length; i++) {
2844 let char = unicode.substring(i, i + 1);
2845 latin_convert[char] = latin;
2846 }
2847 }
2848 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
2849 /**
2850 * Initialize the unicode_map from the give code point ranges
2851 */
2852 const initialize = (_code_points) => {
2853 if (unicode_map !== undefined)
2854 return;
2855 unicode_map = generateMap(_code_points || code_points);
2856 };
2857 /**
2858 * Helper method for normalize a string
2859 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
2860 */
2861 const normalize = (str, form = 'NFKD') => str.normalize(form);
2862 /**
2863 * Remove accents without reordering string
2864 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
2865 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
2866 */
2867 const asciifold = (str) => {
2868 return Array.from(str).reduce(
2869 /**
2870 * @param {string} result
2871 * @param {string} char
2872 */
2873 (result, char) => {
2874 return result + _asciifold(char);
2875 }, '');
2876 };
2877 const _asciifold = (str) => {
2878 str = normalize(str)
2879 .toLowerCase()
2880 .replace(convert_pat, (/** @type {string} */ char) => {
2881 return latin_convert[char] || '';
2882 });
2883 //return str;
2884 return normalize(str, 'NFC');
2885 };
2886 /**
2887 * Generate a list of unicode variants from the list of code points
2888 */
2889 function* generator(code_points) {
2890 for (const [code_point_min, code_point_max] of code_points) {
2891 for (let i = code_point_min; i <= code_point_max; i++) {
2892 let composed = String.fromCharCode(i);
2893 let folded = asciifold(composed);
2894 if (folded == composed.toLowerCase()) {
2895 continue;
2896 }
2897 // skip when folded is a string longer than 3 characters long
2898 // bc the resulting regex patterns will be long
2899 // eg:
2900 // folded صلى الله عليه وسل�
2901 length 18 code point 65018
2902 // folded جل جلاله length 8 code point 65019
2903 if (folded.length > max_char_length) {
2904 continue;
2905 }
2906 if (folded.length == 0) {
2907 continue;
2908 }
2909 yield { folded: folded, composed: composed, code_point: i };
2910 }
2911 }
2912 }
2913 /**
2914 * Generate a unicode map from the list of code points
2915 */
2916 const generateSets = (code_points) => {
2917 const unicode_sets = {};
2918 const addMatching = (folded, to_add) => {
2919 /** @type {Set<string>} */
2920 const folded_set = unicode_sets[folded] || new Set();
2921 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
2922 if (to_add.match(patt)) {
2923 return;
2924 }
2925 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
2926 unicode_sets[folded] = folded_set;
2927 };
2928 for (let value of generator(code_points)) {
2929 addMatching(value.folded, value.folded);
2930 addMatching(value.folded, value.composed);
2931 }
2932 return unicode_sets;
2933 };
2934 /**
2935 * Generate a unicode map from the list of code points
2936 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
2937 */
2938 const generateMap = (code_points) => {
2939 const unicode_sets = generateSets(code_points);
2940 const unicode_map = {};
2941 let multi_char = [];
2942 for (let folded in unicode_sets) {
2943 let set = unicode_sets[folded];
2944 if (set) {
2945 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
2946 }
2947 if (folded.length > 1) {
2948 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
2949 }
2950 }
2951 multi_char.sort((a, b) => b.length - a.length);
2952 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
2953 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
2954 return unicode_map;
2955 };
2956 /**
2957 * Map each element of an array from its folded value to all possible unicode matches
2958 */
2959 const mapSequence = (strings, min_replacement = 1) => {
2960 let chars_replaced = 0;
2961 strings = strings.map((str) => {
2962 if (unicode_map[str]) {
2963 chars_replaced += str.length;
2964 }
2965 return unicode_map[str] || str;
2966 });
2967 if (chars_replaced >= min_replacement) {
2968 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
2969 }
2970 return '';
2971 };
2972 /**
2973 * Convert a short string and split it into all possible patterns
2974 * Keep a pattern only if min_replacement is met
2975 *
2976 * 'abc'
2977 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
2978 * => ['abc-pattern','ab-c-pattern'...]
2979 */
2980 const substringsToPattern = (str, min_replacement = 1) => {
2981 min_replacement = Math.max(min_replacement, str.length - 1);
2982 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
2983 return mapSequence(sub_pat, min_replacement);
2984 }));
2985 };
2986 /**
2987 * Convert an array of sequences into a pattern
2988 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
2989 */
2990 const sequencesToPattern = (sequences, all = true) => {
2991 let min_replacement = sequences.length > 1 ? 1 : 0;
2992 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
2993 let seq = [];
2994 const len = all ? sequence.length() : sequence.length() - 1;
2995 for (let j = 0; j < len; j++) {
2996 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
2997 }
2998 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
2999 }));
3000 };
3001 /**
3002 * Return true if the sequence is already in the sequences
3003 */
3004 const inSequences = (needle_seq, sequences) => {
3005 for (const seq of sequences) {
3006 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
3007 continue;
3008 }
3009 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
3010 continue;
3011 }
3012 let needle_parts = needle_seq.parts;
3013 const filter = (part) => {
3014 for (const needle_part of needle_parts) {
3015 if (needle_part.start === part.start && needle_part.substr === part.substr) {
3016 return false;
3017 }
3018 if (part.length == 1 || needle_part.length == 1) {
3019 continue;
3020 }
3021 // check for overlapping parts
3022 // a = ['::=','==']
3023 // b = ['::','===']
3024 // a = ['r','sm']
3025 // b = ['rs','m']
3026 if (part.start < needle_part.start && part.end > needle_part.start) {
3027 return true;
3028 }
3029 if (needle_part.start < part.start && needle_part.end > part.start) {
3030 return true;
3031 }
3032 }
3033 return false;
3034 };
3035 let filtered = seq.parts.filter(filter);
3036 if (filtered.length > 0) {
3037 continue;
3038 }
3039 return true;
3040 }
3041 return false;
3042 };
3043 class Sequence {
3044 parts;
3045 substrs;
3046 start;
3047 end;
3048 constructor() {
3049 this.parts = [];
3050 this.substrs = [];
3051 this.start = 0;
3052 this.end = 0;
3053 }
3054 add(part) {
3055 if (part) {
3056 this.parts.push(part);
3057 this.substrs.push(part.substr);
3058 this.start = Math.min(part.start, this.start);
3059 this.end = Math.max(part.end, this.end);
3060 }
3061 }
3062 last() {
3063 return this.parts[this.parts.length - 1];
3064 }
3065 length() {
3066 return this.parts.length;
3067 }
3068 clone(position, last_piece) {
3069 let clone = new Sequence();
3070 let parts = JSON.parse(JSON.stringify(this.parts));
3071 let last_part = parts.pop();
3072 for (const part of parts) {
3073 clone.add(part);
3074 }
3075 let last_substr = last_piece.substr.substring(0, position - last_part.start);
3076 let clone_last_len = last_substr.length;
3077 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
3078 return clone;
3079 }
3080 }
3081 /**
3082 * Expand a regular expression pattern to include unicode variants
3083 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁ�
3084 ⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢ�
3085 ǺǍȀȂẠẬẶḀĄȺⱯ/
3086 *
3087 * Issue:
3088 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
3089 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
3090 *
3091 * İIJ = IIJ = �
3092 �J
3093 *
3094 * 1/2/4
3095 */
3096 const getPattern = (str) => {
3097 initialize();
3098 str = asciifold(str);
3099 let pattern = '';
3100 let sequences = [new Sequence()];
3101 for (let i = 0; i < str.length; i++) {
3102 let substr = str.substring(i);
3103 let match = substr.match(multi_char_reg);
3104 const char = str.substring(i, i + 1);
3105 const match_str = match ? match[0] : null;
3106 // loop through sequences
3107 // add either the char or multi_match
3108 let overlapping = [];
3109 let added_types = new Set();
3110 for (const sequence of sequences) {
3111 const last_piece = sequence.last();
3112 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
3113 // if we have a multi match
3114 if (match_str) {
3115 const len = match_str.length;
3116 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
3117 added_types.add('1');
3118 }
3119 else {
3120 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
3121 added_types.add('2');
3122 }
3123 }
3124 else if (match_str) {
3125 let clone = sequence.clone(i, last_piece);
3126 const len = match_str.length;
3127 clone.add({ start: i, end: i + len, length: len, substr: match_str });
3128 overlapping.push(clone);
3129 }
3130 else {
3131 // don't add char
3132 // adding would create invalid patterns: 234 => [2,34,4]
3133 added_types.add('3');
3134 }
3135 }
3136 // if we have overlapping
3137 if (overlapping.length > 0) {
3138 // ['ii','iii'] before ['i','i','iii']
3139 overlapping = overlapping.sort((a, b) => {
3140 return a.length() - b.length();
3141 });
3142 for (let clone of overlapping) {
3143 // don't add if we already have an equivalent sequence
3144 if (inSequences(clone, sequences)) {
3145 continue;
3146 }
3147 sequences.push(clone);
3148 }
3149 continue;
3150 }
3151 // if we haven't done anything unique
3152 // clean up the patterns
3153 // helps keep patterns smaller
3154 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
3155 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
3156 pattern += sequencesToPattern(sequences, false);
3157 let new_seq = new Sequence();
3158 const old_seq = sequences[0];
3159 if (old_seq) {
3160 new_seq.add(old_seq.last());
3161 }
3162 sequences = [new_seq];
3163 }
3164 }
3165 pattern += sequencesToPattern(sequences, true);
3166 return pattern;
3167 };
3168
3169 //# sourceMappingURL=index.js.map
3170
3171 /***/ },
3172
3173 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
3174 /*!*******************************************************************!*\
3175 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
3176 \*******************************************************************/
3177 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3178
3179 "use strict";
3180 __webpack_require__.r(__webpack_exports__);
3181 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3182 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
3183 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
3184 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
3185 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
3186 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
3187 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
3188 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
3189 /* harmony export */ });
3190 /**
3191 * Convert array of strings to a regular expression
3192 * ex ['ab','a'] => (?:ab|a)
3193 * ex ['a','b'] => [ab]
3194 */
3195 const arrayToPattern = (chars) => {
3196 chars = chars.filter(Boolean);
3197 if (chars.length < 2) {
3198 return chars[0] || '';
3199 }
3200 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
3201 };
3202 const sequencePattern = (array) => {
3203 if (!hasDuplicates(array)) {
3204 return array.join('');
3205 }
3206 let pattern = '';
3207 let prev_char_count = 0;
3208 const prev_pattern = () => {
3209 if (prev_char_count > 1) {
3210 pattern += '{' + prev_char_count + '}';
3211 }
3212 };
3213 array.forEach((char, i) => {
3214 if (char === array[i - 1]) {
3215 prev_char_count++;
3216 return;
3217 }
3218 prev_pattern();
3219 pattern += char;
3220 prev_char_count = 1;
3221 });
3222 prev_pattern();
3223 return pattern;
3224 };
3225 /**
3226 * Convert array of strings to a regular expression
3227 * ex ['ab','a'] => (?:ab|a)
3228 * ex ['a','b'] => [ab]
3229 */
3230 const setToPattern = (chars) => {
3231 let array = Array.from(chars);
3232 return arrayToPattern(array);
3233 };
3234 /**
3235 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
3236 */
3237 const hasDuplicates = (array) => {
3238 return (new Set(array)).size !== array.length;
3239 };
3240 /**
3241 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
3242 */
3243 const escape_regex = (str) => {
3244 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
3245 };
3246 /**
3247 * Return the max length of array values
3248 */
3249 const maxValueLength = (array) => {
3250 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
3251 };
3252 const unicodeLength = (str) => {
3253 return Array.from(str).length;
3254 };
3255 //# sourceMappingURL=regex.js.map
3256
3257 /***/ },
3258
3259 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
3260 /*!*********************************************************************!*\
3261 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
3262 \*********************************************************************/
3263 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3264
3265 "use strict";
3266 __webpack_require__.r(__webpack_exports__);
3267 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3268 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
3269 /* harmony export */ });
3270 /**
3271 * Get all possible combinations of substrings that add up to the given string
3272 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
3273 */
3274 const allSubstrings = (input) => {
3275 if (input.length === 1)
3276 return [[input]];
3277 let result = [];
3278 const start = input.substring(1);
3279 const suba = allSubstrings(start);
3280 suba.forEach(function (subresult) {
3281 let tmp = subresult.slice(0);
3282 tmp[0] = input.charAt(0) + tmp[0];
3283 result.push(tmp);
3284 tmp = subresult.slice(0);
3285 tmp.unshift(input.charAt(0));
3286 result.push(tmp);
3287 });
3288 return result;
3289 };
3290 //# sourceMappingURL=strings.js.map
3291
3292 /***/ },
3293
3294 /***/ "./node_modules/tom-select/dist/esm/constants.js"
3295 /*!*******************************************************!*\
3296 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
3297 \*******************************************************/
3298 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3299
3300 "use strict";
3301 __webpack_require__.r(__webpack_exports__);
3302 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3303 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
3304 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
3305 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
3306 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
3307 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
3308 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
3309 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
3310 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
3311 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
3312 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
3313 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
3314 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
3315 /* harmony export */ });
3316 const KEY_A = 65;
3317 const KEY_RETURN = 13;
3318 const KEY_ESC = 27;
3319 const KEY_LEFT = 37;
3320 const KEY_UP = 38;
3321 const KEY_RIGHT = 39;
3322 const KEY_DOWN = 40;
3323 const KEY_BACKSPACE = 8;
3324 const KEY_DELETE = 46;
3325 const KEY_TAB = 9;
3326 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
3327 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
3328 //# sourceMappingURL=constants.js.map
3329
3330 /***/ },
3331
3332 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
3333 /*!***************************************************************!*\
3334 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
3335 \***************************************************************/
3336 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3337
3338 "use strict";
3339 __webpack_require__.r(__webpack_exports__);
3340 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3341 /* harmony export */ highlight: () => (/* binding */ highlight),
3342 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
3343 /* harmony export */ });
3344 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
3345 /**
3346 * highlight v3 | MIT license | Johann Burkard <[email protected]>
3347 * Highlights arbitrary terms in a node.
3348 *
3349 * - Modified by Marshal <[email protected]> 2011-6-24 (added regex)
3350 * - Modified by Brian Reavis <[email protected]> 2012-8-27 (cleanup)
3351 */
3352
3353 const highlight = (element, regex) => {
3354 if (regex === null)
3355 return;
3356 // convet string to regex
3357 if (typeof regex === 'string') {
3358 if (!regex.length)
3359 return;
3360 regex = new RegExp(regex, 'i');
3361 }
3362 // Wrap matching part of text node with highlighting <span>, e.g.
3363 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
3364 const highlightText = (node) => {
3365 var match = node.data.match(regex);
3366 if (match && node.data.length > 0) {
3367 var spannode = document.createElement('span');
3368 spannode.className = 'highlight';
3369 var middlebit = node.splitText(match.index);
3370 middlebit.splitText(match[0].length);
3371 var middleclone = middlebit.cloneNode(true);
3372 spannode.appendChild(middleclone);
3373 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
3374 return 1;
3375 }
3376 return 0;
3377 };
3378 // Recurse element node, looking for child text nodes to highlight, unless element
3379 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
3380 const highlightChildren = (node) => {
3381 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
3382 Array.from(node.childNodes).forEach(element => {
3383 highlightRecursive(element);
3384 });
3385 }
3386 };
3387 const highlightRecursive = (node) => {
3388 if (node.nodeType === 3) {
3389 return highlightText(node);
3390 }
3391 highlightChildren(node);
3392 return 0;
3393 };
3394 highlightRecursive(element);
3395 };
3396 /**
3397 * removeHighlight fn copied from highlight v5 and
3398 * edited to remove with(), pass js strict mode, and use without jquery
3399 */
3400 const removeHighlight = (el) => {
3401 var elements = el.querySelectorAll("span.highlight");
3402 Array.prototype.forEach.call(elements, function (el) {
3403 var parent = el.parentNode;
3404 parent.replaceChild(el.firstChild, el);
3405 parent.normalize();
3406 });
3407 };
3408 //# sourceMappingURL=highlight.js.map
3409
3410 /***/ },
3411
3412 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
3413 /*!****************************************************************!*\
3414 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
3415 \****************************************************************/
3416 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3417
3418 "use strict";
3419 __webpack_require__.r(__webpack_exports__);
3420 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3421 /* harmony export */ "default": () => (/* binding */ MicroEvent)
3422 /* harmony export */ });
3423 /**
3424 * MicroEvent - to make any js object an event emitter
3425 *
3426 * - pure javascript - server compatible, browser compatible
3427 * - dont rely on the browser doms
3428 * - super simple - you get it immediatly, no mistery, no magic involved
3429 *
3430 * @author Jerome Etienne (https://github.com/jeromeetienne)
3431 */
3432 /**
3433 * Execute callback for each event in space separated list of event names
3434 *
3435 */
3436 function forEvents(events, callback) {
3437 events.split(/\s+/).forEach((event) => {
3438 callback(event);
3439 });
3440 }
3441 class MicroEvent {
3442 constructor() {
3443 this._events = {};
3444 }
3445 on(events, fct) {
3446 forEvents(events, (event) => {
3447 const event_array = this._events[event] || [];
3448 event_array.push(fct);
3449 this._events[event] = event_array;
3450 });
3451 }
3452 off(events, fct) {
3453 var n = arguments.length;
3454 if (n === 0) {
3455 this._events = {};
3456 return;
3457 }
3458 forEvents(events, (event) => {
3459 if (n === 1) {
3460 delete this._events[event];
3461 return;
3462 }
3463 const event_array = this._events[event];
3464 if (event_array === undefined)
3465 return;
3466 event_array.splice(event_array.indexOf(fct), 1);
3467 this._events[event] = event_array;
3468 });
3469 }
3470 trigger(events, ...args) {
3471 var self = this;
3472 forEvents(events, (event) => {
3473 const event_array = self._events[event];
3474 if (event_array === undefined)
3475 return;
3476 event_array.forEach(fct => {
3477 fct.apply(self, args);
3478 });
3479 });
3480 }
3481 }
3482 ;
3483 //# sourceMappingURL=microevent.js.map
3484
3485 /***/ },
3486
3487 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
3488 /*!*****************************************************************!*\
3489 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
3490 \*****************************************************************/
3491 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3492
3493 "use strict";
3494 __webpack_require__.r(__webpack_exports__);
3495 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3496 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
3497 /* harmony export */ });
3498 /**
3499 * microplugin.js
3500 * Copyright (c) 2013 Brian Reavis & contributors
3501 *
3502 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3503 * file except in compliance with the License. You may obtain a copy of the License at:
3504 * http://www.apache.org/licenses/LICENSE-2.0
3505 *
3506 * Unless required by applicable law or agreed to in writing, software distributed under
3507 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3508 * ANY KIND, either express or implied. See the License for the specific language
3509 * governing permissions and limitations under the License.
3510 *
3511 * @author Brian Reavis <[email protected]>
3512 */
3513 function MicroPlugin(Interface) {
3514 Interface.plugins = {};
3515 return class extends Interface {
3516 constructor() {
3517 super(...arguments);
3518 this.plugins = {
3519 names: [],
3520 settings: {},
3521 requested: {},
3522 loaded: {}
3523 };
3524 }
3525 /**
3526 * Registers a plugin.
3527 *
3528 * @param {function} fn
3529 */
3530 static define(name, fn) {
3531 Interface.plugins[name] = {
3532 'name': name,
3533 'fn': fn
3534 };
3535 }
3536 /**
3537 * Initializes the listed plugins (with options).
3538 * Acceptable formats:
3539 *
3540 * List (without options):
3541 * ['a', 'b', 'c']
3542 *
3543 * List (with options):
3544 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
3545 *
3546 * Hash (with options):
3547 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
3548 *
3549 * @param {array|object} plugins
3550 */
3551 initializePlugins(plugins) {
3552 var key, name;
3553 const self = this;
3554 const queue = [];
3555 if (Array.isArray(plugins)) {
3556 plugins.forEach((plugin) => {
3557 if (typeof plugin === 'string') {
3558 queue.push(plugin);
3559 }
3560 else {
3561 self.plugins.settings[plugin.name] = plugin.options;
3562 queue.push(plugin.name);
3563 }
3564 });
3565 }
3566 else if (plugins) {
3567 for (key in plugins) {
3568 if (plugins.hasOwnProperty(key)) {
3569 self.plugins.settings[key] = plugins[key];
3570 queue.push(key);
3571 }
3572 }
3573 }
3574 while (name = queue.shift()) {
3575 self.require(name);
3576 }
3577 }
3578 loadPlugin(name) {
3579 var self = this;
3580 var plugins = self.plugins;
3581 var plugin = Interface.plugins[name];
3582 if (!Interface.plugins.hasOwnProperty(name)) {
3583 throw new Error('Unable to find "' + name + '" plugin');
3584 }
3585 plugins.requested[name] = true;
3586 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
3587 plugins.names.push(name);
3588 }
3589 /**
3590 * Initializes a plugin.
3591 *
3592 */
3593 require(name) {
3594 var self = this;
3595 var plugins = self.plugins;
3596 if (!self.plugins.loaded.hasOwnProperty(name)) {
3597 if (plugins.requested[name]) {
3598 throw new Error('Plugin has circular dependency ("' + name + '")');
3599 }
3600 self.loadPlugin(name);
3601 }
3602 return plugins.loaded[name];
3603 }
3604 };
3605 }
3606 //# sourceMappingURL=microplugin.js.map
3607
3608 /***/ },
3609
3610 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
3611 /*!******************************************************!*\
3612 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
3613 \******************************************************/
3614 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3615
3616 "use strict";
3617 __webpack_require__.r(__webpack_exports__);
3618 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3619 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
3620 /* harmony export */ });
3621 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
3622 options: [],
3623 optgroups: [],
3624 plugins: [],
3625 delimiter: ',',
3626 splitOn: null, // regexp or string for splitting up values from a paste command
3627 persist: true,
3628 diacritics: true,
3629 create: null,
3630 createOnBlur: false,
3631 createFilter: null,
3632 clearAfterSelect: false,
3633 highlight: true,
3634 openOnFocus: true,
3635 shouldOpen: null,
3636 maxOptions: 50,
3637 maxItems: null,
3638 hideSelected: null,
3639 duplicates: false,
3640 addPrecedence: false,
3641 selectOnTab: false,
3642 preload: null,
3643 allowEmptyOption: false,
3644 //closeAfterSelect: false,
3645 refreshThrottle: 300,
3646 loadThrottle: 300,
3647 loadingClass: 'loading',
3648 dataAttr: null, //'data-data',
3649 optgroupField: 'optgroup',
3650 valueField: 'value',
3651 labelField: 'text',
3652 disabledField: 'disabled',
3653 optgroupLabelField: 'label',
3654 optgroupValueField: 'value',
3655 lockOptgroupOrder: false,
3656 sortField: '$order',
3657 searchField: ['text'],
3658 searchConjunction: 'and',
3659 mode: null,
3660 wrapperClass: 'ts-wrapper',
3661 controlClass: 'ts-control',
3662 dropdownClass: 'ts-dropdown',
3663 dropdownContentClass: 'ts-dropdown-content',
3664 itemClass: 'item',
3665 optionClass: 'option',
3666 dropdownParent: null,
3667 controlInput: '<input type="text" autocomplete="off" size="1" />',
3668 copyClassesToDropdown: false,
3669 placeholder: null,
3670 hidePlaceholder: null,
3671 shouldLoad: function (query) {
3672 return query.length > 0;
3673 },
3674 /*
3675 load : null, // function(query, callback) { ... }
3676 score : null, // function(search) { ... }
3677 onInitialize : null, // function() { ... }
3678 onChange : null, // function(value) { ... }
3679 onItemAdd : null, // function(value, $item) { ... }
3680 onItemRemove : null, // function(value) { ... }
3681 onClear : null, // function() { ... }
3682 onOptionAdd : null, // function(value, data) { ... }
3683 onOptionRemove : null, // function(value) { ... }
3684 onOptionClear : null, // function() { ... }
3685 onOptionGroupAdd : null, // function(id, data) { ... }
3686 onOptionGroupRemove : null, // function(id) { ... }
3687 onOptionGroupClear : null, // function() { ... }
3688 onDropdownOpen : null, // function(dropdown) { ... }
3689 onDropdownClose : null, // function(dropdown) { ... }
3690 onType : null, // function(str) { ... }
3691 onDelete : null, // function(values) { ... }
3692 */
3693 render: {
3694 /*
3695 item: null,
3696 optgroup: null,
3697 optgroup_header: null,
3698 option: null,
3699 option_create: null
3700 */
3701 }
3702 });
3703 //# sourceMappingURL=defaults.js.map
3704
3705 /***/ },
3706
3707 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
3708 /*!*********************************************************!*\
3709 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
3710 \*********************************************************/
3711 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3712
3713 "use strict";
3714 __webpack_require__.r(__webpack_exports__);
3715 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3716 /* harmony export */ "default": () => (/* binding */ getSettings)
3717 /* harmony export */ });
3718 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
3719 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
3720
3721
3722 function getSettings(input, settings_user) {
3723 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
3724 var attr_data = settings.dataAttr;
3725 var field_label = settings.labelField;
3726 var field_value = settings.valueField;
3727 var field_disabled = settings.disabledField;
3728 var field_optgroup = settings.optgroupField;
3729 var field_optgroup_label = settings.optgroupLabelField;
3730 var field_optgroup_value = settings.optgroupValueField;
3731 var tag_name = input.tagName.toLowerCase();
3732 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
3733 if (!placeholder && !settings.allowEmptyOption) {
3734 let option = input.querySelector('option[value=""]');
3735 if (option) {
3736 placeholder = option.textContent;
3737 }
3738 }
3739 var settings_element = {
3740 placeholder: placeholder,
3741 options: [],
3742 optgroups: [],
3743 items: [],
3744 maxItems: null,
3745 };
3746 /**
3747 * Initialize from a <select> element.
3748 *
3749 */
3750 var init_select = () => {
3751 var tagName;
3752 var options = settings_element.options;
3753 var optionsMap = {};
3754 var group_count = 1;
3755 let $order = 0;
3756 var readData = (el) => {
3757 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
3758 var json = attr_data && data[attr_data];
3759 if (typeof json === 'string' && json.length) {
3760 data = Object.assign(data, JSON.parse(json));
3761 }
3762 return data;
3763 };
3764 var addOption = (option, group) => {
3765 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
3766 if (value == null)
3767 return;
3768 if (!value && !settings.allowEmptyOption)
3769 return;
3770 // if the option already exists, it's probably been
3771 // duplicated in another optgroup. in this case, push
3772 // the current group to the "optgroup" property on the
3773 // existing option so that it's rendered in both places.
3774 if (optionsMap.hasOwnProperty(value)) {
3775 if (group) {
3776 var arr = optionsMap[value][field_optgroup];
3777 if (!arr) {
3778 optionsMap[value][field_optgroup] = group;
3779 }
3780 else if (!Array.isArray(arr)) {
3781 optionsMap[value][field_optgroup] = [arr, group];
3782 }
3783 else {
3784 arr.push(group);
3785 }
3786 }
3787 }
3788 else {
3789 var option_data = readData(option);
3790 option_data[field_label] = option_data[field_label] || option.textContent;
3791 option_data[field_value] = option_data[field_value] || value;
3792 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
3793 option_data[field_optgroup] = option_data[field_optgroup] || group;
3794 option_data.$option = option;
3795 option_data.$order = option_data.$order || ++$order;
3796 optionsMap[value] = option_data;
3797 options.push(option_data);
3798 }
3799 if (option.selected) {
3800 settings_element.items.push(value);
3801 }
3802 };
3803 var addGroup = (optgroup) => {
3804 var id, optgroup_data;
3805 optgroup_data = readData(optgroup);
3806 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
3807 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
3808 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
3809 optgroup_data.$order = optgroup_data.$order || ++$order;
3810 settings_element.optgroups.push(optgroup_data);
3811 id = optgroup_data[field_optgroup_value];
3812 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
3813 addOption(option, id);
3814 });
3815 };
3816 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
3817 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
3818 tagName = child.tagName.toLowerCase();
3819 if (tagName === 'optgroup') {
3820 addGroup(child);
3821 }
3822 else if (tagName === 'option') {
3823 addOption(child);
3824 }
3825 });
3826 };
3827 /**
3828 * Initialize from a <input type="text"> element.
3829 *
3830 */
3831 var init_textbox = () => {
3832 var _a, _b;
3833 const data_raw = input.getAttribute(attr_data);
3834 if (!data_raw) {
3835 var value = (_b = (_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
3836 if (!settings.allowEmptyOption && !value.length)
3837 return;
3838 const values = value.split(settings.delimiter);
3839 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
3840 const option = {};
3841 option[field_label] = value;
3842 option[field_value] = value;
3843 settings_element.options.push(option);
3844 });
3845 settings_element.items = values;
3846 }
3847 else {
3848 settings_element.options = JSON.parse(data_raw);
3849 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
3850 settings_element.items.push(opt[field_value]);
3851 });
3852 }
3853 };
3854 if (tag_name === 'select') {
3855 init_select();
3856 }
3857 else {
3858 init_textbox();
3859 }
3860 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
3861 }
3862 ;
3863 //# sourceMappingURL=getSettings.js.map
3864
3865 /***/ },
3866
3867 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
3868 /*!***************************************************************************!*\
3869 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
3870 \***************************************************************************/
3871 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3872
3873 "use strict";
3874 __webpack_require__.r(__webpack_exports__);
3875 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3876 /* harmony export */ "default": () => (/* binding */ plugin)
3877 /* harmony export */ });
3878 /**
3879 * Tom Select v2.6.2
3880 * Licensed under the Apache License, Version 2.0 (the "License");
3881 */
3882
3883 /**
3884 * Converts a scalar to its best string representation
3885 * for hash keys and HTML attribute values.
3886 *
3887 * Transformations:
3888 * 'str' -> 'str'
3889 * null -> ''
3890 * undefined -> ''
3891 * true -> '1'
3892 * false -> '0'
3893 * 0 -> '0'
3894 * 1 -> '1'
3895 *
3896 */
3897
3898 /**
3899 * Iterates over arrays and hashes.
3900 *
3901 * ```
3902 * iterate(this.items, function(item, id) {
3903 * // invoked for each item
3904 * });
3905 * ```
3906 *
3907 */
3908 const iterate = (object, callback) => {
3909 if (Array.isArray(object)) {
3910 object.forEach(callback);
3911 } else {
3912 for (var key in object) {
3913 if (object.hasOwnProperty(key)) {
3914 callback(object[key], key);
3915 }
3916 }
3917 }
3918 };
3919
3920 /**
3921 * Remove css classes
3922 *
3923 */
3924 const removeClasses = (elmts, ...classes) => {
3925 var norm_classes = classesArray(classes);
3926 elmts = castAsArray(elmts);
3927 elmts.map(el => {
3928 norm_classes.map(cls => {
3929 el.classList.remove(cls);
3930 });
3931 });
3932 };
3933
3934 /**
3935 * Return arguments
3936 *
3937 */
3938 const classesArray = args => {
3939 var classes = [];
3940 iterate(args, _classes => {
3941 if (typeof _classes === 'string') {
3942 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
3943 }
3944 if (Array.isArray(_classes)) {
3945 classes = classes.concat(_classes);
3946 }
3947 });
3948 return classes.filter(Boolean);
3949 };
3950
3951 /**
3952 * Create an array from arg if it's not already an array
3953 *
3954 */
3955 const castAsArray = arg => {
3956 if (!Array.isArray(arg)) {
3957 arg = [arg];
3958 }
3959 return arg;
3960 };
3961
3962 /**
3963 * Get the index of an element amongst sibling nodes of the same type
3964 *
3965 */
3966 const nodeIndex = (el, amongst) => {
3967 if (!el) return -1;
3968 amongst = amongst || el.nodeName;
3969 var i = 0;
3970 while (el = el.previousElementSibling) {
3971 if (el.matches(amongst)) {
3972 i++;
3973 }
3974 }
3975 return i;
3976 };
3977
3978 /**
3979 * Plugin: "dropdown_input" (Tom Select)
3980 * Copyright (c) contributors
3981 *
3982 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3983 * file except in compliance with the License. You may obtain a copy of the License at:
3984 * http://www.apache.org/licenses/LICENSE-2.0
3985 *
3986 * Unless required by applicable law or agreed to in writing, software distributed under
3987 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3988 * ANY KIND, either express or implied. See the License for the specific language
3989 * governing permissions and limitations under the License.
3990 *
3991 */
3992
3993 function plugin () {
3994 var self = this;
3995
3996 /**
3997 * Moves the caret to the specified index.
3998 *
3999 * The input must be moved by leaving it in place and moving the
4000 * siblings, due to the fact that focus cannot be restored once lost
4001 * on mobile webkit devices
4002 *
4003 */
4004 self.hook('instead', 'setCaret', new_pos => {
4005 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
4006 new_pos = self.items.length;
4007 } else {
4008 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
4009 if (new_pos != self.caretPos && !self.isPending) {
4010 self.controlChildren().forEach((child, j) => {
4011 if (j < new_pos) {
4012 self.control_input.insertAdjacentElement('beforebegin', child);
4013 } else {
4014 self.control.appendChild(child);
4015 }
4016 });
4017 }
4018 }
4019 self.caretPos = new_pos;
4020 });
4021 self.hook('instead', 'moveCaret', direction => {
4022 if (!self.isFocused) return;
4023
4024 // move caret before or after selected items
4025 const last_active = self.getLastActive(direction);
4026 if (last_active) {
4027 const idx = nodeIndex(last_active);
4028 self.setCaret(direction > 0 ? idx + 1 : idx);
4029 self.setActiveItem();
4030 removeClasses(last_active, 'last-active');
4031
4032 // move caret left or right of current position
4033 } else {
4034 self.setCaret(self.caretPos + direction);
4035 }
4036 });
4037 }
4038
4039
4040 //# sourceMappingURL=plugin.js.map
4041
4042
4043 /***/ },
4044
4045 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
4046 /*!****************************************************************************!*\
4047 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
4048 \****************************************************************************/
4049 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4050
4051 "use strict";
4052 __webpack_require__.r(__webpack_exports__);
4053 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4054 /* harmony export */ "default": () => (/* binding */ plugin)
4055 /* harmony export */ });
4056 /**
4057 * Tom Select v2.6.2
4058 * Licensed under the Apache License, Version 2.0 (the "License");
4059 */
4060
4061 /**
4062 * Converts a scalar to its best string representation
4063 * for hash keys and HTML attribute values.
4064 *
4065 * Transformations:
4066 * 'str' -> 'str'
4067 * null -> ''
4068 * undefined -> ''
4069 * true -> '1'
4070 * false -> '0'
4071 * 0 -> '0'
4072 * 1 -> '1'
4073 *
4074 */
4075
4076 /**
4077 * Add event helper
4078 *
4079 */
4080 const addEvent = (target, type, callback, options) => {
4081 target.addEventListener(type, callback, options);
4082 };
4083
4084 /**
4085 * Plugin: "change_listener" (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 () {
4100 addEvent(this.input, 'change', () => {
4101 this.sync();
4102 });
4103 }
4104
4105
4106 //# sourceMappingURL=plugin.js.map
4107
4108
4109 /***/ },
4110
4111 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
4112 /*!*****************************************************************************!*\
4113 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
4114 \*****************************************************************************/
4115 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4116
4117 "use strict";
4118 __webpack_require__.r(__webpack_exports__);
4119 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4120 /* harmony export */ "default": () => (/* binding */ plugin)
4121 /* harmony export */ });
4122 /**
4123 * Tom Select v2.6.2
4124 * Licensed under the Apache License, Version 2.0 (the "License");
4125 */
4126
4127 /**
4128 * Converts a scalar to its best string representation
4129 * for hash keys and HTML attribute values.
4130 *
4131 * Transformations:
4132 * 'str' -> 'str'
4133 * null -> ''
4134 * undefined -> ''
4135 * true -> '1'
4136 * false -> '0'
4137 * 0 -> '0'
4138 * 1 -> '1'
4139 *
4140 */
4141 const hash_key = value => {
4142 if (typeof value === 'undefined' || value === null) return null;
4143 return get_hash(value);
4144 };
4145 const get_hash = value => {
4146 if (typeof value === 'boolean') return value ? '1' : '0';
4147 return value + '';
4148 };
4149
4150 /**
4151 * Prevent default
4152 *
4153 */
4154 const preventDefault = (evt, stop = false) => {
4155 if (evt) {
4156 evt.preventDefault();
4157 if (stop) {
4158 evt.stopPropagation();
4159 }
4160 }
4161 };
4162
4163 /**
4164 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
4165 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
4166 *
4167 * param query should be {}
4168 */
4169 const getDom = query => {
4170 if (query.jquery) {
4171 return query[0];
4172 }
4173 if (query instanceof HTMLElement) {
4174 return query;
4175 }
4176 if (isHtmlString(query)) {
4177 var tpl = document.createElement('template');
4178 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
4179 return tpl.content.firstChild;
4180 }
4181 return document.querySelector(query);
4182 };
4183 const isHtmlString = arg => {
4184 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
4185 return true;
4186 }
4187 return false;
4188 };
4189
4190 /**
4191 * Plugin: "checkbox_options" (Tom Select)
4192 * Copyright (c) contributors
4193 *
4194 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4195 * file except in compliance with the License. You may obtain a copy of the License at:
4196 * http://www.apache.org/licenses/LICENSE-2.0
4197 *
4198 * Unless required by applicable law or agreed to in writing, software distributed under
4199 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4200 * ANY KIND, either express or implied. See the License for the specific language
4201 * governing permissions and limitations under the License.
4202 *
4203 */
4204
4205 function plugin (userOptions) {
4206 var self = this;
4207 var orig_onOptionSelect = self.onOptionSelect;
4208 self.settings.hideSelected = false;
4209 const cbOptions = Object.assign({
4210 // so that the user may add different ones as well
4211 className: "tomselect-checkbox",
4212 // the following default to the historic plugin's values
4213 checkedClassNames: undefined,
4214 uncheckedClassNames: undefined
4215 }, userOptions);
4216 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
4217 if (toCheck) {
4218 checkbox.checked = true;
4219 if (cbOptions.uncheckedClassNames) {
4220 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
4221 }
4222 if (cbOptions.checkedClassNames) {
4223 checkbox.classList.add(...cbOptions.checkedClassNames);
4224 }
4225 } else {
4226 checkbox.checked = false;
4227 if (cbOptions.checkedClassNames) {
4228 checkbox.classList.remove(...cbOptions.checkedClassNames);
4229 }
4230 if (cbOptions.uncheckedClassNames) {
4231 checkbox.classList.add(...cbOptions.uncheckedClassNames);
4232 }
4233 }
4234 };
4235
4236 // update the checkbox for an option
4237 var UpdateCheckbox = function UpdateCheckbox(option) {
4238 setTimeout(() => {
4239 var checkbox = option.querySelector('input.' + cbOptions.className);
4240 if (checkbox instanceof HTMLInputElement) {
4241 UpdateChecked(checkbox, option.classList.contains('selected'));
4242 }
4243 }, 1);
4244 };
4245
4246 // add checkbox to option template
4247 self.hook('after', 'setupTemplates', () => {
4248 var orig_render_option = self.settings.render.option;
4249 self.settings.render.option = (data, escape_html) => {
4250 var rendered = getDom(orig_render_option.call(self, data, escape_html));
4251 var checkbox = document.createElement('input');
4252 if (cbOptions.className) {
4253 checkbox.classList.add(cbOptions.className);
4254 }
4255 checkbox.addEventListener('click', function (evt) {
4256 preventDefault(evt);
4257 });
4258 checkbox.type = 'checkbox';
4259 const hashed = hash_key(data[self.settings.valueField]);
4260 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
4261 rendered.prepend(checkbox);
4262 return rendered;
4263 };
4264 });
4265
4266 // uncheck when item removed
4267 self.on('item_remove', value => {
4268 var option = self.getOption(value);
4269 if (option) {
4270 // if dropdown hasn't been opened yet, the option won't exist
4271 option.classList.remove('selected'); // selected class won't be removed yet
4272 UpdateCheckbox(option);
4273 }
4274 });
4275
4276 // check when item added
4277 self.on('item_add', value => {
4278 var option = self.getOption(value);
4279 if (option) {
4280 // if dropdown hasn't been opened yet, the option won't exist
4281 UpdateCheckbox(option);
4282 }
4283 });
4284
4285 // remove items when selected option is clicked
4286 self.hook('instead', 'onOptionSelect', (evt, option) => {
4287 if (option.classList.contains('selected')) {
4288 option.classList.remove('selected');
4289 self.removeItem(option.dataset.value);
4290 self.refreshOptions();
4291 preventDefault(evt, true);
4292 return;
4293 }
4294 orig_onOptionSelect.call(self, evt, option);
4295 UpdateCheckbox(option);
4296 });
4297 }
4298
4299
4300 //# sourceMappingURL=plugin.js.map
4301
4302
4303 /***/ },
4304
4305 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
4306 /*!*************************************************************************!*\
4307 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
4308 \*************************************************************************/
4309 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4310
4311 "use strict";
4312 __webpack_require__.r(__webpack_exports__);
4313 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4314 /* harmony export */ "default": () => (/* binding */ plugin)
4315 /* harmony export */ });
4316 /**
4317 * Tom Select v2.6.2
4318 * Licensed under the Apache License, Version 2.0 (the "License");
4319 */
4320
4321 /**
4322 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
4323 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
4324 *
4325 * param query should be {}
4326 */
4327 const getDom = query => {
4328 if (query.jquery) {
4329 return query[0];
4330 }
4331 if (query instanceof HTMLElement) {
4332 return query;
4333 }
4334 if (isHtmlString(query)) {
4335 var tpl = document.createElement('template');
4336 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
4337 return tpl.content.firstChild;
4338 }
4339 return document.querySelector(query);
4340 };
4341 const isHtmlString = arg => {
4342 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
4343 return true;
4344 }
4345 return false;
4346 };
4347
4348 /**
4349 * Plugin: "dropdown_header" (Tom Select)
4350 * Copyright (c) contributors
4351 *
4352 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4353 * file except in compliance with the License. You may obtain a copy of the License at:
4354 * http://www.apache.org/licenses/LICENSE-2.0
4355 *
4356 * Unless required by applicable law or agreed to in writing, software distributed under
4357 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4358 * ANY KIND, either express or implied. See the License for the specific language
4359 * governing permissions and limitations under the License.
4360 *
4361 */
4362
4363 function plugin (userOptions) {
4364 const self = this;
4365 const options = Object.assign({
4366 className: 'clear-button',
4367 title: 'Clear All',
4368 role: 'button',
4369 tabindex: 0,
4370 html: data => {
4371 return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">&times;</div>`;
4372 }
4373 }, userOptions);
4374 self.on('initialize', () => {
4375 var button = getDom(options.html(options));
4376 button.addEventListener('click', evt => {
4377 if (self.isLocked) return;
4378 self.clear();
4379 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
4380 self.addItem('');
4381 }
4382 self.refreshOptions(false);
4383 evt.preventDefault();
4384 evt.stopPropagation();
4385 });
4386 self.control.appendChild(button);
4387 });
4388 }
4389
4390
4391 //# sourceMappingURL=plugin.js.map
4392
4393
4394 /***/ },
4395
4396 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
4397 /*!**********************************************************************!*\
4398 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
4399 \**********************************************************************/
4400 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4401
4402 "use strict";
4403 __webpack_require__.r(__webpack_exports__);
4404 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4405 /* harmony export */ "default": () => (/* binding */ plugin)
4406 /* harmony export */ });
4407 /**
4408 * Tom Select v2.6.2
4409 * Licensed under the Apache License, Version 2.0 (the "License");
4410 */
4411
4412 /**
4413 * Converts a scalar to its best string representation
4414 * for hash keys and HTML attribute values.
4415 *
4416 * Transformations:
4417 * 'str' -> 'str'
4418 * null -> ''
4419 * undefined -> ''
4420 * true -> '1'
4421 * false -> '0'
4422 * 0 -> '0'
4423 * 1 -> '1'
4424 *
4425 */
4426
4427 /**
4428 * Prevent default
4429 *
4430 */
4431 const preventDefault = (evt, stop = false) => {
4432 if (evt) {
4433 evt.preventDefault();
4434 if (stop) {
4435 evt.stopPropagation();
4436 }
4437 }
4438 };
4439
4440 /**
4441 * Add event helper
4442 *
4443 */
4444 const addEvent = (target, type, callback, options) => {
4445 target.addEventListener(type, callback, options);
4446 };
4447
4448 /**
4449 * Iterates over arrays and hashes.
4450 *
4451 * ```
4452 * iterate(this.items, function(item, id) {
4453 * // invoked for each item
4454 * });
4455 * ```
4456 *
4457 */
4458 const iterate = (object, callback) => {
4459 if (Array.isArray(object)) {
4460 object.forEach(callback);
4461 } else {
4462 for (var key in object) {
4463 if (object.hasOwnProperty(key)) {
4464 callback(object[key], key);
4465 }
4466 }
4467 }
4468 };
4469
4470 /**
4471 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
4472 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
4473 *
4474 * param query should be {}
4475 */
4476 const getDom = query => {
4477 if (query.jquery) {
4478 return query[0];
4479 }
4480 if (query instanceof HTMLElement) {
4481 return query;
4482 }
4483 if (isHtmlString(query)) {
4484 var tpl = document.createElement('template');
4485 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
4486 return tpl.content.firstChild;
4487 }
4488 return document.querySelector(query);
4489 };
4490 const isHtmlString = arg => {
4491 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
4492 return true;
4493 }
4494 return false;
4495 };
4496
4497 /**
4498 * Set attributes of an element
4499 *
4500 */
4501 const setAttr = (el, attrs) => {
4502 iterate(attrs, (val, attr) => {
4503 if (val == null) {
4504 el.removeAttribute(attr);
4505 } else {
4506 el.setAttribute(attr, '' + val);
4507 }
4508 });
4509 };
4510
4511 /**
4512 * Plugin: "drag_drop" (Tom Select)
4513 * Copyright (c) contributors
4514 *
4515 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4516 * file except in compliance with the License. You may obtain a copy of the License at:
4517 * http://www.apache.org/licenses/LICENSE-2.0
4518 *
4519 * Unless required by applicable law or agreed to in writing, software distributed under
4520 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4521 * ANY KIND, either express or implied. See the License for the specific language
4522 * governing permissions and limitations under the License.
4523 *
4524 */
4525
4526 const insertAfter = (referenceNode, newNode) => {
4527 var _referenceNode$parent;
4528 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
4529 };
4530 const insertBefore = (referenceNode, newNode) => {
4531 var _referenceNode$parent2;
4532 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
4533 };
4534 const isBefore = (referenceNode, newNode) => {
4535 do {
4536 var _newNode;
4537 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
4538 if (referenceNode == newNode) {
4539 return true;
4540 }
4541 } while (newNode && newNode.previousElementSibling);
4542 return false;
4543 };
4544 function plugin () {
4545 var self = this;
4546 if (self.settings.mode !== 'multi') return;
4547 var orig_lock = self.lock;
4548 var orig_unlock = self.unlock;
4549 let sortable = true;
4550 let drag_item;
4551
4552 /**
4553 * Add draggable attribute to item
4554 */
4555 self.hook('after', 'setupTemplates', () => {
4556 var orig_render_item = self.settings.render.item;
4557 self.settings.render.item = (data, escape) => {
4558 const item = getDom(orig_render_item.call(self, data, escape));
4559 setAttr(item, {
4560 'draggable': 'true'
4561 });
4562
4563 // prevent doc_mousedown (see tom-select.ts)
4564 const mousedown = evt => {
4565 if (!sortable) preventDefault(evt);
4566 evt.stopPropagation();
4567 };
4568 const dragStart = evt => {
4569 drag_item = item;
4570 setTimeout(() => {
4571 item.classList.add('ts-dragging');
4572 }, 0);
4573 };
4574 const dragOver = evt => {
4575 evt.preventDefault();
4576 item.classList.add('ts-drag-over');
4577 moveitem(item, drag_item);
4578 };
4579 const dragLeave = () => {
4580 item.classList.remove('ts-drag-over');
4581 };
4582 const moveitem = (targetitem, dragitem) => {
4583 if (dragitem === undefined) return;
4584 if (isBefore(dragitem, item)) {
4585 insertAfter(targetitem, dragitem);
4586 } else {
4587 insertBefore(targetitem, dragitem);
4588 }
4589 };
4590 const dragend = () => {
4591 var _drag_item;
4592 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
4593 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
4594 drag_item = undefined;
4595 var values = [];
4596 self.control.querySelectorAll(`[data-value]`).forEach(el => {
4597 if (el.dataset.value) {
4598 let value = el.dataset.value;
4599 if (value) {
4600 values.push(value);
4601 }
4602 }
4603 });
4604 self.setValue(values);
4605 };
4606 addEvent(item, 'mousedown', mousedown);
4607 addEvent(item, 'dragstart', dragStart);
4608 addEvent(item, 'dragenter', dragOver);
4609 addEvent(item, 'dragover', dragOver);
4610 addEvent(item, 'dragleave', dragLeave);
4611 addEvent(item, 'dragend', dragend);
4612 return item;
4613 };
4614 });
4615 self.hook('instead', 'lock', () => {
4616 sortable = false;
4617 return orig_lock.call(self);
4618 });
4619 self.hook('instead', 'unlock', () => {
4620 sortable = true;
4621 return orig_unlock.call(self);
4622 });
4623 }
4624
4625
4626 //# sourceMappingURL=plugin.js.map
4627
4628
4629 /***/ },
4630
4631 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
4632 /*!****************************************************************************!*\
4633 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
4634 \****************************************************************************/
4635 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4636
4637 "use strict";
4638 __webpack_require__.r(__webpack_exports__);
4639 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4640 /* harmony export */ "default": () => (/* binding */ plugin)
4641 /* harmony export */ });
4642 /**
4643 * Tom Select v2.6.2
4644 * Licensed under the Apache License, Version 2.0 (the "License");
4645 */
4646
4647 /**
4648 * Converts a scalar to its best string representation
4649 * for hash keys and HTML attribute values.
4650 *
4651 * Transformations:
4652 * 'str' -> 'str'
4653 * null -> ''
4654 * undefined -> ''
4655 * true -> '1'
4656 * false -> '0'
4657 * 0 -> '0'
4658 * 1 -> '1'
4659 *
4660 */
4661
4662 /**
4663 * Prevent default
4664 *
4665 */
4666 const preventDefault = (evt, stop = false) => {
4667 if (evt) {
4668 evt.preventDefault();
4669 if (stop) {
4670 evt.stopPropagation();
4671 }
4672 }
4673 };
4674
4675 /**
4676 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
4677 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
4678 *
4679 * param query should be {}
4680 */
4681 const getDom = query => {
4682 if (query.jquery) {
4683 return query[0];
4684 }
4685 if (query instanceof HTMLElement) {
4686 return query;
4687 }
4688 if (isHtmlString(query)) {
4689 var tpl = document.createElement('template');
4690 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
4691 return tpl.content.firstChild;
4692 }
4693 return document.querySelector(query);
4694 };
4695 const isHtmlString = arg => {
4696 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
4697 return true;
4698 }
4699 return false;
4700 };
4701
4702 /**
4703 * Plugin: "dropdown_header" (Tom Select)
4704 * Copyright (c) contributors
4705 *
4706 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4707 * file except in compliance with the License. You may obtain a copy of the License at:
4708 * http://www.apache.org/licenses/LICENSE-2.0
4709 *
4710 * Unless required by applicable law or agreed to in writing, software distributed under
4711 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4712 * ANY KIND, either express or implied. See the License for the specific language
4713 * governing permissions and limitations under the License.
4714 *
4715 */
4716
4717 function plugin (userOptions) {
4718 const self = this;
4719 const options = Object.assign({
4720 title: 'Untitled',
4721 headerClass: 'dropdown-header',
4722 titleRowClass: 'dropdown-header-title',
4723 labelClass: 'dropdown-header-label',
4724 closeClass: 'dropdown-header-close',
4725 html: data => {
4726 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
4727 }
4728 }, userOptions);
4729 self.on('initialize', () => {
4730 var header = getDom(options.html(options));
4731 var close_link = header.querySelector('.' + options.closeClass);
4732 if (close_link) {
4733 close_link.addEventListener('click', evt => {
4734 preventDefault(evt, true);
4735 self.close();
4736 });
4737 }
4738 self.dropdown.insertBefore(header, self.dropdown.firstChild);
4739 });
4740 }
4741
4742
4743 //# sourceMappingURL=plugin.js.map
4744
4745
4746 /***/ },
4747
4748 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
4749 /*!***************************************************************************!*\
4750 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
4751 \***************************************************************************/
4752 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4753
4754 "use strict";
4755 __webpack_require__.r(__webpack_exports__);
4756 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4757 /* harmony export */ "default": () => (/* binding */ plugin)
4758 /* harmony export */ });
4759 /**
4760 * Tom Select v2.6.2
4761 * Licensed under the Apache License, Version 2.0 (the "License");
4762 */
4763
4764 const KEY_ESC = 27;
4765 const KEY_TAB = 9;
4766 // ctrl key or apple key for ma
4767
4768 /**
4769 * Converts a scalar to its best string representation
4770 * for hash keys and HTML attribute values.
4771 *
4772 * Transformations:
4773 * 'str' -> 'str'
4774 * null -> ''
4775 * undefined -> ''
4776 * true -> '1'
4777 * false -> '0'
4778 * 0 -> '0'
4779 * 1 -> '1'
4780 *
4781 */
4782
4783 /**
4784 * Prevent default
4785 *
4786 */
4787 const preventDefault = (evt, stop = false) => {
4788 if (evt) {
4789 evt.preventDefault();
4790 if (stop) {
4791 evt.stopPropagation();
4792 }
4793 }
4794 };
4795
4796 /**
4797 * Add event helper
4798 *
4799 */
4800 const addEvent = (target, type, callback, options) => {
4801 target.addEventListener(type, callback, options);
4802 };
4803
4804 /**
4805 * Iterates over arrays and hashes.
4806 *
4807 * ```
4808 * iterate(this.items, function(item, id) {
4809 * // invoked for each item
4810 * });
4811 * ```
4812 *
4813 */
4814 const iterate = (object, callback) => {
4815 if (Array.isArray(object)) {
4816 object.forEach(callback);
4817 } else {
4818 for (var key in object) {
4819 if (object.hasOwnProperty(key)) {
4820 callback(object[key], key);
4821 }
4822 }
4823 }
4824 };
4825
4826 /**
4827 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
4828 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
4829 *
4830 * param query should be {}
4831 */
4832 const getDom = query => {
4833 if (query.jquery) {
4834 return query[0];
4835 }
4836 if (query instanceof HTMLElement) {
4837 return query;
4838 }
4839 if (isHtmlString(query)) {
4840 var tpl = document.createElement('template');
4841 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
4842 return tpl.content.firstChild;
4843 }
4844 return document.querySelector(query);
4845 };
4846 const isHtmlString = arg => {
4847 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
4848 return true;
4849 }
4850 return false;
4851 };
4852
4853 /**
4854 * Add css classes
4855 *
4856 */
4857 const addClasses = (elmts, ...classes) => {
4858 var norm_classes = classesArray(classes);
4859 elmts = castAsArray(elmts);
4860 elmts.map(el => {
4861 norm_classes.map(cls => {
4862 el.classList.add(cls);
4863 });
4864 });
4865 };
4866
4867 /**
4868 * Return arguments
4869 *
4870 */
4871 const classesArray = args => {
4872 var classes = [];
4873 iterate(args, _classes => {
4874 if (typeof _classes === 'string') {
4875 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
4876 }
4877 if (Array.isArray(_classes)) {
4878 classes = classes.concat(_classes);
4879 }
4880 });
4881 return classes.filter(Boolean);
4882 };
4883
4884 /**
4885 * Create an array from arg if it's not already an array
4886 *
4887 */
4888 const castAsArray = arg => {
4889 if (!Array.isArray(arg)) {
4890 arg = [arg];
4891 }
4892 return arg;
4893 };
4894
4895 /**
4896 * Plugin: "dropdown_input" (Tom Select)
4897 * Copyright (c) contributors
4898 *
4899 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4900 * file except in compliance with the License. You may obtain a copy of the License at:
4901 * http://www.apache.org/licenses/LICENSE-2.0
4902 *
4903 * Unless required by applicable law or agreed to in writing, software distributed under
4904 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4905 * ANY KIND, either express or implied. See the License for the specific language
4906 * governing permissions and limitations under the License.
4907 *
4908 */
4909
4910 function plugin () {
4911 const self = this;
4912 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
4913
4914 self.hook('before', 'setup', () => {
4915 var _self$input;
4916 self.focus_node = self.control;
4917 addClasses(self.control_input, 'dropdown-input');
4918 const div = getDom('<div class="dropdown-input-wrap">');
4919 div.append(self.control_input);
4920 self.dropdown.insertBefore(div, self.dropdown.firstChild);
4921
4922 // set a placeholder in the select control
4923 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
4924 placeholder.placeholder = self.settings.placeholder || '';
4925 self.control.append(placeholder);
4926 /**
4927 * TomSelect renders a custom control with a focusable <input class="items-placeholder">.
4928 * The source <select>'s aria-label is not automatically propagated to that input,
4929 * which triggers "Missing form label" accessibility warnings.
4930 * This helper copies the label from the <select> onto the generated input.
4931 */
4932 const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label');
4933 if (!label) return;
4934 placeholder.setAttribute('aria-label', label);
4935 });
4936 self.on('initialize', () => {
4937 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
4938 self.control_input.addEventListener('keydown', evt => {
4939 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
4940 switch (evt.keyCode) {
4941 case KEY_ESC:
4942 if (self.isOpen) {
4943 preventDefault(evt, true);
4944 self.close();
4945 }
4946 self.clearActiveItems();
4947 return;
4948 case KEY_TAB:
4949 self.focus_node.tabIndex = -1;
4950 break;
4951 }
4952 return self.onKeyDown.call(self, evt);
4953 });
4954 self.on('blur', () => {
4955 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
4956 });
4957
4958 // give the control_input focus when the dropdown is open
4959 self.on('dropdown_open', () => {
4960 self.control_input.focus();
4961 });
4962
4963 // prevent onBlur from closing when focus is on the control_input
4964 const orig_onBlur = self.onBlur;
4965 self.hook('instead', 'onBlur', evt => {
4966 if (evt && evt.relatedTarget == self.control_input) return;
4967 return orig_onBlur.call(self);
4968 });
4969 addEvent(self.control_input, 'blur', () => self.onBlur());
4970
4971 // return focus to control to allow further keyboard input
4972 self.hook('before', 'close', () => {
4973 if (!self.isOpen) return;
4974 self.focus_node.focus({
4975 preventScroll: true
4976 });
4977 });
4978 });
4979 }
4980
4981
4982 //# sourceMappingURL=plugin.js.map
4983
4984
4985 /***/ },
4986
4987 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
4988 /*!***************************************************************************!*\
4989 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
4990 \***************************************************************************/
4991 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4992
4993 "use strict";
4994 __webpack_require__.r(__webpack_exports__);
4995 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4996 /* harmony export */ "default": () => (/* binding */ plugin)
4997 /* harmony export */ });
4998 /**
4999 * Tom Select v2.6.2
5000 * Licensed under the Apache License, Version 2.0 (the "License");
5001 */
5002
5003 /**
5004 * Converts a scalar to its best string representation
5005 * for hash keys and HTML attribute values.
5006 *
5007 * Transformations:
5008 * 'str' -> 'str'
5009 * null -> ''
5010 * undefined -> ''
5011 * true -> '1'
5012 * false -> '0'
5013 * 0 -> '0'
5014 * 1 -> '1'
5015 *
5016 */
5017
5018 /**
5019 * Add event helper
5020 *
5021 */
5022 const addEvent = (target, type, callback, options) => {
5023 target.addEventListener(type, callback, options);
5024 };
5025
5026 /**
5027 * Plugin: "input_autogrow" (Tom Select)
5028 *
5029 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5030 * file except in compliance with the License. You may obtain a copy of the License at:
5031 * http://www.apache.org/licenses/LICENSE-2.0
5032 *
5033 * Unless required by applicable law or agreed to in writing, software distributed under
5034 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5035 * ANY KIND, either express or implied. See the License for the specific language
5036 * governing permissions and limitations under the License.
5037 *
5038 */
5039
5040 function plugin () {
5041 var self = this;
5042 self.on('initialize', () => {
5043 var test_input = document.createElement('span');
5044 var control = self.control_input;
5045 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
5046 self.wrapper.appendChild(test_input);
5047 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
5048 for (const style_name of transfer_styles) {
5049 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
5050 test_input.style[style_name] = control.style[style_name];
5051 }
5052
5053 /**
5054 * Set the control width
5055 *
5056 */
5057 var resize = () => {
5058 test_input.textContent = control.value;
5059 control.style.width = test_input.clientWidth + 'px';
5060 };
5061 resize();
5062 self.on('update item_add item_remove', resize);
5063 addEvent(control, 'input', resize);
5064 addEvent(control, 'keyup', resize);
5065 addEvent(control, 'blur', resize);
5066 addEvent(control, 'update', resize);
5067 });
5068 }
5069
5070
5071 //# sourceMappingURL=plugin.js.map
5072
5073
5074 /***/ },
5075
5076 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
5077 /*!****************************************************************************!*\
5078 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
5079 \****************************************************************************/
5080 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5081
5082 "use strict";
5083 __webpack_require__.r(__webpack_exports__);
5084 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5085 /* harmony export */ "default": () => (/* binding */ plugin)
5086 /* harmony export */ });
5087 /**
5088 * Tom Select v2.6.2
5089 * Licensed under the Apache License, Version 2.0 (the "License");
5090 */
5091
5092 /**
5093 * Plugin: "no_active_items" (Tom Select)
5094 *
5095 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5096 * file except in compliance with the License. You may obtain a copy of the License at:
5097 * http://www.apache.org/licenses/LICENSE-2.0
5098 *
5099 * Unless required by applicable law or agreed to in writing, software distributed under
5100 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5101 * ANY KIND, either express or implied. See the License for the specific language
5102 * governing permissions and limitations under the License.
5103 *
5104 */
5105
5106 function plugin () {
5107 this.hook('instead', 'setActiveItem', () => {});
5108 this.hook('instead', 'selectAll', () => {});
5109 }
5110
5111
5112 //# sourceMappingURL=plugin.js.map
5113
5114
5115 /***/ },
5116
5117 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
5118 /*!********************************************************************************!*\
5119 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
5120 \********************************************************************************/
5121 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5122
5123 "use strict";
5124 __webpack_require__.r(__webpack_exports__);
5125 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5126 /* harmony export */ "default": () => (/* binding */ plugin)
5127 /* harmony export */ });
5128 /**
5129 * Tom Select v2.6.2
5130 * Licensed under the Apache License, Version 2.0 (the "License");
5131 */
5132
5133 /**
5134 * Plugin: "input_autogrow" (Tom Select)
5135 *
5136 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5137 * file except in compliance with the License. You may obtain a copy of the License at:
5138 * http://www.apache.org/licenses/LICENSE-2.0
5139 *
5140 * Unless required by applicable law or agreed to in writing, software distributed under
5141 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5142 * ANY KIND, either express or implied. See the License for the specific language
5143 * governing permissions and limitations under the License.
5144 *
5145 */
5146
5147 function plugin () {
5148 var self = this;
5149 var orig_deleteSelection = self.deleteSelection;
5150 this.hook('instead', 'deleteSelection', evt => {
5151 if (self.activeItems.length) {
5152 return orig_deleteSelection.call(self, evt);
5153 }
5154 return false;
5155 });
5156 }
5157
5158
5159 //# sourceMappingURL=plugin.js.map
5160
5161
5162 /***/ },
5163
5164 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
5165 /*!*****************************************************************************!*\
5166 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
5167 \*****************************************************************************/
5168 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5169
5170 "use strict";
5171 __webpack_require__.r(__webpack_exports__);
5172 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5173 /* harmony export */ "default": () => (/* binding */ plugin)
5174 /* harmony export */ });
5175 /**
5176 * Tom Select v2.6.2
5177 * Licensed under the Apache License, Version 2.0 (the "License");
5178 */
5179
5180 const KEY_LEFT = 37;
5181 const KEY_RIGHT = 39;
5182 // ctrl key or apple key for ma
5183
5184 /**
5185 * Get the closest node to the evt.target matching the selector
5186 * Stops at wrapper
5187 *
5188 */
5189 const parentMatch = (target, selector, wrapper) => {
5190 while (target && target.matches) {
5191 if (target.matches(selector)) {
5192 return target;
5193 }
5194 target = target.parentNode;
5195 }
5196 };
5197
5198 /**
5199 * Get the index of an element amongst sibling nodes of the same type
5200 *
5201 */
5202 const nodeIndex = (el, amongst) => {
5203 if (!el) return -1;
5204 amongst = amongst || el.nodeName;
5205 var i = 0;
5206 while (el = el.previousElementSibling) {
5207 if (el.matches(amongst)) {
5208 i++;
5209 }
5210 }
5211 return i;
5212 };
5213
5214 /**
5215 * Plugin: "optgroup_columns" (Tom Select.js)
5216 * Copyright (c) contributors
5217 *
5218 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5219 * file except in compliance with the License. You may obtain a copy of the License at:
5220 * http://www.apache.org/licenses/LICENSE-2.0
5221 *
5222 * Unless required by applicable law or agreed to in writing, software distributed under
5223 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5224 * ANY KIND, either express or implied. See the License for the specific language
5225 * governing permissions and limitations under the License.
5226 *
5227 */
5228
5229 function plugin () {
5230 var self = this;
5231 var orig_keydown = self.onKeyDown;
5232 self.hook('instead', 'onKeyDown', evt => {
5233 var index, option, options, optgroup;
5234 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
5235 return orig_keydown.call(self, evt);
5236 }
5237 self.ignoreHover = true;
5238 optgroup = parentMatch(self.activeOption, '[data-group]');
5239 index = nodeIndex(self.activeOption, '[data-selectable]');
5240 if (!optgroup) {
5241 return;
5242 }
5243 if (evt.keyCode === KEY_LEFT) {
5244 optgroup = optgroup.previousSibling;
5245 } else {
5246 optgroup = optgroup.nextSibling;
5247 }
5248 if (!optgroup) {
5249 return;
5250 }
5251 options = optgroup.querySelectorAll('[data-selectable]');
5252 option = options[Math.min(options.length - 1, index)];
5253 if (option) {
5254 self.setActiveOption(option);
5255 }
5256 });
5257 }
5258
5259
5260 //# sourceMappingURL=plugin.js.map
5261
5262
5263 /***/ },
5264
5265 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
5266 /*!**************************************************************************!*\
5267 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
5268 \**************************************************************************/
5269 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5270
5271 "use strict";
5272 __webpack_require__.r(__webpack_exports__);
5273 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5274 /* harmony export */ "default": () => (/* binding */ plugin)
5275 /* harmony export */ });
5276 /**
5277 * Tom Select v2.6.2
5278 * Licensed under the Apache License, Version 2.0 (the "License");
5279 */
5280
5281 /**
5282 * Converts a scalar to its best string representation
5283 * for hash keys and HTML attribute values.
5284 *
5285 * Transformations:
5286 * 'str' -> 'str'
5287 * null -> ''
5288 * undefined -> ''
5289 * true -> '1'
5290 * false -> '0'
5291 * 0 -> '0'
5292 * 1 -> '1'
5293 *
5294 */
5295
5296 /**
5297 * Prevent default
5298 *
5299 */
5300 const preventDefault = (evt, stop = false) => {
5301 if (evt) {
5302 evt.preventDefault();
5303 if (stop) {
5304 evt.stopPropagation();
5305 }
5306 }
5307 };
5308
5309 /**
5310 * Add event helper
5311 *
5312 */
5313 const addEvent = (target, type, callback, options) => {
5314 target.addEventListener(type, callback, options);
5315 };
5316
5317 /**
5318 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
5319 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
5320 *
5321 * param query should be {}
5322 */
5323 const getDom = query => {
5324 if (query.jquery) {
5325 return query[0];
5326 }
5327 if (query instanceof HTMLElement) {
5328 return query;
5329 }
5330 if (isHtmlString(query)) {
5331 var tpl = document.createElement('template');
5332 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
5333 return tpl.content.firstChild;
5334 }
5335 return document.querySelector(query);
5336 };
5337 const isHtmlString = arg => {
5338 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
5339 return true;
5340 }
5341 return false;
5342 };
5343
5344 /**
5345 * Plugin: "remove_button" (Tom Select)
5346 * Copyright (c) contributors
5347 *
5348 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5349 * file except in compliance with the License. You may obtain a copy of the License at:
5350 * http://www.apache.org/licenses/LICENSE-2.0
5351 *
5352 * Unless required by applicable law or agreed to in writing, software distributed under
5353 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5354 * ANY KIND, either express or implied. See the License for the specific language
5355 * governing permissions and limitations under the License.
5356 *
5357 */
5358
5359 function plugin (userOptions) {
5360 const self = this;
5361 const options = Object.assign({
5362 label: '×',
5363 title: 'Remove',
5364 className: 'remove',
5365 tabindex: -1,
5366 role: 'button',
5367 html: data => {
5368 var _data$tabindex;
5369 const el = document.createElement('div');
5370 el.className = data.className || '';
5371 el.title = data.title || '';
5372 el.setAttribute('role', data.role || 'button');
5373 el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1;
5374 el.textContent = data.label || '';
5375 return el;
5376 }
5377 }, userOptions);
5378 self.hook('after', 'setupTemplates', () => {
5379 var orig_render_item = self.settings.render.item;
5380 self.settings.render.item = (data, escape) => {
5381 var item = getDom(orig_render_item.call(self, data, escape));
5382 var close_button = getDom(options.html(options));
5383 item.appendChild(close_button);
5384 addEvent(close_button, 'mousedown', evt => {
5385 preventDefault(evt, true);
5386 });
5387 addEvent(close_button, 'click', evt => {
5388 if (self.isLocked) return;
5389
5390 // propagating will trigger the dropdown to show for single mode
5391 preventDefault(evt, true);
5392 if (self.isLocked) return;
5393 if (!self.shouldDelete([item], evt)) return;
5394 self.removeItem(item);
5395 self.refreshOptions(false);
5396 self.inputState();
5397 });
5398 return item;
5399 };
5400 });
5401 }
5402
5403
5404 //# sourceMappingURL=plugin.js.map
5405
5406
5407 /***/ },
5408
5409 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
5410 /*!*********************************************************************************!*\
5411 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
5412 \*********************************************************************************/
5413 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5414
5415 "use strict";
5416 __webpack_require__.r(__webpack_exports__);
5417 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5418 /* harmony export */ "default": () => (/* binding */ plugin)
5419 /* harmony export */ });
5420 /**
5421 * Tom Select v2.6.2
5422 * Licensed under the Apache License, Version 2.0 (the "License");
5423 */
5424
5425 /**
5426 * Plugin: "restore_on_backspace" (Tom Select)
5427 * Copyright (c) contributors
5428 *
5429 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5430 * file except in compliance with the License. You may obtain a copy of the License at:
5431 * http://www.apache.org/licenses/LICENSE-2.0
5432 *
5433 * Unless required by applicable law or agreed to in writing, software distributed under
5434 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5435 * ANY KIND, either express or implied. See the License for the specific language
5436 * governing permissions and limitations under the License.
5437 *
5438 */
5439
5440 function plugin (userOptions) {
5441 const self = this;
5442 const options = Object.assign({
5443 text: option => {
5444 return option[self.settings.labelField];
5445 }
5446 }, userOptions);
5447 self.on('item_remove', function (value) {
5448 if (!self.isFocused) {
5449 return;
5450 }
5451 if (self.control_input.value.trim() === '') {
5452 var option = self.options[value];
5453 if (option) {
5454 self.setTextboxValue(options.text.call(self, option));
5455 }
5456 }
5457 });
5458 }
5459
5460
5461 //# sourceMappingURL=plugin.js.map
5462
5463
5464 /***/ },
5465
5466 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
5467 /*!***************************************************************************!*\
5468 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
5469 \***************************************************************************/
5470 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5471
5472 "use strict";
5473 __webpack_require__.r(__webpack_exports__);
5474 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5475 /* harmony export */ "default": () => (/* binding */ plugin)
5476 /* harmony export */ });
5477 /**
5478 * Tom Select v2.6.2
5479 * Licensed under the Apache License, Version 2.0 (the "License");
5480 */
5481
5482 /**
5483 * Converts a scalar to its best string representation
5484 * for hash keys and HTML attribute values.
5485 *
5486 * Transformations:
5487 * 'str' -> 'str'
5488 * null -> ''
5489 * undefined -> ''
5490 * true -> '1'
5491 * false -> '0'
5492 * 0 -> '0'
5493 * 1 -> '1'
5494 *
5495 */
5496
5497 /**
5498 * Iterates over arrays and hashes.
5499 *
5500 * ```
5501 * iterate(this.items, function(item, id) {
5502 * // invoked for each item
5503 * });
5504 * ```
5505 *
5506 */
5507 const iterate = (object, callback) => {
5508 if (Array.isArray(object)) {
5509 object.forEach(callback);
5510 } else {
5511 for (var key in object) {
5512 if (object.hasOwnProperty(key)) {
5513 callback(object[key], key);
5514 }
5515 }
5516 }
5517 };
5518
5519 /**
5520 * Add css classes
5521 *
5522 */
5523 const addClasses = (elmts, ...classes) => {
5524 var norm_classes = classesArray(classes);
5525 elmts = castAsArray(elmts);
5526 elmts.map(el => {
5527 norm_classes.map(cls => {
5528 el.classList.add(cls);
5529 });
5530 });
5531 };
5532
5533 /**
5534 * Return arguments
5535 *
5536 */
5537 const classesArray = args => {
5538 var classes = [];
5539 iterate(args, _classes => {
5540 if (typeof _classes === 'string') {
5541 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
5542 }
5543 if (Array.isArray(_classes)) {
5544 classes = classes.concat(_classes);
5545 }
5546 });
5547 return classes.filter(Boolean);
5548 };
5549
5550 /**
5551 * Create an array from arg if it's not already an array
5552 *
5553 */
5554 const castAsArray = arg => {
5555 if (!Array.isArray(arg)) {
5556 arg = [arg];
5557 }
5558 return arg;
5559 };
5560
5561 /**
5562 * Plugin: "virtual_scroll" (Tom Select)
5563 * Copyright (c) contributors
5564 *
5565 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5566 * file except in compliance with the License. You may obtain a copy of the License at:
5567 * http://www.apache.org/licenses/LICENSE-2.0
5568 *
5569 * Unless required by applicable law or agreed to in writing, software distributed under
5570 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
5571 * ANY KIND, either express or implied. See the License for the specific language
5572 * governing permissions and limitations under the License.
5573 *
5574 */
5575
5576 function plugin () {
5577 const self = this;
5578 const orig_canLoad = self.canLoad;
5579 const orig_clearActiveOption = self.clearActiveOption;
5580 const orig_loadCallback = self.loadCallback;
5581 var pagination = {};
5582 var dropdown_content;
5583 var loading_more = false;
5584 var load_more_opt;
5585 var default_values = [];
5586 var default_values_loaded = false;
5587 var default_pagination;
5588 var default_options = [];
5589 var html_values = [];
5590 if (!self.settings.shouldLoadMore) {
5591 // return true if additional results should be loaded
5592 self.settings.shouldLoadMore = () => {
5593 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
5594 if (scroll_percent > 0.9) {
5595 return true;
5596 }
5597 if (self.activeOption) {
5598 var selectable = self.selectable();
5599 var index = Array.from(selectable).indexOf(self.activeOption);
5600 if (index >= selectable.length - 2) {
5601 return true;
5602 }
5603 }
5604 return false;
5605 };
5606 }
5607 if (!self.settings.firstUrl) {
5608 throw 'virtual_scroll plugin requires a firstUrl() method';
5609 }
5610
5611 // in order for virtual scrolling to work,
5612 // options need to be ordered the same way they're returned from the remote data source
5613 self.settings.sortField = [{
5614 field: '$order'
5615 }, {
5616 field: '$score'
5617 }];
5618
5619 // can we load more results for given query?
5620 const canLoadMore = query => {
5621 if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
5622 return false;
5623 }
5624 if (query in pagination && pagination[query]) {
5625 return true;
5626 }
5627 return false;
5628 };
5629 const clearFilter = (option, value) => {
5630 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
5631 return true;
5632 }
5633 return false;
5634 };
5635
5636 // set the next url that will be
5637 self.setNextUrl = (value, next_url) => {
5638 pagination[value] = next_url;
5639 };
5640
5641 // getUrl() to be used in settings.load()
5642 self.getUrl = query => {
5643 if (query in pagination) {
5644 const next_url = pagination[query];
5645 pagination[query] = false;
5646 return next_url;
5647 }
5648
5649 // if the user goes back to a previous query
5650 // we need to load the first page again
5651 self.clearPagination();
5652 return self.settings.firstUrl.call(self, query);
5653 };
5654
5655 // clear pagination
5656 self.clearPagination = () => {
5657 pagination = {};
5658 };
5659
5660 // don't clear the active option (and cause unwanted dropdown scroll)
5661 // while loading more results
5662 self.hook('instead', 'clearActiveOption', () => {
5663 if (loading_more) {
5664 return;
5665 }
5666 return orig_clearActiveOption.call(self);
5667 });
5668
5669 // override the canLoad method
5670 self.hook('instead', 'canLoad', query => {
5671 // first time the query has been seen
5672 if (!(query in pagination)) {
5673 return orig_canLoad.call(self, query);
5674 }
5675 return canLoadMore(query);
5676 });
5677
5678 // wrap the load
5679 self.hook('instead', 'loadCallback', (options, optgroups) => {
5680 if (!loading_more) {
5681 // When searching (non-empty query), keep selected items and HTML default options,
5682 // but remove preloaded remote options so they don't bleed into search results.
5683 // For empty query, use clearFilter (keeps default_values + items).
5684 const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter;
5685 self.clearOptions(activeFilter);
5686 } else if (load_more_opt) {
5687 const first_option = options[0];
5688 if (first_option !== undefined) {
5689 load_more_opt.dataset.value = first_option[self.settings.valueField];
5690 }
5691 }
5692 orig_loadCallback.call(self, options, optgroups);
5693
5694 // After the initial preload (empty query), snapshot default_values and option objects
5695 // so they can be restored when the user clears their search.
5696 if (!loading_more && !default_values_loaded) {
5697 default_values_loaded = true;
5698 if (self.lastValue === '') {
5699 default_values = Object.keys(self.options);
5700 default_pagination = pagination[''];
5701 default_options = Object.values(self.options);
5702 }
5703 }
5704 loading_more = false;
5705 });
5706
5707 // as the “loading_more” element will be removed from the dropdown,
5708 // we activate the previous option if needed
5709 // to avoid the dropdown being scrolled back to the first one
5710 self.hook('before', 'refreshOptions', () => {
5711 if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) {
5712 self.setActiveOption(self.activeOption.previousElementSibling);
5713 }
5714 });
5715
5716 // add templates to dropdown
5717 // loading_more if we have another url in the queue
5718 // no_more_results if we don't have another url in the queue
5719 self.hook('after', 'refreshOptions', () => {
5720 const query = self.lastValue;
5721 var option;
5722 if (canLoadMore(query)) {
5723 option = self.render('loading_more', {
5724 query: query
5725 });
5726 if (option) {
5727 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
5728 load_more_opt = option;
5729 }
5730 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
5731 option = self.render('no_more_results', {
5732 query: query
5733 });
5734 }
5735 if (option) {
5736 addClasses(option, self.settings.optionClass);
5737 dropdown_content.append(option);
5738 }
5739 });
5740
5741 // Restore preloaded options and pagination when clearing search
5742 const restoreDefaults = () => {
5743 if (!default_values_loaded) {
5744 return;
5745 }
5746 // Re-add preloaded option objects (clearOptions can only remove, not restore)
5747 self.addOptions(default_options);
5748 // Remove any search results that are not part of the preloaded defaults
5749 self.clearOptions(clearFilter);
5750 if (default_pagination) {
5751 pagination[''] = default_pagination;
5752 }
5753 };
5754 self.on('type', query => {
5755 if (query === '') {
5756 restoreDefaults();
5757 self.refreshOptions(false);
5758 }
5759 });
5760 self.on('dropdown_close', restoreDefaults);
5761
5762 // add scroll listener and default templates
5763 self.on('initialize', () => {
5764 html_values = Object.keys(self.options);
5765 default_values = Object.keys(self.options);
5766 dropdown_content = self.dropdown_content;
5767
5768 // default templates
5769 self.settings.render = Object.assign({}, {
5770 loading_more: () => {
5771 return `<div class="loading-more-results">Loading more results ... </div>`;
5772 },
5773 no_more_results: () => {
5774 return `<div class="no-more-results">No more results</div>`;
5775 }
5776 }, self.settings.render);
5777
5778 // watch dropdown content scroll position
5779 dropdown_content.addEventListener('scroll', () => {
5780 if (!self.settings.shouldLoadMore.call(self)) {
5781 return;
5782 }
5783
5784 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
5785 if (!canLoadMore(self.lastValue)) {
5786 return;
5787 }
5788
5789 // don't call load() too much
5790 if (loading_more) return;
5791 loading_more = true;
5792 self.load.call(self, self.lastValue);
5793 });
5794 });
5795 }
5796
5797
5798 //# sourceMappingURL=plugin.js.map
5799
5800
5801 /***/ },
5802
5803 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
5804 /*!*****************************************************************!*\
5805 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
5806 \*****************************************************************/
5807 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5808
5809 "use strict";
5810 __webpack_require__.r(__webpack_exports__);
5811 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5812 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5813 /* harmony export */ });
5814 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
5815 /* 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");
5816 /* 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");
5817 /* 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");
5818 /* 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");
5819 /* 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");
5820 /* 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");
5821 /* 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");
5822 /* 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");
5823 /* 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");
5824 /* 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");
5825 /* 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");
5826 /* 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");
5827 /* 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");
5828 /* 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");
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
5845 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
5846 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
5847 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
5848 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
5849 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
5850 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
5851 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
5852 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
5853 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
5854 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
5855 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
5856 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
5857 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
5858 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
5859 //# sourceMappingURL=tom-select.complete.js.map
5860
5861 /***/ },
5862
5863 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
5864 /*!********************************************************!*\
5865 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
5866 \********************************************************/
5867 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5868
5869 "use strict";
5870 __webpack_require__.r(__webpack_exports__);
5871 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5872 /* harmony export */ "default": () => (/* binding */ TomSelect)
5873 /* harmony export */ });
5874 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
5875 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
5876 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
5877 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
5878 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
5879 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
5880 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
5881 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
5882 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892 var instance_i = 0;
5893 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
5894 constructor(input_arg, user_settings) {
5895 super();
5896 this.order = 0;
5897 this.isOpen = false;
5898 this.isDisabled = false;
5899 this.isReadOnly = false;
5900 this.isInvalid = false; // @deprecated 1.8
5901 this.isValid = true;
5902 this.isLocked = false;
5903 this.isFocused = false;
5904 this.isInputHidden = false;
5905 this.isSetup = false;
5906 this.isDropdownContentStale = true;
5907 this.ignoreFocus = false;
5908 this.ignoreHover = false;
5909 this.hasOptions = false;
5910 this.lastValue = '';
5911 this.caretPos = 0;
5912 this.loading = 0;
5913 this.loadedSearches = {};
5914 this.activeOption = null;
5915 this.activeItems = [];
5916 this.optgroups = {};
5917 this.options = {};
5918 this.userOptions = {};
5919 this.items = [];
5920 this.refreshTimeout = null;
5921 instance_i++;
5922 var dir;
5923 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
5924 if (input.tomselect) {
5925 throw new Error('Tom Select already initialized on this element');
5926 }
5927 input.tomselect = this;
5928 // detect rtl environment
5929 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
5930 dir = computedStyle.getPropertyValue('direction');
5931 // setup default state
5932 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
5933 this.settings = settings;
5934 this.input = input;
5935 this.tabIndex = input.tabIndex || 0;
5936 this.is_select_tag = input.tagName.toLowerCase() === 'select';
5937 this.rtl = /rtl/i.test(dir);
5938 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
5939 this.isRequired = input.required;
5940 // search system
5941 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
5942 // option-dependent defaults
5943 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
5944 if (typeof settings.hideSelected !== 'boolean') {
5945 settings.hideSelected = settings.mode === 'multi';
5946 }
5947 if (typeof settings.hidePlaceholder !== 'boolean') {
5948 settings.hidePlaceholder = settings.mode !== 'multi';
5949 }
5950 // set up createFilter callback
5951 var filter = settings.createFilter;
5952 if (typeof filter !== 'function') {
5953 if (typeof filter === 'string') {
5954 filter = new RegExp(filter);
5955 }
5956 if (filter instanceof RegExp) {
5957 settings.createFilter = (input) => filter.test(input);
5958 }
5959 else {
5960 settings.createFilter = (value) => {
5961 return this.settings.duplicates || !this.options[value];
5962 };
5963 }
5964 }
5965 this.initializePlugins(settings.plugins);
5966 this.setupCallbacks();
5967 this.setupTemplates();
5968 // Create all elements
5969 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
5970 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
5971 const dropdown = this._render('dropdown');
5972 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
5973 const classes = this.input.getAttribute('class') || '';
5974 const inputMode = settings.mode;
5975 var control_input;
5976 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
5977 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
5978 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
5979 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
5980 if (settings.copyClassesToDropdown) {
5981 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
5982 }
5983 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
5984 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
5985 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
5986 // default controlInput
5987 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
5988 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
5989 // set attributes
5990 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
5991 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
5992 if (input.getAttribute(attr)) {
5993 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
5994 }
5995 });
5996 control_input.tabIndex = -1;
5997 control.appendChild(control_input);
5998 this.focus_node = control_input;
5999 // dom element
6000 }
6001 else if (settings.controlInput) {
6002 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
6003 this.focus_node = control_input;
6004 }
6005 else {
6006 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
6007 this.focus_node = control;
6008 }
6009 this.wrapper = wrapper;
6010 this.dropdown = dropdown;
6011 this.dropdown_content = dropdown_content;
6012 this.control = control;
6013 this.control_input = control_input;
6014 this.setup();
6015 }
6016 /**
6017 * set up event bindings.
6018 *
6019 */
6020 setup() {
6021 const self = this;
6022 const settings = self.settings;
6023 const control_input = self.control_input;
6024 const dropdown = self.dropdown;
6025 const dropdown_content = self.dropdown_content;
6026 const wrapper = self.wrapper;
6027 const control = self.control;
6028 const input = self.input;
6029 const focus_node = self.focus_node;
6030 const passive_event = { passive: true };
6031 const listboxId = self.inputId + '-ts-dropdown';
6032 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
6033 id: listboxId
6034 });
6035 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
6036 role: 'combobox',
6037 'aria-haspopup': 'listbox',
6038 'aria-expanded': 'false',
6039 'aria-controls': listboxId
6040 });
6041 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
6042 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
6043 const label = document.querySelector(query);
6044 const label_click = self.focus.bind(self);
6045 if (label) {
6046 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
6047 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
6048 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
6049 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
6050 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
6051 }
6052 wrapper.style.width = input.style.width;
6053 wrapper.style.minWidth = input.style.minWidth;
6054 wrapper.style.maxWidth = input.style.maxWidth;
6055 if (self.plugins.names.length) {
6056 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
6057 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
6058 }
6059 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
6060 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
6061 }
6062 if (settings.placeholder) {
6063 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
6064 }
6065 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
6066 if (!settings.splitOn && settings.delimiter) {
6067 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
6068 }
6069 // debounce user defined load() if loadThrottle > 0
6070 // after initializePlugins() so plugins can create/modify user defined loaders
6071 if (settings.load && settings.loadThrottle) {
6072 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
6073 }
6074 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
6075 self.ignoreHover = false;
6076 });
6077 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
6078 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
6079 if (target_match)
6080 self.onOptionHover(e, target_match);
6081 }, { capture: true });
6082 // clicking on an option should select it
6083 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
6084 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
6085 if (option) {
6086 self.onOptionSelect(evt, option);
6087 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
6088 }
6089 });
6090 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
6091 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
6092 if (target_match && self.onItemSelect(evt, target_match)) {
6093 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
6094 return;
6095 }
6096 // retain focus (see control_input mousedown)
6097 if (control_input.value != '') {
6098 return;
6099 }
6100 self.onClick();
6101 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
6102 });
6103 // keydown on focus_node for arrow_down/arrow_up
6104 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
6105 // keypress and input/keyup
6106 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
6107 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
6108 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
6109 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
6110 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
6111 const doc_mousedown = (evt) => {
6112 // blur if target is outside of this instance
6113 // dropdown is not always inside wrapper
6114 const target = evt.composedPath()[0];
6115 if (!wrapper.contains(target) && !dropdown.contains(target)) {
6116 if (self.isFocused) {
6117 self.blur();
6118 }
6119 self.inputState();
6120 return;
6121 }
6122 // retain focus by preventing native handling. if the
6123 // event target is the input it should not be modified.
6124 // otherwise, text selection within the input won't work.
6125 // Fixes bug #212 which is no covered by tests
6126 if (target == control_input && self.isOpen) {
6127 evt.stopPropagation();
6128 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
6129 }
6130 else {
6131 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
6132 }
6133 };
6134 const win_scroll = () => {
6135 if (self.isOpen) {
6136 self.positionDropdown();
6137 }
6138 };
6139 const input_invalid = () => {
6140 if (self.isValid) {
6141 self.isValid = false;
6142 self.isInvalid = true;
6143 self.refreshState();
6144 }
6145 };
6146 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid);
6147 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
6148 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
6149 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
6150 this._destroy = () => {
6151 input.removeEventListener('invalid', input_invalid);
6152 document.removeEventListener('mousedown', doc_mousedown);
6153 window.removeEventListener('scroll', win_scroll);
6154 window.removeEventListener('resize', win_scroll);
6155 if (label)
6156 label.removeEventListener('click', label_click);
6157 };
6158 // store original html and tab index so that they can be
6159 // restored when the destroy() method is called.
6160 this.revertSettings = {
6161 innerHTML: input.innerHTML,
6162 tabIndex: input.tabIndex
6163 };
6164 input.tabIndex = -1;
6165 input.insertAdjacentElement('afterend', self.wrapper);
6166 self.sync(false);
6167 settings.items = [];
6168 delete settings.optgroups;
6169 delete settings.options;
6170 self.refreshItems();
6171 self.close(false);
6172 self.inputState();
6173 self.isSetup = true;
6174 self.on('change', this.onChange);
6175 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
6176 self.trigger('initialize');
6177 // preload options
6178 if (settings.preload === true) {
6179 self.preload();
6180 }
6181 }
6182 /**
6183 * Register options and optgroups
6184 *
6185 */
6186 setupOptions(options = [], optgroups = []) {
6187 // build options table
6188 this.addOptions(options);
6189 // build optgroup table
6190 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
6191 this.registerOptionGroup(optgroup);
6192 });
6193 }
6194 /**
6195 * Sets up default rendering functions.
6196 */
6197 setupTemplates() {
6198 var self = this;
6199 var field_label = self.settings.labelField;
6200 var field_optgroup = self.settings.optgroupLabelField;
6201 var templates = {
6202 'optgroup': (data) => {
6203 let optgroup = document.createElement('div');
6204 optgroup.className = 'optgroup';
6205 optgroup.appendChild(data.options);
6206 return optgroup;
6207 },
6208 'optgroup_header': (data, escape) => {
6209 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
6210 },
6211 'option': (data, escape) => {
6212 return '<div>' + escape(data[field_label]) + '</div>';
6213 },
6214 'item': (data, escape) => {
6215 return '<div>' + escape(data[field_label]) + '</div>';
6216 },
6217 'option_create': (data, escape) => {
6218 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
6219 },
6220 'no_results': () => {
6221 return '<div class="no-results">No results found</div>';
6222 },
6223 'loading': () => {
6224 return '<div class="spinner"></div>';
6225 },
6226 'not_loading': () => { },
6227 'dropdown': () => {
6228 return '<div></div>';
6229 }
6230 };
6231 self.settings.render = Object.assign({}, templates, self.settings.render);
6232 }
6233 /**
6234 * Maps fired events to callbacks provided
6235 * in the settings used when creating the control.
6236 */
6237 setupCallbacks() {
6238 var key, fn;
6239 var callbacks = {
6240 'initialize': 'onInitialize',
6241 'change': 'onChange',
6242 'item_add': 'onItemAdd',
6243 'item_remove': 'onItemRemove',
6244 'item_select': 'onItemSelect',
6245 'clear': 'onClear',
6246 'option_add': 'onOptionAdd',
6247 'option_remove': 'onOptionRemove',
6248 'option_clear': 'onOptionClear',
6249 'optgroup_add': 'onOptionGroupAdd',
6250 'optgroup_remove': 'onOptionGroupRemove',
6251 'optgroup_clear': 'onOptionGroupClear',
6252 'dropdown_open': 'onDropdownOpen',
6253 'dropdown_close': 'onDropdownClose',
6254 'type': 'onType',
6255 'load': 'onLoad',
6256 'focus': 'onFocus',
6257 'blur': 'onBlur'
6258 };
6259 for (key in callbacks) {
6260 fn = this.settings[callbacks[key]];
6261 if (fn)
6262 this.on(key, fn);
6263 }
6264 }
6265 /**
6266 * Sync the Tom Select instance with the original input or select
6267 *
6268 */
6269 sync(get_settings = true) {
6270 const self = this;
6271 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings;
6272 self.setupOptions(settings.options, settings.optgroups);
6273 self.setValue(settings.items || [], true); // silent prevents recursion
6274 if (self.input.disabled) {
6275 self.disable();
6276 }
6277 else if (self.input.readOnly) {
6278 self.setReadOnly(true);
6279 }
6280 else {
6281 self.enable(); //sets tabIndex
6282 }
6283 self.lastQuery = null; // so updated options will be displayed in dropdown
6284 }
6285 /**
6286 * Triggered when the main control element
6287 * has a click event.
6288 *
6289 */
6290 onClick() {
6291 var self = this;
6292 if (self.activeItems.length > 0) {
6293 self.clearActiveItems();
6294 self.focus();
6295 return;
6296 }
6297 if (self.isFocused && self.isOpen) {
6298 self.blur();
6299 }
6300 else {
6301 self.focus();
6302 }
6303 }
6304 /**
6305 * @deprecated v1.7
6306 *
6307 */
6308 onMouseDown() { }
6309 /**
6310 * Triggered when the value of the control has been changed.
6311 * This should propagate the event to the original DOM
6312 * input / select element.
6313 */
6314 onChange() {
6315 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
6316 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
6317 }
6318 /**
6319 * Triggered on <input> paste.
6320 *
6321 */
6322 onPaste(e) {
6323 var self = this;
6324 if (self.isInputHidden || self.isLocked) {
6325 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6326 return;
6327 }
6328 // If a regex or string is included, this will split the pasted
6329 // input and create Items for each separate value
6330 if (!self.settings.splitOn) {
6331 return;
6332 }
6333 // Wait for pasted text to be recognized in value
6334 setTimeout(() => {
6335 var pastedText = self.inputValue();
6336 if (!pastedText.match(self.settings.splitOn)) {
6337 return;
6338 }
6339 var splitInput = pastedText.trim().split(self.settings.splitOn);
6340 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
6341 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
6342 if (hash) {
6343 if (this.options[piece]) {
6344 self.addItem(piece);
6345 }
6346 else {
6347 self.createItem(piece);
6348 }
6349 }
6350 });
6351 }, 0);
6352 }
6353 /**
6354 * Triggered on <input> keypress.
6355 *
6356 */
6357 onKeyPress(e) {
6358 var self = this;
6359 if (self.isLocked) {
6360 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6361 return;
6362 }
6363 var character = String.fromCharCode(e.keyCode || e.which);
6364 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
6365 self.createItem();
6366 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6367 return;
6368 }
6369 }
6370 /**
6371 * Triggered on <input> keydown.
6372 *
6373 */
6374 onKeyDown(e) {
6375 var self = this;
6376 self.ignoreHover = true;
6377 if (self.isLocked) {
6378 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
6379 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6380 }
6381 return;
6382 }
6383 switch (e.keyCode) {
6384 // ctrl+A: select all
6385 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
6386 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
6387 if (self.control_input.value == '') {
6388 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6389 self.selectAll();
6390 return;
6391 }
6392 }
6393 break;
6394 // esc: close dropdown
6395 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
6396 if (self.isOpen) {
6397 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
6398 self.close();
6399 }
6400 self.clearActiveItems();
6401 return;
6402 // down: open dropdown or move selection down
6403 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
6404 if (!self.isOpen && self.hasOptions) {
6405 self.open();
6406 }
6407 else if (self.activeOption) {
6408 let next = self.getAdjacent(self.activeOption, 1);
6409 if (next)
6410 self.setActiveOption(next);
6411 }
6412 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6413 return;
6414 // up: move selection up
6415 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
6416 if (self.activeOption) {
6417 let prev = self.getAdjacent(self.activeOption, -1);
6418 if (prev)
6419 self.setActiveOption(prev);
6420 }
6421 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6422 return;
6423 // return: select active option
6424 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
6425 if (self.canSelect(self.activeOption)) {
6426 self.onOptionSelect(e, self.activeOption);
6427 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6428 // if the option_create=null, the dropdown might be closed
6429 }
6430 else if (self.settings.create && self.createItem()) {
6431 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6432 // don't submit form when searching for a value
6433 }
6434 else if (document.activeElement == self.control_input && self.isOpen) {
6435 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6436 }
6437 return;
6438 // left: modifiy item selection to the left
6439 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
6440 self.advanceSelection(-1, e);
6441 return;
6442 // right: modifiy item selection to the right
6443 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
6444 self.advanceSelection(1, e);
6445 return;
6446 // tab: select active option and/or create item
6447 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
6448 if (self.settings.selectOnTab) {
6449 if (self.canSelect(self.activeOption)) {
6450 self.onOptionSelect(e, self.activeOption);
6451 // prevent default [tab] behaviour of jump to the next field
6452 // if select isFull, then the dropdown won't be open and [tab] will work normally
6453 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6454 }
6455 else if (self.settings.create && self.createItem()) {
6456 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6457 }
6458 }
6459 return;
6460 // delete|backspace: delete items
6461 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
6462 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
6463 self.deleteSelection(e);
6464 return;
6465 }
6466 // don't enter text in the control_input when active items are selected
6467 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
6468 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6469 }
6470 }
6471 /**
6472 * Triggered on <input> keyup.
6473 *
6474 */
6475 onInput(e) {
6476 if (this.isLocked) {
6477 return;
6478 }
6479 const value = this.inputValue();
6480 if (this.lastValue === value)
6481 return;
6482 this.lastValue = value;
6483 if (value == '') {
6484 this._onInput();
6485 return;
6486 }
6487 if (this.refreshTimeout) {
6488 window.clearTimeout(this.refreshTimeout);
6489 }
6490 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
6491 this.refreshTimeout = null;
6492 this._onInput();
6493 }, this.settings.refreshThrottle);
6494 }
6495 _onInput() {
6496 const value = this.lastValue;
6497 if (this.settings.shouldLoad.call(this, value)) {
6498 this.load(value);
6499 }
6500 this.refreshOptions();
6501 this.trigger('type', value);
6502 }
6503 /**
6504 * Triggered when the user rolls over
6505 * an option in the autocomplete dropdown menu.
6506 *
6507 */
6508 onOptionHover(evt, option) {
6509 if (this.ignoreHover)
6510 return;
6511 this.setActiveOption(option, false);
6512 }
6513 /**
6514 * Triggered on <input> focus.
6515 *
6516 */
6517 onFocus(e) {
6518 var self = this;
6519 var wasFocused = self.isFocused;
6520 if (self.isDisabled || self.isReadOnly) {
6521 self.blur();
6522 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6523 return;
6524 }
6525 if (self.ignoreFocus)
6526 return;
6527 self.isFocused = true;
6528 if (self.settings.preload === 'focus')
6529 self.preload();
6530 if (!wasFocused)
6531 self.trigger('focus');
6532 if (!self.activeItems.length) {
6533 self.inputState();
6534 self.refreshOptions(!!self.settings.openOnFocus);
6535 }
6536 self.refreshState();
6537 }
6538 /**
6539 * Triggered on <input> blur.
6540 *
6541 */
6542 onBlur(e) {
6543 if (document.hasFocus() === false)
6544 return;
6545 var self = this;
6546 if (!self.isFocused)
6547 return;
6548 self.isFocused = false;
6549 self.ignoreFocus = false;
6550 var deactivate = () => {
6551 self.close();
6552 self.setActiveItem();
6553 self.setCaret(self.items.length);
6554 self.trigger('blur');
6555 };
6556 if (self.settings.create && self.settings.createOnBlur) {
6557 self.createItem(null, deactivate);
6558 }
6559 else {
6560 deactivate();
6561 }
6562 }
6563 /**
6564 * Triggered when the user clicks on an option
6565 * in the autocomplete dropdown menu.
6566 *
6567 */
6568 onOptionSelect(evt, option) {
6569 var value, self = this;
6570 // should not be possible to trigger a option under a disabled optgroup
6571 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
6572 return;
6573 }
6574 if (option.classList.contains('create')) {
6575 self.createItem(null, () => {
6576 if (self.settings.closeAfterSelect) {
6577 self.close();
6578 }
6579 else if (self.settings.clearAfterSelect) {
6580 self.setTextboxValue();
6581 }
6582 });
6583 }
6584 else {
6585 value = option.dataset.value;
6586 if (typeof value !== 'undefined') {
6587 self.isDropdownContentStale = self.settings.hideSelected;
6588 self.addItem(value);
6589 if (self.settings.closeAfterSelect) {
6590 self.close();
6591 }
6592 else if (self.settings.clearAfterSelect) {
6593 self.setTextboxValue();
6594 }
6595 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
6596 self.setActiveOption(option);
6597 }
6598 }
6599 }
6600 }
6601 /**
6602 * Return true if the given option can be selected
6603 *
6604 */
6605 canSelect(option) {
6606 if (this.isOpen && option && this.dropdown_content.contains(option)) {
6607 return true;
6608 }
6609 return false;
6610 }
6611 /**
6612 * Triggered when the user clicks on an item
6613 * that has been selected.
6614 *
6615 */
6616 onItemSelect(evt, item) {
6617 var self = this;
6618 if (!self.isLocked && self.settings.mode === 'multi') {
6619 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
6620 self.setActiveItem(item, evt);
6621 return true;
6622 }
6623 return false;
6624 }
6625 /**
6626 * Determines whether or not to invoke
6627 * the user-provided option provider / loader
6628 *
6629 * Note, there is a subtle difference between
6630 * this.canLoad() and this.settings.shouldLoad();
6631 *
6632 * - settings.shouldLoad() is a user-input validator.
6633 * When false is returned, the not_loading template
6634 * will be added to the dropdown
6635 *
6636 * - canLoad() is lower level validator that checks
6637 * the Tom Select instance. There is no inherent user
6638 * feedback when canLoad returns false
6639 *
6640 */
6641 canLoad(value) {
6642 if (!this.settings.load)
6643 return false;
6644 if (this.loadedSearches.hasOwnProperty(value))
6645 return false;
6646 return true;
6647 }
6648 /**
6649 * Invokes the user-provided option provider / loader.
6650 *
6651 */
6652 load(value) {
6653 const self = this;
6654 if (!self.canLoad(value))
6655 return;
6656 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
6657 self.loading++;
6658 const callback = self.loadCallback.bind(self);
6659 self.settings.load.call(self, value, callback);
6660 }
6661 /**
6662 * Invoked by the user-provided option provider
6663 *
6664 */
6665 loadCallback(options, optgroups) {
6666 const self = this;
6667 self.loading = Math.max(self.loading - 1, 0);
6668 self.isDropdownContentStale = true;
6669 self.clearActiveOption(); // when new results load, focus should be on first option
6670 self.setupOptions(options, optgroups);
6671 self.refreshOptions(self.isFocused && !self.isInputHidden);
6672 if (!self.loading) {
6673 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
6674 }
6675 self.trigger('load', options, optgroups);
6676 }
6677 preload() {
6678 var classList = this.wrapper.classList;
6679 if (classList.contains('preloaded'))
6680 return;
6681 classList.add('preloaded');
6682 this.load('');
6683 }
6684 /**
6685 * Sets the input field of the control to the specified value.
6686 *
6687 */
6688 setTextboxValue(value = '') {
6689 var input = this.control_input;
6690 var changed = input.value !== value;
6691 if (changed) {
6692 input.value = value;
6693 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
6694 this.lastValue = value;
6695 }
6696 }
6697 /**
6698 * Returns the value of the control. If multiple items
6699 * can be selected (e.g. <select multiple>), this returns
6700 * an array. If only one item can be selected, this
6701 * returns a string.
6702 *
6703 */
6704 getValue() {
6705 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
6706 return this.items;
6707 }
6708 return this.items.join(this.settings.delimiter);
6709 }
6710 /**
6711 * Resets the selected items to the given value.
6712 *
6713 */
6714 setValue(value, silent) {
6715 var events = silent ? [] : ['change'];
6716 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
6717 this.clear(silent);
6718 this.addItems(value, silent);
6719 });
6720 }
6721 /**
6722 * Resets the number of max items to the given value
6723 *
6724 */
6725 setMaxItems(value) {
6726 if (value === 0)
6727 value = null; //reset to unlimited items.
6728 this.settings.maxItems = value;
6729 this.refreshState();
6730 }
6731 /**
6732 * Sets the selected item.
6733 *
6734 */
6735 setActiveItem(item, e) {
6736 var self = this;
6737 var eventName;
6738 var i, begin, end, swap;
6739 var last;
6740 if (self.settings.mode === 'single')
6741 return;
6742 // clear the active selection
6743 if (!item) {
6744 self.clearActiveItems();
6745 if (self.isFocused) {
6746 self.inputState();
6747 }
6748 return;
6749 }
6750 // modify selection
6751 eventName = e && e.type.toLowerCase();
6752 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
6753 last = self.getLastActive();
6754 begin = Array.prototype.indexOf.call(self.control.children, last);
6755 end = Array.prototype.indexOf.call(self.control.children, item);
6756 if (begin > end) {
6757 swap = begin;
6758 begin = end;
6759 end = swap;
6760 }
6761 for (i = begin; i <= end; i++) {
6762 item = self.control.children[i];
6763 if (self.activeItems.indexOf(item) === -1) {
6764 self.setActiveItemClass(item);
6765 }
6766 }
6767 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
6768 }
6769 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))) {
6770 if (item.classList.contains('active')) {
6771 self.removeActiveItem(item);
6772 }
6773 else {
6774 self.setActiveItemClass(item);
6775 }
6776 }
6777 else {
6778 self.clearActiveItems();
6779 self.setActiveItemClass(item);
6780 }
6781 // ensure control has focus
6782 self.inputState();
6783 if (!self.isFocused) {
6784 self.focus();
6785 }
6786 }
6787 /**
6788 * Set the active and last-active classes
6789 *
6790 */
6791 setActiveItemClass(item) {
6792 const self = this;
6793 const last_active = self.control.querySelector('.last-active');
6794 if (last_active)
6795 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
6796 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
6797 self.trigger('item_select', item);
6798 if (self.activeItems.indexOf(item) == -1) {
6799 self.activeItems.push(item);
6800 }
6801 }
6802 /**
6803 * Remove active item
6804 *
6805 */
6806 removeActiveItem(item) {
6807 var idx = this.activeItems.indexOf(item);
6808 this.activeItems.splice(idx, 1);
6809 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
6810 }
6811 /**
6812 * Clears all the active items
6813 *
6814 */
6815 clearActiveItems() {
6816 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
6817 this.activeItems = [];
6818 }
6819 /**
6820 * Sets the selected item in the dropdown menu
6821 * of available options.
6822 *
6823 */
6824 setActiveOption(option, scroll = true) {
6825 if (option === this.activeOption) {
6826 return;
6827 }
6828 this.clearActiveOption();
6829 if (!option)
6830 return;
6831 this.activeOption = option;
6832 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
6833 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
6834 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
6835 if (scroll)
6836 this.scrollToOption(option);
6837 }
6838 /**
6839 * Sets the dropdown_content scrollTop to display the option
6840 *
6841 */
6842 scrollToOption(option, behavior) {
6843 if (!option)
6844 return;
6845 const content = this.dropdown_content;
6846 const height_menu = content.clientHeight;
6847 const scrollTop = content.scrollTop || 0;
6848 const height_item = option.offsetHeight;
6849 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
6850 if (y + height_item > height_menu + scrollTop) {
6851 this.scroll(y - height_menu + height_item, behavior);
6852 }
6853 else if (y < scrollTop) {
6854 this.scroll(y, behavior);
6855 }
6856 }
6857 /**
6858 * Scroll the dropdown to the given position
6859 *
6860 */
6861 scroll(scrollTop, behavior) {
6862 const content = this.dropdown_content;
6863 if (behavior) {
6864 content.style.scrollBehavior = behavior;
6865 }
6866 content.scrollTop = scrollTop;
6867 content.style.scrollBehavior = '';
6868 }
6869 /**
6870 * Clears the active option
6871 *
6872 */
6873 clearActiveOption() {
6874 if (this.activeOption) {
6875 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
6876 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
6877 }
6878 this.activeOption = null;
6879 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
6880 }
6881 /**
6882 * Selects all items (CTRL + A).
6883 */
6884 selectAll() {
6885 const self = this;
6886 if (self.settings.mode === 'single')
6887 return;
6888 const activeItems = self.controlChildren();
6889 if (!activeItems.length)
6890 return;
6891 self.inputState();
6892 self.close();
6893 self.activeItems = activeItems;
6894 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
6895 self.setActiveItemClass(item);
6896 });
6897 }
6898 /**
6899 * Determines if the control_input should be in a hidden or visible state
6900 *
6901 */
6902 inputState() {
6903 var self = this;
6904 if (!self.control.contains(self.control_input))
6905 return;
6906 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
6907 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
6908 self.setTextboxValue();
6909 self.isInputHidden = true;
6910 }
6911 else {
6912 if (self.settings.hidePlaceholder && self.items.length > 0) {
6913 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
6914 }
6915 self.isInputHidden = false;
6916 }
6917 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
6918 }
6919 /**
6920 * Get the input value
6921 */
6922 inputValue() {
6923 return this.control_input.value.trim();
6924 }
6925 /**
6926 * Gives the control focus.
6927 */
6928 focus() {
6929 var self = this;
6930 if (self.isDisabled || self.isReadOnly)
6931 return;
6932 self.ignoreFocus = true;
6933 const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node;
6934 focusTarget.focus();
6935 setTimeout(() => {
6936 self.ignoreFocus = false;
6937 // Fix https://github.com/orchidjs/tom-select/issues/806
6938 // Only proceed if this instance's element is still the active element. If Edge autofill
6939 // (or anything else) has moved focus to a different element in the interim, calling
6940 // onFocus() here would steal focus back and restart the cascade loop.
6941 const root = focusTarget.getRootNode();
6942 if (root.activeElement !== focusTarget) {
6943 return;
6944 }
6945 this.onFocus();
6946 }, 0);
6947 }
6948 /**
6949 * Forces the control out of focus.
6950 *
6951 */
6952 blur() {
6953 this.focus_node.blur();
6954 this.onBlur();
6955 }
6956 /**
6957 * Returns a function that scores an object
6958 * to show how good of a match it is to the
6959 * provided query.
6960 *
6961 * @return {function}
6962 */
6963 getScoreFunction(query) {
6964 return this.sifter.getScoreFunction(query, this.getSearchOptions());
6965 }
6966 /**
6967 * Returns search options for sifter (the system
6968 * for scoring and sorting results).
6969 *
6970 * @see https://github.com/orchidjs/sifter.js
6971 * @return {object}
6972 */
6973 getSearchOptions() {
6974 var settings = this.settings;
6975 var sort = settings.sortField;
6976 if (typeof settings.sortField === 'string') {
6977 sort = [{ field: settings.sortField }];
6978 }
6979 return {
6980 fields: settings.searchField,
6981 conjunction: settings.searchConjunction,
6982 sort: sort,
6983 nesting: settings.nesting
6984 };
6985 }
6986 /**
6987 * Searches through available options and returns
6988 * a sorted array of matches.
6989 *
6990 */
6991 search(query) {
6992 var result, calculateScore;
6993 var self = this;
6994 var options = this.getSearchOptions();
6995 // validate user-provided result scoring function
6996 if (self.settings.score) {
6997 calculateScore = self.settings.score.call(self, query);
6998 if (typeof calculateScore !== 'function') {
6999 throw new Error('Tom Select "score" setting must be a function that returns a function');
7000 }
7001 }
7002 // perform search
7003 if (self.isDropdownContentStale || query !== self.lastQuery) {
7004 self.lastQuery = query;
7005 // temp fix for https://github.com/orchidjs/tom-select/issues/987
7006 // UI crashed when more than 30 same chars in a row, prevent search and return empt result
7007 if (/(.)\1{15,}/.test(query)) {
7008 query = '';
7009 }
7010 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
7011 self.currentResults = result;
7012 }
7013 else {
7014 result = Object.assign({}, self.currentResults);
7015 }
7016 // filter out selected items
7017 if (self.settings.hideSelected) {
7018 result.items = result.items.filter((item) => {
7019 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
7020 return !(hashed !== null && self.items.indexOf(hashed) !== -1);
7021 });
7022 }
7023 return result;
7024 }
7025 /**
7026 * Refreshes the list of available options shown
7027 * in the autocomplete dropdown menu.
7028 *
7029 */
7030 refreshOptions(triggerDropdown = true) {
7031 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
7032 var create;
7033 const groups = {};
7034 const groups_order = [];
7035 var self = this;
7036 var query = self.inputValue();
7037 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
7038 var results = self.search(query);
7039 var active_option = null;
7040 var show_dropdown = self.settings.shouldOpen || false;
7041 var dropdown_content = self.dropdown_content;
7042 if (same_query) {
7043 active_option = self.activeOption;
7044 if (active_option) {
7045 active_group = active_option.closest('[data-group]');
7046 }
7047 }
7048 // build markup
7049 n = results.items.length;
7050 if (typeof self.settings.maxOptions === 'number') {
7051 n = Math.min(n, self.settings.maxOptions);
7052 }
7053 if (n > 0) {
7054 show_dropdown = true;
7055 }
7056 // get fragment for group and the position of the group in group_order
7057 const getGroupFragment = (optgroup, order) => {
7058 let group_order_i = groups[optgroup];
7059 if (group_order_i !== undefined) {
7060 let order_group = groups_order[group_order_i];
7061 if (order_group !== undefined) {
7062 return [group_order_i, order_group.fragment];
7063 }
7064 }
7065 let group_fragment = document.createDocumentFragment();
7066 group_order_i = groups_order.length;
7067 groups_order.push({ fragment: group_fragment, order, optgroup });
7068 return [group_order_i, group_fragment];
7069 };
7070 // render and group available options individually
7071 for (i = 0; i < n; i++) {
7072 // get option dom element
7073 let item = results.items[i];
7074 if (!item)
7075 continue;
7076 let opt_value = item.id;
7077 let option = self.options[opt_value];
7078 if (option === undefined)
7079 continue;
7080 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
7081 let option_el = self.getOption(opt_hash, true);
7082 // toggle 'selected' class
7083 if (!self.settings.hideSelected) {
7084 option_el.classList.toggle('selected', self.items.includes(opt_hash));
7085 }
7086 optgroup = option[self.settings.optgroupField] || '';
7087 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
7088 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
7089 optgroup = optgroups[j];
7090 let order = option.$order;
7091 let self_optgroup = self.optgroups[optgroup];
7092 if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') {
7093 var regGroup;
7094 if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) {
7095 self.registerOptionGroup(regGroup);
7096 }
7097 }
7098 self_optgroup = self.optgroups[optgroup];
7099 if (self_optgroup === undefined) {
7100 optgroup = '';
7101 }
7102 else {
7103 order = self_optgroup.$order;
7104 }
7105 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
7106 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
7107 if (j > 0) {
7108 option_el = option_el.cloneNode(true);
7109 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
7110 option_el.classList.add('ts-cloned');
7111 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
7112 // make sure we keep the activeOption in the same group
7113 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
7114 if (active_group && active_group.dataset.group === optgroup.toString()) {
7115 active_option = option_el;
7116 }
7117 }
7118 }
7119 group_fragment.appendChild(option_el);
7120 if (optgroup != '') {
7121 groups[optgroup] = group_order_i;
7122 }
7123 }
7124 }
7125 // sort optgroups
7126 if (self.settings.lockOptgroupOrder) {
7127 groups_order.sort((a, b) => {
7128 return a.order - b.order;
7129 });
7130 }
7131 // render optgroup headers & join groups
7132 html = document.createDocumentFragment();
7133 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
7134 let group_fragment = group_order.fragment;
7135 let optgroup = group_order.optgroup;
7136 if (!group_fragment || !group_fragment.children.length)
7137 return;
7138 let group_heading = self.optgroups[optgroup];
7139 if (group_heading !== undefined) {
7140 let group_options = document.createDocumentFragment();
7141 let header = self.render('optgroup_header', group_heading);
7142 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
7143 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
7144 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
7145 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
7146 }
7147 else {
7148 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
7149 }
7150 });
7151 dropdown_content.innerHTML = '';
7152 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
7153 self.isDropdownContentStale = false;
7154 // highlight matching terms inline
7155 if (self.settings.highlight) {
7156 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
7157 if (results.query.length && results.tokens.length) {
7158 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
7159 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
7160 });
7161 }
7162 }
7163 // helper method for adding templates to dropdown
7164 var add_template = (template) => {
7165 let content = self.render(template, { input: query });
7166 if (content) {
7167 show_dropdown = true;
7168 dropdown_content.insertBefore(content, dropdown_content.firstChild);
7169 }
7170 return content;
7171 };
7172 // add loading message
7173 if (self.loading) {
7174 add_template('loading');
7175 // invalid query
7176 }
7177 else if (!self.settings.shouldLoad.call(self, query)) {
7178 add_template('not_loading');
7179 // add no_results message
7180 }
7181 else if (results.items.length === 0) {
7182 add_template('no_results');
7183 }
7184 // add create option
7185 has_create_option = self.canCreate(query);
7186 if (has_create_option) {
7187 create = add_template('option_create');
7188 }
7189 // activate
7190 self.hasOptions = results.items.length > 0 || has_create_option;
7191 if (show_dropdown) {
7192 if (results.items.length > 0) {
7193 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
7194 active_option = self.getOption(self.items[0]);
7195 }
7196 if (!dropdown_content.contains(active_option)) {
7197 let active_index = 0;
7198 if (create && !self.settings.addPrecedence) {
7199 active_index = 1;
7200 }
7201 active_option = self.selectable()[active_index];
7202 }
7203 }
7204 else if (create) {
7205 active_option = create;
7206 }
7207 if (triggerDropdown && !self.isOpen) {
7208 self.open();
7209 self.scrollToOption(active_option, 'auto');
7210 }
7211 self.setActiveOption(active_option);
7212 }
7213 else {
7214 self.clearActiveOption();
7215 if (triggerDropdown && self.isOpen) {
7216 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
7217 }
7218 }
7219 }
7220 /**
7221 * Return list of selectable options
7222 *
7223 */
7224 selectable() {
7225 return this.dropdown_content.querySelectorAll('[data-selectable]');
7226 }
7227 /**
7228 * Adds an available option. If it already exists,
7229 * nothing will happen. Note: this does not refresh
7230 * the options list dropdown (use `refreshOptions`
7231 * for that).
7232 *
7233 * Usage:
7234 *
7235 * this.addOption(data)
7236 *
7237 */
7238 addOption(data, user_created = false) {
7239 const self = this;
7240 // @deprecated 1.7.7
7241 // use addOptions( array, user_created ) for adding multiple options
7242 if (Array.isArray(data)) {
7243 self.addOptions(data, user_created);
7244 return false;
7245 }
7246 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
7247 if (key === null || self.options.hasOwnProperty(key)) {
7248 self.updateOption(data[self.settings.valueField], data);
7249 return false;
7250 }
7251 data.$order = data.$order || ++self.order;
7252 data.$id = self.inputId + '-opt-' + data.$order;
7253 self.options[key] = data;
7254 self.isDropdownContentStale = true;
7255 if (user_created) {
7256 self.userOptions[key] = user_created;
7257 self.trigger('option_add', key, data);
7258 }
7259 return key;
7260 }
7261 /**
7262 * Add multiple options
7263 *
7264 */
7265 addOptions(data, user_created = false) {
7266 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
7267 this.addOption(dat, user_created);
7268 });
7269 }
7270 /**
7271 * @deprecated 1.7.7
7272 */
7273 registerOption(data) {
7274 return this.addOption(data);
7275 }
7276 /**
7277 * Registers an option group to the pool of option groups.
7278 *
7279 * @return {boolean|string}
7280 */
7281 registerOptionGroup(data) {
7282 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
7283 if (key === null)
7284 return false;
7285 data.$order = data.$order || ++this.order;
7286 this.optgroups[key] = data;
7287 return key;
7288 }
7289 /**
7290 * Registers a new optgroup for options
7291 * to be bucketed into.
7292 *
7293 */
7294 addOptionGroup(id, data) {
7295 var hashed_id;
7296 data[this.settings.optgroupValueField] = id;
7297 if (hashed_id = this.registerOptionGroup(data)) {
7298 this.trigger('optgroup_add', hashed_id, data);
7299 }
7300 }
7301 /**
7302 * Removes an existing option group.
7303 *
7304 */
7305 removeOptionGroup(id) {
7306 if (this.optgroups.hasOwnProperty(id)) {
7307 delete this.optgroups[id];
7308 this.clearCache();
7309 this.trigger('optgroup_remove', id);
7310 }
7311 }
7312 /**
7313 * Clears all existing option groups.
7314 */
7315 clearOptionGroups() {
7316 this.optgroups = {};
7317 this.clearCache();
7318 this.trigger('optgroup_clear');
7319 }
7320 /**
7321 * Updates an option available for selection. If
7322 * it is visible in the selected items or options
7323 * dropdown, it will be re-rendered automatically.
7324 *
7325 */
7326 updateOption(value, data) {
7327 const self = this;
7328 var item_new;
7329 var index_item;
7330 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
7331 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
7332 // sanity checks
7333 if (value_old === null)
7334 return;
7335 const data_old = self.options[value_old];
7336 if (data_old == undefined)
7337 return;
7338 if (typeof value_new !== 'string')
7339 throw new Error('Value must be set in option data');
7340 const option = self.getOption(value_old);
7341 const item = self.getItem(value_old);
7342 data.$order = data.$order || data_old.$order;
7343 delete self.options[value_old];
7344 // invalidate render cache
7345 // don't remove existing node yet, we'll remove it after replacing it
7346 self.uncacheValue(value_new);
7347 self.options[value_new] = data;
7348 // update the option if it's in the dropdown
7349 if (option) {
7350 if (self.dropdown_content.contains(option)) {
7351 const option_new = self._render('option', data);
7352 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
7353 if (self.activeOption === option) {
7354 self.setActiveOption(option_new);
7355 }
7356 }
7357 option.remove();
7358 }
7359 // update the item if we have one
7360 if (item) {
7361 index_item = self.items.indexOf(value_old);
7362 if (index_item !== -1) {
7363 self.items.splice(index_item, 1, value_new);
7364 }
7365 item_new = self._render('item', data);
7366 if (item.classList.contains('active'))
7367 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
7368 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
7369 }
7370 // we might have updated the sortField
7371 self.isDropdownContentStale = true;
7372 }
7373 /**
7374 * Removes a single option.
7375 *
7376 */
7377 removeOption(value, silent) {
7378 const self = this;
7379 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
7380 self.uncacheValue(value);
7381 delete self.userOptions[value];
7382 delete self.options[value];
7383 self.isDropdownContentStale = true;
7384 self.trigger('option_remove', value);
7385 self.removeItem(value, silent);
7386 }
7387 /**
7388 * Clears all options.
7389 */
7390 clearOptions(filter) {
7391 const boundFilter = (filter || this.clearFilter).bind(this);
7392 this.loadedSearches = {};
7393 this.userOptions = {};
7394 this.clearCache();
7395 const selected = {};
7396 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
7397 if (boundFilter(option, key)) {
7398 selected[key] = option;
7399 }
7400 });
7401 this.options = this.sifter.items = selected;
7402 this.isDropdownContentStale = true;
7403 this.trigger('option_clear');
7404 }
7405 /**
7406 * Used by clearOptions() to decide whether or not an option should be removed
7407 * Return true to keep an option, false to remove
7408 *
7409 */
7410 clearFilter(option, value) {
7411 if (this.items.indexOf(value) >= 0) {
7412 return true;
7413 }
7414 return false;
7415 }
7416 /**
7417 * Returns the dom element of the option
7418 * matching the given value.
7419 *
7420 */
7421 getOption(value, create = false) {
7422 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
7423 if (hashed === null)
7424 return null;
7425 const option = this.options[hashed];
7426 if (option != undefined) {
7427 if (option.$div) {
7428 return option.$div;
7429 }
7430 if (create) {
7431 return this._render('option', option);
7432 }
7433 }
7434 return null;
7435 }
7436 /**
7437 * Returns the dom element of the next or previous dom element of the same type
7438 * Note: adjacent options may not be adjacent DOM elements (optgroups)
7439 *
7440 */
7441 getAdjacent(option, direction, type = 'option') {
7442 var self = this, all;
7443 if (!option) {
7444 return null;
7445 }
7446 if (type == 'item') {
7447 all = self.controlChildren();
7448 }
7449 else {
7450 all = self.dropdown_content.querySelectorAll('[data-selectable]');
7451 }
7452 for (let i = 0; i < all.length; i++) {
7453 if (all[i] != option) {
7454 continue;
7455 }
7456 if (direction > 0) {
7457 return all[i + 1];
7458 }
7459 return all[i - 1];
7460 }
7461 return null;
7462 }
7463 /**
7464 * Returns the dom element of the item
7465 * matching the given value.
7466 *
7467 */
7468 getItem(item) {
7469 if (typeof item == 'object') {
7470 return item;
7471 }
7472 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
7473 return value !== null
7474 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
7475 : null;
7476 }
7477 /**
7478 * "Selects" multiple items at once. Adds them to the list
7479 * at the current caret position.
7480 *
7481 */
7482 addItems(values, silent) {
7483 var self = this;
7484 var items = Array.isArray(values) ? values : [values];
7485 items = items.filter(x => self.items.indexOf(x) === -1);
7486 const last_item = items[items.length - 1];
7487 items.forEach(item => {
7488 self.isPending = (item !== last_item);
7489 self.addItem(item, silent);
7490 });
7491 }
7492 /**
7493 * "Selects" an item. Adds it to the list
7494 * at the current caret position.
7495 *
7496 */
7497 addItem(value, silent) {
7498 var events = silent ? [] : ['change', 'dropdown_close'];
7499 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
7500 var item, wasFull;
7501 const self = this;
7502 const inputMode = self.settings.mode;
7503 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
7504 if (hashed && self.items.indexOf(hashed) !== -1) {
7505 if (inputMode === 'single') {
7506 self.close();
7507 }
7508 if (inputMode === 'single' || !self.settings.duplicates) {
7509 return;
7510 }
7511 }
7512 if (hashed === null || !self.options.hasOwnProperty(hashed))
7513 return;
7514 if (inputMode === 'single')
7515 self.clear(silent);
7516 if (inputMode === 'multi' && self.isFull())
7517 return;
7518 item = self._render('item', self.options[hashed]);
7519 if (self.control.contains(item)) { // duplicates
7520 item = item.cloneNode(true);
7521 }
7522 wasFull = self.isFull();
7523 self.items.splice(self.caretPos, 0, hashed);
7524 self.insertAtCaret(item);
7525 if (self.isSetup) {
7526 // update menu / remove the option (if this is not one item being added as part of series)
7527 if (!self.isPending && self.settings.hideSelected) {
7528 let option = self.getOption(hashed);
7529 let next = self.getAdjacent(option, 1);
7530 if (next) {
7531 self.setActiveOption(next);
7532 }
7533 }
7534 //remove input value when enabled
7535 if (self.settings.clearAfterSelect) {
7536 self.setTextboxValue();
7537 }
7538 // refreshOptions after setActiveOption(),
7539 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
7540 if (!self.isPending && !self.settings.closeAfterSelect) {
7541 self.refreshOptions(self.isFocused && inputMode !== 'single');
7542 }
7543 // hide the menu if the maximum number of items have been selected or no options are left
7544 if (self.settings.closeAfterSelect != false && self.isFull()) {
7545 self.close();
7546 }
7547 else if (!self.isPending) {
7548 self.positionDropdown();
7549 }
7550 self.trigger('item_add', hashed, item);
7551 if (!self.isPending) {
7552 self.updateOriginalInput({ silent: silent });
7553 }
7554 }
7555 if (!self.isPending || (!wasFull && self.isFull())) {
7556 self.inputState();
7557 self.refreshState();
7558 }
7559 });
7560 }
7561 /**
7562 * Removes the selected item matching
7563 * the provided value.
7564 *
7565 */
7566 removeItem(item = null, silent) {
7567 const self = this;
7568 item = self.getItem(item);
7569 if (!item)
7570 return;
7571 var i, idx;
7572 const value = item.dataset.value;
7573 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
7574 item.remove();
7575 if (item.classList.contains('active')) {
7576 idx = self.activeItems.indexOf(item);
7577 self.activeItems.splice(idx, 1);
7578 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
7579 }
7580 self.items.splice(i, 1);
7581 self.isDropdownContentStale = true;
7582 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
7583 self.removeOption(value, silent);
7584 }
7585 if (i < self.caretPos) {
7586 self.setCaret(self.caretPos - 1);
7587 }
7588 self.updateOriginalInput({ silent: silent });
7589 self.refreshState();
7590 self.positionDropdown();
7591 self.trigger('item_remove', value, item);
7592 }
7593 /**
7594 * Invokes the `create` method provided in the
7595 * TomSelect options that should provide the data
7596 * for the new item, given the user input.
7597 *
7598 * Once this completes, it will be added
7599 * to the item list.
7600 *
7601 */
7602 createItem(input = null, callback = () => { }) {
7603 // triggerDropdown parameter @deprecated 2.1.1
7604 if (arguments.length === 3) {
7605 callback = arguments[2];
7606 }
7607 if (typeof callback != 'function') {
7608 callback = () => { };
7609 }
7610 var self = this;
7611 var caret = self.caretPos;
7612 var output;
7613 input = input || self.inputValue();
7614 if (!self.canCreate(input)) {
7615 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input);
7616 if (hash) {
7617 if (this.options[input]) {
7618 self.addItem(input);
7619 }
7620 }
7621 callback();
7622 return false;
7623 }
7624 self.lock();
7625 var created = false;
7626 var create = (data) => {
7627 self.unlock();
7628 if (!data || typeof data !== 'object')
7629 return callback();
7630 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
7631 if (typeof value !== 'string') {
7632 return callback();
7633 }
7634 self.setTextboxValue();
7635 self.addOption(data, true);
7636 self.setCaret(caret);
7637 self.addItem(value);
7638 callback(data);
7639 created = true;
7640 };
7641 if (typeof self.settings.create === 'function') {
7642 output = self.settings.create.call(this, input, create);
7643 }
7644 else {
7645 output = {
7646 [self.settings.labelField]: input,
7647 [self.settings.valueField]: input,
7648 };
7649 }
7650 if (!created) {
7651 create(output);
7652 }
7653 return true;
7654 }
7655 /**
7656 * Re-renders the selected item lists.
7657 */
7658 refreshItems() {
7659 var self = this;
7660 self.isDropdownContentStale = true;
7661 if (self.isSetup) {
7662 self.addItems(self.items);
7663 }
7664 self.updateOriginalInput();
7665 self.refreshState();
7666 }
7667 /**
7668 * Updates all state-dependent attributes
7669 * and CSS classes.
7670 */
7671 refreshState() {
7672 const self = this;
7673 self.refreshValidityState();
7674 const isFull = self.isFull();
7675 const isLocked = self.isLocked;
7676 self.wrapper.classList.toggle('rtl', self.rtl);
7677 const wrap_classList = self.wrapper.classList;
7678 wrap_classList.toggle('focus', self.isFocused);
7679 wrap_classList.toggle('disabled', self.isDisabled);
7680 wrap_classList.toggle('readonly', self.isReadOnly);
7681 wrap_classList.toggle('required', self.isRequired);
7682 wrap_classList.toggle('invalid', !self.isValid);
7683 wrap_classList.toggle('locked', isLocked);
7684 wrap_classList.toggle('full', isFull);
7685 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
7686 wrap_classList.toggle('dropdown-active', self.isOpen);
7687 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
7688 wrap_classList.toggle('has-items', self.items.length > 0);
7689 }
7690 /**
7691 * Update the `required` attribute of both input and control input.
7692 *
7693 * The `required` property needs to be activated on the control input
7694 * for the error to be displayed at the right place. `required` also
7695 * needs to be temporarily deactivated on the input since the input is
7696 * hidden and can't show errors.
7697 */
7698 refreshValidityState() {
7699 var self = this;
7700 if (!self.input.validity) {
7701 return;
7702 }
7703 self.isValid = self.input.validity.valid;
7704 self.isInvalid = !self.isValid;
7705 }
7706 /**
7707 * Determines whether or not more items can be added
7708 * to the control without exceeding the user-defined maximum.
7709 *
7710 * @returns {boolean}
7711 */
7712 isFull() {
7713 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
7714 }
7715 /**
7716 * Refreshes the original <select> or <input>
7717 * element to reflect the current state.
7718 *
7719 */
7720 updateOriginalInput(opts = {}) {
7721 const self = this;
7722 var option, label;
7723 const empty_option = self.input.querySelector('option[value=""]');
7724 if (self.is_select_tag) {
7725 const selected = [];
7726 const has_selected = self.input.querySelectorAll('option:checked').length;
7727 function AddSelected(option_el, value, label) {
7728 if (!option_el) {
7729 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>');
7730 }
7731 // don't move empty option from top of list
7732 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
7733 if (option_el != empty_option) {
7734 self.input.append(option_el);
7735 }
7736 selected.push(option_el);
7737 // marking empty option as selected can break validation
7738 // fixes https://github.com/orchidjs/tom-select/issues/303
7739 if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') {
7740 option_el.selected = true;
7741 }
7742 return option_el;
7743 }
7744 // unselect all selected options
7745 self.input.querySelectorAll('option:checked').forEach((option_el) => {
7746 option_el.selected = false;
7747 });
7748 // nothing selected?
7749 if (self.items.length == 0 && self.settings.mode == 'single') {
7750 AddSelected(empty_option, "", "");
7751 // order selected <option> tags for values in self.items
7752 }
7753 else {
7754 self.items.forEach((value) => {
7755 option = self.options[value];
7756 label = option[self.settings.labelField] || '';
7757 if (selected.includes(option.$option)) {
7758 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
7759 AddSelected(reuse_opt, value, label);
7760 }
7761 else {
7762 option.$option = AddSelected(option.$option, value, label);
7763 }
7764 });
7765 }
7766 }
7767 else {
7768 self.input.value = self.getValue();
7769 }
7770 if (self.isSetup) {
7771 if (!opts.silent) {
7772 self.trigger('change', self.getValue());
7773 }
7774 }
7775 }
7776 /**
7777 * Shows the autocomplete dropdown containing
7778 * the available options.
7779 */
7780 open() {
7781 var self = this;
7782 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
7783 return;
7784 self.isOpen = true;
7785 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
7786 self.refreshState();
7787 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
7788 self.positionDropdown();
7789 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
7790 self.focus();
7791 self.trigger('dropdown_open', self.dropdown);
7792 }
7793 /**
7794 * Closes the autocomplete dropdown menu.
7795 */
7796 close(setTextboxValue = true) {
7797 var self = this;
7798 var trigger = self.isOpen;
7799 if (setTextboxValue) {
7800 // before blur() to prevent form onchange event
7801 self.setTextboxValue();
7802 if (self.settings.mode === 'single' && self.items.length) {
7803 self.inputState();
7804 }
7805 }
7806 self.isOpen = false;
7807 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
7808 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
7809 if (self.settings.hideSelected) {
7810 self.clearActiveOption();
7811 }
7812 self.refreshState();
7813 if (trigger)
7814 self.trigger('dropdown_close', self.dropdown);
7815 }
7816 /**
7817 * Calculates and applies the appropriate
7818 * position of the dropdown if dropdownParent = 'body'.
7819 * Otherwise, position is determined by css
7820 */
7821 positionDropdown() {
7822 if (this.settings.dropdownParent !== 'body') {
7823 return;
7824 }
7825 var context = this.control;
7826 var rect = context.getBoundingClientRect();
7827 var top = context.offsetHeight + rect.top + window.scrollY;
7828 var left = rect.left + window.scrollX;
7829 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
7830 width: rect.width + 'px',
7831 top: top + 'px',
7832 left: left + 'px'
7833 });
7834 }
7835 /**
7836 * Resets / clears all selected items
7837 * from the control.
7838 *
7839 */
7840 clear(silent) {
7841 var self = this;
7842 if (!self.items.length)
7843 return;
7844 var items = self.controlChildren();
7845 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
7846 self.removeItem(item, true);
7847 });
7848 self.inputState();
7849 if (!silent)
7850 self.updateOriginalInput();
7851 self.trigger('clear');
7852 }
7853 /**
7854 * A helper method for inserting an element
7855 * at the current caret position.
7856 *
7857 */
7858 insertAtCaret(el) {
7859 const self = this;
7860 const caret = self.caretPos;
7861 const target = self.control;
7862 target.insertBefore(el, target.children[caret] || null);
7863 self.setCaret(caret + 1);
7864 }
7865 /**
7866 * Removes the current selected item(s).
7867 *
7868 */
7869 deleteSelection(e) {
7870 var direction, selection, caret, tail;
7871 var self = this;
7872 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
7873 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
7874 // determine items that will be removed
7875 const rm_items = [];
7876 if (self.activeItems.length) {
7877 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
7878 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
7879 if (direction > 0) {
7880 caret++;
7881 }
7882 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
7883 }
7884 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
7885 const items = self.controlChildren();
7886 let rm_item;
7887 if (direction < 0 && selection.start === 0 && selection.length === 0) {
7888 rm_item = items[self.caretPos - 1];
7889 }
7890 else if (direction > 0 && selection.start === self.inputValue().length) {
7891 rm_item = items[self.caretPos];
7892 }
7893 if (rm_item !== undefined) {
7894 rm_items.push(rm_item);
7895 }
7896 }
7897 if (!self.shouldDelete(rm_items, e)) {
7898 return false;
7899 }
7900 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
7901 // perform removal
7902 if (typeof caret !== 'undefined') {
7903 self.setCaret(caret);
7904 }
7905 while (rm_items.length) {
7906 self.removeItem(rm_items.pop());
7907 }
7908 self.inputState();
7909 self.positionDropdown();
7910 self.refreshOptions(false);
7911 return true;
7912 }
7913 /**
7914 * Return true if the items should be deleted
7915 */
7916 shouldDelete(items, evt) {
7917 const values = items.map(item => item.dataset.value);
7918 // allow the callback to abort
7919 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) {
7920 return false;
7921 }
7922 return true;
7923 }
7924 /**
7925 * Selects the previous / next item (depending on the `direction` argument).
7926 *
7927 * > 0 - right
7928 * < 0 - left
7929 *
7930 */
7931 advanceSelection(direction, e) {
7932 var last_active, adjacent, self = this;
7933 if (self.rtl)
7934 direction *= -1;
7935 if (self.inputValue().length)
7936 return;
7937 // add or remove to active items
7938 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)) {
7939 last_active = self.getLastActive(direction);
7940 if (last_active) {
7941 if (!last_active.classList.contains('active')) {
7942 adjacent = last_active;
7943 }
7944 else {
7945 adjacent = self.getAdjacent(last_active, direction, 'item');
7946 }
7947 // if no active item, get items adjacent to the control input
7948 }
7949 else if (direction > 0) {
7950 adjacent = self.control_input.nextElementSibling;
7951 }
7952 else {
7953 adjacent = self.control_input.previousElementSibling;
7954 }
7955 if (adjacent) {
7956 if (adjacent.classList.contains('active')) {
7957 self.removeActiveItem(last_active);
7958 }
7959 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
7960 }
7961 // move caret to the left or right
7962 }
7963 else {
7964 self.moveCaret(direction);
7965 }
7966 }
7967 moveCaret(direction) { }
7968 /**
7969 * Get the last active item
7970 *
7971 */
7972 getLastActive(direction) {
7973 let last_active = this.control.querySelector('.last-active');
7974 if (last_active) {
7975 return last_active;
7976 }
7977 var result = this.control.querySelectorAll('.active');
7978 if (result) {
7979 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
7980 }
7981 }
7982 /**
7983 * Moves the caret to the specified index.
7984 *
7985 * The input must be moved by leaving it in place and moving the
7986 * siblings, due to the fact that focus cannot be restored once lost
7987 * on mobile webkit devices
7988 *
7989 */
7990 setCaret(new_pos) {
7991 this.caretPos = this.items.length;
7992 }
7993 /**
7994 * Return list of item dom elements
7995 *
7996 */
7997 controlChildren() {
7998 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
7999 }
8000 /**
8001 * Disables user input on the control. Used while
8002 * items are being asynchronously created.
8003 */
8004 lock() {
8005 this.setLocked(true);
8006 }
8007 /**
8008 * Re-enables user input on the control.
8009 */
8010 unlock() {
8011 this.setLocked(false);
8012 }
8013 /**
8014 * Disable or enable user input on the control
8015 */
8016 setLocked(lock = this.isReadOnly || this.isDisabled) {
8017 this.isLocked = lock;
8018 this.refreshState();
8019 }
8020 /**
8021 * Disables user input on the control completely.
8022 * While disabled, it cannot receive focus.
8023 */
8024 disable() {
8025 this.setDisabled(true);
8026 this.close();
8027 }
8028 /**
8029 * Enables the control so that it can respond
8030 * to focus and user input.
8031 */
8032 enable() {
8033 this.setDisabled(false);
8034 }
8035 setDisabled(disabled) {
8036 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
8037 this.isDisabled = disabled;
8038 this.input.disabled = disabled;
8039 this.control_input.disabled = disabled;
8040 this.setLocked();
8041 }
8042 setReadOnly(isReadOnly) {
8043 this.isReadOnly = isReadOnly;
8044 this.input.readOnly = isReadOnly;
8045 this.control_input.readOnly = isReadOnly;
8046 this.setLocked();
8047 }
8048 /**
8049 * Completely destroys the control and
8050 * unbinds all event listeners so that it can
8051 * be garbage collected.
8052 */
8053 destroy() {
8054 var self = this;
8055 var revertSettings = self.revertSettings;
8056 self.trigger('destroy');
8057 self.off();
8058 self.wrapper.remove();
8059 self.dropdown.remove();
8060 self.input.innerHTML = revertSettings.innerHTML;
8061 self.input.tabIndex = revertSettings.tabIndex;
8062 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
8063 self._destroy();
8064 delete self.input.tomselect;
8065 }
8066 /**
8067 * A helper method for rendering "item" and
8068 * "option" templates, given the data.
8069 *
8070 */
8071 render(templateName, data) {
8072 var id, html;
8073 const self = this;
8074 if (typeof this.settings.render[templateName] !== 'function') {
8075 return null;
8076 }
8077 // render markup
8078 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
8079 if (!html) {
8080 return null;
8081 }
8082 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
8083 // add mandatory attributes
8084 if (templateName === 'option' || templateName === 'option_create') {
8085 if (data[self.settings.disabledField]) {
8086 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
8087 }
8088 else {
8089 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
8090 }
8091 }
8092 else if (templateName === 'optgroup') {
8093 id = data.group[self.settings.optgroupValueField];
8094 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
8095 if (data.group[self.settings.disabledField]) {
8096 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
8097 }
8098 }
8099 if (templateName === 'option' || templateName === 'item') {
8100 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
8101 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
8102 // make sure we have some classes if a template is overwritten
8103 if (templateName === 'item') {
8104 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
8105 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
8106 }
8107 else {
8108 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
8109 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
8110 role: 'option',
8111 id: data.$id
8112 });
8113 // update cache
8114 data.$div = html;
8115 self.options[value] = data;
8116 }
8117 }
8118 return html;
8119 }
8120 /**
8121 * Type guarded rendering
8122 *
8123 */
8124 _render(templateName, data) {
8125 const html = this.render(templateName, data);
8126 if (html == null) {
8127 throw 'HTMLElement expected';
8128 }
8129 return html;
8130 }
8131 /**
8132 * Clears the render cache for a template. If
8133 * no template is given, clears all render
8134 * caches.
8135 *
8136 */
8137 clearCache() {
8138 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
8139 if (option.$div) {
8140 option.$div.remove();
8141 delete option.$div;
8142 }
8143 });
8144 }
8145 /**
8146 * Removes a value from item and option caches
8147 *
8148 */
8149 uncacheValue(value) {
8150 const option_el = this.getOption(value);
8151 if (option_el)
8152 option_el.remove();
8153 }
8154 /**
8155 * Determines whether or not to display the
8156 * create item prompt, given a user input.
8157 *
8158 */
8159 canCreate(input) {
8160 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
8161 }
8162 /**
8163 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
8164 *
8165 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
8166 *
8167 * });
8168 */
8169 hook(when, method, new_fn) {
8170 var self = this;
8171 var orig_method = self[method];
8172 self[method] = function () {
8173 var result, result_new;
8174 if (when === 'after') {
8175 result = orig_method.apply(self, arguments);
8176 }
8177 result_new = new_fn.apply(self, arguments);
8178 if (when === 'instead') {
8179 return result_new;
8180 }
8181 if (when === 'before') {
8182 result = orig_method.apply(self, arguments);
8183 }
8184 return result;
8185 };
8186 }
8187 }
8188 ;
8189 //# sourceMappingURL=tom-select.js.map
8190
8191 /***/ },
8192
8193 /***/ "./node_modules/tom-select/dist/esm/utils.js"
8194 /*!***************************************************!*\
8195 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
8196 \***************************************************/
8197 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8198
8199 "use strict";
8200 __webpack_require__.r(__webpack_exports__);
8201 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8202 /* harmony export */ addEvent: () => (/* binding */ addEvent),
8203 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
8204 /* harmony export */ append: () => (/* binding */ append),
8205 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
8206 /* harmony export */ escape_html: () => (/* binding */ escape_html),
8207 /* harmony export */ getId: () => (/* binding */ getId),
8208 /* harmony export */ getSelection: () => (/* binding */ getSelection),
8209 /* harmony export */ get_hash: () => (/* binding */ get_hash),
8210 /* harmony export */ hash_key: () => (/* binding */ hash_key),
8211 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
8212 /* harmony export */ iterate: () => (/* binding */ iterate),
8213 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
8214 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
8215 /* harmony export */ timeout: () => (/* binding */ timeout)
8216 /* harmony export */ });
8217 /**
8218 * Converts a scalar to its best string representation
8219 * for hash keys and HTML attribute values.
8220 *
8221 * Transformations:
8222 * 'str' -> 'str'
8223 * null -> ''
8224 * undefined -> ''
8225 * true -> '1'
8226 * false -> '0'
8227 * 0 -> '0'
8228 * 1 -> '1'
8229 *
8230 */
8231 const hash_key = (value) => {
8232 if (typeof value === 'undefined' || value === null)
8233 return null;
8234 return get_hash(value);
8235 };
8236 const get_hash = (value) => {
8237 if (typeof value === 'boolean')
8238 return value ? '1' : '0';
8239 return value + '';
8240 };
8241 /**
8242 * Escapes a string for use within HTML.
8243 *
8244 */
8245 const escape_html = (str) => {
8246 return (str + '')
8247 .replace(/&/g, '&amp;')
8248 .replace(/</g, '&lt;')
8249 .replace(/>/g, '&gt;')
8250 .replace(/"/g, '&quot;');
8251 };
8252 /**
8253 * use setTimeout if timeout > 0
8254 */
8255 const timeout = (fn, timeout) => {
8256 if (timeout > 0) {
8257 return window.setTimeout(fn, timeout);
8258 }
8259 fn.call(null);
8260 return null;
8261 };
8262 /**
8263 * Debounce the user provided load function
8264 *
8265 */
8266 const loadDebounce = (fn, delay) => {
8267 var timeout;
8268 return function (value, callback) {
8269 var self = this;
8270 if (timeout) {
8271 self.loading = Math.max(self.loading - 1, 0);
8272 clearTimeout(timeout);
8273 }
8274 timeout = setTimeout(function () {
8275 timeout = null;
8276 self.loadedSearches[value] = true;
8277 fn.call(self, value, callback);
8278 }, delay);
8279 };
8280 };
8281 /**
8282 * Debounce all fired events types listed in `types`
8283 * while executing the provided `fn`.
8284 *
8285 */
8286 const debounce_events = (self, types, fn) => {
8287 var type;
8288 var trigger = self.trigger;
8289 var event_args = {};
8290 // override trigger method
8291 self.trigger = function () {
8292 var type = arguments[0];
8293 if (types.indexOf(type) !== -1) {
8294 event_args[type] = arguments;
8295 }
8296 else {
8297 return trigger.apply(self, arguments);
8298 }
8299 };
8300 // invoke provided function
8301 fn.apply(self, []);
8302 self.trigger = trigger;
8303 // trigger queued events
8304 for (type of types) {
8305 if (type in event_args) {
8306 trigger.apply(self, event_args[type]);
8307 }
8308 }
8309 };
8310 /**
8311 * Determines the current selection within a text input control.
8312 * Returns an object containing:
8313 * - start
8314 * - length
8315 *
8316 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
8317 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
8318 */
8319 const getSelection = (input) => {
8320 return {
8321 start: input.selectionStart || 0,
8322 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
8323 };
8324 };
8325 /**
8326 * Prevent default
8327 *
8328 */
8329 const preventDefault = (evt, stop = false) => {
8330 if (evt) {
8331 evt.preventDefault();
8332 if (stop) {
8333 evt.stopPropagation();
8334 }
8335 }
8336 };
8337 /**
8338 * Add event helper
8339 *
8340 */
8341 const addEvent = (target, type, callback, options) => {
8342 target.addEventListener(type, callback, options);
8343 };
8344 /**
8345 * Return true if the requested key is down
8346 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
8347 * The current evt may not always set ( eg calling advanceSelection() )
8348 *
8349 */
8350 const isKeyDown = (key_name, evt) => {
8351 if (!evt) {
8352 return false;
8353 }
8354 if (!evt[key_name]) {
8355 return false;
8356 }
8357 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
8358 if (count === 1) {
8359 return true;
8360 }
8361 return false;
8362 };
8363 /**
8364 * Get the id of an element
8365 * If the id attribute is not set, set the attribute with the given id
8366 *
8367 */
8368 const getId = (el, id) => {
8369 const existing_id = el.getAttribute('id');
8370 if (existing_id) {
8371 return existing_id;
8372 }
8373 el.setAttribute('id', id);
8374 return id;
8375 };
8376 /**
8377 * Returns a string with backslashes added before characters that need to be escaped.
8378 */
8379 const addSlashes = (str) => {
8380 return str.replace(/[\\"']/g, '\\$&');
8381 };
8382 /**
8383 *
8384 */
8385 const append = (parent, node) => {
8386 if (node)
8387 parent.append(node);
8388 };
8389 /**
8390 * Iterates over arrays and hashes.
8391 *
8392 * ```
8393 * iterate(this.items, function(item, id) {
8394 * // invoked for each item
8395 * });
8396 * ```
8397 *
8398 */
8399 const iterate = (object, callback) => {
8400 if (Array.isArray(object)) {
8401 object.forEach(callback);
8402 }
8403 else {
8404 for (var key in object) {
8405 if (object.hasOwnProperty(key)) {
8406 callback(object[key], key);
8407 }
8408 }
8409 }
8410 };
8411 //# sourceMappingURL=utils.js.map
8412
8413 /***/ },
8414
8415 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
8416 /*!*****************************************************!*\
8417 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
8418 \*****************************************************/
8419 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8420
8421 "use strict";
8422 __webpack_require__.r(__webpack_exports__);
8423 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8424 /* harmony export */ addClasses: () => (/* binding */ addClasses),
8425 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
8426 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
8427 /* harmony export */ classesArray: () => (/* binding */ classesArray),
8428 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
8429 /* harmony export */ getDom: () => (/* binding */ getDom),
8430 /* harmony export */ getTail: () => (/* binding */ getTail),
8431 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
8432 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
8433 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
8434 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
8435 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
8436 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
8437 /* harmony export */ setAttr: () => (/* binding */ setAttr),
8438 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
8439 /* harmony export */ });
8440 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8441
8442 /**
8443 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
8444 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
8445 *
8446 * param query should be {}
8447 */
8448 const getDom = (query) => {
8449 if (query.jquery) {
8450 return query[0];
8451 }
8452 if (query instanceof HTMLElement) {
8453 return query;
8454 }
8455 if (isHtmlString(query)) {
8456 var tpl = document.createElement('template');
8457 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
8458 return tpl.content.firstChild;
8459 }
8460 return document.querySelector(query);
8461 };
8462 const isHtmlString = (arg) => {
8463 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
8464 return true;
8465 }
8466 return false;
8467 };
8468 const escapeQuery = (query) => {
8469 return query.replace(/['"\\]/g, '\\$&');
8470 };
8471 /**
8472 * Dispatch an event
8473 *
8474 */
8475 const triggerEvent = (dom_el, event_name) => {
8476 var event = document.createEvent('HTMLEvents');
8477 event.initEvent(event_name, true, false);
8478 dom_el.dispatchEvent(event);
8479 };
8480 /**
8481 * Apply CSS rules to a dom element
8482 *
8483 */
8484 const applyCSS = (dom_el, css) => {
8485 Object.assign(dom_el.style, css);
8486 };
8487 /**
8488 * Add css classes
8489 *
8490 */
8491 const addClasses = (elmts, ...classes) => {
8492 var norm_classes = classesArray(classes);
8493 elmts = castAsArray(elmts);
8494 elmts.map(el => {
8495 norm_classes.map(cls => {
8496 el.classList.add(cls);
8497 });
8498 });
8499 };
8500 /**
8501 * Remove css classes
8502 *
8503 */
8504 const removeClasses = (elmts, ...classes) => {
8505 var norm_classes = classesArray(classes);
8506 elmts = castAsArray(elmts);
8507 elmts.map(el => {
8508 norm_classes.map(cls => {
8509 el.classList.remove(cls);
8510 });
8511 });
8512 };
8513 /**
8514 * Return arguments
8515 *
8516 */
8517 const classesArray = (args) => {
8518 var classes = [];
8519 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
8520 if (typeof _classes === 'string') {
8521 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8522 }
8523 if (Array.isArray(_classes)) {
8524 classes = classes.concat(_classes);
8525 }
8526 });
8527 return classes.filter(Boolean);
8528 };
8529 /**
8530 * Create an array from arg if it's not already an array
8531 *
8532 */
8533 const castAsArray = (arg) => {
8534 if (!Array.isArray(arg)) {
8535 arg = [arg];
8536 }
8537 return arg;
8538 };
8539 /**
8540 * Get the closest node to the evt.target matching the selector
8541 * Stops at wrapper
8542 *
8543 */
8544 const parentMatch = (target, selector, wrapper) => {
8545 if (wrapper && !wrapper.contains(target)) {
8546 return;
8547 }
8548 while (target && target.matches) {
8549 if (target.matches(selector)) {
8550 return target;
8551 }
8552 target = target.parentNode;
8553 }
8554 };
8555 /**
8556 * Get the first or last item from an array
8557 *
8558 * > 0 - right (last)
8559 * <= 0 - left (first)
8560 *
8561 */
8562 const getTail = (list, direction = 0) => {
8563 if (direction > 0) {
8564 return list[list.length - 1];
8565 }
8566 return list[0];
8567 };
8568 /**
8569 * Return true if an object is empty
8570 *
8571 */
8572 const isEmptyObject = (obj) => {
8573 return (Object.keys(obj).length === 0);
8574 };
8575 /**
8576 * Get the index of an element amongst sibling nodes of the same type
8577 *
8578 */
8579 const nodeIndex = (el, amongst) => {
8580 if (!el)
8581 return -1;
8582 amongst = amongst || el.nodeName;
8583 var i = 0;
8584 while (el = el.previousElementSibling) {
8585 if (el.matches(amongst)) {
8586 i++;
8587 }
8588 }
8589 return i;
8590 };
8591 /**
8592 * Set attributes of an element
8593 *
8594 */
8595 const setAttr = (el, attrs) => {
8596 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
8597 if (val == null) {
8598 el.removeAttribute(attr);
8599 }
8600 else {
8601 el.setAttribute(attr, '' + val);
8602 }
8603 });
8604 };
8605 /**
8606 * Replace a node
8607 */
8608 const replaceNode = (existing, replacement) => {
8609 if (existing.parentNode)
8610 existing.parentNode.replaceChild(replacement, existing);
8611 };
8612 //# sourceMappingURL=vanilla.js.map
8613
8614 /***/ }
8615
8616 /******/ });
8617 /************************************************************************/
8618 /******/ // The module cache
8619 /******/ const __webpack_module_cache__ = {};
8620 /******/
8621 /******/ // The require function
8622 /******/ function __webpack_require__(moduleId) {
8623 /******/ // Check if module is in cache
8624 /******/ const cachedModule = __webpack_module_cache__[moduleId];
8625 /******/ if (cachedModule !== undefined) {
8626 /******/ return cachedModule.exports;
8627 /******/ }
8628 /******/ // Create a new module (and put it into the cache)
8629 /******/ const module = __webpack_module_cache__[moduleId] = {
8630 /******/ id: moduleId,
8631 /******/ // no module.loaded needed
8632 /******/ exports: {}
8633 /******/ };
8634 /******/
8635 /******/ // Execute the module function
8636 /******/ if (!(moduleId in __webpack_modules__)) {
8637 /******/ delete __webpack_module_cache__[moduleId];
8638 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
8639 /******/ e.code = 'MODULE_NOT_FOUND';
8640 /******/ throw e;
8641 /******/ }
8642 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
8643 /******/
8644 /******/ // Return the exports of the module
8645 /******/ return module.exports;
8646 /******/ }
8647 /******/
8648 /************************************************************************/
8649 /******/ /* webpack/runtime/compat get default export */
8650 /******/ (() => {
8651 /******/ // getDefaultExport function for compatibility with non-harmony modules
8652 /******/ __webpack_require__.n = (module) => {
8653 /******/ const getter = module && module.__esModule ?
8654 /******/ () => (module['default']) :
8655 /******/ () => (module);
8656 /******/ __webpack_require__.d(getter, { a: getter });
8657 /******/ return getter;
8658 /******/ };
8659 /******/ })();
8660 /******/
8661 /******/ /* webpack/runtime/define property getters */
8662 /******/ (() => {
8663 /******/ // define getter/value functions for harmony exports
8664 /******/ __webpack_require__.d = (exports, definition) => {
8665 /******/ if(Array.isArray(definition)) {
8666 /******/ var i = 0;
8667 /******/ while(i < definition.length) {
8668 /******/ var key = definition[i++];
8669 /******/ var binding = definition[i++];
8670 /******/ if(!__webpack_require__.o(exports, key)) {
8671 /******/ if(binding === 0) {
8672 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
8673 /******/ } else {
8674 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
8675 /******/ }
8676 /******/ } else if(binding === 0) { i++; }
8677 /******/ }
8678 /******/ } else {
8679 /******/ for(var key in definition) {
8680 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
8681 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
8682 /******/ }
8683 /******/ }
8684 /******/ }
8685 /******/ };
8686 /******/ })();
8687 /******/
8688 /******/ /* webpack/runtime/hasOwnProperty shorthand */
8689 /******/ (() => {
8690 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
8691 /******/ })();
8692 /******/
8693 /******/ /* webpack/runtime/make namespace object */
8694 /******/ (() => {
8695 /******/ // define __esModule on exports
8696 /******/ __webpack_require__.r = (exports) => {
8697 /******/ if(Symbol.toStringTag) {
8698 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
8699 /******/ }
8700 /******/ Object.defineProperty(exports, '__esModule', { value: true });
8701 /******/ };
8702 /******/ })();
8703 /******/
8704 /******/ /* webpack/runtime/nonce */
8705 /******/ (() => {
8706 /******/ __webpack_require__.nc = undefined;
8707 /******/ })();
8708 /******/
8709 /************************************************************************/
8710 let __webpack_exports__ = {};
8711 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
8712 (() => {
8713 "use strict";
8714 /*!**************************************!*\
8715 !*** ./assets/src/js/admin/admin.js ***!
8716 \**************************************/
8717 __webpack_require__.r(__webpack_exports__);
8718 /* harmony import */ var _init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./init-tom-select.js */ "./assets/src/js/admin/init-tom-select.js");
8719 /* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
8720 /* harmony import */ var _share_dropdown_pages_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./share/dropdown-pages.js */ "./assets/src/js/admin/share/dropdown-pages.js");
8721
8722
8723
8724 (function ($) {
8725 /**
8726 * Callback event for button to creating pages inside error message.
8727 *
8728 * @param {Event} e
8729 */
8730
8731 const createPages = function createPages(e) {
8732 const $button = $(this).addClass('disabled');
8733 e.preventDefault();
8734 $.post({
8735 url: $button.attr('href'),
8736 data: {
8737 'lp-ajax': 'create-pages'
8738 },
8739 dataType: 'text',
8740 success: function success(res) {
8741 const $message = $button.closest('.lp-notice').html('<p>' + res + '</p>');
8742 setTimeout(function () {
8743 $message.fadeOut();
8744 }, 2000);
8745 }
8746 });
8747 };
8748 const lpMetaboxFileInput = () => {
8749 $('.lp-meta-box__file').each((i, element) => {
8750 let lpImageFrame;
8751 const imageGalleryIds = $(element).find('.lp-meta-box__file_input');
8752 const listImages = $(element).find('.lp-meta-box__file_list');
8753 const btnUpload = $(element).find('.btn-upload');
8754 const isMultil = !!$(element).data('multil');
8755 $(btnUpload).on('click', event => {
8756 event.preventDefault();
8757 if (lpImageFrame) {
8758 lpImageFrame.open();
8759 return;
8760 }
8761 lpImageFrame = wp.media({
8762 states: [new wp.media.controller.Library({
8763 filterable: 'all',
8764 multiple: isMultil
8765 })]
8766 });
8767 lpImageFrame.on('select', function () {
8768 const selection = lpImageFrame.state().get('selection');
8769 let attachmentIds = imageGalleryIds.val();
8770 selection.forEach(function (attachment) {
8771 attachment = attachment.toJSON();
8772 if (attachment.id) {
8773 if (!isMultil) {
8774 attachmentIds = attachment.id;
8775 listImages.empty();
8776 } else {
8777 attachmentIds = attachmentIds ? attachmentIds + ',' + attachment.id : attachment.id;
8778 }
8779 listImages.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="' + attachment.id + '"><img class="is_file" src="' + attachment.icon + '" /><span>' + attachment.filename + '</span><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>');
8780 }
8781 });
8782 delImage();
8783 imageGalleryIds.val(attachmentIds);
8784 });
8785 lpImageFrame.open();
8786 });
8787 if (isMultil) {
8788 listImages.sortable({
8789 items: 'li.image',
8790 cursor: 'move',
8791 scrollSensitivity: 40,
8792 forcePlaceholderSize: true,
8793 forceHelperSize: false,
8794 helper: 'clone',
8795 opacity: 0.65,
8796 placeholder: 'lp-metabox-sortable-placeholder',
8797 start(event, ui) {
8798 ui.item.css('background-color', '#f6f6f6');
8799 },
8800 stop(event, ui) {
8801 ui.item.removeAttr('style');
8802 },
8803 update() {
8804 let attachmentIds = '';
8805 listImages.find('li.image').css('cursor', 'default').each(function () {
8806 const attachmentId = $(this).attr('data-attachment_id');
8807 attachmentIds = attachmentIds + attachmentId + ',';
8808 });
8809 delImage();
8810 imageGalleryIds.val(attachmentIds);
8811 }
8812 });
8813 }
8814 const delImage = () => {
8815 $(listImages).find('li.image').each((i, ele) => {
8816 const del = $(ele).find('a.delete');
8817 del.on('click', function () {
8818 $(ele).remove();
8819 if (isMultil) {
8820 let attachmentIds = '';
8821 $(listImages).find('li.image').css('cursor', 'default').each(function () {
8822 const attachmentId = $(this).attr('data-attachment_id');
8823 attachmentIds = attachmentIds + attachmentId + ',';
8824 });
8825 imageGalleryIds.val(attachmentIds);
8826 } else {
8827 imageGalleryIds.val('');
8828 }
8829 return false;
8830 });
8831 });
8832 };
8833 delImage();
8834 });
8835 };
8836 const onReady = function onReady() {
8837 lpMetaboxFileInput();
8838 //updateDb();
8839 const dropdownPages = new _share_dropdown_pages_js__WEBPACK_IMPORTED_MODULE_2__.DropdownPages();
8840 dropdownPages.init();
8841 //$( '.learn-press-advertisement-slider' ).LP( 'Advertisement', 'a', 's' ).appendTo( $( '#wpbody-content' ) );
8842 //$( '.learn-press-toggle-item-preview' ).on( 'change', updateItemPreview );
8843 $('.learn-press-tip').LP('QuickTip'); //$('.learn-press-tabs').LP('AdminTab');
8844
8845 $(document).on('click', '#learn-press-create-pages', createPages)
8846 //.on( 'click', '.lp-upgrade-notice .close-notice', hideUpgradeMessage )
8847 //.on( 'click', '.plugin-action-buttons a', pluginActions )
8848 //.on( 'click', '[data-remove-confirm]', preventDefault )
8849 .on('mousedown', '.lp-sortable-handle', function (e) {
8850 $('html, body').addClass('lp-item-moving');
8851 $(e.target).closest('.lp-sortable-handle').css('cursor', 'inherit');
8852 }).on('mouseup', function (e) {
8853 $('html, body').removeClass('lp-item-moving');
8854 $('.lp-sortable-handle').css('cursor', '');
8855 });
8856
8857 // Scroll to Passing grade when click link final Quiz in Course Setting.
8858 if (window.location.hash) {
8859 const hash = window.location.hash;
8860 if (hash === '#_lp_passing_grade') {
8861 const ele = document.querySelector(hash);
8862 $('html, body').animate({
8863 scrollTop: $(hash).offset().top
8864 }, 900, 'swing');
8865 ele.parentNode.style.border = '2px solid orangered';
8866 }
8867 }
8868
8869 // Show/hide meta-box field with type checkbox
8870 /*$( 'input' ).on( 'click', function( e ) {
8871 const el = $( e.target );
8872 if ( ! el.length ) {
8873 return;
8874 }
8875 const id = el.attr( 'id' );
8876 if ( ! id ) {
8877 return;
8878 }
8879 const classHide = id.replace( 'learn_press_', '' );
8880 const elHide = $( `.show_if_${ classHide }` );
8881 if ( el.is( ':checked' ) ) {
8882 elHide.show();
8883 } else {
8884 elHide.hide();
8885 }
8886 } );*/
8887 };
8888 $(document).ready(onReady);
8889 })(jQuery);
8890 const showHideOptionsDependency = (e, target) => {
8891 if (target.tagName === 'INPUT') {
8892 if (target.closest('.forminp ')) {
8893 const nameInput = target.name;
8894 const classDependency = nameInput.replace('learn_press_', '');
8895 const elClassDependency = document.querySelectorAll(`.show_if_${classDependency}`);
8896 if (elClassDependency) {
8897 elClassDependency.forEach(el => {
8898 el.classList.toggle('lp-option-disabled');
8899 });
8900 }
8901 } else if (target.closest('.lp-meta-box')) {
8902 const elLPMetaBox = target.closest('.lp-meta-box');
8903 const nameInput = target.name;
8904 const elClassDependency = elLPMetaBox.querySelectorAll(`[data-dependency="${nameInput}"]`);
8905 if (elClassDependency) {
8906 elClassDependency.forEach(el => {
8907 el.classList.toggle('lp-option-disabled');
8908 });
8909 }
8910 }
8911 }
8912 };
8913
8914 // Events
8915 document.addEventListener('click', e => {
8916 const target = e.target;
8917 showHideOptionsDependency(e, target);
8918 // For case click add on Widgets of WordPress.
8919 (0,_init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__.initElsTomSelect)();
8920 });
8921 document.addEventListener('DOMContentLoaded', () => {
8922 (0,_init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__.searchUserOnListPost)();
8923 // Sure that the TomSelect is loaded if listen can't find elements.
8924 (0,_init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__.initElsTomSelect)();
8925 });
8926
8927 // Listen element select created on DOM.
8928 _utils_admin_js__WEBPACK_IMPORTED_MODULE_1__.Utils.lpOnElementReady('select.lp-tom-select', e => {
8929 (0,_init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__.initElsTomSelect)();
8930 });
8931 _utils_admin_js__WEBPACK_IMPORTED_MODULE_1__.Utils.lpOnElementReady('#posts-filter', e => {
8932 (0,_init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__.searchUserOnListPost)();
8933 });
8934 window.lpFindTomSelect = _init_tom_select_js__WEBPACK_IMPORTED_MODULE_0__.initElsTomSelect;
8935 })();
8936
8937 /******/ })()
8938 ;
8939 //# sourceMappingURL=admin.js.map