!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports&&"function"==typeof require?e(require("jquery")):e(jQuery)}(function(v){"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}},s=27,i=9,o=13,a=38,l=39,r=40;function u(e,t){function n(){}var s=this,i={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:"wd-search-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};s.element=e,s.el=v(e),s.suggestions=[],s.badQueries=[],s.selectedIndex=-1,s.currentValue=s.element.value,s.intervalId=0,s.cachedResponse={},s.onChangeInterval=null,s.onChange=null,s.isLocal=!1,s.suggestionsContainer=null,s.noSuggestionsContainer=null,s.options=v.extend({},i,t),s.classes={selected:"wd-active",suggestion:"wd-suggestion"},s.hint=null,s.hintValue="",s.selection=null,s.initialize(),s.setOptions(t)}u.utils=n,(v.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,s=t.classes.selected,i=t.options,i=(t.element.setAttribute("autocomplete","off"),t.killerFn=function(e){0===v(e.target).closest("."+t.options.containerClass).length&&(t.killSuggestions(),t.disableKillerFn())},t.noSuggestionsContainer=v('
').html(this.options.noSuggestionNotice).get(0),t.suggestionsContainer=u.utils.createNode(i.containerClass),(e=v(t.suggestionsContainer)).appendTo(i.appendTo),"auto"!==i.width&&e.width(i.width),e.on("mouseover.autocomplete",n,function(e){if(v(this).hasClass("wd-not-found"))return e.preventDefault(),!1;t.activate(v(this).data("index"))}),e.on("mouseout.autocomplete",function(){t.selectedIndex=-1,e.find("."+s).removeClass(s)}),e.on("click.autocomplete",n,function(e){if(v(this).hasClass("wd-not-found")||v(this).hasClass("wd-search-title"))return e.preventDefault(),!1;e=0 a").length;t.select(v(this).data("index"),e)}),t.fixPositionCapture=function(){t.visible&&t.fixPosition()},v(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)}),t.el.parent().find(".wd-clear-search"));i&&i.on("click",function(e){t.onClearSearch(e)})},onClearSearch:function(e){e.target.classList.contains("wd-clear-search")&&e.target.classList.add("wd-hide"),this.clear(),this.el.trigger("focus")},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;v.extend(n,e),t.isLocal=Array.isArray(n.lookup),t.isLocal&&(n.lookup=t.verifySuggestionsFormat(n.lookup)),n.orientation=t.validateOrientation(n.orientation,"bottom"),v(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,s,i,o,a,l,r=this,u=v(r.suggestionsContainer),c=u.parent().get(0);c!==document.body&&!r.options.forceFixPosition||(o=r.options.orientation,e=u.outerHeight(),t=r.el.outerHeight(),n={top:(l=r.el.offset()).top,left:l.left},"auto"===o&&(a=v(window).height(),s=-(i=v(window).scrollTop())+l.top-e,i=i+a-(l.top+t+e),o=Math.max(s,i)===s?"top":"bottom"),n.top+="top"===o?-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(){v(document).on("click.autocomplete",this.killerFn)},disableKillerFn:function(){v(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 s:t.el.val(t.currentValue),t.hide();break;case l:if(t.hint&&t.options.onHint&&t.isCursorAtEnd()){t.selectHint();break}return;case i: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 o:if(-1===t.selectedIndex)return void t.hide(!0);t.select(t.selectedIndex,!0);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(),0i&&(e.suggestions=e.suggestions.slice(0,i)),e},getSuggestions:function(s){var e,t,n,i=this,o=i.options,a=o.serviceUrl;o.params[o.paramName]=s,e=o.ignoreParams?null:o.params,!1!==o.onSearchStart.call(i.element,o.params)&&("function"==typeof o.lookup?o.lookup(s,function(e){i.suggestions=e.suggestions,i.suggest(),o.onSearchComplete.call(i.element,s,e.suggestions)}):(n=i.isLocal?i.getSuggestionsLocal(s):("function"==typeof a&&(a=a.call(i.element,s)),t=a+"?"+v.param(e||{}),i.cachedResponse[t]))&&Array.isArray(n.suggestions)?(i.suggestions=n.suggestions,i.suggest(),o.onSearchComplete.call(i.element,s,n.suggestions)):i.isBadQuery(s)?o.onSearchComplete.call(i.element,s,[]):(i.abortAjax(),n={url:a,data:e,type:o.type,dataType:o.dataType},v.extend(n,o.ajaxSettings),i.currentRequest=v.ajax(n).done(function(e){i.currentRequest=null,e=o.transformResult(e,s),i.processResponse(e,s,t),o.onSearchComplete.call(i.element,s,e.suggestions)}).fail(function(e,t,n){o.onSearchError.call(i.element,s,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(e=!1){var t;e||(t=v((e=this).suggestionsContainer),"function"==typeof e.options.onHide&&e.visible&&e.options.onHide.call(e.element,t),e.visible=!1,e.selectedIndex=-1,clearInterval(e.onChangeInterval),v(e.suggestionsContainer).hide(),e.signalHint(null))},suggest:function(){var e,t,i,o,a,l,n,s,r,u,c,g,d,h,p,f;0===this.suggestions.length?this.options.showNoSuggestionNotice?this.noSuggestions():this.hide():(t=(e=this).options,i=t.groupBy,o=t.formatResult,a=e.getQuery(e.currentValue),l=e.classes.suggestion,n=e.classes.selected,s=v(e.suggestionsContainer),r=v(e.noSuggestionsContainer),u=t.beforeRender,c="",d=function(e,t){e=e.data[i];return g===e?"":'
'+(g=e)+"
"},t.triggerSelectOnValidInput&&e.isExactMatch(a)?e.select(0):(h=function(e,s=""){return v.each(e,function(e,t){i&&(s+=d(t,a,e));var n=l;t.item_classes&&(n+=" "+t.item_classes),s+='
'+o(t,a)+"
"}),s},p=0,(f=e.suggestions.reduce((e,t)=>{var n=t.group||"default";e[n]||(e[n]={});e[n][p]=t;p++;return e},{}))?v.each(f,function(e,n){v.each(n,function(e,t){t&&t.divider&&(c+='
'+t.divider+"
",delete n[e])}),c=h(n,c+='
'),c+="
"}):c=h(e.suggestions),this.adjustContainerWidth(),r.detach(),s.html(c),"function"==typeof u&&u.call(e.element,s),e.fixPosition(),s.show(),t.autoSelectFirst&&(e.selectedIndex=0,s.scrollTop(0),s.children("."+l).first().addClass(n)),e.visible=!0,e.findBestHint()))},noSuggestions:function(){var e=v(this.suggestionsContainer),t=v(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=v(this.suggestionsContainer);"auto"===e.width&&(e=this.el.outerWidth()-2,t.width(0