define(["require","exports","tslib","./esriDelegate!esri/tasks/support/ProjectParameters","../../Validation","./tools","./MapProvider","../../Hooks","./ArcGisApiVersion","esri/tasks/GeometryService"],function(p,e,v,c,d,u,t,r,l,f){"use strict";function m(e){return"number"==typeof e?{wkid:e}:"string"==typeof e?{wkt:e}:"object"==typeof e?e:null}Object.defineProperty(e,"__esModule",{value:!0}),f=v.__importDefault(f);i.prototype.execute=function(n,o,s){return v.__awaiter(this,void 0,void 0,function(){var t,r,i;return v.__generator(this,function(e){switch(e.label){case 0:return t=n.url,(i=!t)?[4,function(){return v.__awaiter(this,void 0,void 0,function(){var t;return v.__generator(this,function(e){switch(e.label){case 0:return t=!1,(t=l.isArcGisApiVersionAtLeast("4.7")||l.isArcGisApiVersion3x&&l.isArcGisApiVersionAtLeast("3.24")?!0:t)?[4,new Promise(function(e,t){p(["esri/geometry/projection"],e,t)}).then(v.__importStar)]:[3,2];case 1:e.sent().isSupported()||(t=!1),e.label=2;case 2:return[2,t]}})})}()]:[3,2];case 1:i=e.sent(),e.label=2;case 2:return i?[4,function(l,f){return v.__awaiter(this,void 0,void 0,function(){var t,r,i,n,o,s,a,c,u;return v.__generator(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e,t){p(["esri/geometry/projection"],e,t)}).then(v.__importStar)];case 1:return t=e.sent(),r=d.validation.array("geometry",l.geometry,d.validation.never),i=m(l.transformation),n=f.getOutSR(l.outSpatialReference),[4,t.load()];case 2:if(e.sent(),i)for(s=t.getTransformations(r[0].spatialReference,n),a=0,c=s;a<c.length;a++)if((u=c[a]).steps[0].isInverse===l.reverse){if(u.steps[0].wkid&&i.wkid&&u.steps[0].wkid===i.wkid){o=u;break}if(u.steps[0].wkt&&i.wkt&&u.steps[0].wkt===i.wkt){o=u;break}}return[2,t.project(r,n,o)]}})})}(n,s)]:[3,4];case 3:return r=e.sent(),[3,6];case 4:return[4,function(n,o,s,a){return v.__awaiter(this,void 0,void 0,function(){var t,r,i;return v.__generator(this,function(e){return(t=new c.ProjectParameters).geometries=d.validation.array("geometry",o.geometry,d.validation.never),t.transformation=m(o.transformation),t.transformForward=!o.reverse,l.isArcGisApiVersionAtLeast("4.4")?t.outSpatialReference=a.getOutSR(o.outSpatialReference):t.outSR=a.getOutSR(o.outSpatialReference),r=new f.default(n),i=u.isAbortable(s.cancellationToken)?{signal:s.cancellationToken.signal}:void 0,i=r.project(t,i),u.schedulePromiseCancellation(s,i),[2,u.inline(i,function(e){return e})]})})}(t=t||"https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer",n,o,s)];case 5:r=e.sent(),e.label=6;case 6:return[2,{geometry:r[0],results:r}]}})})},i.action="gcx:wf:arcgis::ProjectServiceTask",i.suite="gcx:wf:builtin",t=v.__decorate([r.activate(t.MapProvider)],i);function i(){}e.ProjectServiceTask=t});