/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{isSome as e}from"../../../core/arrayUtils.js";import{convertUnit as t}from"../../../core/units.js";import{load as r,execute as o,executeMany as i,isLoaded as s}from"../gx/operatorGeodesicBuffer.js";import{geodeticCurveType as n}from"../support/geodeticCurveType.js";let a,m,c;function u(){return!!a&&s()}async function p(){if(!u()){const[e]=await Promise.all([import("../support/jsonConverter.js"),r()]);a=e.fromGeometries,m=e.fromGeometry,c=e.toGeometry}}function f(e,r,i={}){let{curveType:s="geodesic",maxDeviation:a=NaN,unit:u}=i;u&&(r=t(r,u,"meters"),a&&(a=t(a,u,"meters")));const p=m(e),f=p.getSpatialReference();return c(o(p.getGeometry(),f,n[s],r,a),f)}function l(r,o,s={}){let{curveType:m="geodesic",maxDeviation:u=NaN,union:p=!1,unit:f}=s;f&&(o=o.map(e=>t(e,f,"meters")),u&&(u=t(u,f,"meters")));const[l,y]=a(r);return i(l,y,n[m],o,u,p).map(e=>c(e,y)).filter(e)}export{f as execute,l as executeMany,u as isLoaded,p as load};
