/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./assets/src/js/admin/init-tom-select.js"
/*!************************************************!*\
!*** ./assets/src/js/admin/init-tom-select.js ***!
\************************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ initElsTomSelect: () => (/* binding */ initElsTomSelect),
/* harmony export */ initTomSelect: () => (/* binding */ initTomSelect),
/* harmony export */ searchUserOnListPost: () => (/* binding */ searchUserOnListPost)
/* harmony export */ });
/* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
/**
* Handle data response from API for tom-select
*
* @param {*} response
* @param {*} tomSelectEl
* @param dataStruct
* @param fetchAPI
* @param customOptions
* @param {*} callBack
*/
const handleResponse = (response, tomSelectEl, dataStruct, fetchAPI, customOptions = {}, callBack) => {
if (!response || !tomSelectEl || !dataStruct || !fetchAPI || !callBack) {
return;
}
//Function format render data
const getTextOption = data => {
if (!dataStruct.keyGetValue?.text || !dataStruct.keyGetValue.key_render) {
return;
}
let text = dataStruct.keyGetValue.text;
for (const [key, value] of Object.entries(dataStruct.keyGetValue.key_render)) {
text = text.replace(new RegExp(`{{${value}}}`, 'g'), data[value]);
}
return text;
};
// Get default item tom-select
const defaultIds = tomSelectEl.dataset?.saved ? JSON.parse(tomSelectEl.dataset.saved) : 0;
let options = [];
// Format response data set option tom-select
if (response.data[dataStruct.dataType].length > 0) {
options = response.data[dataStruct.dataType].map(item => ({
value: item[dataStruct.keyGetValue.value],
text: getTextOption(item)
}));
}
// Setting option tom-select
const settingOption = {
items: defaultIds,
render: {
item(data, escape) {
return `` + `
${data.text}
`;
}
},
onChange: data => {
if (data.length < 1) {
tomSelectEl.value = '';
}
},
...customOptions,
options
};
if (null != tomSelectEl.tomSelectInstance) {
tomSelectEl.tomSelectInstance.addOptions(options);
return options;
}
tomSelectEl.tomSelectInstance = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.buildTomSelect(tomSelectEl, settingOption, fetchAPI, {}, callBack);
return options;
};
//Init Tom-select with available options
const initTomSelectWithOption = (tomSelectEl, settingTomSelect = {}) => {
if (!tomSelectEl) {
return null;
}
if (null != tomSelectEl.tomSelectInstance) {
return null;
}
tomSelectEl.tomSelectInstance = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.buildTomSelect(tomSelectEl, settingTomSelect);
};
// Init Tom-select
const initTomSelect = (tomSelectEl, customOptions = {}, customParams = {}) => {
var _dataStruct$dataSendA, _dataStruct$urlApi;
if (!tomSelectEl) {
return;
}
if (tomSelectEl.classList.contains('loaded')) {
return;
}
tomSelectEl.classList.add('loaded');
const defaultIds = tomSelectEl.dataset?.saved ? JSON.parse(tomSelectEl.dataset.saved) : 0;
const dataStruct = tomSelectEl?.dataset?.struct ? JSON.parse(tomSelectEl.dataset.struct) : '';
if (!dataStruct) {
initTomSelectWithOption(tomSelectEl);
return;
}
const getParentElByTagName = (tag, el) => {
const newEl = el.parentElement;
if (newEl.tagName.toLowerCase() === tag) {
return newEl;
}
if (newEl.tagName.toLowerCase() === 'html') {
return false;
}
return getParentElByTagName(tag, newEl);
};
const formParent = getParentElByTagName('form', tomSelectEl);
if (formParent) {
const elInput = formParent.querySelector('input[name="' + tomSelectEl.getAttribute('name') + '"]');
if (elInput) {
elInput.remove();
}
}
const dataSendApi = (_dataStruct$dataSendA = dataStruct.dataSendApi) !== null && _dataStruct$dataSendA !== void 0 ? _dataStruct$dataSendA : '';
const urlApi = (_dataStruct$urlApi = dataStruct.urlApi) !== null && _dataStruct$urlApi !== void 0 ? _dataStruct$urlApi : '';
const settingTomSelect = {
...dataStruct.setting,
...customOptions
};
if (!urlApi) {
initTomSelectWithOption(tomSelectEl, settingTomSelect);
return;
}
const fetchFunction = (keySearch = '', customParams, callback) => {
const url = urlApi;
const dataSend = {
current_ids: defaultIds,
...dataSendApi,
...customParams
};
dataSend.search = keySearch;
const params = {
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': lpData.nonce
},
method: 'POST',
body: JSON.stringify(dataSend)
};
_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, callback);
};
const callBackApi = {
success: response => {
handleResponse(response, tomSelectEl, dataStruct, fetchFunction, settingTomSelect, callBackApi);
}
};
// Fetch data for first load tom-select
// Get ids selected, and show list without ids selected with limit.
let idNotIn = [];
if (typeof defaultIds === 'object') {
idNotIn = Object.entries(defaultIds).map(([key, value]) => ({
key,
value
}));
}
if (dataSendApi?.id_not_in) {
idNotIn = [...idNotIn, ...dataSendApi.id_not_in];
}
customParams.id_not_in = idNotIn.join(',');
fetchFunction('', customParams, callBackApi);
};
// Init Tom-select user in admin
const searchUserOnListPost = () => {
if (lpData.show_search_author_field === '0') {
return;
}
const elPostFilter = document.querySelector('#posts-filter');
if (!elPostFilter) {
return;
}
let elSearchPost = elPostFilter.querySelector('.search-box');
if (!elSearchPost) {
elPostFilter.insertAdjacentHTML('afterbegin', lpData.show_search_author_field);
elSearchPost = elPostFilter.querySelector('.search-box');
}
if (!elSearchPost) {
return;
}
const selectNew = elSearchPost.querySelector('select#author');
if (selectNew) {
return;
}
const createSelectUserHtml = () => {
let defaultId = '';
const authorIdFilter = lpData.urlParams.author;
if (authorIdFilter) {
defaultId = JSON.stringify(authorIdFilter);
}
const dataStruct = {
urlApi: _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiSearchUsers,
dataType: 'users',
keyGetValue: {
value: 'ID',
text: '{{display_name}}(#{{ID}}) - {{user_email}}',
key_render: {
display_name: 'display_name',
user_email: 'user_email',
ID: 'ID'
}
},
setting: {
placeholder: 'Choose user'
}
};
const dataStructJson = JSON.stringify(dataStruct);
const htmlSelectUser = `` + ``;
const elInputSearch = elSearchPost.querySelector('input[name="s"]');
if (elInputSearch) {
elInputSearch.insertAdjacentHTML('afterend', htmlSelectUser);
}
// Remove input hide default of WP.
const elInputAuthor = elPostFilter.querySelector('input[name="author"]');
if (elInputAuthor) {
elInputAuthor.remove();
}
};
createSelectUserHtml();
};
const initElsTomSelect = () => {
const tomSelectEls = document.querySelectorAll('select.lp-tom-select:not(.loaded)');
if (tomSelectEls.length) {
tomSelectEls.forEach(tomSelectEl => {
// Not build elements tom-select in Widget left classic of WordPress.
if (tomSelectEl.closest('.widget-liquid-left')) {
return;
}
initTomSelect(tomSelectEl);
});
}
};
/***/ },
/***/ "./assets/src/js/admin/utils-admin.js"
/*!********************************************!*\
!*** ./assets/src/js/admin/utils-admin.js ***!
\********************************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
/* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
/* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
/* harmony export */ });
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
/* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
/* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
/**
* Library run on Admin
*
* @since 4.2.6.9
* @version 1.0.1
*/
const AdminUtilsFunctions = {
buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
if (!elTomSelect) {
return;
}
const optionDefault = {
plugins: {
remove_button: {
title: 'Remove this item'
},
dropdown_input: {}
},
onInitialize() {},
onItemAdd(e) {
// Get list without current item.
if (fetchAPI) {
const selectedOptions = Array.from(elTomSelect.selectedOptions);
const selectedValues = selectedOptions.map(option => option.value);
selectedValues.push(e);
dataSend.id_not_in = selectedValues.join(',');
fetchAPI('', dataSend, callBackHandleData);
}
}
};
if (fetchAPI) {
optionDefault.load = (keySearch, callbackTom) => {
const selectedOptions = Array.from(elTomSelect.selectedOptions);
const selectedValues = selectedOptions.map(option => option.value);
dataSend.id_not_in = selectedValues.join(',');
fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
};
}
options = {
...optionDefault,
...options
};
const items_selected = options.options;
/*if ( options?.options?.length > 20 ) {
const chunkSize = 20;
const length = options.options.length;
let i = 0;
const chunkedOptions = { ...options };
chunkedOptions.options = items_selected.slice( i, chunkSize );
const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
i += chunkSize;
const interval = setInterval( () => {
if ( i > ( length - 1 ) ) {
clearInterval( interval );
}
const optionsSlice = items_selected.slice( i, i + chunkSize );
i += chunkSize;
tomSelect.addOptions( optionsSlice );
tomSelect.setValue( options.items );
}, 200 );
return tomSelect;
}*/
return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
},
callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
return {
success: response => {
const options = callBackHandleData.success(response);
callbackTom(options);
}
};
},
fetchCourses(keySearch = '', dataSend = {}, callback) {
const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
dataSend.search = keySearch;
const params = {
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': lpDataAdmin.nonce
},
method: 'POST',
body: JSON.stringify(dataSend)
};
_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
},
fetchUsers(keySearch = '', dataSend = {}, callback) {
const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
dataSend.search = keySearch;
const params = {
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': lpDataAdmin.nonce
},
method: 'POST',
body: JSON.stringify(dataSend)
};
_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
}
};
/***/ },
/***/ "./assets/src/js/api.js"
/*!******************************!*\
!*** ./assets/src/js/api.js ***!
\******************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/**
* List API on backend
*
* @since 4.2.6
* @version 1.0.2
*/
const lplistAPI = {};
let lp_rest_url;
if ('undefined' !== typeof lpDataAdmin) {
lp_rest_url = lpDataAdmin.lp_rest_url;
lplistAPI.admin = {
apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
apiAddons: lp_rest_url + 'lp/v1/addon/all',
apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
};
}
if ('undefined' !== typeof lpData) {
lp_rest_url = lpData.lp_rest_url;
lplistAPI.frontend = {
apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
// Deprecated API, don't load from v4.3.7
apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
// Deprecated since 4.3.0
apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
};
}
if (lp_rest_url) {
lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
}
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
/***/ },
/***/ "./assets/src/js/utils.js"
/*!********************************!*\
!*** ./assets/src/js/utils.js ***!
\********************************/
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ debounce: () => (/* binding */ debounce),
/* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
/* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
/* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
/* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
/* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
/* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
/* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
/* harmony export */ lpClassName: () => (/* binding */ lpClassName),
/* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
/* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
/* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
/* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
/* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
/* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
/* harmony export */ });
/**
* Utils functions
*
* @param url
* @param data
* @param functions
* @since 4.2.5.1
* @version 1.0.6
*/
const lpClassName = {
hidden: 'lp-hidden',
loading: 'loading',
elCollapse: 'lp-collapse',
elSectionToggle: '.lp-section-toggle',
elTriggerToggle: '.lp-trigger-toggle'
};
const lpFetchAPI = (url, data = {}, functions = {}) => {
if ('function' === typeof functions.before) {
functions.before();
}
fetch(url, {
method: 'GET',
...data
}).then(response => response.json()).then(response => {
if ('function' === typeof functions.success) {
functions.success(response);
}
}).catch(err => {
if ('function' === typeof functions.error) {
functions.error(err);
}
}).finally(() => {
if ('function' === typeof functions.completed) {
functions.completed();
}
});
};
/**
* Get current URL without params.
*
* @since 4.2.5.1
*/
const lpGetCurrentURLNoParam = () => {
let currentUrl = window.location.href;
const hasParams = currentUrl.includes('?');
if (hasParams) {
currentUrl = currentUrl.split('?')[0];
}
return currentUrl;
};
const lpAddQueryArgs = (endpoint, args) => {
const url = new URL(endpoint);
Object.keys(args).forEach(arg => {
url.searchParams.set(arg, args[arg]);
});
return url;
};
/**
* Listen element viewed.
*
* @param el
* @param callback
* @since 4.2.5.8
*/
const listenElementViewed = (el, callback) => {
const observerSeeItem = new IntersectionObserver(function (entries) {
for (const entry of entries) {
if (entry.isIntersecting) {
callback(entry);
}
}
});
observerSeeItem.observe(el);
};
/**
* Listen element created.
*
* @param callback
* @since 4.2.5.8
*/
const listenElementCreated = callback => {
const observerCreateItem = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.addedNodes) {
mutation.addedNodes.forEach(function (node) {
if (node.nodeType === 1) {
callback(node);
}
});
}
});
});
observerCreateItem.observe(document, {
childList: true,
subtree: true
});
// End.
};
/**
* Listen element created.
*
* @param selector
* @param callback
* @since 4.2.7.1
*/
const lpOnElementReady = (selector, callback) => {
const element = document.querySelector(selector);
if (element) {
callback(element);
return;
}
const observer = new MutationObserver((mutations, obs) => {
const element = document.querySelector(selector);
if (element) {
obs.disconnect();
callback(element);
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
};
// Parse JSON from string with content include LP_AJAX_START.
const lpAjaxParseJsonOld = data => {
if (typeof data !== 'string') {
return data;
}
const m = String.raw({
raw: data
}).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
try {
if (m) {
data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
} else {
data = JSON.parse(data);
}
} catch (e) {
data = {};
}
return data;
};
// status 0: hide, 1: show
const lpShowHideEl = (el, status = 0) => {
if (!el) {
return;
}
if (!status) {
el.classList.add(lpClassName.hidden);
} else {
el.classList.remove(lpClassName.hidden);
}
};
// status 0: hide, 1: show
const lpSetLoadingEl = (el, status) => {
if (!el) {
return;
}
if (!status) {
el.classList.remove(lpClassName.loading);
} else {
el.classList.add(lpClassName.loading);
}
};
// Toggle collapse section
const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
if (!elTriggerClassName) {
elTriggerClassName = lpClassName.elTriggerToggle;
}
// Exclude elements, which should not trigger the collapse toggle
if (elsExclude && elsExclude.length > 0) {
for (const elExclude of elsExclude) {
if (target.closest(elExclude)) {
return;
}
}
}
const elTrigger = target.closest(elTriggerClassName);
if (!elTrigger) {
return;
}
//console.log( 'elTrigger', elTrigger );
const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
if (!elSectionToggle) {
return;
}
elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
if ('function' === typeof callback) {
callback(elSectionToggle);
}
};
// Get data of form
const getDataOfForm = form => {
const dataSend = {};
const formData = new FormData(form);
for (const pair of formData.entries()) {
const key = pair[0];
const value = formData.getAll(key);
if (!dataSend.hasOwnProperty(key)) {
// Convert value array to string.
dataSend[key] = value.join(',');
}
}
return dataSend;
};
// Get field keys of form
const getFieldKeysOfForm = form => {
const keys = [];
const elements = form.elements;
for (let i = 0; i < elements.length; i++) {
const name = elements[i].name;
if (name && !keys.includes(name)) {
keys.push(name);
}
}
return keys;
};
// Merge data handle with data form.
const mergeDataWithDatForm = (elForm, dataHandle) => {
const dataForm = getDataOfForm(elForm);
const keys = getFieldKeysOfForm(elForm);
keys.forEach(key => {
if (!dataForm.hasOwnProperty(key)) {
delete dataHandle[key];
} else if (dataForm[key][0] === '') {
delete dataForm[key];
delete dataHandle[key];
}
});
dataHandle = {
...dataHandle,
...dataForm
};
return dataHandle;
};
/**
* Event trigger
* For each list of event handlers, listen event on document.
*
* eventName: 'click', 'change', ...
* eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
*
* @param eventName
* @param eventHandlers
*/
const eventHandlers = (eventName, eventHandlers) => {
document.addEventListener(eventName, e => {
const target = e.target;
let args = {
e,
target
};
eventHandlers.forEach(eventHandler => {
args = {
...args,
...eventHandler
};
//console.log( args );
// Check condition before call back
if (eventHandler.conditionBeforeCallBack) {
if (eventHandler.conditionBeforeCallBack(args) !== true) {
return;
}
}
// Special check for keydown event with checkIsEventEnter = true
if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
if (e.key !== 'Enter') {
return;
}
}
if (target.closest(eventHandler.selector)) {
if (eventHandler.class) {
// Call method of class, function callBack will understand exactly {this} is class object.
eventHandler.class[eventHandler.callBack](args);
} else {
// For send args is objected, {this} is eventHandler object, not class object.
eventHandler.callBack(args);
}
}
});
});
};
/**
* Debounce - delays function execution until after `wait` ms of inactivity.
*
* Each call resets the timer. Only the last call in a burst executes.
*
* USE CASES:
* - Search inputs, form validation, window resize
* - Multiple elements need independent timers
* - When you need to call with different arguments
*
* EXAMPLES:
* const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
* searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
*
* const debouncedResize = debounce( recalculateLayout, 250 );
* window.addEventListener('resize', debouncedResize);
*
* ⚠️ Create ONCE outside event handlers, not inside.
*
* @param {Function} func - Function to debounce (can be anonymous)
* @param {number} wait - Milliseconds to wait (default: 500)
* @return {Function} Debounced wrapper function
* @since 4.3.7
* @version 1.0.0
*/
const debounce = (func, wait = 500) => {
let timer;
return args => {
clearTimeout(timer);
timer = setTimeout(() => func(args), wait);
};
};
/***/ },
/***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
/*!**********************************************************!*\
!*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
\**********************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Sifter: () => (/* binding */ Sifter),
/* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
/* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
/* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
/* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
/* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
/* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
/* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
/* harmony export */ });
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
/* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
/**
* sifter.js
* Copyright (c) 2013–2020 Brian Reavis & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*
* @author Brian Reavis
*/
class Sifter {
items; // []|{};
settings;
/**
* Textually searches arrays and hashes of objects
* by property (or multiple properties). Designed
* specifically for autocomplete.
*
*/
constructor(items, settings) {
this.items = items;
this.settings = settings || { diacritics: true };
}
;
/**
* Splits a search string into an array of individual
* regexps to be used to match results.
*
*/
tokenize(query, respect_word_boundaries, weights) {
if (!query || !query.length)
return [];
const tokens = [];
const words = query.split(/\s+/);
var field_regex;
if (weights) {
field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
}
words.forEach((word) => {
let field_match;
let field = null;
let regex = null;
// look for "field:query" tokens
if (field_regex && (field_match = word.match(field_regex))) {
field = field_match[1];
word = field_match[2];
}
if (word.length > 0) {
if (this.settings.diacritics) {
regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
}
else {
regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
}
if (regex && respect_word_boundaries)
regex = "\\b" + regex;
}
tokens.push({
string: word,
regex: regex ? new RegExp(regex, 'iu') : null,
field: field,
});
});
return tokens;
}
;
/**
* Returns a function to be used to score individual results.
*
* Good matches will have a higher score than poor matches.
* If an item is not a match, 0 will be returned by the function.
*
* @returns {T.ScoreFn}
*/
getScoreFunction(query, options) {
var search = this.prepareSearch(query, options);
return this._getScoreFunction(search);
}
/**
* @returns {T.ScoreFn}
*
*/
_getScoreFunction(search) {
const tokens = search.tokens, token_count = tokens.length;
if (!token_count) {
return function () { return 0; };
}
const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
if (!field_count) {
return function () { return 1; };
}
/**
* Calculates the score of an object
* against the search query.
*
*/
const scoreObject = (function () {
if (field_count === 1) {
return function (token, data) {
const field = fields[0].field;
return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
};
}
return function (token, data) {
var sum = 0;
// is the token specific to a field?
if (token.field) {
const value = getAttrFn(data, token.field);
if (!token.regex && value) {
sum += (1 / field_count);
}
else {
sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
}
}
else {
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
});
}
return sum / field_count;
};
})();
if (token_count === 1) {
return function (data) {
return scoreObject(tokens[0], data);
};
}
if (search.options.conjunction === 'and') {
return function (data) {
var score, sum = 0;
for (let token of tokens) {
score = scoreObject(token, data);
if (score <= 0)
return 0;
sum += score;
}
return sum / token_count;
};
}
else {
return function (data) {
var sum = 0;
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
sum += scoreObject(token, data);
});
return sum / token_count;
};
}
}
;
/**
* Returns a function that can be used to compare two
* results, for sorting purposes. If no sorting should
* be performed, `null` will be returned.
*
* @return function(a,b)
*/
getSortFunction(query, options) {
var search = this.prepareSearch(query, options);
return this._getSortFunction(search);
}
_getSortFunction(search) {
var implicit_score, sort_flds = [];
const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
if (typeof sort == 'function') {
return sort.bind(this);
}
/**
* Fetches the specified sort field value
* from a search result item.
*
*/
const get_field = function (name, result) {
if (name === '$score')
return result.score;
return search.getAttrFn(self.items[result.id], name);
};
// parse options
if (sort) {
for (let s of sort) {
if (search.query || s.field !== '$score') {
sort_flds.push(s);
}
}
}
// the "$score" field is implied to be the primary
// sort field, unless it's manually specified
if (search.query) {
implicit_score = true;
for (let fld of sort_flds) {
if (fld.field === '$score') {
implicit_score = false;
break;
}
}
if (implicit_score) {
sort_flds.unshift({ field: '$score', direction: 'desc' });
}
// without a search.query, all items will have the same score
}
else {
sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
}
// build function
const sort_flds_count = sort_flds.length;
if (!sort_flds_count) {
return null;
}
return function (a, b) {
var result, field;
for (let sort_fld of sort_flds) {
field = sort_fld.field;
let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
if (result)
return result;
}
return 0;
};
}
;
/**
* Parses a search query and returns an object
* with tokens and fields ready to be populated
* with results.
*
*/
prepareSearch(query, optsUser) {
const weights = {};
var options = Object.assign({}, optsUser);
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
// convert fields to new format
if (options.fields) {
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
const fields = [];
options.fields.forEach((field) => {
if (typeof field == 'string') {
field = { field: field, weight: 1 };
}
fields.push(field);
weights[field.field] = ('weight' in field) ? field.weight : 1;
});
options.fields = fields;
}
return {
options: options,
query: query.toLowerCase().trim(),
tokens: this.tokenize(query, options.respect_word_boundaries, weights),
total: 0,
items: [],
weights: weights,
getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
};
}
;
/**
* Searches through all items and returns a sorted array of matches.
*
*/
search(query, options) {
var self = this, score, search;
search = this.prepareSearch(query, options);
options = search.options;
query = search.query;
// generate result scoring function
const fn_score = options.score || self._getScoreFunction(search);
// perform search and sort
if (query.length) {
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
score = fn_score(item);
if (options.filter === false || score > 0) {
search.items.push({ 'score': score, 'id': id });
}
});
}
else {
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
search.items.push({ 'score': 1, 'id': id });
});
}
const fn_sort = self._getSortFunction(search);
if (fn_sort)
search.items.sort(fn_sort);
// apply limits
search.total = search.items.length;
if (typeof options.limit === 'number') {
search.items = search.items.slice(0, options.limit);
}
return search;
}
;
}
//# sourceMappingURL=sifter.js.map
/***/ },
/***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
/*!*********************************************************!*\
!*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
\*********************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
//# sourceMappingURL=types.js.map
/***/ },
/***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
/*!*********************************************************!*\
!*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
\*********************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ cmp: () => (/* binding */ cmp),
/* harmony export */ getAttr: () => (/* binding */ getAttr),
/* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
/* harmony export */ iterate: () => (/* binding */ iterate),
/* harmony export */ propToArray: () => (/* binding */ propToArray),
/* harmony export */ scoreValue: () => (/* binding */ scoreValue)
/* harmony export */ });
/* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
/**
* A property getter resolving dot-notation
* @param {Object} obj The root object to fetch property on
* @param {String} name The optionally dotted property name to fetch
* @return {Object} The resolved property value
*/
const getAttr = (obj, name) => {
if (!obj)
return;
return obj[name];
};
/**
* A property getter resolving dot-notation
* @param {Object} obj The root object to fetch property on
* @param {String} name The optionally dotted property name to fetch
* @return {Object} The resolved property value
*/
const getAttrNesting = (obj, name) => {
if (!obj)
return;
var part, names = name.split(".");
while ((part = names.shift()) && (obj = obj[part]))
;
return obj;
};
/**
* Calculates how close of a match the
* given value is against a search token.
*
*/
const scoreValue = (value, token, weight) => {
var score, pos;
if (!value)
return 0;
value = value + '';
if (token.regex == null)
return 0;
pos = value.search(token.regex);
if (pos === -1)
return 0;
score = token.string.length / value.length;
if (pos === 0)
score += 0.5;
return score * weight;
};
/**
* Cast object property to an array if it exists and has a value
*
*/
const propToArray = (obj, key) => {
var value = obj[key];
if (typeof value == 'function')
return value;
if (value && !Array.isArray(value)) {
obj[key] = [value];
}
};
/**
* Iterates over arrays and hashes.
*
* ```
* iterate(this.items, function(item, id) {
* // invoked for each item
* });
* ```
*
*/
const iterate = (object, callback) => {
if (Array.isArray(object)) {
object.forEach(callback);
}
else {
for (var key in object) {
if (object.hasOwnProperty(key)) {
callback(object[key], key);
}
}
}
};
const cmp = (a, b) => {
if (typeof a === 'number' && typeof b === 'number') {
return a > b ? 1 : (a < b ? -1 : 0);
}
a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
if (a > b)
return 1;
if (b > a)
return -1;
return 0;
};
//# sourceMappingURL=utils.js.map
/***/ },
/***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
/*!*******************************************************************!*\
!*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
\*******************************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ _asciifold: () => (/* binding */ _asciifold),
/* harmony export */ asciifold: () => (/* binding */ asciifold),
/* harmony export */ code_points: () => (/* binding */ code_points),
/* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
/* harmony export */ generateMap: () => (/* binding */ generateMap),
/* harmony export */ generateSets: () => (/* binding */ generateSets),
/* harmony export */ generator: () => (/* binding */ generator),
/* harmony export */ getPattern: () => (/* binding */ getPattern),
/* harmony export */ initialize: () => (/* binding */ initialize),
/* harmony export */ mapSequence: () => (/* binding */ mapSequence),
/* harmony export */ normalize: () => (/* binding */ normalize),
/* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
/* harmony export */ unicode_map: () => (/* binding */ unicode_map)
/* harmony export */ });
/* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
/* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
const code_points = [[0, 65535]];
const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
let unicode_map;
let multi_char_reg;
const max_char_length = 3;
const latin_convert = {};
const latin_condensed = {
'/': '⁄∕',
'0': '߀',
"a": "ⱥɐɑ",
"aa": "ꜳ",
"ae": "æǽǣ",
"ao": "ꜵ",
"au": "ꜷ",
"av": "ꜹꜻ",
"ay": "ꜽ",
"b": "ƀɓƃ",
"c": "ꜿƈȼↄ",
"d": "đɗɖᴅƌꮷԁɦ",
"e": "ɛǝᴇɇ",
"f": "ꝼƒ",
"g": "ǥɠꞡᵹꝿɢ",
"h": "ħⱨⱶɥ",
"i": "ɨı",
"j": "ɉȷ",
"k": "ƙⱪꝁꝃꝅꞣ",
"l": "łƚɫⱡꝉꝇꞁɭ",
"m": "ɱɯϻ",
"n": "ꞥƞɲꞑᴎлԉ",
"o": "øǿɔɵꝋꝍᴑ",
"oe": "œ",
"oi": "ƣ",
"oo": "ꝏ",
"ou": "ȣ",
"p": "ƥᵽꝑꝓꝕρ",
"q": "ꝗꝙɋ",
"r": "ɍɽꝛꞧꞃ",
"s": "ßȿꞩꞅʂ",
"t": "ŧƭʈⱦꞇ",
"th": "þ",
"tz": "ꜩ",
"u": "ʉ",
"v": "ʋꝟʌ",
"vy": "ꝡ",
"w": "ⱳ",
"y": "ƴɏỿ",
"z": "ƶȥɀⱬꝣ",
"hv": "ƕ"
};
for (let latin in latin_condensed) {
let unicode = latin_condensed[latin] || '';
for (let i = 0; i < unicode.length; i++) {
let char = unicode.substring(i, i + 1);
latin_convert[char] = latin;
}
}
const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
/**
* Initialize the unicode_map from the give code point ranges
*/
const initialize = (_code_points) => {
if (unicode_map !== undefined)
return;
unicode_map = generateMap(_code_points || code_points);
};
/**
* Helper method for normalize a string
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
*/
const normalize = (str, form = 'NFKD') => str.normalize(form);
/**
* Remove accents without reordering string
* calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
* via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
*/
const asciifold = (str) => {
return Array.from(str).reduce(
/**
* @param {string} result
* @param {string} char
*/
(result, char) => {
return result + _asciifold(char);
}, '');
};
const _asciifold = (str) => {
str = normalize(str)
.toLowerCase()
.replace(convert_pat, (/** @type {string} */ char) => {
return latin_convert[char] || '';
});
//return str;
return normalize(str, 'NFC');
};
/**
* Generate a list of unicode variants from the list of code points
*/
function* generator(code_points) {
for (const [code_point_min, code_point_max] of code_points) {
for (let i = code_point_min; i <= code_point_max; i++) {
let composed = String.fromCharCode(i);
let folded = asciifold(composed);
if (folded == composed.toLowerCase()) {
continue;
}
// skip when folded is a string longer than 3 characters long
// bc the resulting regex patterns will be long
// eg:
// folded صلى الله عليه وسلم length 18 code point 65018
// folded جل جلاله length 8 code point 65019
if (folded.length > max_char_length) {
continue;
}
if (folded.length == 0) {
continue;
}
yield { folded: folded, composed: composed, code_point: i };
}
}
}
/**
* Generate a unicode map from the list of code points
*/
const generateSets = (code_points) => {
const unicode_sets = {};
const addMatching = (folded, to_add) => {
/** @type {Set} */
const folded_set = unicode_sets[folded] || new Set();
const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
if (to_add.match(patt)) {
return;
}
folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
unicode_sets[folded] = folded_set;
};
for (let value of generator(code_points)) {
addMatching(value.folded, value.folded);
addMatching(value.folded, value.composed);
}
return unicode_sets;
};
/**
* Generate a unicode map from the list of code points
* ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
*/
const generateMap = (code_points) => {
const unicode_sets = generateSets(code_points);
const unicode_map = {};
let multi_char = [];
for (let folded in unicode_sets) {
let set = unicode_sets[folded];
if (set) {
unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
}
if (folded.length > 1) {
multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
}
}
multi_char.sort((a, b) => b.length - a.length);
const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
return unicode_map;
};
/**
* Map each element of an array from its folded value to all possible unicode matches
*/
const mapSequence = (strings, min_replacement = 1) => {
let chars_replaced = 0;
strings = strings.map((str) => {
if (unicode_map[str]) {
chars_replaced += str.length;
}
return unicode_map[str] || str;
});
if (chars_replaced >= min_replacement) {
return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
}
return '';
};
/**
* Convert a short string and split it into all possible patterns
* Keep a pattern only if min_replacement is met
*
* 'abc'
* => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
* => ['abc-pattern','ab-c-pattern'...]
*/
const substringsToPattern = (str, min_replacement = 1) => {
min_replacement = Math.max(min_replacement, str.length - 1);
return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
return mapSequence(sub_pat, min_replacement);
}));
};
/**
* Convert an array of sequences into a pattern
* [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
*/
const sequencesToPattern = (sequences, all = true) => {
let min_replacement = sequences.length > 1 ? 1 : 0;
return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
let seq = [];
const len = all ? sequence.length() : sequence.length() - 1;
for (let j = 0; j < len; j++) {
seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
}
return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
}));
};
/**
* Return true if the sequence is already in the sequences
*/
const inSequences = (needle_seq, sequences) => {
for (const seq of sequences) {
if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
continue;
}
if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
continue;
}
let needle_parts = needle_seq.parts;
const filter = (part) => {
for (const needle_part of needle_parts) {
if (needle_part.start === part.start && needle_part.substr === part.substr) {
return false;
}
if (part.length == 1 || needle_part.length == 1) {
continue;
}
// check for overlapping parts
// a = ['::=','==']
// b = ['::','===']
// a = ['r','sm']
// b = ['rs','m']
if (part.start < needle_part.start && part.end > needle_part.start) {
return true;
}
if (needle_part.start < part.start && needle_part.end > part.start) {
return true;
}
}
return false;
};
let filtered = seq.parts.filter(filter);
if (filtered.length > 0) {
continue;
}
return true;
}
return false;
};
class Sequence {
parts;
substrs;
start;
end;
constructor() {
this.parts = [];
this.substrs = [];
this.start = 0;
this.end = 0;
}
add(part) {
if (part) {
this.parts.push(part);
this.substrs.push(part.substr);
this.start = Math.min(part.start, this.start);
this.end = Math.max(part.end, this.end);
}
}
last() {
return this.parts[this.parts.length - 1];
}
length() {
return this.parts.length;
}
clone(position, last_piece) {
let clone = new Sequence();
let parts = JSON.parse(JSON.stringify(this.parts));
let last_part = parts.pop();
for (const part of parts) {
clone.add(part);
}
let last_substr = last_piece.substr.substring(0, position - last_part.start);
let clone_last_len = last_substr.length;
clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
return clone;
}
}
/**
* Expand a regular expression pattern to include unicode variants
* eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
*
* Issue:
* ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
* becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
*
* İIJ = IIJ = ⅡJ
*
* 1/2/4
*/
const getPattern = (str) => {
initialize();
str = asciifold(str);
let pattern = '';
let sequences = [new Sequence()];
for (let i = 0; i < str.length; i++) {
let substr = str.substring(i);
let match = substr.match(multi_char_reg);
const char = str.substring(i, i + 1);
const match_str = match ? match[0] : null;
// loop through sequences
// add either the char or multi_match
let overlapping = [];
let added_types = new Set();
for (const sequence of sequences) {
const last_piece = sequence.last();
if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
// if we have a multi match
if (match_str) {
const len = match_str.length;
sequence.add({ start: i, end: i + len, length: len, substr: match_str });
added_types.add('1');
}
else {
sequence.add({ start: i, end: i + 1, length: 1, substr: char });
added_types.add('2');
}
}
else if (match_str) {
let clone = sequence.clone(i, last_piece);
const len = match_str.length;
clone.add({ start: i, end: i + len, length: len, substr: match_str });
overlapping.push(clone);
}
else {
// don't add char
// adding would create invalid patterns: 234 => [2,34,4]
added_types.add('3');
}
}
// if we have overlapping
if (overlapping.length > 0) {
// ['ii','iii'] before ['i','i','iii']
overlapping = overlapping.sort((a, b) => {
return a.length() - b.length();
});
for (let clone of overlapping) {
// don't add if we already have an equivalent sequence
if (inSequences(clone, sequences)) {
continue;
}
sequences.push(clone);
}
continue;
}
// if we haven't done anything unique
// clean up the patterns
// helps keep patterns smaller
// if str = 'r₨㎧aarss', pattern will be 446 instead of 655
if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
pattern += sequencesToPattern(sequences, false);
let new_seq = new Sequence();
const old_seq = sequences[0];
if (old_seq) {
new_seq.add(old_seq.last());
}
sequences = [new_seq];
}
}
pattern += sequencesToPattern(sequences, true);
return pattern;
};
//# sourceMappingURL=index.js.map
/***/ },
/***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
/*!*******************************************************************!*\
!*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
\*******************************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
/* harmony export */ escape_regex: () => (/* binding */ escape_regex),
/* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
/* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
/* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
/* harmony export */ setToPattern: () => (/* binding */ setToPattern),
/* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
/* harmony export */ });
/**
* Convert array of strings to a regular expression
* ex ['ab','a'] => (?:ab|a)
* ex ['a','b'] => [ab]
*/
const arrayToPattern = (chars) => {
chars = chars.filter(Boolean);
if (chars.length < 2) {
return chars[0] || '';
}
return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
};
const sequencePattern = (array) => {
if (!hasDuplicates(array)) {
return array.join('');
}
let pattern = '';
let prev_char_count = 0;
const prev_pattern = () => {
if (prev_char_count > 1) {
pattern += '{' + prev_char_count + '}';
}
};
array.forEach((char, i) => {
if (char === array[i - 1]) {
prev_char_count++;
return;
}
prev_pattern();
pattern += char;
prev_char_count = 1;
});
prev_pattern();
return pattern;
};
/**
* Convert array of strings to a regular expression
* ex ['ab','a'] => (?:ab|a)
* ex ['a','b'] => [ab]
*/
const setToPattern = (chars) => {
let array = Array.from(chars);
return arrayToPattern(array);
};
/**
* https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
*/
const hasDuplicates = (array) => {
return (new Set(array)).size !== array.length;
};
/**
* https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
*/
const escape_regex = (str) => {
return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
};
/**
* Return the max length of array values
*/
const maxValueLength = (array) => {
return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
};
const unicodeLength = (str) => {
return Array.from(str).length;
};
//# sourceMappingURL=regex.js.map
/***/ },
/***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
/*!*********************************************************************!*\
!*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
\*********************************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
/* harmony export */ });
/**
* Get all possible combinations of substrings that add up to the given string
* https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
*/
const allSubstrings = (input) => {
if (input.length === 1)
return [[input]];
let result = [];
const start = input.substring(1);
const suba = allSubstrings(start);
suba.forEach(function (subresult) {
let tmp = subresult.slice(0);
tmp[0] = input.charAt(0) + tmp[0];
result.push(tmp);
tmp = subresult.slice(0);
tmp.unshift(input.charAt(0));
result.push(tmp);
});
return result;
};
//# sourceMappingURL=strings.js.map
/***/ },
/***/ "./node_modules/tom-select/dist/esm/constants.js"
/*!*******************************************************!*\
!*** ./node_modules/tom-select/dist/esm/constants.js ***!
\*******************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
/* harmony export */ KEY_A: () => (/* binding */ KEY_A),
/* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
/* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
/* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
/* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
/* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
/* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
/* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
/* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
/* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
/* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
/* harmony export */ });
const KEY_A = 65;
const KEY_RETURN = 13;
const KEY_ESC = 27;
const KEY_LEFT = 37;
const KEY_UP = 38;
const KEY_RIGHT = 39;
const KEY_DOWN = 40;
const KEY_BACKSPACE = 8;
const KEY_DELETE = 46;
const KEY_TAB = 9;
const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
//# sourceMappingURL=constants.js.map
/***/ },
/***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
/*!***************************************************************!*\
!*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
\***************************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ highlight: () => (/* binding */ highlight),
/* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
/* harmony export */ });
/* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
/**
* highlight v3 | MIT license | Johann Burkard
* Highlights arbitrary terms in a node.
*
* - Modified by Marshal 2011-6-24 (added regex)
* - Modified by Brian Reavis 2012-8-27 (cleanup)
*/
const highlight = (element, regex) => {
if (regex === null)
return;
// convet string to regex
if (typeof regex === 'string') {
if (!regex.length)
return;
regex = new RegExp(regex, 'i');
}
// Wrap matching part of text node with highlighting , e.g.
// Soccer -> Soccer for regex = /soc/i
const highlightText = (node) => {
var match = node.data.match(regex);
if (match && node.data.length > 0) {
var spannode = document.createElement('span');
spannode.className = 'highlight';
var middlebit = node.splitText(match.index);
middlebit.splitText(match[0].length);
var middleclone = middlebit.cloneNode(true);
spannode.appendChild(middleclone);
(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
return 1;
}
return 0;
};
// Recurse element node, looking for child text nodes to highlight, unless element
// is childless,