// 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/grid/coreUtils/gridLayoutCalcUtils/columns/ColumnsProcessor",["dojox/uuid/generateRandomUuid","./ColumnDataUtil"],function(v,f){function w(a){a._dynamicBindings={};if(a.getNumDynamicColumns()){for(var b=a.getNumDynamicColumns(),f=a.getNumFixedColumns(),c=0;c<f;c++)a.columns[c].isFixed=!0;for(var c=[],h=0;h<b;h++){for(var g=f,k=[];g<a.columns.length;){var m=a.columns[g+h];m.isDynamic=!0;k.push(m);g+=b}c.push(k)}c.forEach(function(b){b.forEach(function(c){a._dynamicBindings[c.field]=
b})})}}var p={recalcColumns:function(a,b){var p=b&&b.resetWidth,c=b&&b.columnsToPreserve,h=b&&b.stickToRight,g=b&&b.newWidth,k=b&&b.rightOffsetWeight,m=b&&b._isJson,q={},n=0;a.columns.every(function(d,a){if(!d.style||!d.style.width||isNaN(d.style.width)||"number"!==typeof d.style.width)return n=0,!1;n+=d.style.width;q[a]=d.style.width;return!0});var e;e=g?g:h?a.getAllowedWidth():n?Math.min(n,a._width):a._width;e-=0<k?e*k:0;var r=e/a.columns.length,l=e;if(c){var x=c.length*r,t=0;c.forEach(function(a){t+=
a.style.width});c.forEach(function(a){a.style.width=x/t*a.style.width/l*100+"%"})}a.columns.forEach(function(a,b,c){a.index=b;a.style=a.style||{};if("number"!==typeof a.style.width||p)if(b===c.length-1)a.style.width=l;else{var d=a.style.width;"string"===typeof d&&-1!==d.indexOf("%")?a.style.width=parseFloat(d.substr(0,d.length-1))/100*e:a.style.width=r}l-=a.style.width;b===c.length-1&&0>l&&(a.style.width+=l);void 0===a.id&&(a.id=v())});if(a.looseResize){a.columns.some(function(b,c){var d=q[c]?b.style.width/
q[c]:void 0;a.store.data.forEach(function(c){var e=f.getFieldWidthOwn(a,c,b.field);e?d&&1!==d&&f.setFieldWidth(a,c,b.field,e*d):f.setFieldWidth(a,c,b.field,b.style.width)})});var u=a.columns[a.columns.length-1].field;a.store.data.forEach(function(b){var c=0;a.columns.some(function(d){c+=f.getFieldWidthOwn(a,b,d.field)});var d=e-c;0!==d&&f.setFieldWidth(a,b,u,f.getFieldWidthOwn(a,b,u)+d)})}m||(w(a),f.recalcGridWidth(a));return e},recalcColumnsTableJson:function(a){p.recalcColumns(a.data,{resetWidth:!0,
newWidth:a.style.width,_isJson:!0})}};return p});