From e6ebf6045ac0f05d9abf2ea6ca57159528a79d7d Mon Sep 17 00:00:00 2001
From: Xon <635541+Xon@users.noreply.github.com>
Date: Mon, 12 Aug 2024 18:36:54 +0800
Subject: [PATCH] 11.0.0-rc6
---
CHANGELOG.md | 2 +-
package.json | 2 +-
public/assets/scripts/choices.js | 19 +++++++++++--------
public/assets/scripts/choices.min.js | 4 ++--
public/assets/scripts/choices.min.mjs | 4 ++--
public/assets/scripts/choices.mjs | 19 +++++++++++--------
public/assets/scripts/choices.search-basic.js | 19 +++++++++++--------
.../scripts/choices.search-basic.min.js | 4 ++--
.../scripts/choices.search-basic.min.mjs | 4 ++--
.../assets/scripts/choices.search-basic.mjs | 19 +++++++++++--------
.../assets/scripts/choices.search-prefix.js | 19 +++++++++++--------
.../scripts/choices.search-prefix.min.js | 4 ++--
.../scripts/choices.search-prefix.min.mjs | 4 ++--
.../assets/scripts/choices.search-prefix.mjs | 19 +++++++++++--------
.../types/src/scripts/interfaces/store.d.ts | 1 +
public/types/src/scripts/store/store.d.ts | 2 +-
16 files changed, 82 insertions(+), 63 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a11e8c10..712038db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
# Changelog
-## [11.0.0-rc6] (2024-08-)
+## [11.0.0-rc6] (2024-08-12)
### Features
* Improve performance of search/filtering with large number of choices.
diff --git a/package.json b/package.json
index 4ca9dcf4..e37285e6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "choices.js",
- "version": "11.0.0-rc5",
+ "version": "11.0.0-rc6",
"description": "A vanilla JS customisable text input/select box plugin",
"type": "module",
"main": "./public/assets/scripts/choices.js",
diff --git a/public/assets/scripts/choices.js b/public/assets/scripts/choices.js
index f837f450..ec86c533 100644
--- a/public/assets/scripts/choices.js
+++ b/public/assets/scripts/choices.js
@@ -1,4 +1,4 @@
-/*! choices.js v11.0.0-rc5 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
+/*! choices.js v11.0.0-rc6 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1156,10 +1156,15 @@
choices: init,
};
};
- Store.prototype.resetStore = function () {
+ Store.prototype.reset = function () {
this._store = this.defaultState;
var changes = this.changeSet(true);
- this._listeners.forEach(function (l) { return l(changes); });
+ if (this._txn) {
+ this._outstandingChanges = changes;
+ }
+ else {
+ this._listeners.forEach(function (l) { return l(changes); });
+ }
};
Store.prototype.subscribe = function (onChange) {
this._listeners.push(onChange);
@@ -3886,7 +3891,7 @@
return this;
};
Choices.prototype.clearStore = function () {
- this._store.resetStore();
+ this._store.reset();
this._lastAddedChoiceId = 0;
this._lastAddedGroupId = 0;
// @todo integrate with Store
@@ -4669,13 +4674,12 @@
var target = event.target;
var targetWasRemoveButton = target && target.hasAttribute('data-button');
var addedItem = false;
+ event.preventDefault();
if (targetWasRemoveButton) {
- event.preventDefault();
this._handleButtonAction(items, target);
return;
}
if (!hasActiveDropdown && this._isSelectOneElement) {
- event.preventDefault();
this.showDropdown();
return;
}
@@ -4685,7 +4689,6 @@
if (highlightedChoice) {
addedItem = this._handleChoiceAction(items, highlightedChoice, 13 /* KeyCodeMap.ENTER_KEY */);
if (addedItem) {
- event.preventDefault();
this.unhighlightAll();
return;
}
@@ -5255,7 +5258,7 @@
throw new TypeError("".concat(caller, " called for an element which has multiple instances of Choices initialised on it"));
}
};
- Choices.version = '11.0.0-rc5';
+ Choices.version = '11.0.0-rc6';
return Choices;
}());
diff --git a/public/assets/scripts/choices.min.js b/public/assets/scripts/choices.min.js
index 462b4e4f..d7d61b7b 100644
--- a/public/assets/scripts/choices.min.js
+++ b/public/assets/scripts/choices.min.js
@@ -1,2 +1,2 @@
-/*! choices.js v11.0.0-rc5 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=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])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i/g,">").replace(/0?this.element.scrollTop+r-s:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(c,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,n=this.element.scrollTop,s=!1;t>0?(this._scrollDown(n,4,e),ne&&(s=!0)),s&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}(),E=function(){function e(e){var t=e.element,i=e.classNames;this.element=t,this.classNames=i,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.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){var e;(e=this.element.classList).add.apply(e,u(this.classNames.input)),this.element.hidden=!0,this.element.tabIndex=-1;var t=this.element.getAttribute("style");t&&this.element.setAttribute("data-choice-orig-style",t),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){var e;(e=this.element.classList).remove.apply(e,u(this.classNames.input)),this.element.hidden=!1,this.element.removeAttribute("tabindex");var t=this.element.getAttribute("data-choice-orig-style");t?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",t)):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){!function(e,t,i){void 0===i&&(i=null);var n=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});e.dispatchEvent(n)}(this.element,e,t||{})},e}(),C=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i}(E),I=function(e,t){return void 0===t&&(t=!0),void 0===e?t:!!e},S=function(e){if("string"==typeof e&&(e=e.split(" ").filter((function(e){return 0!==e.length}))),Array.isArray(e)&&0!==e.length)return e},w=function(e,t){if("string"==typeof e)return w({value:e,label:e},!1);var i=e;if("choices"in i){if(!t)throw new TypeError("optGroup is not allowed");var n=i,s=n.choices.map((function(e){return w(e,!1)}));return{id:0,label:h(n.label)||n.value,active:0!==s.length,disabled:!!n.disabled,choices:s}}var o=i;return{id:0,groupId:0,score:0,rank:0,value:o.value,label:o.label||o.value,active:I(o.active),selected:I(o.selected,!1),disabled:I(o.disabled,!1),placeholder:I(o.placeholder,!1),highlighted:!1,labelClass:S(o.labelClass),labelDescription:o.labelDescription,customProperties:o.customProperties}},O=function(e){function i(t){var i=t.element,n=t.classNames,s=t.template,o=t.extractPlaceholder,r=e.call(this,{element:i,classNames:n})||this;return r.template=s,r.extractPlaceholder=o,r}return t(i,e),Object.defineProperty(i.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),i.prototype.addOptions=function(e){var t=this;e.forEach((function(e){var i=e;if(!i.element){var n=t.template(i);t.element.appendChild(n),i.element=n}}))},i.prototype.optionsAsChoices=function(){var e=this,t=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach((function(i){!function(e){return"OPTION"===e.tagName}(i)?function(e){return"OPTGROUP"===e.tagName}(i)&&t.push(e._optgroupToChoice(i)):t.push(e._optionToChoice(i))})),t},i.prototype._optionToChoice=function(e){return{id:0,groupId:0,score:0,rank:0,value:e.value,label:e.innerHTML,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(""===e.value||e.hasAttribute("placeholder")),labelClass:void 0!==e.dataset.labelClass?S(e.dataset.labelClass):void 0,labelDescription:void 0!==e.dataset.labelDescription?e.dataset.labelDescription:void 0,customProperties:p(e.dataset.customProperties)}},i.prototype._optgroupToChoice=function(e){var t=this,i=e.querySelectorAll("option"),n=Array.from(i).map((function(e){return t._optionToChoice(e)}));return{id:0,label:e.label||"",element:e,active:0!==n.length,disabled:e.disabled,choices:n}},i}(E),x={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(e){return!!e&&""!==e},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,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:function(e,t){var i=e.value,n=e.label,s=void 0===n?i:n,o=t.value,r=t.label,c=void 0===r?o:r;return h(s).localeCompare(h(c),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},shadowRoot:null,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(e,'"')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(e){return"Remove item: ".concat(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:{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"],description:["choices__description"],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"],addChoice:["choices__item","choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},appendGroupInSearch:!1},A=["fuseOptions","classNames"];var L={groups:function(e,t){var i=e,n=!1;switch(t.type){case"ADD_GROUP":var s=t;n=!0,i.push(s.group);break;case"CLEAR_CHOICES":n=!0,i=[]}return{state:i,update:n}},items:function(e,t){var i=e,n=!1;switch(t.type){case"ADD_ITEM":var s=t.item;if(s.id)s.selected=!0,(o=s.element)&&(o.selected=!0,o.setAttribute("selected","")),n=!0,i.push(s),i.forEach((function(e){e.highlighted=!1}));break;case"REMOVE_ITEM":var o,r=t.item;if(r.id)r.selected=!1,(o=r.element)&&(o.selected=!1,o.removeAttribute("selected")),n=!0,i=i.filter((function(e){return e.id!==r.id}));break;case"REMOVE_CHOICE":var c=t.choice;n=!0,i=i.filter((function(e){return e.id!==c.id}));break;case"HIGHLIGHT_ITEM":var a=t;n=!0,i.forEach((function(e){var t=e;t.id===a.item.id&&(t.highlighted=a.highlighted)}))}return{state:i,update:n}},choices:function(e,t){var i=e,n=!1;switch(t.type){case"ADD_CHOICE":var s=t.choice;i.push(s),n=!0;break;case"REMOVE_CHOICE":var o=t.choice;n=!0,i=i.filter((function(e){return e.id!==o.id}));break;case"ADD_ITEM":(r=t.item).id&&r.selected&&(n=!0);break;case"REMOVE_ITEM":var r;(r=t.item).id&&!r.selected&&(n=!0);break;case"FILTER_CHOICES":var c=t.results;n=!0;var a=[];c.forEach((function(e){a[e.item.id]=e})),i.forEach((function(e){var t=e,i=a[t.id];void 0!==i?(t.score=i.score,t.rank=i.rank,t.active=!0):(t.score=0,t.rank=0,t.active=!1)}));break;case"ACTIVATE_CHOICES":var h=t.active;n=!0,i.forEach((function(e){var t=e;return t.active=h,t}));break;case"CLEAR_CHOICES":n=!0,i=[]}return{state:i,update:n}}},T=function(){function e(){this._store=this.defaultState,this._listeners=[],this._txn=0}return Object.defineProperty(e.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),e.prototype.changeSet=function(e){return{groups:e,items:e,choices:e}},e.prototype.resetStore=function(){this._store=this.defaultState;var e=this.changeSet(!0);this._listeners.forEach((function(t){return t(e)}))},e.prototype.subscribe=function(e){this._listeners.push(e)},e.prototype.dispatch=function(e){var t=this._store,i=!1,n=this._outstandingChanges||this.changeSet(!1);Object.keys(L).forEach((function(s){var o=L[s](t[s],e);o.update&&(i=!0,n[s]=!0,t[s]=o.state)})),i&&(this._txn?this._outstandingChanges=n:this._listeners.forEach((function(e){return e(n)})))},e.prototype.withTxn=function(e){this._txn++;try{e()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var t=this._outstandingChanges;t&&(this._outstandingChanges=void 0,this._listeners.forEach((function(e){return e(t)})))}}},Object.defineProperty(e.prototype,"state",{get:function(){return this._store},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedActiveItems",{get:function(){return this.items.filter((function(e){return!e.disabled&&e.active&&e.highlighted}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeChoices",{get:function(){return this.choices.filter((function(e){return e.active}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"searchableChoices",{get:function(){return this.choices.filter((function(e){return!e.disabled&&!e.placeholder}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeGroups",{get:function(){var e=this;return this.state.groups.filter((function(t){var i=t.active&&!t.disabled,n=e.state.choices.some((function(e){return e.active&&!e.disabled}));return i&&n}),[])},enumerable:!1,configurable:!0}),e.prototype.inTxn=function(){return this._txn>0},e.prototype.getChoiceById=function(e){return this.activeChoices.find((function(t){return t.id===e}))},e.prototype.getGroupById=function(e){return this.groups.find((function(t){return t.id===e}))},e}(),M=function(e,t){return e?function(e){if("string"==typeof e)return e;if("object"==typeof e){if("escaped"in e)return e.escaped;if("trusted"in e)return e.trusted}return""}(t):c(t)},N=function(e,t){if(t){var i=e.dataset;"string"==typeof t?i.customProperties=t:"object"!=typeof t||function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(t)||(i.customProperties=JSON.stringify(t))}},F={containerOuter:function(e,t,i,n,s,o,r){var c=e.classNames.containerOuter,a=Object.assign(document.createElement("div"),{className:u(c).join(" ")});return a.dataset.type=o,t&&(a.dir=t),n&&(a.tabIndex=0),i&&(a.setAttribute("role",s?"combobox":"listbox"),s&&a.setAttribute("aria-autocomplete","list")),a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-expanded","false"),r&&a.setAttribute("aria-labelledby",r),a},containerInner:function(e){var t=e.classNames.containerInner;return Object.assign(document.createElement("div"),{className:u(t).join(" ")})},itemList:function(e,t){var i=e.classNames,n=i.list,s=i.listSingle,o=i.listItems;return Object.assign(document.createElement("div"),{className:"".concat(u(n).join(" ")," ").concat(t?u(s).join(" "):u(o).join(" "))})},placeholder:function(e,t){var i=e.allowHTML,n=e.classNames.placeholder;return Object.assign(document.createElement("div"),{className:u(n).join(" "),innerHTML:M(i,t)})},item:function(e,t,i){var n,s,o,r=e.allowHTML,a=e.removeItemButtonAlignLeft,h=e.classNames,l=h.item,d=h.button,p=h.highlightedState,f=h.itemSelectable,m=h.placeholder,g=t.id,v=t.value,_=t.label,y=t.labelClass,b=t.labelDescription,E=t.customProperties,C=t.active,I=t.disabled,S=t.highlighted,w=t.placeholder,O=Object.assign(document.createElement("div"),{className:u(l).join(" ")});if(y){var x=Object.assign(document.createElement("span"),{innerHTML:M(r,_),className:u(y).join(" ")});O.appendChild(x)}else O.innerHTML=M(r,_);if(Object.assign(O.dataset,{item:"",id:g,value:v}),y&&(O.dataset.labelClass=u(y).join(" ")),b&&(O.dataset.labelDescription=b),N(O,E),C&&O.setAttribute("aria-selected","true"),I&&O.setAttribute("aria-disabled","true"),w&&((n=O.classList).add.apply(n,u(m)),O.dataset.placeholder=""),(s=O.classList).add.apply(s,u(S?p:f)),i){I&&(o=O.classList).remove.apply(o,u(f)),O.dataset.deletable="";var A="function"==typeof this.config.removeItemIconText?this.config.removeItemIconText(c(v),v):this.config.removeItemIconText,L="function"==typeof this.config.removeItemLabelText?this.config.removeItemLabelText(c(v),v):this.config.removeItemLabelText,T=Object.assign(document.createElement("button"),{type:"button",className:u(d).join(" "),innerHTML:A});L&&T.setAttribute("aria-label",L),T.dataset.button="",a?O.insertAdjacentElement("afterbegin",T):O.appendChild(T)}return O},choiceList:function(e,t){var i=e.classNames.list,n=Object.assign(document.createElement("div"),{className:u(i).join(" ")});return t||n.setAttribute("aria-multiselectable","true"),n.setAttribute("role","listbox"),n},choiceGroup:function(e,t){var i=e.allowHTML,n=e.classNames,s=n.group,o=n.groupHeading,r=n.itemDisabled,c=t.id,a=t.label,h=t.disabled,l=Object.assign(document.createElement("div"),{className:"".concat(u(s).join(" ")," ").concat(h?u(r).join(" "):"")});return l.setAttribute("role","group"),Object.assign(l.dataset,{group:"",id:c,value:a}),h&&l.setAttribute("aria-disabled","true"),l.appendChild(Object.assign(document.createElement("div"),{className:u(o).join(" "),innerHTML:M(i,a)})),l},choice:function(e,t,i){var n,s,o,r,c,a=e.allowHTML,h=e.classNames,l=h.item,d=h.itemChoice,p=h.itemSelectable,f=h.selectedState,m=h.itemDisabled,g=h.description,v=h.placeholder,_=t.id,y=t.value,b=t.label,E=t.groupId,C=t.elementId,I=t.labelClass,S=t.labelDescription,w=t.disabled,O=t.selected,x=t.placeholder,A=Object.assign(document.createElement("div"),{id:C,className:"".concat(u(l).join(" ")," ").concat(u(d).join(" "))}),L=A;if(I){var T=Object.assign(document.createElement("span"),{innerHTML:M(a,b),className:u(I).join(" ")});L=T,A.appendChild(T)}else A.innerHTML=M(a,b);if(S){var N="".concat(C,"-description");L.setAttribute("aria-describedby",N);var F=Object.assign(document.createElement("span"),{innerHTML:M(a,S),id:N});(n=F.classList).add.apply(n,u(g)),A.appendChild(F)}return O&&(s=A.classList).add.apply(s,u(f)),x&&(o=A.classList).add.apply(o,u(v)),A.setAttribute("role",E&&E>0?"treeitem":"option"),Object.assign(A.dataset,{choice:"",id:_,value:y,selectText:i}),I&&(A.dataset.labelClass=u(I).join(" ")),S&&(A.dataset.labelDescription=S),w?((r=A.classList).add.apply(r,u(m)),A.dataset.choiceDisabled="",A.setAttribute("aria-disabled","true")):((c=A.classList).add.apply(c,u(p)),A.dataset.choiceSelectable=""),A},input:function(e,t){var i=e.classNames,n=i.input,s=i.inputCloned,o=Object.assign(document.createElement("input"),{type:"search",className:"".concat(u(n).join(" ")," ").concat(u(s).join(" ")),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),t&&o.setAttribute("aria-label",t),o},dropdown:function(e){var t,i,n=e.classNames,s=n.list,o=n.listDropdown,r=document.createElement("div");return(t=r.classList).add.apply(t,u(s)),(i=r.classList).add.apply(i,u(o)),r.setAttribute("aria-expanded","false"),r},notice:function(e,t,i){var s=e.allowHTML,o=e.classNames,r=o.item,c=o.itemChoice,a=o.addChoice,h=o.noResults,l=o.noChoices;void 0===i&&(i="");var d=n(n([],u(r),!0),u(c),!0);switch(i){case"add-choice":d.push.apply(d,u(a));break;case"no-results":d.push.apply(d,u(h));break;case"no-choices":d.push.apply(d,u(l))}var p=Object.assign(document.createElement("div"),{innerHTML:M(s,t),className:d.join(" ")});return"add-choice"===i&&(p.dataset.choiceSelectable="",p.dataset.choice=""),p},option:function(e){var t=e.label,i=e.value,n=e.labelClass,s=e.labelDescription,o=e.customProperties,r=e.active,c=e.disabled,a=h(t),l=new Option(a,i,!1,r);return n&&(l.dataset.labelClass=u(n).join(" ")),s&&(l.dataset.labelDescription=s),N(l,o),l.disabled=c,l}};function D(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function j(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function k(e){for(var t=1;t`Missing ${e} property in key`,z=e=>`Property 'weight' in key '${e}' must be a positive integer`,J=Object.prototype.hasOwnProperty;class X{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=Q(e);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 Q(e){let t=null,i=null,n=null,s=1,o=null;if(K(e)||P(e))n=e,t=Y(e),i=Z(e);else{if(!J.call(e,"name"))throw new Error(G("name"));const r=e.name;if(n=r,J.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(z(r));t=Y(r),i=Z(r),o=e.getFn}return{path:t,id:i,weight:s,src:n,getFn:o}}function Y(e){return P(e)?e:e.split(".")}function Z(e){return P(e)?e.join("."):e}const ee={useExtendedSearch:!1,getFn:function(e,t){let i=[],n=!1;const s=(e,t,o)=>{if(q(e))if(t[o]){const r=e[t[o]];if(!q(r))return;if(o===t.length-1&&(K(r)||V(r)||B(r)))i.push(R(r));else if(P(r)){n=!0;for(let e=0,i=r.length;ee.score===t.score?e.idx{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,K(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();K(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 s=t.getFn?t.getFn(e):this.getFn(e,t.path);if(q(s))if(P(s)){let e=[];const t=[{nestedArrIndex:-1,value:s}];for(;t.length;){const{nestedArrIndex:i,value:n}=t.pop();if(q(n))if(K(n)&&!U(n)){let t={v:n,i:i,n:this.norm.get(n)};e.push(t)}else P(n)&&n.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[n]=e}else if(K(s)&&!U(s)){let e={v:s,n:this.norm.get(s)};i.$[n]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function se(e,t,{getFn:i=te.getFn,fieldNormWeight:n=te.fieldNormWeight}={}){const s=new ne({getFn:i,fieldNormWeight:n});return s.setKeys(e.map(Q)),s.setSources(t),s.create(),s}function oe(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:s=te.distance,ignoreLocation:o=te.ignoreLocation}={}){const r=t/e.length;if(o)return r;const c=Math.abs(n-i);return s?r+c/s:c?1:r}const re=32;function ce(e,t,i,{location:n=te.location,distance:s=te.distance,threshold:o=te.threshold,findAllMatches:r=te.findAllMatches,minMatchCharLength:c=te.minMatchCharLength,includeMatches:a=te.includeMatches,ignoreLocation:h=te.ignoreLocation}={}){if(t.length>re)throw new Error(`Pattern length exceeds max of ${re}.`);const l=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=o,f=d;const m=c>1||a,g=m?Array(u):[];let v;for(;(v=e.indexOf(t,f))>-1;){let e=oe(t,{currentLocation:v,expectedLocation:d,distance:s,ignoreLocation:h});if(p=Math.min(e,p),f=v+l,m){let e=0;for(;e=a;o-=1){let r=o-1,c=i[e.charAt(r)];if(m&&(g[r]=+!!c),C[o]=(C[o+1]<<1|1)&c,n&&(C[o]|=(_[o+1]|_[o])<<1|1|_[o+1]),C[o]&E&&(y=oe(t,{errors:n,currentLocation:r,expectedLocation:d,distance:s,ignoreLocation:h}),y<=p)){if(p=y,f=r,f<=d)break;a=Math.max(1,2*d-f)}}if(oe(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:h})>p)break;_=C}const C={isMatch:f>=0,score:Math.max(.001,y)};if(m){const e=function(e=[],t=te.minMatchCharLength){let i=[],n=-1,s=-1,o=0;for(let r=e.length;o=t&&i.push([n,s]),n=-1)}return e[o-1]&&o-n>=t&&i.push([n,o-1]),i}(g,c);e.length?a&&(C.indices=e):C.isMatch=!1}return C}function ae(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:ae(e),startIndex:t})},l=this.pattern.length;if(l>re){let e=0;const t=l%re,i=l-t;for(;e{const{isMatch:f,score:m,indices:g}=ce(e,t,d,{location:n+p,distance:s,threshold:o,findAllMatches:r,minMatchCharLength:c,includeMatches:i,ignoreLocation:a});f&&(u=!0),l+=m,f&&g&&(h=[...h,...g])}));let d={isMatch:u,score:u?l/this.chunks.length:1};return u&&i&&(d.indices=h),d}}class le{constructor(e){this.pattern=e}static isMultiMatch(e){return ue(e,this.multiRegex)}static isSingleMatch(e){return ue(e,this.singleRegex)}search(){}}function ue(e,t){const i=e.match(t);return i?i[1]:null}class de extends le{constructor(e,{location:t=te.location,threshold:i=te.threshold,distance:n=te.distance,includeMatches:s=te.includeMatches,findAllMatches:o=te.findAllMatches,minMatchCharLength:r=te.minMatchCharLength,isCaseSensitive:c=te.isCaseSensitive,ignoreLocation:a=te.ignoreLocation}={}){super(e),this._bitapSearch=new he(e,{location:t,threshold:i,distance:n,includeMatches:s,findAllMatches:o,minMatchCharLength:r,isCaseSensitive:c,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class pe extends le{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 o=!!n.length;return{isMatch:o,score:o?0:1,indices:n}}}const fe=[class extends le{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]}}},pe,class extends le{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 le{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 le{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 le{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 le{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]}}},de],me=fe.length,ge=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const ve=new Set([de.type,pe.type]);class _e{constructor(e,{isCaseSensitive:t=te.isCaseSensitive,includeMatches:i=te.includeMatches,minMatchCharLength:n=te.minMatchCharLength,ignoreLocation:s=te.ignoreLocation,findAllMatches:o=te.findAllMatches,location:r=te.location,threshold:c=te.threshold,distance:a=te.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:o,ignoreLocation:s,location:r,threshold:c,distance:a},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(ge).filter((e=>e&&!!e.trim())),n=[];for(let e=0,s=i.length;e!(!e[Ee]&&!e[Ce]),Oe=e=>({[Ee]:Object.keys(e).map((t=>({[t]:e[t]})))});function xe(e,t,{auto:i=!0}={}){const n=e=>{let s=Object.keys(e);const o=(e=>!!e[Ie])(e);if(!o&&s.length>1&&!we(e))return n(Oe(e));if((e=>!P(e)&&$(e)&&!we(e))(e)){const n=o?e[Ie]:s[0],r=o?e[Se]:e[n];if(!K(r))throw new Error((e=>`Invalid value for key ${e}`)(n));const c={keyId:Z(n),pattern:r};return i&&(c.searcher=be(r,t)),c}let r={children:[],operator:s[0]};return s.forEach((t=>{const i=e[t];P(i)&&i.forEach((e=>{r.children.push(n(e))}))})),r};return we(e)||(e=Oe(e)),n(e)}function Ae(e,t){const i=e.matches;t.matches=[],q(i)&&i.forEach((e=>{if(!q(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 Le(e,t){t.score=e.score}class Te{constructor(e,t={},i){this.options=k(k({},te),t),this.options.useExtendedSearch,this._keyStore=new X(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof ne))throw new Error("Incorrect 'index' type");this._myIndex=t||se(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){q(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 o=e?e.weight:null;i*=Math.pow(0===s&&o?Number.EPSILON:s,(o||1)*(t?1:n))})),e.score=i}))}(c,{ignoreFieldNorm:r}),s&&c.sort(o),V(t)&&t>-1&&(c=c.slice(0,t)),function(e,t,{includeMatches:i=te.includeMatches,includeScore:n=te.includeScore}={}){const s=[];return i&&s.push(Ae),n&&s.push(Le),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return s.length&&s.forEach((t=>{t(e,n)})),n}))}(c,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=be(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i:i,n:s})=>{if(!q(e))return;const{isMatch:o,score:r,indices:c}=t.searchIn(e);o&&n.push({item:e,idx:i,matches:[{score:r,value:e,norm:s,indices:c}]})})),n}_searchLogical(e){const t=xe(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:s}=e,o=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:s});return o&&o.length?[{idx:n,item:t,matches:o}]:[]}const s=[];for(let o=0,r=e.children.length;o{if(q(e)){let r=i(t,e,n);r.length&&(s[n]||(s[n]={idx:n,item:e,matches:[]},o.push(s[n])),r.forEach((({matches:e})=>{s[n].matches.push(...e)})))}})),o}_searchObjectList(e){const t=be(e,this.options),{keys:i,records:n}=this._myIndex,s=[];return n.forEach((({$:e,i:n})=>{if(!q(e))return;let o=[];i.forEach(((i,n)=>{o.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),o.length&&s.push({idx:n,item:e,matches:o})})),s}_findMatches({key:e,value:t,searcher:i}){if(!q(t))return[];let n=[];if(P(t))t.forEach((({v:t,i:s,n:o})=>{if(!q(t))return;const{isMatch:r,score:c,indices:a}=i.searchIn(t);r&&n.push({score:c,key:e,value:t,idx:s,norm:o,indices:a})}));else{const{v:s,n:o}=t,{isMatch:r,score:c,indices:a}=i.searchIn(s);r&&n.push({score:c,key:e,value:s,norm:o,indices:a})}return n}}Te.version="7.0.0",Te.createIndex=se,Te.parseIndex=function(e,{getFn:t=te.getFn,fieldNormWeight:i=te.fieldNormWeight}={}){const{keys:n,records:s}=e,o=new ne({getFn:t,fieldNormWeight:i});return o.setKeys(n),o.setIndexRecords(s),o},Te.config=te,Te.parseQuery=xe,function(...e){ye.push(...e)}(_e);var Me=function(){function e(e){this._haystack=[],this._fuseOptions=i(i({},e.fuseOptions),{keys:n([],e.searchFields,!0),includeMatches:!0})}return e.prototype.index=function(e){this._haystack=e,this._fuse&&this._fuse.setCollection(e)},e.prototype.reset=function(){this._haystack=[],this._fuse=void 0},e.prototype.isEmptyIndex=function(){return 0===this._haystack.length},e.prototype.search=function(e){return this._fuse||(this._fuse=new Te(this._haystack,this._fuseOptions)),this._fuse.search(e).map((function(e,t){return{item:e.item,score:e.score||0,rank:t}}))},e}();var Ne="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Fe={},De=function(e){if(e){var t=e.dataset.id;return t?parseInt(t,10):void 0}},je=function(){function e(t,n){void 0===t&&(t="[data-choice]"),void 0===n&&(n={});var s=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this.config=i(i(i({},e.defaults.allOptions),e.defaults.options),n),A.forEach((function(t){s.config[t]=i(i(i({},e.defaults.allOptions[t]),e.defaults.options[t]),n[t])})),this.config.silent||this._validateConfig();var o=this.config.shadowRoot||document.documentElement,c="string"==typeof t?o.querySelector(t):t;if(!c||"object"!=typeof c||"INPUT"!==c.tagName&&!function(e){return"SELECT"===e.tagName}(c)){if(!c&&"string"==typeof t)throw TypeError("Selector ".concat(t," failed to find an element"));throw TypeError("Expected one of the following types text|select-one|select-multiple")}if(this._elementType=c.type,this._isTextElement=this._elementType===m,(this._isTextElement||1!==this.config.maxItemCount)&&(this.config.singleModeForMultiSelect=!1),this.config.singleModeForMultiSelect&&(this._elementType=v),this._isSelectOneElement=this._elementType===g,this._isSelectMultipleElement=this._elementType===v,this._isSelectElement=this._isSelectOneElement||this._isSelectMultipleElement,this._canAddUserChoices=this._isTextElement&&this.config.addItems||this._isSelectElement&&this.config.addChoices,["auto","always"].includes("".concat(this.config.renderSelectedChoices))||(this.config.renderSelectedChoices="auto"),this.config.placeholder&&(this.config.placeholderValue?this._hasNonChoicePlaceholder=!0:c.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,this.config.placeholderValue=c.dataset.placeholder)),n.addItemFilter&&"function"!=typeof n.addItemFilter){var a=n.addItemFilter instanceof RegExp?n.addItemFilter:new RegExp(n.addItemFilter);this.config.addItemFilter=a.test.bind(a)}if(this._isTextElement)this.passedElement=new C({element:c,classNames:this.config.classNames});else{var h=c;this.passedElement=new O({element:h,classNames:this.config.classNames,template:function(e){return s._templates.option(e)},extractPlaceholder:this.config.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new T,this._currentValue="",this.config.searchEnabled=!this._isTextElement&&this.config.searchEnabled||this._elementType===v,this._canSearch=this.config.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=function(e,t){var i=e.id||e.name&&"".concat(e.name,"-").concat(r(2))||r(4);return i=i.replace(/(:|\.|\[|\]|,)/g,""),"".concat(t,"-").concat(i)}(this.passedElement.element,"choices-"),this._direction=this.passedElement.dir,!this._direction){var l=window.getComputedStyle(this.passedElement.element).direction;l!==window.getComputedStyle(document.documentElement).direction&&(this._direction=l)}if(this._idNames={itemChoice:"item-choice"},this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive)return this.config.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,void(this.initialisedOK=!1);this.init(),this._initialItems=this._store.items.map((function(e){return e.value}))}return Object.defineProperty(e,"defaults",{get:function(){return Object.preventExtensions({get options(){return Fe},get allOptions(){return x},get templates(){return F}})},enumerable:!1,configurable:!0}),e.prototype.init=function(){if(!this.initialised&&void 0===this.initialisedOK){var e;this._searcher=(e=this.config,new Me(e)),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._initStore(),this._addEventListeners(),(this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||!!this.passedElement.element.closest("fieldset:disabled"))&&this.disable(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;t&&"function"==typeof t&&t.call(this)}},e.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this.clearStore(),this._store._listeners=[],this._stopSearch(),this._templates=F,this.initialised=!1,this.initialisedOK=void 0)},e.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},e.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},e.prototype.highlightItem=function(e,t){if(void 0===t&&(t=!0),!e||!e.id)return this;var i=this._store.choices.find((function(t){return t.id===e.id}));return!i||i.highlighted||(this._store.dispatch(o(i,!0)),t&&this.passedElement.triggerEvent("highlightItem",this._getChoiceForOutput(i))),this},e.prototype.unhighlightItem=function(e,t){if(void 0===t&&(t=!0),!e||!e.id)return this;var i=this._store.choices.find((function(t){return t.id===e.id}));return i&&i.highlighted?(this._store.dispatch(o(i,!1)),t&&this.passedElement.triggerEvent("highlightItem",this._getChoiceForOutput(i)),this):this},e.prototype.highlightAll=function(){var e=this;return this._store.withTxn((function(){e._store.items.forEach((function(t){return e.highlightItem(t)}))})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.withTxn((function(){e._store.items.forEach((function(t){return e.unhighlightItem(t)}))})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.withTxn((function(){t._store.items.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.withTxn((function(){t._store.items.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.withTxn((function(){t._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("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("hideDropdown")})),this):this},e.prototype.getValue=function(e){var t=this;void 0===e&&(e=!1);var i=this._store.items.reduce((function(i,n){var s=e?n.value:t._getChoiceForOutput(n);return i.push(s),i}),[]);return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},e.prototype.setValue=function(e){var t=this;return this.initialisedOK?(this._store.withTxn((function(){e.forEach((function(e){e&&t._addChoice(w(e,!1))}))})),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},e.prototype.setChoiceByValue=function(e){var t=this;return this.initialisedOK?(this._isTextElement||(this._store.withTxn((function(){(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)}))})),this._searcher.reset()),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},e.prototype.setChoices=function(e,t,n,s){var o=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===n&&(n="label"),void 0===s&&(s=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;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(s&&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 o._handleLoadingState(!0)})).then((function(){return r})).then((function(e){return o.setChoices(e,t,n,s)})).catch((function(e){o.config.silent||console.error(e)})).then((function(){return o._handleLoadingState(!1)})).then((function(){return o}));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,n,!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._store.withTxn((function(){var s="value"===t,r="label"===n;e.forEach((function(e){if("choices"in e){var c=e;r||(c=i(i({},c),{label:c[n]})),o._addGroup(w(c,!0))}else{var a=e;r&&s||(a=i(i({},a),{value:a[t],label:a[n]})),o._addChoice(w(a,!1))}}))})),this._searcher.reset(),this},e.prototype.refresh=function(e,t,i){var n=this;return void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),this._isSelectElement?(this._store.withTxn((function(){var s=n.passedElement.optionsAsChoices(),o=n._store.items,r={};i||o.forEach((function(e){e.id&&e.active&&e.selected&&!e.disabled&&(r[e.value]=!0)})),s.forEach((function(e){if(!("choices"in e)){var t=e;i?t.selected=!1:r[t.value]&&(t.selected=!0)}})),n.clearStore(),n._addPredefinedChoices(s,t,e),n._isSearching&&n._searchChoices(n.input.value)})),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a