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

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

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