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

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

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