// 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("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/Deferred jimu/utils esri/request esri/IdentityManager".split(" "),function(l,d,h,k,m,n,p){return l([],{leafTypes:null,serviceTypes:null,_restInfoCache:{},constructor:function(a){d.mixin(this,a);d.isArrayLike(this.leafTypes)||(this.leafTypes=[]);d.isArrayLike(this.serviceTypes)||(this.serviceTypes=[])},getItem:function(a){return this.defaultGetItem(a)},getSubItemUrls:function(a){return this.defaultGetSubItemUrls(a)},getIconImageName:function(a,
b){return""},defaultGetItem:function(a){var b=new k;a=a.replace(/\/*$/g,"");if(this.isUrlEndWithServiceType(a)){var c=a.split("/"),f=c[c.length-1],e=c[c.length-2];this.getRestInfo(a).then(d.hitch(this,function(g){b.resolve({name:e,type:f,url:a,definition:g})}),d.hitch(this,function(g){console.error(g);b.reject({errorCode:"NETWORK_ERROR",error:g})}))}else b.resolve(null);return b},defaultGetSubItemUrls:function(a){a=new k;a.resolve([]);return a},getRestInfo:function(a){var b=new k;a=a.replace(/\/*$/g,
"");var c=this._restInfoCache[a];if(c)b.resolve(c);else{c={url:a,content:{f:"json"},handleAs:"json",callbackParamName:"callback",timeout:2E4};var f=p.findCredential(a);f&&f.token&&(c.content.token=f.token);n(c).then(d.hitch(this,function(e){this._restInfoCache[a]=e;b.resolve(e)}),function(e){b.reject(e)})}return b},isServiceTypeSupported:function(a){a=a.toLowerCase();return h.some(this.serviceTypes,d.hitch(this,function(b){return b.toLowerCase()===a}))},isUrlEndWithServiceType:function(a){return h.some(this.serviceTypes,
d.hitch(this,function(b){return m.isStringEndWith(a,"/"+b)}))},isUrlContainsServiceType:function(a){a=a.toLowerCase();return h.some(this.serviceTypes,d.hitch(this,function(b){b=b.toLowerCase();return 0<=a.indexOf("/"+b)}))}})});