/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{floatEqualRelative as t}from"../../../core/mathUtils.js";import{exactEquals as a}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{DerivedCircle as r,interpolateCircle as n}from"./circleUtils.js";import{angularRangeOriented as o,wrapAtan2 as s}from"./mathUtils.js";function c(a,n){const[c,i,e,h]=n.a,[m,l]=a,[f,u]=c,[M,p]=i,j=m-M,x=l-p,b=Math.sqrt(j*j+x*x),d=f-M,I=u-p,U=Math.sqrt(d*d+I*I),q=0===b||0===U||!t(b,U),v=b,[y,E]=o(s(l-p,m-M),Math.atan2(u-p,f-M),e,h);return new r(M,p,v,y,E,q)}function i(t,a,r){const{cx:o,cy:s,thetaStart:c,thetaEnd:i}=t,[e,h,m,l]=a.a,f=c*(1-r)+i*r;return[{a:[n(t,r),[o,s],Math.abs(f-c)<Math.PI?1:0,l]},{a:[[...e],[o,s],Math.abs(i-f)<Math.PI?1:0,l]}]}function e(t,r){const[n,o]=r.a[0],{cx:s,cy:i,isInvalid:e,thetaEnd:h,thetaStart:m}=c(t,r);if(e){const[r,s]=t;return a([n,o],[r,s])?null:[n-r,o-s]}const l=n-s,f=o-i;return h>m?[-f,l]:[f,-l]}export{e as calculateEllipticArc4Tangent,c as deriveCircleFromEllipticArc4,i as splitEllipticArc4};
