\n \n ')},containerInner:function(e){return(0,s.strToEl)('\n \n ')},itemList:function(e,t){var n,r=(0,o.default)(e.list,(n={},i(n,e.listSingle,t),i(n,e.listItems,!t),n));return(0,s.strToEl)('\n \n ')},placeholder:function(e,t){return(0,s.strToEl)('\n \n '+t+"\n
\n ")},item:function(e,t,n){var r,a=t.active?'aria-selected="true"':"",c=t.disabled?'aria-disabled="true"':"",l=(0,o.default)(e.item,(r={},i(r,e.highlightedState,t.highlighted),i(r,e.itemSelectable,!t.highlighted),i(r,e.placeholder,t.placeholder),r));if(n){var u;return l=(0,o.default)(e.item,(u={},i(u,e.highlightedState,t.highlighted),i(u,e.itemSelectable,!t.disabled),i(u,e.placeholder,t.placeholder),u)),(0,s.strToEl)('\n \n "+t.label+'\x3c!--\n --\x3e\n
\n ")}return(0,s.strToEl)('\n \n "+t.label+"\n
\n ")},choiceList:function(e,t){var n=t?"":'aria-multiselectable="true"';return(0,s.strToEl)('\n \n
\n ")},choiceGroup:function(e,t){var n=t.disabled?'aria-disabled="true"':"",r=(0,o.default)(e.group,i({},e.itemDisabled,t.disabled));return(0,s.strToEl)('\n \n ")},choice:function(e,t,n){var r,a=t.groupId>0?'role="treeitem"':'role="option"',c=(0,o.default)(e.item,e.itemChoice,(r={},i(r,e.itemDisabled,t.disabled),i(r,e.itemSelectable,!t.disabled),i(r,e.placeholder,t.placeholder),r));return(0,s.strToEl)('\n \n "+t.label+"\n
\n ")},input:function(e){var t=(0,o.default)(e.input,e.inputCloned);return(0,s.strToEl)('\n \n ')},dropdown:function(e){var t=(0,o.default)(e.list,e.listDropdown);return(0,s.strToEl)('\n \n
\n ')},notice:function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=(0,o.default)(e.item,e.itemChoice,(n={},i(n,e.noResults,"no-results"===r),i(n,e.noChoices,"no-choices"===r),n));return(0,s.strToEl)('\n \n '+t+"\n
\n ")},option:function(e){return(0,s.strToEl)('\n \n ")}};t.default=a},function(e,t,n){e.exports=n(35)},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:"[data-choice]",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,e),(0,b.isType)("String",t)){var i=Array.from(document.querySelectorAll(t));if(i.length>1)return this._generateInstances(i,n)}this.config=e._generateConfig(n),["auto","always"].includes(this.config.renderSelectedChoices)||(this.config.renderSelectedChoices="auto");var r=(0,b.isType)("String",t)?document.querySelector(t):t;if(this._isTextElement="text"===r.type,this._isSelectOneElement="select-one"===r.type,this._isSelectMultipleElement="select-multiple"===r.type,this._isSelectElement=this._isSelectOneElement||this._isSelectMultipleElement,this._isTextElement?this.passedElement=new f.WrappedInput({element:r,classNames:this.config.classNames,delimiter:this.config.delimiter}):this._isSelectElement&&(this.passedElement=new f.WrappedSelect({element:r,classNames:this.config.classNames})),!this.passedElement)throw new Error("Could not wrap passed element");if(!0===this.config.shouldSortItems&&this._isSelectOneElement&&!this.config.silent&&console.warn("shouldSortElements: Type of passed element is 'select-one', falling back to false."),this._store=new d.default(this.render),this.initialised=!1,this._currentState={},this._prevState={},this._currentValue="",this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=(0,b.generateId)(this.passedElement.element,"choices-"),this._idNames={itemChoice:"item-choice"},this._presetChoices=this.config.choices,this._presetItems=this.config.items,this.passedElement.value&&(this._presetItems=this._presetItems.concat(this.passedElement.value.split(this.config.delimiter))),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._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),"active"===this.passedElement.element.getAttribute("data-choice"))return!1;this.init()}return c(e,[{key:"init",value:function(){if(!this.initialised){this.initialised=!0,this._createTemplates(),this._createElements(),this._createStructure(),this._store.subscribe(this.render),this.render(),this._addEventListeners();var e=this.config.callbackOnInit;e&&(0,b.isType)("Function",e)&&e.call(this)}}},{key:"destroy",value:function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._isSelectElement&&(this.passedElement.options=this._presetChoices),this.clearStore(),this.config.templates=null,this.initialised=!1)}},{key:"enable",value:function(){return this.initialised?(this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this):this}},{key:"disable",value:function(){return this.initialised?(this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this):this}},{key:"render",value:function(){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,n=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),n&&this._renderItems(),this._prevState=this._currentState)}},{key:"highlightItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e)return this;var n=e.id,i=e.groupId,r=void 0===i?-1:i,o=e.value,s=void 0===o?"":o,a=e.label,c=void 0===a?"":a,l=r>=0?this._store.getGroupById(r):null;return this._store.dispatch((0,g.highlightItem)(n,!0)),t&&this.passedElement.triggerEvent(p.EVENTS.highlightItem,{id:n,value:s,label:c,groupValue:l&&l.value?l.value:null}),this}},{key:"unhighlightItem",value:function(e){if(!e)return this;var t=e.id,n=e.groupId,i=void 0===n?-1:n,r=e.value,o=void 0===r?"":r,s=e.label,a=void 0===s?"":s,c=i>=0?this._store.getGroupById(i):null;return this._store.dispatch((0,g.highlightItem)(t,!1)),this.passedElement.triggerEvent(p.EVENTS.highlightItem,{id:t,value:o,label:a,groupValue:c&&c.value?c.value:null}),this}},{key:"highlightAll",value:function(){var e=this;return this._store.items.forEach(function(t){return e.highlightItem(t)}),this}},{key:"unhighlightAll",value:function(){var e=this;return this._store.items.forEach(function(t){return e.unhighlightItem(t)}),this}},{key:"removeActiveItemsByValue",value:function(e){var t=this;return this._store.activeItems.filter(function(t){return t.value===e}).forEach(function(e){return t._removeItem(e)}),this}},{key:"removeActiveItems",value:function(e){var t=this;return this._store.activeItems.filter(function(t){return t.id!==e}).forEach(function(e){return t._removeItem(e)}),this}},{key:"removeHighlightedItems",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._store.highlightedActiveItems.forEach(function(n){e._removeItem(n),t&&e._triggerChange(n.value)}),this}},{key:"showDropdown",value:function(e){var t=this;return this.dropdown.isActive?this:(requestAnimationFrame(function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow()),e&&t.config.searchEnabled&&t.input.focus(),t.passedElement.triggerEvent(p.EVENTS.showDropdown,{})}),this)}},{key:"hideDropdown",value:function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame(function(){t.dropdown.hide(),t.containerOuter.close(),e&&t.config.searchEnabled&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent(p.EVENTS.hideDropdown,{})}),this):this}},{key:"toggleDropdown",value:function(){return this.dropdown.isActive?this.hideDropdown():this.showDropdown(!0),this}},{key:"getValue",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this._store.activeItems.reduce(function(t,n){var i=e?n.value:n;return t.push(i),t},[]);return this._isSelectOneElement?t[0]:t}},{key:"setValue",value:function(e){var t=this;return this.initialised?([].concat(o(e)).forEach(function(e){return t._setChoiceOrItem(e)}),this):this}},{key:"setChoiceByValue",value:function(e){var t=this;return!this.initialised||this._isTextElement?this:(((0,b.isType)("Array",e)?e:[e]).forEach(function(e){return t._findAndSelectChoiceByValue(e)}),this)}},{key:"setChoices",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!this._isSelectElement||!e.length||!t)return this;r&&this._clearChoices(),this.containerOuter.removeLoadingState();var o=function(e){e.choices?n._addGroup(e,e.id||null,t,i):n._addChoice(e[t],e[i],e.selected,e.disabled,void 0,e.customProperties,e.placeholder)};return e.forEach(o),this}},{key:"clearStore",value:function(){return this._store.dispatch((0,_.clearAll)()),this}},{key:"clearInput",value:function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this.config.searchEnabled&&(this._isSearching=!1,this._store.dispatch((0,m.activateChoices)(!0))),this}},{key:"ajax",value:function(e){var t=this;return this.initialised&&this._isSelectElement&&e?(requestAnimationFrame(function(){return t._handleLoadingState(!0)}),e(this._ajaxCallback()),this):this}},{key:"_createGroupsFragment",value:function(e,t,n){var i=this,r=n||document.createDocumentFragment(),o=function(e){return t.filter(function(t){return i._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===i.config.renderSelectedChoices||!t.selected)})};return this.config.shouldSort&&e.sort(this.config.sortFn),e.forEach(function(e){var t=o(e);if(t.length>=1){var n=i._getTemplate("choiceGroup",e);r.appendChild(n),i._createChoicesFragment(t,r,!0)}}),r}},{key:"_createChoicesFragment",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=t||document.createDocumentFragment(),s=this.config,a=s.renderSelectedChoices,c=s.searchResultLimit,l=s.renderChoiceLimit,u=this._isSearching?b.sortByScore:this.config.sortFn,h=e;"auto"!==a||this._isSelectOneElement||(h=e.filter(function(e){return!e.selected}));var d=h.reduce(function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e},{placeholderChoices:[],normalChoices:[]}),f=d.placeholderChoices,p=d.normalChoices;(this.config.shouldSort||this._isSearching)&&p.sort(u);var v=h.length,m=[].concat(o(f),o(p));this._isSearching?v=c:l>0&&!i&&(v=l);for(var g=0;g1&&void 0!==arguments[1]?arguments[1]:null,i=this.config,r=i.shouldSortItems,o=i.sortFn,s=i.removeItemButton,a=n||document.createDocumentFragment();r&&!this._isSelectOneElement&&e.sort(o),this._isTextElement?this.passedElement.value=e:this.passedElement.options=e;var c=function(e){var n=t._getTemplate("item",e,s);a.appendChild(n)};return e.forEach(function(e){return c(e)}),a}},{key:"_triggerChange",value:function(e){void 0!==e&&null!==e&&this.passedElement.triggerEvent(p.EVENTS.change,{value:e})}},{key:"_selectPlaceholderChoice",value:function(){var e=this._store.placeholderChoice;e&&(this._addItem(e.value,e.label,e.id,e.groupId,null,e.placeholder),this._triggerChange(e.value))}},{key:"_handleButtonAction",value:function(e,t){if(e&&t&&this.config.removeItems&&this.config.removeItemButton){var n=t.parentNode.getAttribute("data-id"),i=e.find(function(e){return e.id===parseInt(n,10)});this._removeItem(i),this._triggerChange(i.value),this._isSelectOneElement&&this._selectPlaceholderChoice()}}},{key:"_handleItemAction",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e&&t&&this.config.removeItems&&!this._isSelectOneElement){var r=t.getAttribute("data-id");e.forEach(function(e){e.id!==parseInt(r,10)||e.highlighted?!i&&e.highlighted&&n.unhighlightItem(e):n.highlightItem(e)}),this.input.focus()}}},{key:"_handleChoiceAction",value:function(e,t){if(e&&t){var n=t.getAttribute("data-id"),i=this._store.getChoiceById(n),r=e[0]&&e[0].keyCode?e[0].keyCode:null,o=this.dropdown.isActive;if(i.keyCode=r,this.passedElement.triggerEvent(p.EVENTS.choice,{choice:i}),i&&!i.selected&&!i.disabled){this._canAddItem(e,i.value).response&&(this._addItem(i.value,i.label,i.id,i.groupId,i.customProperties,i.placeholder,i.keyCode),this._triggerChange(i.value))}this.clearInput(),o&&this._isSelectOneElement&&(this.hideDropdown(),this.containerOuter.focus())}}},{key:"_handleBackspace",value:function(e){if(this.config.removeItems&&e){var t=e[e.length-1],n=e.some(function(e){return e.highlighted});this.config.editItems&&!n&&t?(this.input.value=t.value,this.input.setWidth(),this._removeItem(t),this._triggerChange(t.value)):(n||this.highlightItem(t,!1),this.removeHighlightedItems(!0))}}},{key:"_handleLoadingState",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.itemList.getChild("."+this.config.classNames.placeholder);e?(this.containerOuter.addLoadingState(),this._isSelectOneElement?t?t.innerHTML=this.config.loadingText:(t=this._getTemplate("placeholder",this.config.loadingText),this.itemList.append(t)):this.input.placeholder=this.config.loadingText):(this.containerOuter.removeLoadingState(),this._isSelectOneElement?t.innerHTML=this._placeholderValue||"":this.input.placeholder=this._placeholderValue||"")}},{key:"_canAddItem",value:function(e,t){var n=!0,i=(0,b.isType)("Function",this.config.addItemText)?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var r=!(0,b.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(n=!1,i=(0,b.isType)("Function",this.config.maxItemText)?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),this.config.regexFilter&&this._isTextElement&&this.config.addItems&&n&&(n=(0,b.regexFilter)(t,this.config.regexFilter)),this.config.duplicateItems||r||!n||(n=!1,i=(0,b.isType)("Function",this.config.uniqueItemText)?this.config.uniqueItemText(t):this.config.uniqueItemText)}return{response:n,notice:i}}},{key:"_ajaxCallback",value:function(){var e=this;return function(t,n,i){if(t&&n){var r=(0,b.isType)("Object",t)?[t]:t;r&&(0,b.isType)("Array",r)&&r.length?(e._handleLoadingState(!1),r.forEach(function(t){if(t.choices){var r=t.id||null;e._addGroup(t,r,n,i)}else e._addChoice((0,b.fetchFromObject)(t,n),(0,b.fetchFromObject)(t,i),t.selected,t.disabled,void 0,t.customProperties,t.placeholder)}),e._isSelectOneElement&&e._selectPlaceholderChoice()):e._handleLoadingState(!1)}}}},{key:"_searchChoices",value:function(e){var t=(0,b.isType)("String",e)?e.trim():e,n=(0,b.isType)("String",this._currentValue)?this._currentValue.trim():this._currentValue;if(t.length<1&&t===n+" ")return 0;var i=this._store.searchableChoices,r=t,o=(0,b.isType)("Array",this.config.searchFields)?this.config.searchFields:[this.config.searchFields],s=Object.assign(this.config.fuseOptions,{keys:o}),a=new u.default(i,s),c=a.search(r);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,m.filterChoices)(c)),c.length}},{key:"_handleSearch",value:function(e){if(e&&this.input.isFocussed){var t=this._store.choices,n=this.config,i=n.searchFloor,r=n.searchChoices,o=t.some(function(e){return!e.active});if(e&&e.length>=i){var s=r?this._searchChoices(e):0;this.passedElement.triggerEvent(p.EVENTS.search,{value:e,resultCount:s})}else o&&(this._isSearching=!1,this._store.dispatch((0,m.activateChoices)(!0)))}}},{key:"_addEventListeners",value:function(){document.addEventListener("keyup",this._onKeyUp),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("click",this._onClick),document.addEventListener("touchmove",this._onTouchMove),document.addEventListener("touchend",this._onTouchEnd),document.addEventListener("mousedown",this._onMouseDown),document.addEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.addEventListener("focus",this._onFocus),this.containerOuter.element.addEventListener("blur",this._onBlur)),this.input.element.addEventListener("focus",this._onFocus),this.input.element.addEventListener("blur",this._onBlur),this.input.addEventListeners()}},{key:"_removeEventListeners",value:function(){document.removeEventListener("keyup",this._onKeyUp),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("click",this._onClick),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),document.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.removeEventListeners()}},{key:"_onKeyDown",value:function(e){var t,n=this,i=e.target,o=e.keyCode,s=e.ctrlKey,a=e.metaKey;if(i===this.input.element||this.containerOuter.element.contains(i)){var c=this._store.activeItems,l=this.input.isFocussed,u=this.dropdown.isActive,h=this.itemList.hasChildren,d=String.fromCharCode(o),f=p.KEY_CODES.BACK_KEY,v=p.KEY_CODES.DELETE_KEY,m=p.KEY_CODES.ENTER_KEY,g=p.KEY_CODES.A_KEY,y=p.KEY_CODES.ESC_KEY,_=p.KEY_CODES.UP_KEY,E=p.KEY_CODES.DOWN_KEY,S=p.KEY_CODES.PAGE_UP_KEY,O=p.KEY_CODES.PAGE_DOWN_KEY,I=s||a;!this._isTextElement&&/[a-zA-Z0-9-_ ]/.test(d)&&this.showDropdown(!0),this.config.searchEnabled=this.config.searchEnabled;var w=function(){I&&h&&(n.config.searchEnabled=!1,n.config.removeItems&&!n.input.value&&n.input.element===document.activeElement&&n.highlightAll())},C=function(){if(n._isTextElement&&i.value){var t=n.input.value;n._canAddItem(c,t).response&&(n.hideDropdown(),n._addItem(t),n._triggerChange(t),n.clearInput())}if(i.hasAttribute("data-button")&&(n._handleButtonAction(c,i),e.preventDefault()),u){e.preventDefault();var r=n.dropdown.getChild("."+n.config.classNames.highlightedState);r&&(c[0]&&(c[0].keyCode=m),n._handleChoiceAction(c,r))}else n._isSelectOneElement&&(n.showDropdown(!0),e.preventDefault())},T=function(){u&&(n.hideDropdown(),n.containerOuter.focus())},A=function(){if(u||n._isSelectOneElement){n.showDropdown(!0),n.config.searchEnabled=!1;var t=o===E||o===O?1:-1,i=a||o===O||o===S,r=void 0;if(i)r=t>0?Array.from(n.dropdown.element.querySelectorAll("[data-choice-selectable]")).pop():n.dropdown.element.querySelector("[data-choice-selectable]");else{var s=n.dropdown.element.querySelector("."+n.config.classNames.highlightedState);r=s?(0,b.getAdjacentEl)(s,"[data-choice-selectable]",t):n.dropdown.element.querySelector("[data-choice-selectable]")}r&&((0,b.isScrolledIntoView)(r,n.choiceList.element,t)||n.choiceList.scrollToChoice(r,t),n._highlightChoice(r)),e.preventDefault()}},k=function(){!l||i.value||n._isSelectOneElement||(n._handleBackspace(c),e.preventDefault())},x=(t={},r(t,g,w),r(t,m,C),r(t,y,T),r(t,_,A),r(t,S,A),r(t,E,A),r(t,O,A),r(t,v,k),r(t,f,k),t);x[o]&&x[o]()}}},{key:"_onKeyUp",value:function(e){var t=e.target,n=e.keyCode;if(t===this.input.element){var i=this.input.value,r=this._store.activeItems,o=this._canAddItem(r,i);if(this._isTextElement)if(i){if(o.notice){var s=this._getTemplate("notice",o.notice);this.dropdown.element.innerHTML=s.outerHTML}!0===o.response?this.showDropdown():o.notice||this.hideDropdown()}else this.hideDropdown();else{var a=p.KEY_CODES.BACK_KEY,c=p.KEY_CODES.DELETE_KEY;n!==a&&n!==c||t.value?this.config.searchEnabled&&o.response&&this._handleSearch(this.input.value):!this._isTextElement&&this._isSearching&&(this._isSearching=!1,this._store.dispatch((0,m.activateChoices)(!0)))}this.config.searchEnabled=this.config.searchEnabled}}},{key:"_onTouchMove",value:function(){!0===this._wasTap&&(this._wasTap=!1)}},{key:"_onTouchEnd",value:function(e){var t=e.target||e.touches[0].target;!0===this._wasTap&&this.containerOuter.element.contains(t)&&(t!==this.containerOuter.element&&t!==this.containerInner.element||this._isSelectOneElement||(this._isTextElement?this.input.focus():this.showDropdown(!0)),e.stopPropagation()),this._wasTap=!0}},{key:"_onMouseDown",value:function(e){var t=e.target,n=e.shiftKey;if(t===this.choiceList&&(0,b.isIE11)()&&(this._isScrollingOnIe=!0),this.containerOuter.element.contains(t)&&t!==this.input.element){var i=this._store.activeItems,r=n,o=(0,b.findAncestorByAttrName)(t,"data-button"),s=(0,b.findAncestorByAttrName)(t,"data-item"),a=(0,b.findAncestorByAttrName)(t,"data-choice");o?this._handleButtonAction(i,o):s?this._handleItemAction(i,s,r):a&&this._handleChoiceAction(i,a),e.preventDefault()}}},{key:"_onMouseOver",value:function(e){var t=e.target;(t===this.dropdown||this.dropdown.element.contains(t))&&t.hasAttribute("data-choice")&&this._highlightChoice(t)}},{key:"_onClick",value:function(e){var t=e.target,n=this.dropdown.isActive,i=this._store.activeItems;if(this.containerOuter.element.contains(t))n?this._isSelectOneElement&&t!==this.input.element&&!this.dropdown.element.contains(t)&&this.hideDropdown(!0):this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():this.config.searchEnabled?this.showDropdown(!0):(this.showDropdown(),this.containerOuter.focus());else{i.some(function(e){return e.highlighted})&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown()}}},{key:"_onFocus",value:function(e){var t=this,n=e.target;if(this.containerOuter.element.contains(n)){({text:function(){n===t.input.element&&t.containerOuter.addFocusState()},"select-one":function(){t.containerOuter.addFocusState(),n===t.input.element&&t.showDropdown()},"select-multiple":function(){n===t.input.element&&(t.containerOuter.addFocusState(),t.showDropdown(!0))}})[this.passedElement.element.type]()}}},{key:"_onBlur",value:function(e){var t=this,n=e.target;if(this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var i=this._store.activeItems,r=i.some(function(e){return e.highlighted});({text:function(){n===t.input.element&&(t.containerOuter.removeFocusState(),r&&t.unhighlightAll(),t.hideDropdown())},"select-one":function(){t.containerOuter.removeFocusState(),(n===t.input.element||n===t.containerOuter.element&&!t.config.searchEnabled)&&t.hideDropdown()},"select-multiple":function(){n===t.input.element&&(t.containerOuter.removeFocusState(),t.hideDropdown(),r&&t.unhighlightAll())}})[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()}},{key:"_highlightChoice",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(n.length){var i=t,r=Array.from(this.dropdown.element.querySelectorAll("."+this.config.classNames.highlightedState)),o=this.dropdown.isActive;r.forEach(function(t){t.classList.remove(e.config.classNames.highlightedState),t.setAttribute("aria-selected","false")}),i?this._highlightPosition=n.indexOf(i):(i=n.length>this._highlightPosition?n[this._highlightPosition]:n[n.length-1])||(i=n[0]),i.classList.add(this.config.classNames.highlightedState),i.setAttribute("aria-selected","true"),o&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}}},{key:"_addItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,a=(0,b.isType)("String",e)?e.trim():e,c=s,l=r,u=this._store.items,h=t||a,d=parseInt(n,10)||-1,f=i>=0?this._store.getGroupById(i):null,v=u?u.length+1:1;return this.config.prependValue&&(a=this.config.prependValue+a.toString()),this.config.appendValue&&(a+=this.config.appendValue.toString()),this._store.dispatch((0,g.addItem)(a,h,v,d,i,r,o,c)),this._isSelectOneElement&&this.removeActiveItems(v),f&&f.value?this.passedElement.triggerEvent(p.EVENTS.addItem,{id:v,value:a,label:h,customProperties:l,groupValue:f.value,keyCode:c}):this.passedElement.triggerEvent(p.EVENTS.addItem,{id:v,value:a,label:h,customProperties:l,keyCode:c}),this}},{key:"_removeItem",value:function(e){if(!e||!(0,b.isType)("Object",e))return this;var t=e.id,n=e.value,i=e.label,r=e.choiceId,o=e.groupId,s=o>=0?this._store.getGroupById(o):null;return this._store.dispatch((0,g.removeItem)(t,r)),s&&s.value?this.passedElement.triggerEvent(p.EVENTS.removeItem,{id:t,value:n,label:i,groupValue:s.value}):this.passedElement.triggerEvent(p.EVENTS.removeItem,{id:t,value:n,label:i}),this}},{key:"_addChoice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=arguments.length>6&&void 0!==arguments[6]&&arguments[6],a=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;if(void 0!==e&&null!==e){var c=this._store.choices,l=t||e,u=c?c.length+1:1,h=this._baseId+"-"+this._idNames.itemChoice+"-"+u;this._store.dispatch((0,m.addChoice)(e,l,u,r,i,h,o,s,a)),n&&this._addItem(e,l,u,void 0,o,s,a)}}},{key:"_clearChoices",value:function(){this._store.dispatch((0,m.clearChoices)())}},{key:"_addGroup",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"value",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"label",o=(0,b.isType)("Object",e)?e.choices:Array.from(e.getElementsByTagName("OPTION")),s=t||Math.floor((new Date).valueOf()*Math.random()),a=!!e.disabled&&e.disabled;if(o){this._store.dispatch((0,y.addGroup)(e.label,s,!0,a));var c=function(e){var t=e.disabled||e.parentNode&&e.parentNode.disabled;n._addChoice(e[i],(0,b.isType)("Object",e)?e[r]:e.innerHTML,e.selected,t,s,e.customProperties,e.placeholder)};o.forEach(c)}else this._store.dispatch((0,y.addGroup)(e.label,e.id,!1,e.disabled))}},{key:"_getTemplate",value:function(e){var t;if(!e)return null;for(var n=this.config,i=n.templates,r=n.classNames,o=arguments.length,s=Array(o>1?o-1:0),a=1;a=1&&!this._isSearching){var r=n.filter(function(e){return!0===e.placeholder&&-1===e.groupId});r.length>=1&&(i=this._createChoicesFragment(r,i)),i=this._createGroupsFragment(t,n,i)}else n.length>=1&&(i=this._createChoicesFragment(n,i));if(i.childNodes&&i.childNodes.length>0){var o=this._store.activeItems,s=this._canAddItem(o,this.input.value);s.response?(this.choiceList.append(i),this._highlightChoice()):this.choiceList.append(this._getTemplate("notice",s.notice))}else{var a=void 0,c=void 0;this._isSearching?(c=(0,b.isType)("Function",this.config.noResultsText)?this.config.noResultsText():this.config.noResultsText,a=this._getTemplate("notice",c,"no-results")):(c=(0,b.isType)("Function",this.config.noChoicesText)?this.config.noChoicesText():this.config.noChoicesText,a=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(a)}}},{key:"_renderItems",value:function(){var e=this._store.activeItems||[];if(this.itemList.clear(),e.length){var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)}}}],[{key:"_generateConfig",value:function(t){var n=a({},p.DEFAULT_CONFIG,{items:[],choices:[],classNames:p.DEFAULT_CLASSNAMES,sortFn:b.sortByAlpha});return(0,b.extend)(n,e.userDefaults,t)}}]),e}();E.userDefaults={},e.exports=E},function(e,t,n){!function(t,n){e.exports=n()}(0,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,n){"use strict";e.exports=function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;nn)return o(e,this.pattern,i);var r=this.options,a=r.location,c=r.distance,l=r.threshold,u=r.findAllMatches,h=r.minMatchCharLength;return s(e,this.pattern,this.patternAlphabet,{location:a,distance:c,threshold:l,findAllMatches:u,minMatchCharLength:h})}}]),e}();e.exports=c},function(e,t,n){"use strict";var i=n(0),r=function e(t,n,r){if(n){var o=n.indexOf("."),s=n,a=null;-1!==o&&(s=n.slice(0,o),a=n.slice(o+1));var c=t[s];if(null!==c&&void 0!==c)if(a||"string"!=typeof c&&"number"!=typeof c)if(i(c))for(var l=0,u=c.length;l0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=[],i=-1,r=-1,o=0,s=e.length;o=t&&n.push([i,r]),i=-1)}return e[o-1]&&o-i>=t&&n.push([i,o-1]),n}},function(e,t,n){"use strict";e.exports=function(e){for(var t={},n=e.length,i=0;i2&&void 0!==arguments[2]?arguments[2]:/ +/g,r=new RegExp(t.replace(i,"\\$&").replace(n,"|")),o=e.match(r),s=!!o,a=[];if(s)for(var c=0,l=o.length;c=P;M-=1){var N=M-1,F=n[e.charAt(N)];if(F&&(E[N]=1),D[M]=(D[M+1]<<1|1)&F,0!==k&&(D[M]|=(w[M+1]|w[M])<<1|1|w[M+1]),D[M]&A&&(C=i(t,{errors:k,currentLocation:N,expectedLocation:m,distance:l}))<=y){if(y=C,(_=N)<=m)break;P=Math.max(1,2*m-_)}}if(i(t,{errors:k+1,currentLocation:m,expectedLocation:m,distance:l})>y)break;w=D}return{isMatch:_>=0,score:0===C?.001:C,matchedIndices:r(E,v)}}},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",t=[];if(this.options.tokenize)for(var n=e.split(this.options.tokenSeparator),i=0,r=n.length;i0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],n=this.list,i={},r=[];if("string"==typeof n[0]){for(var o=0,s=n.length;o1)throw new Error("Key weight has to be > 0 and <= 1");f=f.name}else a[f]={weight:1};this._analyze({key:f,value:this.options.getFn(u,f),record:u,index:c},{resultMap:i,results:r,tokenSearchers:e,fullSearcher:t})}return{weights:a,results:r}}},{key:"_analyze",value:function(e,t){var n=e.key,i=e.arrayIndex,r=void 0===i?-1:i,o=e.value,s=e.record,c=e.index,l=t.tokenSearchers,u=void 0===l?[]:l,h=t.fullSearcher,d=void 0===h?[]:h,f=t.resultMap,p=void 0===f?{}:f,v=t.results,m=void 0===v?[]:v;if(void 0!==o&&null!==o){var g=!1,y=-1,_=0;if("string"==typeof o){this._log("\nKey: "+(""===n?"-":n));var b=d.search(o);if(this._log('Full text: "'+o+'", score: '+b.score),this.options.tokenize){for(var E=o.split(this.options.tokenSeparator),S=[],O=0;O-1&&(P=(P+y)/2),this._log("Score average:",P);var j=!this.options.tokenize||!this.options.matchAllTokens||_>=u.length;if(this._log("\nCheck Matches: "+j),(g||b.isMatch)&&j){var D=p[c];D?D.output.push({key:n,arrayIndex:r,value:o,score:P,matchedIndices:b.matchedIndices}):(p[c]={item:s,output:[{key:n,arrayIndex:r,value:o,score:P,matchedIndices:b.matchedIndices}]},m.push(p[c]))}}else if(a(o))for(var M=0,N=o.length;M-1&&(s.arrayIndex=o.arrayIndex),t.matches.push(s)}}}),this.options.includeScore&&n.push(function(e,t){t.score=e.score});for(var i=0,r=e.length;i=t.length?{value:void 0,done:!0}:(e=i(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){var i=n(10),r=n(11);e.exports=function(e){return function(t,n){var o,s,a=String(r(t)),c=i(n),l=a.length;return c<0||c>=l?e?"":void 0:(o=a.charCodeAt(c),o<55296||o>56319||c+1===l||(s=a.charCodeAt(c+1))<56320||s>57343?e?a.charAt(c):o:e?a.slice(c,c+2):s-56320+(o-55296<<10)+65536)}}},function(e,t,n){"use strict";var i=n(17),r=n(18),o=n(21),s=n(5),a=n(15),c=n(45),l=n(28),u=n(54),h=n(0)("iterator"),d=!([].keys&&"next"in[].keys()),f=function(){return this};e.exports=function(e,t,n,p,v,m,g){c(n,t,p);var y,_,b,E=function(e){if(!d&&e in w)return w[e];switch(e){case"keys":case"values":return function(){return new n(this,e)}}return function(){return new n(this,e)}},S=t+" Iterator",O="values"==v,I=!1,w=e.prototype,C=w[h]||w["@@iterator"]||v&&w[v],T=C||E(v),A=v?O?E("entries"):T:void 0,k="Array"==t?w.entries||C:C;if(k&&(b=u(k.call(new e)))!==Object.prototype&&b.next&&(l(b,S,!0),i||"function"==typeof b[h]||s(b,h,f)),O&&C&&"values"!==C.name&&(I=!0,T=function(){return C.call(this)}),i&&!g||!d&&!I&&w[h]||s(w,h,T),a[t]=T,a[S]=f,v)if(y={values:O?T:E("values"),keys:m?T:E("keys"),entries:A},g)for(_ in y)_ in w||o(w,_,y[_]);else r(r.P+r.F*(d||I),t,y);return y}},function(e,t,n){e.exports=!n(8)&&!n(19)(function(){return 7!=Object.defineProperty(n(20)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){var i=n(12);e.exports=function(e,t){if(!i(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!i(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!i(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!i(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){"use strict";var i=n(46),r=n(13),o=n(28),s={};n(5)(s,n(0)("iterator"),function(){return this}),e.exports=function(e,t,n){e.prototype=i(s,{next:r(1,n)}),o(e,t+" Iterator")}},function(e,t,n){var i=n(7),r=n(47),o=n(27),s=n(16)("IE_PROTO"),a=function(){},c=function(){var e,t=n(20)("iframe"),i=o.length;for(t.style.display="none",n(53).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("
+
+