/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{GeometryCursor as e}from"../../../geometry/GeometryCursor.js";import{PathEffectCursor as t}from"../CIMCursor.js";import{CurveHelper as i}from"../CurveHelper.js";class r{static{this.instance=null}static local(){return null===r.instance&&(r.instance=new r),r.instance}execute(e,t,i){return new u(e,t,i)}}class u extends t{constructor(e,t,r){super(e,!0,!0),this._curveHelper=new i,this._beginCut=(void 0!==t.beginCut?t.beginCut:1)*r,this._endCut=(void 0!==t.endCut?t.endCut:1)*r,this._middleCut=(void 0!==t.middleCut?t.middleCut:0)*r,this._invert=void 0!==t.invert&&t.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const{_beginCut:i,_endCut:r,_middleCut:u}=this,s=t.pathLength(),n=e.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==i||0!==r||0!==u)if(i+r+u>=s)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else this._curveHelper.appendSubCurve(n,t,0,i),this._curveHelper.appendSubCurve(n,t,.5*(s-u),.5*(s+u)),this._curveHelper.appendSubCurve(n,t,s-r,r)}else if(0===i&&0===r&&0===u)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else i+r+u<s&&(0===u?this._curveHelper.appendSubCurve(n,t,i,s-r):(this._curveHelper.appendSubCurve(n,t,i,.5*(s-u)),this._curveHelper.appendSubCurve(n,t,.5*(s+u),s-r)));return 0===n.totalSize?null:n}}export{r as EffectCut};
