(function(d){var c=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,c;this.isMultiLine=this.element.is("textarea");this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(b){if(!a.options.disabled&&
!a.element.propAttr("readOnly")){c=!1;var f=d.ui.keyCode;switch(b.keyCode){case f.PAGE_UP:a._move("previousPage",b);break;case f.PAGE_DOWN:a._move("nextPage",b);break;case f.UP:a._keyEvent("previous",b);break;case f.DOWN:a._keyEvent("next",b);break;case f.ENTER:case f.NUMPAD_ENTER:a.menu.active&&(c=!0,b.preventDefault());case f.TAB:if(!a.menu.active)break;a.menu.select(b);break;case f.ESCAPE:a.element.val(a.term);a.close(b);break;default:clearTimeout(a.searching),a.searching=setTimeout(function(){a.term!=
a.element.val()&&(a.selectedItem=null,a.search(null,b))},a.options.delay)}}}).bind("keypress.autocomplete",function(a){c&&(c=!1,a.preventDefault())}).bind("focus.autocomplete",function(){a.options.disabled||(a.selectedItem=null,a.previous=a.element.val())}).bind("blur.autocomplete",function(b){a.options.disabled||(clearTimeout(a.searching),a.closing=setTimeout(function(){a.close(b);a._change(b)},150))});this._initSource();this.menu=d("<ul></ul>").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||
"body",b)[0]).mousedown(function(b){var c=a.menu.element[0];d(b.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(b){b.target!==a.element[0]&&b.target!==c&&!d.ui.contains(c,b.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(b,d){var c=d.item.data("item.autocomplete");!1!==a._trigger("focus",b,{item:c})&&/^key/.test(b.originalEvent.type)&&a.element.val(c.value)},selected:function(c,d){var e=d.item.data("item.autocomplete"),
h=a.previous;a.element[0]!==b.activeElement&&(a.element.focus(),a.previous=h,setTimeout(function(){a.previous=h;a.selectedItem=e},1));!1!==a._trigger("select",c,{item:e})&&a.element.val(e.value);a.term=a.element.val();a.close(c);a.selectedItem=e},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");d.fn.bgiframe&&this.menu.element.bgiframe();a.beforeunloadHandler=function(){a.element.removeAttr("autocomplete")};
d(window).bind("beforeunload",a.beforeunloadHandler)},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d(window).unbind("beforeunload",this.beforeunloadHandler);d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);"source"===a&&this._initSource();"appendTo"===a&&this.menu.element.appendTo(d(b||
"body",this.element[0].ownerDocument)[0]);"disabled"===a&&b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,c;d.isArray(this.options.source)?(b=this.options.source,this.source=function(a,c){c(d.ui.autocomplete.filter(b,a.term))}):"string"==typeof this.options.source?(c=this.options.source,this.source=function(b,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:c,data:b,dataType:"json",success:function(a){f(a)},error:function(){f([])}})}):this.source=this.options.source},search:function(a,
b){a=null!=a?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(!1!==this._trigger("search",b))return this._search(a)},_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this._response())},_response:function(){var a=this,b=++c;return function(d){b===c&&a.__response(d);a.pending--;a.pending||a.element.removeClass("ui-autocomplete-loading")}},__response:function(a){!this.options.disabled&&
a&&a.length?(a=this._normalize(a),this._suggest(a),this._trigger("open")):this.close()},close:function(a){clearTimeout(this.closing);this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.deactivate(),this._trigger("close",a))},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){return a.length&&a[0].label&&a[0].value?a:d.map(a,function(a){return"string"==typeof a?{label:a,value:a}:d.extend({label:a.label||
a.value,value:a.value||a.label},a)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();b.show();this._resizeMenu();b.position(d.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next(new d.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(a,b){var c=
this;d.each(b,function(b,d){c._renderItem(a,d)})},_renderItem:function(a,b){return d("<li></li>").data("item.autocomplete",b).append(d("<a></a>").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a))this.element.val(this.term),this.menu.deactivate();else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element},_keyEvent:function(a,b){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(a,
b),b.preventDefault()}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(a,b){var c=RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(a){return c.test(a.label||a.value||a)})}})})(jQuery);
(function(d){d.widget("ui.menu",{_create:function(){var c=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){d(a.target).closest(".ui-menu-item a").length&&(a.preventDefault(),c.select(a))});this.refresh()},refresh:function(){var c=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
-1).mouseenter(function(a){c.activate(a,d(this).parent())}).mouseleave(function(){c.deactivate()})},activate:function(c,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,d=this.element.scrollTop(),g=this.element.height();0>b?this.element.scrollTop(d+b):b>=g&&this.element.scrollTop(d+b-g+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",c,{item:a})},deactivate:function(){this.active&&
(this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null)},next:function(c){this.move("next",".ui-menu-item:first",c)},previous:function(c){this.move("prev",".ui-menu-item:last",c)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(c,a,b){this.active?(c=this.active[c+"All"](".ui-menu-item").eq(0),c.length?this.activate(b,
c):this.activate(b,this.element.children(a))):this.activate(b,this.element.children(a))},nextPage:function(c){if(this.hasScroll())if(!this.active||this.last())this.activate(c,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return 10>c&&-10<c});e.length||(e=this.element.children(".ui-menu-item:last"));this.activate(c,e)}else this.activate(c,
this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(c){if(this.hasScroll())if(!this.active||this.first())this.activate(c,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a+b-d(this).height();return 10>c&&-10<c});e.length||(e=this.element.children(".ui-menu-item:first"));this.activate(c,e)}else this.activate(c,
this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[d.fn.prop?"prop":"attr"]("scrollHeight")},select:function(c){this._trigger("selected",c,{item:this.active})}})})(jQuery);