(function(c){"function"===typeof define&&define.amd?define(["jquery","./core","./widget","./position","./menu"],c):c(jQuery)})(function(c){c.widget("ui.autocomplete",{version:"1.11.4",defaultElement:"<input>",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var a,b,f,e=this.element[0].nodeName.toLowerCase(),
h="textarea"===e,e="input"===e;this.isMultiLine=h?!0:e?!1:this.element.prop("isContentEditable");this.valueMethod=this.element[h||e?"val":"text"];this.isNewMenu=!0;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off");this._on(this.element,{keydown:function(d){if(this.element.prop("readOnly"))b=f=a=!0;else{b=f=a=!1;var g=c.ui.keyCode;switch(d.keyCode){case g.PAGE_UP:a=!0;this._move("previousPage",d);break;case g.PAGE_DOWN:a=!0;this._move("nextPage",d);break;case g.UP:a=!0;this._keyEvent("previous",
d);break;case g.DOWN:a=!0;this._keyEvent("next",d);break;case g.ENTER:this.menu.active&&(a=!0,d.preventDefault(),this.menu.select(d));break;case g.TAB:this.menu.active&&this.menu.select(d);break;case g.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(d),d.preventDefault());break;default:b=!0,this._searchTimeout(d)}}},keypress:function(d){if(a)a=!1,this.isMultiLine&&!this.menu.element.is(":visible")||d.preventDefault();else if(!b){var g=c.ui.keyCode;switch(d.keyCode){case g.PAGE_UP:this._move("previousPage",
d);break;case g.PAGE_DOWN:this._move("nextPage",d);break;case g.UP:this._keyEvent("previous",d);break;case g.DOWN:this._keyEvent("next",d)}}},input:function(a){f?(f=!1,a.preventDefault()):this._searchTimeout(a)},focus:function(){this.selectedItem=null;this.previous=this._value()},blur:function(a){this.cancelBlur?delete this.cancelBlur:(clearTimeout(this.searching),this.close(a),this._change(a))}});this._initSource();this.menu=c("<ul>").addClass("ui-autocomplete ui-front").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance");
this._on(this.menu.element,{mousedown:function(a){a.preventDefault();this.cancelBlur=!0;this._delay(function(){delete this.cancelBlur});var b=this.menu.element[0];c(a.target).closest(".ui-menu-item").length||this._delay(function(){var a=this;this.document.one("mousedown",function(d){d.target===a.element[0]||d.target===b||c.contains(b,d.target)||a.close()})})},menufocus:function(a,b){var e;if(this.isNewMenu&&(this.isNewMenu=!1,a.originalEvent&&/^mouse/.test(a.originalEvent.type))){this.menu.blur();
this.document.one("mousemove",function(){c(a.target).trigger(a.originalEvent)});return}e=b.item.data("ui-autocomplete-item");!1!==this._trigger("focus",a,{item:e})&&a.originalEvent&&/^key/.test(a.originalEvent.type)&&this._value(e.value);(e=b.item.attr("aria-label")||e.value)&&c.trim(e).length&&(this.liveRegion.children().hide(),c("<div>").text(e).appendTo(this.liveRegion))},menuselect:function(a,b){var c=b.item.data("ui-autocomplete-item"),e=this.previous;this.element[0]!==this.document[0].activeElement&&
(this.element.focus(),this.previous=e,this._delay(function(){this.previous=e;this.selectedItem=c}));!1!==this._trigger("select",a,{item:c})&&this._value(c.value);this.term=this._value();this.close(a);this.selectedItem=c}});this.liveRegion=c("<span>",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body);this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching);
this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete");this.menu.element.remove();this.liveRegion.remove()},_setOption:function(a,b){this._super(a,b);"source"===a&&this._initSource();"appendTo"===a&&this.menu.element.appendTo(this._appendTo());"disabled"===a&&b&&this.xhr&&this.xhr.abort()},_appendTo:function(){var a=this.options.appendTo;a&&(a=a.jquery||a.nodeType?c(a):this.document.find(a).eq(0));a&&a[0]||(a=this.element.closest(".ui-front"));a.length||(a=this.document[0].body);
return a},_initSource:function(){var a,b,f=this;c.isArray(this.options.source)?(a=this.options.source,this.source=function(b,f){f(c.ui.autocomplete.filter(a,b.term))}):"string"===typeof this.options.source?(b=this.options.source,this.source=function(a,h){f.xhr&&f.xhr.abort();f.xhr=c.ajax({url:b,data:a,dataType:"json",success:function(a){h(a)},error:function(){h([])}})}):this.source=this.options.source},_searchTimeout:function(a){clearTimeout(this.searching);this.searching=this._delay(function(){var b=
this.term===this._value(),c=this.menu.element.is(":visible"),e=a.altKey||a.ctrlKey||a.metaKey||a.shiftKey;if(!b||b&&!c&&!e)this.selectedItem=null,this.search(null,a)},this.options.delay)},search:function(a,b){a=null!=a?a:this._value();this.term=this._value();if(a.length<this.options.minLength)return this.close(b);if(!1!==this._trigger("search",b))return this._search(a)},_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.cancelSearch=!1;this.source({term:a},this._response())},
_response:function(){var a=++this.requestIndex;return c.proxy(function(b){a===this.requestIndex&&this.__response(b);this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},this)},__response:function(a){a&&(a=this._normalize(a));this._trigger("response",null,{content:a});!this.options.disabled&&a&&a.length&&!this.cancelSearch?(this._suggest(a),this._trigger("open")):this._close()},close:function(a){this.cancelSearch=!0;this._close(a)},_close:function(a){this.menu.element.is(":visible")&&
(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",a))},_change:function(a){this.previous!==this._value()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){return a.length&&a[0].label&&a[0].value?a:c.map(a,function(a){return"string"===typeof a?{label:a,value:a}:c.extend({},a,{label:a.label||a.value,value:a.value||a.label})})},_suggest:function(a){var b=this.menu.element.empty();this._renderMenu(b,a);this.isNewMenu=!0;this.menu.refresh();b.show();
this._resizeMenu();b.position(c.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next()},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(a,b){var f=this;c.each(b,function(b,c){f._renderItemData(a,c)})},_renderItemData:function(a,b){return this._renderItem(a,b).data("ui-autocomplete-item",b)},_renderItem:function(a,b){return c("<li>").text(b.label).appendTo(a)},_move:function(a,
b){if(this.menu.element.is(":visible"))if(this.menu.isFirstItem()&&/^previous/.test(a)||this.menu.isLastItem()&&/^next/.test(a))this.isMultiLine||this._value(this.term),this.menu.blur();else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(a,b){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(a,b),b.preventDefault()}});c.extend(c.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,
"\\$&")},filter:function(a,b){var f=new RegExp(c.ui.autocomplete.escapeRegex(b),"i");return c.grep(a,function(a){return f.test(a.label||a.value||a)})}});c.widget("ui.autocomplete",c.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(a){return a+(1<a?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(a){var b;this._superApply(arguments);this.options.disabled||this.cancelSearch||(b=a&&a.length?this.options.messages.results(a.length):
this.options.messages.noResults,this.liveRegion.children().hide(),c("<div>").text(b).appendTo(this.liveRegion))}});return c.ui.autocomplete});