import{__decorate}from"tslib";import{validation}from"../../Validation.js";import{inline,schedulePromiseCancellation,addToPath,fetch}from"./tools.js";import{MapProvider}from"./MapProvider.js";import{activate}from"../../Hooks.js";let Geocode=class{execute(e,t,o){var i=validation.string("url",e.url,validation.never),i=addToPath(i,"findAddressCandidates"),a=validation.number("timeout",e.timeout,void 0),n=validation.number("maxLocations",e.maxLocations,void 0);const r=validation.exists("outFields",e.outFields,"*"),d=validation.exists("searchExtent",e.searchExtent,void 0),s=validation.exists("location",e.location,void 0);var c=validation.number("distance",e.distance,void 0),l=e.address;const v={maxLocations:n,singleLine:"string"==typeof l?l:void 0,outSR:o.getOutSR(e.outSpatialReference),outFields:r instanceof Array?r.toString():r,searchExtent:d instanceof Array?d.toString():d,location:s instanceof Array?s.toString():s,distance:c};if("object"==typeof l&&null!==l)for(const u in l){var f=l[u];"string"==typeof f&&(v[u]=f)}a=fetch(i,v,a,t.cancellationToken.signal);return schedulePromiseCancellation(t,a),inline(a,function(e){var t=e.candidates;return{candidate:t[0],candidates:t,spatialReference:e.spatialReference}})}};Geocode.action="gcx:wf:arcgis::Geocode",Geocode.suite="gcx:wf:builtin",Geocode=__decorate([activate(MapProvider)],Geocode);export{Geocode};