// 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/core/infographics/dataDrilling/DataDrillingLibrary","dojo/_base/lang ./_FieldInfoBuilder ../../supportClasses/TableUtil ../../supportClasses/templateJsonUtils/fieldInfo/FieldInfoNameUtil ./_config ./EnrichUtil".split(" "),function(k,p,q,r,g,l){function n(a){return"string"===typeof a?a.split(",").map(function(a){return a+"/"}):a}var d={};l.ddLibrary=d;d.hasDrillingOptions=function(a,b,f){return!!d.getDrillingOptions(a,b,f)};d.getDrillingOptions=function(a,
b,f){if(b){var c=function(){function c(a,c){return d&&-1!==d.indexOf(a)?!0:e&&e.some(function(b){return-1!==b.indexOf(a)||-1!==b.indexOf(c)})}var e=b.usedFields||f&&f(b),e=e&&e.map(function(a){return a.toUpperCase()});if(!b.variableID&&!e)return null;var d=b.variableID&&b.variableID.toUpperCase(),h=g.LIBRARY[a],m;for(m in h){var k=m.toUpperCase(),l=r.createFieldNameFromVariable(m).toUpperCase();if(c(k,l))return h[m]}return null}();c&&c.forEach(function(a){d._provideStateData(a)});return c}};d.getDrillingOptionInfo=
function(a,b,f,c,t,e,g){a=(a=d.getDrillingOptions(a,b,g))&&a.filter(function(a){return a.name===f})[0];if(!a)return null;!e&&a.defaultState&&(e=a.defaultState);e=e&&e.charAt(0)||"n";var h;a.calcGroup&&(h=k.clone(a.calcGroup),h.value=e+"/");c=q.createSingleCellTable({fieldInfo:a.stateData[e].fieldInfo,width:c,height:t});return{calculationStatesGroup:h,tableJson:k.clone(c),enrichInfos:l._getStandardEnrichInfosForTableInfo(a,!0)}};d._provideStateData=function(a){if(!a.stateData){a.stateData={n:{fieldInfo:a.fieldInfo}};
a.states&&(a.states=n(a.states),a.states.forEach(function(c){c=c.charAt(0);if("n"!==c){var b=k.clone(a.fieldInfo);a.stateData[c]={fieldInfo:b};b.isChart&&(b.chartJson.visualProperties.title.text+=" ("+g.STATE_LOCALIZATION_MAP_SHORT[c]+")",b.chartJson.visualProperties.yAxis.title=g.STATE_LOCALIZATION_MAP[c],b.chartJson.visualProperties.dataLabelsDecimals=a.dataLabelsDecimals&&a.dataLabelsDecimals[c])}}),a.calcGroup=d.createCalculationStatesGroup(a.states),delete a.states,delete a.dataLabelsDecimals);
for(var b in a.stateData){var f=a.stateData[b];f.fieldInfo.isChart&&f.fieldInfo.chartJson.seriesItems.forEach(function(a){a.points.forEach(function(c){p.provideFieldInfoForChartPoint(c,a,1===f.fieldInfo.chartJson.seriesItems.length,b,f.fieldInfo.chartJson.comparisonInfo&&f.fieldInfo.chartJson.comparisonInfo.calculatorName)})})}delete a.fieldInfo}};d.createCalculationStatesGroup=function(a){if(a)return a=n(a),{states:{ids:a,names:a.slice(),labels:a.map(function(a){return g.STATE_LOCALIZATION_MAP_SHORT[a.charAt(0)]})},
value:a[0]}};return d});