// 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/GridQueryUtil",["./GridDataUtil","esri/dijit/geoenrichment/utils/ArrayUtil"],function(h,m){var f={querySingleCell:function(b,a){a.fieldCell&&(a={rowId:a.fieldCell.rowId,columnId:a.fieldCell.columnId});var c;b.getFieldCells().some(function(b){if(b.parentGrid&&b.column&&b.gridData&&!(b.columnId!==a.columnId&&b.column.index!==a.columnIndex&&b.column.field!==a.columnField||b.rowId!==a.rowId&&b.gridData.index!==a.rowIndex))return c=b,!0});
if(c)return c;if(a.considerSpans){var d=f.queryColumn(b,a),g=f.queryData(b,a);if(!d||!g)return null;var e=d.index,k=g.index;b.store.data.some(function(a){return b.columns.some(function(d){var g=d.index,l=d.index+(a.columnSpans&&a.columnSpans[d.field]||0),h=a.index;d=a.index+(a.rowSpans&&a.rowSpans[d.field]||0);if(g<=e&&l>=e&&h<=k&&d>=k)return c=f.querySingleCell(b,{columnIndex:g,rowIndex:h}),!0})})}return c},queryColumn:function(b,a){var c;b.columns.some(function(b){if(b.id===a.columnId||b.index===
a.columnIndex||b.field===a.columnField)return c=b,!0});return c},queryData:function(b,a){var c;b.store.data.some(function(b){if(b.id===a.rowId||b.index===a.rowIndex)return c=b,!0});return c},queryCells:function(b,a){var c=[];if(a.fieldCell){var d=a.rowSpan||1,g=a.columnSpan||1,e=f.querySingleCell(b,a);if(e)for(var k=e.gridData.index;k<e.gridData.index+d;k++)for(var l=e.column.index;l<e.column.index+g;l++){var h=f.querySingleCell(b,{rowIndex:k,columnIndex:l});h&&c.push(h)}}else{if(!Object.keys(a).length)return c;
b.getFieldCells().forEach(function(b,d){if(void 0===a.cellIndex||d===a.cellIndex)if(void 0===a.cellIndexes||-1!==a.cellIndexes.indexOf(d))if(void 0===a.columnId||b.columnId===a.columnId)if(void 0===a.columnIds||-1!==a.columnIds.indexOf(b.columnId))if(void 0===a.columnIndex||b.column.index===a.columnIndex)if(void 0===a.columnIndexes||-1!==a.columnIndexes.indexOf(b.column.index))if(void 0===a.columnField||b.column.field===a.columnField)if(void 0===a.columnFields||-1!==a.columnFields.indexOf(b.column.field))if(void 0===
a.rowId||b.rowId===a.rowId)if(void 0===a.rowIds||-1!==a.rowIds.indexOf(b.rowId))if(void 0===a.rowIndex||b.gridData.index===a.rowIndex)void 0!==a.rowIndexes&&-1===a.rowIndexes.indexOf(b.gridData.index)||c.push(b)})}return c},getTitleCell:function(b){var a=f.querySingleCell(b,{rowIndex:0,columnIndex:0});if(a&&!h.getFieldInfo(a)&&(1===b.columns.length||h.getColumnSpan(a)===b.columns.length))return a},isDynamicFieldCell:function(b,a){return b._dynamicBindings&&b._dynamicBindings[a.column.field]},getDynamicallyBoundColumns:function(b,
a){return b._dynamicBindings&&b._dynamicBindings[a.field]},getDynamicallyBoundFieldCells:function(b,a){if(a.column){var c=b._dynamicBindings&&b._dynamicBindings[a.column.field];if(!c)return null;var d=[];c.forEach(function(c){(c=c&&f.querySingleCell(b,{columnId:c.id,rowId:a.rowId}))&&d.push(c)});return d}},getAllBoundCells:function(b,a,c){var d=[],g={};a&&a.forEach(function(a){if((!c||c(a))&&!g[a.uniqueId]){g[a.uniqueId]=!0;var e=f.getDynamicallyBoundFieldCells(b,a);e?e.forEach(function(a){d.push(a);
g[a.uniqueId]=!0}):d.push(a)}});return m.removeDuplicates(d,"uniqueId")},trimDynamicBindings:function(b,a){var c=[],d={};a&&a.forEach(function(a){var e=f.getDynamicallyBoundFieldCells(b,a);e&&e.length?(d[e[0].uniqueId]||c.push(e[0]),e.forEach(function(a){d[a.uniqueId]=!0})):c.push(a)});return c},collectFieldInfos:function(b,a){var c=[];a=a||{};var d=a.fieldCells;a.trimDynamicBinding&&d&&(d=f.trimDynamicBindings(b,d));d?d.forEach(function(a){(a=h.getFieldInfo(a))&&c.push(a)}):b.store.data.forEach(function(a){for(var b in a.fieldInfos){var d=
a.fieldInfos[b];d&&c.push(d)}});return c},cellHasFloatingTableParent:function(b){function a(b){return b.isFloatingTable?!0:b.parentWidget?a(b.parentWidget):!1}return b&&b.parentGrid?a(b.parentGrid):!1}};return f});