import RelationParameters from"@arcgis/core/tasks/support/RelationParameters";import{validation}from"../../Validation.js";import{inline,isAbortable,schedulePromiseCancellation}from"./tools.js";import GeometryService from"@arcgis/core/tasks/GeometryService";class RelationServiceTask{execute(e,i){var t=validation.exists("url",e.url,validation.never);const r=new RelationParameters,n=r.geometries1=validation.array("geometry1",e.geometry1,validation.never),o=r.geometries2=validation.array("geometry2",e.geometry2,validation.never),a=validation.string("relation",e.relation,"intersection");a.match(/^[TF012\*]{9}$/)?(r.relation="esriGeometryRelationRelation",r.relationParam='RELATE(G1,G2,"'+a+'")'):r.relation=this.getEsriGeometryRelation(a);const s=new GeometryService(t);t=isAbortable(i.cancellationToken)?{signal:i.cancellationToken.signal}:void 0,t=s.relation(r,t);return schedulePromiseCancellation(i,t),inline(t,function(e){e=e.map(function(e){return[n[e.geometry1Index],o[e.geometry2Index]]});return{incident:e[0],incidents:e}})}getEsriGeometryRelation(e){switch(e){case"cross":return"esriGeometryRelationCross";case"disjoint":return"esriGeometryRelationDisjoint";case"in":return"esriGeometryRelationIn";case"interior-intersection":return"esriGeometryRelationInteriorIntersection";case"intersection":return"esriGeometryRelationIntersection";case"line-coincidence":return"esriGeometryRelationLineCoincidence";case"line-touch":return"esriGeometryRelationLineTouch";case"overlap":return"esriGeometryRelationOverlap";case"point-touch":return"esriGeometryRelationPointTouch";case"touch":return"esriGeometryRelationTouch";case"within":return"esriGeometryRelationWithin";default:return e}}}RelationServiceTask.action="gcx:wf:arcgis::RelationServiceTask",RelationServiceTask.suite="gcx:wf:builtin";export{RelationServiceTask};