/* esm.sh - d3-chord@3.0.1 */
var I=Math.abs,x=Math.cos,T=Math.sin,k=Math.PI,C=k/2,q=k*2,R=Math.max,P=1e-12;function D(a,b){return Array.from({length:b-a},(p,d)=>a+d)}function V(a){return function(b,p){return a(b.source.value+b.target.value,p.source.value+p.target.value)}}function z(){return G(!1,!1)}function B(){return G(!1,!0)}function H(){return G(!0,!1)}function G(a,b){var p=0,d=null,A=null,v=null;function i(u){var n=u.length,l=new Array(n),r=D(0,n),g=new Array(n*n),w=new Array(n),f=0,y;u=Float64Array.from({length:n*n},b?(s,e)=>u[e%n][e/n|0]:(s,e)=>u[e/n|0][e%n]);for(let s=0;s<n;++s){let e=0;for(let c=0;c<n;++c)e+=u[s*n+c]+a*u[c*n+s];f+=l[s]=e}f=R(0,q-p*n)/f,y=f?p:q/n;{let s=0;d&&r.sort((e,c)=>d(l[e],l[c]));for(let e of r){let c=s;if(a){let h=D(~n+1,n).filter(t=>t<0?u[~t*n+e]:u[e*n+t]);A&&h.sort((t,o)=>A(t<0?-u[~t*n+e]:u[e*n+t],o<0?-u[~o*n+e]:u[e*n+o]));for(let t of h)if(t<0){let o=g[~t*n+e]||(g[~t*n+e]={source:null,target:null});o.target={index:e,startAngle:s,endAngle:s+=u[~t*n+e]*f,value:u[~t*n+e]}}else{let o=g[e*n+t]||(g[e*n+t]={source:null,target:null});o.source={index:e,startAngle:s,endAngle:s+=u[e*n+t]*f,value:u[e*n+t]}}w[e]={index:e,startAngle:c,endAngle:s,value:l[e]}}else{let h=D(0,n).filter(t=>u[e*n+t]||u[t*n+e]);A&&h.sort((t,o)=>A(u[e*n+t],u[e*n+o]));for(let t of h){let o;if(e<t?(o=g[e*n+t]||(g[e*n+t]={source:null,target:null}),o.source={index:e,startAngle:s,endAngle:s+=u[e*n+t]*f,value:u[e*n+t]}):(o=g[t*n+e]||(g[t*n+e]={source:null,target:null}),o.target={index:e,startAngle:s,endAngle:s+=u[e*n+t]*f,value:u[e*n+t]},e===t&&(o.source=o.target)),o.source&&o.target&&o.source.value<o.target.value){let S=o.source;o.source=o.target,o.target=S}}w[e]={index:e,startAngle:c,endAngle:s,value:l[e]}}s+=y}}return g=Object.values(g),g.groups=w,v?g.sort(v):g}return i.padAngle=function(u){return arguments.length?(p=R(0,u),i):p},i.sortGroups=function(u){return arguments.length?(d=u,i):d},i.sortSubgroups=function(u){return arguments.length?(A=u,i):A},i.sortChords=function(u){return arguments.length?(u==null?v=null:(v=V(u))._=u,i):v&&v._},i}import{path as J}from"../../d3-path@^3.1.0?target=es2022";var E=Array.prototype.slice;function m(a){return function(){return a}}function K(a){return a.source}function L(a){return a.target}function F(a){return a.radius}function N(a){return a.startAngle}function Q(a){return a.endAngle}function U(){return 0}function W(){return 10}function O(a){var b=K,p=L,d=F,A=F,v=N,i=Q,u=U,n=null;function l(){var r,g=b.apply(this,arguments),w=p.apply(this,arguments),f=u.apply(this,arguments)/2,y=E.call(arguments),s=+d.apply(this,(y[0]=g,y)),e=v.apply(this,y)-C,c=i.apply(this,y)-C,h=+A.apply(this,(y[0]=w,y)),t=v.apply(this,y)-C,o=i.apply(this,y)-C;if(n||(n=r=J()),f>P&&(I(c-e)>f*2+P?c>e?(e+=f,c-=f):(e-=f,c+=f):e=c=(e+c)/2,I(o-t)>f*2+P?o>t?(t+=f,o-=f):(t-=f,o+=f):t=o=(t+o)/2),n.moveTo(s*x(e),s*T(e)),n.arc(0,0,s,e,c),e!==t||c!==o)if(a){var S=+a.apply(this,arguments),M=h-S,j=(t+o)/2;n.quadraticCurveTo(0,0,M*x(t),M*T(t)),n.lineTo(h*x(j),h*T(j)),n.lineTo(M*x(o),M*T(o))}else n.quadraticCurveTo(0,0,h*x(t),h*T(t)),n.arc(0,0,h,t,o);if(n.quadraticCurveTo(0,0,s*x(e),s*T(e)),n.closePath(),r)return n=null,r+""||null}return a&&(l.headRadius=function(r){return arguments.length?(a=typeof r=="function"?r:m(+r),l):a}),l.radius=function(r){return arguments.length?(d=A=typeof r=="function"?r:m(+r),l):d},l.sourceRadius=function(r){return arguments.length?(d=typeof r=="function"?r:m(+r),l):d},l.targetRadius=function(r){return arguments.length?(A=typeof r=="function"?r:m(+r),l):A},l.startAngle=function(r){return arguments.length?(v=typeof r=="function"?r:m(+r),l):v},l.endAngle=function(r){return arguments.length?(i=typeof r=="function"?r:m(+r),l):i},l.padAngle=function(r){return arguments.length?(u=typeof r=="function"?r:m(+r),l):u},l.source=function(r){return arguments.length?(b=r,l):b},l.target=function(r){return arguments.length?(p=r,l):p},l.context=function(r){return arguments.length?(n=r??null,l):n},l}function X(){return O()}function Y(){return O(W)}export{z as chord,H as chordDirected,B as chordTranspose,X as ribbon,Y as ribbonArrow};
//# sourceMappingURL=d3-chord.mjs.map