"use strict";const n=require("./index-9IAMar3z.cjs");function $(o){return o.innerRadius}function b(o){return o.outerRadius}function k(o){return o.startAngle}function _(o){return o.endAngle}function nn(o){return o&&o.padAngle}function en(o,x,D,P,h,v,j,i){var E=D-o,t=P-x,e=j-h,y=i-v,s=y*E-e*t;if(!(s*s<n.epsilon))return s=(e*(x-v)-y*(o-h))/s,[o+s*E,x+s*t]}function M(o,x,D,P,h,v,j){var i=o-D,E=x-P,t=(j?v:-v)/n.sqrt(i*i+E*E),e=t*E,y=-t*i,s=o+e,u=x+y,c=D+e,f=P+y,z=(s+c)/2,l=(u+f)/2,g=c-s,p=f-u,A=g*g+p*p,R=h-v,T=s*f-c*u,I=(p<0?-1:1)*n.sqrt(n.max(0,R*R*A-T*T)),O=(T*p-g*I)/A,S=(-T*g-p*I)/A,q=(T*p+g*I)/A,d=(-T*g+p*I)/A,m=O-z,a=S-l,r=q-z,B=d-l;return m*m+a*a>r*r+B*B&&(O=q,S=d),{cx:O,cy:S,x01:-e,y01:-y,x11:O*(h/R-1),y11:S*(h/R-1)}}function an(){var o=$,x=b,D=n.constant(0),P=null,h=k,v=_,j=nn,i=null,E=n.withPath(t);function t(){var e,y,s=+o.apply(this,arguments),u=+x.apply(this,arguments),c=h.apply(this,arguments)-n.halfPi,f=v.apply(this,arguments)-n.halfPi,z=n.abs(f-c),l=f>c;if(i||(i=e=E()),u<s&&(y=u,u=s,s=y),!(u>n.epsilon))i.moveTo(0,0);else if(z>n.tau-n.epsilon)i.moveTo(u*n.cos(c),u*n.sin(c)),i.arc(0,0,u,c,f,!l),s>n.epsilon&&(i.moveTo(s*n.cos(f),s*n.sin(f)),i.arc(0,0,s,f,c,l));else{var g=c,p=f,A=c,R=f,T=z,I=z,O=j.apply(this,arguments)/2,S=O>n.epsilon&&(P?+P.apply(this,arguments):n.sqrt(s*s+u*u)),q=n.min(n.abs(u-s)/2,+D.apply(this,arguments)),d=q,m=q,a,r;if(S>n.epsilon){var B=n.asin(S/s*n.sin(O)),G=n.asin(S/u*n.sin(O));(T-=B*2)>n.epsilon?(B*=l?1:-1,A+=B,R-=B):(T=0,A=R=(c+f)/2),(I-=G*2)>n.epsilon?(G*=l?1:-1,g+=G,p-=G):(I=0,g=p=(c+f)/2)}var C=u*n.cos(g),F=u*n.sin(g),H=s*n.cos(R),J=s*n.sin(R);if(q>n.epsilon){var K=u*n.cos(p),L=u*n.sin(p),N=s*n.cos(A),Q=s*n.sin(A),w;if(z<n.pi)if(w=en(C,F,N,Q,K,L,H,J)){var U=C-w[0],V=F-w[1],W=K-w[0],X=L-w[1],Y=1/n.sin(n.acos((U*W+V*X)/(n.sqrt(U*U+V*V)*n.sqrt(W*W+X*X)))/2),Z=n.sqrt(w[0]*w[0]+w[1]*w[1]);d=n.min(q,(s-Z)/(Y-1)),m=n.min(q,(u-Z)/(Y+1))}else d=m=0}I>n.epsilon?m>n.epsilon?(a=M(N,Q,C,F,u,m,l),r=M(K,L,H,J,u,m,l),i.moveTo(a.cx+a.x01,a.cy+a.y01),m<q?i.arc(a.cx,a.cy,m,n.atan2(a.y01,a.x01),n.atan2(r.y01,r.x01),!l):(i.arc(a.cx,a.cy,m,n.atan2(a.y01,a.x01),n.atan2(a.y11,a.x11),!l),i.arc(0,0,u,n.atan2(a.cy+a.y11,a.cx+a.x11),n.atan2(r.cy+r.y11,r.cx+r.x11),!l),i.arc(r.cx,r.cy,m,n.atan2(r.y11,r.x11),n.atan2(r.y01,r.x01),!l))):(i.moveTo(C,F),i.arc(0,0,u,g,p,!l)):i.moveTo(C,F),!(s>n.epsilon)||!(T>n.epsilon)?i.lineTo(H,J):d>n.epsilon?(a=M(H,J,K,L,s,-d,l),r=M(C,F,N,Q,s,-d,l),i.lineTo(a.cx+a.x01,a.cy+a.y01),d<q?i.arc(a.cx,a.cy,d,n.atan2(a.y01,a.x01),n.atan2(r.y01,r.x01),!l):(i.arc(a.cx,a.cy,d,n.atan2(a.y01,a.x01),n.atan2(a.y11,a.x11),!l),i.arc(0,0,s,n.atan2(a.cy+a.y11,a.cx+a.x11),n.atan2(r.cy+r.y11,r.cx+r.x11),l),i.arc(r.cx,r.cy,d,n.atan2(r.y11,r.x11),n.atan2(r.y01,r.x01),!l))):i.arc(0,0,s,R,A,l)}if(i.closePath(),e)return i=null,e+""||null}return t.centroid=function(){var e=(+o.apply(this,arguments)+ +x.apply(this,arguments))/2,y=(+h.apply(this,arguments)+ +v.apply(this,arguments))/2-n.pi/2;return[n.cos(y)*e,n.sin(y)*e]},t.innerRadius=function(e){return arguments.length?(o=typeof e=="function"?e:n.constant(+e),t):o},t.outerRadius=function(e){return arguments.length?(x=typeof e=="function"?e:n.constant(+e),t):x},t.cornerRadius=function(e){return arguments.length?(D=typeof e=="function"?e:n.constant(+e),t):D},t.padRadius=function(e){return arguments.length?(P=e==null?null:typeof e=="function"?e:n.constant(+e),t):P},t.startAngle=function(e){return arguments.length?(h=typeof e=="function"?e:n.constant(+e),t):h},t.endAngle=function(e){return arguments.length?(v=typeof e=="function"?e:n.constant(+e),t):v},t.padAngle=function(e){return arguments.length?(j=typeof e=="function"?e:n.constant(+e),t):j},t.context=function(e){return arguments.length?(i=e??null,t):i},t}exports.d3arc=an;
