From 3236b99e253fec08dac2055d5f0bfa21509f7961 Mon Sep 17 00:00:00 2001 From: mtriff Date: Tue, 29 Nov 2022 19:03:40 +0000 Subject: [PATCH] deploy: 5dbea2825a5887d88d6947443f4874bb7b84cc3a --- assets/scripts/choices.js | 1648 +++++------------ assets/scripts/choices.min.js | 2 +- assets/scripts/choices.min.js.LICENSE.txt | 2 +- assets/styles/choices.min.css | 2 +- index.html | 7 +- types/cypress/e2e/select-multiple.spec.d.ts | 1 + .../cypress/e2e/select-multiple.spec.d.ts.map | 1 + types/cypress/e2e/select-one.spec.d.ts | 1 + types/cypress/e2e/select-one.spec.d.ts.map | 1 + types/cypress/e2e/text.spec.d.ts | 1 + types/cypress/e2e/text.spec.d.ts.map | 1 + types/cypress/plugins/index.d.ts | 3 + types/cypress/plugins/index.d.ts.map | 1 + types/cypress/support/commands.d.ts | 1 + types/cypress/support/commands.d.ts.map | 1 + types/cypress/support/e2e.d.ts | 2 + types/cypress/support/e2e.d.ts.map | 1 + types/cypress/support/index.d.ts | 2 + types/cypress/support/index.d.ts.map | 1 + types/src/scripts/choices.d.ts | 2 +- types/src/scripts/choices.d.ts.map | 2 +- types/src/scripts/interfaces/action-type.d.ts | 2 +- .../scripts/interfaces/action-type.d.ts.map | 2 +- types/src/scripts/interfaces/event-type.d.ts | 2 +- .../scripts/interfaces/event-type.d.ts.map | 2 +- types/src/scripts/interfaces/options.d.ts | 2 +- .../interfaces/passed-element-type.d.ts | 2 +- .../interfaces/passed-element-type.d.ts.map | 2 +- .../interfaces/position-options-type.d.ts | 2 +- .../interfaces/position-options-type.d.ts.map | 2 +- types/src/scripts/lib/utils.d.ts | 1 + types/src/scripts/lib/utils.d.ts.map | 2 +- types/src/scripts/reducers/choices.d.ts | 2 +- types/src/scripts/reducers/choices.d.ts.map | 2 +- types/src/scripts/reducers/groups.d.ts | 2 +- types/src/scripts/reducers/groups.d.ts.map | 2 +- types/src/scripts/reducers/items.d.ts | 2 +- types/src/scripts/reducers/items.d.ts.map | 2 +- types/src/scripts/reducers/loading.d.ts | 2 +- types/src/scripts/reducers/loading.d.ts.map | 2 +- types/src/scripts/templates.d.ts | 2 +- types/src/scripts/templates.d.ts.map | 2 +- 42 files changed, 525 insertions(+), 1199 deletions(-) create mode 100644 types/cypress/e2e/select-multiple.spec.d.ts create mode 100644 types/cypress/e2e/select-multiple.spec.d.ts.map create mode 100644 types/cypress/e2e/select-one.spec.d.ts create mode 100644 types/cypress/e2e/select-one.spec.d.ts.map create mode 100644 types/cypress/e2e/text.spec.d.ts create mode 100644 types/cypress/e2e/text.spec.d.ts.map create mode 100644 types/cypress/plugins/index.d.ts create mode 100644 types/cypress/plugins/index.d.ts.map create mode 100644 types/cypress/support/commands.d.ts create mode 100644 types/cypress/support/commands.d.ts.map create mode 100644 types/cypress/support/e2e.d.ts create mode 100644 types/cypress/support/e2e.d.ts.map create mode 100644 types/cypress/support/index.d.ts create mode 100644 types/cypress/support/index.d.ts.map diff --git a/assets/scripts/choices.js b/assets/scripts/choices.js index 5847eeb..8cadac6 100644 --- a/assets/scripts/choices.js +++ b/assets/scripts/choices.js @@ -1,4 +1,4 @@ -/*! choices.js v10.1.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ +/*! choices.js v10.2.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -22,19 +22,17 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.clearChoices = exports.activateChoices = exports.filterChoices = exports.addChoice = void 0; - var constants_1 = __webpack_require__(883); - var addChoice = function (_a) { var value = _a.value, - label = _a.label, - id = _a.id, - groupId = _a.groupId, - disabled = _a.disabled, - elementId = _a.elementId, - customProperties = _a.customProperties, - placeholder = _a.placeholder, - keyCode = _a.keyCode; + label = _a.label, + id = _a.id, + groupId = _a.groupId, + disabled = _a.disabled, + elementId = _a.elementId, + customProperties = _a.customProperties, + placeholder = _a.placeholder, + keyCode = _a.keyCode; return { type: constants_1.ACTION_TYPES.ADD_CHOICE, value: value, @@ -48,37 +46,29 @@ var addChoice = function (_a) { keyCode: keyCode }; }; - exports.addChoice = addChoice; - var filterChoices = function (results) { return { type: constants_1.ACTION_TYPES.FILTER_CHOICES, results: results }; }; - exports.filterChoices = filterChoices; - var activateChoices = function (active) { if (active === void 0) { active = true; } - return { type: constants_1.ACTION_TYPES.ACTIVATE_CHOICES, active: active }; }; - exports.activateChoices = activateChoices; - var clearChoices = function () { return { type: constants_1.ACTION_TYPES.CLEAR_CHOICES }; }; - exports.clearChoices = clearChoices; /***/ }), @@ -92,14 +82,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.addGroup = void 0; - var constants_1 = __webpack_require__(883); - var addGroup = function (_a) { var value = _a.value, - id = _a.id, - active = _a.active, - disabled = _a.disabled; + id = _a.id, + active = _a.active, + disabled = _a.disabled; return { type: constants_1.ACTION_TYPES.ADD_GROUP, value: value, @@ -108,7 +96,6 @@ var addGroup = function (_a) { disabled: disabled }; }; - exports.addGroup = addGroup; /***/ }), @@ -122,18 +109,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.highlightItem = exports.removeItem = exports.addItem = void 0; - var constants_1 = __webpack_require__(883); - var addItem = function (_a) { var value = _a.value, - label = _a.label, - id = _a.id, - choiceId = _a.choiceId, - groupId = _a.groupId, - customProperties = _a.customProperties, - placeholder = _a.placeholder, - keyCode = _a.keyCode; + label = _a.label, + id = _a.id, + choiceId = _a.choiceId, + groupId = _a.groupId, + customProperties = _a.customProperties, + placeholder = _a.placeholder, + keyCode = _a.keyCode; return { type: constants_1.ACTION_TYPES.ADD_ITEM, value: value, @@ -146,9 +131,7 @@ var addItem = function (_a) { keyCode: keyCode }; }; - exports.addItem = addItem; - var removeItem = function (id, choiceId) { return { type: constants_1.ACTION_TYPES.REMOVE_ITEM, @@ -156,9 +139,7 @@ var removeItem = function (id, choiceId) { choiceId: choiceId }; }; - exports.removeItem = removeItem; - var highlightItem = function (id, highlighted) { return { type: constants_1.ACTION_TYPES.HIGHLIGHT_ITEM, @@ -166,7 +147,6 @@ var highlightItem = function (id, highlighted) { highlighted: highlighted }; }; - exports.highlightItem = highlightItem; /***/ }), @@ -180,33 +160,26 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.setIsLoading = exports.resetTo = exports.clearAll = void 0; - var constants_1 = __webpack_require__(883); - var clearAll = function () { return { type: constants_1.ACTION_TYPES.CLEAR_ALL }; }; - exports.clearAll = clearAll; - var resetTo = function (state) { return { type: constants_1.ACTION_TYPES.RESET_TO, state: state }; }; - exports.resetTo = resetTo; - var setIsLoading = function (isLoading) { return { type: constants_1.ACTION_TYPES.SET_IS_LOADING, isLoading: isLoading }; }; - exports.setIsLoading = setIsLoading; /***/ }), @@ -225,73 +198,49 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) { } return to.concat(ar || Array.prototype.slice.call(from)); }; - var __importDefault = this && this.__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; - Object.defineProperty(exports, "__esModule", ({ value: true })); - var deepmerge_1 = __importDefault(__webpack_require__(996)); /* eslint-disable @typescript-eslint/no-explicit-any */ - - var fuse_js_1 = __importDefault(__webpack_require__(221)); - var choices_1 = __webpack_require__(282); - var groups_1 = __webpack_require__(783); - var items_1 = __webpack_require__(464); - var misc_1 = __webpack_require__(137); - var components_1 = __webpack_require__(520); - var constants_1 = __webpack_require__(883); - var defaults_1 = __webpack_require__(789); - var utils_1 = __webpack_require__(799); - var reducers_1 = __webpack_require__(655); - var store_1 = __importDefault(__webpack_require__(744)); - var templates_1 = __importDefault(__webpack_require__(686)); /** @see {@link http://browserhacks.com/#hack-acea075d0ac6954f275a70023906050c} */ - - var IS_IE11 = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style; var USER_DEFAULTS = {}; /** * Choices * @author Josh Johnson */ - -var Choices = -/** @class */ -function () { +var Choices = /** @class */function () { function Choices(element, userConfig) { - var _this = this; - if (element === void 0) { element = '[data-choice]'; } - if (userConfig === void 0) { userConfig = {}; } - + var _this = this; if (userConfig.allowHTML === undefined) { console.warn('Deprecation warning: allowHTML will default to false in a future release. To render HTML in Choices, you will need to set it to true. Setting allowHTML will suppress this message.'); } - - this.config = deepmerge_1.default.all([defaults_1.DEFAULT_CONFIG, Choices.defaults.options, userConfig], // When merging array configs, replace with a copy of the userConfig array, + this.config = deepmerge_1.default.all([defaults_1.DEFAULT_CONFIG, Choices.defaults.options, userConfig], + // When merging array configs, replace with a copy of the userConfig array, // instead of concatenating with the default array { arrayMerge: function (_, sourceArray) { @@ -299,32 +248,25 @@ function () { } }); var invalidConfigOptions = (0, utils_1.diff)(this.config, defaults_1.DEFAULT_CONFIG); - if (invalidConfigOptions.length) { console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', ')); } - var passedElement = typeof element === 'string' ? document.querySelector(element) : element; - if (!(passedElement instanceof HTMLInputElement || passedElement instanceof HTMLSelectElement)) { throw TypeError('Expected one of the following types text|select-one|select-multiple'); } - this._isTextElement = passedElement.type === constants_1.TEXT_TYPE; this._isSelectOneElement = passedElement.type === constants_1.SELECT_ONE_TYPE; this._isSelectMultipleElement = passedElement.type === constants_1.SELECT_MULTIPLE_TYPE; this._isSelectElement = this._isSelectOneElement || this._isSelectMultipleElement; this.config.searchEnabled = this._isSelectMultipleElement || this.config.searchEnabled; - if (!['auto', 'always'].includes("".concat(this.config.renderSelectedChoices))) { this.config.renderSelectedChoices = 'auto'; } - if (userConfig.addItemFilter && typeof userConfig.addItemFilter !== 'function') { var re = userConfig.addItemFilter instanceof RegExp ? userConfig.addItemFilter : new RegExp(userConfig.addItemFilter); this.config.addItemFilter = re.test.bind(re); } - if (this._isTextElement) { this.passedElement = new components_1.WrappedInput({ element: passedElement, @@ -340,7 +282,6 @@ function () { } }); } - this.initialised = false; this._store = new store_1.default(); this._initialState = reducers_1.defaultState; @@ -357,40 +298,33 @@ function () { * setting direction in cases where it's explicitly set on passedElement * or when calculated direction is different from the document */ - this._direction = this.passedElement.dir; - if (!this._direction) { var elementDirection = window.getComputedStyle(this.passedElement.element).direction; var documentDirection = window.getComputedStyle(document.documentElement).direction; - if (elementDirection !== documentDirection) { this._direction = elementDirection; } } - this._idNames = { itemChoice: 'item-choice' }; - if (this._isSelectElement) { // Assign preset groups from passed element - this._presetGroups = this.passedElement.optionGroups; // Assign preset options from passed element - + this._presetGroups = this.passedElement.optionGroups; + // Assign preset options from passed element this._presetOptions = this.passedElement.options; - } // Assign preset choices from passed object - - - this._presetChoices = this.config.choices; // Assign preset items from passed object first - - this._presetItems = this.config.items; // Add any values passed from attribute - + } + // Assign preset choices from passed object + this._presetChoices = this.config.choices; + // Assign preset items from passed object first + this._presetItems = this.config.items; + // Add any values passed from attribute if (this.passedElement.value && this._isTextElement) { var splitValues = this.passedElement.value.split(this.config.delimiter); this._presetItems = this._presetItems.concat(splitValues); - } // Create array of choices from option elements - - + } + // Create array of choices from option elements if (this.passedElement.options) { this.passedElement.options.forEach(function (option) { _this._presetChoices.push({ @@ -399,11 +333,10 @@ function () { selected: !!option.selected, disabled: option.disabled || option.parentNode.disabled, placeholder: option.value === '' || option.hasAttribute('placeholder'), - customProperties: option.dataset['custom-properties'] + customProperties: (0, utils_1.parseCustomProperties)(option.dataset.customProperties) }); }); } - this._render = this._render.bind(this); this._onFocus = this._onFocus.bind(this); this._onBlur = this._onBlur.bind(this); @@ -419,140 +352,107 @@ function () { this._onEnterKey = this._onEnterKey.bind(this); this._onEscapeKey = this._onEscapeKey.bind(this); this._onDirectionKey = this._onDirectionKey.bind(this); - this._onDeleteKey = this._onDeleteKey.bind(this); // If element has already been initialised with Choices, fail silently - + this._onDeleteKey = this._onDeleteKey.bind(this); + // If element has already been initialised with Choices, fail silently if (this.passedElement.isActive) { if (!this.config.silent) { console.warn('Trying to initialise Choices on element already initialised', { element: element }); } - this.initialised = true; return; - } // Let's go - - + } + // Let's go this.init(); } - Object.defineProperty(Choices, "defaults", { get: function () { return Object.preventExtensions({ get options() { return USER_DEFAULTS; }, - get templates() { return templates_1.default; } - }); }, enumerable: false, configurable: true }); - Choices.prototype.init = function () { if (this.initialised) { return; } - this._createTemplates(); - this._createElements(); - this._createStructure(); - this._store.subscribe(this._render); - this._render(); - this._addEventListeners(); - var shouldDisable = !this.config.addItems || this.passedElement.element.hasAttribute('disabled'); - if (shouldDisable) { this.disable(); } - this.initialised = true; - var callbackOnInit = this.config.callbackOnInit; // Run callback if it is a function - + var callbackOnInit = this.config.callbackOnInit; + // Run callback if it is a function if (callbackOnInit && typeof callbackOnInit === 'function') { callbackOnInit.call(this); } }; - Choices.prototype.destroy = function () { if (!this.initialised) { return; } - this._removeEventListeners(); - this.passedElement.reveal(); this.containerOuter.unwrap(this.passedElement.element); this.clearStore(); - if (this._isSelectElement) { this.passedElement.options = this._presetOptions; } - this._templates = templates_1.default; this.initialised = false; }; - Choices.prototype.enable = function () { if (this.passedElement.isDisabled) { this.passedElement.enable(); } - if (this.containerOuter.isDisabled) { this._addEventListeners(); - this.input.enable(); this.containerOuter.enable(); } - return this; }; - Choices.prototype.disable = function () { if (!this.passedElement.isDisabled) { this.passedElement.disable(); } - if (!this.containerOuter.isDisabled) { this._removeEventListeners(); - this.input.disable(); this.containerOuter.disable(); } - return this; }; - Choices.prototype.highlightItem = function (item, runEvent) { if (runEvent === void 0) { runEvent = true; } - if (!item || !item.id) { return this; } - var id = item.id, - _a = item.groupId, - groupId = _a === void 0 ? -1 : _a, - _b = item.value, - value = _b === void 0 ? '' : _b, - _c = item.label, - label = _c === void 0 ? '' : _c; + _a = item.groupId, + groupId = _a === void 0 ? -1 : _a, + _b = item.value, + value = _b === void 0 ? '' : _b, + _c = item.label, + label = _c === void 0 ? '' : _c; var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - this._store.dispatch((0, items_1.highlightItem)(id, true)); - if (runEvent) { this.passedElement.triggerEvent(constants_1.EVENTS.highlightItem, { id: id, @@ -561,26 +461,21 @@ function () { groupValue: group && group.value ? group.value : null }); } - return this; }; - Choices.prototype.unhighlightItem = function (item) { if (!item || !item.id) { return this; } - var id = item.id, - _a = item.groupId, - groupId = _a === void 0 ? -1 : _a, - _b = item.value, - value = _b === void 0 ? '' : _b, - _c = item.label, - label = _c === void 0 ? '' : _c; + _a = item.groupId, + groupId = _a === void 0 ? -1 : _a, + _b = item.value, + value = _b === void 0 ? '' : _b, + _c = item.label, + label = _c === void 0 ? '' : _c; var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - this._store.dispatch((0, items_1.highlightItem)(id, false)); - this.passedElement.triggerEvent(constants_1.EVENTS.highlightItem, { id: id, value: value, @@ -589,153 +484,114 @@ function () { }); return this; }; - Choices.prototype.highlightAll = function () { var _this = this; - this._store.items.forEach(function (item) { return _this.highlightItem(item); }); - return this; }; - Choices.prototype.unhighlightAll = function () { var _this = this; - this._store.items.forEach(function (item) { return _this.unhighlightItem(item); }); - return this; }; - Choices.prototype.removeActiveItemsByValue = function (value) { var _this = this; - this._store.activeItems.filter(function (item) { return item.value === value; }).forEach(function (item) { return _this._removeItem(item); }); - return this; }; - Choices.prototype.removeActiveItems = function (excludedId) { var _this = this; - this._store.activeItems.filter(function (_a) { var id = _a.id; return id !== excludedId; }).forEach(function (item) { return _this._removeItem(item); }); - return this; }; - Choices.prototype.removeHighlightedItems = function (runEvent) { var _this = this; - if (runEvent === void 0) { runEvent = false; } - this._store.highlightedActiveItems.forEach(function (item) { - _this._removeItem(item); // If this action was performed by the user + _this._removeItem(item); + // If this action was performed by the user // trigger the event - - if (runEvent) { _this._triggerChange(item.value); } }); - return this; }; - Choices.prototype.showDropdown = function (preventInputFocus) { var _this = this; - if (this.dropdown.isActive) { return this; } - requestAnimationFrame(function () { _this.dropdown.show(); - _this.containerOuter.open(_this.dropdown.distanceFromTopWindow); - if (!preventInputFocus && _this._canSearch) { _this.input.focus(); } - _this.passedElement.triggerEvent(constants_1.EVENTS.showDropdown, {}); }); return this; }; - Choices.prototype.hideDropdown = function (preventInputBlur) { var _this = this; - if (!this.dropdown.isActive) { return this; } - requestAnimationFrame(function () { _this.dropdown.hide(); - _this.containerOuter.close(); - if (!preventInputBlur && _this._canSearch) { _this.input.removeActiveDescendant(); - _this.input.blur(); } - _this.passedElement.triggerEvent(constants_1.EVENTS.hideDropdown, {}); }); return this; }; - Choices.prototype.getValue = function (valueOnly) { if (valueOnly === void 0) { valueOnly = false; } - var values = this._store.activeItems.reduce(function (selectedItems, item) { var itemValue = valueOnly ? item.value : item; selectedItems.push(itemValue); return selectedItems; }, []); - return this._isSelectOneElement ? values[0] : values; }; - Choices.prototype.setValue = function (items) { var _this = this; - if (!this.initialised) { return this; } - items.forEach(function (value) { return _this._setChoiceOrItem(value); }); return this; }; - Choices.prototype.setChoiceByValue = function (value) { var _this = this; - if (!this.initialised || this._isTextElement) { return this; - } // If only one value has been passed, convert to array - - - var choiceValue = Array.isArray(value) ? value : [value]; // Loop through each value and - + } + // If only one value has been passed, convert to array + var choiceValue = Array.isArray(value) ? value : [value]; + // Loop through each value and choiceValue.forEach(function (val) { return _this._findAndSelectChoiceByValue(val); }); @@ -804,48 +660,36 @@ function () { * }], 'value', 'label', false); * ``` */ - - Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices) { var _this = this; - if (choicesArrayOrFetcher === void 0) { choicesArrayOrFetcher = []; } - if (value === void 0) { value = 'value'; } - if (label === void 0) { label = 'label'; } - if (replaceChoices === void 0) { replaceChoices = false; } - if (!this.initialised) { throw new ReferenceError("setChoices was called on a non-initialized instance of Choices"); } - if (!this._isSelectElement) { throw new TypeError("setChoices can't be used with INPUT based Choices"); } - if (typeof value !== 'string' || !value) { throw new TypeError("value parameter must be a name of 'value' field in passed objects"); - } // Clear choices if needed - - + } + // Clear choices if needed if (replaceChoices) { this.clearChoices(); } - if (typeof choicesArrayOrFetcher === 'function') { // it's a choices fetcher function var fetcher_1 = choicesArrayOrFetcher(this); - if (typeof Promise === 'function' && fetcher_1 instanceof Promise) { // that's a promise // eslint-disable-next-line no-promise-executor-return @@ -866,25 +710,19 @@ function () { }).then(function () { return _this; }); - } // function returned something else than promise, let's check if it's an array of choices - - + } + // function returned something else than promise, let's check if it's an array of choices if (!Array.isArray(fetcher_1)) { throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof fetcher_1)); - } // recursion with results, it's sync and choices were cleared already - - + } + // recursion with results, it's sync and choices were cleared already return this.setChoices(fetcher_1, value, label, false); } - if (!Array.isArray(choicesArrayOrFetcher)) { throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices"); } - this.containerOuter.removeLoadingState(); - this._startLoading(); - choicesArrayOrFetcher.forEach(function (groupOrChoice) { if (groupOrChoice.choices) { _this._addGroup({ @@ -895,7 +733,6 @@ function () { }); } else { var choice = groupOrChoice; - _this._addChoice({ value: choice[value], label: choice[label], @@ -906,115 +743,87 @@ function () { }); } }); - this._stopLoading(); - return this; }; - Choices.prototype.clearChoices = function () { this._store.dispatch((0, choices_1.clearChoices)()); - return this; }; - Choices.prototype.clearStore = function () { this._store.dispatch((0, misc_1.clearAll)()); - return this; }; - Choices.prototype.clearInput = function () { var shouldSetInputWidth = !this._isSelectOneElement; this.input.clear(shouldSetInputWidth); - if (!this._isTextElement && this._canSearch) { this._isSearching = false; - this._store.dispatch((0, choices_1.activateChoices)(true)); } - return this; }; - Choices.prototype._render = function () { if (this._store.isLoading()) { return; } - this._currentState = this._store.state; var stateChanged = this._currentState.choices !== this._prevState.choices || this._currentState.groups !== this._prevState.groups || this._currentState.items !== this._prevState.items; var shouldRenderChoices = this._isSelectElement; var shouldRenderItems = this._currentState.items !== this._prevState.items; - if (!stateChanged) { return; } - if (shouldRenderChoices) { this._renderChoices(); } - if (shouldRenderItems) { this._renderItems(); } - this._prevState = this._currentState; }; - Choices.prototype._renderChoices = function () { var _this = this; - var _a = this._store, - activeGroups = _a.activeGroups, - activeChoices = _a.activeChoices; + activeGroups = _a.activeGroups, + activeChoices = _a.activeChoices; var choiceListFragment = document.createDocumentFragment(); this.choiceList.clear(); - if (this.config.resetScrollPosition) { requestAnimationFrame(function () { return _this.choiceList.scrollToTop(); }); - } // If we have grouped options - - + } + // If we have grouped options if (activeGroups.length >= 1 && !this._isSearching) { // If we have a placeholder choice along with groups var activePlaceholders = activeChoices.filter(function (activeChoice) { return activeChoice.placeholder === true && activeChoice.groupId === -1; }); - if (activePlaceholders.length >= 1) { choiceListFragment = this._createChoicesFragment(activePlaceholders, choiceListFragment); } - choiceListFragment = this._createGroupsFragment(activeGroups, activeChoices, choiceListFragment); } else if (activeChoices.length >= 1) { choiceListFragment = this._createChoicesFragment(activeChoices, choiceListFragment); - } // If we have choices to show - - + } + // If we have choices to show if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) { var activeItems = this._store.activeItems; - - var canAddItem = this._canAddItem(activeItems, this.input.value); // ...and we can select them - - + var canAddItem = this._canAddItem(activeItems, this.input.value); + // ...and we can select them if (canAddItem.response) { // ...append them and highlight the first choice this.choiceList.append(choiceListFragment); - this._highlightChoice(); } else { var notice = this._getTemplate('notice', canAddItem.notice); - this.choiceList.append(notice); } } else { // Otherwise show a notice var dropdownItem = void 0; var notice = void 0; - if (this._isSearching) { notice = typeof this.config.noResultsText === 'function' ? this.config.noResultsText() : this.config.noResultsText; dropdownItem = this._getTemplate('notice', notice, 'no-results'); @@ -1022,154 +831,122 @@ function () { notice = typeof this.config.noChoicesText === 'function' ? this.config.noChoicesText() : this.config.noChoicesText; dropdownItem = this._getTemplate('notice', notice, 'no-choices'); } - this.choiceList.append(dropdownItem); } }; - Choices.prototype._renderItems = function () { var activeItems = this._store.activeItems || []; - this.itemList.clear(); // Create a fragment to store our list items + this.itemList.clear(); + // Create a fragment to store our list items // (so we don't have to update the DOM for each item) - - var itemListFragment = this._createItemsFragment(activeItems); // If we have items to add, append them - - + var itemListFragment = this._createItemsFragment(activeItems); + // If we have items to add, append them if (itemListFragment.childNodes) { this.itemList.append(itemListFragment); } }; - Choices.prototype._createGroupsFragment = function (groups, choices, fragment) { var _this = this; - if (fragment === void 0) { fragment = document.createDocumentFragment(); } - var getGroupChoices = function (group) { return choices.filter(function (choice) { if (_this._isSelectOneElement) { return choice.groupId === group.id; } - return choice.groupId === group.id && (_this.config.renderSelectedChoices === 'always' || !choice.selected); }); - }; // If sorting is enabled, filter groups - - + }; + // If sorting is enabled, filter groups if (this.config.shouldSort) { groups.sort(this.config.sorter); } - groups.forEach(function (group) { var groupChoices = getGroupChoices(group); - if (groupChoices.length >= 1) { var dropdownGroup = _this._getTemplate('choiceGroup', group); - fragment.appendChild(dropdownGroup); - _this._createChoicesFragment(groupChoices, fragment, true); } }); return fragment; }; - Choices.prototype._createChoicesFragment = function (choices, fragment, withinGroup) { var _this = this; - if (fragment === void 0) { fragment = document.createDocumentFragment(); } - if (withinGroup === void 0) { withinGroup = false; - } // Create a fragment to store our list items (so we don't have to update the DOM for each item) - - + } + // Create a fragment to store our list items (so we don't have to update the DOM for each item) var _a = this.config, - renderSelectedChoices = _a.renderSelectedChoices, - searchResultLimit = _a.searchResultLimit, - renderChoiceLimit = _a.renderChoiceLimit; + renderSelectedChoices = _a.renderSelectedChoices, + searchResultLimit = _a.searchResultLimit, + renderChoiceLimit = _a.renderChoiceLimit; var filter = this._isSearching ? utils_1.sortByScore : this.config.sorter; - var appendChoice = function (choice) { var shouldRender = renderSelectedChoices === 'auto' ? _this._isSelectOneElement || !choice.selected : true; - if (shouldRender) { var dropdownItem = _this._getTemplate('choice', choice, _this.config.itemSelectText); - fragment.appendChild(dropdownItem); } }; - var rendererableChoices = choices; - if (renderSelectedChoices === 'auto' && !this._isSelectOneElement) { rendererableChoices = choices.filter(function (choice) { return !choice.selected; }); - } // Split array into placeholders and "normal" choices - - + } + // Split array into placeholders and "normal" choices var _b = rendererableChoices.reduce(function (acc, choice) { - if (choice.placeholder) { - acc.placeholderChoices.push(choice); - } else { - acc.normalChoices.push(choice); - } - - return acc; - }, { - placeholderChoices: [], - normalChoices: [] - }), - placeholderChoices = _b.placeholderChoices, - normalChoices = _b.normalChoices; // If sorting is enabled or the user is searching, filter choices - - + if (choice.placeholder) { + acc.placeholderChoices.push(choice); + } else { + acc.normalChoices.push(choice); + } + return acc; + }, { + placeholderChoices: [], + normalChoices: [] + }), + placeholderChoices = _b.placeholderChoices, + normalChoices = _b.normalChoices; + // If sorting is enabled or the user is searching, filter choices if (this.config.shouldSort || this._isSearching) { normalChoices.sort(filter); } - - var choiceLimit = rendererableChoices.length; // Prepend placeholeder - + var choiceLimit = rendererableChoices.length; + // Prepend placeholeder var sortedChoices = this._isSelectOneElement ? __spreadArray(__spreadArray([], placeholderChoices, true), normalChoices, true) : normalChoices; - if (this._isSearching) { choiceLimit = searchResultLimit; } else if (renderChoiceLimit && renderChoiceLimit > 0 && !withinGroup) { choiceLimit = renderChoiceLimit; - } // Add each choice to dropdown within range - - + } + // Add each choice to dropdown within range for (var i = 0; i < choiceLimit; i += 1) { if (sortedChoices[i]) { appendChoice(sortedChoices[i]); } } - return fragment; }; - Choices.prototype._createItemsFragment = function (items, fragment) { var _this = this; - if (fragment === void 0) { fragment = document.createDocumentFragment(); - } // Create fragment to add elements to - - + } + // Create fragment to add elements to var _a = this.config, - shouldSortItems = _a.shouldSortItems, - sorter = _a.sorter, - removeItemButton = _a.removeItemButton; // If sorting is enabled, filter items - + shouldSortItems = _a.shouldSortItems, + sorter = _a.sorter, + removeItemButton = _a.removeItemButton; + // If sorting is enabled, filter items if (shouldSortItems && !this._isSelectOneElement) { items.sort(sorter); } - if (this._isTextElement) { // Update the value of the hidden input this.passedElement.value = items.map(function (_a) { @@ -1180,30 +957,24 @@ function () { // Update the options of the hidden input this.passedElement.options = items; } - var addItemToFragment = function (item) { // Create new list element - var listItem = _this._getTemplate('item', item, removeItemButton); // Append it to list - - + var listItem = _this._getTemplate('item', item, removeItemButton); + // Append it to list fragment.appendChild(listItem); - }; // Add each list item to list - - + }; + // Add each list item to list items.forEach(addItemToFragment); return fragment; }; - Choices.prototype._triggerChange = function (value) { if (value === undefined || value === null) { return; } - this.passedElement.triggerEvent(constants_1.EVENTS.change, { value: value }); }; - Choices.prototype._selectPlaceholderChoice = function (placeholderChoice) { this._addItem({ value: placeholderChoice.value, @@ -1212,86 +983,68 @@ function () { groupId: placeholderChoice.groupId, placeholder: placeholderChoice.placeholder }); - this._triggerChange(placeholderChoice.value); }; - Choices.prototype._handleButtonAction = function (activeItems, element) { if (!activeItems || !element || !this.config.removeItems || !this.config.removeItemButton) { return; } - var itemId = element.parentNode && element.parentNode.dataset.id; var itemToRemove = itemId && activeItems.find(function (item) { return item.id === parseInt(itemId, 10); }); - if (!itemToRemove) { return; - } // Remove item associated with button - - + } + // Remove item associated with button this._removeItem(itemToRemove); - this._triggerChange(itemToRemove.value); - if (this._isSelectOneElement && this._store.placeholderChoice) { this._selectPlaceholderChoice(this._store.placeholderChoice); } }; - Choices.prototype._handleItemAction = function (activeItems, element, hasShiftKey) { var _this = this; - if (hasShiftKey === void 0) { hasShiftKey = false; } - if (!activeItems || !element || !this.config.removeItems || this._isSelectOneElement) { return; } - - var passedId = element.dataset.id; // We only want to select one item with a click + var passedId = element.dataset.id; + // We only want to select one item with a click // so we deselect any items that aren't the target // unless shift is being pressed - activeItems.forEach(function (item) { if (item.id === parseInt("".concat(passedId), 10) && !item.highlighted) { _this.highlightItem(item); } else if (!hasShiftKey && item.highlighted) { _this.unhighlightItem(item); } - }); // Focus input as without focus, a user cannot do anything with a + }); + // Focus input as without focus, a user cannot do anything with a // highlighted item - this.input.focus(); }; - Choices.prototype._handleChoiceAction = function (activeItems, element) { if (!activeItems || !element) { return; - } // If we are clicking on an option - - + } + // If we are clicking on an option var id = element.dataset.id; - var choice = id && this._store.getChoiceById(id); - if (!choice) { return; } - var passedKeyCode = activeItems[0] && activeItems[0].keyCode ? activeItems[0].keyCode : undefined; - var hasActiveDropdown = this.dropdown.isActive; // Update choice keyCode - + var hasActiveDropdown = this.dropdown.isActive; + // Update choice keyCode choice.keyCode = passedKeyCode; this.passedElement.triggerEvent(constants_1.EVENTS.choice, { choice: choice }); - if (!choice.selected && !choice.disabled) { var canAddItem = this._canAddItem(activeItems, choice.value); - if (canAddItem.response) { this._addItem({ value: choice.value, @@ -1302,70 +1055,56 @@ function () { placeholder: choice.placeholder, keyCode: choice.keyCode }); - this._triggerChange(choice.value); } } - - this.clearInput(); // We want to close the dropdown if we are dealing with a single select box - + this.clearInput(); + // We want to close the dropdown if we are dealing with a single select box if (hasActiveDropdown && this._isSelectOneElement) { this.hideDropdown(true); this.containerOuter.focus(); } }; - Choices.prototype._handleBackspace = function (activeItems) { if (!this.config.removeItems || !activeItems) { return; } - var lastItem = activeItems[activeItems.length - 1]; var hasHighlightedItems = activeItems.some(function (item) { return item.highlighted; - }); // If editing the last item is allowed and there are not other selected items, + }); + // If editing the last item is allowed and there are not other selected items, // we can edit the item value. Otherwise if we can remove items, remove all selected items - if (this.config.editItems && !hasHighlightedItems && lastItem) { this.input.value = lastItem.value; this.input.setWidth(); - this._removeItem(lastItem); - this._triggerChange(lastItem.value); } else { if (!hasHighlightedItems) { // Highlight last item if none already highlighted this.highlightItem(lastItem, false); } - this.removeHighlightedItems(true); } }; - Choices.prototype._startLoading = function () { this._store.dispatch((0, misc_1.setIsLoading)(true)); }; - Choices.prototype._stopLoading = function () { this._store.dispatch((0, misc_1.setIsLoading)(false)); }; - Choices.prototype._handleLoadingState = function (setLoading) { if (setLoading === void 0) { setLoading = true; } - var placeholderItem = this.itemList.getChild(".".concat(this.config.classNames.placeholder)); - if (setLoading) { this.disable(); this.containerOuter.addLoadingState(); - if (this._isSelectOneElement) { if (!placeholderItem) { placeholderItem = this._getTemplate('placeholder', this.config.loadingText); - if (placeholderItem) { this.itemList.append(placeholderItem); } @@ -1378,7 +1117,6 @@ function () { } else { this.enable(); this.containerOuter.removeLoadingState(); - if (this._isSelectOneElement) { if (placeholderItem) { placeholderItem.innerHTML = this._placeholderValue || ''; @@ -1388,23 +1126,21 @@ function () { } } }; - Choices.prototype._handleSearch = function (value) { if (!this.input.isFocussed) { return; } - var choices = this._store.choices; var _a = this.config, - searchFloor = _a.searchFloor, - searchChoices = _a.searchChoices; + searchFloor = _a.searchFloor, + searchChoices = _a.searchChoices; var hasUnactiveChoices = choices.some(function (option) { return !option.active; - }); // Check that we have a value to search and the input was an alphanumeric character - + }); + // Check that we have a value to search and the input was an alphanumeric character if (value !== null && typeof value !== 'undefined' && value.length >= searchFloor) { - var resultCount = searchChoices ? this._searchChoices(value) : 0; // Trigger search event - + var resultCount = searchChoices ? this._searchChoices(value) : 0; + // Trigger search event this.passedElement.triggerEvent(constants_1.EVENTS.search, { value: value, resultCount: resultCount @@ -1412,51 +1148,41 @@ function () { } else if (hasUnactiveChoices) { // Otherwise reset choices to active this._isSearching = false; - this._store.dispatch((0, choices_1.activateChoices)(true)); } }; - Choices.prototype._canAddItem = function (activeItems, value) { var canAddItem = true; var notice = typeof this.config.addItemText === 'function' ? this.config.addItemText(value) : this.config.addItemText; - if (!this._isSelectOneElement) { var isDuplicateValue = (0, utils_1.existsInArray)(activeItems, value); - if (this.config.maxItemCount > 0 && this.config.maxItemCount <= activeItems.length) { // If there is a max entry limit and we have reached that limit // don't update canAddItem = false; notice = typeof this.config.maxItemText === 'function' ? this.config.maxItemText(this.config.maxItemCount) : this.config.maxItemText; } - if (!this.config.duplicateItemsAllowed && isDuplicateValue && canAddItem) { canAddItem = false; notice = typeof this.config.uniqueItemText === 'function' ? this.config.uniqueItemText(value) : this.config.uniqueItemText; } - if (this._isTextElement && this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) { canAddItem = false; notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText; } } - return { response: canAddItem, notice: notice }; }; - Choices.prototype._searchChoices = function (value) { var newValue = typeof value === 'string' ? value.trim() : value; var currentValue = typeof this._currentValue === 'string' ? this._currentValue.trim() : this._currentValue; - if (newValue.length < 1 && newValue === "".concat(currentValue, " ")) { return 0; - } // If new value matches the desired length and is not the same as the current value with a space - - + } + // If new value matches the desired length and is not the same as the current value with a space var haystack = this._store.searchableChoices; var needle = newValue; var options = Object.assign(this.config.fuseOptions, { @@ -1465,23 +1191,19 @@ function () { }); var fuse = new fuse_js_1.default(haystack, options); var results = fuse.search(needle); // see https://github.com/krisk/Fuse/issues/303 - this._currentValue = newValue; this._highlightPosition = 0; this._isSearching = true; - this._store.dispatch((0, choices_1.filterChoices)(results)); - return results.length; }; - Choices.prototype._addEventListeners = function () { - var documentElement = document.documentElement; // capture events - can cancel event processing or propagation - + var documentElement = document.documentElement; + // capture events - can cancel event processing or propagation documentElement.addEventListener('touchend', this._onTouchEnd, true); this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true); - this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); // passive events - doesn't call `preventDefault` or `stopPropagation` - + this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); + // passive events - doesn't call `preventDefault` or `stopPropagation` documentElement.addEventListener('click', this._onClick, { passive: true }); @@ -1491,7 +1213,6 @@ function () { this.dropdown.element.addEventListener('mouseover', this._onMouseOver, { passive: true }); - if (this._isSelectOneElement) { this.containerOuter.element.addEventListener('focus', this._onFocus, { passive: true @@ -1500,7 +1221,6 @@ function () { passive: true }); } - this.input.element.addEventListener('keyup', this._onKeyUp, { passive: true }); @@ -1510,16 +1230,13 @@ function () { this.input.element.addEventListener('blur', this._onBlur, { passive: true }); - if (this.input.element.form) { this.input.element.form.addEventListener('reset', this._onFormReset, { passive: true }); } - this.input.addEventListeners(); }; - Choices.prototype._removeEventListeners = function () { var documentElement = document.documentElement; documentElement.removeEventListener('touchend', this._onTouchEnd, true); @@ -1528,23 +1245,18 @@ function () { documentElement.removeEventListener('click', this._onClick); documentElement.removeEventListener('touchmove', this._onTouchMove); this.dropdown.element.removeEventListener('mouseover', this._onMouseOver); - if (this._isSelectOneElement) { this.containerOuter.element.removeEventListener('focus', this._onFocus); this.containerOuter.element.removeEventListener('blur', this._onBlur); } - this.input.element.removeEventListener('keyup', this._onKeyUp); this.input.element.removeEventListener('focus', this._onFocus); this.input.element.removeEventListener('blur', this._onBlur); - if (this.input.element.form) { this.input.element.form.removeEventListener('reset', this._onFormReset); } - this.input.removeEventListeners(); }; - Choices.prototype._onKeyDown = function (event) { var keyCode = event.keyCode; var activeItems = this._store.activeItems; @@ -1552,72 +1264,60 @@ function () { var hasActiveDropdown = this.dropdown.isActive; var hasItems = this.itemList.hasChildren(); var keyString = String.fromCharCode(keyCode); - var wasAlphaNumericChar = /[a-zA-Z0-9-_ ]/.test(keyString); + // eslint-disable-next-line no-control-regex + var wasPrintableChar = /[^\x00-\x1F]/.test(keyString); var BACK_KEY = constants_1.KEY_CODES.BACK_KEY, - DELETE_KEY = constants_1.KEY_CODES.DELETE_KEY, - ENTER_KEY = constants_1.KEY_CODES.ENTER_KEY, - A_KEY = constants_1.KEY_CODES.A_KEY, - ESC_KEY = constants_1.KEY_CODES.ESC_KEY, - UP_KEY = constants_1.KEY_CODES.UP_KEY, - DOWN_KEY = constants_1.KEY_CODES.DOWN_KEY, - PAGE_UP_KEY = constants_1.KEY_CODES.PAGE_UP_KEY, - PAGE_DOWN_KEY = constants_1.KEY_CODES.PAGE_DOWN_KEY; - - if (!this._isTextElement && !hasActiveDropdown && wasAlphaNumericChar) { + DELETE_KEY = constants_1.KEY_CODES.DELETE_KEY, + ENTER_KEY = constants_1.KEY_CODES.ENTER_KEY, + A_KEY = constants_1.KEY_CODES.A_KEY, + ESC_KEY = constants_1.KEY_CODES.ESC_KEY, + UP_KEY = constants_1.KEY_CODES.UP_KEY, + DOWN_KEY = constants_1.KEY_CODES.DOWN_KEY, + PAGE_UP_KEY = constants_1.KEY_CODES.PAGE_UP_KEY, + PAGE_DOWN_KEY = constants_1.KEY_CODES.PAGE_DOWN_KEY; + if (!this._isTextElement && !hasActiveDropdown && wasPrintableChar) { this.showDropdown(); - if (!this.input.isFocussed) { /* We update the input value with the pressed key as the input was not focussed at the time of key press therefore does not have the value of the key. */ - this.input.value += keyString.toLowerCase(); + this.input.value += event.key.toLowerCase(); } } - switch (keyCode) { case A_KEY: return this._onSelectKey(event, hasItems); - case ENTER_KEY: return this._onEnterKey(event, activeItems, hasActiveDropdown); - case ESC_KEY: return this._onEscapeKey(hasActiveDropdown); - case UP_KEY: case PAGE_UP_KEY: case DOWN_KEY: case PAGE_DOWN_KEY: return this._onDirectionKey(event, hasActiveDropdown); - case DELETE_KEY: case BACK_KEY: return this._onDeleteKey(event, activeItems, hasFocusedInput); - default: } }; - Choices.prototype._onKeyUp = function (_a) { var target = _a.target, - keyCode = _a.keyCode; + keyCode = _a.keyCode; var value = this.input.value; var activeItems = this._store.activeItems; - var canAddItem = this._canAddItem(activeItems, value); - var backKey = constants_1.KEY_CODES.BACK_KEY, - deleteKey = constants_1.KEY_CODES.DELETE_KEY; // We are typing into a text input and have a value, we want to show a dropdown + deleteKey = constants_1.KEY_CODES.DELETE_KEY; + // We are typing into a text input and have a value, we want to show a dropdown // notice. Otherwise hide the dropdown - if (this._isTextElement) { var canShowDropdownNotice = canAddItem.notice && value; - if (canShowDropdownNotice) { var dropdownItem = this._getTemplate('notice', canAddItem.notice); - this.dropdown.element.innerHTML = dropdownItem.outerHTML; this.showDropdown(true); } else { @@ -1628,66 +1328,50 @@ function () { var userHasRemovedValue = wasRemovalKeyCode && target && !target.value; var canReactivateChoices = !this._isTextElement && this._isSearching; var canSearch = this._canSearch && canAddItem.response; - if (userHasRemovedValue && canReactivateChoices) { this._isSearching = false; - this._store.dispatch((0, choices_1.activateChoices)(true)); } else if (canSearch) { this._handleSearch(this.input.rawValue); } } - this._canSearch = this.config.searchEnabled; }; - Choices.prototype._onSelectKey = function (event, hasItems) { var ctrlKey = event.ctrlKey, - metaKey = event.metaKey; - var hasCtrlDownKeyPressed = ctrlKey || metaKey; // If CTRL + A or CMD + A have been pressed and there are items to select - + metaKey = event.metaKey; + var hasCtrlDownKeyPressed = ctrlKey || metaKey; + // If CTRL + A or CMD + A have been pressed and there are items to select if (hasCtrlDownKeyPressed && hasItems) { this._canSearch = false; var shouldHightlightAll = this.config.removeItems && !this.input.value && this.input.element === document.activeElement; - if (shouldHightlightAll) { this.highlightAll(); } } }; - Choices.prototype._onEnterKey = function (event, activeItems, hasActiveDropdown) { var target = event.target; var enterKey = constants_1.KEY_CODES.ENTER_KEY; var targetWasButton = target && target.hasAttribute('data-button'); - if (this._isTextElement && target && target.value) { var value = this.input.value; - var canAddItem = this._canAddItem(activeItems, value); - if (canAddItem.response) { this.hideDropdown(true); - this._addItem({ value: value }); - this._triggerChange(value); - this.clearInput(); } } - if (targetWasButton) { this._handleButtonAction(activeItems, target); - event.preventDefault(); } - if (hasActiveDropdown) { var highlightedChoice = this.dropdown.getChild(".".concat(this.config.classNames.highlightedState)); - if (highlightedChoice) { // add enter keyCode value if (activeItems[0]) { @@ -1696,28 +1380,25 @@ function () { this._handleChoiceAction(activeItems, highlightedChoice); } - event.preventDefault(); } else if (this._isSelectOneElement) { this.showDropdown(); event.preventDefault(); } }; - Choices.prototype._onEscapeKey = function (hasActiveDropdown) { if (hasActiveDropdown) { this.hideDropdown(true); this.containerOuter.focus(); } }; - Choices.prototype._onDirectionKey = function (event, hasActiveDropdown) { var keyCode = event.keyCode, - metaKey = event.metaKey; + metaKey = event.metaKey; var downKey = constants_1.KEY_CODES.DOWN_KEY, - pageUpKey = constants_1.KEY_CODES.PAGE_UP_KEY, - pageDownKey = constants_1.KEY_CODES.PAGE_DOWN_KEY; // If up or down key is pressed, traverse through options - + pageUpKey = constants_1.KEY_CODES.PAGE_UP_KEY, + pageDownKey = constants_1.KEY_CODES.PAGE_DOWN_KEY; + // If up or down key is pressed, traverse through options if (hasActiveDropdown || this._isSelectOneElement) { this.showDropdown(); this._canSearch = false; @@ -1725,7 +1406,6 @@ function () { var skipKey = metaKey || keyCode === pageDownKey || keyCode === pageUpKey; var selectableChoiceIdentifier = '[data-choice-selectable]'; var nextEl = void 0; - if (skipKey) { if (directionInt > 0) { nextEl = this.dropdown.element.querySelector("".concat(selectableChoiceIdentifier, ":last-of-type")); @@ -1734,98 +1414,78 @@ function () { } } else { var currentEl = this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState)); - if (currentEl) { nextEl = (0, utils_1.getAdjacentEl)(currentEl, selectableChoiceIdentifier, directionInt); } else { nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier); } } - if (nextEl) { // We prevent default to stop the cursor moving // when pressing the arrow if (!(0, utils_1.isScrolledIntoView)(nextEl, this.choiceList.element, directionInt)) { this.choiceList.scrollToChildElement(nextEl, directionInt); } - this._highlightChoice(nextEl); - } // Prevent default to maintain cursor position whilst + } + // Prevent default to maintain cursor position whilst // traversing dropdown options - - event.preventDefault(); } }; - Choices.prototype._onDeleteKey = function (event, activeItems, hasFocusedInput) { - var target = event.target; // If backspace or delete key is pressed and the input has no value - + var target = event.target; + // If backspace or delete key is pressed and the input has no value if (!this._isSelectOneElement && !target.value && hasFocusedInput) { this._handleBackspace(activeItems); - event.preventDefault(); } }; - Choices.prototype._onTouchMove = function () { if (this._wasTap) { this._wasTap = false; } }; - Choices.prototype._onTouchEnd = function (event) { var target = (event || event.touches[0]).target; var touchWasWithinContainer = this._wasTap && this.containerOuter.element.contains(target); - if (touchWasWithinContainer) { var containerWasExactTarget = target === this.containerOuter.element || target === this.containerInner.element; - if (containerWasExactTarget) { if (this._isTextElement) { this.input.focus(); } else if (this._isSelectMultipleElement) { this.showDropdown(); } - } // Prevents focus event firing - - + } + // Prevents focus event firing event.stopPropagation(); } - this._wasTap = true; }; /** * Handles mousedown event in capture mode for containetOuter.element */ - - Choices.prototype._onMouseDown = function (event) { var target = event.target; - if (!(target instanceof HTMLElement)) { return; - } // If we have our mouse down on the scrollbar and are on IE11... - - + } + // If we have our mouse down on the scrollbar and are on IE11... if (IS_IE11 && this.choiceList.element.contains(target)) { // check if click was on a scrollbar area var firstChoice = this.choiceList.element.firstElementChild; var isOnScrollbar = this._direction === 'ltr' ? event.offsetX >= firstChoice.offsetWidth : event.offsetX < firstChoice.offsetLeft; this._isScrollingOnIe = isOnScrollbar; } - if (target === this.input.element) { return; } - var item = target.closest('[data-button],[data-item],[data-choice]'); - if (item instanceof HTMLElement) { var hasShiftKey = event.shiftKey; var activeItems = this._store.activeItems; var dataset = item.dataset; - if ('button' in dataset) { this._handleButtonAction(activeItems, item); } else if ('item' in dataset) { @@ -1834,27 +1494,21 @@ function () { this._handleChoiceAction(activeItems, item); } } - event.preventDefault(); }; /** * Handles mouseover event over this.dropdown * @param {MouseEvent} event */ - - Choices.prototype._onMouseOver = function (_a) { var target = _a.target; - if (target instanceof HTMLElement && 'choice' in target.dataset) { this._highlightChoice(target); } }; - Choices.prototype._onClick = function (_a) { var target = _a.target; var clickWasWithinContainer = this.containerOuter.element.contains(target); - if (clickWasWithinContainer) { if (!this.dropdown.isActive && !this.containerOuter.isDisabled) { if (this._isTextElement) { @@ -1870,58 +1524,45 @@ function () { } } else { var hasHighlightedItems = this._store.highlightedActiveItems.length > 0; - if (hasHighlightedItems) { this.unhighlightAll(); } - this.containerOuter.removeFocusState(); this.hideDropdown(true); } }; - Choices.prototype._onFocus = function (_a) { var _b; - var _this = this; - var target = _a.target; var focusWasWithinContainer = target && this.containerOuter.element.contains(target); - if (!focusWasWithinContainer) { return; } - var focusActions = (_b = {}, _b[constants_1.TEXT_TYPE] = function () { if (target === _this.input.element) { _this.containerOuter.addFocusState(); } }, _b[constants_1.SELECT_ONE_TYPE] = function () { _this.containerOuter.addFocusState(); - if (target === _this.input.element) { _this.showDropdown(true); } }, _b[constants_1.SELECT_MULTIPLE_TYPE] = function () { if (target === _this.input.element) { - _this.showDropdown(true); // If element is a select box, the focused element is the container and the dropdown + _this.showDropdown(true); + // If element is a select box, the focused element is the container and the dropdown // isn't already open, focus and show dropdown - - _this.containerOuter.addFocusState(); } }, _b); focusActions[this.passedElement.element.type](); }; - Choices.prototype._onBlur = function (_a) { var _b; - var _this = this; - var target = _a.target; var blurWasWithinContainer = target && this.containerOuter.element.contains(target); - if (blurWasWithinContainer && !this._isScrollingOnIe) { var activeItems = this._store.activeItems; var hasHighlightedItems_1 = activeItems.some(function (item) { @@ -1930,25 +1571,20 @@ function () { var blurActions = (_b = {}, _b[constants_1.TEXT_TYPE] = function () { if (target === _this.input.element) { _this.containerOuter.removeFocusState(); - if (hasHighlightedItems_1) { _this.unhighlightAll(); } - _this.hideDropdown(true); } }, _b[constants_1.SELECT_ONE_TYPE] = function () { _this.containerOuter.removeFocusState(); - if (target === _this.input.element || target === _this.containerOuter.element && !_this._canSearch) { _this.hideDropdown(true); } }, _b[constants_1.SELECT_MULTIPLE_TYPE] = function () { if (target === _this.input.element) { _this.containerOuter.removeFocusState(); - _this.hideDropdown(true); - if (hasHighlightedItems_1) { _this.unhighlightAll(); } @@ -1963,32 +1599,25 @@ function () { this.input.element.focus(); } }; - Choices.prototype._onFormReset = function () { this._store.dispatch((0, misc_1.resetTo)(this._initialState)); }; - Choices.prototype._highlightChoice = function (el) { var _this = this; - if (el === void 0) { el = null; } - var choices = Array.from(this.dropdown.element.querySelectorAll('[data-choice-selectable]')); - if (!choices.length) { return; } - var passedEl = el; - var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))); // Remove any highlighted choices - + var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))); + // Remove any highlighted choices highlightedChoices.forEach(function (choice) { choice.classList.remove(_this.config.classNames.highlightedState); choice.setAttribute('aria-selected', 'false'); }); - if (passedEl) { this._highlightPosition = choices.indexOf(passedEl); } else { @@ -2000,18 +1629,15 @@ function () { // Otherwise highlight the option before passedEl = choices[choices.length - 1]; } - if (!passedEl) { passedEl = choices[0]; } } - passedEl.classList.add(this.config.classNames.highlightedState); passedEl.setAttribute('aria-selected', 'true'); this.passedElement.triggerEvent(constants_1.EVENTS.highlightChoice, { el: passedEl }); - if (this.dropdown.isActive) { // IE11 ignores aria-label and blocks virtual keyboard // if aria-activedescendant is set without a dropdown @@ -2019,37 +1645,34 @@ function () { this.containerOuter.setActiveDescendant(passedEl.id); } }; - Choices.prototype._addItem = function (_a) { var value = _a.value, - _b = _a.label, - label = _b === void 0 ? null : _b, - _c = _a.choiceId, - choiceId = _c === void 0 ? -1 : _c, - _d = _a.groupId, - groupId = _d === void 0 ? -1 : _d, - _e = _a.customProperties, - customProperties = _e === void 0 ? {} : _e, - _f = _a.placeholder, - placeholder = _f === void 0 ? false : _f, - _g = _a.keyCode, - keyCode = _g === void 0 ? -1 : _g; + _b = _a.label, + label = _b === void 0 ? null : _b, + _c = _a.choiceId, + choiceId = _c === void 0 ? -1 : _c, + _d = _a.groupId, + groupId = _d === void 0 ? -1 : _d, + _e = _a.customProperties, + customProperties = _e === void 0 ? {} : _e, + _f = _a.placeholder, + placeholder = _f === void 0 ? false : _f, + _g = _a.keyCode, + keyCode = _g === void 0 ? -1 : _g; var passedValue = typeof value === 'string' ? value.trim() : value; var items = this._store.items; var passedLabel = label || passedValue; var passedOptionId = choiceId || -1; var group = groupId >= 0 ? this._store.getGroupById(groupId) : null; - var id = items ? items.length + 1 : 1; // If a prepended value has been passed, prepend it - + var id = items ? items.length + 1 : 1; + // If a prepended value has been passed, prepend it if (this.config.prependValue) { passedValue = this.config.prependValue + passedValue.toString(); - } // If an appended value has been passed, append it - - + } + // If an appended value has been passed, append it if (this.config.appendValue) { passedValue += this.config.appendValue.toString(); } - this._store.dispatch((0, items_1.addItem)({ value: passedValue, label: passedLabel, @@ -2060,12 +1683,10 @@ function () { placeholder: placeholder, keyCode: keyCode })); - if (this._isSelectOneElement) { this.removeActiveItems(id); - } // Trigger change event - - + } + // Trigger change event this.passedElement.triggerEvent(constants_1.EVENTS.addItem, { id: id, value: passedValue, @@ -2075,22 +1696,18 @@ function () { keyCode: keyCode }); }; - Choices.prototype._removeItem = function (item) { var id = item.id, - value = item.value, - label = item.label, - customProperties = item.customProperties, - choiceId = item.choiceId, - groupId = item.groupId; + value = item.value, + label = item.label, + customProperties = item.customProperties, + choiceId = item.choiceId, + groupId = item.groupId; var group = groupId && groupId >= 0 ? this._store.getGroupById(groupId) : null; - if (!id || !choiceId) { return; } - this._store.dispatch((0, items_1.removeItem)(id, choiceId)); - this.passedElement.triggerEvent(constants_1.EVENTS.removeItem, { id: id, value: value, @@ -2099,34 +1716,30 @@ function () { groupValue: group && group.value ? group.value : null }); }; - Choices.prototype._addChoice = function (_a) { var value = _a.value, - _b = _a.label, - label = _b === void 0 ? null : _b, - _c = _a.isSelected, - isSelected = _c === void 0 ? false : _c, - _d = _a.isDisabled, - isDisabled = _d === void 0 ? false : _d, - _e = _a.groupId, - groupId = _e === void 0 ? -1 : _e, - _f = _a.customProperties, - customProperties = _f === void 0 ? {} : _f, - _g = _a.placeholder, - placeholder = _g === void 0 ? false : _g, - _h = _a.keyCode, - keyCode = _h === void 0 ? -1 : _h; - + _b = _a.label, + label = _b === void 0 ? null : _b, + _c = _a.isSelected, + isSelected = _c === void 0 ? false : _c, + _d = _a.isDisabled, + isDisabled = _d === void 0 ? false : _d, + _e = _a.groupId, + groupId = _e === void 0 ? -1 : _e, + _f = _a.customProperties, + customProperties = _f === void 0 ? {} : _f, + _g = _a.placeholder, + placeholder = _g === void 0 ? false : _g, + _h = _a.keyCode, + keyCode = _h === void 0 ? -1 : _h; if (typeof value === 'undefined' || value === null) { return; - } // Generate unique id - - + } + // Generate unique id var choices = this._store.choices; var choiceLabel = label || value; var choiceId = choices ? choices.length + 1 : 1; var choiceElementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(choiceId); - this._store.dispatch((0, choices_1.addChoice)({ id: choiceId, groupId: groupId, @@ -2138,7 +1751,6 @@ function () { placeholder: placeholder, keyCode: keyCode })); - if (isSelected) { this._addItem({ value: value, @@ -2150,20 +1762,17 @@ function () { }); } }; - Choices.prototype._addGroup = function (_a) { var _this = this; - var group = _a.group, - id = _a.id, - _b = _a.valueKey, - valueKey = _b === void 0 ? 'value' : _b, - _c = _a.labelKey, - labelKey = _c === void 0 ? 'label' : _c; + id = _a.id, + _b = _a.valueKey, + valueKey = _b === void 0 ? 'value' : _b, + _c = _a.labelKey, + labelKey = _c === void 0 ? 'label' : _c; var groupChoices = (0, utils_1.isType)('Object', group) ? group.choices : Array.from(group.getElementsByTagName('OPTION')); var groupId = id || Math.floor(new Date().valueOf() * Math.random()); var isDisabled = group.disabled ? group.disabled : false; - if (groupChoices) { this._store.dispatch((0, groups_1.addGroup)({ value: group.label, @@ -2171,10 +1780,8 @@ function () { active: true, disabled: isDisabled })); - var addGroupChoices = function (choice) { var isOptDisabled = choice.disabled || choice.parentNode && choice.parentNode.disabled; - _this._addChoice({ value: choice[valueKey], label: (0, utils_1.isType)('Object', choice) ? choice[labelKey] : choice.innerHTML, @@ -2185,7 +1792,6 @@ function () { placeholder: choice.placeholder }); }; - groupChoices.forEach(addGroupChoices); } else { this._store.dispatch((0, groups_1.addGroup)({ @@ -2196,30 +1802,22 @@ function () { })); } }; - Choices.prototype._getTemplate = function (template) { var _a; - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return (_a = this._templates[template]).call.apply(_a, __spreadArray([this, this.config], args, false)); }; - Choices.prototype._createTemplates = function () { var callbackOnCreateTemplates = this.config.callbackOnCreateTemplates; var userTemplates = {}; - if (callbackOnCreateTemplates && typeof callbackOnCreateTemplates === 'function') { userTemplates = callbackOnCreateTemplates.call(this, utils_1.strToEl); } - this._templates = (0, deepmerge_1.default)(templates_1.default, userTemplates); }; - Choices.prototype._createElements = function () { this.containerOuter = new components_1.Container({ element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type, this.config.labelId), @@ -2251,62 +1849,49 @@ function () { type: this.passedElement.element.type }); }; - Choices.prototype._createStructure = function () { // Hide original element - this.passedElement.conceal(); // Wrap input in container preserving DOM ordering - - this.containerInner.wrap(this.passedElement.element); // Wrapper inner container with outer container - + this.passedElement.conceal(); + // Wrap input in container preserving DOM ordering + this.containerInner.wrap(this.passedElement.element); + // Wrapper inner container with outer container this.containerOuter.wrap(this.containerInner.element); - if (this._isSelectOneElement) { this.input.placeholder = this.config.searchPlaceholderValue || ''; } else if (this._placeholderValue) { this.input.placeholder = this._placeholderValue; this.input.setWidth(); } - this.containerOuter.element.appendChild(this.containerInner.element); this.containerOuter.element.appendChild(this.dropdown.element); this.containerInner.element.appendChild(this.itemList.element); - if (!this._isTextElement) { this.dropdown.element.appendChild(this.choiceList.element); } - if (!this._isSelectOneElement) { this.containerInner.element.appendChild(this.input.element); } else if (this.config.searchEnabled) { this.dropdown.element.insertBefore(this.input.element, this.dropdown.element.firstChild); } - if (this._isSelectElement) { this._highlightPosition = 0; this._isSearching = false; - this._startLoading(); - if (this._presetGroups.length) { this._addPredefinedGroups(this._presetGroups); } else { this._addPredefinedChoices(this._presetChoices); } - this._stopLoading(); } - if (this._isTextElement) { this._addPredefinedItems(this._presetItems); } }; - Choices.prototype._addPredefinedGroups = function (groups) { - var _this = this; // If we have a placeholder option - - + var _this = this; + // If we have a placeholder option var placeholderChoice = this.passedElement.placeholderOption; - if (placeholderChoice && placeholderChoice.parentNode && placeholderChoice.parentNode.tagName === 'SELECT') { this._addChoice({ value: placeholderChoice.value, @@ -2316,7 +1901,6 @@ function () { placeholder: true }); } - groups.forEach(function (group) { return _this._addGroup({ group: group, @@ -2324,15 +1908,12 @@ function () { }); }); }; - Choices.prototype._addPredefinedChoices = function (choices) { - var _this = this; // If sorting is enabled or the user is searching, filter choices - - + var _this = this; + // If sorting is enabled or the user is searching, filter choices if (this.config.shouldSort) { choices.sort(this.config.sorter); } - var hasSelectedChoice = choices.some(function (choice) { return choice.selected; }); @@ -2341,11 +1922,10 @@ function () { }); choices.forEach(function (choice, index) { var _a = choice.value, - value = _a === void 0 ? '' : _a, - label = choice.label, - customProperties = choice.customProperties, - placeholder = choice.placeholder; - + value = _a === void 0 ? '' : _a, + label = choice.label, + customProperties = choice.customProperties, + placeholder = choice.placeholder; if (_this._isSelectElement) { // If the choice is actually a group if (choice.choices) { @@ -2363,7 +1943,6 @@ function () { var shouldPreselect = _this._isSelectOneElement && !hasSelectedChoice && index === firstEnabledChoiceIndex; var isSelected = shouldPreselect ? true : choice.selected; var isDisabled = choice.disabled; - _this._addChoice({ value: value, label: label, @@ -2385,10 +1964,8 @@ function () { } }); }; - Choices.prototype._addPredefinedItems = function (items) { var _this = this; - items.forEach(function (item) { if (typeof item === 'object' && item.value) { _this._addItem({ @@ -2399,7 +1976,6 @@ function () { placeholder: item.placeholder }); } - if (typeof item === 'string') { _this._addItem({ value: item @@ -2407,19 +1983,16 @@ function () { } }); }; - Choices.prototype._setChoiceOrItem = function (item) { var _this = this; - var itemType = (0, utils_1.getType)(item).toLowerCase(); var handleType = { object: function () { if (!item.value) { return; - } // If we are dealing with a select input, we need to create an option first + } + // If we are dealing with a select input, we need to create an option first // that is then selected. For text inputs we can just add items normally. - - if (!_this._isTextElement) { _this._addChoice({ value: item.value, @@ -2456,16 +2029,13 @@ function () { }; handleType[itemType](); }; - Choices.prototype._findAndSelectChoiceByValue = function (value) { var _this = this; - - var choices = this._store.choices; // Check 'value' property exists and the choice isn't already selected - + var choices = this._store.choices; + // Check 'value' property exists and the choice isn't already selected var foundChoice = choices.find(function (choice) { return _this.config.valueComparer(choice.value, value); }); - if (foundChoice && !foundChoice.selected) { this._addItem({ value: foundChoice.value, @@ -2478,34 +2048,27 @@ function () { }); } }; - Choices.prototype._generatePlaceholderValue = function () { if (this._isSelectElement && this.passedElement.placeholderOption) { var placeholderOption = this.passedElement.placeholderOption; return placeholderOption ? placeholderOption.text : null; } - var _a = this.config, - placeholder = _a.placeholder, - placeholderValue = _a.placeholderValue; + placeholder = _a.placeholder, + placeholderValue = _a.placeholderValue; var dataset = this.passedElement.element.dataset; - if (placeholder) { if (placeholderValue) { return placeholderValue; } - if (dataset.placeholder) { return dataset.placeholder; } } - return null; }; - return Choices; }(); - exports["default"] = Choices; /***/ }), @@ -2518,19 +2081,14 @@ exports["default"] = Choices; Object.defineProperty(exports, "__esModule", ({ value: true })); - var utils_1 = __webpack_require__(799); - var constants_1 = __webpack_require__(883); - -var Container = -/** @class */ -function () { +var Container = /** @class */function () { function Container(_a) { var element = _a.element, - type = _a.type, - classNames = _a.classNames, - position = _a.position; + type = _a.type, + classNames = _a.classNames, + position = _a.position; this.element = element; this.classNames = classNames; this.type = type; @@ -2543,12 +2101,10 @@ function () { this._onFocus = this._onFocus.bind(this); this._onBlur = this._onBlur.bind(this); } - Container.prototype.addEventListeners = function () { this.element.addEventListener('focus', this._onFocus); this.element.addEventListener('blur', this._onBlur); }; - Container.prototype.removeEventListeners = function () { this.element.removeEventListener('focus', this._onFocus); this.element.removeEventListener('blur', this._onBlur); @@ -2557,129 +2113,102 @@ function () { * Determine whether container should be flipped based on passed * dropdown position */ - - Container.prototype.shouldFlip = function (dropdownPos) { if (typeof dropdownPos !== 'number') { return false; - } // If flip is enabled and the dropdown bottom position is + } + // If flip is enabled and the dropdown bottom position is // greater than the window height flip the dropdown. - - var shouldFlip = false; - if (this.position === 'auto') { shouldFlip = !window.matchMedia("(min-height: ".concat(dropdownPos + 1, "px)")).matches; } else if (this.position === 'top') { shouldFlip = true; } - return shouldFlip; }; - Container.prototype.setActiveDescendant = function (activeDescendantID) { this.element.setAttribute('aria-activedescendant', activeDescendantID); }; - Container.prototype.removeActiveDescendant = function () { this.element.removeAttribute('aria-activedescendant'); }; - Container.prototype.open = function (dropdownPos) { this.element.classList.add(this.classNames.openState); this.element.setAttribute('aria-expanded', 'true'); this.isOpen = true; - if (this.shouldFlip(dropdownPos)) { this.element.classList.add(this.classNames.flippedState); this.isFlipped = true; } }; - Container.prototype.close = function () { this.element.classList.remove(this.classNames.openState); this.element.setAttribute('aria-expanded', 'false'); this.removeActiveDescendant(); - this.isOpen = false; // A dropdown flips if it does not have space within the page - + this.isOpen = false; + // A dropdown flips if it does not have space within the page if (this.isFlipped) { this.element.classList.remove(this.classNames.flippedState); this.isFlipped = false; } }; - Container.prototype.focus = function () { if (!this.isFocussed) { this.element.focus(); } }; - Container.prototype.addFocusState = function () { this.element.classList.add(this.classNames.focusState); }; - Container.prototype.removeFocusState = function () { this.element.classList.remove(this.classNames.focusState); }; - Container.prototype.enable = function () { this.element.classList.remove(this.classNames.disabledState); this.element.removeAttribute('aria-disabled'); - if (this.type === constants_1.SELECT_ONE_TYPE) { this.element.setAttribute('tabindex', '0'); } - this.isDisabled = false; }; - Container.prototype.disable = function () { this.element.classList.add(this.classNames.disabledState); this.element.setAttribute('aria-disabled', 'true'); - if (this.type === constants_1.SELECT_ONE_TYPE) { this.element.setAttribute('tabindex', '-1'); } - this.isDisabled = true; }; - Container.prototype.wrap = function (element) { (0, utils_1.wrap)(element, this.element); }; - Container.prototype.unwrap = function (element) { if (this.element.parentNode) { // Move passed element outside this element - this.element.parentNode.insertBefore(element, this.element); // Remove this element - + this.element.parentNode.insertBefore(element, this.element); + // Remove this element this.element.parentNode.removeChild(this.element); } }; - Container.prototype.addLoadingState = function () { this.element.classList.add(this.classNames.loadingState); this.element.setAttribute('aria-busy', 'true'); this.isLoading = true; }; - Container.prototype.removeLoadingState = function () { this.element.classList.remove(this.classNames.loadingState); this.element.removeAttribute('aria-busy'); this.isLoading = false; }; - Container.prototype._onFocus = function () { this.isFocussed = true; }; - Container.prototype._onBlur = function () { this.isFocussed = false; }; - return Container; }(); - exports["default"] = Container; /***/ }), @@ -2692,20 +2221,16 @@ exports["default"] = Container; Object.defineProperty(exports, "__esModule", ({ value: true })); - -var Dropdown = -/** @class */ -function () { +var Dropdown = /** @class */function () { function Dropdown(_a) { var element = _a.element, - type = _a.type, - classNames = _a.classNames; + type = _a.type, + classNames = _a.classNames; this.element = element; this.classNames = classNames; this.type = type; this.isActive = false; } - Object.defineProperty(Dropdown.prototype, "distanceFromTopWindow", { /** * Bottom position of dropdown in viewport coordinates @@ -2716,15 +2241,12 @@ function () { enumerable: false, configurable: true }); - Dropdown.prototype.getChild = function (selector) { return this.element.querySelector(selector); }; /** * Show dropdown to user by adding active state class */ - - Dropdown.prototype.show = function () { this.element.classList.add(this.classNames.activeState); this.element.setAttribute('aria-expanded', 'true'); @@ -2734,18 +2256,14 @@ function () { /** * Hide dropdown from user */ - - Dropdown.prototype.hide = function () { this.element.classList.remove(this.classNames.activeState); this.element.setAttribute('aria-expanded', 'false'); this.isActive = false; return this; }; - return Dropdown; }(); - exports["default"] = Dropdown; /***/ }), @@ -2760,34 +2278,21 @@ var __importDefault = this && this.__importDefault || function (mod) { "default": mod }; }; - Object.defineProperty(exports, "__esModule", ({ value: true })); exports.WrappedSelect = exports.WrappedInput = exports.List = exports.Input = exports.Container = exports.Dropdown = void 0; - var dropdown_1 = __importDefault(__webpack_require__(217)); - exports.Dropdown = dropdown_1.default; - var container_1 = __importDefault(__webpack_require__(613)); - exports.Container = container_1.default; - var input_1 = __importDefault(__webpack_require__(11)); - exports.Input = input_1.default; - var list_1 = __importDefault(__webpack_require__(624)); - exports.List = list_1.default; - var wrapped_input_1 = __importDefault(__webpack_require__(541)); - exports.WrappedInput = wrapped_input_1.default; - var wrapped_select_1 = __importDefault(__webpack_require__(982)); - exports.WrappedSelect = wrapped_select_1.default; /***/ }), @@ -2800,19 +2305,14 @@ exports.WrappedSelect = wrapped_select_1.default; Object.defineProperty(exports, "__esModule", ({ value: true })); - var utils_1 = __webpack_require__(799); - var constants_1 = __webpack_require__(883); - -var Input = -/** @class */ -function () { +var Input = /** @class */function () { function Input(_a) { var element = _a.element, - type = _a.type, - classNames = _a.classNames, - preventPaste = _a.preventPaste; + type = _a.type, + classNames = _a.classNames, + preventPaste = _a.preventPaste; this.element = element; this.type = type; this.classNames = classNames; @@ -2824,7 +2324,6 @@ function () { this._onFocus = this._onFocus.bind(this); this._onBlur = this._onBlur.bind(this); } - Object.defineProperty(Input.prototype, "placeholder", { set: function (placeholder) { this.element.placeholder = placeholder; @@ -2849,7 +2348,6 @@ function () { enumerable: false, configurable: true }); - Input.prototype.addEventListeners = function () { this.element.addEventListener('paste', this._onPaste); this.element.addEventListener('input', this._onInput, { @@ -2862,98 +2360,79 @@ function () { passive: true }); }; - Input.prototype.removeEventListeners = function () { this.element.removeEventListener('input', this._onInput); this.element.removeEventListener('paste', this._onPaste); this.element.removeEventListener('focus', this._onFocus); this.element.removeEventListener('blur', this._onBlur); }; - Input.prototype.enable = function () { this.element.removeAttribute('disabled'); this.isDisabled = false; }; - Input.prototype.disable = function () { this.element.setAttribute('disabled', ''); this.isDisabled = true; }; - Input.prototype.focus = function () { if (!this.isFocussed) { this.element.focus(); } }; - Input.prototype.blur = function () { if (this.isFocussed) { this.element.blur(); } }; - Input.prototype.clear = function (setWidth) { if (setWidth === void 0) { setWidth = true; } - if (this.element.value) { this.element.value = ''; } - if (setWidth) { this.setWidth(); } - return this; }; /** * Set the correct input width based on placeholder * value or input value */ - - Input.prototype.setWidth = function () { // Resize input to contents or placeholder var _a = this.element, - style = _a.style, - value = _a.value, - placeholder = _a.placeholder; + style = _a.style, + value = _a.value, + placeholder = _a.placeholder; style.minWidth = "".concat(placeholder.length + 1, "ch"); style.width = "".concat(value.length + 1, "ch"); }; - Input.prototype.setActiveDescendant = function (activeDescendantID) { this.element.setAttribute('aria-activedescendant', activeDescendantID); }; - Input.prototype.removeActiveDescendant = function () { this.element.removeAttribute('aria-activedescendant'); }; - Input.prototype._onInput = function () { if (this.type !== constants_1.SELECT_ONE_TYPE) { this.setWidth(); } }; - Input.prototype._onPaste = function (event) { if (this.preventPaste) { event.preventDefault(); } }; - Input.prototype._onFocus = function () { this.isFocussed = true; }; - Input.prototype._onBlur = function () { this.isFocussed = false; }; - return Input; }(); - exports["default"] = Input; /***/ }), @@ -2966,102 +2445,80 @@ exports["default"] = Input; Object.defineProperty(exports, "__esModule", ({ value: true })); - var constants_1 = __webpack_require__(883); - -var List = -/** @class */ -function () { +var List = /** @class */function () { function List(_a) { var element = _a.element; this.element = element; this.scrollPos = this.element.scrollTop; this.height = this.element.offsetHeight; } - List.prototype.clear = function () { this.element.innerHTML = ''; }; - List.prototype.append = function (node) { this.element.appendChild(node); }; - List.prototype.getChild = function (selector) { return this.element.querySelector(selector); }; - List.prototype.hasChildren = function () { return this.element.hasChildNodes(); }; - List.prototype.scrollToTop = function () { this.element.scrollTop = 0; }; - List.prototype.scrollToChildElement = function (element, direction) { var _this = this; - if (!element) { return; } - - var listHeight = this.element.offsetHeight; // Scroll position of dropdown - + var listHeight = this.element.offsetHeight; + // Scroll position of dropdown var listScrollPosition = this.element.scrollTop + listHeight; - var elementHeight = element.offsetHeight; // Distance from bottom of element to top of parent - - var elementPos = element.offsetTop + elementHeight; // Difference between the element and scroll position - + var elementHeight = element.offsetHeight; + // Distance from bottom of element to top of parent + var elementPos = element.offsetTop + elementHeight; + // Difference between the element and scroll position var destination = direction > 0 ? this.element.scrollTop + elementPos - listScrollPosition : element.offsetTop; requestAnimationFrame(function () { _this._animateScroll(destination, direction); }); }; - List.prototype._scrollDown = function (scrollPos, strength, destination) { var easing = (destination - scrollPos) / strength; var distance = easing > 1 ? easing : 1; this.element.scrollTop = scrollPos + distance; }; - List.prototype._scrollUp = function (scrollPos, strength, destination) { var easing = (scrollPos - destination) / strength; var distance = easing > 1 ? easing : 1; this.element.scrollTop = scrollPos - distance; }; - List.prototype._animateScroll = function (destination, direction) { var _this = this; - var strength = constants_1.SCROLLING_SPEED; var choiceListScrollTop = this.element.scrollTop; var continueAnimation = false; - if (direction > 0) { this._scrollDown(choiceListScrollTop, strength, destination); - if (choiceListScrollTop < destination) { continueAnimation = true; } } else { this._scrollUp(choiceListScrollTop, strength, destination); - if (choiceListScrollTop > destination) { continueAnimation = true; } } - if (continueAnimation) { requestAnimationFrame(function () { _this._animateScroll(destination, direction); }); } }; - return List; }(); - exports["default"] = List; /***/ }), @@ -3074,25 +2531,18 @@ exports["default"] = List; Object.defineProperty(exports, "__esModule", ({ value: true })); - var utils_1 = __webpack_require__(799); - -var WrappedElement = -/** @class */ -function () { +var WrappedElement = /** @class */function () { function WrappedElement(_a) { var element = _a.element, - classNames = _a.classNames; + classNames = _a.classNames; this.element = element; this.classNames = classNames; - if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLSelectElement)) { throw new TypeError('Invalid element passed'); } - this.isDisabled = false; } - Object.defineProperty(WrappedElement.prototype, "isActive", { get: function () { return this.element.dataset.choice === 'active'; @@ -3118,41 +2568,35 @@ function () { enumerable: false, configurable: true }); - WrappedElement.prototype.conceal = function () { // Hide passed input this.element.classList.add(this.classNames.input); - this.element.hidden = true; // Remove element from tab index - - this.element.tabIndex = -1; // Backup original styles if any - + this.element.hidden = true; + // Remove element from tab index + this.element.tabIndex = -1; + // Backup original styles if any var origStyle = this.element.getAttribute('style'); - if (origStyle) { this.element.setAttribute('data-choice-orig-style', origStyle); } - this.element.setAttribute('data-choice', 'active'); }; - WrappedElement.prototype.reveal = function () { // Reinstate passed element this.element.classList.remove(this.classNames.input); this.element.hidden = false; - this.element.removeAttribute('tabindex'); // Recover original styles if any - + this.element.removeAttribute('tabindex'); + // Recover original styles if any var origStyle = this.element.getAttribute('data-choice-orig-style'); - if (origStyle) { this.element.removeAttribute('data-choice-orig-style'); this.element.setAttribute('style', origStyle); } else { this.element.removeAttribute('style'); } - - this.element.removeAttribute('data-choice'); // Re-assign values - this is weird, I know + this.element.removeAttribute('data-choice'); + // Re-assign values - this is weird, I know // @todo Figure out why we need to do this - this.element.value = this.element.value; // eslint-disable-line no-self-assign }; @@ -3161,20 +2605,16 @@ function () { this.element.disabled = false; this.isDisabled = false; }; - WrappedElement.prototype.disable = function () { this.element.setAttribute('disabled', ''); this.element.disabled = true; this.isDisabled = true; }; - WrappedElement.prototype.triggerEvent = function (eventType, data) { (0, utils_1.dispatchEvent)(this.element, eventType, data); }; - return WrappedElement; }(); - exports["default"] = WrappedElement; /***/ }), @@ -3193,53 +2633,39 @@ var __extends = this && this.__extends || function () { } || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); }; - return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __importDefault = this && this.__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; - Object.defineProperty(exports, "__esModule", ({ value: true })); - var wrapped_element_1 = __importDefault(__webpack_require__(730)); - -var WrappedInput = -/** @class */ -function (_super) { +var WrappedInput = /** @class */function (_super) { __extends(WrappedInput, _super); - function WrappedInput(_a) { var element = _a.element, - classNames = _a.classNames, - delimiter = _a.delimiter; - + classNames = _a.classNames, + delimiter = _a.delimiter; var _this = _super.call(this, { element: element, classNames: classNames }) || this; - _this.delimiter = delimiter; return _this; } - Object.defineProperty(WrappedInput.prototype, "value", { get: function () { return this.element.value; @@ -3253,7 +2679,6 @@ function (_super) { }); return WrappedInput; }(wrapped_element_1.default); - exports["default"] = WrappedInput; /***/ }), @@ -3272,56 +2697,43 @@ var __extends = this && this.__extends || function () { } || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); }; - return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __importDefault = this && this.__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; - Object.defineProperty(exports, "__esModule", ({ value: true })); - var wrapped_element_1 = __importDefault(__webpack_require__(730)); - -var WrappedSelect = -/** @class */ -function (_super) { +var WrappedSelect = /** @class */function (_super) { __extends(WrappedSelect, _super); - function WrappedSelect(_a) { var element = _a.element, - classNames = _a.classNames, - template = _a.template; - + classNames = _a.classNames, + template = _a.template; var _this = _super.call(this, { element: element, classNames: classNames }) || this; - _this.template = template; return _this; } - Object.defineProperty(WrappedSelect.prototype, "placeholderOption", { get: function () { - return this.element.querySelector('option[value=""]') || // Backward compatibility layer for the non-standard placeholder attribute supported in older versions. + return this.element.querySelector('option[value=""]') || + // Backward compatibility layer for the non-standard placeholder attribute supported in older versions. this.element.querySelector('option[placeholder]'); }, enumerable: false, @@ -3340,18 +2752,14 @@ function (_super) { }, set: function (options) { var _this = this; - var fragment = document.createDocumentFragment(); - var addOptionToFragment = function (data) { // Create a standard select option - var option = _this.template(data); // Append it to fragment - - + var option = _this.template(data); + // Append it to fragment fragment.appendChild(option); - }; // Add each list item to list - - + }; + // Add each list item to list options.forEach(function (optionData) { return addOptionToFragment(optionData); }); @@ -3360,15 +2768,12 @@ function (_super) { enumerable: false, configurable: true }); - WrappedSelect.prototype.appendDocFragment = function (fragment) { this.element.innerHTML = ''; this.element.appendChild(fragment); }; - return WrappedSelect; }(wrapped_element_1.default); - exports["default"] = WrappedSelect; /***/ }), @@ -3434,9 +2839,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.DEFAULT_CONFIG = exports.DEFAULT_CLASSNAMES = void 0; - var utils_1 = __webpack_require__(799); - exports.DEFAULT_CLASSNAMES = { containerOuter: 'choices', containerInner: 'choices__inner', @@ -3537,8 +2940,8 @@ Object.defineProperty(exports, "__esModule", ({ /***/ (function(__unused_webpack_module, exports) { -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", ({ value: true })); @@ -3582,8 +2985,8 @@ Object.defineProperty(exports, "__esModule", ({ /***/ (function(__unused_webpack_module, exports) { -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", ({ value: true })); @@ -3597,53 +3000,40 @@ Object.defineProperty(exports, "__esModule", ({ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { - enumerable: true, - get: function () { - return m[k]; - } - }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { + enumerable: true, + get: function () { + return m[k]; + } + }; + } + Object.defineProperty(o, k2, desc); } : function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); - var __exportStar = this && this.__exportStar || function (m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; - Object.defineProperty(exports, "__esModule", ({ value: true })); - __exportStar(__webpack_require__(18), exports); - __exportStar(__webpack_require__(978), exports); - __exportStar(__webpack_require__(948), exports); - __exportStar(__webpack_require__(359), exports); - __exportStar(__webpack_require__(285), exports); - __exportStar(__webpack_require__(533), exports); - __exportStar(__webpack_require__(287), exports); - __exportStar(__webpack_require__(132), exports); - __exportStar(__webpack_require__(837), exports); - __exportStar(__webpack_require__(598), exports); - __exportStar(__webpack_require__(369), exports); - __exportStar(__webpack_require__(37), exports); - __exportStar(__webpack_require__(47), exports); - __exportStar(__webpack_require__(923), exports); - __exportStar(__webpack_require__(876), exports); /***/ }), @@ -3751,19 +3141,16 @@ Object.defineProperty(exports, "__esModule", ({ /***/ (function(__unused_webpack_module, exports) { -/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.diff = exports.cloneObject = exports.existsInArray = exports.dispatchEvent = exports.sortByScore = exports.sortByAlpha = exports.strToEl = exports.sanitise = exports.isScrolledIntoView = exports.getAdjacentEl = exports.wrap = exports.isType = exports.getType = exports.generateId = exports.generateChars = exports.getRandomNumber = void 0; - +exports.parseCustomProperties = exports.diff = exports.cloneObject = exports.existsInArray = exports.dispatchEvent = exports.sortByScore = exports.sortByAlpha = exports.strToEl = exports.sanitise = exports.isScrolledIntoView = exports.getAdjacentEl = exports.wrap = exports.isType = exports.getType = exports.generateId = exports.generateChars = exports.getRandomNumber = void 0; var getRandomNumber = function (min, max) { return Math.floor(Math.random() * (max - min) + min); }; - exports.getRandomNumber = getRandomNumber; - var generateChars = function (length) { return Array.from({ length: length @@ -3771,35 +3158,26 @@ var generateChars = function (length) { return (0, exports.getRandomNumber)(0, 36).toString(36); }).join(''); }; - exports.generateChars = generateChars; - var generateId = function (element, prefix) { var id = element.id || element.name && "".concat(element.name, "-").concat((0, exports.generateChars)(2)) || (0, exports.generateChars)(4); id = id.replace(/(:|\.|\[|\]|,)/g, ''); id = "".concat(prefix, "-").concat(id); return id; }; - exports.generateId = generateId; - var getType = function (obj) { return Object.prototype.toString.call(obj).slice(8, -1); }; - exports.getType = getType; - var isType = function (type, obj) { return obj !== undefined && obj !== null && (0, exports.getType)(obj) === type; }; - exports.isType = isType; - var wrap = function (element, wrapper) { if (wrapper === void 0) { wrapper = document.createElement('div'); } - if (element.parentNode) { if (element.nextSibling) { element.parentNode.insertBefore(wrapper, element.nextSibling); @@ -3807,44 +3185,32 @@ var wrap = function (element, wrapper) { element.parentNode.appendChild(wrapper); } } - return wrapper.appendChild(element); }; - exports.wrap = wrap; - var getAdjacentEl = function (startEl, selector, direction) { if (direction === void 0) { direction = 1; } - var prop = "".concat(direction > 0 ? 'next' : 'previous', "ElementSibling"); var sibling = startEl[prop]; - while (sibling) { if (sibling.matches(selector)) { return sibling; } - sibling = sibling[prop]; } - return sibling; }; - exports.getAdjacentEl = getAdjacentEl; - var isScrolledIntoView = function (element, parent, direction) { if (direction === void 0) { direction = 1; } - if (!element) { return false; } - var isVisible; - if (direction > 0) { // In view from bottom isVisible = parent.scrollTop + parent.offsetHeight >= element.offsetTop + element.offsetHeight; @@ -3852,68 +3218,54 @@ var isScrolledIntoView = function (element, parent, direction) { // In view from top isVisible = element.offsetTop >= parent.scrollTop; } - return isVisible; }; - exports.isScrolledIntoView = isScrolledIntoView; - var sanitise = function (value) { if (typeof value !== 'string') { return value; } - return value.replace(/&/g, '&').replace(/>/g, '>').replace(/ -1) { return state.map(function (obj) { var choice = obj; - if (choice.id === parseInt("".concat(addItemAction_1.choiceId), 10)) { choice.selected = true; } - return choice; }); } - return state; } - case 'REMOVE_ITEM': { - var removeItemAction_1 = action; // When an item is removed and it has an associated choice, + var removeItemAction_1 = action; + // When an item is removed and it has an associated choice, // we want to re-enable it so it can be chosen again - if (removeItemAction_1.choiceId && removeItemAction_1.choiceId > -1) { return state.map(function (obj) { var choice = obj; - if (choice.id === parseInt("".concat(removeItemAction_1.choiceId), 10)) { choice.selected = false; } - return choice; }); } - return state; } - case 'FILTER_CHOICES': { var filterChoicesAction_1 = action; return state.map(function (obj) { - var choice = obj; // Set active state based on whether choice is + var choice = obj; + // Set active state based on whether choice is // within filtered results - choice.active = filterChoicesAction_1.results.some(function (_a) { var item = _a.item, - score = _a.score; - + score = _a.score; if (item.id === choice.id) { choice.score = score; return true; } - return false; }); return choice; }); } - case 'ACTIVATE_CHOICES': { var activateChoicesAction_1 = action; @@ -4088,19 +3425,16 @@ function choices(state, action) { return choice; }); } - case 'CLEAR_CHOICES': { return exports.defaultState; } - default: { return state; } } } - exports["default"] = choices; /***/ }), @@ -4119,22 +3453,18 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) { } return to.concat(ar || Array.prototype.slice.call(from)); }; - Object.defineProperty(exports, "__esModule", ({ value: true })); exports.defaultState = void 0; exports.defaultState = []; - function groups(state, action) { if (state === void 0) { state = exports.defaultState; } - if (action === void 0) { action = {}; } - switch (action.type) { case 'ADD_GROUP': { @@ -4146,19 +3476,16 @@ function groups(state, action) { disabled: addGroupAction.disabled }], false); } - case 'CLEAR_CHOICES': { return []; } - default: { return state; } } } - exports["default"] = groups; /***/ }), @@ -4173,24 +3500,16 @@ var __importDefault = this && this.__importDefault || function (mod) { "default": mod }; }; - Object.defineProperty(exports, "__esModule", ({ value: true })); exports.defaultState = void 0; - -var redux_1 = __webpack_require__(857); - +var redux_1 = __webpack_require__(791); var items_1 = __importDefault(__webpack_require__(52)); - var groups_1 = __importDefault(__webpack_require__(871)); - var choices_1 = __importDefault(__webpack_require__(273)); - var loading_1 = __importDefault(__webpack_require__(502)); - var utils_1 = __webpack_require__(799); - exports.defaultState = { groups: [], items: [], @@ -4203,22 +3522,19 @@ var appReducer = (0, redux_1.combineReducers)({ choices: choices_1.default, loading: loading_1.default }); - var rootReducer = function (passedState, action) { - var state = passedState; // If we are clearing all items, groups and options we reassign + var state = passedState; + // If we are clearing all items, groups and options we reassign // state and then pass that state to our proper reducer. This isn't // mutating our actual state // See: http://stackoverflow.com/a/35641992 - if (action.type === 'CLEAR_ALL') { state = exports.defaultState; } else if (action.type === 'RESET_TO') { return (0, utils_1.cloneObject)(action.state); } - return appReducer(state, action); }; - exports["default"] = rootReducer; /***/ }), @@ -4237,27 +3553,23 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) { } return to.concat(ar || Array.prototype.slice.call(from)); }; - Object.defineProperty(exports, "__esModule", ({ value: true })); exports.defaultState = void 0; exports.defaultState = []; - function items(state, action) { if (state === void 0) { state = exports.defaultState; } - if (action === void 0) { action = {}; } - switch (action.type) { case 'ADD_ITEM': { - var addItemAction = action; // Add object to items array - + var addItemAction = action; + // Add object to items array var newState = __spreadArray(__spreadArray([], state, true), [{ id: addItemAction.id, choiceId: addItemAction.choiceId, @@ -4270,49 +3582,40 @@ function items(state, action) { placeholder: addItemAction.placeholder || false, keyCode: null }], false); - return newState.map(function (obj) { var item = obj; item.highlighted = false; return item; }); } - case 'REMOVE_ITEM': { // Set item to inactive return state.map(function (obj) { var item = obj; - if (item.id === action.id) { item.active = false; } - return item; }); } - case 'HIGHLIGHT_ITEM': { var highlightItemAction_1 = action; return state.map(function (obj) { var item = obj; - if (item.id === highlightItemAction_1.id) { item.highlighted = highlightItemAction_1.highlighted; } - return item; }); } - default: { return state; } } } - exports["default"] = items; /***/ }), @@ -4327,29 +3630,24 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.defaultState = void 0; exports.defaultState = false; - var general = function (state, action) { if (state === void 0) { state = exports.defaultState; } - if (action === void 0) { action = {}; } - switch (action.type) { case 'SET_IS_LOADING': { return action.isLoading; } - default: { return state; } } }; - exports["default"] = general; /***/ }), @@ -4368,45 +3666,33 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) { } return to.concat(ar || Array.prototype.slice.call(from)); }; - var __importDefault = this && this.__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; - Object.defineProperty(exports, "__esModule", ({ value: true })); /* eslint-disable @typescript-eslint/no-explicit-any */ - -var redux_1 = __webpack_require__(857); - +var redux_1 = __webpack_require__(791); var index_1 = __importDefault(__webpack_require__(655)); - -var Store = -/** @class */ -function () { +var Store = /** @class */function () { function Store() { this._store = (0, redux_1.createStore)(index_1.default, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()); } /** * Subscribe store to function call (wrapped Redux method) */ - - Store.prototype.subscribe = function (onChange) { this._store.subscribe(onChange); }; /** * Dispatch event to store (wrapped Redux method) */ - - Store.prototype.dispatch = function (action) { this._store.dispatch(action); }; - Object.defineProperty(Store.prototype, "state", { /** * Get store object (wrapping Redux method) @@ -4525,9 +3811,8 @@ function () { */ get: function () { var _a = this, - groups = _a.groups, - choices = _a.choices; - + groups = _a.groups, + choices = _a.choices; return groups.filter(function (group) { var isActive = group.active === true && group.disabled === false; var hasActiveOptions = choices.some(function (choice) { @@ -4542,15 +3827,12 @@ function () { /** * Get loading state from store */ - Store.prototype.isLoading = function () { return this.state.loading; }; /** * Get single choice by it's ID */ - - Store.prototype.getChoiceById = function (id) { return this.activeChoices.find(function (choice) { return choice.id === parseInt(id, 10); @@ -4559,17 +3841,13 @@ function () { /** * Get group by group id */ - - Store.prototype.getGroupById = function (id) { return this.groups.find(function (group) { return group.id === id; }); }; - return Store; }(); - exports["default"] = Store; /***/ }), @@ -4578,11 +3856,11 @@ exports["default"] = Store; /***/ (function(__unused_webpack_module, exports) { + /** * Helpers to create HTML elements used by Choices * Can be overridden by providing `callbackOnCreateTemplates` option */ - Object.defineProperty(exports, "__esModule", ({ value: true })); @@ -4593,30 +3871,23 @@ var templates = { className: containerOuter }); div.dataset.type = passedElementType; - if (dir) { div.dir = dir; } - if (isSelectOneElement) { div.tabIndex = 0; } - if (isSelectElement) { div.setAttribute('role', searchEnabled ? 'combobox' : 'listbox'); - if (searchEnabled) { div.setAttribute('aria-autocomplete', 'list'); } } - div.setAttribute('aria-haspopup', 'true'); div.setAttribute('aria-expanded', 'false'); - if (labelId) { - div.setAttribute('aria-labeledby', labelId); + div.setAttribute('aria-labelledby', labelId); } - return div; }, containerInner: function (_a) { @@ -4627,40 +3898,38 @@ var templates = { }, itemList: function (_a, isSelectOneElement) { var _b = _a.classNames, - list = _b.list, - listSingle = _b.listSingle, - listItems = _b.listItems; + list = _b.list, + listSingle = _b.listSingle, + listItems = _b.listItems; return Object.assign(document.createElement('div'), { className: "".concat(list, " ").concat(isSelectOneElement ? listSingle : listItems) }); }, placeholder: function (_a, value) { var _b; - var allowHTML = _a.allowHTML, - placeholder = _a.classNames.placeholder; + placeholder = _a.classNames.placeholder; return Object.assign(document.createElement('div'), (_b = { className: placeholder }, _b[allowHTML ? 'innerHTML' : 'innerText'] = value, _b)); }, item: function (_a, _b, removeItemButton) { var _c, _d; - var allowHTML = _a.allowHTML, - _e = _a.classNames, - item = _e.item, - button = _e.button, - highlightedState = _e.highlightedState, - itemSelectable = _e.itemSelectable, - placeholder = _e.placeholder; + _e = _a.classNames, + item = _e.item, + button = _e.button, + highlightedState = _e.highlightedState, + itemSelectable = _e.itemSelectable, + placeholder = _e.placeholder; var id = _b.id, - value = _b.value, - label = _b.label, - customProperties = _b.customProperties, - active = _b.active, - disabled = _b.disabled, - highlighted = _b.highlighted, - isPlaceholder = _b.placeholder; + value = _b.value, + label = _b.label, + customProperties = _b.customProperties, + active = _b.active, + disabled = _b.disabled, + highlighted = _b.highlighted, + isPlaceholder = _b.placeholder; var div = Object.assign(document.createElement('div'), (_c = { className: item }, _c[allowHTML ? 'innerHTML' : 'innerText'] = label, _c)); @@ -4670,29 +3939,22 @@ var templates = { value: value, customProperties: customProperties }); - if (active) { div.setAttribute('aria-selected', 'true'); } - if (disabled) { div.setAttribute('aria-disabled', 'true'); } - if (isPlaceholder) { div.classList.add(placeholder); } - div.classList.add(highlighted ? highlightedState : itemSelectable); - if (removeItemButton) { if (disabled) { div.classList.remove(itemSelectable); } - div.dataset.deletable = ''; /** @todo This MUST be localizable, not hardcoded! */ - var REMOVE_ITEM_TEXT = 'Remove item'; var removeButton = Object.assign(document.createElement('button'), (_d = { type: 'button', @@ -4702,7 +3964,6 @@ var templates = { removeButton.dataset.button = ''; div.appendChild(removeButton); } - return div; }, choiceList: function (_a, isSelectOneElement) { @@ -4710,25 +3971,22 @@ var templates = { var div = Object.assign(document.createElement('div'), { className: list }); - if (!isSelectOneElement) { div.setAttribute('aria-multiselectable', 'true'); } - div.setAttribute('role', 'listbox'); return div; }, choiceGroup: function (_a, _b) { var _c; - var allowHTML = _a.allowHTML, - _d = _a.classNames, - group = _d.group, - groupHeading = _d.groupHeading, - itemDisabled = _d.itemDisabled; + _d = _a.classNames, + group = _d.group, + groupHeading = _d.groupHeading, + itemDisabled = _d.itemDisabled; var id = _b.id, - value = _b.value, - disabled = _b.disabled; + value = _b.value, + disabled = _b.disabled; var div = Object.assign(document.createElement('div'), { className: "".concat(group, " ").concat(disabled ? itemDisabled : '') }); @@ -4738,11 +3996,9 @@ var templates = { id: id, value: value }); - if (disabled) { div.setAttribute('aria-disabled', 'true'); } - div.appendChild(Object.assign(document.createElement('div'), (_c = { className: groupHeading }, _c[allowHTML ? 'innerHTML' : 'innerText'] = value, _c))); @@ -4750,35 +4006,31 @@ var templates = { }, choice: function (_a, _b, selectText) { var _c; - var allowHTML = _a.allowHTML, - _d = _a.classNames, - item = _d.item, - itemChoice = _d.itemChoice, - itemSelectable = _d.itemSelectable, - selectedState = _d.selectedState, - itemDisabled = _d.itemDisabled, - placeholder = _d.placeholder; + _d = _a.classNames, + item = _d.item, + itemChoice = _d.itemChoice, + itemSelectable = _d.itemSelectable, + selectedState = _d.selectedState, + itemDisabled = _d.itemDisabled, + placeholder = _d.placeholder; var id = _b.id, - value = _b.value, - label = _b.label, - groupId = _b.groupId, - elementId = _b.elementId, - isDisabled = _b.disabled, - isSelected = _b.selected, - isPlaceholder = _b.placeholder; + value = _b.value, + label = _b.label, + groupId = _b.groupId, + elementId = _b.elementId, + isDisabled = _b.disabled, + isSelected = _b.selected, + isPlaceholder = _b.placeholder; var div = Object.assign(document.createElement('div'), (_c = { id: elementId }, _c[allowHTML ? 'innerHTML' : 'innerText'] = label, _c.className = "".concat(item, " ").concat(itemChoice), _c)); - if (isSelected) { div.classList.add(selectedState); } - if (isPlaceholder) { div.classList.add(placeholder); } - div.setAttribute('role', groupId && groupId > 0 ? 'treeitem' : 'option'); Object.assign(div.dataset, { choice: '', @@ -4786,7 +4038,6 @@ var templates = { value: value, selectText: selectText }); - if (isDisabled) { div.classList.add(itemDisabled); div.dataset.choiceDisabled = ''; @@ -4795,13 +4046,12 @@ var templates = { div.classList.add(itemSelectable); div.dataset.choiceSelectable = ''; } - return div; }, input: function (_a, placeholderValue) { var _b = _a.classNames, - input = _b.input, - inputCloned = _b.inputCloned; + input = _b.input, + inputCloned = _b.inputCloned; var inp = Object.assign(document.createElement('input'), { type: 'search', name: 'search_terms', @@ -4817,8 +4067,8 @@ var templates = { }, dropdown: function (_a) { var _b = _a.classNames, - list = _b.list, - listDropdown = _b.listDropdown; + list = _b.list, + listDropdown = _b.listDropdown; var div = document.createElement('div'); div.classList.add(list, listDropdown); div.setAttribute('aria-expanded', 'false'); @@ -4826,40 +4076,33 @@ var templates = { }, notice: function (_a, innerText, type) { var _b; - var allowHTML = _a.allowHTML, - _c = _a.classNames, - item = _c.item, - itemChoice = _c.itemChoice, - noResults = _c.noResults, - noChoices = _c.noChoices; - + _c = _a.classNames, + item = _c.item, + itemChoice = _c.itemChoice, + noResults = _c.noResults, + noChoices = _c.noChoices; if (type === void 0) { type = ''; } - var classes = [item, itemChoice]; - if (type === 'no-choices') { classes.push(noChoices); } else if (type === 'no-results') { classes.push(noResults); } - return Object.assign(document.createElement('div'), (_b = {}, _b[allowHTML ? 'innerHTML' : 'innerText'] = innerText, _b.className = classes.join(' '), _b)); }, option: function (_a) { var label = _a.label, - value = _a.value, - customProperties = _a.customProperties, - active = _a.active, - disabled = _a.disabled; + value = _a.value, + customProperties = _a.customProperties, + active = _a.active, + disabled = _a.disabled; var opt = new Option(label, value, false, active); - if (customProperties) { opt.dataset.customProperties = "".concat(customProperties); } - opt.disabled = !!disabled; return opt; } @@ -5016,9 +4259,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ "default": function() { return /* binding */ Fuse; } /* harmony export */ }); /** - * Fuse.js v6.5.3 - Lightweight fuzzy-search (http://fusejs.io) + * Fuse.js v6.6.2 - Lightweight fuzzy-search (http://fusejs.io) * - * Copyright (c) 2021 Kiro Risk (http://kiro.me) + * Copyright (c) 2022 Kiro Risk (http://kiro.me) * All Rights Reserved. Apache Software License 2.0 * * http://www.apache.org/licenses/LICENSE-2.0 @@ -5145,6 +4388,7 @@ function createKey(key) { let id = null; let src = null; let weight = 1; + let getFn = null; if (isString(key) || isArray(key)) { src = key; @@ -5168,9 +4412,10 @@ function createKey(key) { path = createKeyPath(name); id = createKeyId(name); + getFn = key.getFn; } - return { path, id, weight, src } + return { path, id, weight, src, getFn } } function createKeyPath(key) { @@ -5413,8 +4658,7 @@ class FuseIndex { // Iterate over every key (i.e, path), and fetch the value at that key this.keys.forEach((key, keyIndex) => { - // console.log(key) - let value = this.getFn(doc, key.path); + let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path); if (!isDefined(value)) { return @@ -5449,7 +4693,7 @@ class FuseIndex { } else ; } record.$[keyIndex] = subRecords; - } else if (!isBlank(value)) { + } else if (isString(value) && !isBlank(value)) { let subRecord = { v: value, n: this.norm.get(value) @@ -6144,7 +5388,7 @@ const searchers = [ const searchersLen = searchers.length; // Regex to split by spaces, but keep anything in quotes together -const SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/; +const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/; const OR_TOKEN = '|'; // Return a 2D array representation of the query, for simpler parsing. @@ -6778,7 +6022,7 @@ class Fuse { } } -Fuse.version = '6.5.3'; +Fuse.version = '6.6.2'; Fuse.createIndex = createIndex; Fuse.parseIndex = parseIndex; Fuse.config = Config; @@ -6796,7 +6040,7 @@ Fuse.config = Config; /***/ }), -/***/ 857: +/***/ 791: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { // ESM COMPAT FLAG @@ -6809,11 +6053,43 @@ __webpack_require__.d(__webpack_exports__, { "bindActionCreators": function() { return /* binding */ bindActionCreators; }, "combineReducers": function() { return /* binding */ combineReducers; }, "compose": function() { return /* binding */ compose; }, - "createStore": function() { return /* binding */ createStore; } + "createStore": function() { return /* binding */ createStore; }, + "legacy_createStore": function() { return /* binding */ legacy_createStore; } }); +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js +function _typeof(obj) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js + +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js + + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js + function _defineProperty(obj, key, value) { + key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -6824,25 +6100,20 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js - function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } - return keys; } - function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; @@ -6852,7 +6123,6 @@ function _objectSpread2(target) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } - return target; } ;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js @@ -6965,29 +6235,29 @@ function kindOf(val) { } /** - * Creates a Redux store that holds the state tree. - * The only way to change the data in the store is to call `dispatch()` on it. + * @deprecated * - * There should only be a single store in your app. To specify how different - * parts of the state tree respond to actions, you may combine several reducers - * into a single reducer function by using `combineReducers`. + * **We recommend using the `configureStore` method + * of the `@reduxjs/toolkit` package**, which replaces `createStore`. * - * @param {Function} reducer A function that returns the next state tree, given - * the current state tree and the action to handle. + * Redux Toolkit is our recommended approach for writing Redux logic today, + * including store setup, reducers, data fetching, and more. * - * @param {any} [preloadedState] The initial state. You may optionally specify it - * to hydrate the state from the server in universal apps, or to restore a - * previously serialized user session. - * If you use `combineReducers` to produce the root reducer function, this must be - * an object with the same shape as `combineReducers` keys. + * **For more details, please read this Redux docs page:** + * **https://redux.js.org/introduction/why-rtk-is-redux-today** * - * @param {Function} [enhancer] The store enhancer. You may optionally specify it - * to enhance the store with third-party capabilities such as middleware, - * time travel, persistence, etc. The only store enhancer that ships with Redux - * is `applyMiddleware()`. + * `configureStore` from Redux Toolkit is an improved version of `createStore` that + * simplifies setup and helps avoid common bugs. + * + * You should not be using the `redux` core package by itself today, except for learning purposes. + * The `createStore` method from the core `redux` package will not be removed, but we encourage + * all users to migrate to using Redux Toolkit for all Redux code. + * + * If you want to use `createStore` without this visual deprecation warning, use + * the `legacy_createStore` import instead: + * + * `import { legacy_createStore as createStore} from 'redux'` * - * @returns {Store} A Redux store that lets you read the state, dispatch actions - * and subscribe to changes. */ function createStore(reducer, preloadedState, enhancer) { @@ -7237,6 +6507,38 @@ function createStore(reducer, preloadedState, enhancer) { replaceReducer: replaceReducer }, _ref2[$$observable] = observable, _ref2; } +/** + * Creates a Redux store that holds the state tree. + * + * **We recommend using `configureStore` from the + * `@reduxjs/toolkit` package**, which replaces `createStore`: + * **https://redux.js.org/introduction/why-rtk-is-redux-today** + * + * The only way to change the data in the store is to call `dispatch()` on it. + * + * There should only be a single store in your app. To specify how different + * parts of the state tree respond to actions, you may combine several reducers + * into a single reducer function by using `combineReducers`. + * + * @param {Function} reducer A function that returns the next state tree, given + * the current state tree and the action to handle. + * + * @param {any} [preloadedState] The initial state. You may optionally specify it + * to hydrate the state from the server in universal apps, or to restore a + * previously serialized user session. + * If you use `combineReducers` to produce the root reducer function, this must be + * an object with the same shape as `combineReducers` keys. + * + * @param {Function} [enhancer] The store enhancer. You may optionally specify it + * to enhance the store with third-party capabilities such as middleware, + * time travel, persistence, etc. The only store enhancer that ships with Redux + * is `applyMiddleware()`. + * + * @returns {Store} A Redux store that lets you read the state, dispatch actions + * and subscribe to changes. + */ + +var legacy_createStore = createStore; /** * Prints a warning in the console if it exists. diff --git a/assets/scripts/choices.min.js b/assets/scripts/choices.min.js index 8227e7f..af28094 100644 --- a/assets/scripts/choices.min.js +++ b/assets/scripts/choices.min.js @@ -1,2 +1,2 @@ /*! For license information please see choices.min.js.LICENSE.txt */ -!function(){"use strict";var e={282:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.clearChoices=t.activateChoices=t.filterChoices=t.addChoice=void 0;var n=i(883);t.addChoice=function(e){var t=e.value,i=e.label,s=e.id,r=e.groupId,o=e.disabled,a=e.elementId,c=e.customProperties,l=e.placeholder,h=e.keyCode;return{type:n.ACTION_TYPES.ADD_CHOICE,value:t,label:i,id:s,groupId:r,disabled:o,elementId:a,customProperties:c,placeholder:l,keyCode:h}},t.filterChoices=function(e){return{type:n.ACTION_TYPES.FILTER_CHOICES,results:e}},t.activateChoices=function(e){return void 0===e&&(e=!0),{type:n.ACTION_TYPES.ACTIVATE_CHOICES,active:e}},t.clearChoices=function(){return{type:n.ACTION_TYPES.CLEAR_CHOICES}}},783:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.addGroup=void 0;var n=i(883);t.addGroup=function(e){var t=e.value,i=e.id,s=e.active,r=e.disabled;return{type:n.ACTION_TYPES.ADD_GROUP,value:t,id:i,active:s,disabled:r}}},464:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.highlightItem=t.removeItem=t.addItem=void 0;var n=i(883);t.addItem=function(e){var t=e.value,i=e.label,s=e.id,r=e.choiceId,o=e.groupId,a=e.customProperties,c=e.placeholder,l=e.keyCode;return{type:n.ACTION_TYPES.ADD_ITEM,value:t,label:i,id:s,choiceId:r,groupId:o,customProperties:a,placeholder:c,keyCode:l}},t.removeItem=function(e,t){return{type:n.ACTION_TYPES.REMOVE_ITEM,id:e,choiceId:t}},t.highlightItem=function(e,t){return{type:n.ACTION_TYPES.HIGHLIGHT_ITEM,id:e,highlighted:t}}},137:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.setIsLoading=t.resetTo=t.clearAll=void 0;var n=i(883);t.clearAll=function(){return{type:n.ACTION_TYPES.CLEAR_ALL}},t.resetTo=function(e){return{type:n.ACTION_TYPES.RESET_TO,state:e}},t.setIsLoading=function(e){return{type:n.ACTION_TYPES.SET_IS_LOADING,isLoading:e}}},373:function(e,t,i){var n=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,s=0,r=t.length;s=0?this._store.getGroupById(s):null;return this._store.dispatch((0,l.highlightItem)(i,!0)),t&&this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:i,value:o,label:c,groupValue:h&&h.value?h.value:null}),this},e.prototype.unhighlightItem=function(e){if(!e||!e.id)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,s=e.value,r=void 0===s?"":s,o=e.label,a=void 0===o?"":o,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch((0,l.highlightItem)(t,!1)),this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:t,value:r,label:a,groupValue:c&&c.value?c.value:null}),this},e.prototype.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(d.EVENTS.showDropdown,{})})),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent(d.EVENTS.hideDropdown,{})})),this):this},e.prototype.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},e.prototype.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},e.prototype.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement||(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this},e.prototype.setChoices=function(e,t,i,n){var s=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(n&&this.clearChoices(),"function"==typeof e){var r=e(this);if("function"==typeof Promise&&r instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return s._handleLoadingState(!0)})).then((function(){return r})).then((function(e){return s.setChoices(e,t,i,n)})).catch((function(e){s.config.silent||console.error(e)})).then((function(){return s._handleLoadingState(!1)})).then((function(){return s}));if(!Array.isArray(r))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof r));return this.setChoices(r,t,i,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._startLoading(),e.forEach((function(e){if(e.choices)s._addGroup({id:e.id?parseInt("".concat(e.id),10):null,group:e,valueKey:t,labelKey:i});else{var n=e;s._addChoice({value:n[t],label:n[i],isSelected:!!n.selected,isDisabled:!!n.disabled,placeholder:!!n.placeholder,customProperties:n.customProperties})}})),this._stopLoading(),this},e.prototype.clearChoices=function(){return this._store.dispatch((0,a.clearChoices)()),this},e.prototype.clearStore=function(){return this._store.dispatch((0,h.clearAll)()),this},e.prototype.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))),this},e.prototype._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},e.prototype._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,s=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var r=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));r.length>=1&&(s=this._createChoicesFragment(r,s)),s=this._createGroupsFragment(i,n,s)}else n.length>=1&&(s=this._createChoicesFragment(n,s));if(s.childNodes&&s.childNodes.length>0){var o=this._store.activeItems,a=this._canAddItem(o,this.input.value);if(a.response)this.choiceList.append(s),this._highlightChoice();else{var c=this._getTemplate("notice",a.notice);this.choiceList.append(c)}}else{var l=void 0;c=void 0,this._isSearching?(c="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,l=this._getTemplate("notice",c,"no-results")):(c="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,l=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(l)}},e.prototype._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},e.prototype._createGroupsFragment=function(e,t,i){var n=this;return void 0===i&&(i=document.createDocumentFragment()),this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var s=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(s.length>=1){var r=n._getTemplate("choiceGroup",e);i.appendChild(r),n._createChoicesFragment(s,i,!0)}})),i},e.prototype._createChoicesFragment=function(e,t,i){var s=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var r=this.config,o=r.renderSelectedChoices,a=r.searchResultLimit,c=r.renderChoiceLimit,l=this._isSearching?f.sortByScore:this.config.sorter,h=function(e){if("auto"!==o||s._isSelectOneElement||!e.selected){var i=s._getTemplate("choice",e,s.config.itemSelectText);t.appendChild(i)}},u=e;"auto"!==o||this._isSelectOneElement||(u=e.filter((function(e){return!e.selected})));var d=u.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),p=d.placeholderChoices,m=d.normalChoices;(this.config.shouldSort||this._isSearching)&&m.sort(l);var v=u.length,g=this._isSelectOneElement?n(n([],p,!0),m,!0):m;this._isSearching?v=a:c&&c>0&&!i&&(v=c);for(var _=0;_=n){var o=s?this._searchChoices(e):0;this.passedElement.triggerEvent(d.EVENTS.search,{value:e,resultCount:o})}else r&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0)))}},e.prototype._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var s=(0,f.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&s&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},e.prototype._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t==="".concat(i," "))return 0;var s=this._store.searchableChoices,r=t,c=Object.assign(this.config.fuseOptions,{keys:n([],this.config.searchFields,!0),includeMatches:!0}),l=new o.default(s,c).search(r);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,a.filterChoices)(l)),l.length},e.prototype._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this._store.activeItems,n=this.input.isFocussed,s=this.dropdown.isActive,r=this.itemList.hasChildren(),o=String.fromCharCode(t),a=/[a-zA-Z0-9-_ ]/.test(o),c=d.KEY_CODES.BACK_KEY,l=d.KEY_CODES.DELETE_KEY,h=d.KEY_CODES.ENTER_KEY,u=d.KEY_CODES.A_KEY,p=d.KEY_CODES.ESC_KEY,f=d.KEY_CODES.UP_KEY,m=d.KEY_CODES.DOWN_KEY,v=d.KEY_CODES.PAGE_UP_KEY,g=d.KEY_CODES.PAGE_DOWN_KEY;switch(this._isTextElement||s||!a||(this.showDropdown(),this.input.isFocussed||(this.input.value+=o.toLowerCase())),t){case u:return this._onSelectKey(e,r);case h:return this._onEnterKey(e,i,s);case p:return this._onEscapeKey(s);case f:case v:case m:case g:return this._onDirectionKey(e,s);case l:case c:return this._onDeleteKey(e,i,n)}},e.prototype._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,s=this._store.activeItems,r=this._canAddItem(s,n),o=d.KEY_CODES.BACK_KEY,c=d.KEY_CODES.DELETE_KEY;if(this._isTextElement)if(r.notice&&n){var l=this._getTemplate("notice",r.notice);this.dropdown.element.innerHTML=l.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0);else{var h=(i===o||i===c)&&t&&!t.value,u=!this._isTextElement&&this._isSearching,p=this._canSearch&&r.response;h&&u?(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))):p&&this._handleSearch(this.input.rawValue)}this._canSearch=this.config.searchEnabled},e.prototype._onSelectKey=function(e,t){var i=e.ctrlKey,n=e.metaKey;(i||n)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t,i){var n=e.target,s=d.KEY_CODES.ENTER_KEY,r=n&&n.hasAttribute("data-button");if(this._isTextElement&&n&&n.value){var o=this.input.value;this._canAddItem(t,o).response&&(this.hideDropdown(!0),this._addItem({value:o}),this._triggerChange(o),this.clearInput())}if(r&&(this._handleButtonAction(t,n),e.preventDefault()),i){var a=this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));a&&(t[0]&&(t[0].keyCode=s),this._handleChoiceAction(t,a)),e.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),e.preventDefault())},e.prototype._onEscapeKey=function(e){e&&(this.hideDropdown(!0),this.containerOuter.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode,n=e.metaKey,s=d.KEY_CODES.DOWN_KEY,r=d.KEY_CODES.PAGE_UP_KEY,o=d.KEY_CODES.PAGE_DOWN_KEY;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var a=i===s||i===o?1:-1,c="[data-choice-selectable]",l=void 0;if(n||i===o||i===r)l=a>0?this.dropdown.element.querySelector("".concat(c,":last-of-type")):this.dropdown.element.querySelector(c);else{var h=this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));l=h?(0,f.getAdjacentEl)(h,c,a):this.dropdown.element.querySelector(c)}l&&((0,f.isScrolledIntoView)(l,this.choiceList.element,a)||this.choiceList.scrollToChildElement(l,a),this._highlightChoice(l)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){var n=e.target;this._isSelectOneElement||n.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(_&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},e.prototype._onFocus=function(e){var t,i=this,n=e.target;n&&this.containerOuter.element.contains(n)&&((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},e.prototype._onBlur=function(e){var t,i=this,n=e.target;if(n&&this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var s=this._store.activeItems.some((function(e){return e.highlighted}));((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),s&&i.unhighlightAll(),i.hideDropdown(!0))},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.removeFocusState(),(n===i.input.element||n===i.containerOuter.element&&!i._canSearch)&&i.hideDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),i.hideDropdown(!0),s&&i.unhighlightAll())},t)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},e.prototype._onFormReset=function(){this._store.dispatch((0,h.resetTo)(this._initialState))},e.prototype._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(d.EVENTS.highlightChoice,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},e.prototype._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,s=e.choiceId,r=void 0===s?-1:s,o=e.groupId,a=void 0===o?-1:o,c=e.customProperties,h=void 0===c?{}:c,u=e.placeholder,p=void 0!==u&&u,f=e.keyCode,m=void 0===f?-1:f,v="string"==typeof t?t.trim():t,g=this._store.items,_=n||v,y=r||-1,E=a>=0?this._store.getGroupById(a):null,b=g?g.length+1:1;this.config.prependValue&&(v=this.config.prependValue+v.toString()),this.config.appendValue&&(v+=this.config.appendValue.toString()),this._store.dispatch((0,l.addItem)({value:v,label:_,id:b,choiceId:y,groupId:a,customProperties:h,placeholder:p,keyCode:m})),this._isSelectOneElement&&this.removeActiveItems(b),this.passedElement.triggerEvent(d.EVENTS.addItem,{id:b,value:v,label:_,customProperties:h,groupValue:E&&E.value?E.value:null,keyCode:m})},e.prototype._removeItem=function(e){var t=e.id,i=e.value,n=e.label,s=e.customProperties,r=e.choiceId,o=e.groupId,a=o&&o>=0?this._store.getGroupById(o):null;t&&r&&(this._store.dispatch((0,l.removeItem)(t,r)),this.passedElement.triggerEvent(d.EVENTS.removeItem,{id:t,value:i,label:n,customProperties:s,groupValue:a&&a.value?a.value:null}))},e.prototype._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,s=e.isSelected,r=void 0!==s&&s,o=e.isDisabled,c=void 0!==o&&o,l=e.groupId,h=void 0===l?-1:l,u=e.customProperties,d=void 0===u?{}:u,p=e.placeholder,f=void 0!==p&&p,m=e.keyCode,v=void 0===m?-1:m;if(null!=t){var g=this._store.choices,_=n||t,y=g?g.length+1:1,E="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(y);this._store.dispatch((0,a.addChoice)({id:y,groupId:h,elementId:E,value:t,label:_,disabled:c,customProperties:d,placeholder:f,keyCode:v})),r&&this._addItem({value:t,label:_,choiceId:y,customProperties:d,placeholder:f,keyCode:v})}},e.prototype._addGroup=function(e){var t=this,i=e.group,n=e.id,s=e.valueKey,r=void 0===s?"value":s,o=e.labelKey,a=void 0===o?"label":o,l=(0,f.isType)("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),h=n||Math.floor((new Date).valueOf()*Math.random()),u=!!i.disabled&&i.disabled;l?(this._store.dispatch((0,c.addGroup)({value:i.label,id:h,active:!0,disabled:u})),l.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[r],label:(0,f.isType)("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:h,customProperties:e.customProperties,placeholder:e.placeholder})}))):this._store.dispatch((0,c.addGroup)({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},e.prototype._getTemplate=function(e){for(var t,i=[],s=1;s0?this.element.scrollTop+o-s:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t,s=n>1?n:1;this.element.scrollTop=e+s},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t,s=n>1?n:1;this.element.scrollTop=e-s},e.prototype._animateScroll=function(e,t){var i=this,s=n.SCROLLING_SPEED,r=this.element.scrollTop,o=!1;t>0?(this._scrollDown(r,s,e),re&&(o=!0)),o&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}();t.default=s},730:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=i(799),s=function(){function e(e){var t=e.element,i=e.classNames;if(this.element=t,this.classNames=i,!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement))throw new TypeError("Invalid element passed");this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){this.element.classList.add(this.classNames.input),this.element.hidden=!0,this.element.tabIndex=-1;var e=this.element.getAttribute("style");e&&this.element.setAttribute("data-choice-orig-style",e),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){this.element.classList.remove(this.classNames.input),this.element.hidden=!1,this.element.removeAttribute("tabindex");var e=this.element.getAttribute("data-choice-orig-style");e?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",e)):this.element.removeAttribute("style"),this.element.removeAttribute("data-choice"),this.element.value=this.element.value},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){(0,n.dispatchEvent)(this.element,e,t)},e}();t.default=s},541:function(e,t,i){var n,s=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,s=t.delimiter,r=e.call(this,{element:i,classNames:n})||this;return r.delimiter=s,r}return s(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),t}(r(i(730)).default);t.default=o},982:function(e,t,i){var n,s=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,s=t.template,r=e.call(this,{element:i,classNames:n})||this;return r.template=s,r}return s(t,e),Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optionGroups",{get:function(){return Array.from(this.element.getElementsByTagName("OPTGROUP"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return Array.from(this.element.options)},set:function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){return n=e,s=t.template(n),void i.appendChild(s);var n,s})),this.appendDocFragment(i)},enumerable:!1,configurable:!0}),t.prototype.appendDocFragment=function(e){this.element.innerHTML="",this.element.appendChild(e)},t}(r(i(730)).default);t.default=o},883:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.SELECT_MULTIPLE_TYPE=t.SELECT_ONE_TYPE=t.TEXT_TYPE=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=void 0,t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL",RESET_TO:"RESET_TO",SET_IS_LOADING:"SET_IS_LOADING"},t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},t.TEXT_TYPE="text",t.SELECT_ONE_TYPE="select-one",t.SELECT_MULTIPLE_TYPE="select-multiple",t.SCROLLING_SPEED=4},789:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(799);t.DEFAULT_CLASSNAMES={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",selectedState:"is-selected",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"},t.DEFAULT_CONFIG={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilter:null,removeItems:!0,removeItemButton:!1,editItems:!1,allowHTML:!0,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:n.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:t.DEFAULT_CLASSNAMES}},18:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},978:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},948:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},359:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},285:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},533:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},187:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),s(i(18),t),s(i(978),t),s(i(948),t),s(i(359),t),s(i(285),t),s(i(533),t),s(i(287),t),s(i(132),t),s(i(837),t),s(i(598),t),s(i(369),t),s(i(37),t),s(i(47),t),s(i(923),t),s(i(876),t)},287:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},132:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},837:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},598:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},37:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},369:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},47:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},923:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},876:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},799:function(e,t){var i;Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.cloneObject=t.existsInArray=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.wrap=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0,t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.generateChars=function(e){return Array.from({length:e},(function(){return(0,t.getRandomNumber)(0,36).toString(36)})).join("")},t.generateId=function(e,i){var n=e.id||e.name&&"".concat(e.name,"-").concat((0,t.generateChars)(2))||(0,t.generateChars)(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),"".concat(i,"-").concat(n)},t.getType=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.isType=function(e,i){return null!=i&&(0,t.getType)(i)===e},t.wrap=function(e,t){return void 0===t&&(t=document.createElement("div")),e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)),t.appendChild(e)},t.getAdjacentEl=function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),s=e[n];s;){if(s.matches(t))return s;s=s[n]}return s},t.isScrolledIntoView=function(e,t,i){return void 0===i&&(i=1),!!e&&(i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop)},t.sanitise=function(e){return"string"!=typeof e?e:e.replace(/&/g,"&").replace(/>/g,">").replace(/-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(o.choiceId),10)&&(t.selected=!0),t})):e;case"REMOVE_ITEM":var a=n;return a.choiceId&&a.choiceId>-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(a.choiceId),10)&&(t.selected=!1),t})):e;case"FILTER_CHOICES":var c=n;return e.map((function(e){var t=e;return t.active=c.results.some((function(e){var i=e.item,n=e.score;return i.id===t.id&&(t.score=n,!0)})),t}));case"ACTIVATE_CHOICES":var l=n;return e.map((function(e){var t=e;return t.active=l.active,t}));case"CLEAR_CHOICES":return t.defaultState;default:return e}}},871:function(e,t){var i=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,s=0,r=t.length;s0?"treeitem":"option"),Object.assign(E.dataset,{choice:"",id:d,value:p,selectText:i}),g?(E.classList.add(h),E.dataset.choiceDisabled="",E.setAttribute("aria-disabled","true")):(E.classList.add(c),E.dataset.choiceSelectable=""),E},input:function(e,t){var i=e.classNames,n=i.input,s=i.inputCloned,r=Object.assign(document.createElement("input"),{type:"search",name:"search_terms",className:"".concat(n," ").concat(s),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return r.setAttribute("role","textbox"),r.setAttribute("aria-autocomplete","list"),r.setAttribute("aria-label",t),r},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,s=document.createElement("div");return s.classList.add(i,n),s.setAttribute("aria-expanded","false"),s},notice:function(e,t,i){var n,s=e.allowHTML,r=e.classNames,o=r.item,a=r.itemChoice,c=r.noResults,l=r.noChoices;void 0===i&&(i="");var h=[o,a];return"no-choices"===i?h.push(l):"no-results"===i&&h.push(c),Object.assign(document.createElement("div"),((n={})[s?"innerHTML":"innerText"]=t,n.className=h.join(" "),n))},option:function(e){var t=e.label,i=e.value,n=e.customProperties,s=e.active,r=e.disabled,o=new Option(t,i,!1,s);return n&&(o.dataset.customProperties="".concat(n)),o.disabled=!!r,o}};t.default=i},996:function(e){var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function s(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function r(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,i,c){(c=c||{}).arrayMerge=c.arrayMerge||s,c.isMergeableObject=c.isMergeableObject||t,c.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(i);return l===Array.isArray(e)?l?c.arrayMerge(e,i,c):function(e,t,i){var s={};return i.isMergeableObject(e)&&r(e).forEach((function(t){s[t]=n(e[t],i)})),r(t).forEach((function(r){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(o(e,r)&&i.isMergeableObject(t[r])?s[r]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(r,i)(e[r],t[r],i):s[r]=n(t[r],i))})),s}(e,i,c):n(i,c)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var c=a;e.exports=c},221:function(e,t,i){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===l(e)}function s(e){return"string"==typeof e}function r(e){return"number"==typeof e}function o(e){return"object"==typeof e}function a(e){return null!=e}function c(e){return!e.trim().length}function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}i.r(t),i.d(t,{default:function(){return R}});const h=Object.prototype.hasOwnProperty;class u{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=d(e);t+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function d(e){let t=null,i=null,r=null,o=1;if(s(e)||n(e))r=e,t=p(e),i=f(e);else{if(!h.call(e,"name"))throw new Error("Missing name property in key");const n=e.name;if(r=n,h.call(e,"weight")&&(o=e.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(n));t=p(n),i=f(n)}return{path:t,id:i,weight:o,src:r}}function p(e){return n(e)?e:e.split(".")}function f(e){return n(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx{if(a(e))if(t[u]){const d=e[t[u]];if(!a(d))return;if(u===t.length-1&&(s(d)||r(d)||function(e){return!0===e||!1===e||function(e){return o(e)&&null!==e}(e)&&"[object Boolean]"==l(e)}(d)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(d));else if(n(d)){c=!0;for(let e=0,i=d.length;e{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,s(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();s(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let o=this.getFn(e,t.path);if(a(o))if(n(o)){let e=[];const t=[{nestedArrIndex:-1,value:o}];for(;t.length;){const{nestedArrIndex:i,value:r}=t.pop();if(a(r))if(s(r)&&!c(r)){let t={v:r,i:i,n:this.norm.get(r)};e.push(t)}else n(r)&&r.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[r]=e}else if(!c(o)){let e={v:o,n:this.norm.get(o)};i.$[r]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function _(e,t,{getFn:i=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const s=new g({getFn:i,fieldNormWeight:n});return s.setKeys(e.map(d)),s.setSources(t),s.create(),s}function y(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:s=m.distance,ignoreLocation:r=m.ignoreLocation}={}){const o=t/e.length;if(r)return o;const a=Math.abs(n-i);return s?o+a/s:a?1:o}const E=32;function b(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:b(e),startIndex:t})},h=this.pattern.length;if(h>E){let e=0;const t=h%E,i=h-t;for(;e{const{isMatch:f,score:v,indices:g}=function(e,t,i,{location:n=m.location,distance:s=m.distance,threshold:r=m.threshold,findAllMatches:o=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:c=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(t.length>E)throw new Error("Pattern length exceeds max of 32.");const h=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=r,f=d;const v=a>1||c,g=v?Array(u):[];let _;for(;(_=e.indexOf(t,f))>-1;){let e=y(t,{currentLocation:_,expectedLocation:d,distance:s,ignoreLocation:l});if(p=Math.min(e,p),f=_+h,v){let e=0;for(;e=c;r-=1){let o=r-1,a=i[e.charAt(o)];if(v&&(g[o]=+!!a),_[r]=(_[r+1]<<1|1)&a,n&&(_[r]|=(b[r+1]|b[r])<<1|1|b[r+1]),_[r]&O&&(S=y(t,{errors:n,currentLocation:o,expectedLocation:d,distance:s,ignoreLocation:l}),S<=p)){if(p=S,f=o,f<=d)break;c=Math.max(1,2*d-f)}}if(y(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:l})>p)break;b=_}const C={isMatch:f>=0,score:Math.max(.001,S)};if(v){const e=function(e=[],t=m.minMatchCharLength){let i=[],n=-1,s=-1,r=0;for(let o=e.length;r=t&&i.push([n,s]),n=-1)}return e[r-1]&&r-n>=t&&i.push([n,r-1]),i}(g,a);e.length?c&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:s,threshold:r,findAllMatches:o,minMatchCharLength:a,includeMatches:i,ignoreLocation:c});f&&(u=!0),h+=v,f&&g&&(l=[...l,...g])}));let d={isMatch:u,score:u?h/this.chunks.length:1};return u&&i&&(d.indices=l),d}}class I{constructor(e){this.pattern=e}static isMultiMatch(e){return O(e,this.multiRegex)}static isSingleMatch(e){return O(e,this.singleRegex)}search(){}}function O(e,t){const i=e.match(t);return i?i[1]:null}class C extends I{constructor(e,{location:t=m.location,threshold:i=m.threshold,distance:n=m.distance,includeMatches:s=m.includeMatches,findAllMatches:r=m.findAllMatches,minMatchCharLength:o=m.minMatchCharLength,isCaseSensitive:a=m.isCaseSensitive,ignoreLocation:c=m.ignoreLocation}={}){super(e),this._bitapSearch=new S(e,{location:t,threshold:i,distance:n,includeMatches:s,findAllMatches:r,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class T extends I{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],s=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+s,n.push([t,i-1]);const r=!!n.length;return{isMatch:r,score:r?0:1,indices:n}}}const L=[class extends I{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},T,class extends I{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends I{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends I{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends I{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends I{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},C],w=L.length,A=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/,M=new Set([C.type,T.type]);const P=[];function x(e,t){for(let i=0,n=P.length;i!(!e.$and&&!e.$or),j=e=>({[N]:Object.keys(e).map((t=>({[t]:e[t]})))});function F(e,t,{auto:i=!0}={}){const r=e=>{let a=Object.keys(e);const c=(e=>!!e.$path)(e);if(!c&&a.length>1&&!D(e))return r(j(e));if((e=>!n(e)&&o(e)&&!D(e))(e)){const n=c?e.$path:a[0],r=c?e.$val:e[n];if(!s(r))throw new Error((e=>`Invalid value for key ${e}`)(n));const o={keyId:f(n),pattern:r};return i&&(o.searcher=x(r,t)),o}let l={children:[],operator:a[0]};return a.forEach((t=>{const i=e[t];n(i)&&i.forEach((e=>{l.children.push(r(e))}))})),l};return D(e)||(e=j(e)),r(e)}function k(e,t){const i=e.matches;t.matches=[],a(i)&&i.forEach((e=>{if(!a(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let s={indices:i,value:n};e.key&&(s.key=e.key.src),e.idx>-1&&(s.refIndex=e.idx),t.matches.push(s)}))}function K(e,t){t.score=e.score}class R{constructor(e,t={},i){this.options={...m,...t},this.options.useExtendedSearch,this._keyStore=new u(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof g))throw new Error("Incorrect 'index' type");this._myIndex=t||_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){a(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:s})=>{const r=e?e.weight:null;i*=Math.pow(0===s&&r?Number.EPSILON:s,(r||1)*(t?1:n))})),e.score=i}))}(l,{ignoreFieldNorm:c}),o&&l.sort(a),r(t)&&t>-1&&(l=l.slice(0,t)),function(e,t,{includeMatches:i=m.includeMatches,includeScore:n=m.includeScore}={}){const s=[];return i&&s.push(k),n&&s.push(K),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return s.length&&s.forEach((t=>{t(e,n)})),n}))}(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=x(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:s})=>{if(!a(e))return;const{isMatch:r,score:o,indices:c}=t.searchIn(e);r&&n.push({item:e,idx:i,matches:[{score:o,value:e,norm:s,indices:c}]})})),n}_searchLogical(e){const t=F(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:s}=e,r=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:s});return r&&r.length?[{idx:n,item:t,matches:r}]:[]}const s=[];for(let r=0,o=e.children.length;r{if(a(e)){let o=i(t,e,n);o.length&&(s[n]||(s[n]={idx:n,item:e,matches:[]},r.push(s[n])),o.forEach((({matches:e})=>{s[n].matches.push(...e)})))}})),r}_searchObjectList(e){const t=x(e,this.options),{keys:i,records:n}=this._myIndex,s=[];return n.forEach((({$:e,i:n})=>{if(!a(e))return;let r=[];i.forEach(((i,n)=>{r.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),r.length&&s.push({idx:n,item:e,matches:r})})),s}_findMatches({key:e,value:t,searcher:i}){if(!a(t))return[];let s=[];if(n(t))t.forEach((({v:t,i:n,n:r})=>{if(!a(t))return;const{isMatch:o,score:c,indices:l}=i.searchIn(t);o&&s.push({score:c,key:e,value:t,idx:n,norm:r,indices:l})}));else{const{v:n,n:r}=t,{isMatch:o,score:a,indices:c}=i.searchIn(n);o&&s.push({score:a,key:e,value:n,norm:r,indices:c})}return s}}R.version="6.5.3",R.createIndex=_,R.parseIndex=function(e,{getFn:t=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const{keys:n,records:s}=e,r=new g({getFn:t,fieldNormWeight:i});return r.setKeys(n),r.setIndexRecords(s),r},R.config=m,R.parseQuery=F,function(...e){P.push(...e)}(class{constructor(e,{isCaseSensitive:t=m.isCaseSensitive,includeMatches:i=m.includeMatches,minMatchCharLength:n=m.minMatchCharLength,ignoreLocation:s=m.ignoreLocation,findAllMatches:r=m.findAllMatches,location:o=m.location,threshold:a=m.threshold,distance:c=m.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:r,ignoreLocation:s,location:o,threshold:a,distance:c},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(A).filter((e=>e&&!!e.trim())),n=[];for(let e=0,s=i.length;e=0?this._store.getGroupById(r):null;return this._store.dispatch((0,l.highlightItem)(i,!0)),t&&this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:i,value:o,label:c,groupValue:h&&h.value?h.value:null}),this},e.prototype.unhighlightItem=function(e){if(!e||!e.id)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,r=e.value,s=void 0===r?"":r,o=e.label,a=void 0===o?"":o,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch((0,l.highlightItem)(t,!1)),this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:t,value:s,label:a,groupValue:c&&c.value?c.value:null}),this},e.prototype.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(d.EVENTS.showDropdown,{})})),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent(d.EVENTS.hideDropdown,{})})),this):this},e.prototype.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},e.prototype.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},e.prototype.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement||(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this},e.prototype.setChoices=function(e,t,i,n){var r=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(n&&this.clearChoices(),"function"==typeof e){var s=e(this);if("function"==typeof Promise&&s instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return r._handleLoadingState(!0)})).then((function(){return s})).then((function(e){return r.setChoices(e,t,i,n)})).catch((function(e){r.config.silent||console.error(e)})).then((function(){return r._handleLoadingState(!1)})).then((function(){return r}));if(!Array.isArray(s))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof s));return this.setChoices(s,t,i,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._startLoading(),e.forEach((function(e){if(e.choices)r._addGroup({id:e.id?parseInt("".concat(e.id),10):null,group:e,valueKey:t,labelKey:i});else{var n=e;r._addChoice({value:n[t],label:n[i],isSelected:!!n.selected,isDisabled:!!n.disabled,placeholder:!!n.placeholder,customProperties:n.customProperties})}})),this._stopLoading(),this},e.prototype.clearChoices=function(){return this._store.dispatch((0,a.clearChoices)()),this},e.prototype.clearStore=function(){return this._store.dispatch((0,h.clearAll)()),this},e.prototype.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))),this},e.prototype._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},e.prototype._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,r=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var s=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));s.length>=1&&(r=this._createChoicesFragment(s,r)),r=this._createGroupsFragment(i,n,r)}else n.length>=1&&(r=this._createChoicesFragment(n,r));if(r.childNodes&&r.childNodes.length>0){var o=this._store.activeItems,a=this._canAddItem(o,this.input.value);if(a.response)this.choiceList.append(r),this._highlightChoice();else{var c=this._getTemplate("notice",a.notice);this.choiceList.append(c)}}else{var l=void 0;c=void 0,this._isSearching?(c="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,l=this._getTemplate("notice",c,"no-results")):(c="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,l=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(l)}},e.prototype._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},e.prototype._createGroupsFragment=function(e,t,i){var n=this;return void 0===i&&(i=document.createDocumentFragment()),this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var r=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(r.length>=1){var s=n._getTemplate("choiceGroup",e);i.appendChild(s),n._createChoicesFragment(r,i,!0)}})),i},e.prototype._createChoicesFragment=function(e,t,i){var r=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var s=this.config,o=s.renderSelectedChoices,a=s.searchResultLimit,c=s.renderChoiceLimit,l=this._isSearching?f.sortByScore:this.config.sorter,h=function(e){if("auto"!==o||r._isSelectOneElement||!e.selected){var i=r._getTemplate("choice",e,r.config.itemSelectText);t.appendChild(i)}},u=e;"auto"!==o||this._isSelectOneElement||(u=e.filter((function(e){return!e.selected})));var d=u.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),p=d.placeholderChoices,m=d.normalChoices;(this.config.shouldSort||this._isSearching)&&m.sort(l);var v=u.length,g=this._isSelectOneElement?n(n([],p,!0),m,!0):m;this._isSearching?v=a:c&&c>0&&!i&&(v=c);for(var _=0;_=n){var o=r?this._searchChoices(e):0;this.passedElement.triggerEvent(d.EVENTS.search,{value:e,resultCount:o})}else s&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0)))}},e.prototype._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var r=(0,f.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&r&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},e.prototype._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t==="".concat(i," "))return 0;var r=this._store.searchableChoices,s=t,c=Object.assign(this.config.fuseOptions,{keys:n([],this.config.searchFields,!0),includeMatches:!0}),l=new o.default(r,c).search(s);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,a.filterChoices)(l)),l.length},e.prototype._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this._store.activeItems,n=this.input.isFocussed,r=this.dropdown.isActive,s=this.itemList.hasChildren(),o=String.fromCharCode(t),a=/[^\x00-\x1F]/.test(o),c=d.KEY_CODES.BACK_KEY,l=d.KEY_CODES.DELETE_KEY,h=d.KEY_CODES.ENTER_KEY,u=d.KEY_CODES.A_KEY,p=d.KEY_CODES.ESC_KEY,f=d.KEY_CODES.UP_KEY,m=d.KEY_CODES.DOWN_KEY,v=d.KEY_CODES.PAGE_UP_KEY,g=d.KEY_CODES.PAGE_DOWN_KEY;switch(this._isTextElement||r||!a||(this.showDropdown(),this.input.isFocussed||(this.input.value+=e.key.toLowerCase())),t){case u:return this._onSelectKey(e,s);case h:return this._onEnterKey(e,i,r);case p:return this._onEscapeKey(r);case f:case v:case m:case g:return this._onDirectionKey(e,r);case l:case c:return this._onDeleteKey(e,i,n)}},e.prototype._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,r=this._store.activeItems,s=this._canAddItem(r,n),o=d.KEY_CODES.BACK_KEY,c=d.KEY_CODES.DELETE_KEY;if(this._isTextElement)if(s.notice&&n){var l=this._getTemplate("notice",s.notice);this.dropdown.element.innerHTML=l.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0);else{var h=(i===o||i===c)&&t&&!t.value,u=!this._isTextElement&&this._isSearching,p=this._canSearch&&s.response;h&&u?(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))):p&&this._handleSearch(this.input.rawValue)}this._canSearch=this.config.searchEnabled},e.prototype._onSelectKey=function(e,t){var i=e.ctrlKey,n=e.metaKey;(i||n)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t,i){var n=e.target,r=d.KEY_CODES.ENTER_KEY,s=n&&n.hasAttribute("data-button");if(this._isTextElement&&n&&n.value){var o=this.input.value;this._canAddItem(t,o).response&&(this.hideDropdown(!0),this._addItem({value:o}),this._triggerChange(o),this.clearInput())}if(s&&(this._handleButtonAction(t,n),e.preventDefault()),i){var a=this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));a&&(t[0]&&(t[0].keyCode=r),this._handleChoiceAction(t,a)),e.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),e.preventDefault())},e.prototype._onEscapeKey=function(e){e&&(this.hideDropdown(!0),this.containerOuter.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode,n=e.metaKey,r=d.KEY_CODES.DOWN_KEY,s=d.KEY_CODES.PAGE_UP_KEY,o=d.KEY_CODES.PAGE_DOWN_KEY;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var a=i===r||i===o?1:-1,c="[data-choice-selectable]",l=void 0;if(n||i===o||i===s)l=a>0?this.dropdown.element.querySelector("".concat(c,":last-of-type")):this.dropdown.element.querySelector(c);else{var h=this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));l=h?(0,f.getAdjacentEl)(h,c,a):this.dropdown.element.querySelector(c)}l&&((0,f.isScrolledIntoView)(l,this.choiceList.element,a)||this.choiceList.scrollToChildElement(l,a),this._highlightChoice(l)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){var n=e.target;this._isSelectOneElement||n.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(_&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},e.prototype._onFocus=function(e){var t,i=this,n=e.target;n&&this.containerOuter.element.contains(n)&&((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},e.prototype._onBlur=function(e){var t,i=this,n=e.target;if(n&&this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var r=this._store.activeItems.some((function(e){return e.highlighted}));((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),r&&i.unhighlightAll(),i.hideDropdown(!0))},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.removeFocusState(),(n===i.input.element||n===i.containerOuter.element&&!i._canSearch)&&i.hideDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),i.hideDropdown(!0),r&&i.unhighlightAll())},t)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},e.prototype._onFormReset=function(){this._store.dispatch((0,h.resetTo)(this._initialState))},e.prototype._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(d.EVENTS.highlightChoice,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},e.prototype._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,r=e.choiceId,s=void 0===r?-1:r,o=e.groupId,a=void 0===o?-1:o,c=e.customProperties,h=void 0===c?{}:c,u=e.placeholder,p=void 0!==u&&u,f=e.keyCode,m=void 0===f?-1:f,v="string"==typeof t?t.trim():t,g=this._store.items,_=n||v,y=s||-1,E=a>=0?this._store.getGroupById(a):null,b=g?g.length+1:1;this.config.prependValue&&(v=this.config.prependValue+v.toString()),this.config.appendValue&&(v+=this.config.appendValue.toString()),this._store.dispatch((0,l.addItem)({value:v,label:_,id:b,choiceId:y,groupId:a,customProperties:h,placeholder:p,keyCode:m})),this._isSelectOneElement&&this.removeActiveItems(b),this.passedElement.triggerEvent(d.EVENTS.addItem,{id:b,value:v,label:_,customProperties:h,groupValue:E&&E.value?E.value:null,keyCode:m})},e.prototype._removeItem=function(e){var t=e.id,i=e.value,n=e.label,r=e.customProperties,s=e.choiceId,o=e.groupId,a=o&&o>=0?this._store.getGroupById(o):null;t&&s&&(this._store.dispatch((0,l.removeItem)(t,s)),this.passedElement.triggerEvent(d.EVENTS.removeItem,{id:t,value:i,label:n,customProperties:r,groupValue:a&&a.value?a.value:null}))},e.prototype._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,r=e.isSelected,s=void 0!==r&&r,o=e.isDisabled,c=void 0!==o&&o,l=e.groupId,h=void 0===l?-1:l,u=e.customProperties,d=void 0===u?{}:u,p=e.placeholder,f=void 0!==p&&p,m=e.keyCode,v=void 0===m?-1:m;if(null!=t){var g=this._store.choices,_=n||t,y=g?g.length+1:1,E="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(y);this._store.dispatch((0,a.addChoice)({id:y,groupId:h,elementId:E,value:t,label:_,disabled:c,customProperties:d,placeholder:f,keyCode:v})),s&&this._addItem({value:t,label:_,choiceId:y,customProperties:d,placeholder:f,keyCode:v})}},e.prototype._addGroup=function(e){var t=this,i=e.group,n=e.id,r=e.valueKey,s=void 0===r?"value":r,o=e.labelKey,a=void 0===o?"label":o,l=(0,f.isType)("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),h=n||Math.floor((new Date).valueOf()*Math.random()),u=!!i.disabled&&i.disabled;l?(this._store.dispatch((0,c.addGroup)({value:i.label,id:h,active:!0,disabled:u})),l.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[s],label:(0,f.isType)("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:h,customProperties:e.customProperties,placeholder:e.placeholder})}))):this._store.dispatch((0,c.addGroup)({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},e.prototype._getTemplate=function(e){for(var t,i=[],r=1;r0?this.element.scrollTop+o-r:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t,r=n>1?n:1;this.element.scrollTop=e+r},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t,r=n>1?n:1;this.element.scrollTop=e-r},e.prototype._animateScroll=function(e,t){var i=this,r=n.SCROLLING_SPEED,s=this.element.scrollTop,o=!1;t>0?(this._scrollDown(s,r,e),se&&(o=!0)),o&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}();t.default=r},730:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=i(799),r=function(){function e(e){var t=e.element,i=e.classNames;if(this.element=t,this.classNames=i,!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement))throw new TypeError("Invalid element passed");this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){this.element.classList.add(this.classNames.input),this.element.hidden=!0,this.element.tabIndex=-1;var e=this.element.getAttribute("style");e&&this.element.setAttribute("data-choice-orig-style",e),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){this.element.classList.remove(this.classNames.input),this.element.hidden=!1,this.element.removeAttribute("tabindex");var e=this.element.getAttribute("data-choice-orig-style");e?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",e)):this.element.removeAttribute("style"),this.element.removeAttribute("data-choice"),this.element.value=this.element.value},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){(0,n.dispatchEvent)(this.element,e,t)},e}();t.default=r},541:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,r=t.delimiter,s=e.call(this,{element:i,classNames:n})||this;return s.delimiter=r,s}return r(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),t}(s(i(730)).default);t.default=o},982:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var i=t.element,n=t.classNames,r=t.template,s=e.call(this,{element:i,classNames:n})||this;return s.template=r,s}return r(t,e),Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optionGroups",{get:function(){return Array.from(this.element.getElementsByTagName("OPTGROUP"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return Array.from(this.element.options)},set:function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){return n=e,r=t.template(n),void i.appendChild(r);var n,r})),this.appendDocFragment(i)},enumerable:!1,configurable:!0}),t.prototype.appendDocFragment=function(e){this.element.innerHTML="",this.element.appendChild(e)},t}(s(i(730)).default);t.default=o},883:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.SELECT_MULTIPLE_TYPE=t.SELECT_ONE_TYPE=t.TEXT_TYPE=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=void 0,t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL",RESET_TO:"RESET_TO",SET_IS_LOADING:"SET_IS_LOADING"},t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},t.TEXT_TYPE="text",t.SELECT_ONE_TYPE="select-one",t.SELECT_MULTIPLE_TYPE="select-multiple",t.SCROLLING_SPEED=4},789:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(799);t.DEFAULT_CLASSNAMES={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",selectedState:"is-selected",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"},t.DEFAULT_CONFIG={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilter:null,removeItems:!0,removeItemButton:!1,editItems:!1,allowHTML:!0,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:n.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:t.DEFAULT_CLASSNAMES}},18:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},978:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},948:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},359:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},285:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},533:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},187:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),r(i(18),t),r(i(978),t),r(i(948),t),r(i(359),t),r(i(285),t),r(i(533),t),r(i(287),t),r(i(132),t),r(i(837),t),r(i(598),t),r(i(369),t),r(i(37),t),r(i(47),t),r(i(923),t),r(i(876),t)},287:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},132:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},837:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},598:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},37:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},369:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},47:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},923:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},876:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},799:function(e,t){var i;Object.defineProperty(t,"__esModule",{value:!0}),t.parseCustomProperties=t.diff=t.cloneObject=t.existsInArray=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.wrap=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0,t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.generateChars=function(e){return Array.from({length:e},(function(){return(0,t.getRandomNumber)(0,36).toString(36)})).join("")},t.generateId=function(e,i){var n=e.id||e.name&&"".concat(e.name,"-").concat((0,t.generateChars)(2))||(0,t.generateChars)(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),"".concat(i,"-").concat(n)},t.getType=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.isType=function(e,i){return null!=i&&(0,t.getType)(i)===e},t.wrap=function(e,t){return void 0===t&&(t=document.createElement("div")),e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)),t.appendChild(e)},t.getAdjacentEl=function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),r=e[n];r;){if(r.matches(t))return r;r=r[n]}return r},t.isScrolledIntoView=function(e,t,i){return void 0===i&&(i=1),!!e&&(i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop)},t.sanitise=function(e){return"string"!=typeof e?e:e.replace(/&/g,"&").replace(/>/g,">").replace(/-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(o.choiceId),10)&&(t.selected=!0),t})):e;case"REMOVE_ITEM":var a=n;return a.choiceId&&a.choiceId>-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(a.choiceId),10)&&(t.selected=!1),t})):e;case"FILTER_CHOICES":var c=n;return e.map((function(e){var t=e;return t.active=c.results.some((function(e){var i=e.item,n=e.score;return i.id===t.id&&(t.score=n,!0)})),t}));case"ACTIVATE_CHOICES":var l=n;return e.map((function(e){var t=e;return t.active=l.active,t}));case"CLEAR_CHOICES":return t.defaultState;default:return e}}},871:function(e,t){var i=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,r=0,s=t.length;r0?"treeitem":"option"),Object.assign(E.dataset,{choice:"",id:d,value:p,selectText:i}),g?(E.classList.add(h),E.dataset.choiceDisabled="",E.setAttribute("aria-disabled","true")):(E.classList.add(c),E.dataset.choiceSelectable=""),E},input:function(e,t){var i=e.classNames,n=i.input,r=i.inputCloned,s=Object.assign(document.createElement("input"),{type:"search",name:"search_terms",className:"".concat(n," ").concat(r),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return s.setAttribute("role","textbox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-label",t),s},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,r=document.createElement("div");return r.classList.add(i,n),r.setAttribute("aria-expanded","false"),r},notice:function(e,t,i){var n,r=e.allowHTML,s=e.classNames,o=s.item,a=s.itemChoice,c=s.noResults,l=s.noChoices;void 0===i&&(i="");var h=[o,a];return"no-choices"===i?h.push(l):"no-results"===i&&h.push(c),Object.assign(document.createElement("div"),((n={})[r?"innerHTML":"innerText"]=t,n.className=h.join(" "),n))},option:function(e){var t=e.label,i=e.value,n=e.customProperties,r=e.active,s=e.disabled,o=new Option(t,i,!1,r);return n&&(o.dataset.customProperties="".concat(n)),o.disabled=!!s,o}};t.default=i},996:function(e){var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function r(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,i,c){(c=c||{}).arrayMerge=c.arrayMerge||r,c.isMergeableObject=c.isMergeableObject||t,c.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(i);return l===Array.isArray(e)?l?c.arrayMerge(e,i,c):function(e,t,i){var r={};return i.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=n(e[t],i)})),s(t).forEach((function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&i.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,i)(e[s],t[s],i):r[s]=n(t[s],i))})),r}(e,i,c):n(i,c)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var c=a;e.exports=c},221:function(e,t,i){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===l(e)}function r(e){return"string"==typeof e}function s(e){return"number"==typeof e}function o(e){return"object"==typeof e}function a(e){return null!=e}function c(e){return!e.trim().length}function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}i.r(t),i.d(t,{default:function(){return R}});const h=Object.prototype.hasOwnProperty;class u{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=d(e);t+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function d(e){let t=null,i=null,s=null,o=1,a=null;if(r(e)||n(e))s=e,t=p(e),i=f(e);else{if(!h.call(e,"name"))throw new Error("Missing name property in key");const n=e.name;if(s=n,h.call(e,"weight")&&(o=e.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(n));t=p(n),i=f(n),a=e.getFn}return{path:t,id:i,weight:o,src:s,getFn:a}}function p(e){return n(e)?e:e.split(".")}function f(e){return n(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx{if(a(e))if(t[u]){const d=e[t[u]];if(!a(d))return;if(u===t.length-1&&(r(d)||s(d)||function(e){return!0===e||!1===e||function(e){return o(e)&&null!==e}(e)&&"[object Boolean]"==l(e)}(d)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(d));else if(n(d)){c=!0;for(let e=0,i=d.length;e{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,r(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();r(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let o=t.getFn?t.getFn(e):this.getFn(e,t.path);if(a(o))if(n(o)){let e=[];const t=[{nestedArrIndex:-1,value:o}];for(;t.length;){const{nestedArrIndex:i,value:s}=t.pop();if(a(s))if(r(s)&&!c(s)){let t={v:s,i:i,n:this.norm.get(s)};e.push(t)}else n(s)&&s.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[s]=e}else if(r(o)&&!c(o)){let e={v:o,n:this.norm.get(o)};i.$[s]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function _(e,t,{getFn:i=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const r=new g({getFn:i,fieldNormWeight:n});return r.setKeys(e.map(d)),r.setSources(t),r.create(),r}function y(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:r=m.distance,ignoreLocation:s=m.ignoreLocation}={}){const o=t/e.length;if(s)return o;const a=Math.abs(n-i);return r?o+a/r:a?1:o}const E=32;function b(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:b(e),startIndex:t})},h=this.pattern.length;if(h>E){let e=0;const t=h%E,i=h-t;for(;e{const{isMatch:f,score:v,indices:g}=function(e,t,i,{location:n=m.location,distance:r=m.distance,threshold:s=m.threshold,findAllMatches:o=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:c=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(t.length>E)throw new Error("Pattern length exceeds max of 32.");const h=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=s,f=d;const v=a>1||c,g=v?Array(u):[];let _;for(;(_=e.indexOf(t,f))>-1;){let e=y(t,{currentLocation:_,expectedLocation:d,distance:r,ignoreLocation:l});if(p=Math.min(e,p),f=_+h,v){let e=0;for(;e=c;s-=1){let o=s-1,a=i[e.charAt(o)];if(v&&(g[o]=+!!a),_[s]=(_[s+1]<<1|1)&a,n&&(_[s]|=(b[s+1]|b[s])<<1|1|b[s+1]),_[s]&I&&(S=y(t,{errors:n,currentLocation:o,expectedLocation:d,distance:r,ignoreLocation:l}),S<=p)){if(p=S,f=o,f<=d)break;c=Math.max(1,2*d-f)}}if(y(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:l})>p)break;b=_}const C={isMatch:f>=0,score:Math.max(.001,S)};if(v){const e=function(e=[],t=m.minMatchCharLength){let i=[],n=-1,r=-1,s=0;for(let o=e.length;s=t&&i.push([n,r]),n=-1)}return e[s-1]&&s-n>=t&&i.push([n,s-1]),i}(g,a);e.length?c&&(C.indices=e):C.isMatch=!1}return C}(e,t,d,{location:n+p,distance:r,threshold:s,findAllMatches:o,minMatchCharLength:a,includeMatches:i,ignoreLocation:c});f&&(u=!0),h+=v,f&&g&&(l=[...l,...g])}));let d={isMatch:u,score:u?h/this.chunks.length:1};return u&&i&&(d.indices=l),d}}class O{constructor(e){this.pattern=e}static isMultiMatch(e){return I(e,this.multiRegex)}static isSingleMatch(e){return I(e,this.singleRegex)}search(){}}function I(e,t){const i=e.match(t);return i?i[1]:null}class C extends O{constructor(e,{location:t=m.location,threshold:i=m.threshold,distance:n=m.distance,includeMatches:r=m.includeMatches,findAllMatches:s=m.findAllMatches,minMatchCharLength:o=m.minMatchCharLength,isCaseSensitive:a=m.isCaseSensitive,ignoreLocation:c=m.ignoreLocation}={}){super(e),this._bitapSearch=new S(e,{location:t,threshold:i,distance:n,includeMatches:r,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class T extends O{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],r=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+r,n.push([t,i-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const L=[class extends O{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},T,class extends O{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends O{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},C],w=L.length,A=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,M=new Set([C.type,T.type]);const P=[];function x(e,t){for(let i=0,n=P.length;i!(!e.$and&&!e.$or),j=e=>({[N]:Object.keys(e).map((t=>({[t]:e[t]})))});function F(e,t,{auto:i=!0}={}){const s=e=>{let a=Object.keys(e);const c=(e=>!!e.$path)(e);if(!c&&a.length>1&&!D(e))return s(j(e));if((e=>!n(e)&&o(e)&&!D(e))(e)){const n=c?e.$path:a[0],s=c?e.$val:e[n];if(!r(s))throw new Error((e=>`Invalid value for key ${e}`)(n));const o={keyId:f(n),pattern:s};return i&&(o.searcher=x(s,t)),o}let l={children:[],operator:a[0]};return a.forEach((t=>{const i=e[t];n(i)&&i.forEach((e=>{l.children.push(s(e))}))})),l};return D(e)||(e=j(e)),s(e)}function k(e,t){const i=e.matches;t.matches=[],a(i)&&i.forEach((e=>{if(!a(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let r={indices:i,value:n};e.key&&(r.key=e.key.src),e.idx>-1&&(r.refIndex=e.idx),t.matches.push(r)}))}function K(e,t){t.score=e.score}class R{constructor(e,t={},i){this.options={...m,...t},this.options.useExtendedSearch,this._keyStore=new u(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof g))throw new Error("Incorrect 'index' type");this._myIndex=t||_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){a(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:r})=>{const s=e?e.weight:null;i*=Math.pow(0===r&&s?Number.EPSILON:r,(s||1)*(t?1:n))})),e.score=i}))}(l,{ignoreFieldNorm:c}),o&&l.sort(a),s(t)&&t>-1&&(l=l.slice(0,t)),function(e,t,{includeMatches:i=m.includeMatches,includeScore:n=m.includeScore}={}){const r=[];return i&&r.push(k),n&&r.push(K),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return r.length&&r.forEach((t=>{t(e,n)})),n}))}(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=x(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:r})=>{if(!a(e))return;const{isMatch:s,score:o,indices:c}=t.searchIn(e);s&&n.push({item:e,idx:i,matches:[{score:o,value:e,norm:r,indices:c}]})})),n}_searchLogical(e){const t=F(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:r}=e,s=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:r});return s&&s.length?[{idx:n,item:t,matches:s}]:[]}const r=[];for(let s=0,o=e.children.length;s{if(a(e)){let o=i(t,e,n);o.length&&(r[n]||(r[n]={idx:n,item:e,matches:[]},s.push(r[n])),o.forEach((({matches:e})=>{r[n].matches.push(...e)})))}})),s}_searchObjectList(e){const t=x(e,this.options),{keys:i,records:n}=this._myIndex,r=[];return n.forEach((({$:e,i:n})=>{if(!a(e))return;let s=[];i.forEach(((i,n)=>{s.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),s.length&&r.push({idx:n,item:e,matches:s})})),r}_findMatches({key:e,value:t,searcher:i}){if(!a(t))return[];let r=[];if(n(t))t.forEach((({v:t,i:n,n:s})=>{if(!a(t))return;const{isMatch:o,score:c,indices:l}=i.searchIn(t);o&&r.push({score:c,key:e,value:t,idx:n,norm:s,indices:l})}));else{const{v:n,n:s}=t,{isMatch:o,score:a,indices:c}=i.searchIn(n);o&&r.push({score:a,key:e,value:n,norm:s,indices:c})}return r}}R.version="6.6.2",R.createIndex=_,R.parseIndex=function(e,{getFn:t=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const{keys:n,records:r}=e,s=new g({getFn:t,fieldNormWeight:i});return s.setKeys(n),s.setIndexRecords(r),s},R.config=m,R.parseQuery=F,function(...e){P.push(...e)}(class{constructor(e,{isCaseSensitive:t=m.isCaseSensitive,includeMatches:i=m.includeMatches,minMatchCharLength:n=m.minMatchCharLength,ignoreLocation:r=m.ignoreLocation,findAllMatches:s=m.findAllMatches,location:o=m.location,threshold:a=m.threshold,distance:c=m.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:s,ignoreLocation:r,location:o,threshold:a,distance:c},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(A).filter((e=>e&&!!e.trim())),n=[];for(let e=0,r=i.length;e - +