/*
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(e,t,n,i,s){"use strict";const l=.001;let o=function(){function e(){}return e.local=function(){return null===e.instance&&(e.instance=new e),e.instance},e.prototype.execute=function(e,t,n,i){return new r(e,t,n)},e}();o.instance=null;let r=function(e){function o(t,n,s){var o;return(o=e.call(this,t,!0,!0)||this)._curveHelper=new i.CurveHelper,o._angleToLine=void 0===n.angleToLine||n.angleToLine,o._offset=void 0!==n.offset?n.offset*s:0,o._relativeTo=n.relativeTo,o._position=void 0!==n.startPointOffset?n.startPointOffset*s:0,o._epsilon=l*s,o}t._inheritsLoose(o,e);var r=o.prototype;return r.processPath=function(e){const t=this._position;if(this._relativeTo===s.PlacementOnLineRelativeTo.SegmentMidpoint){for(this.iteratePath||(this._segmentCount=e.length,this._curSegment=1,this.iteratePath=!0);this._curSegment<this._segmentCount;){const t=this._curSegment;this._curSegment++;const i=e[t-1],s=e[t],l=this._curveHelper.calculateLength(i,s);if(l<this._epsilon)continue;const o=.5+this._position/l,[r,a]=this._curveHelper.getAngleCS(i,s,o),c=n.getCoord2D(i,s,o);return this.internalPlacement.setTranslate(c[0]-this._offset*a,c[1]+this._offset*r),this._angleToLine&&this.internalPlacement.setRotateCS(r,a),this.internalPlacement}return this.iteratePath=!1,null}this._relativeTo===s.PlacementOnLineRelativeTo.LineEnd&&n.reversePath(e);const i=this.onLine(e,t);return this._relativeTo===s.PlacementOnLineRelativeTo.LineEnd&&n.reversePath(e),i},r.onLine=function(e,t){let i,l=!1;switch(this._relativeTo){case s.PlacementOnLineRelativeTo.LineMiddle:default:i=this._curveHelper.calculatePathLength(e)/2+t;break;case s.PlacementOnLineRelativeTo.LineBeginning:i=t;break;case s.PlacementOnLineRelativeTo.LineEnd:i=t,l=!0}const o=e.length;let r,a=0,c=e[0];for(let s=1;s<o;++s){r=c,c=e[s];const t=this._curveHelper.calculateLength(r,c);if(a+t>i){const e=(i-a)/t,[s,o]=this._curveHelper.getAngleCS(r,c,e),u=n.getCoord2D(r,c,e),h=l?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-h*o,u[1]+h*s),this._angleToLine&&(l?this.internalPlacement.setRotateCS(-s,-o):this.internalPlacement.setRotateCS(s,o)),this.internalPlacement}a+=t}return null},o}(n.PathTransformationCursor);e.PlacementOnLine=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
