// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define(["jimu/loaderplugins/jquery-loader! ./libs/jquery/jquery-1-11-1.js"],function(z){var v=function(g){g.Configuration=function(c){function l(a,b){function e(f,k){for(var d in k)void 0===f[d]&&a.log("Property '"+d+"' does not exist in EasyAutocomplete options API."),"object"===typeof f[d]&&-1===z.inArray(d,m)&&e(f[d],k[d])}e(h,b)}var h={data:"list-required",url:"list-required",dataType:"json",listLocation:function(a){return a},xmlElementName:"",getValue:function(a){return a},autocompleteOff:!0,
placeholder:!1,ajaxCallback:function(){},matchResponseProperty:!1,list:{sort:{enabled:!1,method:function(a,b){a=h.getValue(a);b=h.getValue(b);return a<b?-1:a>b?1:0}},maxNumberOfElements:6,hideOnEmptyPhrase:!0,match:{enabled:!1,caseSensitive:!1,method:function(a,b){return-1<a.search(b)?!0:!1}},showAnimation:{type:"normal",time:400,callback:function(){}},hideAnimation:{type:"normal",time:400,callback:function(){}},onClickEvent:function(){},onSelectItemEvent:function(){},onLoadEvent:function(){},onChooseEvent:function(){},
onKeyEnterEvent:function(){},onMouseOverEvent:function(){},onMouseOutEvent:function(){},onShowListEvent:function(){},onHideListEvent:function(){}},highlightPhrase:!0,theme:"",cssClasses:"",minCharNumber:0,requestDelay:0,adjustWidth:!0,ajaxSettings:{},preparePostData:function(a){return a},loggerEnabled:!0,template:"",categoriesAssigned:!1,categories:[{maxNumberOfElements:4}]},m=["ajaxSettings","template"];this.get=function(a){return h[a]};this.equals=function(a,b){var e=void 0!==h[a]&&null!==h[a]?
!0:!1;return e&&h[a]===b?!0:!1};this.checkDataUrlProperties=function(){return"list-required"===h.url&&"list-required"===h.data?!1:!0};this.checkRequiredProperties=function(){for(var a in h)if("required"===h[a])return!1;return!0};this.printPropertiesThatDoesntExist=function(a,b){l(a,b)};(function(){"xml"===c.dataType&&(c.getValue||(c.getValue=function(d){return z(d).text()}),c.list||(c.list={}),c.list.sort||(c.list.sort={}),c.list.sort.method=function(d,t){d=c.getValue(d);t=c.getValue(t);return d<
t?-1:d>t?1:0},c.list.match||(c.list.match={}),c.list.match.method=function(d,t){return-1<d.search(t)?!0:!1});if(void 0!==c.categories&&c.categories instanceof Array){for(var a=[],b=0,e=c.categories.length;b<e;b+=1){var f=c.categories[b],k;for(k in h.categories[0])void 0===f[k]&&(f[k]=h.categories[0][k]);a.push(f)}c.categories=a}})();(function(){function a(b,e){var f=b||{},k;for(k in b)void 0!==e[k]&&null!==e[k]&&("object"!==typeof e[k]||e[k]instanceof Array?f[k]=e[k]:a(b[k],e[k]));void 0!==e.data&&
null!==e.data&&"object"===typeof e.data&&(f.data=e.data);return f}h=a(h,c)})();!0===h.loggerEnabled&&l(console,c);h.ajaxSettings=void 0!==c.ajaxSettings&&"object"===typeof c.ajaxSettings?c.ajaxSettings:{};(function(){if("list-required"!==h.url&&"function"!==typeof h.url){var a=h.url;h.url=function(){return a}}void 0!==h.ajaxSettings.url&&"function"!==typeof h.ajaxSettings.url&&(a=h.ajaxSettings.url,h.ajaxSettings.url=function(){return a});if("string"===typeof h.listLocation){var b=h.listLocation;
"XML"===h.dataType.toUpperCase()?h.listLocation=function(f){return z(f).find(b)}:h.listLocation=function(f){return f[b]}}if("string"===typeof h.getValue){var e=h.getValue;h.getValue=function(f){return f[e]}}void 0!==c.categories&&(h.categoriesAssigned=!0)})()};return g}(v||{});v=function(g){g.Logger=function(){this.error=function(c){};this.warning=function(c){}};return g}(v||{});v=function(g){g.Constans=function(){var c={CONTAINER_CLASS:"easy-autocomplete-container",CONTAINER_ID:"eac-container-",
WRAPPER_CSS_CLASS:"easy-autocomplete"};this.getValue=function(l){return c[l]}};return g}(v||{});v=function(g){g.ListBuilderService=function(c,l){function h(a,b){function e(){var t={},B;void 0!==a.xmlElementName&&(t.xmlElementName=a.xmlElementName);void 0!==a.listLocation?B=a.listLocation:void 0!==c.get("listLocation")&&(B=c.get("listLocation"));void 0!==B?"string"===typeof B?t.data=z(b).find(B):"function"===typeof B&&(t.data=B(b)):t.data=b;return t}function f(){var t={};void 0!==a.listLocation?"string"===
typeof a.listLocation?t.data=b[a.listLocation]:"function"===typeof a.listLocation&&(t.data=a.listLocation(b)):t.data=b;return t}var k={};k="XML"===c.get("dataType").toUpperCase()?e():f();void 0!==a.header&&(k.header=a.header);void 0!==a.maxNumberOfElements&&(k.maxNumberOfElements=a.maxNumberOfElements);void 0!==c.get("list").maxNumberOfElements&&(k.maxListSize=c.get("list").maxNumberOfElements);if(void 0!==a.getValue)if("string"===typeof a.getValue){var d=a.getValue;k.getValue=function(t){return t[d]}}else"function"===
typeof a.getValue&&(k.getValue=a.getValue);else k.getValue=c.get("getValue");return k}function m(a){var b=[];void 0===a.xmlElementName&&(a.xmlElementName=c.get("xmlElementName"));z(a.data).find(a.xmlElementName).each(function(){b.push(this)});return b}this.init=function(a){var b=[],e={};e.data=c.get("listLocation")(a);e.getValue=c.get("getValue");e.maxListSize=c.get("list").maxNumberOfElements;b.push(e);return b};this.updateCategories=function(a,b){if(c.get("categoriesAssigned")){a=[];for(var e=0;e<
c.get("categories").length;e+=1){var f=h(c.get("categories")[e],b);a.push(f)}}return a};this.convertXml=function(a){if("XML"===c.get("dataType").toUpperCase())for(var b=0;b<a.length;b+=1)a[b].data=m(a[b]);return a};this.processData=function(a,b){for(var e=0,f=a.length;e<f;e+=1)a[e].data=l(c,a[e],b);return a};this.checkIfDataExists=function(a){for(var b=0,e=a.length;b<e;b+=1)if(void 0!==a[b].data&&a[b].data instanceof Array&&0<a[b].data.length)return!0;return!1}};return g}(v||{});v=function(g){g.proccess=
function(c,l,h){function m(b,e){c.get("list").match.caseSensitive||("string"===typeof b&&(b=b.toLowerCase()),e=e.toLowerCase());return c.get("list").match.method(b,e)?!0:!1}g.proccess.match=m;var a=l.data;a=function(b,e){var f=[],k="";if(c.get("list").match.enabled)for(var d=0,t=b.length;d<t;d+=1)k=c.get("getValue")(b[d]),m(k,e)&&f.push(b[d]);else f=b;return f}(a,h);a=function(b){void 0!==l.maxNumberOfElements&&b.length>l.maxNumberOfElements&&(b=b.slice(0,l.maxNumberOfElements));return b}(a);return a=
function(b){c.get("list").sort.enabled&&b.sort(c.get("list").sort.method);return b}(a)};return g}(v||{});v=function(g){g.Template=function(c){var l={basic:{type:"basic",method:function(m){return m},cssClass:""},description:{type:"description",fields:{description:"description"},method:function(m){return m+" - description"},cssClass:"eac-description"},iconLeft:{type:"iconLeft",fields:{icon:""},method:function(m){return m},cssClass:"eac-icon-left"},iconRight:{type:"iconRight",fields:{iconSrc:""},method:function(m){return m},
cssClass:"eac-icon-right"},links:{type:"links",fields:{link:""},method:function(m){return m},cssClass:""},custom:{type:"custom",method:function(){},cssClass:""}},h=function(m){var a=m.fields;if("description"===m.type){var b=l.description.method;"string"===typeof a.description?b=function(e,f){return e+" - \x3cspan\x3e"+f[a.description]+"\x3c/span\x3e"}:"function"===typeof a.description&&(b=function(e,f){return e+" - \x3cspan\x3e"+a.description(f)+"\x3c/span\x3e"});return b}return"iconRight"===m.type?
("string"===typeof a.iconSrc?b=function(e,f){return e+"\x3cimg class\x3d'eac-icon' src\x3d'"+f[a.iconSrc]+"' /\x3e"}:"function"===typeof a.iconSrc&&(b=function(e,f){return e+"\x3cimg class\x3d'eac-icon' src\x3d'"+a.iconSrc(f)+"' /\x3e"}),b):"iconLeft"===m.type?("string"===typeof a.iconSrc?b=function(e,f){return"\x3cimg class\x3d'eac-icon' src\x3d'"+f[a.iconSrc]+"' /\x3e"+e}:"function"===typeof a.iconSrc&&(b=function(e,f){return"\x3cimg class\x3d'eac-icon' src\x3d'"+a.iconSrc(f)+"' /\x3e"+e}),b):"links"===
m.type?("string"===typeof a.link?b=function(e,f){return"\x3ca href\x3d'"+f[a.link]+"' \x3e"+e+"\x3c/a\x3e"}:"function"===typeof a.link&&(b=function(e,f){return"\x3ca href\x3d'"+a.link(f)+"' \x3e"+e+"\x3c/a\x3e"}),b):"custom"===m.type?m.method:l.basic.method};this.getTemplateClass=function(m){var a=function(){return""};return m&&m.type?m.type&&l[m.type]?function(){var b=l[m.type].cssClass;return function(){return b}}():a:a}(c);c=c&&c.type?c.type&&l[c.type]?h(c):l.basic.method:l.basic.method;this.build=
c};return g}(v||{});v=function(g){g.main=function(c,l){function h(){function q(r,n){return d.get("highlightPhrase")&&""!==n?(n=n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$\x26"),(r+"").replace(new RegExp("("+n+")","gi"),"\x3cb\x3e$1\x3c/b\x3e")):r}u.parent().hasClass(k.getValue("WRAPPER_CSS_CLASS"))&&(u.next("."+k.getValue("CONTAINER_CLASS")).remove(),u.unwrap());(function(){var r=z("\x3cdiv\x3e"),n=k.getValue("WRAPPER_CSS_CLASS");d.get("theme")&&""!==d.get("theme")&&(n+=" eac-"+d.get("theme"));
d.get("cssClasses")&&""!==d.get("cssClasses")&&(n+=" "+d.get("cssClasses"));""!==B.getTemplateClass()&&(n+=" "+B.getTemplateClass());r.addClass(n);u.wrap(r);!0===d.get("adjustWidth")&&u.parent().css("width","100%")})();(function(){var r=z("\x3cdiv\x3e").addClass(k.getValue("CONTAINER_CLASS"));r.attr("id",m()).prepend(z("\x3cul\x3e"));(function(){r.on("show.eac",function(){switch(d.get("list").showAnimation.type){case "slide":var n=d.get("list").showAnimation.time;var p=d.get("list").showAnimation.callback;
r.find("ul").slideDown(n,p);break;case "fade":n=d.get("list").showAnimation.time;p=d.get("list").showAnimation.callback;r.find("ul").fadeIn(n,p);break;default:r.find("ul").show()}d.get("list").onShowListEvent()}).on("hide.eac",function(){switch(d.get("list").hideAnimation.type){case "slide":var n=d.get("list").hideAnimation.time;var p=d.get("list").hideAnimation.callback;r.find("ul").slideUp(n,p);break;case "fade":n=d.get("list").hideAnimation.time;p=d.get("list").hideAnimation.callback;r.find("ul").fadeOut(n,
p);break;default:r.find("ul").hide()}d.get("list").onHideListEvent()}).on("selectElement.eac",function(){r.find("ul li").removeClass("selected");r.find("ul li").eq(w).addClass("selected");d.get("list").onSelectItemEvent()}).on("loadElements.eac",function(n,p,y){var D="";n=r.find("ul");n.empty().detach();A=[];for(var C=0,x=0,G=p.length;x<G;x+=1){var H=p[x].data;if(0!==H.length){void 0!==p[x].header&&0<p[x].header.length&&n.append("\x3cdiv class\x3d'eac-category' \x3e"+p[x].header+"\x3c/div\x3e");for(var I=
0,N=H.length;I<N&&C<p[x].maxListSize;I+=1)D=z("\x3cli\x3e\x3cdiv class\x3d'eac-item'\x3e\x3c/div\x3e\x3c/li\x3e"),function(){var L=I,J=C,M=p[x].getValue(H[L]);D.find(" \x3e div").on("click",function(){u.val(M).trigger("change");w=J;f(J);d.get("list").onClickEvent();d.get("list").onChooseEvent()}).mouseover(function(){w=J;f(J);d.get("list").onMouseOverEvent()}).mouseout(function(){d.get("list").onMouseOutEvent()}).html(B.build(q(M,y),H[L]))}(),n.append(D),A.push(H[I]),C+=1}}r.append(n);d.get("list").onLoadEvent()})})();
u.after(r)})();F=z("#"+m());d.get("placeholder")&&u.attr("placeholder",d.get("placeholder"))}function m(){var q=u.attr("id");return q=k.getValue("CONTAINER_ID")+q}function a(){O("autocompleteOff",!0)&&u.attr("autocomplete","off");(function(){u.focusout(function(){var q=u.val();d.get("list").match.caseSensitive||(q=q.toLowerCase());for(var r=0,n=A.length;r<n;r+=1){var p=d.get("getValue")(A[r]);d.get("list").match.caseSensitive||(p=p.toLowerCase());if(p===q){w=r;f(w);break}}})})();(function(){u.off("keyup").keyup(function(q){function r(p){if(!(p.length<
d.get("minCharNumber"))){if("list-required"!==d.get("data")){var y=d.get("data"),D=E.init(y);D=E.updateCategories(D,y);D=E.processData(D,p);F.trigger("loadElements.eac",[D,p]);0<u.parent().find("li").length?b():e()}y=function(){var C={},x=d.get("ajaxSettings")||{},G;for(G in x)C[G]=x[G];return C}();if(void 0===y.url||""===y.url)y.url=d.get("url");if(void 0===y.dataType||""===y.dataType)y.dataType=d.get("dataType");void 0!==y.url&&"list-required"!==y.url&&(y.url=y.url(p),y.data=d.get("preparePostData")(y.data,
p),z.ajax(y).done(function(C){var x=E.init(C);x=E.updateCategories(x,C);x=E.convertXml(x);if(!1!==d.get("matchResponseProperty")?"string"===typeof d.get("matchResponseProperty")?C[d.get("matchResponseProperty")]===p:"function"===typeof d.get("matchResponseProperty")?d.get("matchResponseProperty")(C)===p:1:1)x=E.processData(x,p),F.trigger("loadElements.eac",[x,p]);E.checkIfDataExists(x)&&0<u.parent().find("li").length?b():e();d.get("ajaxCallback")()}).fail(function(){t.warning("Fail to load response data")}).always(function(){}))}}
switch(q.keyCode){case 27:e();u.trigger("blur");break;case 38:q.preventDefault();0<A.length&&0<w&&(--w,u.val(d.get("getValue")(A[w])),f(w));break;case 40:q.preventDefault();0<A.length&&w<A.length-1&&(w+=1,u.val(d.get("getValue")(A[w])),f(w));break;default:if(40<q.keyCode||8===q.keyCode){var n=u.val();!0!==d.get("list").hideOnEmptyPhrase||8!==q.keyCode||""!==n?0<d.get("requestDelay")?(void 0!==K&&clearTimeout(K),K=setTimeout(function(){r(n)},d.get("requestDelay"))):r(n):e()}}})})();(function(){u.on("keydown",
function(q){q=q||window.event;if(38===q.keyCode)return!1}).keydown(function(q){13===q.keyCode&&-1<w&&(u.val(d.get("getValue")(A[w])),d.get("list").onKeyEnterEvent(),d.get("list").onChooseEvent(),w=-1,e(),q.preventDefault())})})();u.off("keypress");(function(){u.focus(function(){""!==u.val()&&0<A.length&&(w=-1,b())})})();(function(){u.blur(function(){setTimeout(function(){w=-1;e()},250)})})()}function b(){F.trigger("show.eac")}function e(){F.trigger("hide.eac")}function f(q){F.trigger("selectElement.eac",
q)}var k=new g.Constans,d=new g.Configuration(l),t=new g.Logger,B=new g.Template(l.template),E=new g.ListBuilderService(d,g.proccess),O=d.equals,u=c,F="",A=[],w=-1,K;g.consts=k;this.getConstants=function(){return k};this.getConfiguration=function(){return d};this.getContainer=function(){return F};this.getSelectedItemIndex=function(){return w};this.getItems=function(){return A};this.getItemData=function(q){return A.length<q||void 0===A[q]?-1:A[q]};this.getSelectedItemData=function(){return this.getItemData(w)};
this.build=function(){h()};this.init=function(){0===u.length?t.error("Input field doesn't exist."):d.checkDataUrlProperties()?d.checkRequiredProperties()?(h(),a()):t.error("Will not work without mentioned properties."):t.error("One of options variables 'data' or 'url' must be defined.")}};g.eacHandles=[];g.getHandle=function(c){return g.eacHandles[c]};g.inputHasId=function(c){return void 0!==z(c).attr("id")&&0<z(c).attr("id").length?!0:!1};g.assignRandomId=function(c){var l="";do l="eac-"+Math.floor(1E4*
Math.random());while(0!==z("#"+l).length);z(c).attr("id",l)};g.setHandle=function(c,l){g.eacHandles[l]=c};return g}(v||{});(function(g){g.fn.easyAutocomplete=function(c){return this.each(function(){var l=g(this),h=new v.main(l,c);v.inputHasId(l)||v.assignRandomId(l);h.init();v.setHandle(h,l.attr("id"))})};g.fn.getSelectedItemIndex=function(){var c=g(this).attr("id");return void 0!==c?v.getHandle(c).getSelectedItemIndex():-1};g.fn.getItems=function(){var c=g(this).attr("id");return void 0!==c?v.getHandle(c).getItems():
-1};g.fn.getItemData=function(c){var l=g(this).attr("id");return void 0!==l&&-1<c?v.getHandle(l).getItemData(c):-1};g.fn.getSelectedItemData=function(){var c=g(this).attr("id");return void 0!==c?v.getHandle(c).getSelectedItemData():-1}})(jQuery)});