// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["../../core/Error","./summaryStatistics","./support/ageUtils","../support/adapters/support/layerUtils"],function(f,k,c,d){async function l(a){if(!(a&&a.layer&&a.startTime&&a.endTime&&a.unit))throw new f("summary-statistics-for-age:missing-parameters","'layer', 'startTime', 'endTime' and 'unit' parameters are required");const {layer:e,...g}=a;var b=d.createLayerAdapter(e,d.featureCapableLayerTypes);if(!b)throw new f("summary-statistics-for-age:invalid-parameters","'layer' must be one of these types: "+ d.getLayerTypeLabels(d.featureCapableLayerTypes).join(", "));a={layerAdapter:b,...g};const h=null!=a.signal?{signal:a.signal}:null;await Promise.all([a.view?.when(),b.load(h)]);if(b=c.verifyDates(b,a.startTime,a.endTime,"summary-statistics-for-age:invalid-parameters"))throw b;if(!a.unit||!c.supportedAgeUnits.includes(a.unit))throw new f("summary-statistics-for-age:invalid-parameters",`Supported units are: ${c.supportedAgeUnits.join(", ")}`);return a}return async function(a){const {layerAdapter:e, ...g}=await l(a),{view:b,startTime:h,endTime:m,unit:n,minValue:p,maxValue:q,signal:r}=g,{valueExpression:t,statisticsQuery:u}=c.getAgeExpressions({layer:e,startTime:h,endTime:m,unit:n});return k({layer:e,valueExpression:t,...u,minValue:p,maxValue:q,view:b,signal:r})}});