!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports&&"function"==typeof require?e(require("jquery")):e(jQuery)}(function(d){"use strict";var n={escapeRegExChars:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(e){var t=document.createElement("div");return t.className=e,t.style.position="absolute",t.style.display="none",t}},o=27,s=9,i=13,a=38,l=39,r=40;function u(e,t){function n(){}var o=this,s={ajaxSettings:{},autoSelectFirst:!1,appendTo:document.body,serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:u.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:n,onSearchComplete:n,onSearchError:n,preserveInput:!1,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(e,t,n){return-1!==e.value.toLowerCase().indexOf(n)},paramName:"query",transformResult:function(e){return"string"==typeof e?JSON.parse(e):e},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1};o.element=e,o.el=d(e),o.suggestions=[],o.badQueries=[],o.selectedIndex=-1,o.currentValue=o.element.value,o.intervalId=0,o.cachedResponse={},o.onChangeInterval=null,o.onChange=null,o.isLocal=!1,o.suggestionsContainer=null,o.noSuggestionsContainer=null,o.options=d.extend({},s,t),o.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},o.hint=null,o.hintValue="",o.selection=null,o.initialize(),o.setOptions(t)}u.utils=n,(d.Autocomplete=u).formatResult=function(e,t){t="("+n.escapeRegExChars(t)+")";return e.value.replace(new RegExp(t,"gi"),"$1").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/<(\/?strong)>/g,"<$1>")},u.prototype={killerFn:null,initialize:function(){var e,t=this,n="."+t.classes.suggestion,o=t.classes.selected,s=t.options;t.element.setAttribute("autocomplete","off"),t.killerFn=function(e){0===d(e.target).closest("."+t.options.containerClass).length&&(t.killSuggestions(),t.disableKillerFn())},t.noSuggestionsContainer=d('
').html(this.options.noSuggestionNotice).get(0),t.suggestionsContainer=u.utils.createNode(s.containerClass),(e=d(t.suggestionsContainer)).appendTo(s.appendTo),"auto"!==s.width&&e.width(s.width),e.on("mouseover.autocomplete",n,function(){t.activate(d(this).data("index"))}),e.on("mouseout.autocomplete",function(){t.selectedIndex=-1,e.children("."+o).removeClass(o)}),e.on("click.autocomplete",n,function(){t.select(d(this).data("index"))}),t.fixPositionCapture=function(){t.visible&&t.fixPosition()},d(window).on("resize.autocomplete",t.fixPositionCapture),t.el.on("keydown.autocomplete",function(e){t.onKeyPress(e)}),t.el.on("keyup.autocomplete",function(e){t.onKeyUp(e)}),t.el.on("blur.autocomplete",function(){t.onBlur()}),t.el.on("focus.autocomplete",function(){t.onFocus()}),t.el.on("change.autocomplete",function(e){t.onKeyUp(e)}),t.el.on("input.autocomplete",function(e){t.onKeyUp(e)})},onFocus:function(){var e=this;e.fixPosition(),0===e.options.minChars&&0===e.el.val().length&&e.onValueChange()},onBlur:function(){this.enableKillerFn()},abortAjax:function(){var e=this;e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null)},setOptions:function(e){var t=this,n=t.options;d.extend(n,e),t.isLocal=Array.isArray(n.lookup),t.isLocal&&(n.lookup=t.verifySuggestionsFormat(n.lookup)),n.orientation=t.validateOrientation(n.orientation,"bottom"),d(t.suggestionsContainer).css({"max-height":n.maxHeight+"px",width:n.width+"px","z-index":n.zIndex})},clearCache:function(){this.cachedResponse={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var e=this;e.disabled=!0,clearInterval(e.onChangeInterval),e.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var e,t,n,o,s,i,a,l,r=this,u=d(r.suggestionsContainer),c=u.parent().get(0);c!==document.body&&!r.options.forceFixPosition||(i=r.options.orientation,e=u.outerHeight(),t=r.el.outerHeight(),n={top:(l=r.el.offset()).top,left:l.left},"auto"===i&&(a=d(window).height(),o=-(s=d(window).scrollTop())+l.top-e,s=s+a-(l.top+t+e),i=Math.max(o,s)===o?"top":"bottom"),n.top+="top"===i?-e:t,c!==document.body&&(a=u.css("opacity"),r.visible||u.css("opacity",0).show(),l=u.offsetParent().offset(),n.top-=l.top,n.left-=l.left,r.visible||u.css("opacity",a).hide()),"auto"===r.options.width&&(n.width=r.el.outerWidth()-2+"px"),u.css(n))},enableKillerFn:function(){d(document).on("click.autocomplete",this.killerFn)},disableKillerFn:function(){d(document).off("click.autocomplete",this.killerFn)},killSuggestions:function(){var e=this;e.stopKillSuggestions(),e.intervalId=window.setInterval(function(){e.visible&&(e.el.val(e.currentValue),e.hide()),e.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var e=this.el.val().length,t=this.element.selectionStart;return"number"==typeof t?t===e:!document.selection||((t=document.selection.createRange()).moveStart("character",-e),e===t.text.length)},onKeyPress:function(e){var t=this;if(t.disabled||t.visible||e.which!==r||!t.currentValue){if(!t.disabled&&t.visible){switch(e.which){case o:t.el.val(t.currentValue),t.hide();break;case l:if(t.hint&&t.options.onHint&&t.isCursorAtEnd()){t.selectHint();break}return;case s:if(t.hint&&t.options.onHint)return void t.selectHint();if(-1===t.selectedIndex)return void t.hide();if(t.select(t.selectedIndex),!1===t.options.tabDisabled)return;break;case i:if(-1===t.selectedIndex)return void t.hide();t.select(t.selectedIndex);break;case a:t.moveUp();break;case r:t.moveDown();break;default:return}e.stopImmediatePropagation(),e.preventDefault()}}else t.suggest()},onKeyUp:function(e){var t=this;if(!t.disabled){switch(e.which){case a:case r:return}clearInterval(t.onChangeInterval),t.currentValue!==t.el.val()&&(t.findBestHint(),0s&&(e.suggestions=e.suggestions.slice(0,s)),e},getSuggestions:function(o){var e,t,n,s=this,i=s.options,a=i.serviceUrl;i.params[i.paramName]=o,e=i.ignoreParams?null:i.params,!1!==i.onSearchStart.call(s.element,i.params)&&("function"==typeof i.lookup?i.lookup(o,function(e){s.suggestions=e.suggestions,s.suggest(),i.onSearchComplete.call(s.element,o,e.suggestions)}):(n=s.isLocal?s.getSuggestionsLocal(o):("function"==typeof a&&(a=a.call(s.element,o)),t=a+"?"+d.param(e||{}),s.cachedResponse[t]))&&Array.isArray(n.suggestions)?(s.suggestions=n.suggestions,s.suggest(),i.onSearchComplete.call(s.element,o,n.suggestions)):s.isBadQuery(o)?i.onSearchComplete.call(s.element,o,[]):(s.abortAjax(),n={url:a,data:e,type:i.type,dataType:i.dataType},d.extend(n,i.ajaxSettings),s.currentRequest=d.ajax(n).done(function(e){s.currentRequest=null,e=i.transformResult(e,o),s.processResponse(e,o,t),i.onSearchComplete.call(s.element,o,e.suggestions)}).fail(function(e,t,n){i.onSearchError.call(s.element,o,e,t,n)})))},isBadQuery:function(e){if(this.options.preventBadQueries)for(var t=this.badQueries,n=t.length;n--;)if(0===e.indexOf(t[n]))return!0;return!1},hide:function(){var e=this,t=d(e.suggestionsContainer);"function"==typeof e.options.onHide&&e.visible&&e.options.onHide.call(e.element,t),e.visible=!1,e.selectedIndex=-1,clearInterval(e.onChangeInterval),d(e.suggestionsContainer).hide(),e.signalHint(null)},suggest:function(){var e,t,n,o,s,i,a,l,r,u,c,g;0===this.suggestions.length?this.options.showNoSuggestionNotice?this.noSuggestions():this.hide():(t=(e=this).options,n=t.groupBy,o=t.formatResult,s=e.getQuery(e.currentValue),i=e.classes.suggestion,a=e.classes.selected,l=d(e.suggestionsContainer),r=d(e.noSuggestionsContainer),u=t.beforeRender,c="",t.triggerSelectOnValidInput&&e.isExactMatch(s)?e.select(0):(d.each(e.suggestions,function(e,t){n&&(c+=function(e){e=e.data[n];return g===e?"":'
'+(g=e)+"
"}(t)),c+='
'+o(t,s)+"
"}),this.adjustContainerWidth(),r.detach(),l.html(c),"function"==typeof u&&u.call(e.element,l),e.fixPosition(),l.show(),t.autoSelectFirst&&(e.selectedIndex=0,l.scrollTop(0),l.children("."+i).first().addClass(a)),e.visible=!0,e.findBestHint()))},noSuggestions:function(){var e=d(this.suggestionsContainer),t=d(this.noSuggestionsContainer);this.adjustContainerWidth(),t.detach(),e.empty(),e.append(t),this.fixPosition(),e.show(),this.visible=!0},adjustContainerWidth:function(){var e=this.options,t=d(this.suggestionsContainer);"auto"===e.width&&(e=this.el.outerWidth()-2,t.width(0t.selectedIndex?(o=s.get(t.selectedIndex),d(o).addClass(n),o):null},selectHint:function(){var e=d.inArray(this.hint,this.suggestions);this.select(e)},select:function(e){this.hide(),this.onSelect(e)},moveUp:function(){var e=this;-1!==e.selectedIndex&&(0===e.selectedIndex?(d(e.suggestionsContainer).children().first().removeClass(e.classes.selected),e.selectedIndex=-1,e.el.val(e.currentValue),e.findBestHint()):e.adjustScroll(e.selectedIndex-1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(e){var t,n,o,s=this,i=s.activate(e);i&&(t=d(i).outerHeight(),i=i.offsetTop,o=(n=d(s.suggestionsContainer).scrollTop())+s.options.maxHeight-t,i