import{bl as un,am as I}from"./katex-D8o5-F7C.d_mIDReB.js";const rn=Math.abs,o=Math.atan2,N=Math.cos,cn=Math.max,nn=Math.min,O=Math.sin,$=Math.sqrt,j=Math.PI,G=j/2,sn=2*j;function on(e){return e>1?0:e<-1?j:Math.acos(e)}function en(e){return e>=1?G:e<=-1?-G:Math.asin(e)}function ln(e){return e.innerRadius}function yn(e){return e.outerRadius}function fn(e){return e.startAngle}function gn(e){return e.endAngle}function xn(e){return e&&e.padAngle}function pn(e,m,E,_,d,v,R,r){var P=E-e,c=_-m,n=R-d,g=r-v,a=g*P-n*c;if(!(a*a<1e-12))return a=(n*(m-v)-g*(e-d))/a,[e+a*P,m+a*c]}function Y(e,m,E,_,d,v,R){var r=e-E,P=m-_,c=(R?v:-v)/$(r*r+P*P),n=c*P,g=-c*r,a=e+n,i=m+g,l=E+n,y=_+g,q=(a+l)/2,s=(i+y)/2,x=l-a,f=y-i,T=x*x+f*f,M=d-v,A=a*y-l*i,S=(f<0?-1:1)*$(cn(0,M*M*T-A*A)),C=(A*f-x*S)/T,D=(-A*x-f*S)/T,b=(A*f+x*S)/T,p=(-A*x+f*S)/T,h=C-q,t=D-s,u=b-q,F=p-s;return h*h+t*t>u*u+F*F&&(C=b,D=p),{cx:C,cy:D,x01:-n,y01:-g,x11:C*(d/M-1),y11:D*(d/M-1)}}function mn(){var e=ln,m=yn,E=I(0),_=null,d=fn,v=gn,R=xn,r=null,P=un(c);function c(){var n,g,a=+e.apply(this,arguments),i=+m.apply(this,arguments),l=d.apply(this,arguments)-G,y=v.apply(this,arguments)-G,q=rn(y-l),s=y>l;if(r||(r=n=P()),i<a&&(g=i,i=a,a=g),!(i>1e-12))r.moveTo(0,0);else if(q>sn-1e-12)r.moveTo(i*N(l),i*O(l)),r.arc(0,0,i,l,y,!s),a>1e-12&&(r.moveTo(a*N(y),a*O(y)),r.arc(0,0,a,y,l,s));else{var x=l,f=y,T=l,M=y,A=q,S=q,C=R.apply(this,arguments)/2,D=C>1e-12&&(_?+_.apply(this,arguments):$(a*a+i*i)),b=nn(rn(i-a)/2,+E.apply(this,arguments)),p=b,h=b,t,u;if(D>1e-12){var F=en(D/a*O(C)),k=en(D/i*O(C));(A-=F*2)>1e-12?(F*=s?1:-1,T+=F,M-=F):(A=0,T=M=(l+y)/2),(S-=k*2)>1e-12?(k*=s?1:-1,x+=k,f-=k):(S=0,x=f=(l+y)/2)}var X=i*N(x),Z=i*O(x),H=a*N(M),J=a*O(M);if(b>1e-12){var K=i*N(f),U=i*O(f),W=a*N(T),L=a*O(T),w;if(q<j)if(w=pn(X,Z,W,L,K,U,H,J)){var z=X-w[0],Q=Z-w[1],V=K-w[0],B=U-w[1],tn=1/O(on((z*V+Q*B)/($(z*z+Q*Q)*$(V*V+B*B)))/2),an=$(w[0]*w[0]+w[1]*w[1]);p=nn(b,(a-an)/(tn-1)),h=nn(b,(i-an)/(tn+1))}else p=h=0}S>1e-12?h>1e-12?(t=Y(W,L,X,Z,i,h,s),u=Y(K,U,H,J,i,h,s),r.moveTo(t.cx+t.x01,t.cy+t.y01),h<b?r.arc(t.cx,t.cy,h,o(t.y01,t.x01),o(u.y01,u.x01),!s):(r.arc(t.cx,t.cy,h,o(t.y01,t.x01),o(t.y11,t.x11),!s),r.arc(0,0,i,o(t.cy+t.y11,t.cx+t.x11),o(u.cy+u.y11,u.cx+u.x11),!s),r.arc(u.cx,u.cy,h,o(u.y11,u.x11),o(u.y01,u.x01),!s))):(r.moveTo(X,Z),r.arc(0,0,i,x,f,!s)):r.moveTo(X,Z),!(a>1e-12)||!(A>1e-12)?r.lineTo(H,J):p>1e-12?(t=Y(H,J,K,U,a,-p,s),u=Y(X,Z,W,L,a,-p,s),r.lineTo(t.cx+t.x01,t.cy+t.y01),p<b?r.arc(t.cx,t.cy,p,o(t.y01,t.x01),o(u.y01,u.x01),!s):(r.arc(t.cx,t.cy,p,o(t.y01,t.x01),o(t.y11,t.x11),!s),r.arc(0,0,a,o(t.cy+t.y11,t.cx+t.x11),o(u.cy+u.y11,u.cx+u.x11),s),r.arc(u.cx,u.cy,p,o(u.y11,u.x11),o(u.y01,u.x01),!s))):r.arc(0,0,a,M,T,s)}if(r.closePath(),n)return r=null,n+""||null}return c.centroid=function(){var n=(+e.apply(this,arguments)+ +m.apply(this,arguments))/2,g=(+d.apply(this,arguments)+ +v.apply(this,arguments))/2-j/2;return[N(g)*n,O(g)*n]},c.innerRadius=function(n){return arguments.length?(e=typeof n=="function"?n:I(+n),c):e},c.outerRadius=function(n){return arguments.length?(m=typeof n=="function"?n:I(+n),c):m},c.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:I(+n),c):E},c.padRadius=function(n){return arguments.length?(_=n==null?null:typeof n=="function"?n:I(+n),c):_},c.startAngle=function(n){return arguments.length?(d=typeof n=="function"?n:I(+n),c):d},c.endAngle=function(n){return arguments.length?(v=typeof n=="function"?n:I(+n),c):v},c.padAngle=function(n){return arguments.length?(R=typeof n=="function"?n:I(+n),c):R},c.context=function(n){return arguments.length?(r=n??null,c):r},c}export{mn as a,sn as t};
