!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","../../Validation","./ArcGisApiVersion","esri/geometry/Multipoint","esri/geometry/Point"],e)}(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e("tslib"),l=e("../../Validation"),i=e("./ArcGisApiVersion"),u=n.__importDefault(e("esri/geometry/Multipoint")),y=n.__importDefault(e("esri/geometry/Point"));function f(e){if(null==e)return null;switch(e.type){case"extent":return new y.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=i.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,i=0,r=0,o=0,a=0,l=t;a<l.length;a++)for(var u=void 0,f=void 0,s=0,c=l[a];s<c.length;s++){var p=c[s],d=p[0];void 0!==u&&(n+=(d+u)*(g=Math.abs(d-u))/2,r+=g);var g=p[1];void 0!==f&&(i+=(g+f)*(p=Math.abs(g-f))/2,o+=p),u=d,f=g}return new y.default({x:n/r,y:i/o,spatialReference:e.spatialReference})}}(e);case"multipoint":return function(e){var t=e.points;if(!(t.length<1)){for(var n=0,i=0,r=0,o=t;r<o.length;r++){var a=o[r];n+=a[0],i+=a[1]}return new y.default({x:n/t.length,y:i/t.length,spatialReference:e.spatialReference})}}(e)}}r.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,i=0,r=e;i<r.length;i++){var o=r[i],a=f(o);null!=a&&(n.addPoint(f(a)),n.spatialReference=o.spatialReference||n.spatialReference)}return{centroid:f(n)}}return{centroid:f(e[0])}},r.action="gcx:wf:arcgis::GetCentroid",r.suite="gcx:wf:builtin",e=r;function r(){}t.GetCentroid=e});