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

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

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