import DistanceParameters from"@arcgis/core/tasks/support/DistanceParameters";import{validation}from"../../Validation.js";import{inline,isAbortable,schedulePromiseCancellation,toEsriUnit}from"./tools.js";import GeometryService from"@arcgis/core/tasks/GeometryService";class DistanceServiceTask{execute(e,i){var t=validation.string("url",e.url,validation.never);const a=new DistanceParameters;a.geometry1=validation.exists("geometry1",e.geometry1),a.geometry2=validation.exists("geometry2",e.geometry2),a.distanceUnit=toEsriUnit(e.unit),a.geodesic=validation.boolean("geodesic",e.geodesic,!1);const r=new GeometryService(t);t=isAbortable(i.cancellationToken)?{signal:i.cancellationToken.signal}:void 0,t=r.distance(a,t);return schedulePromiseCancellation(i,t),inline(t,function(e){return{distance:e}})}}DistanceServiceTask.action="gcx:wf:arcgis::DistanceServiceTask",DistanceServiceTask.suite="gcx:wf:builtin";export{DistanceServiceTask};