/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../chunks/languageUtils","./fieldStats","../../core/sql/WhereClause"],(function(n,t,e,r,u){"use strict";function a(n,t,e,r,u,a){return i.apply(this,arguments)}function i(){return(i=t._asyncToGenerator((function*(n,t,a,i,s,o){if(1===i.length){if(e.isArray(i[0]))return r.calculateStat(n,i[0],e.defaultUndefined(i[1],-1));if(e.isImmutableArray(i[0]))return r.calculateStat(n,i[0].toArray(),e.defaultUndefined(i[1],-1))}else if(2===i.length){if(e.isArray(i[0]))return r.calculateStat(n,i[0],e.defaultUndefined(i[1],-1));if(e.isImmutableArray(i[0]))return r.calculateStat(n,i[0].toArray(),e.defaultUndefined(i[1],-1));if(e.isFeatureSet(i[0])){const r=yield i[0].load(),a=yield c(u.WhereClause.create(i[1],r.getFieldsIndex()),o,s);return i[0].calculateStatistic(n,a,e.defaultUndefined(i[2],1e3),t.abortSignal)}}else if(3===i.length&&e.isFeatureSet(i[0])){const r=yield i[0].load(),a=yield c(u.WhereClause.create(i[1],r.getFieldsIndex()),o,s);return i[0].calculateStatistic(n,a,e.defaultUndefined(i[2],1e3),t.abortSignal)}return r.calculateStat(n,i,-1)}))).apply(this,arguments)}function c(n,t,e){return s.apply(this,arguments)}function s(){return(s=t._asyncToGenerator((function*(n,t,e){const r=n.getVariables();if(r.length>0){const u=[];for(let n=0;n<r.length;n++){const a={name:r[n]};u.push(yield t.evaluateIdentifier(e,a))}const a={};for(let n=0;n<r.length;n++)a[r[n]]=u[n];return n.parameters=a,n}return n}))).apply(this,arguments)}function o(n){"async"===n.mode&&(n.functions.stdev=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("stdev",e,r,u,t,n)}))},n.functions.variance=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("variance",e,r,u,t,n)}))},n.functions.average=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("mean",e,r,u,t,n)}))},n.functions.mean=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("mean",e,r,u,t,n)}))},n.functions.sum=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("sum",e,r,u,t,n)}))},n.functions.min=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("min",e,r,u,t,n)}))},n.functions.max=function(t,e){return n.standardFunctionAsync(t,e,(function(e,r,u){return a("max",e,r,u,t,n)}))},n.functions.count=function(t,r){return n.standardFunctionAsync(t,r,(function(n,t,r){if(e.pcCheck(r,1,1),e.isFeatureSet(r[0]))return r[0].count(n.abortSignal);if(e.isArray(r[0])||e.isString(r[0]))return r[0].length;if(e.isImmutableArray(r[0]))return r[0].length();throw new Error("Invalid Parameters for Count")}))})}n.registerFunctions=o,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
