import{__decorate}from"tslib";import ServiceAreaParameters from"@arcgis/core/tasks/support/ServiceAreaParameters";import{validation}from"../../Validation.js";import{inline,isAbortable,schedulePromiseCancellation}from"./tools.js";import{MapProvider}from"./MapProvider.js";import{activate}from"../../Hooks.js";import EsriServiceAreaTask from"@arcgis/core/tasks/ServiceAreaTask";let ServiceAreaTask=class{execute(i,e,r){var t=validation.string("url",i.url,validation.never);const o=new ServiceAreaParameters;o.facilities=validation.exists("facilities",i.facilities),o.accumulateAttributes=validation.array("accumulateAttributes",i.accumulateAttributes),o.attributeParameterValues=validation.exists("attributeParameterValues",i.attributeParameterValues,void 0),o.defaultBreaks=validation.exists("defaultBreaks",i.defaultBreaks,void 0),o.doNotLocateOnRestrictedElements=validation.boolean("doNotLocateOnRestrictedElements",i.doNotLocateOnRestrictedElements,void 0),o.excludeSourcesFromPolygons=validation.exists("excludeSourcesFromPolygons",i.excludeSourcesFromPolygons,void 0),o.impedanceAttribute=validation.string("impedanceAttribute",i.impedanceAttribute,void 0),o.impedanceAttribute||(o.impedanceAttribute=validation.string("impedenceAttribute",i.impedenceAttribute,void 0)),o.mergeSimilarPolygonRanges=validation.boolean("mergeSimilarPolygonRanges",i.mergeSimilarPolygonRanges,void 0),o.outputGeometryPrecision=validation.number("outputGeometryPrecision",i.outputGeometryPrecision,void 0),o.outputGeometryPrecisionUnits=validation.string("outputGeometryPrecisionUnits",i.outputGeometryPrecisionUnits,void 0),o.outputLines=validation.string("outputLines",i.outputLines,void 0),o.outputPolygons=validation.string("outputPolygons",i.outputPolygons,void 0),o.overlapLines=validation.boolean("overlapLines",i.overlapLines,void 0),o.overlapPolygons=validation.boolean("overlapPolygons",i.overlapPolygons,void 0),o.pointBarriers=validation.exists("pointBarriers",i.pointBarriers,void 0),o.polygonBarriers=validation.exists("polygonBarriers",i.polygonBarriers,void 0),o.polylineBarriers=validation.exists("polylineBarriers",i.polylineBarriers,void 0),o.restrictionAttributes=validation.exists("restrictionAttributes",i.restrictionAttributes,void 0),o.restrictUTurns=validation.string("restrictUTurns",i.restrictUTurns,void 0),o.returnFacilities=validation.boolean("returnFacilities",i.returnFacilities,void 0),o.returnPointBarriers=validation.boolean("returnPointBarriers",i.returnPointBarriers,void 0),o.returnPolygonBarriers=validation.boolean("returnPolygonBarriers",i.returnPolygonBarriers,void 0),o.returnPolylineBarriers=validation.boolean("returnPolylineBarriers",i.returnPolylineBarriers,void 0),o.splitLinesAtBreaks=validation.boolean("splitLinesAtBreaks",i.splitLinesAtBreaks,void 0),o.splitPolygonsAtBreaks=validation.boolean("splitPolygonsAtBreaks",i.splitPolygonsAtBreaks,void 0),o.timeOfDay=validation.exists("timeOfDay",i.timeOfDay,void 0),o.travelDirection=validation.string("travelDirection",i.travelDirection,void 0),o.trimOuterPolygon=validation.boolean("trimOuterPolygon",i.trimOuterPolygon,void 0),o.trimPolygonDistance=validation.number("trimPolygonDistance",i.trimPolygonDistance,void 0),o.trimPolygonDistanceUnits=validation.string("trimPolygonDistanceUnits",i.trimPolygonDistanceUnits,void 0),o.useHierarchy=validation.boolean("useHierarchy",i.useHierarchy,void 0);i=validation.exists("outSpatialReference",i.outSpatialReference,void 0);o.outSpatialReference=r.getOutSR(i);const a=new EsriServiceAreaTask(t);t=isAbortable(e.cancellationToken)?{signal:e.cancellationToken.signal}:void 0,t=a.solve(o,t);return schedulePromiseCancellation(e,t),inline(t,function(i){return{facilities:i.facilities,messages:i.messages,pointBarriers:i.pointBarriers,polygonBarriers:i.polygonBarriers,polylineBarriers:i.polylineBarriers,serviceAreaPolygons:i.serviceAreaPolygons,serviceAreaPolylines:i.serviceAreaPolylines}})}};ServiceAreaTask.action="gcx:wf:arcgis::ServiceAreaTask",ServiceAreaTask.suite="gcx:wf:builtin",ServiceAreaTask=__decorate([activate(MapProvider)],ServiceAreaTask);export{ServiceAreaTask};