wishthis/semantic/dist/components/dropdown.min.js
2022-02-23 22:46:34 +01:00

11 lines
No EOL
57 KiB
JavaScript

/*
* # Fomantic UI - 2.8.8
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(te,ne,ie,ae){"use strict";te.isFunction=te.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},ne=void 0!==ne&&ne.Math==Math?ne:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),te.fn.dropdown=function(B){var K,W=te(this),Q=te(ie),Y=W.selector||"",$="ontouchstart"in ie.documentElement,X=$?"touchstart":"click",G=(new Date).getTime(),J=[],Z=B,_="string"==typeof Z,ee=[].slice.call(arguments,1);return W.each(function(n){var d,e,i,a,s,o,r,c,u,v=te.isPlainObject(B)?te.extend(!0,{},te.fn.dropdown.settings,B):te.extend({},te.fn.dropdown.settings),m=v.className,C=v.message,y=v.fields,x=v.keys,h=v.metadata,S=v.namespace,A=v.regExp,f=v.selector,T=v.error,L=v.templates,t="."+S,I="module-"+S,g=te(this),D=te(v.context),k=g.find(f.text),O=g.find(f.search),q=g.find(f.sizer),l=g.find(f.input),R=g.find(f.icon),V=g.find(f.clearIcon),E=0<g.prev().find(f.text).length?g.prev().find(f.text):g.prev(),p=g.children(f.menu),b=p.find(f.item),M=v.hideDividers?b.parent().children(f.divider):te(),z=!1,F=!1,P=!1,N=!1,H=this,j=!1,U=g.data(I),w={initialize:function(){w.debug("Initializing dropdown",v),w.is.alreadySetup()?w.setup.reference():(v.ignoreDiacritics&&!String.prototype.normalize&&(v.ignoreDiacritics=!1,w.error(T.noNormalize,H)),w.setup.layout(),v.values&&(w.set.initialLoad(),w.change.values(v.values),w.remove.initialLoad()),w.refreshData(),w.save.defaults(),w.restore.selected(),w.create.id(),w.bind.events(),w.observeChanges(),w.instantiate())},instantiate:function(){w.verbose("Storing instance of dropdown",w),U=w,g.data(I,w)},destroy:function(){w.verbose("Destroying previous dropdown",g),w.remove.tabbable(),w.remove.active(),p.transition("stop all"),p.removeClass(m.visible).addClass(m.hidden),g.off(t).removeData(I),p.off(t),Q.off(s),w.disconnect.menuObserver(),w.disconnect.selectObserver(),w.disconnect.classObserver()},observeChanges:function(){"MutationObserver"in ne&&(r=new MutationObserver(w.event.select.mutation),c=new MutationObserver(w.event.menu.mutation),u=new MutationObserver(w.event.class.mutation),w.debug("Setting up mutation observer",r,c,u),w.observe.select(),w.observe.menu(),w.observe.class())},disconnect:{menuObserver:function(){c&&c.disconnect()},selectObserver:function(){r&&r.disconnect()},classObserver:function(){u&&u.disconnect()}},observe:{select:function(){w.has.input()&&r&&r.observe(g[0],{childList:!0,subtree:!0})},menu:function(){w.has.menu()&&c&&c.observe(p[0],{childList:!0,subtree:!0})},class:function(){w.has.search()&&u&&u.observe(g[0],{attributes:!0})}},create:{id:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),s="."+o,w.verbose("Creating unique id for element",o)},userChoice:function(e){var n,i;return!!(e=e||w.get.userValues())&&(e=Array.isArray(e)?e:[e],te.each(e,function(e,t){!1===w.get.item(t)&&(i=v.templates.addition(w.add.variables(C.addResult,t)),i=te("<div />").html(i).attr("data-"+h.value,t).attr("data-"+h.text,t).addClass(m.addition).addClass(m.item),v.hideAdditions&&i.addClass(m.hidden),n=n===ae?i:n.add(i),w.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=w.get.userValues();t&&(w.debug("Adding user labels",t),te.each(t,function(e,t){w.verbose("Adding custom user value"),w.add.label(t,t)}))},menu:function(){p=te("<div />").addClass(m.menu).appendTo(g)},sizer:function(){q=te("<span />").addClass(m.sizer).insertAfter(O)}},search:function(e){e=e!==ae?e:w.get.query(),w.verbose("Searching for query",e),!1===v.fireOnInit&&w.is.initialLoad()?w.verbose("Skipping callback on initial load",v.onSearch):w.has.minCharacters(e)&&!1!==v.onSearch.call(H,e)?w.filter(e):w.hide(null,!0)},select:{firstUnfiltered:function(){w.verbose("Selecting first non-filtered element"),w.remove.selectedItem(),b.not(f.unselectable).not(f.addition+f.hidden).eq(0).addClass(m.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(f.item).not(f.unselectable).eq(0),e=e.prevAll(f.item).not(f.unselectable).eq(0);0<t.length?(w.verbose("Moving selection to",t),t.addClass(m.selected)):(w.verbose("Moving selection to",e),e.addClass(m.selected))}},setup:{api:function(){var e={debug:v.debug,urlData:{value:w.get.value(),query:w.get.query()},on:!1};w.verbose("First request, initializing API"),g.api(e)},layout:function(){g.is("select")&&(w.setup.select(),w.setup.returnedObject()),w.has.menu()||w.create.menu(),w.is.clearable()&&!w.has.clearItem()&&(w.verbose("Adding clear icon"),V=te("<i />").addClass("remove icon").insertBefore(k)),w.is.search()&&!w.has.search()&&(w.verbose("Adding search input"),O=te("<input />").addClass(m.search).prop("autocomplete",w.is.chrome()?"fomantic-search":"off").insertBefore(k)),w.is.multiple()&&w.is.searchSelection()&&!w.has.sizer()&&w.create.sizer(),v.allowTab&&w.set.tabbable()},select:function(){var e=w.get.selectValues();w.debug("Dropdown initialized on a select",e),0<(l=g.is("select")?g:l).parent(f.dropdown).length?(w.debug("UI dropdown already exists. Creating dropdown menu only"),g=l.closest(f.dropdown),w.has.menu()||w.create.menu(),p=g.children(f.menu),w.setup.menu(e)):(w.debug("Creating entire dropdown from select"),g=te("<div />").attr("class",l.attr("class")).addClass(m.selection).addClass(m.dropdown).html(L.dropdown(e,y,v.preserveHTML,v.className)).insertBefore(l),l.hasClass(m.multiple)&&!1===l.prop("multiple")&&(w.error(T.missingMultiple),l.prop("multiple",!0)),l.is("[multiple]")&&w.set.multiple(),l.prop("disabled")&&(w.debug("Disabling dropdown"),g.addClass(m.disabled)),l.removeAttr("required").removeAttr("class").detach().prependTo(g)),w.refresh()},menu:function(e){p.html(L.menu(e,y,v.preserveHTML,v.className)),b=p.find(f.item),M=v.hideDividers?b.parent().children(f.divider):te()},reference:function(){w.debug("Dropdown behavior was called on select, replacing with closest dropdown"),g=g.parent(f.dropdown),U=g.data(I),H=g.get(0),w.refresh(),w.setup.returnedObject()},returnedObject:function(){var e=W.slice(0,n),t=W.slice(n+1);W=e.add(g).add(t)}},refresh:function(){w.refreshSelectors(),w.refreshData()},refreshItems:function(){b=p.find(f.item),M=v.hideDividers?b.parent().children(f.divider):te()},refreshSelectors:function(){w.verbose("Refreshing selector cache"),k=g.find(f.text),O=g.find(f.search),l=g.find(f.input),R=g.find(f.icon),E=0<g.prev().find(f.text).length?g.prev().find(f.text):g.prev(),p=g.children(f.menu),b=p.find(f.item),M=v.hideDividers?b.parent().children(f.divider):te()},refreshData:function(){w.verbose("Refreshing cached metadata"),b.removeData(h.text).removeData(h.value)},clearData:function(){w.verbose("Clearing metadata"),b.removeData(h.text).removeData(h.value),g.removeData(h.defaultText).removeData(h.defaultValue).removeData(h.placeholderText)},clearItems:function(){p.empty(),w.refreshItems()},toggle:function(){w.verbose("Toggling menu visibility"),w.is.active()?w.hide():w.show()},show:function(e,t){if(e=te.isFunction(e)?e:function(){},(j||N)&&w.is.remote()&&w.is.noApiCache()&&w.clearItems(),!w.can.show()&&w.is.remote()&&(w.debug("No API results retrieved, searching before show"),w.queryRemote(w.get.query(),w.show,[e,t])),w.can.show()&&!w.is.active()){if(w.debug("Showing dropdown"),!w.has.message()||w.has.maxSelections()||w.has.allResultsFiltered()||w.remove.message(),w.is.allFiltered())return!0;!1!==v.onShow.call(H)&&w.animate.show(function(){w.can.click()&&w.bind.intent(),w.has.search()&&!t&&w.focusSearch(),w.set.visible(),e.call(H)})}},hide:function(e,t){e=te.isFunction(e)?e:function(){},w.is.active()&&!w.is.animatingOutward()?(w.debug("Hiding dropdown"),!1!==v.onHide.call(H)&&w.animate.hide(function(){w.remove.visible(),w.is.focusedOnSearch()&&!0!==t&&O.blur(),e.call(H)})):w.can.click()&&w.unbind.intent(),j=N=!1},hideOthers:function(){w.verbose("Finding other dropdowns to hide"),W.not(g).has(f.menu+"."+m.visible).dropdown("hide")},hideMenu:function(){w.verbose("Hiding menu instantaneously"),w.remove.active(),w.remove.visible(),p.transition("hide")},hideSubMenus:function(){var e=p.children(f.item).find(f.menu);w.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){w.bind.keyboardEvents(),w.bind.inputEvents(),w.bind.mouseEvents()},keyboardEvents:function(){w.verbose("Binding keyboard events"),g.on("keydown"+t,w.event.keydown),w.has.search()&&g.on(w.get.inputEvent()+t,f.search,w.event.input),w.is.multiple()&&Q.on("keydown"+s,w.event.document.keydown)},inputEvents:function(){w.verbose("Binding input change events"),g.on("change"+t,f.input,w.event.change)},mouseEvents:function(){w.verbose("Binding mouse events"),w.is.multiple()&&g.on(X+t,f.label,w.event.label.click).on(X+t,f.remove,w.event.remove.click),w.is.searchSelection()?(g.on("mousedown"+t,w.event.mousedown).on("mouseup"+t,w.event.mouseup).on("mousedown"+t,f.menu,w.event.menu.mousedown).on("mouseup"+t,f.menu,w.event.menu.mouseup).on(X+t,f.icon,w.event.icon.click).on(X+t,f.clearIcon,w.event.clearIcon.click).on("focus"+t,f.search,w.event.search.focus).on(X+t,f.search,w.event.search.focus).on("blur"+t,f.search,w.event.search.blur).on(X+t,f.text,w.event.text.focus),w.is.multiple()&&g.on(X+t,w.event.click).on(X+t,w.event.search.focus)):("click"==v.on?g.on(X+t,f.icon,w.event.icon.click).on(X+t,w.event.test.toggle):"hover"==v.on?g.on("mouseenter"+t,w.delay.show).on("mouseleave"+t,w.delay.hide):g.on(v.on+t,w.toggle),g.on("mousedown"+t,w.event.mousedown).on("mouseup"+t,w.event.mouseup).on("focus"+t,w.event.focus).on(X+t,f.clearIcon,w.event.clearIcon.click),w.has.menuSearch()?g.on("blur"+t,f.search,w.event.search.blur):g.on("blur"+t,w.event.blur)),p.on(($?"touchstart":"mouseenter")+t,f.item,w.event.item.mouseenter).on("mouseleave"+t,f.item,w.event.item.mouseleave).on("click"+t,f.item,w.event.item.click)},intent:function(){w.verbose("Binding hide intent event to document"),$&&Q.on("touchstart"+s,w.event.test.touch).on("touchmove"+s,w.event.test.touch),Q.on(X+s,w.event.test.hide)}},unbind:{intent:function(){w.verbose("Removing hide intent event from document"),$&&Q.off("touchstart"+s).off("touchmove"+s),Q.off(X+s)}},filter:function(e){function t(){w.is.multiple()&&w.filterActive(),(e||!e&&0==w.get.activeItem().length)&&w.select.firstUnfiltered(),w.has.allResultsFiltered()?v.onNoResults.call(H,n)?v.allowAdditions?v.hideAdditions&&(w.verbose("User addition with no menu, setting empty style"),w.set.empty(),w.hideMenu()):(w.verbose("All items filtered, showing message",n),w.add.message(C.noResults)):(w.verbose("All items filtered, hiding dropdown",n),w.hideMenu()):(w.remove.empty(),w.remove.message()),v.allowAdditions&&w.add.userSuggestion(w.escape.htmlEntities(e)),w.is.searchSelection()&&w.can.show()&&w.is.focusedOnSearch()&&w.show()}var n=e!==ae?e:w.get.query();v.useLabels&&w.has.maxSelections()||(v.apiSettings?w.can.useAPI()?w.queryRemote(n,function(){v.filterRemoteData&&w.filterItems(n);var e=l.val();Array.isArray(e)||(e=e&&""!==e?e.split(v.delimiter):[]),w.is.multiple()&&te.each(e,function(e,t){b.filter('[data-value="'+t+'"]').addClass(m.filtered)}),w.focusSearch(!0),t()}):w.error(T.noAPI):(w.filterItems(n),t()))},queryRemote:function(e,n,i){Array.isArray(i)||(i=[i]);e={errorDuration:!1,cache:"local",throttle:v.throttle,urlData:{query:e},onError:function(){w.add.message(C.serverError),j=N=!1,n.apply(null,i)},onFailure:function(){w.add.message(C.serverError),j=N=!1,n.apply(null,i)},onSuccess:function(e){var e=e[y.remoteValues],t=(Array.isArray(e)||(e=[]),w.remove.message(),{});t[y.values]=e,w.setup.menu(t),0!==e.length||v.allowAdditions?""!==(t=w.is.multiple()?w.get.values():w.get.value())&&(w.verbose("Value(s) present after click icon, select value(s) in items"),w.set.selected(t,null,null,!0)):w.add.message(C.noResults),j=N=!1,n.apply(null,i)}};g.api("get request")||w.setup.api(),e=te.extend(!0,{},e,v.apiSettings),g.api("setting",e).api("query")},filterItems:function(e){var n=w.remove.diacritics(e!==ae?e:w.get.query()),i=null,e=w.escape.string(n),t=(v.ignoreSearchCase?"i":"")+"gm",a=new RegExp("^"+e,t);w.has.query()&&(i=[],w.verbose("Searching for matching values",n),b.each(function(){var e,t=te(this);if(t.hasClass(m.unfilterable))return i.push(this),!0;if("both"===v.match||"text"===v.match){if(-1!==(e=w.remove.diacritics(String(w.get.choiceText(t,!1)))).search(a))return i.push(this),!0;if("exact"===v.fullTextSearch&&w.exactSearch(n,e))return i.push(this),!0;if(!0===v.fullTextSearch&&w.fuzzySearch(n,e))return i.push(this),!0}return("both"===v.match||"value"===v.match)&&(-1!==(t=w.remove.diacritics(String(w.get.choiceValue(t,e)))).search(a)||"exact"===v.fullTextSearch&&w.exactSearch(n,t)||!0===v.fullTextSearch&&w.fuzzySearch(n,t))?(i.push(this),!0):void 0})),w.debug("Showing only matched items",n),w.remove.filteredItem(),i&&b.not(i).addClass(m.filtered),w.has.query()?!0===v.hideDividers?M.addClass(m.hidden):"empty"===v.hideDividers&&M.removeClass(m.hidden).filter(function(){var e=te(this).nextUntil(f.item);return 0===(e.length?e:te(this)).nextUntil(f.divider).filter(f.item+":not(."+m.filtered+")").length}).addClass(m.hidden):M.removeClass(m.hidden)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=v.ignoreSearchCase?e.toLowerCase():e,t=v.ignoreSearchCase?t.toLowerCase():t,n<i)return!1;if(i===n)return e===t;e:for(var a=0,s=0;a<i;a++){for(var o=e.charCodeAt(a);s<n;)if(t.charCodeAt(s++)===o)continue e;return!1}return!0},exactSearch:function(e,t){return e=v.ignoreSearchCase?e.toLowerCase():e,-1<(t=v.ignoreSearchCase?t.toLowerCase():t).indexOf(e)},filterActive:function(){v.useLabels&&b.filter("."+m.active).addClass(m.filtered)},focusSearch:function(e){w.has.search()&&!w.is.focusedOnSearch()&&(e?(g.off("focus"+t,f.search),O.focus(),g.on("focus"+t,f.search,w.event.search.focus)):O.focus())},blurSearch:function(){w.has.search()&&O.blur()},forceSelection:function(){var e=b.not(m.filtered).filter("."+m.selected).eq(0),t=b.not(m.filtered).filter("."+m.active).eq(0),e=0<e.length?e:t,t=0<e.length;v.allowAdditions||t&&!w.is.multiple()?(w.debug("Forcing partial selection to selected item",e),w.event.item.click.call(e,{},!0)):w.remove.searchTerm()},change:{values:function(e){v.allowAdditions||w.clear(),w.debug("Creating dropdown with specified values",e);var t={};t[y.values]=e,w.setup.menu(t),te.each(e,function(e,t){if(1==t.selected&&(w.debug("Setting initial selection to",t[y.value]),w.set.selected(t[y.value]),!w.is.multiple()))return!1}),w.has.selectInput()&&(w.disconnect.selectObserver(),l.html(""),l.append("<option disabled selected value></option>"),te.each(e,function(e,t){var n=v.templates.deQuote(t[y.value]),t=v.templates.escape(t[y.name]||"",v.preserveHTML);l.append('<option value="'+n+'">'+t+"</option>")}),w.observe.select())}},event:{change:function(){P||(w.debug("Input changed, updating selection"),w.set.selected())},focus:function(){v.showOnFocus&&!z&&w.is.hidden()&&!i&&(j=!0,w.show())},blur:function(e){i=ie.activeElement===this,z||i||(w.remove.activeLabel(),w.hide())},mousedown:function(){w.is.searchSelection()?a=!0:z=!0},mouseup:function(){w.is.searchSelection()?a=!1:z=!1},click:function(e){te(e.target).is(g)&&(w.is.focusedOnSearch()?w.show():w.focusSearch())},search:{focus:function(e){z=!0,w.is.multiple()&&w.remove.activeLabel(),j||w.is.active()||!(v.showOnFocus||"focus"!==e.type&&"focusin"!==e.type)||(j=!0,w.search())},blur:function(e){i=ie.activeElement===this,w.is.searchSelection()&&!a&&(F||i||(v.forceSelection?w.forceSelection():v.allowAdditions||w.remove.searchTerm(),w.hide())),a=!1}},clearIcon:{click:function(e){w.clear(),w.is.searchSelection()&&w.remove.searchTerm(),w.hide(),e.stopPropagation()}},icon:{click:function(e){N=!0,w.has.search()?w.is.active()?w.blurSearch():v.showOnFocus?w.focusSearch():w.toggle():w.toggle(),e.stopPropagation()}},text:{focus:function(e){z=!0,w.focusSearch()}},input:function(e){(w.is.multiple()||w.is.searchSelection())&&w.set.filtered(),clearTimeout(w.timer),w.timer=setTimeout(w.search,v.delay.search)},label:{click:function(e){var t=te(this),n=g.find(f.label),i=n.filter("."+m.active),a=t.nextAll("."+m.active),s=t.prevAll("."+m.active),a=(0<a.length?t.nextUntil(a):t.prevUntil(s)).add(i).add(t);e.shiftKey?(i.removeClass(m.active),a.addClass(m.active)):e.ctrlKey?t.toggleClass(m.active):(i.removeClass(m.active),t.addClass(m.active)),v.onLabelSelect.apply(this,n.filter("."+m.active)),e.stopPropagation()}},remove:{click:function(e){var t=te(this).parent();t.hasClass(m.active)?w.remove.activeLabels():w.remove.activeLabels(t),e.stopPropagation()}},test:{toggle:function(e){var t=w.is.multiple()?w.show:w.toggle;w.is.bubbledLabelClick(e)||w.is.bubbledIconClick(e)||(w.is.multiple()&&(!w.is.multiple()||w.is.active())||(j=!0),w.determine.eventOnElement(e,t)&&e.preventDefault())},touch:function(e){w.determine.eventOnElement(e,function(){"touchstart"==e.type?w.timer=setTimeout(function(){w.hide()},v.delay.touch):"touchmove"==e.type&&clearTimeout(w.timer)}),e.stopPropagation()},hide:function(e){w.determine.eventInModule(e,w.hide)&&H.id&&te(e.target).attr("for")===H.id&&e.preventDefault()}},class:{mutation:function(e){e.forEach(function(e){"class"===e.attributeName&&w.check.disabled()})}},select:{mutation:function(e){w.debug("<select> modified, recreating menu"),w.is.selectMutation(e)&&(w.disconnect.selectObserver(),w.refresh(),w.setup.select(),w.set.selected(),w.observe.select())}},menu:{mutation:function(e){var e=e[0],t=e.addedNodes?te(e.addedNodes[0]):te(!1),e=e.removedNodes?te(e.removedNodes[0]):te(!1),t=t.add(e),e=t.is(f.addition)||0<t.closest(f.addition).length,t=t.is(f.message)||0<t.closest(f.message).length;e||t?(w.debug("Updating item selector cache"),w.refreshItems()):(w.debug("Menu modified, updating selector cache"),w.refresh())},mousedown:function(){F=!0},mouseup:function(){F=!1}},item:{mouseenter:function(e){var t=te(e.target),n=te(this),i=n.children(f.menu),a=n.siblings(f.item).children(f.menu),n=0<i.length;0<i.find(t).length||!n||(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Showing sub-menu",i),te.each(a,function(){w.animate.hide(!1,te(this))}),w.animate.show(!1,i)},v.delay.show),e.preventDefault())},mouseleave:function(e){var t=te(this).children(f.menu);0<t.length&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Hiding sub-menu",t),w.animate.hide(!1,t)},v.delay.hide))},click:function(e,t){var n=te(this),e=te(e?e.target:""),i=n.find(f.menu),a=w.get.choiceText(n),s=w.get.choiceValue(n,a),o=0<i.length,i=0<i.find(e).length;"input"!==ie.activeElement.tagName.toLowerCase()&&te(ie.activeElement).blur(),i||o&&!v.allowCategorySelection||(w.is.searchSelection()&&(v.allowAdditions&&w.remove.userAddition(),w.remove.searchTerm(),w.is.focusedOnSearch()||1==t||w.focusSearch(!0)),v.useLabels||(w.remove.filteredItem(),w.set.scrollPosition(n)),w.determine.selectAction.call(this,a,s))}},document:{keydown:function(e){var t,n,i,a,u,s,o,r,l,d,v,c=e.which;w.is.inObject(c,x)&&((n=(t=g.find(f.label)).filter("."+m.active)).data(h.value),s=t.index(n),o=t.length,i=0<n.length,a=1<n.length,u=0===s,s=s+1==o,o=w.is.searchSelection(),r=w.is.focusedOnSearch(),l=w.is.focused(),v=(d=r&&0===w.get.caretPosition(!1))&&0!==w.get.caretPosition(!0),o&&!i&&!r||(c==x.leftArrow?!l&&!d||i?i&&(e.shiftKey?w.verbose("Adding previous label to selection"):(w.verbose("Selecting previous label"),t.removeClass(m.active)),u&&!a?n.addClass(m.active):n.prev(f.siblingLabel).addClass(m.active).end(),e.preventDefault()):(w.verbose("Selecting previous label"),t.last().addClass(m.active)):c==x.rightArrow?(l&&!i&&t.first().addClass(m.active),i&&(e.shiftKey?w.verbose("Adding next label to selection"):(w.verbose("Selecting next label"),t.removeClass(m.active)),s?o?r?t.removeClass(m.active):w.focusSearch():(a?n.next(f.siblingLabel):n).addClass(m.active):n.next(f.siblingLabel).addClass(m.active),e.preventDefault())):c==x.deleteKey||c==x.backspace?i?(w.verbose("Removing active labels"),s&&o&&!r&&w.focusSearch(),n.last().next(f.siblingLabel).addClass(m.active),w.remove.activeLabels(n),e.preventDefault()):!d||v||i||c!=x.backspace||(w.verbose("Removing last label on input backspace"),n=t.last().addClass(m.active),w.remove.activeLabels(n)):n.removeClass(m.active)))}},keydown:function(e){var t=e.which;if(w.is.inObject(t,x)){var n,i=b.not(f.unselectable).filter("."+m.selected).eq(0),a=p.children("."+m.active).eq(0),i=0<i.length?i:a,a=0<i.length?i.siblings(":not(."+m.filtered+")").addBack():p.children(":not(."+m.filtered+")"),s=i.children(f.menu),o=i.closest(f.menu),r=o.hasClass(m.visible)||o.hasClass(m.animating)||0<o.parent(f.menu).length,u=0<s.length,l=0<i.length,d=0<i.not(f.unselectable).length,c=t==x.delimiter&&v.allowAdditions&&w.is.multiple();if(v.allowAdditions&&v.hideAdditions&&(t==x.enter||c)&&d&&(w.verbose("Selecting item from keyboard shortcut",i),w.event.item.click.call(i,e),w.is.searchSelection()&&w.remove.searchTerm(),w.is.multiple()&&e.preventDefault()),w.is.visible()){if(t!=x.enter&&!c||(t==x.enter&&l&&u&&!v.allowCategorySelection?(w.verbose("Pressed enter on unselectable category, opening sub menu"),t=x.rightArrow):d&&(w.verbose("Selecting item from keyboard shortcut",i),w.event.item.click.call(i,e),w.is.searchSelection()&&(w.remove.searchTerm(),w.is.multiple()&&O.focus())),e.preventDefault()),l&&(t==x.leftArrow&&o[0]!==p[0]&&(w.verbose("Left key pressed, closing sub-menu"),w.animate.hide(!1,o),i.removeClass(m.selected),o.closest(f.item).addClass(m.selected),e.preventDefault()),t==x.rightArrow&&u&&(w.verbose("Right key pressed, opening sub-menu"),w.animate.show(!1,s),i.removeClass(m.selected),s.find(f.item).eq(0).addClass(m.selected),e.preventDefault())),t==x.upArrow){if(n=(l&&r?i.prevAll(f.item+":not("+f.unselectable+")"):b).eq(0),a.index(n)<0)return w.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();w.verbose("Up key pressed, changing active item"),i.removeClass(m.selected),n.addClass(m.selected),w.set.scrollPosition(n),v.selectOnKeydown&&w.is.single()&&w.set.selectedItem(n),e.preventDefault()}if(t==x.downArrow){if(0===(n=(l&&r?i.nextAll(f.item+":not("+f.unselectable+")"):b).eq(0)).length)return w.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();w.verbose("Down key pressed, changing active item"),b.removeClass(m.selected),n.addClass(m.selected),w.set.scrollPosition(n),v.selectOnKeydown&&w.is.single()&&w.set.selectedItem(n),e.preventDefault()}t==x.pageUp&&(w.scrollPage("up"),e.preventDefault()),t==x.pageDown&&(w.scrollPage("down"),e.preventDefault()),t==x.escape&&(w.verbose("Escape key pressed, closing dropdown"),w.hide())}else c&&e.preventDefault(),t!=x.downArrow||w.is.visible()||(w.verbose("Down key pressed, showing dropdown"),w.show(),e.preventDefault())}else w.has.search()||w.set.selectedLetter(String.fromCharCode(t))}},trigger:{change:function(){var e,t=l[0];t&&(e=ie.createEvent("HTMLEvents"),w.verbose("Triggering native change event"),e.initEvent("change",!0,!1),t.dispatchEvent(e))}},determine:{selectAction:function(e,t){d=!0,w.verbose("Determining action",v.action),te.isFunction(w.action[v.action])?(w.verbose("Triggering preset action",v.action,e,t),w.action[v.action].call(H,e,t,this)):te.isFunction(v.action)?(w.verbose("Triggering user action",v.action,e,t),v.action.call(H,e,t,this)):w.error(T.action,v.action),d=!1},eventInModule:function(e,t){var e=te(e.target),n=0<e.closest(ie.documentElement).length,e=0<e.closest(g).length;return t=te.isFunction(t)?t:function(){},n&&!e?(w.verbose("Triggering event",t),t(),!0):(w.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(e,t){var n=te(e.target),i=n.closest(f.siblingLabel),e=ie.body.contains(e.target),i=0===g.find(i).length||!(w.is.multiple()&&v.useLabels),n=0===n.closest(p).length;return t=te.isFunction(t)?t:function(){},e&&i&&n?(w.verbose("Triggering event",t),t(),!0):(w.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(e,t,n){t=t!==ae?t:e,w.can.activate(te(n))&&(w.set.selected(t,te(n)),w.is.multiple()||w.hideAndClear())},select:function(e,t,n){t=t!==ae?t:e,w.can.activate(te(n))&&(w.set.value(t,e,te(n)),w.is.multiple()||w.hideAndClear())},combo:function(e,t,n){w.set.selected(t=t!==ae?t:e,te(n)),w.hideAndClear()},hide:function(e,t,n){w.set.value(t,e,te(n)),w.hideAndClear()}},get:{id:function(){return o},defaultText:function(){return g.data(h.defaultText)},defaultValue:function(){return g.data(h.defaultValue)},placeholderText:function(){return"auto"!=v.placeholder&&"string"==typeof v.placeholder?v.placeholder:g.data(h.placeholderText)||""},text:function(){return v.preserveHTML?k.html():k.text()},query:function(){return String(O.val()).trim()},searchWidth:function(e){return e=e!==ae?e:O.val(),q.text(e),Math.ceil(q.width()+1)},selectionCount:function(){var e=w.get.values();return w.is.multiple()?Array.isArray(e)?e.length:0:""!==w.get.value()?1:0},transition:function(e){return"auto"===v.transition?w.is.upward(e)?"slide up":"slide down":v.transition},userValues:function(){var e=w.get.values();return!!e&&(e=Array.isArray(e)?e:[e],te.grep(e,function(e){return!1===w.get.item(e)}))},uniqueArray:function(n){return te.grep(n,function(e,t){return te.inArray(e,n)===t})},caretPosition:function(e){var t,n,i=O.get(0);return e&&"selectionEnd"in i?i.selectionEnd:!e&&"selectionStart"in i?i.selectionStart:ie.selection?(i.focus(),n=(t=ie.selection.createRange()).text.length,e?n:(t.moveStart("character",-i.value.length),t.text.length-n)):void 0},value:function(){var e=0<l.length?l.val():g.data(h.value),t=Array.isArray(e)&&1===e.length&&""===e[0];return e===ae||t?"":e},values:function(e){var t=w.get.value();return""===t?"":!w.has.selectInput()&&w.is.multiple()?"string"==typeof t?(e?t:w.escape.htmlEntities(t)).split(v.delimiter):"":t},remoteValues:function(){var e=w.get.values(),i=!1;return e&&te.each(e="string"==typeof e?[e]:e,function(e,t){var n=w.read.remoteData(t);w.verbose("Restoring value from session data",n,t),n&&((i=i||{})[t]=n)}),i},choiceText:function(e,t){if(t=t!==ae?t:v.preserveHTML,e)return 0<e.find(f.menu).length&&(w.verbose("Retrieving text of element with sub-menu"),(e=e.clone()).find(f.menu).remove(),e.find(f.menuIcon).remove()),e.data(h.text)!==ae?e.data(h.text):t?e.html()&&e.html().trim():e.text()&&e.text().trim()},choiceValue:function(e,t){return t=t||w.get.choiceText(e),!!e&&(e.data(h.value)!==ae?String(e.data(h.value)):"string"==typeof t?String(v.ignoreSearchCase?t.toLowerCase():t).trim():String(t))},inputEvent:function(){var e=O[0];return!!e&&(e.oninput!==ae?"input":e.onpropertychange!==ae?"propertychange":"keyup")},selectValues:function(){var s={},o=[],r=[];return g.find("option").each(function(){var e=te(this),t=e.html(),n=e.attr("disabled"),i=e.attr("value")!==ae?e.attr("value"):t,a=e.data(h.text)!==ae?e.data(h.text):t,e=e.parent("optgroup");"auto"===v.placeholder&&""===i?s.placeholder=t:(e.length===o.length&&e[0]===o[0]||(r.push({type:"header",divider:v.headerDivider,name:e.attr("label")||""}),o=e),r.push({name:t,value:i,text:a,disabled:n}))}),v.placeholder&&"auto"!==v.placeholder&&(w.debug("Setting placeholder value to",v.placeholder),s.placeholder=v.placeholder),v.sortSelect?(!0===v.sortSelect?r.sort(function(e,t){return e.name.localeCompare(t.name)}):"natural"===v.sortSelect?r.sort(function(e,t){return e.name.toLowerCase().localeCompare(t.name.toLowerCase())}):te.isFunction(v.sortSelect)&&r.sort(v.sortSelect),s[y.values]=r,w.debug("Retrieved and sorted values from select",s)):(s[y.values]=r,w.debug("Retrieved values from select",s)),s},activeItem:function(){return b.filter("."+m.active)},selectedItem:function(){var e=b.not(f.unselectable).filter("."+m.selected);return 0<e.length?e:b.eq(0)},itemWithAdditions:function(e){var t=w.get.item(e),e=w.create.userChoice(e);return t=e&&0<e.length?0<t.length?t.add(e):e:t},item:function(n,i){var e,a,s=!1;return n=n!==ae?n:w.get.values()!==ae?w.get.values():w.get.text(),e=(a=w.is.multiple()&&Array.isArray(n))?0<n.length:n!==ae&&null!==n,i=""===n||!1===n||!0===n||(i||!1),e&&b.each(function(){var e=te(this),t=w.get.choiceText(e),t=w.get.choiceValue(e,t);if(null!==t&&t!==ae)if(a)-1!==te.inArray(w.escape.htmlEntities(String(t)),n.map(function(e){return String(e)}))&&(s=s?s.add(e):e);else if(i){if(w.verbose("Ambiguous dropdown value using strict type check",e,n),t===n)return s=e,!0}else if(v.ignoreCase&&(t=t.toLowerCase(),n=n.toLowerCase()),w.escape.htmlEntities(String(t))===w.escape.htmlEntities(String(n)))return w.verbose("Found select item by value",t,n),s=e,!0}),s},displayType:function(){return g.hasClass("column")?"flex":v.displayType}},check:{maxSelections:function(e){return!v.maxSelections||((e=e!==ae?e:w.get.selectionCount())>=v.maxSelections?(w.debug("Maximum selection count reached"),v.useLabels&&(b.addClass(m.filtered),w.add.message(C.maxSelections)),!0):(w.verbose("No longer at maximum selection count"),w.remove.message(),w.remove.filteredItem(),w.is.searchSelection()&&w.filterItems(),!1))},disabled:function(){O.attr("tabindex",w.is.disabled()?-1:0)}},restore:{defaults:function(e){w.clear(e),w.restore.defaultText(),w.restore.defaultValue()},defaultText:function(){var e=w.get.defaultText();e===w.get.placeholderText?(w.debug("Restoring default placeholder text",e),w.set.placeholderText(e)):(w.debug("Restoring default text",e),w.set.text(e))},placeholderText:function(){w.set.placeholderText()},defaultValue:function(){var e=w.get.defaultValue();e!==ae&&(w.debug("Restoring default value",e),""!==e?(w.set.value(e),w.set.selected()):(w.remove.activeItem(),w.remove.selectedItem()))},labels:function(){v.allowAdditions&&(v.useLabels||(w.error(T.labels),v.useLabels=!0),w.debug("Restoring selected values"),w.create.userLabels()),w.check.maxSelections()},selected:function(){w.restore.values(),w.is.multiple()?(w.debug("Restoring previously selected values and labels"),w.restore.labels()):w.debug("Restoring previously selected values")},values:function(){w.set.initialLoad(),v.apiSettings&&v.saveRemoteData&&w.get.remoteValues()?w.restore.remoteValues():w.set.selected();var e=w.get.value();!e||""===e||Array.isArray(e)&&0===e.length?l.addClass(m.noselection):l.removeClass(m.noselection),w.remove.initialLoad()},remoteValues:function(){var e=w.get.remoteValues();w.debug("Recreating selected from session data",e),e&&(w.is.single()?te.each(e,function(e,t){w.set.text(t)}):te.each(e,function(e,t){w.add.label(e,t)}))}},read:{remoteData:function(e){if(ne.Storage!==ae)return(e=sessionStorage.getItem(e))!==ae&&e;w.error(T.noStorage)}},save:{defaults:function(){w.save.defaultText(),w.save.placeholderText(),w.save.defaultValue()},defaultValue:function(){var e=w.get.value();w.verbose("Saving default value as",e),g.data(h.defaultValue,e)},defaultText:function(){var e=w.get.text();w.verbose("Saving default text as",e),g.data(h.defaultText,e)},placeholderText:function(){var e;!1!==v.placeholder&&k.hasClass(m.placeholder)&&(e=w.get.text(),w.verbose("Saving placeholder text as",e),g.data(h.placeholderText,e))},remoteData:function(e,t){ne.Storage!==ae?(w.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e)):w.error(T.noStorage)}},clear:function(e){w.is.multiple()&&v.useLabels?w.remove.labels(g.find(f.label),e):(w.remove.activeItem(),w.remove.selectedItem(),w.remove.filteredItem()),w.set.placeholderText(),w.clearValue(e)},clearValue:function(e){w.set.value("",null,null,e)},scrollPage:function(e,t){var t=t||w.get.selectedItem(),n=t.closest(f.menu),i=n.outerHeight(),a=n.scrollTop(),s=b.eq(0).outerHeight(),i=Math.floor(i/s),a=(n.prop("scrollHeight"),"up"==e?a-s*i:a+s*i),s=b.not(f.unselectable),i="up"==e?s.index(t)-i:s.index(t)+i,i=("up"==e?0<=i:i<s.length)?s.eq(i):"up"==e?s.first():s.last();0<i.length&&(w.debug("Scrolling page",e,i),t.removeClass(m.selected),i.addClass(m.selected),v.selectOnKeydown&&w.is.single()&&w.set.selectedItem(i),n.scrollTop(a))},set:{filtered:function(){var e=w.is.multiple(),t=w.is.searchSelection(),n=e&&t,t=t?w.get.query():"",i="string"==typeof t&&0<t.length,a=w.get.searchWidth(),t=""!==t;e&&i&&(w.verbose("Adjusting input width",a,v.glyphWidth),O.css("width",a)),i||n&&t?(w.verbose("Hiding placeholder text"),k.addClass(m.filtered)):e&&(!n||t)||(w.verbose("Showing placeholder text"),k.removeClass(m.filtered))},empty:function(){g.addClass(m.empty)},loading:function(){g.addClass(m.loading)},placeholderText:function(e){e=e||w.get.placeholderText(),w.debug("Setting placeholder text",e),w.set.text(e),k.addClass(m.placeholder)},tabbable:function(){w.is.searchSelection()?(w.debug("Added tabindex to searchable dropdown"),O.val(""),w.check.disabled(),p.attr("tabindex",-1)):(w.debug("Added tabindex to dropdown"),g.attr("tabindex")===ae&&(g.attr("tabindex",0),p.attr("tabindex",-1)))},initialLoad:function(){w.verbose("Setting initial load"),e=!0},activeItem:function(e){v.allowAdditions&&0<e.filter(f.addition).length?e.addClass(m.filtered):e.addClass(m.active)},partialSearch:function(e){var t=w.get.query().length;O.val(e.substr(0,t))},scrollPosition:function(e,t){var n,i,a=(e=e||w.get.selectedItem()).closest(f.menu),s=e&&0<e.length;t=t!==ae&&t,0===w.get.activeItem().length&&(t=!1),e&&0<a.length&&s&&(e.position().top,a.addClass(m.loading),e=(s=a.scrollTop())-a.offset().top+e.offset().top,t||(i=s+a.height()<e+5,n=e-5<s),w.debug("Scrolling to active item",e),(t||n||i)&&a.scrollTop(e),a.removeClass(m.loading))},text:function(e){"combo"===v.action?(w.debug("Changing combo button text",e,E),v.preserveHTML?E.html(e):E.text(e)):"activate"===v.action&&(e!==w.get.placeholderText()&&k.removeClass(m.placeholder),w.debug("Changing text",e,k),k.removeClass(m.filtered),v.preserveHTML?k.html(e):k.text(e))},selectedItem:function(e){var t=w.get.choiceValue(e),n=w.get.choiceText(e,!1),i=w.get.choiceText(e,!0);w.debug("Setting user selection to item",e),w.remove.activeItem(),w.set.partialSearch(n),w.set.activeItem(e),w.set.selected(t,e),w.set.text(i)},selectedLetter:function(e){var t=b.filter("."+m.selected),n=0<t.length&&w.has.firstLetter(t,e),i=!1;n&&(n=t.nextAll(b).eq(0),w.has.firstLetter(n,e)&&(i=n)),i||b.each(function(){if(w.has.firstLetter(te(this),e))return i=te(this),!1}),i&&(w.verbose("Scrolling to next value with letter",e),w.set.scrollPosition(i),t.removeClass(m.selected),i.addClass(m.selected),v.selectOnKeydown&&w.is.single()&&w.set.selectedItem(i))},direction:function(e){"auto"==v.direction?(e?w.is.upward(e)&&w.remove.upward(e):w.remove.upward(),(w.can.openDownward(e)?w.remove:w.set).upward(e),w.is.leftward(e)||w.can.openRightward(e)||w.set.leftward(e)):"upward"==v.direction&&w.set.upward(e)},upward:function(e){(e||g).addClass(m.upward)},leftward:function(e){(e||p).addClass(m.leftward)},value:function(e,t,n,i){e===ae||""===e||Array.isArray(e)&&0===e.length?l.addClass(m.noselection):l.removeClass(m.noselection);var a=w.escape.value(e),s=0<l.length,o=w.get.values(),r=e!==ae?String(e):e;if(s){if(!v.allowReselection&&r==o&&(w.verbose("Skipping value update already same value",e,o),!w.is.initialLoad()))return;w.is.single()&&w.has.selectInput()&&w.can.extendSelect()&&(w.debug("Adding user option",e),w.add.optionValue(e)),w.debug("Updating input value",a,o),P=!0,l.val(a),!1===v.fireOnInit&&w.is.initialLoad()?w.debug("Input native change event ignored on initial load"):!0!==i&&w.trigger.change(),P=!1}else w.verbose("Storing value in metadata",a,l),a!==o&&g.data(h.value,r);!1===v.fireOnInit&&w.is.initialLoad()?w.verbose("No callback on initial load",v.onChange):!0!==i&&v.onChange.call(H,e,t,n)},active:function(){g.addClass(m.active)},multiple:function(){g.addClass(m.multiple)},visible:function(){g.addClass(m.visible)},exactly:function(e,t){w.debug("Setting selected to exact values"),w.clear(),w.set.selected(e,t)},selected:function(e,r,l,c){var u=w.is.multiple();(r=v.allowAdditions?r||w.get.itemWithAdditions(e):r||w.get.item(e))&&(w.debug("Setting selected menu item to",r),w.is.multiple()&&w.remove.searchWidth(),w.is.single()?(w.remove.activeItem(),w.remove.selectedItem()):v.useLabels&&w.remove.selectedItem(),r.each(function(){var e=te(this),t=w.get.choiceText(e),n=w.get.choiceValue(e,t),i=e.hasClass(m.filtered),a=e.hasClass(m.active),s=e.hasClass(m.addition),o=u&&1==r.length;u?!a||s?(v.apiSettings&&v.saveRemoteData&&w.save.remoteData(t,n),v.useLabels?(w.add.label(n,t,o),w.add.value(n,t,e),w.set.activeItem(e),w.filterActive(),w.select.nextAvailable(r)):(w.add.value(n,t,e),w.set.text(w.add.variables(C.count)),w.set.activeItem(e))):i||!v.useLabels&&!d||(w.debug("Selected active value, removing label"),w.remove.selected(n)):(v.apiSettings&&v.saveRemoteData&&w.save.remoteData(t,n),c||w.set.text(t),w.set.value(n,t,e,l),e.addClass(m.active).addClass(m.selected))}),c||w.remove.searchTerm())}},add:{label:function(e,t,n){var i,a=w.is.searchSelection()?O:k,s=w.escape.value(e);v.ignoreCase&&(s=s.toLowerCase()),i=te("<a />").addClass(m.label).attr("data-"+h.value,s).html(L.label(s,t,v.preserveHTML,v.className)),i=v.onLabelCreate.call(i,s,t),w.has.label(e)?w.debug("User selection already exists, skipping",s):(v.label.variation&&i.addClass(v.label.variation),!0===n?(w.debug("Animating in label",i),i.addClass(m.hidden).insertBefore(a).transition({animation:v.label.transition,debug:v.debug,verbose:v.verbose,duration:v.label.duration})):(w.debug("Adding selection label",i),i.insertBefore(a)))},message:function(e){var t=p.children(f.message),e=v.templates.message(w.add.variables(e));0<t.length?t.html(e):te("<div/>").html(e).addClass(m.message).appendTo(p)},optionValue:function(e){var t=w.escape.value(e);0<l.find('option[value="'+w.escape.string(t)+'"]').length||(w.disconnect.selectObserver(),w.is.single()&&(w.verbose("Removing previous user addition"),l.find("option."+m.addition).remove()),te("<option/>").prop("value",t).addClass(m.addition).html(e).appendTo(l),w.verbose("Adding user addition as an <option>",e),w.observe.select())},userSuggestion:function(e){var t=p.children(f.addition),n=w.get.item(e),n=n&&n.not(f.addition).length,i=0<t.length;v.useLabels&&w.has.maxSelections()||(""===e||n?t.remove():(i?(t.data(h.value,e).data(h.text,e).attr("data-"+h.value,e).attr("data-"+h.text,e).removeClass(m.filtered),v.hideAdditions||(n=v.templates.addition(w.add.variables(C.addResult,e)),t.html(n)),w.verbose("Replacing user suggestion with new value",t)):((t=w.create.userChoice(e)).prependTo(p),w.verbose("Adding item choice to menu corresponding with user choice addition",t)),v.hideAdditions&&!w.is.allFiltered()||t.addClass(m.selected).siblings().removeClass(m.selected),w.refreshItems()))},variables:function(e,t){var n,i=-1!==e.search("{count}"),a=-1!==e.search("{maxCount}"),s=-1!==e.search("{term}");return w.verbose("Adding templated variables to message",e),i&&(n=w.get.selectionCount(),e=e.replace("{count}",n)),a&&(n=w.get.selectionCount(),e=e.replace("{maxCount}",v.maxSelections)),s&&(i=t||w.get.query(),e=e.replace("{term}",i)),e},value:function(e,t,n){var i,a=w.get.values(!0);w.has.value(e)?w.debug("Value already selected"):""!==e?(i=Array.isArray(a)?(i=a.concat([e]),w.get.uniqueArray(i)):[e],w.has.selectInput()?w.can.extendSelect()&&(w.debug("Adding value to select",e,i,l),w.add.optionValue(e)):(i=i.join(v.delimiter),w.debug("Setting hidden input to delimited value",i,l)),!1===v.fireOnInit&&w.is.initialLoad()?w.verbose("Skipping onadd callback on initial load",v.onAdd):v.onAdd.call(H,e,t,n),w.set.value(i,t,n),w.check.maxSelections()):w.debug("Cannot select blank values from multiselect")}},remove:{active:function(){g.removeClass(m.active)},activeLabel:function(){g.find(f.label).removeClass(m.active)},empty:function(){g.removeClass(m.empty)},loading:function(){g.removeClass(m.loading)},initialLoad:function(){e=!1},upward:function(e){(e||g).removeClass(m.upward)},leftward:function(e){(e||p).removeClass(m.leftward)},visible:function(){g.removeClass(m.visible)},activeItem:function(){b.removeClass(m.active)},filteredItem:function(){v.useLabels&&w.has.maxSelections()||((v.useLabels&&w.is.multiple()?b.not("."+m.active):b).removeClass(m.filtered),v.hideDividers&&M.removeClass(m.hidden),w.remove.empty())},optionValue:function(e){var e=w.escape.value(e),t=l.find('option[value="'+w.escape.string(e)+'"]');0<t.length&&t.hasClass(m.addition)&&(r&&(r.disconnect(),w.verbose("Temporarily disconnecting mutation observer")),t.remove(),w.verbose("Removing user addition as an <option>",e),r&&r.observe(l[0],{childList:!0,subtree:!0}))},message:function(){p.children(f.message).remove()},searchWidth:function(){O.css("width","")},searchTerm:function(){w.verbose("Cleared search term"),O.val(""),w.set.filtered()},userAddition:function(){b.filter(f.addition).remove()},selected:function(e,t,i){if(!(t=v.allowAdditions?t||w.get.itemWithAdditions(e):t||w.get.item(e)))return!1;t.each(function(){var e=te(this),t=w.get.choiceText(e),n=w.get.choiceValue(e,t);w.is.multiple()?v.useLabels?(w.remove.value(n,t,e,i),w.remove.label(n)):(w.remove.value(n,t,e,i),0===w.get.selectionCount()?w.set.placeholderText():w.set.text(w.add.variables(C.count))):w.remove.value(n,t,e,i),e.removeClass(m.filtered).removeClass(m.active),v.useLabels&&e.removeClass(m.selected)})},selectedItem:function(){b.removeClass(m.selected)},value:function(e,t,n,i){var a,s=w.get.values();e=w.escape.htmlEntities(e),w.has.selectInput()?(w.verbose("Input is <select> removing selected option",e),a=w.remove.arrayValue(e,s),w.remove.optionValue(e)):(w.verbose("Removing from delimited values",e),a=(a=w.remove.arrayValue(e,s)).join(v.delimiter)),!1===v.fireOnInit&&w.is.initialLoad()?w.verbose("No callback on initial load",v.onRemove):v.onRemove.call(H,e,t,n),w.set.value(a,t,n,i),w.check.maxSelections()},arrayValue:function(t,e){return Array.isArray(e)||(e=[e]),e=te.grep(e,function(e){return t!=e}),w.verbose("Removed value from delimited string",t,e),e},label:function(e,t){e=w.escape.value(e),e=g.find(f.label).filter("[data-"+h.value+'="'+w.escape.string(v.ignoreCase?e.toLowerCase():e)+'"]');w.verbose("Removing label",e),e.remove()},activeLabels:function(e){e=e||g.find(f.label).filter("."+m.active),w.verbose("Removing active label selections",e),w.remove.labels(e)},labels:function(e,a){e=e||g.find(f.label),w.verbose("Removing labels",e),e.each(function(){var e=te(this),t=e.data(h.value),n=t!==ae?String(t):t,i=w.is.userValue(n);!1!==v.onLabelRemove.call(e,t)?(w.remove.message(),i?(w.remove.value(n,n,w.get.item(n),a),w.remove.label(n)):w.remove.selected(n,!1,a)):w.debug("Label remove callback cancelled removal")})},tabbable:function(){w.is.searchSelection()?(w.debug("Searchable dropdown initialized"),O.removeAttr("tabindex")):(w.debug("Simple selection dropdown initialized"),g.removeAttr("tabindex")),p.removeAttr("tabindex")},diacritics:function(e){return v.ignoreDiacritics?e.normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}},has:{menuSearch:function(){return w.has.search()&&0<O.closest(p).length},clearItem:function(){return 0<V.length},search:function(){return 0<O.length},sizer:function(){return 0<q.length},selectInput:function(){return l.is("select")},minCharacters:function(e){return v.minCharacters&&!N?(e=e!==ae?String(e):String(w.get.query())).length>=v.minCharacters:!(N=!1)},firstLetter:function(e,t){return!(!e||0===e.length||"string"!=typeof t)&&(e=w.get.choiceText(e,!1),(t=t.toLowerCase())==String(e).charAt(0).toLowerCase())},input:function(){return 0<l.length},items:function(){return 0<b.length},menu:function(){return 0<p.length},subMenu:function(e){return 0<(e||p).find(f.menu).length},message:function(){return 0!==p.children(f.message).length},label:function(e){var e=w.escape.value(e),t=g.find(f.label);return v.ignoreCase&&(e=e.toLowerCase()),0<t.filter("[data-"+h.value+'="'+w.escape.string(e)+'"]').length},maxSelections:function(){return v.maxSelections&&w.get.selectionCount()>=v.maxSelections},allResultsFiltered:function(){var e=b.not(f.addition);return e.filter(f.unselectable).length===e.length},userSuggestion:function(){return 0<p.children(f.addition).length},query:function(){return""!==w.get.query()},value:function(e){return v.ignoreCase?w.has.valueIgnoringCase(e):w.has.valueMatchingCase(e)},valueMatchingCase:function(e){var t=w.get.values(!0);return!!(Array.isArray(t)?t&&-1!==te.inArray(e,t):t==e)},valueIgnoringCase:function(n){var e=w.get.values(!0),i=!1;return Array.isArray(e)||(e=[e]),te.each(e,function(e,t){if(String(n).toLowerCase()==String(t).toLowerCase())return!(i=!0)}),i}},is:{active:function(){return g.hasClass(m.active)},animatingInward:function(){return p.transition("is inward")},animatingOutward:function(){return p.transition("is outward")},bubbledLabelClick:function(e){return te(e.target).is("select, input")&&0<g.closest("label").length},bubbledIconClick:function(e){return 0<te(e.target).closest(R).length},chrome:function(){return!(!ne.chrome||!ne.chrome.webstore&&!ne.chrome.runtime)},alreadySetup:function(){return g.is("select")&&g.parent(f.dropdown).data(I)!==ae&&0===g.prev().length},animating:function(e){return e?e.transition&&e.transition("is animating"):p.transition&&p.transition("is animating")},leftward:function(e){return(e||p).hasClass(m.leftward)},clearable:function(){return g.hasClass(m.clearable)||v.clearable},disabled:function(){return g.hasClass(m.disabled)},focused:function(){return ie.activeElement===g[0]},focusedOnSearch:function(){return ie.activeElement===O[0]},allFiltered:function(){return(w.is.multiple()||w.has.search())&&!(0==v.hideAdditions&&w.has.userSuggestion())&&!w.has.message()&&w.has.allResultsFiltered()},hidden:function(e){return!w.is.visible(e)},initialLoad:function(){return e},inObject:function(n,e){var i=!1;return te.each(e,function(e,t){if(t==n)return i=!0}),i},multiple:function(){return g.hasClass(m.multiple)},remote:function(){return v.apiSettings&&w.can.useAPI()},noApiCache:function(){return v.apiSettings&&!v.apiSettings.cache},single:function(){return!w.is.multiple()},selectMutation:function(e){var n=!1;return te.each(e,function(e,t){if(te(t.target).is("select")||te(t.addedNodes).is("select"))return!(n=!0)}),n},search:function(){return g.hasClass(m.search)},searchSelection:function(){return w.has.search()&&1===O.parent(f.dropdown).length},selection:function(){return g.hasClass(m.selection)},userValue:function(e){return-1!==te.inArray(e,w.get.userValues())},upward:function(e){return(e||g).hasClass(m.upward)},visible:function(e){return(e||p).hasClass(m.visible)},verticallyScrollableContext:function(){var e=D.get(0)!==ne&&D.css("overflow-y");return"auto"==e||"scroll"==e},horizontallyScrollableContext:function(){var e=D.get(0)!==ne&&D.css("overflow-X");return"auto"==e||"scroll"==e}},can:{activate:function(e){return!!v.useLabels||(!w.has.maxSelections()||!(!w.has.maxSelections()||!e.hasClass(m.active)))},openDownward:function(e){var t,e=e||p,n=!0;return e.addClass(m.loading),t={context:{offset:D.get(0)===ne?{top:0,left:0}:D.offset(),scrollTop:D.scrollTop(),height:D.outerHeight()},menu:{offset:e.offset(),height:e.outerHeight()}},w.is.verticallyScrollableContext()&&(t.menu.offset.top+=t.context.scrollTop),w.has.subMenu(e)&&(t.menu.height+=e.find(f.menu).first().outerHeight()),n=(t={above:t.context.scrollTop<=t.menu.offset.top-t.context.offset.top-t.menu.height,below:t.context.scrollTop+t.context.height>=t.menu.offset.top-t.context.offset.top+t.menu.height}).below?(w.verbose("Dropdown can fit in context downward",t),!0):t.above?(w.verbose("Dropdown cannot fit below, opening upward",t),!1):(w.verbose("Dropdown cannot fit in either direction, favoring downward",t),!0),e.removeClass(m.loading),n},openRightward:function(e){var t,e=e||p,n=!0;return e.addClass(m.loading),t={context:{offset:D.get(0)===ne?{top:0,left:0}:D.offset(),scrollLeft:D.scrollLeft(),width:D.outerWidth()},menu:{offset:e.offset(),width:e.outerWidth()}},w.is.horizontallyScrollableContext()&&(t.menu.offset.left+=t.context.scrollLeft),(t=t.menu.offset.left-t.context.offset.left+t.menu.width>=t.context.scrollLeft+t.context.width)&&(w.verbose("Dropdown cannot fit in context rightward",t),n=!1),e.removeClass(m.loading),n},click:function(){return $||"click"==v.on},extendSelect:function(){return v.allowAdditions||v.apiSettings},show:function(){return!w.is.disabled()&&(w.has.items()||w.has.message())},useAPI:function(){return te.fn.api!==ae}},animate:{show:function(e,t){var n=t||p,i=t?function(){}:function(){w.hideSubMenus(),w.hideOthers(),w.set.active()};e=te.isFunction(e)?e:function(){},w.verbose("Doing menu show animation",n),w.set.direction(t),t=v.transition.showMethod||w.get.transition(t),w.is.selection()&&w.set.scrollPosition(w.get.selectedItem(),!0),(w.is.hidden(n)||w.is.animating(n))&&("none"===t?(i(),n.transition({displayType:w.get.displayType()}).transition("show"),e.call(H)):te.fn.transition!==ae&&g.transition("is supported")?n.transition({animation:t+" in",debug:v.debug,verbose:v.verbose,duration:v.transition.showDuration||v.duration,queue:!0,onStart:i,displayType:w.get.displayType(),onComplete:function(){e.call(H)}}):w.error(T.noTransition,t))},hide:function(e,t){var n=t||p,i=t?function(){}:function(){w.can.click()&&w.unbind.intent(),w.remove.active()},t=v.transition.hideMethod||w.get.transition(t);e=te.isFunction(e)?e:function(){},(w.is.visible(n)||w.is.animating(n))&&(w.verbose("Doing menu hide animation",n),"none"===t?(i(),n.transition({displayType:w.get.displayType()}).transition("hide"),e.call(H)):te.fn.transition!==ae&&g.transition("is supported")?n.transition({animation:t+" out",duration:v.transition.hideDuration||v.duration,debug:v.debug,verbose:v.verbose,queue:!1,onStart:i,displayType:w.get.displayType(),onComplete:function(){e.call(H)}}):w.error(T.transition))}},hideAndClear:function(){w.remove.searchTerm(),w.has.maxSelections()||(w.has.search()?w.hide(function(){w.remove.filteredItem()}):w.hide())},delay:{show:function(){w.verbose("Delaying show event to ensure user intent"),clearTimeout(w.timer),w.timer=setTimeout(w.show,v.delay.show)},hide:function(){w.verbose("Delaying hide event to ensure user intent"),clearTimeout(w.timer),w.timer=setTimeout(w.hide,v.delay.hide)}},escape:{value:function(e){var t=Array.isArray(e),n="string"==typeof e,i=!n&&!t,n=n&&-1!==e.search(A.quote),a=[];return i||!n?e:(w.debug("Encoding quote values for use in select",e),t?(te.each(e,function(e,t){a.push(t.replace(A.quote,"&quot;"))}),a):e.replace(A.quote,"&quot;"))},string:function(e){return(e=String(e)).replace(A.escape,"\\$&")},htmlEntities:function(e){var t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?(e=e.replace(/&(?![a-z0-9#]{1,6};)/,"&amp;")).replace(/[<>"'`]/g,function(e){return t[e]}):e}},setting:function(e,t){if(w.debug("Changing setting",e,t),te.isPlainObject(e))te.extend(!0,v,e);else{if(t===ae)return v[e];te.isPlainObject(v[e])?te.extend(!0,v[e],t):v[e]=t}},internal:function(e,t){if(te.isPlainObject(e))te.extend(!0,w,e);else{if(t===ae)return w[e];w[e]=t}},debug:function(){!v.silent&&v.debug&&(v.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,v.name+":"),w.debug.apply(console,arguments)))},verbose:function(){!v.silent&&v.verbose&&v.debug&&(v.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),w.verbose.apply(console,arguments)))},error:function(){v.silent||(w.error=Function.prototype.bind.call(console.error,console,v.name+":"),w.error.apply(console,arguments))},performance:{log:function(e){var t,n;v.performance&&(n=(t=(new Date).getTime())-(G||t),G=t,J.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:H,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,500)},display:function(){var e=v.name+":",n=0;G=!1,clearTimeout(w.performance.timer),te.each(J,function(e,t){n+=t["Execution Time"]}),e+=" "+n+"ms",Y&&(e+=" '"+Y+"'"),(console.group!==ae||console.table!==ae)&&0<J.length&&(console.groupCollapsed(e),console.table?console.table(J):te.each(J,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),J=[]}},invoke:function(i,e,t){var a,s,n,o=U;return e=e||ee,t=H||t,"string"==typeof i&&o!==ae&&(i=i.split(/[\. ]/),a=i.length-1,te.each(i,function(e,t){var n=e!=a?t+i[e+1].charAt(0).toUpperCase()+i[e+1].slice(1):i;if(te.isPlainObject(o[n])&&e!=a)o=o[n];else{if(o[n]!==ae)return s=o[n],!1;{if(!te.isPlainObject(o[t])||e==a)return o[t]!==ae?s=o[t]:w.error(T.method,i),!1;o=o[t]}}})),te.isFunction(s)?n=s.apply(t,e):s!==ae&&(n=s),Array.isArray(K)?K.push(n):K!==ae?K=[K,n]:n!==ae&&(K=n),s}};_?(U===ae&&w.initialize(),w.invoke(Z)):(U!==ae&&U.invoke("destroy"),w.initialize())}),K!==ae?K:W},te.fn.dropdown.settings={silent:!1,debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",values:!1,clearable:!1,apiSettings:!1,selectOnKeydown:!0,minCharacters:0,filterRemoteData:!1,saveRemoteData:!0,throttle:200,context:ne,direction:"auto",keepOnScreen:!0,match:"both",fullTextSearch:!1,ignoreDiacritics:!1,hideDividers:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,forceSelection:!0,allowAdditions:!1,ignoreCase:!1,ignoreSearchCase:!0,hideAdditions:!0,maxSelections:!1,useLabels:!0,delimiter:",",showOnFocus:!0,allowReselection:!1,allowTab:!0,allowCategorySelection:!1,fireOnInit:!1,transition:"auto",duration:200,displayType:!1,glyphWidth:1.037,headerDivider:!0,label:{transition:"scale",duration:200,variation:!1},delay:{hide:300,show:200,search:20,touch:50},onChange:function(e,t,n){},onAdd:function(e,t,n){},onRemove:function(e,t,n){},onSearch:function(e){},onLabelSelect:function(e){},onLabelCreate:function(e,t){return te(this)},onLabelRemove:function(e){return!0},onNoResults:function(e){return!0},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add <b>{term}</b>",count:"{count} selected",maxSelections:"Max {maxCount} selections",noResults:"No results found.",serverError:"There was an error contacting the server"},error:{action:"You called a dropdown action that was not defined",alreadySetup:"Once a select has been initialized behaviors must be called on the created ui dropdown",labels:"Allowing user additions currently requires the use of labels.",missingMultiple:"<select> requires multiple property to be set to correctly preserve multiple values",method:"The method you called is not defined.",noAPI:"The API module is required to load resources remotely",noStorage:"Saving remote data requires session storage",noTransition:"This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>",noNormalize:'"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/unorm@1.4.1/lib/unorm.min.js> as a polyfill.'},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s:=@]/g,quote:/"/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholder",text:"text",value:"value"},fields:{remoteValues:"results",values:"values",disabled:"disabled",name:"name",description:"description",descriptionVertical:"descriptionVertical",value:"value",text:"text",type:"type",image:"image",imageClass:"imageClass",icon:"icon",iconClass:"iconClass",class:"class",divider:"divider"},keys:{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40},selector:{addition:".addition",divider:".divider, .header",dropdown:".ui.dropdown",hidden:".hidden",icon:"> .dropdown.icon",input:'> input[type="hidden"], > select',item:".item",label:"> .label",remove:"> .label > .delete.icon",siblingLabel:".label",menu:".menu",message:".message",menuIcon:".dropdown.icon",search:"input.search, .menu > .search > input, .menu input.search",sizer:"> span.sizer",text:"> .text:not(.icon)",unselectable:".disabled, .filtered",clearIcon:"> .remove.icon"},className:{active:"active",addition:"addition",animating:"animating",description:"description",descriptionVertical:"vertical",disabled:"disabled",empty:"empty",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",icon:"icon",image:"image",item:"item",label:"ui label",loading:"loading",menu:"menu",message:"message",multiple:"multiple",placeholder:"default",sizer:"sizer",search:"search",selected:"selected",selection:"selection",text:"text",upward:"upward",leftward:"left",visible:"visible",clearable:"clearable",noselection:"noselection",delete:"delete",header:"header",divider:"divider",groupIcon:"",unfilterable:"unfilterable"}},te.fn.dropdown.settings.templates={deQuote:function(e,t){return String(e).replace(/"/g,t?"&quot;":"")},escape:function(e,t){if(t)return e;var n={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?(e=e.replace(/&(?![a-z0-9#]{1,6};)/,"&amp;")).replace(/[<>"'`]/g,function(e){return n[e]}):e},dropdown:function(e,t,n,i){var a=e.placeholder||!1,s="",o=te.fn.dropdown.settings.templates.escape;return s=(s=(s=(s+='<i class="dropdown icon"></i>')+(a?'<div class="default text">'+o(a,n)+"</div>":'<div class="text"></div>'))+('<div class="'+i.menu+'">'))+te.fn.dropdown.settings.templates.menu(e,t,n,i)+"</div>"},menu:function(e,l,c,u){var e=e[l.values]||[],d="",v=te.fn.dropdown.settings.templates.escape,m=te.fn.dropdown.settings.templates.deQuote;return te.each(e,function(e,t){var n,i,a,s,o=t[l.type]||"item",r=-1!==o.indexOf("menu");"item"===o||r?(n=t[l.text]?' data-text="'+m(t[l.text],!0)+'"':"",a=t[l.disabled]?u.disabled+" ":"",s=t[l.descriptionVertical]?u.descriptionVertical+" ":"",i=""!=v(t[l.description]||"",c),d+='<div class="'+a+s+(t[l.class]?m(t[l.class]):u.item)+'" data-value="'+m(t[l.value],!0)+'"'+n+">",r&&(d+='<i class="'+(-1!==o.indexOf("left")?"left":"")+' dropdown icon"></i>'),t[l.image]&&(d+='<img class="'+(t[l.imageClass]?m(t[l.imageClass]):u.image)+'" src="'+m(t[l.image])+'">'),t[l.icon]&&(d+='<i class="'+m(t[l.icon])+" "+(t[l.iconClass]?m(t[l.iconClass]):u.icon)+'"></i>'),i&&(d=(d+='<span class="'+u.description+'">'+v(t[l.description]||"",c)+"</span>")+(r?"":'<span class="'+u.text+'">')),r&&(d+='<span class="'+u.text+'">'),d+=v(t[l.name]||"",c),r?d=(d=d+'</span><div class="'+o+'">')+te.fn.dropdown.settings.templates.menu(t,l,c,u)+"</div>":i&&(d+="</span>"),d+="</div>"):"header"===o&&(a=v(t[l.name]||"",c),s=t[l.icon]?m(t[l.icon]):u.groupIcon,""===a&&""===s||(d+='<div class="'+(t[l.class]?m(t[l.class]):u.header)+'">',""!==s&&(d+='<i class="'+s+" "+(t[l.iconClass]?m(t[l.iconClass]):u.icon)+'"></i>'),d=d+a+"</div>"),t[l.divider]&&(d+='<div class="'+u.divider+'"></div>'))}),d},label:function(e,t,n,i){return(0,te.fn.dropdown.settings.templates.escape)(t,n)+'<i class="'+i.delete+' icon"></i>'},message:function(e){return e},addition:function(e){return e}}}(jQuery,window,document);