!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require,exports):"function"==typeof define&&define.amd&&define(["require","exports","tslib","./esriDelegate!esri/tasks/support/ProjectParameters","../../Validation","./tools","./MapProvider","../../Hooks","./ArcGisApiVersion","esri/tasks/GeometryService"],e)}(function(p,e){"use strict";var d="object"==typeof module&&"object"==typeof module.exports;Object.defineProperty(e,"__esModule",{value:!0});var m=p("tslib"),c=p("./esriDelegate!esri/tasks/support/ProjectParameters"),v=p("../../Validation"),u=p("./tools"),t=p("./MapProvider"),r=p("../../Hooks"),l=p("./ArcGisApiVersion"),f=m.__importDefault(p("esri/tasks/GeometryService"));function _(e){return"number"==typeof e?{wkid:e}:"string"==typeof e?{wkt:e}:"object"==typeof e?e:null}i.prototype.execute=function(o,n,s){return m.__awaiter(this,void 0,void 0,function(){var t,r,i;return m.__generator(this,function(e){switch(e.label){case 0:return t=o.url,(i=!t)?[4,function(){return m.__awaiter(this,void 0,void 0,function(){var t;return m.__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,d?Promise.resolve().then(function(){return m.__importStar(p("esri/geometry/projection"))}):new Promise(function(e,t){p(["esri/geometry/projection"],e,t)}).then(m.__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 m.__awaiter(this,void 0,void 0,function(){var t,r,i,o,n,s,a,c,u;return m.__generator(this,function(e){switch(e.label){case 0:return[4,d?Promise.resolve().then(function(){return m.__importStar(p("esri/geometry/projection"))}):new Promise(function(e,t){p(["esri/geometry/projection"],e,t)}).then(m.__importStar)];case 1:return t=e.sent(),r=v.validation.array("geometry",l.geometry,v.validation.never),i=_(l.transformation),o=f.getOutSR(l.outSpatialReference),[4,t.load()];case 2:if(e.sent(),i)for(s=t.getTransformations(r[0].spatialReference,o),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){n=u;break}if(u.steps[0].wkt&&i.wkt&&u.steps[0].wkt===i.wkt){n=u;break}}return[2,t.project(r,o,n)]}})})}(o,s)]:[3,4];case 3:return r=e.sent(),[3,6];case 4:return[4,function(o,n,s,a){return m.__awaiter(this,void 0,void 0,function(){var t,r,i;return m.__generator(this,function(e){return(t=new c.ProjectParameters).geometries=v.validation.array("geometry",n.geometry,v.validation.never),t.transformation=_(n.transformation),t.transformForward=!n.reverse,l.isArcGisApiVersionAtLeast("4.4")?t.outSpatialReference=a.getOutSR(n.outSpatialReference):t.outSR=a.getOutSR(n.outSpatialReference),r=new f.default(o),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",o,n,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=m.__decorate([r.activate(t.MapProvider)],i);function i(){}e.ProjectServiceTask=t});