/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","./enums"],(function(t,e){"use strict";const n=.03;let o=function(){function t(){this._path=[]}var e=t.prototype;return e.path=function(){return this._path},e.addPath=function(t,e){e||t.reverse(),Array.prototype.push.apply(this._path,t),e||t.reverse()},t.mergePath=function(t,e){e&&Array.prototype.push.apply(t,e)},e.startPath=function(t){this._path.push(t)},e.lineTo=function(t){this._path.push(t)},e.close=function(){const t=this._path;t.length>1&&(t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]||t.push([t[0][0],t[0][1]]))},t}(),s=function(){function t(t=0,e=!1){}var n=t.prototype;return n.normalize=function(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);0!==e&&(t[0]/=e,t[1]/=e)},n.calculateLength=function(t,e){const n=e[0]-t[0],o=e[1]-t[1];return Math.sqrt(n*n+o*o)},n.calculateSegLength=function(t,e){return this.calculateLength(t[e],t[e+1])},n.calculatePathLength=function(t){let e=0;const n=t?t.length:0;for(let o=0;o<n-1;++o)e+=this.calculateSegLength(t,o);return e},n.calculatePathArea=function(t){let e=0;const n=t?t.length:0;for(let o=0;o<n-1;++o)e+=(t[o+1][0]-t[o][0])*(t[o+1][1]+t[o][1]);return e/2},n.getCoord2D=function(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]},n.getSegCoord2D=function(t,e,n){return this.getCoord2D(t[e],t[e+1],n)},n.getAngle=function(t,e,n){const o=e[0]-t[0],s=e[1]-t[1];return Math.atan2(s,o)},n.getSegAngle=function(t,e,n){return this.getAngle(t[e],t[e+1],n)},n.getAngleCS=function(t,e,n){const o=e[0]-t[0],s=e[1]-t[1],r=Math.sqrt(o*o+s*s);return r>0?[o/r,s/r]:[1,0]},n.getSegAngleCS=function(t,e,n){return this.getAngleCS(t[e],t[e+1],n)},n.cut=function(t,e,n,o){return[n<=0?t[e]:this.getSegCoord2D(t,e,n),o>=1?t[e+1]:this.getSegCoord2D(t,e,o)]},n.addSegment=function(t,e,n){n&&t.push(e[0]),t.push(e[1])},n.getSubCurve=function(t,e,n){const o=[];return this.appendSubCurve(o,t,e,n)?o:null},n.appendSubCurve=function(t,e,n,o){const s=e?e.length-1:0;let r=0,u=!0,i=0;for(;i<s;){const s=this.calculateSegLength(e,i);if(0!==s){if(u){if(r+s>n){const c=(n-r)/s;let h=1,l=!1;r+s>=o&&(h=(o-r)/s,l=!0);const a=this.cut(e,i,c,h);if(a&&this.addSegment(t,a,u),l)break;u=!1}}else{if(r+s>o){const n=this.cut(e,i,0,(o-r)/s);n&&this.addSegment(t,n,u);break}this.addSegment(t,[e[i],e[i+1]],u)}r+=s,++i}else++i}return!0},n.getCIMPointAlong=function(t,e){const n=t?t.length-1:0;let o=0,s=-1;for(;s<n;){++s;const n=this.calculateSegLength(t,s);if(0!==n){if(o+n>e){const r=(e-o)/n;return this.getCoord2D(t[s],t[s+1],r)}o+=n}}return null},n.isEmpty=function(t,e){if(!t||t.length<=1)return!0;const n=t?t.length-1:0;let o=-1;for(;o<n;){if(++o,t[o+1][0]!==t[o][0]||t[o+1][1]!==t[o][1])return!1;if(e&&t[o+1][2]!==t[o][2])return!1}return!0},n.offset=function(t,n,o,s,r){if(!t||t.length<2)return null;let u=0,i=t[u++],c=u;for(;u<t.length;){const e=t[u];e[0]===i[0]&&e[1]===i[1]||(u!==c&&(t[c]=t[u]),i=t[c++]),u++}const h=t[0][0]===t[c-1][0]&&t[0][1]===t[c-1][1];if(h&&--c,c<(h?3:2))return null;const l=[];i=h?t[c-1]:null;let a=t[0];for(let f=0;f<c;f++){const r=f===c-1?h?t[0]:null:t[f+1];if(i)if(r){const t=[r[0]-a[0],r[1]-a[1]];this.normalize(t);const u=[a[0]-i[0],a[1]-i[1]];this.normalize(u);const c=u[0]*t[1]-u[1]*t[0],h=u[0]*t[0]+u[1]*t[1];if(0===c&&1===h){a=r;continue}if(c>=0==n<=0){if(h<1){const e=[t[0]-u[0],t[1]-u[1]];this.normalize(e);const o=Math.sqrt((1+h)/2);if(o>1/s){const t=-Math.abs(n)/o;l.push([a[0]-e[0]*t,a[1]-e[1]*t])}}}else switch(o){case e.GeometricEffectOffsetMethod.Mitered:{const e=Math.sqrt((1+h)/2);if(e>0&&1/e<s){const o=[t[0]-u[0],t[1]-u[1]];this.normalize(o);const s=Math.abs(n)/e;l.push([a[0]-o[0]*s,a[1]-o[1]*s]);break}}case e.GeometricEffectOffsetMethod.Bevelled:l.push([a[0]+u[1]*n,a[1]-u[0]*n]),l.push([a[0]+t[1]*n,a[1]-t[0]*n]);break;case e.GeometricEffectOffsetMethod.Rounded:if(h<1){l.push([a[0]+u[1]*n,a[1]-u[0]*n]);const e=Math.floor(2.5*(1-h));if(e>0){const o=1/e;let s=o;for(let r=1;r<e;r++,s+=o){const e=[u[1]*(1-s)+t[1]*s,-u[0]*(1-s)-t[0]*s];this.normalize(e),l.push([a[0]+e[0]*n,a[1]+e[1]*n])}}l.push([a[0]+t[1]*n,a[1]-t[0]*n])}break;case e.GeometricEffectOffsetMethod.Square:default:if(c<0)l.push([a[0]+(u[1]+u[0])*n,a[1]+(u[1]-u[0])*n]),l.push([a[0]+(t[1]-t[0])*n,a[1]-(t[0]+t[1])*n]);else{const e=Math.sqrt((1+Math.abs(h))/2),o=[t[0]-u[0],t[1]-u[1]];this.normalize(o);const s=n/e;l.push([a[0]-o[0]*s,a[1]-o[1]*s])}}}else{const t=[a[0]-i[0],a[1]-i[1]];this.normalize(t),l.push([a[0]+t[1]*n,a[1]-t[0]*n])}else{const t=[r[0]-a[0],r[1]-a[1]];this.normalize(t),l.push([a[0]+t[1]*n,a[1]-t[0]*n])}i=a,a=r}return l.length<(h?3:2)?null:(h&&l.push([l[0][0],l[0][1]]),l)},t}();t.CurveHelper=s,t.PIXEL_TOLERANCE=n,t.PathHelper=o,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
