// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/ReportPlayer/dataProviders/supportClasses/InfographicOptionsProvider","dojo/_base/declare esri/kernel esri/dijit/geoenrichment/InfographicsOptions esri/dijit/geoenrichment/Geoenrichment esri/dijit/geoenrichment/config esri/tasks/geoenrichment/GeometryStudyArea esri/tasks/geoenrichment/StandardGeographyStudyArea esri/tasks/geoenrichment/studyAreaFromJson ./ge/LocalGEInfographic".split(" "),function(d,l,e,m,f,g,h,n,p){var q=d(null,{_options:null,getTask:function(){return null},
createGeoenrichment:function(a,b){return a&&a.calcData?new p(a,b):new m},getCountry:function(a){return null},getOptions:function(){this._options||(this._options=new e);return this._options}}),k=d(null,{countryID:null,reportID:null,geoenrichmentUrl:null,studyAreas:null,studyArea:null,_provider:null,constructor:function(a,b){this.countryID=a.countryID;this.reportID=a.reportID;this.geoenrichmentUrl=a.geoenrichmentUrl;this.studyAreas=a.studyAreas.map(function(a){return a instanceof g||a instanceof h?
a:n(a)});this._provider=b;this.setCurrentAnalysisAreaIndex(0)},setCurrentAnalysisAreaIndex:function(a){this.studyArea=this.studyAreas[a]},_getGEKey:function(a){a=a||this.studyArea;return JSON.stringify(a.toJson())+this.countryID+this.reportID},_getGEKeys:function(){return this.studyAreas.map(function(a){return this._getGEKey(a)},this)},getOptions:function(){return this._provider._getFactory().getOptions()},createGeoenrichment:function(a,b){return this._provider._createGE(this._getGEKey(),a,b)},toJson:function(){return{countryID:this.countryID,
reportID:this.reportID,geoenrichmentUrl:this.geoenrichmentUrl,geoenrichmentCache:this._provider._getGECacheJson(this._getGEKeys()),infographicsOptions:this.getOptions().toJson(),studyAreas:this.studyAreas.map(function(a){return a.toJson()})}}});return d(null,{_infographicsFactory:null,_geoenrichmentCache:null,constructor:function(){this._geoenrichmentCache={}},_getFactory:function(){return this._infographicsFactory=this._infographicsFactory||new q},_createGE:function(a,b,c){b=this._getFactory().createGeoenrichment(b,
c);(c=this._geoenrichmentCache[a])?b.cache=c:this._geoenrichmentCache[a]=b.cache;return b},_getGECacheJson:function(a){var b={};a.forEach(function(a){var c=this._geoenrichmentCache[a];c&&(b[a]=c.toJson())},this);return b},setServerUrl:function(a){f.server=a.geoenrichmentUrl;a=l.id.credentials[0];f.token=a&&a.token},getInfographicOptions:function(a){return new k({geoenrichmentUrl:a.geoenrichmentUrl,countryID:a.countryID,reportID:a.reportID,studyAreas:a.analysisAreas.map(function(b){return b.geographies&&
b.geographies.length?new h({countryID:a.countryID,layer:b.geographies[0].levelId,ids:[b.geographies.map(function(a){return a.id}).join(",")],attributes:b.feature&&b.feature.attributes}):new g({geometry:b.feature.geometry,attributes:b.feature.attributes})})},this)},getInfographicOptionsFromJson:function(a){this.setServerUrl(a);for(var b in a.geoenrichmentCache){var c=a.geoenrichmentCache[b];this._createGE(b);this._geoenrichmentCache[b].fromJson(c)}this._infographicsFactory&&(this._infographicsFactory._options=
new e(a.infographicsOptions));return new k(a,this)}})});