import{__decorate}from"tslib";import BufferParameters from"@arcgis/core/tasks/support/BufferParameters";import{validation}from"../../Validation.js";import{inline,isAbortable,schedulePromiseCancellation,toEsriUnit}from"./tools.js";import{MapProvider}from"./MapProvider.js";import{activate}from"../../Hooks.js";import GeometryService from"@arcgis/core/tasks/GeometryService";let BufferServiceTask=class{execute(e,r,i){var a=validation.string("url",e.url,validation.never);const t=new BufferParameters;t.bufferSpatialReference=i.getOutSR(e.bufferSpatialReference),t.outSpatialReference=i.getOutSR(e.outSpatialReference),t.geometries=validation.array("geometry",e.geometry,[]),t.distances=validation.array("distance",e.distance,[]),t.geodesic=validation.boolean("geodesic",e.geodesic,!1),t.unit=toEsriUnit(e.unit),t.unionResults=validation.boolean("union",e.union,!1);const o=new GeometryService(a);a=isAbortable(r.cancellationToken)?{signal:r.cancellationToken.signal}:void 0,a=o.buffer(t,a);return schedulePromiseCancellation(r,a),inline(a,function(e){e=Array.isArray(e)?e:[e];return{geometry:e[0],results:e}})}};BufferServiceTask.action="gcx:wf:arcgis::BufferServiceTask",BufferServiceTask.suite="gcx:wf:builtin",BufferServiceTask=__decorate([activate(MapProvider)],BufferServiceTask);export{BufferServiceTask};