// 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
require({cache:{"url:widgets/Screening/impactSummaryReport/impactSummaryReport.html":'\x3cdiv\x3e\r\n  \x3cdiv class\x3d"esriCTImpactSummaryLayerContainer" data-dojo-attach-point\x3d"impactSummaryLayerContainer"\x3e\r\n    \x3c!--title \x26 field icon table--\x3e\r\n    \x3cdiv class\x3d"esriCTLayerTitleAndFieldParentContainer esriCTLayerSectionDisabled esriCTCursorPointer"\r\n      data-dojo-attach-point\x3d"layerTitleAndFieldParentContainer" tabindex\x3d"0" role\x3d"group"\x3e\r\n      \x3c!--title \x26 field icon row--\x3e\r\n      \x3cdiv class\x3d"esriCTLayerTitleAndFieldChildContainer"\x3e\r\n        \x3cdiv class\x3d"esriCTLayerPanelIcon esriCTLayerPanelExpand" data-dojo-attach-point\x3d"layerSectionIcon" tabindex\x3d"-1"\r\n          role\x3d"button" aria-expanded\x3d"false" aria-label\x3d"${nls.reportsTab.expandCollapseIconLabel}"\x3e\r\n        \x3c/div\x3e\r\n        \x3c!--title--\x3e\r\n        \x3cdiv class\x3d"esriCTImpactSummaryLayerTitle" data-dojo-attach-point\x3d"impactSummaryLayerTitle"\x3e\r\n        \x3c/div\x3e\r\n        \x3c!--field icon--\x3e\r\n        \x3cdiv class\x3d"esriCTImpactSummaryLayerFieldIcon esriCTImpactSummaryLayerFieldIconDisabled"\r\n          data-dojo-attach-point\x3d"impactSummaryLayerField" title\x3d"${nls.reportsTab.attributeChooserTooltip}"\r\n          tabindex\x3d"-1" aria-label\x3d"${nls.reportsTab.attributeChooserTooltip}" role\x3d"button"\x3e\x3c/div\x3e\r\n        \x3c!--feature count--\x3e\r\n        \x3cdiv class\x3d"esriCTImpactSummaryLayerFeatureCount esriCTLoadingIcon"\r\n          data-dojo-attach-point\x3d"impactSummaryLayerFeatureCount"\x3e\x3c/div\x3e\r\n        \x3c!-- Hint for count exceeding max record count --\x3e\r\n        \x3cdiv class\x3d"esriCTImpactSummaryLayerMaxRecordHint esriCTHidden" title\x3d"${nls.reportsTab.unableToAnalyzeText}"\r\n          data-dojo-attach-point\x3d"impactSummaryLayerMaxRecordHint" tabindex\x3d"-1" role\x3d"button"\r\n          aria-label\x3d"${nls.reportsTab.unableToAnalyzeText}"\x3e\x3c/div\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3c!--layer description--\x3e\r\n    \x3cdiv class\x3d"esriCTImpactSummaryLayerDetailContainer esriCTHidden"\r\n      data-dojo-attach-point\x3d"impactSummaryLayerDetailContainer"\x3e\r\n      \x3cdiv data-dojo-attach-point\x3d"impactSummaryLayerDetailsMsg" class\x3d"esriCTImpactSummaryLayerDetailsMsg"\x3e\x3c/div\x3e\r\n      \x3cdiv data-dojo-attach-point\x3d"impactSummaryLayerDetails" class\x3d"esriCTImpactSummaryLayerDetails"\x3e\x3c/div\x3e\r\n      \x3cdiv data-dojo-attach-point\x3d"noFieldsSelectedContainer" class\x3d"esriCTNoFieldSelectedContainer esriCTHidden"\x3e\r\n        ${nls.reportsTab.noFieldsSelected}\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/text!./impactSummaryReport.html dijit/_WidgetsInTemplateMixin dojo/_base/lang dojo/_base/array dojo/Evented jimu/BaseWidget dojo/on dojo/dom-class dojo/dom-attr esri/geometry/geometryEngine esri/geometry/Polyline esri/SpatialReference esri/graphic dojo/dom-construct esri/tasks/query esri/tasks/QueryTask dojo/Deferred ../geometryUtils ../conversionUtils ../highlightSymbolUtils ../fieldSelectorPopup/fieldSelectorPopup esri/lang jimu/utils dojo/query dojo/number dojo/string dojo/promise/all dojo/keys dijit/focus dojo/_base/event esri/arcadeProfiles/fieldCalculateProfile esri/arcade/arcade esri/arcade/Feature esri/support/expressionUtils esri/arcadeProfiles/utils".split(" "),
function(N,O,P,k,u,Q,R,x,l,p,A,S,T,F,y,H,I,z,J,U,V,W,X,w,K,C,Y,G,v,D,B,ba,L,Z,E,aa){return N([R,P,Q],{baseClass:"jimu-widget-screening-impactSummaryReport",templateString:O,_feetUnitData:[],_squareFeetUnitData:[],_milesUnitData:[],_acresUnitData:[],_metersUnitData:[],_squareMetersUnitData:[],_kilometersUnitData:[],_squareKilometersUnitData:[],_squareMilesUnitData:[],_hectaresUnitData:[],_printCompleteData:{},_printData:{},_feetUnitInfo:[],_squareFeetUnitInfo:[],_countUnitInfo:[],_milesUnitInfo:[],
_acresUnitInfo:[],_metersUnitInfo:[],_squareMetersUnitInfo:[],_kilometersUnitInfo:[],_squareKilometersUnitInfo:[],_hectaresUnitInfo:[],_squareMilesUnitInfo:[],_intersectFeatureCount:0,isExceedingMaxRecordCount:!1,intersectingFeatureIdsToTolerance:[],intersectingFeatureIds:[],_lengthAnalysisUnitsArray:[],_areaAnalysisUnitsArray:[],_aggregatedFeatureGeometries:[],_featureIntersectResultArr:[],_layerDefinition:null,_isFieldsSelectorClick:!1,_selectedFields:[],constructor:function(b){this._feetUnitData=
[];this._squareFeetUnitData=[];this._milesUnitData=[];this._acresUnitData=[];this._metersUnitData=[];this._squareMetersUnitData=[];this._kilometersUnitData=[];this._squareKilometersUnitData=[];this._squareMilesUnitData=[];this._hectaresUnitData=[];this._printCompleteData={};this._printData={};this._feetUnitInfo=[];this._squareFeetUnitInfo=[];this._countUnitInfo=[];this._milesUnitInfo=[];this._acresUnitInfo=[];this._metersUnitInfo=[];this._squareMetersUnitInfo=[];this._kilometersUnitInfo=[];this._squareKilometersUnitInfo=
[];this._hectaresUnitInfo=[];this._squareMilesUnitInfo=[];this._intersectFeatureCount=0;this.isExceedingMaxRecordCount=!1;this.intersectingFeatureIdsToTolerance=[];this.intersectingFeatureIds=[];this._lengthAnalysisUnitsArray=[];this._areaAnalysisUnitsArray=[];this._aggregatedFeatureGeometries=[];this._featureIntersectResultArr=[];this._layerDefinition=null;this._isFieldsSelectorClick=!1;this._selectedFields=[];k.mixin(this,b)},postCreate:function(){this._layerDefinition=w.getFeatureLayerDefinition(this.featureLayer);
this._lengthAnalysisUnitsArray=["Feet","Miles","Meters","Kilometers"];this._areaAnalysisUnitsArray="SquareFeet Acres SquareMeters SquareKilometers Hectares SquareMiles".split(" ");this.own(x(this.impactSummaryLayerMaxRecordHint,"click",k.hitch(this,function(b){b.stopPropagation();b.preventDefault();this.isExceedingMaxRecordCount?this.emit("showMessage",this.nls.reportsTab.unableToAnalyzeText):this.emit("showMessage",this.nls.reportsTab.layerNotVisibleText)})));this._attachEventToNodes()},_displayLayerNotVisibleText:function(){l.add(this.impactSummaryLayerFeatureCount,
"esriCTHidden");l.remove(this.layerTitleAndFieldParentContainer,"esriCTLayerSectionDisabled");p.set(this.impactSummaryLayerMaxRecordHint,"title",this.nls.reportsTab.layerNotVisibleText);l.remove(this.impactSummaryLayerMaxRecordHint,"esriCTHidden");l.add(this.impactSummaryLayerTitle,"esriCTLayerTitleOverrideWidth");this._showMessage(this.nls.reportsTab.layerNotVisibleText)},generateReport:function(b,a,c){var d,e;var f=new z;this._setAttributeToFeatureLayerContainer();this._setFeatureLayerTitle();this._attachEventToLayerTitle();
this._aggregatedFeatureGeometries=[];this._featureIntersectResultArr=[];(e=this.layerInfosObj.getLayerInfoById(this.featureLayer.id))&&e.isVisible()&&e.isInScale()||e&&!e.isVisible()&&!this.config.allowVisibleLayerAnalysisOnly||e&&!e.isInScale()&&!this.config.allowVisibleLayerAnalysisOnly||this.isFeatureCollectionLayer?this._getIntersectingFeaturesCount(c).then(k.hitch(this,function(g){this._getIntersectingFeaturesCount(a).then(k.hitch(this,function(h){this.intersectingFeatureIdsToTolerance=this._getUniqueIds(g,
h);this._getIntersectingFeaturesCount(b).then(k.hitch(this,function(n){this.intersectingFeatureIds=k.clone(n);n=this._getUniqueIds(h,n);if(this.isExceedingMaxRecordCount)this._setFeatureLayerIntersectFeatureCount(n.length),this._pushDataInPrintDataObj(this.configuredLayerLabel,null,null),this._printData={},this._printData=k.clone(this._printCompleteData),this._showMessage(this.nls.reportsTab.unableToAnalyzeText),l.remove(this.layerTitleAndFieldParentContainer,"esriCTLayerSectionDisabled"),this._showReport(),
f.resolve(this._getReportLayerDetails([]));else{var m=b||a;this._getFeatureByChunks(n,m).then(k.hitch(this,function(r){var q=[];this._featureIntersectResultArr=[];u.forEach(r,k.hitch(this,function(M){b&&A.touches(M.geometry,b)||q.push(M)}));var t=[];this._setFeatureLayerIntersectFeatureCount(q.length);0<q.length?("esriGeometryPolyline"!==this.featureLayer.geometryType&&"esriGeometryPolygon"!==this.featureLayer.geometryType||!b?t=q:(d=this._polygonToPolyline(b),t=this._getCutOrWithInFeatures(d,q,b)),
this._createLayerDetails(t,this.featureLayer.geometryType).then(k.hitch(this,function(){this._filterPrintDataObjAccToConfiguredFields(this.configuredField);l.remove(this.impactSummaryLayerField,"esriCTImpactSummaryLayerFieldIconDisabled");l.remove(this.layerTitleAndFieldParentContainer,"esriCTLayerSectionDisabled");this._featureIntersectResultArr=t;this._showReport();f.resolve(this._getReportLayerDetails(t))}))):(this._pushDataInPrintDataObj(this.configuredLayerLabel,null,null),this._printData={},
this._printData=k.clone(this._printCompleteData),this._showMessage(this.nls.reportsTab.noDetailsAvailableText),l.remove(this.layerTitleAndFieldParentContainer,"esriCTLayerSectionDisabled"),this._featureIntersectResultArr=t,this._showReport(),f.resolve(this._getReportLayerDetails(t)))}))}}))}))})):(this._displayLayerNotVisibleText(),f.resolve());return f.promise},retainLastSelectedField:function(){null!==this.retainSelectedFieldsArr&&(this._selectedFields=this.retainSelectedFieldsArr,l.contains(this.impactSummaryLayerField,
"esriCTImpactSummaryLayerFieldIconDisabled")||this._filterFieldsForReport(this.retainSelectedFieldsArr))},_getReportLayerDetails:function(b){var a={};a.id=this.id;a.featureLayerId=this.featureLayer.id;a.features=b;a.printInfo={};a.printInfo.isExceedingMaxRecordCount=this.isExceedingMaxRecordCount;a.printInfo.featureCount=this._intersectFeatureCount;a.printInfo.info=this._printData;a.printInfo.feetUnitInfo=this._feetUnitInfo;a.printInfo.squareFeetUnitInfo=this._squareFeetUnitInfo;a.printInfo.countUnitInfo=
this._countUnitInfo;a.printInfo.milesUnitInfo=this._milesUnitInfo;a.printInfo.acresUnitInfo=this._acresUnitInfo;a.printInfo.metersUnitInfo=this._metersUnitInfo;a.printInfo.squareMetersUnitInfo=this._squareMetersUnitInfo;a.printInfo.kilometersUnitInfo=this._kilometersUnitInfo;a.printInfo.squareKilometersUnitInfo=this._squareKilometersUnitInfo;a.printInfo.squareMilesUnitInfo=this._squareMilesUnitInfo;a.printInfo.hectaresUnitInfo=this._hectaresUnitInfo;a.printInfo.geometryType=this.featureLayer.geometryType;
a.printInfo.groupbyfieldCheckBoxStatus=this.groupbyfieldCheckBoxStatus;return a},_setAttributeToFeatureLayerContainer:function(){p.set(this.impactSummaryLayerContainer,"featureLayerID",this.featureLayer.id)},_setFeatureLayerTitle:function(b){var a=this.configuredLayerLabel;this.configuredLayerLabel||(a=this.configuredLayerLabel=this.featureLayer.name);if(b||0===b)a=Y.substitute(this.nls.reportsTab.layerNameWithFeatureCount,{layerName:this.configuredLayerLabel,featureCount:b});p.set(this.impactSummaryLayerTitle,
"innerHTML",w.sanitizeHTML(this.configuredLayerLabel));p.set(this.impactSummaryLayerTitle,"title",w.sanitizeHTML(this.configuredLayerLabel));p.set(this.layerTitleAndFieldParentContainer,"aria-label",a)},_attachEventToLayerTitle:function(){this.own(x(this.layerTitleAndFieldParentContainer,"click",k.hitch(this,function(b){l.contains(b.target,"esriCTImpactSummaryLayerFieldIcon")?l.contains(this.impactSummaryLayerField,"esriCTImpactSummaryLayerFieldIconDisabled")||this._createFieldSelectorPopupWidget():
l.contains(this.layerTitleAndFieldParentContainer,"esriCTLayerSectionDisabled")||this._showOrHideLayerDetailsContainer()})))},_createFieldSelectorPopupWidget:function(){this._isFieldsSelectorClick=!0;if(this._fieldSelectorWidget)this._fieldSelectorWidget.onFieldsSelectorClick();else this._fieldSelectorWidget=new W({outFields:this.configuredField,popupTitle:this.configuredLayerLabel,fieldTitle:this.nls.reportsTab.selectReportFieldTitle,nls:this.nls,appConfig:this.appConfig,retainSelectedFieldsArr:this.retainSelectedFieldsArr}),
x(this._fieldSelectorWidget,"onFieldSelectComplete",k.hitch(this,function(b){this._selectedFields=b;this._filterFieldsForReport(b)})),x(this._fieldSelectorWidget,"onCancel",k.hitch(this,function(){this._selectedFields=null!==this.retainSelectedFieldsArr?this.retainSelectedFieldsArr:this._getAllFields()})),x(this._fieldSelectorWidget,"onClose",k.hitch(this,function(){this._selectedFields=null!==this.retainSelectedFieldsArr?this.retainSelectedFieldsArr:this._getAllFields()})),this._fieldSelectorWidget.startup();
"DartTheme"===this.appConfig.theme.name&&l.add(this._fieldSelectorWidget.fieldsPopup.domNode,"esriCTDartPanel")},_getAllFields:function(){var b;var a=[];for(b in this.configuredField)this.configuredField.hasOwnProperty(b)&&(this.configuredField[b].hasOwnProperty("fieldName")&&a.push(this.configuredField[b].fieldName),this.configuredField[b].hasOwnProperty("name")&&a.push(this.configuredField[b].name));return a},getSelectedFields:function(){return l.contains(this.impactSummaryLayerField,"esriCTImpactSummaryLayerFieldIconDisabled")?
0<this._selectedFields.length?this._selectedFields:0===this._selectedFields.length&&null===this.retainSelectedFieldsArr?this._getAllFields():0===this._selectedFields.length&&0===this.retainSelectedFieldsArr.length?[]:this._getAllFields():this._isFieldsSelectorClick&&0<this._selectedFields.length?this._selectedFields:this._isFieldsSelectorClick&&0===this._selectedFields.length?[]:!this._isFieldsSelectorClick&&0<this._selectedFields.length?this._selectedFields:this._isFieldsSelectorClick||0!==this._selectedFields.length||
null!==this.retainSelectedFieldsArr?this._isFieldsSelectorClick||0!==this._selectedFields.length||0!==this.retainSelectedFieldsArr.length?this._getAllFields():[]:this._getAllFields()},_filterFieldsForReport:function(b){var a=k.clone(this.configuredField),c;for(c in this.configuredField)-1>=b.indexOf(c)&&delete a[c];this._filterPrintDataObjAccToConfiguredFields(a);(b=K(".esriCTAttrTableHighlighted",this.domNode.parentElement))&&0<b.length&&p.get(b[0],"esriCTLayerId")===this.featureLayer.id&&(l.remove(b[0],
"esriCTAttrTableHighlighted"),this.highlightGraphicsLayer.clear());this._showReport();this.emit("printDataUpdated",{id:this.id,printData:this._printData})},_showOrHideLayerDetailsContainer:function(){l.toggle(this.layerTitleAndFieldParentContainer,"esriCTBoldFont");l.toggle(this.impactSummaryLayerDetailContainer,"esriCTHidden");l.contains(this.layerSectionIcon,"esriCTLayerPanelExpand")?(l.replace(this.layerSectionIcon,"esriCTLayerPanelCollapse","esriCTLayerPanelExpand"),p.set(this.layerSectionIcon,
"aria-expanded","true")):(l.replace(this.layerSectionIcon,"esriCTLayerPanelExpand","esriCTLayerPanelCollapse"),p.set(this.layerSectionIcon,"aria-expanded","false"))},_getIntersectingFeaturesCount:function(b){var a,c;var d=new z;if(b)if(this.isFeatureCollectionLayer){var e=[];if(0<this.featureLayer.graphics.length)for(c=0;c<this.featureLayer.graphics.length;c++)(a=this.featureLayer.graphics[c].geometry?A.intersects(b,this.featureLayer.graphics[c].geometry):null)&&e.push(c);d.resolve(e)}else{var f;
e=new H;a=new I(this.featureLayer.url);(f=this.layerInfosObj.getLayerInfoById(this.featureLayer.id))&&(c=f.getFilter()?f.getFilter():"1\x3d1");c&&(e.where=c);e.geometry=b;a.executeForIds(e,k.hitch(this,function(g){g&&0!==g.length?(g.length>this.maxFeaturesForAnalysis&&(l.remove(this.impactSummaryLayerMaxRecordHint,"esriCTHidden"),l.add(this.impactSummaryLayerTitle,"esriCTLayerTitleOverrideWidth"),this.isExceedingMaxRecordCount=!0,this.emit("exceedingMaxRecordCount")),d.resolve(g)):d.resolve([])}),
k.hitch(this,function(){d.resolve([])}))}else d.resolve([]);return d.promise},_getFeatureByChunks:function(b,a){var c=new z;var d=[];var e=this.featureLayer.maxRecordCount;if(this.isFeatureCollectionLayer)d.push(this._getIntersectFeature(b,a));else for(;0<b.length;)d.push(this._getIntersectFeature(b.splice(0,e),a));G(d).then(k.hitch(this,function(f){var g=[];u.forEach(f,k.hitch(this,function(h){g=g.concat(h)}));c.resolve(g)}));return c.promise},_getIntersectFeature:function(b,a){var c;var d=new z;
if(this.isFeatureCollectionLayer){var e=[];if(0<this.featureLayer.graphics.length)for(b=0;b<this.featureLayer.graphics.length;b++)(c=this.featureLayer.graphics[b].geometry?A.intersects(a,this.featureLayer.graphics[b].geometry):null)&&e.push(this.featureLayer.graphics[b]);d.resolve(e.splice(0,this.maxFeaturesForAnalysis))}else e=new H,e.outFields=["*"],e.returnGeometry=!0,e.objectIds=b,e.outSpatialReference=a.spatialReference,a=new I(this.featureLayer.url),a.execute(e,k.hitch(this,function(f){f.features?
d.resolve(f.features):d.resolve([])}),k.hitch(this,function(){d.resolve([])}));return d.promise},_setFeatureLayerIntersectFeatureCount:function(b){this._intersectFeatureCount=C.format(b);l.remove(this.impactSummaryLayerFeatureCount,"esriCTLoadingIcon");p.set(this.impactSummaryLayerFeatureCount,"innerHTML","("+this._intersectFeatureCount+")");p.set(this.impactSummaryLayerFeatureCount,"title","("+this._intersectFeatureCount+")");this._setFeatureLayerTitle(b)},_isDonutPolygon:function(b){var a=!1;"polygon"===
b.type&&1<b.rings.length&&u.forEach(b.rings,k.hitch(this,function(c){b.isClockwise(c)||(a=!0)}));return a},_getCutOrWithInFeatures:function(b,a,c){var d=[];for(var e=0;e<b.length;e++)for(var f=0;f<a.length;f++){var g=A.cut(a[f].geometry,b[e]);0<g.length?d=this._getWithinFeature({cutFeatureArr:g,bufferGeometry:c,featureIntersectResultArr:d,intersectFeatureArr:a,index:f}):(A.within(a[f].geometry,c)?g=new F(a[f].geometry,null,a[f].attributes):(g=A.intersect(a[f].geometry,c),g=new F(g,null,a[f].attributes,
null)),d.push(g))}return d},_getWithinFeature:function(b){var a;var c=b.cutFeatureArr;var d=b.bufferGeometry;var e=b.intersectFeatureArr;var f=b.featureIntersectResultArr;var g=b.index;u.forEach(c,k.hitch(this,function(h){A.within(h,d)&&(a=new F(h,null,e[g].attributes),f.push(a))}));return f},_polygonToPolyline:function(b){var a,c;var d=[];var e=new S(new T({wkid:102100}));for(c=0;c<b.rings.length;c++){var f=[];for(a=0;a<b.rings[c].length;a++)f.push(b.rings[c][a]);e.addPath(f)}d.push(e);return d},
_updateFormattedAttribute:function(b){var a=new z,c=[],d=null;if(!this.isFeatureCollectionLayer){var e=this.layerInfosObj.getLayerInfoById(this.featureLayer.id);d=e.originOperLayer.popupInfo;!d&&e&&e.getPopupInfo&&e.getPopupInfo()&&(d=e.getPopupInfo())}if(d&&d.expressionInfos&&0<d.expressionInfos.length){var f=this.parseArcadeExpressions(d.expressionInfos);u.forEach(b,k.hitch(this,function(g){c.push(this.combineFeatureAttributesAndExpressionResolutions(g,e,d.expressionInfos,f))}))}G(c).then(k.hitch(this,
function(g){u.forEach(b,k.hitch(this,function(h,n){var m;-1===this.intersectingFeatureIds.indexOf(h.attributes[this.featureLayer.objectIdField])&&(m=!0);var r=g&&0<g.length&&g[n]?k.clone(g[n]):k.clone(h.attributes);r=this._getFormatedAttrs(r,this.featureLayer.fields,d);b[n].setAttributes(r);u.forEach(this.featureLayer.fields,k.hitch(this,function(q){b[n].attributes.hasOwnProperty(q.name)||(b[n].attributes[q.name]=this.nls.reportsTab.noDataText);if(b[n].attributes.hasOwnProperty(q.name)){var t=b[n].attributes[q.name];
void 0===t||""===t||null===t?b[n].attributes[q.name]=this.nls.reportsTab.noDataText:""===k.trim(t.toString())&&(b[n].attributes[q.name]=this.nls.reportsTab.noDataText)}}));if(m&&"esriGeometryPolygon"===this.featureLayer.geometryType)this._squareFeetUnitData.push(0),this._acresUnitData.push(0),this._squareMetersUnitData.push(0),this._squareKilometersUnitData.push(0),this._squareMilesUnitData.push(0),this._hectaresUnitData.push(0);else if(m&&"esriGeometryPolyline"===this.featureLayer.geometryType)this._feetUnitData.push(0),
this._milesUnitData.push(0),this._metersUnitData.push(0),this._kilometersUnitData.push(0);else switch(this.featureLayer.geometryType){case "esriGeometryPolygon":h=J.getAreaOfGeometry(h.geometry);this._squareFeetUnitData.push(h.squareFeet);this._acresUnitData.push(h.acres);this._squareMetersUnitData.push(h.squareMeters);this._squareKilometersUnitData.push(h.squareKilometer);this._squareMilesUnitData.push(h.squareMiles);this._hectaresUnitData.push(h.hectares);break;case "esriGeometryPolyline":h=J.getLengthOfGeometry(h.geometry),
this._feetUnitData.push(h.feet),this._milesUnitData.push(h.miles),this._metersUnitData.push(h.meters),this._kilometersUnitData.push(h.kilometers)}}));a.resolve(b)}));return a},_getFieldText:function(b,a){return b.label?b.label:b.alias?b.alias:a},_createLayerDetails:function(b,a){var c,d,e,f,g;var h=Object.keys(this.configuredField).length;var n=new z;this._updateFormattedAttribute(b).then(k.hitch(this,function(m){b=m;this._pushDataInPrintDataObj(this.configuredLayerLabel,null,null);for(g in this.configuredField)for(e=
this.configuredField[g],f=this._getFieldText(e,g),this._printCompleteData.cols.push(f),c=0;c<b.length;c++)switch((d=b[c].attributes[g])||0===d?this._pushDataInPrintDataObj(null,c,d):this._pushDataInPrintDataObj(null,c,""),a){case "esriGeometryPolyline":this._printCompleteData.cols.length===h&&(this._feetUnitInfo.push(this._feetUnitData[c]),this._milesUnitInfo.push(this._milesUnitData[c]),this._metersUnitInfo.push(this._metersUnitData[c]),this._kilometersUnitInfo.push(this._kilometersUnitData[c]));
break;case "esriGeometryPolygon":this._printCompleteData.cols.length===h&&(this._squareFeetUnitInfo.push(this._squareFeetUnitData[c]),this._acresUnitInfo.push(this._acresUnitData[c]),this._squareMetersUnitInfo.push(this._squareMetersUnitData[c]),this._squareKilometersUnitInfo.push(this._squareKilometersUnitData[c]),this._squareMilesUnitInfo.push(this._squareMilesUnitData[c]),this._hectaresUnitInfo.push(this._hectaresUnitData[c]));break;case "esriGeometryPoint":this._printCompleteData.cols.length===
h&&this._countUnitInfo.push(1)}n.resolve()}));return n.promise},_pushDataInPrintDataObj:function(b,a,c){b?(this._printCompleteData={},this._feetUnitInfo=[],this._squareFeetUnitInfo=[],this._countUnitInfo=[],this._milesUnitInfo=[],this._acresUnitInfo=[],this._metersUnitInfo=[],this._squareMetersUnitInfo=[],this._kilometersUnitInfo=[],this.squareKilometersUnitInfo=[],this.squareMilesUnitInfo=[],this._hectaresUnitInfo=[],this._printCompleteData.title=b,this._printCompleteData.rows=[],this._printCompleteData.cols=
[]):(c===this.nls.reportsTab.noDataText&&(c="\x3ci\x3e"+c+"\x3c/i\x3e"),this._printCompleteData.rows[a]||this._printCompleteData.rows.push([]),this._printCompleteData.rows[a].push(c))},_filterPrintDataObjAccToConfiguredFields:function(b){var a,c;this._printData={};this._printData=k.clone(this._printCompleteData);for(a=this._printData.cols.length-1;0<=a;--a){var d=!1;for(c in b)switch(this._printData.cols[a]){case b[c].label:d=!0;break;case b[c].alias:d=!0;break;case c:d=!0}if(!d)for(this._printData.cols.splice(a,
1),d=0;d<this._printData.rows.length;d++)this._printData.rows[d].splice(a,1)}},_getFormatedAttrs:function(b,a,c){function d(g){if(c&&X.isDefined(c.fieldInfos))for(var h=0,n=c.fieldInfos.length;h<n;h++){var m=c.fieldInfos[h];if(m.fieldName===g)return m.format}return null}var e=[null,void 0,""],f={};u.forEach(a,k.hitch(this,function(g,h){if(-1===e.indexOf(b[g.name])){var n="esriFieldTypeDate"===g.type,m=g.name;if("esriFieldTypeDate"===a[h].type)f[m]=w.fieldFormatter.getFormattedDate(b[g.name],d(g.name));
else if("esriFieldTypeDouble"===a[h].type||"esriFieldTypeSingle"===a[h].type||"esriFieldTypeInteger"===a[h].type||"esriFieldTypeSmallInteger"===a[h].type)f[m]=this._getFormattedNumber(b[g.name],d(g.name));n||(f[m]=m in f?f[m]:b[g.name],(g=w.getDisplayValueForCodedValueOrSubtype(this._layerDefinition,g.name,b))&&g.isCodedValueOrSubtype&&g.hasOwnProperty("displayValue")&&-1===e.indexOf(g.displayValue)&&(g=g.displayValue,f[m]=g||isFinite(g)?g:""))}}));c&&c.expressionInfos&&u.forEach(c.expressionInfos,
k.hitch(this,function(g,h){h="expression/"+g.name;-1===e.indexOf(b[h])&&("date"===g.returnType?f[h]=w.fieldFormatter.getFormattedDate(b[h],d(h)):"number"===g.returnType?f[h]=this._getFormattedNumber(Number(b[h]),d(h)):"string"===g.returnType&&(f[h]=b[h]))}));return f},_getFormattedNumber:function(b,a){if("number"===typeof b){var c=(b.toString().split(".")[1]||"").length;return(b=w.localizeNumberByFieldInfo(b,{format:{places:a&&"number"===typeof a.places?parseInt(a.places,10):c,digitSeparator:a&&a.digitSeparator}}))||
""}return b},_getArrayIndex:function(b,a){var c,d,e=[];for(c=0;c<b.length;++c)if(a.length===b[c].length){var f=b[c];for(d=0;d<a.length&&a[d]===f[d];)++d;d===a.length&&e.push(c)}return e},getSum:function(b,a){b=(a&&0<a.length?u.filter(b,function(c,d){return-1<a.indexOf(d)}):b).reduce(function(c,d){return c+d},0);return.01<b?U.honourPopupRounding(2,b):b},_getAggregatedColTitle:function(b){switch(b){case "esriGeometryPoint":var a=this.nls.reportsTab.featureCountText;break;case "esriGeometryPolyline":a=
this.nls.reportsTab.featureLengthText;break;case "esriGeometryPolygon":a=this.nls.reportsTab.featureAreaText}return a},_getUnitsForGeometry:function(b,a){switch(b){case "esriGeometryPoint":var c="";break;case "esriGeometryPolyline":c=this._getAnalysisUnitForGeometry(a,b);break;case "esriGeometryPolygon":c=this._getAnalysisUnitForGeometry(a,b)}return c},_getAnalysisUnitForGeometry:function(b,a){switch(b){case "Feet":case "SquareFeet":var c="esriGeometryPolygon"===a?this.nls.units.feetAbbr+"\x26sup2":
this.nls.units.feetAbbr;break;case "Miles":case "Acres":c="esriGeometryPolygon"===a?this.nls.units.acresAbbr:this.nls.units.milesAbbr;break;case "Meters":case "SquareMeters":c="esriGeometryPolygon"===a?this.nls.units.metersAbbr+"\x26sup2":this.nls.units.metersAbbr;break;case "Kilometers":case "SquareKilometers":c="esriGeometryPolygon"===a?this.nls.units.kilometersAbbr+"\x26sup2":this.nls.units.kilometersAbbr;break;case "Hectares":c="esriGeometryPolygon"===a?this.nls.reportsTab.hectaresAbbr:this.nls.units.kilometersAbbr;
break;case "SquareMiles":c="esriGeometryPolygon"===a?this.nls.units.milesAbbr+"\x26sup2":this.nls.units.milesAbbr}return c},_showMessage:function(b){y.empty(this.impactSummaryLayerDetails);p.set(this.impactSummaryLayerDetailsMsg,"innerHTML",b);l.add(this.impactSummaryLayerDetailsMsg,"esriCTLayerDetailCenterText")},_showReport:function(){var b,a,c=[];var d=this._printData;y.empty(this.impactSummaryLayerDetails);if(!d.cols.length&&0<d.rows.length)this._showMessage(this.nls.reportsTab.noFieldsSelected);
else if(d.rows&&0<d.rows.length){p.set(this.impactSummaryLayerDetailsMsg,"innerHTML","");l.remove(this.impactSummaryLayerDetailsMsg,"esriCTLayerDetailCenterText");var e=[];var f={};for(a=0;a<d.rows.length;a++)if(this.groupbyfieldCheckBoxStatus){if(0>e.indexOf(a)){var g=this._getArrayIndex(d.rows,d.rows[a]);f[a]=g;e=e.concat(g)}if(e.length===d.rows.length)break}else g=[],g.push(a),f[a]=g;e={rows:[],cols:k.clone(d.cols)};a=this._getAggregatedColTitle(this.featureLayer.geometryType);"esriGeometryPoint"===
this.featureLayer.geometryType?e.cols.push(a):"esriGeometryPolyline"===this.featureLayer.geometryType?(e.cols.push(a),e.cols.push(a),e.cols.push(a),e.cols.push(a)):"esriGeometryPolygon"===this.featureLayer.geometryType&&(e.cols.push(a),e.cols.push(a),e.cols.push(a),e.cols.push(a),e.cols.push(a),e.cols.push(a));for(b in f){a=k.clone(d.rows[parseInt(b,10)]);if("esriGeometryPolyline"===this.featureLayer.geometryType){a.push(this.getSum(this._feetUnitInfo,f[parseInt(b,10)]));a.push(this.getSum(this._milesUnitInfo,
f[parseInt(b,10)]));a.push(this.getSum(this._metersUnitInfo,f[parseInt(b,10)]));var h=this.getSum(this._kilometersUnitInfo,f[parseInt(b,10)]);a.push(h)}else if("esriGeometryPolygon"===this.featureLayer.geometryType){a.push(this.getSum(this._squareFeetUnitInfo,f[parseInt(b,10)]));a.push(this.getSum(this._acresUnitInfo,f[parseInt(b,10)]));a.push(this.getSum(this._squareMetersUnitInfo,f[parseInt(b,10)]));a.push(this.getSum(this._squareKilometersUnitInfo,f[parseInt(b,10)]));var n=this.getSum(this._hectaresUnitInfo,
f[parseInt(b,10)]);a.push(n);a.push(this.getSum(this._squareMilesUnitInfo,f[parseInt(b,10)]))}else if("esriGeometryPoint"===this.featureLayer.geometryType){var m=this.getSum(this._countUnitInfo,f[parseInt(b,10)]);a.push(m)}e.rows.push(a);this._featureIntersectResultArr&&("esriGeometryPolyline"===this.featureLayer.geometryType?c.push({features:this._getAggregatedFeatures(f[b]),sortValue:h}):"esriGeometryPolygon"===this.featureLayer.geometryType?c.push({features:this._getAggregatedFeatures(f[b]),sortValue:n}):
"esriGeometryPoint"===this.featureLayer.geometryType&&c.push({features:this._getAggregatedFeatures(f[b]),sortValue:m}))}this._renderReport(e,c)}},_getAggregatedFeatures:function(b){var a=[];u.forEach(b,k.hitch(this,function(c){a.push(this._featureIntersectResultArr[c])}));return a},_sortFeatureArray:function(b,a){var c=b.length-1;return b[c]<a[c]?1:b[c]>a[c]?-1:0},_sortArrayByKey:function(b,a){return b.sortValue<a.sortValue?1:b.sortValue>a.sortValue?-1:0},_createTemplateNode:function(){var b=y.create("div",
{"class":"esriCTImpactSummaryLayerDetailMainNode",tabindex:0,role:"presentation"},this.impactSummaryLayerDetails);var a=y.create("table",{"class":"esriCTAttrTable esriCTCursorPointer",cellpadding:"0px",cellspacing:"0px"},b);y.create("div",{"class":"esriCTInfoDataSeparator"},this.impactSummaryLayerDetails);this.own(x(a,"click",k.hitch(this,function(c){this._highlightSelection(c.currentTarget)})));this.own(x(b,"keydown",k.hitch(this,function(c){c.keyCode!==v.ENTER&&c.keyCode!==v.SPACE||this._highlightSelection(c.currentTarget.children[0])})));
return a},_renderReport:function(b,a){b.rows&&0<b.rows.length&&(b.rows=b.rows.sort(this._sortFeatureArray),this._aggregatedFeatureGeometries=a=a.sort(this._sortArrayByKey),u.forEach(b.rows,k.hitch(this,function(c,d){var e;var f=this._createTemplateNode();p.set(f,"esriCTTableIndex",d);p.set(f,"esriCTLayerId",this.featureLayer.id);u.forEach(c,k.hitch(this,function(g,h){e=y.create("tr",{valign:"top"},f);var n=y.create("td",{"class":"esriCTAttrName"},e);var m=y.create("td",{"class":"esriCTAttrValue"},
e);var r=w.fieldFormatter.getFormattedUrl(g);g=b.cols[h]+": ";var q=r;switch(this.featureLayer.geometryType){case "esriGeometryPoint":var t=1;break;case "esriGeometryPolyline":t=4;break;case "esriGeometryPolygon":t=6}if(h>=c.length-t){h-=c.length-t;.01<=r?(r="esriGeometryPoint"!==this.featureLayer.geometryType?C.format(r,{places:2}):C.format(r),"esriGeometryPolyline"===this.featureLayer.geometryType?q=g+r+" "+this._getUnitsForGeometry(this.featureLayer.geometryType,this._lengthAnalysisUnitsArray[h]):
"esriGeometryPolygon"===this.featureLayer.geometryType?q=g+r+" "+this._getUnitsForGeometry(this.featureLayer.geometryType,this._areaAnalysisUnitsArray[h]):"esriGeometryPoint"===this.featureLayer.geometryType&&(q=g+r+" "+this._getUnitsForGeometry(this.featureLayer.geometryType,null))):.01>r&&0!==r?"esriGeometryPolyline"===this.featureLayer.geometryType?q=g+"  \x3c "+C.format(.01)+" "+this._getUnitsForGeometry(this.featureLayer.geometryType,this._lengthAnalysisUnitsArray[h]):"esriGeometryPolygon"===
this.featureLayer.geometryType?q=g+"  \x3c "+C.format(.01)+" "+this._getUnitsForGeometry(this.featureLayer.geometryType,this._areaAnalysisUnitsArray[h]):"esriGeometryPoint"===this.featureLayer.geometryType&&(q=g+"  \x3c "+C.format(.01)+" "+this._getUnitsForGeometry(this.featureLayer.geometryType,null)):q=g+" "+this.nls.reportsTab.notApplicableText;g="";l.add(n,"esriCTReportsTabInfoData");r="esriGeometryPolyline"===this.featureLayer.geometryType?"esriCTFieldDistinct"+this._lengthAnalysisUnitsArray[h]+
"UnitData":"esriCTFieldDistinct"+this._areaAnalysisUnitsArray[h]+"UnitData";l.add(m,"esriCTInfoDataMeasurement esriCTReportsTabInfoData");if("esriGeometryPolyline"===this.featureLayer.geometryType){switch(this._lengthAnalysisUnitsArray[h]){case "Feet":case "Miles":case "Meters":case "Kilometers":l.add(m,r),l.add(m,"esriCTEsriGeometryPolyline")}this.config.lengthUnits!==this._lengthAnalysisUnitsArray[h]&&l.add(m,"esriCTHidden")}if("esriGeometryPolygon"===this.featureLayer.geometryType){switch(this._areaAnalysisUnitsArray[h]){case "SquareFeet":case "Acres":case "SquareMeters":case "SquareKilometers":case "Hectares":case "SquareMiles":l.add(m,
r),l.add(m,"esriCTEsriGeometryPolygon")}this.config.areaUnits!==this._areaAnalysisUnitsArray[h]&&l.add(m,"esriCTHidden")}}p.set(n,"innerHTML",g);p.set(m,"innerHTML",q)}))})))},_getUniqueIds:function(b,a){if(0===b.length)return a;if(0===a.length)return b;u.forEach(b,k.hitch(this,function(c){c=a.indexOf(c);-1!==c&&a.splice(c,1)}));return b.concat(a)},_highlightSelection:function(b){var a;l.contains(b,"esriCTAttrTableHighlighted")?(l.remove(b,"esriCTAttrTableHighlighted"),this.highlightGraphicsLayer.clear()):
((a=K(".esriCTAttrTableHighlighted",this.domNode.parentElement))&&0<a.length&&l.remove(a[0],"esriCTAttrTableHighlighted"),this.highlightGraphicsLayer.clear(),l.add(b,"esriCTAttrTableHighlighted"),b=p.get(b,"esriCTTableIndex"),b=this._aggregatedFeatureGeometries[parseInt(b,10)].features,u.forEach(b,k.hitch(this,function(c){c=V.getHighLightSymbol(c,this.featureLayer);this.highlightGraphicsLayer.add(c)})))},_attachEventToNodes:function(){var b=this.own(x.pausable(this.layerTitleAndFieldParentContainer,
"keydown",k.hitch(this,function(a){if(a.keyCode===v.ENTER||a.keyCode===v.SPACE)B.stop(a),this._setFocus(),b[0].pause()})));this.own(x(this.layerSectionIcon,"keydown",k.hitch(this,function(a){if(a.keyCode===v.ENTER||a.keyCode===v.SPACE)B.stop(a),l.contains(this.layerTitleAndFieldParentContainer,"esriCTImpactSummaryLayerFieldIcon")?l.contains(this.impactSummaryLayerField,"esriCTImpactSummaryLayerFieldIconDisabled")||this._createFieldSelectorPopupWidget():l.contains(this.layerTitleAndFieldParentContainer,
"esriCTLayerSectionDisabled")||this._showOrHideLayerDetailsContainer();a.keyCode===v.ESCAPE&&(B.stop(a),this._removeFocus(),b[0].resume())})));this.own(x(this.impactSummaryLayerField,"keydown",k.hitch(this,function(a){if(a.keyCode===v.ENTER||a.keyCode===v.SPACE)B.stop(a),l.contains(a.target,"esriCTImpactSummaryLayerFieldIconDisabled")||this._createFieldSelectorPopupWidget();a.keyCode===v.ESCAPE&&(B.stop(a),this._removeFocus(),b[0].resume())})));this.own(x(this.impactSummaryLayerMaxRecordHint,"keydown",
k.hitch(this,function(a){if(a.keyCode===v.ENTER||a.keyCode===v.SPACE)B.stop(a),this.isExceedingMaxRecordCount?this.emit("showMessage",this.nls.reportsTab.unableToAnalyzeText):this.emit("showMessage",this.nls.reportsTab.layerNotVisibleText);a.keyCode===v.ESCAPE&&(B.stop(a),this._removeFocus(),b[0].resume())})))},_removeFocus:function(){this._restrictFocus();this.emit("initializeAccessibility");this._focusOutCurrentNode();D.focus(this.layerTitleAndFieldParentContainer)},_setFocus:function(){this._allowFocus();
this._setFirstFocusNode();this._setLastFocusNode();this._setFocusOnFirstNode()},_restrictFocus:function(){p.set(this.layerSectionIcon,"tabindex","-1");p.set(this.impactSummaryLayerMaxRecordHint,"tabindex","-1");p.set(this.impactSummaryLayerField,"tabindex","-1")},_allowFocus:function(){p.set(this.layerSectionIcon,"tabindex","1");l.contains(this.impactSummaryLayerMaxRecordHint,"esriCTHidden")||p.set(this.impactSummaryLayerMaxRecordHint,"tabindex","1");l.contains(this.impactSummaryLayerField,"esriCTImpactSummaryLayerFieldIconDisabled")||
p.set(this.impactSummaryLayerField,"tabindex","1")},_setFirstFocusNode:function(){w.initFirstFocusNode(this.domNodeObj,this.layerSectionIcon)},_setLastFocusNode:function(){l.contains(this.impactSummaryLayerField,"esriCTImpactSummaryLayerFieldIconDisabled")?l.contains(this.impactSummaryLayerMaxRecordHint,"esriCTHidden")?w.initLastFocusNode(this.domNodeObj,this.layerSectionIcon):w.initLastFocusNode(this.domNodeObj,this.impactSummaryLayerMaxRecordHint):w.initLastFocusNode(this.domNodeObj,this.impactSummaryLayerField)},
_focusOutCurrentNode:function(){D.curNode&&D.curNode.blur()},_setFocusOnFirstNode:function(){this._focusOutCurrentNode();D.focus(this.layerSectionIcon)},parseArcadeExpressions:function(b){if(Array.isArray(b)&&0<b.length){var a={};u.forEach(b,function(c){a[c.name]=L.parseScript(c.expression)})}return a},initArcadeContext:function(b,a,c){var d=null,e=null;this.map&&(d=this.map);a&&a.layerObject&&(a=a.layerObject);b&&b.geometry&&b.geometry.spatialReference&&(e=b.geometry.spatialReference);return this.getEvalOptions({expression:c,
feature:b,layer:a,map:d,sr:e}).context},getEvalOptions:function(b){var a=b.feature,c=b.layer,d=b.map;b=b.spatialReference;a=a?Z.createFromGraphicLikeObject(a.geometry,a.attributes,c):null;if(c){var e={spatialReference:b};var f=c.getMap()?E.createFeatureSetFromLayer(c,e):E.createFeatureSetFromLayerUrl(c.url,e);e=(c=aa.getServiceUrl(c.url))?E.createFeatureSetCollectionFromServiceUrl(c,e):null}d=d?E.createFeatureSetCollectionFromMap(d):null;return{context:{vars:{$feature:a,$layer:f,$datastore:e,$map:d},
spatialReference:b}}},combineFeatureAttributesAndExpressionResolutions:function(b,a,c,d){var e=new z,f=[],g;var h=k.mixin({},b.attributes);if(d){b=this.initArcadeContext(b,a,c,d);for(g in d)f.push(this.executeArcadeExpression(g,d[g],b,h));G(f).then(function(){e.resolve(h)})}else e.resolve(h);return e.promise},executeArcadeExpression:function(b,a,c,d){var e=new z;(a=L.executeScript(a,c))&&a.then?a.then(function(f){d["expression/"+b]=f?f.toString():"";e.resolve(f)},function(f){d["expression/"+b]=f?
f.toString():"";e.resolve(f)}):(d["expression/"+b]=a?a.toString():"",e.resolve(a));return e.promise}})});