/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../CIMCursor","../CurveHelper","../enums"],(function(t,e,r,n,o){"use strict";const s=1.7320508075688772,i=5,c=o.GeometricEffectArrowType.OpenEnded;let l=function(){function t(){}return t.local=function(){return null===t.instance&&(t.instance=new t),t.instance},t.prototype.execute=function(t,e,r,n){return new u(t,e,r)},t}();l.instance=null;let u=function(t){function l(e,r,o){var s;return(s=t.call(this,e,!1,!0)||this)._curveHelper=new n.CurveHelper,s._width=(void 0!==r.width?r.width:i)*o,s._arrowType=void 0!==r.geometricEffectArrowType?r.geometricEffectArrowType:void 0!==r.arrowType?r.arrowType:c,s._offsetFlattenError=n.PIXEL_TOLERANCE*o,s}e._inheritsLoose(l,t);var u=l.prototype;return u.processPath=function(t){switch(this._arrowType){case o.GeometricEffectArrowType.OpenEnded:default:return this._constructSimpleArrow(t,!0);case o.GeometricEffectArrowType.Block:return this._constructSimpleArrow(t,!1);case o.GeometricEffectArrowType.Crossed:return this._constructCrossedArrow(t)}},u._constructSimpleArrow=function(t,e){const r=this._curveHelper.calculatePathLength(t);let o=this._width;r<2*o&&(o=r/2);const s=this._curveHelper.getSubCurve(t,0,r-o);if(!s)return null;const i=o/2;if(this._curveHelper.isEmpty(s,!1))return null;const c=this._constructOffset(s,-i);if(!c)return null;const l=this._constructOffset(s,i);if(!l)return null;const u=this._constructArrowBasePoint(c,-i/2);if(!u)return null;const h=this._constructArrowBasePoint(l,i/2);if(!h)return null;const a=t[t.length-1];e||(this._makeControlPoint(l,!0),this._makeControlPoint(c,!0));const f=new n.PathHelper;return f.addPath(l,!0),f.lineTo(h),this._makeControlPoint(f.path()),f.lineTo(a),this._makeControlPoint(f.path()),f.lineTo(u),this._makeControlPoint(f.path()),f.addPath(c,!1),e?{paths:[f.path()]}:(f.close(),{rings:[f.path()]})},u._constructCrossedArrow=function(t){const e=this._curveHelper.calculatePathLength(t);let r=this._width;e<r*(1+s+1)&&(r=e/(1+s+1));const o=this._curveHelper.getSubCurve(t,0,e-r*(1+s));if(!o)return null;const i=r/2;if(this._curveHelper.isEmpty(o,!1))return null;const c=this._constructOffset(o,i);if(!c)return null;const l=this._constructOffset(o,-i);if(!l)return null;const u=this._curveHelper.getSubCurve(t,0,e-r);if(!u)return null;if(this._curveHelper.isEmpty(u,!1))return null;const h=this._constructOffset(u,i);if(!h)return null;const a=this._constructOffset(u,-i);if(!a)return null;const f=h[h.length-1],p=this._constructArrowBasePoint(h,i/2);if(!p)return null;const _=a[a.length-1],d=this._constructArrowBasePoint(a,-i/2);if(!d)return null;const w=t[t.length-1];this._makeControlPoint(c,!1),this._makeControlPoint(l,!1);const P=new n.PathHelper;return P.addPath(c,!0),this._makeControlPoint(P.path()),P.lineTo(_),P.lineTo(d),this._makeControlPoint(P.path()),P.lineTo(w),this._makeControlPoint(P.path()),P.lineTo(p),this._makeControlPoint(P.path()),P.lineTo(f),this._makeControlPoint(P.path()),P.addPath(l,!1),{paths:[P.path()]}},u._constructOffset=function(t,e){return this._curveHelper.offset(t,e,o.GeometricEffectOffsetMethod.Rounded,4,this._offsetFlattenError)},u._constructArrowBasePoint=function(t,e){if(!t||t.length<2)return null;const r=t[t.length-2],n=t[t.length-1],o=[n[0]-r[0],n[1]-r[1]];return this._curveHelper.normalize(o),[n[0]+o[1]*e,n[1]-o[0]*e]},u._makeControlPoint=function(t,e=!1){e?r.setId(t[0],1):r.setId(t[t.length-1],1)},l}(r.PathGeometryCursor);t.EffectArrow=l,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
