/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{convertToSpatialReferenceUnit as e,toLengthUnit as r}from"./unitConversion.js";import{execute as t}from"../../geometry/operators/gx/operatorOffset.js";import{fromGeometry as o,getSpatialReference as n,fromSpatialReference as s,toGeometry as i}from"../../geometry/operators/support/apiConverter.js";import{fromGeometry as m,toGeometry as f}from"../../geometry/operators/support/jsonConverter.js";const p={round:0,bevel:1,miter:2,square:3};function u(t,m,f,p,u,a){m=e(r(f),t.spatialReference,m);const l=o(t),y=n(t),v=c(l,s(y),m,p,u,a);return i(v,y)}function a(t,o,n,s,i,p){o=e(r(n),t.spatialReference,o);const u=m(t),a=u.getGeometry(),l=u.getSpatialReference(),y=c(a,l,o,s,i,p);return f(y,l)}function c(e,r,o,n,s,i){const m=t(e,r,o,p[n],s,i);if(!m.isEmpty())return m;{const m=e.clone();m.reverseAllPaths();const f=t(m,r,-o,p[n],s,i);if(!f.isEmpty())return f.reverseAllPaths(),f}const f=Math.abs(o)/10,u=f/10;let a=i;if("round"===n&&(a+=u),"bevel"===n||"square"===n){const m=t(e,r,o,p[n="miter"],s,i);if(!m.isEmpty())return m}if("miter"===n){const m=t(e,r,o,p[n="round"],s,i);if(!m.isEmpty())return m}if("round"===n)for(;a<=f;a+=u){const i=t(e,r,o,p[n],s,a);if(!i.isEmpty())return i}return null}export{u as executeOffset,a as executeOffsetJson};
