/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../geometry/support/jsonUtils","../CurveHelper","../enums"],(function(e,t,i,s){"use strict";let n=function(){function e(){}return e.local=function(){return null===e.instance&&(e.instance=new e),e.instance},e.prototype.execute=function(e,t,i,s){return new r(e,t,i,s)},e}();n.instance=null;let r=function(){function e(e,t,s,n){this._inputGeometries=e,this._curveHelper=new i.CurveHelper,this._size=(void 0!==t.size?t.size:1)*s,this._offsetFlattenError=i.PIXEL_TOLERANCE*s}return e.prototype.next=function(){let e=this._inputGeometries.next();for(;e;){if(t.isExtent(e))if(this._size>0){const t=[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]],i=this._curveHelper.offset(t,this._size,s.GeometricEffectOffsetMethod.Rounded,4,this._offsetFlattenError);if(i)return{rings:[i]}}else{if(!(this._size<0))return e;if(Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._size>0)return{xmin:e.xmin-this._size,xmax:e.xmax+this._size,ymin:e.ymin-this._size,ymax:e.ymax+this._size}}if(t.isPolygon(e)){if(0===this._size)return e;const t=[];for(const i of e.rings){const e=this._curveHelper.offset(i,this._size,s.GeometricEffectOffsetMethod.Rounded,4,this._offsetFlattenError);e&&t.push(e)}if(t.length)return{rings:t}}if(t.isPolyline(e)&&this._size>0){const t=[];for(const i of e.paths)if(i&&i.length>1){const e=this._curveHelper.offset(i,this._size,s.GeometricEffectOffsetMethod.Rounded,4,this._offsetFlattenError),n=this._curveHelper.offset(i,-this._size,s.GeometricEffectOffsetMethod.Rounded,4,this._offsetFlattenError);if(e&&n){for(let t=n.length-1;t>=0;t--)e.push(n[t]);e.push([e[0][0],e[0][1]]),t.push(e)}}if(t.length)return{rings:t}}t.isPoint(e)&&this._size,e=this._inputGeometries.next()}return null},e}();e.EffectBuffer=n,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
