Files
mermaid-live-editor/_app/immutable/chunks/arc.24267adf.js
T
2023-09-14 20:12:03 +00:00

2 lines
3.4 KiB
JavaScript

import{w as ln,c as z}from"./path.53f90ab3.js";import{b2 as an,b3 as G,b4 as w,b5 as rn,b6 as y,am as on,b7 as K,b8 as _,b9 as un,ba as t,bb as sn,bc as tn,bd as fn}from"./state.184cb521.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function dn(l,h,E,q,v,A,B,a){var I=E-l,i=q-h,n=B-v,m=a-A,r=m*I-n*i;if(!(r*r<y))return r=(n*(h-A)-m*(l-v))/r,[l+r*I,h+r*i]}function V(l,h,E,q,v,A,B){var a=l-E,I=h-q,i=(B?A:-A)/K(a*a+I*I),n=i*I,m=-i*a,r=l+n,s=h+m,f=E+n,c=q+m,C=(r+f)/2,o=(s+c)/2,p=f-r,g=c-s,R=p*p+g*g,b=v-A,T=r*c-f*s,O=(g<0?-1:1)*K(fn(0,b*b*R-T*T)),S=(T*g-p*O)/R,j=(-T*p-g*O)/R,P=(T*g+p*O)/R,d=(-T*p+g*O)/R,x=S-C,e=j-o,u=P-C,F=d-o;return x*x+e*e>u*u+F*F&&(S=P,j=d),{cx:S,cy:j,x01:-n,y01:-m,x11:S*(v/b-1),y11:j*(v/b-1)}}function vn(){var l=cn,h=yn,E=z(0),q=null,v=gn,A=mn,B=pn,a=null,I=ln(i);function i(){var n,m,r=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-rn,c=A.apply(this,arguments)-rn,C=un(c-f),o=c>f;if(a||(a=n=I()),s<r&&(m=s,s=r,r=m),!(s>y))a.moveTo(0,0);else if(C>on-y)a.moveTo(s*G(f),s*w(f)),a.arc(0,0,s,f,c,!o),r>y&&(a.moveTo(r*G(c),r*w(c)),a.arc(0,0,r,c,f,o));else{var p=f,g=c,R=f,b=c,T=C,O=C,S=B.apply(this,arguments)/2,j=S>y&&(q?+q.apply(this,arguments):K(r*r+s*s)),P=_(un(s-r)/2,+E.apply(this,arguments)),d=P,x=P,e,u;if(j>y){var F=sn(j/r*w(S)),L=sn(j/s*w(S));(T-=F*2)>y?(F*=o?1:-1,R+=F,b-=F):(T=0,R=b=(f+c)/2),(O-=L*2)>y?(L*=o?1:-1,p+=L,g-=L):(O=0,p=g=(f+c)/2)}var H=s*G(p),J=s*w(p),M=r*G(b),N=r*w(b);if(P>y){var Q=s*G(g),U=s*w(g),W=r*G(R),X=r*w(R),D;if(C<an)if(D=dn(H,J,W,X,Q,U,M,N)){var Y=H-D[0],Z=J-D[1],$=Q-D[0],k=U-D[1],nn=1/w(tn((Y*$+Z*k)/(K(Y*Y+Z*Z)*K($*$+k*k)))/2),en=K(D[0]*D[0]+D[1]*D[1]);d=_(P,(r-en)/(nn-1)),x=_(P,(s-en)/(nn+1))}else d=x=0}O>y?x>y?(e=V(W,X,H,J,s,x,o),u=V(Q,U,M,N,s,x,o),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<P?a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,s,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),!o),a.arc(u.cx,u.cy,x,t(u.y11,u.x11),t(u.y01,u.x01),!o))):(a.moveTo(H,J),a.arc(0,0,s,p,g,!o)):a.moveTo(H,J),!(r>y)||!(T>y)?a.lineTo(M,N):d>y?(e=V(M,N,Q,U,r,-d,o),u=V(H,J,W,X,r,-d,o),a.lineTo(e.cx+e.x01,e.cy+e.y01),d<P?a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,r,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),o),a.arc(u.cx,u.cy,d,t(u.y11,u.x11),t(u.y01,u.x01),!o))):a.arc(0,0,r,b,R,o)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[G(m)*n,w(m)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:z(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:z(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:z(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:z(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:z(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:z(+n),i):A},i.padAngle=function(n){return arguments.length?(B=typeof n=="function"?n:z(+n),i):B},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{vn as a};