define(["require","exports","tslib","../../Validation","./ArcGisApiVersion","esri/geometry/Multipoint","esri/geometry/Point"],function(e,t,n,l,r,u,v){"use strict";function f(e){if(null==e)return null;switch(e.type){case"extent":return new v.default({x:(e.xmax+e.xmin)/2,y:(e.ymax+e.ymin)/2,spatialReference:e.spatialReference});case"point":return e;case"polygon":return function(e){if(null!=(e=r.isArcGisApiVersion3x?e.getCentroid():e.centroid))return e}(e);case"polyline":return function(e){var t=e.paths;if(!(t.length<1)){for(var n=0,r=0,i=0,a=0,o=0,l=t;o<l.length;o++)for(var u=void 0,f=void 0,c=0,s=l[o];c<s.length;c++){var p=s[c],d=p[0];void 0!==u&&(n+=(d+u)*(g=Math.abs(d-u))/2,i+=g);var g=p[1];void 0!==f&&(r+=(g+f)*(p=Math.abs(g-f))/2,a+=p),u=d,f=g}return new v.default({x:n/i,y:r/a,spatialReference:e.spatialReference})}}(e);case"multipoint":return function(e){var t=e.points;if(!(t.length<1)){for(var n=0,r=0,i=0,a=t;i<a.length;i++){var o=a[i];n+=o[0],r+=o[1]}return new v.default({x:n/t.length,y:r/t.length,spatialReference:e.spatialReference})}}(e)}}Object.defineProperty(t,"__esModule",{value:!0}),u=n.__importDefault(u),v=n.__importDefault(v);i.prototype.execute=function(e,t){e=l.validation.array("geometry",e.geometry,l.validation.never);if(1<e.length){for(var n=new u.default,r=0,i=e;r<i.length;r++){var a=i[r],o=f(a);null!=o&&(n.addPoint(f(o)),n.spatialReference=a.spatialReference||n.spatialReference)}return{centroid:f(n)}}return{centroid:f(e[0])}},i.action="gcx:wf:arcgis::GetCentroid",i.suite="gcx:wf:builtin",n=i;function i(){}t.GetCentroid=n});