semiotic 3.0.0-beta.4 → 3.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),a=require("d3-force"),o=require("d3-scale"),i=require("d3-chord"),c=require("d3-shape"),s=require("d3-hierarchy");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=l(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var a;for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const c=r[i.edgeIndex];if(!c||!c.bezier){i.active=!1;continue}const s=n&&null!==(a=n[i.edgeIndex])&&void 0!==a?a:1;if(i.t+=e*t*s*(c.bezier.circular?.3:1),i.t>=1){i.active=!1;continue}const l=y(c.bezier,i.t,i.offset);i.x=l.x,i.y=l.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function y(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const a=e.length,o=t*a,i=Math.min(Math.floor(o),a-1),c=o-i,[s,l,u,d]=e[i],h=g(s,l,u,d,c),f=d.x-s.x,y=d.y-s.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;h.x+=-y/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,a,o,i]=e.points,c=g(n,a,o,i,t),s=i.x-n.x,l=i.y-n.y,u=Math.sqrt(s*s+l*l);if(u>.001){const t=s/u;c.x+=-l/u*r*e.halfWidth*2,c.y+=t*r*e.halfWidth*2}return c}function g(e,t,r,n,a){const o=1-a,i=o*o,c=i*o,s=a*a,l=s*a;return{x:c*e.x+3*i*a*t.x+3*o*s*r.x+l*n.x,y:c*e.y+3*i*a*t.y+3*o*s*r.y+l*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],a=[],o=[],i={},c=[];function s(e){o[e]=!1,i.hasOwnProperty(e)&&Object.keys(i[e]).forEach(function(t){delete i[e][t],o[t]&&s(t)})}function l(e){var t,n,d=!1;for(a.push(e),o[e]=!0,t=0;c[e].length>t;t++)(n=c[e][t])===r?(u(r,a),d=!0):o[n]||(d=l(n));if(d)s(e);else for(t=0;c[e].length>t;t++){var h=i[n=c[e][t]];h||(i[n]=h={}),h[n]=!0}return a.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),a=Array(t),o=Array(t),i=Array(t),c=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,a[s]=!1,o[s]=0,i[s]=-1,c[s]=[];var l,u=0,d=[],h=[];function f(t){var s=[t],l=[t];for(r[t]=n[t]=u,a[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>o[t]){for(var y=o[t];f.length>y;++y){var g=f[y];if(0>r[g]){r[g]=n[g]=u,a[g]=!0,u+=1,s.push(g),l.push(g);break}a[g]&&(n[t]=0|Math.min(n[t],n[g])),0>i[g]||c[t].push(i[g])}o[t]=y}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var b=s[y];if(a[b]=!1,p.push(b),v.push(c[b]),m+=c[b].length,i[b]=d.length,b===t){s.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}l.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);h[s]=l}}return{components:d,adjacencyList:h}}(e),a=n.components.filter(function(e){return e.length>1}),o=1/0,i=0;a.length>i;i++)for(var c=0;a[i].length>c;c++)o>a[i][c]&&(o=a[i][c],r=i);var s=a[r];if(!s)return!1;var l=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:o,adjList:l}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,c=f.adjList){for(var y=0;c.length>y;y++)for(var g=0;c[y].length>g;g++){var p=c[y][g];o[+p]=!1,i[p]={}}l(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function L(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function E(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function D(e,t){return t(e)}function A(e){return P(e.source)}function S(e){return P(e.target)}function P(e){return(e.y0+e.y1)/2}function T(e){return e.virtual?0:e.value}function M(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function O(e){return e.target.depth}function _(e,t){return e.sourceLinks.length?e.depth:t-1}function $(e,t){return e.y0-t.y0}function N(e,t){return t.y0-e.y0}function I(e,t){return e.y1-t.y1}function W(e,t){return t.y1-e.y1}function C(e,t){return R(e.source,t.source)||e.index-t.index}function j(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function B(e,t){return z(e)==z(t)?"bottom"==e.circularLinkType?N(e,t):$(e,t):z(t)-z(e)}function z(e){return e.target.column-e.source.column}function F(e,t){return Y(e)==Y(t)}function Y(e){return e.y0-e.y1>0?"up":"down"}function X(e,t,n,a,o){let i=e;var c=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,c))});var s=r.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),H(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),H(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+a,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=a+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=a+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=a+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=a+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==r&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?N:$);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=a+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=a+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(l=i.links.filter(function(e){return e.target.column==r&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?W:I),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=a+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=a+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,a=e.y1,o=(t+n)/2;return"M"+t+","+r+"C"+o+","+r+" "+o+","+a+" "+n+","+a}(e)}),i}function H(e,t,r){e.sort(B);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,a){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var i=0;n.length>i;i++){var c=n[i];if(c!==e&&c.circularPathData&&void 0!==c.circularPathData.verticalBuffer&&G(e,c)){var s=c.circularPathData.verticalBuffer+(c._circularWidth||c.width)/2+r;o=s>o?s:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function Z(e){return e.nodes}function K(e){return e.links}function Q(e,t,n){var a=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});a.forEach(function(r){var o=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?M(t,n)-M(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==a.length-1&&1==o||0==t.depth&&1==o?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==M(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/o*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-o/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,a,o,i){var c=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,l=i;l>0;--l)u(s*=.99,n),d();function u(t,n){var a=c.length;c.forEach(function(o){var i=o.length,c=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&M(o,n)>0){var l=r.mean(o.sourceLinks,S),u=r.mean(o.targetLinks,A),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-P(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==c&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(c==a-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var f=r.mean(o.sourceLinks,S),y=r.mean(o.targetLinks,A),g=((f&&y?(f+y)/2:f||y)-P(o))*t;o.y0+=g,o.y1+=g}})})}function d(){c.forEach(function(r){var n,i,c,s=e.y0,l=r.length;for(r.sort(t||R),c=0;l>c;++c)(i=s-(n=r[c]).y0)>0&&(n.y0+=i,n.y1+=i),s=n.y1+a;if((i=s-a-e.y1)>0)for(s=n.y0-=i,n.y1-=i,c=l-2;c>=0;--c)(i=(n=r[c]).y1+o-s)>0&&(n.y0-=i,n.y1-=i),s=n.y0})}}function U(e){e.nodes.forEach(function(e){e.sourceLinks.sort(j),e.targetLinks.sort(C)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,a=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=a-e.width/2,a-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,a=1,o=24,i=8,c=null,s=V,l=_,u=void 0,d=32,h=2,f=Z,y=K;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=a,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,a=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof a&&(a=e.target=p(n,a)),r.sourceLinks.push(e),a.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],a=0;e.links.length>a;a++){var o=e.links[a],i=o.source.index,c=o.target.index;n[i]||(n[i]=[]),n[c]||(n[c]=[]),-1===n[i].indexOf(c)&&n[i].push(c)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var l={};for(a=0;s.length>a;a++){var u=s[a].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(a){a.circular&&(a.circularLinkType=a.source.circularLinkType||a.target.circularLinkType?a.source.circularLinkType?a.source.circularLinkType:a.target.circularLinkType:n>r?"top":"bottom","top"==a.circularLinkType?r++:n++,e.nodes.forEach(function(e){D(e,t)!=D(a.source,t)&&D(e,t)!=D(a.target,t)||(e.circularLinkType=a.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,T),r.sum(e.targetLinks,T)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,a,o;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var i=0,c=t(e.nodes[0]);e.nodes.forEach(function(e){i=t(e)==c?i:i+1,c=t(e)==c?c:t(e),e.column=i})}for(n=e.nodes,a=[],o=0;n.length;++o,n=a,a=[])n.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>a.indexOf(e.target)&&!e.circular&&a.push(e.target)})});for(n=e.nodes,a=[],o=0;n.length;++o,n=a,a=[])n.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>a.indexOf(e.source)&&!e.circular&&a.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,o):e.column})}(f,u,l);var y=i;if(null!==c){var g=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(g,function(e){return e.length});m>1&&(y=Math.max(1,(a-t)*c/(m-1)))}(function(e,t,n){var a=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=r.min(a,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,o),Q(f,u,s),J(f,u,s,y,y,d),U(f),X(f,s,h,10,8),Q(f,u,s),J(f,u,s,y,y,d),U(f),X(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return D(r.source,t)==D(e,t)}),a=n.length;a>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!F(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;n.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var o=r+1,i=0;a>o;o++)i+=n[o].width;t.y0=e.y1-i-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return D(r.target,t)==D(e,t)}),a=n.length;a>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!F(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=L(t,e);return e.y0-r}if(t.source.column>e.source.column)return L(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;n.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var o=r+1,i=0;a>o;o++)i+=n[o].width;t.y1=e.y1-i-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,a=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?a=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==a||0==o){var i=r.min(t,function(e){return e.y0}),c=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(c-i);function l(t){return(t-i)/(c-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),X(f,s,h,10,8)}(g),g}return g.update=function(e){return U(e),X(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(c=+e,g):c},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:q(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:q(e),g):l},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],a=+r[1][1],g):[[e,t],[n,a]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],a=+r[1],g):[n-e,a-t]},g}const te=e=>{let r,n,a,o,i,c,s,l,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,a=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.y1,c=e.target.y0,s=t.interpolateNumber(i,c),l=s(.5),u=s(.5),`M${r},${i}C${r},${l} ${n},${u} ${n},${c}L${a},${c}C${a},${u} ${o},${l} ${o},${i}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),a=s(.5),o=s(.5),i=e.y0-e.sankeyWidth/2,c=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${i}C${a},${i} ${o},${c} ${n},${c}L${n},${l}C${o},${l} ${a},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,a=e.circularPathData;if(!a)return null;if("down"===e.direction)return null;if(e._circularStub){const t=a.sourceX,n=a.sourceY,o=a.targetX,i=a.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const c=Math.max(15,Math.min(40,.33*(a.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(o-a.leftFullExtent)));return`M${t},${n-r}L${t+c},${n-r}L${t+c},${n+r}L${t},${n+r}ZM${o},${i-r}L${o-s},${i-r}L${o-s},${i+r}L${o},${i+r}Z`}const o=a.sourceX,i=a.sourceY,c=a.targetX,s=a.targetY,l=a.rightFullExtent,u=a.leftFullExtent,d=a.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${o},${i-h*r}L${l},${i-h*r}L${l+n},${i-h*r+h*f}L${l+n},${d+h*n-h*f}L${l+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${c},${s-h*r}L${c},${s+h*r}L${u},${s+h*r}L${u},${d-h*n}L${l},${d-h*n}L${l},${i+h*r}L${o},${i+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(O))-1:0},justify:_},ae={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var a,o,i,c,s,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(a=r.nodeWidth)&&void 0!==a?a:15,y=null!==(o=r.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(i=r.iterations)&&void 0!==i?i:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||_).nodeId(e=>e.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let e=1/0,t=-1/0,r=1/0,a=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>a&&(a=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const o=n.circularPathData,i=(null!==(s=null!==(c=n._circularWidth)&&void 0!==c?c:n.width)&&void 0!==s?s:0)/2;e>o.leftFullExtent-i&&(e=o.leftFullExtent-i),o.rightFullExtent+i>t&&(t=o.rightFullExtent+i),r>o.verticalFullExtent-i&&(r=o.verticalFullExtent-i),o.verticalFullExtent+i>a&&(a=o.verticalFullExtent+i)}const o=t-e,i=a-r,u=n[0],d=n[1];if(o>0&&i>0&&(0>e||0>r||t>u||a>d)){const t=Math.min(u/o,d/i),n=-e*t+(u-o*t)/2,a=-r*t+(d-i*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+a,e.y1=e.y1*t+a;for(const e of v)if(e.y0=e.y0*t+a,e.y1=e.y1*t+a,e.width=(null!==(l=e.width)&&void 0!==l?l:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+a,r.targetY=r.targetY*t+a,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+a,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+a,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+a,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",a="object"==typeof r&&null!==r?r.id:r+"",o=k.get(`${n}\0${a}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=d;const t=x.get(n),r=x.get(a);t&&(o.source=t),r&&(o.target=r)}}},buildScene(e,t,r,a){var o,i,c,s;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(o=r.edgeOpacity)&&void 0!==o?o:.5,f=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},a={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:a,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const a=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=a.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+o},${t.sourceY-r}L${t.sourceX+o},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:a.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(c=a.fillOpacity)&&void 0!==c?c:h,stroke:"none",opacity:a.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let o;if(o=e.circular&&e.circularPathData?re(e):te(e),!o)continue;const l={fill:a.fill||n,fillOpacity:null!==(s=a.fillOpacity)&&void 0!==s?s:h,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};v.push({type:"bezier",pathD:o,bezierCache:e.bezier,style:l,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const o=t?t(r):r.id;if(!o)continue;let i,c,s;"down"===l?(i=r.x0+e/2,c=r.y1+14,s="middle"):(a[0]/2>r.x0+e/2?(i=r.x0-6,s="end"):(i=r.x1+6,s="start"),c=r.y0+n/2),m.push({x:i,y:c,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},oe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var o,i;if(0===e.length)return;const c=null!==(o=r.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,l=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const r=e[t];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;r.x=l+e*Math.cos(n),r.y=u+e*Math.sin(n)}}const d=ie(r.nodeSize,r.nodeSizeRange,e),h=a.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),f=n[1]/n[0],y=a.forceSimulation().force("charge",a.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",a.forceX(n[0]/2).strength(.1*f)).force("y",a.forceY(n[1]/2).strength(.1));if(y.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));y.force("link",h),y.force("link").links(e)}.1>y.alpha()&&y.alpha(1),y.stop();for(let e=0;c>e;++e)y.tick();const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,a){var o,i,c;const s=r.nodeStyle,l=r.edgeStyle,u=ie(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=l?l(e):{},a={stroke:n.stroke||"#999",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(c=n.opacity)&&void 0!==c?c:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:a,datum:e})}if(!1!==r.showLabels){const t=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ie(e,t,n){var a,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const c=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>c[0];const l=null!==(a=r.min(s))&&void 0!==a?a:0,u=null!==(i=r.max(s))&&void 0!==i?i:1;if(l===u)return()=>(c[0]+c[1])/2;const d=o.scaleLinear().domain([l,u]).range(c).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?c[0]:d(n)}}const ce=n.schemeCategory10,se={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:a=.01,groupWidth:o=20,sortGroups:s}=r,l=Math.min(n[0],n[1])/2,u=l-o,d=n[0]/2,h=n[1]/2,f=(y=r.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=g.get("string"==typeof e.source?e.source:e.source.id),n=g.get(t);if(void 0===r||void 0===n)continue;const a=f(e);v[r][n]=a}const m=i.chord().padAngle(a);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const L=new Map;for(const e of t)L.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,a=L.get(`${r}\0${n}`)||L.get(`${n}\0${r}`);a&&(a.chordData=t)}},buildScene(e,t,r,n){var a,o;const{groupWidth:c=20,edgeOpacity:s=.5}=r,l=Math.min(n[0],n[1])/2,u=l-c,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:ce,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=i.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let o;o=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const i=f?f(r):{},c={fill:o,stroke:i.stroke||"black",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:c,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=le(r,d,h);let a="#999";if(y)a=y(e).fill||a;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===g&&r?a=v.get(r.id)||a:t&&(a=v.get(t.id)||a)}const i=y?y(e):{},c={fill:a,fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};x.push({type:"ribbon",pathD:n,style:c,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=l+12;for(const r of e){const e=r.arcData;if(!e)continue;const a=t?t(r):r.id;if(!a)continue;const o=(e.startAngle+e.endAngle)/2,i=o-Math.PI/2;k.push({x:d+Math.cos(i)*n,y:h+Math.sin(i)*n,text:a+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function le(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const a=[];let o=0;for(;n.length>o;){const e=n[o];if("M"===e||"L"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)a.push(Number(n[o])+t+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(a.push(Number(n[o])+r+""),o++);else if("C"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)for(let e=0;3>e&&n.length>o&&!isNaN(Number(n[o]));e++)a.push(Number(n[o])+t+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(a.push(Number(n[o])+r+""),o++);else if("Q"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)for(let e=0;2>e&&n.length>o&&!isNaN(Number(n[o]));e++)a.push(Number(n[o])+t+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(a.push(Number(n[o])+r+""),o++);else if("A"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&(a.push(Number(n[o])+t+""),o++),n.length>o&&(a.push(Number(n[o])+r+""),o++);else"Z"===e||"z"===e?(a.push(e),o++):(a.push(n[o]),o++)}return a.join(" ")}const ue={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var a;const o=r.__hierarchyRoot;if(!o)return;const i=r.chartType,c=(l=r.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(o,c);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(i){case"tree":!function(e,t,r,n){const a=t.treeOrientation||"vertical",o=s.tree();o.size("horizontal"===a?[n,r]:"radial"===a?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),o(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const a=t.treeOrientation||"vertical",o=s.cluster();o.size("horizontal"===a?[n,r]:"radial"===a?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),o(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var a,o;const i=null!==(a=t.padding)&&void 0!==a?a:4,c=null!==(o=t.paddingTop)&&void 0!==o?o:0,l=s.treemap().size([r,n]).tile(s.treemapBinary).padding(i);c>0&&l.paddingTop(c),l(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var a;const o=null!==(a=t.padding)&&void 0!==a?a:4;s.pack().size([r,n]).padding(o)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var a;s.partition().size([r,n]).padding(null!==(a=t.padding)&&void 0!==a?a:1)(e)}(d,r,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],o={id:ge(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(a=n.value)&&void 0!==a?a:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?de(o,n,r):"treemap"===i||"partition"===i?he(o,n):"circlepack"===i&&fe(o,n),o.__hierarchyNode=n,e.push(o),g.set(n,o)}if("tree"===i||"cluster"===i)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const a=r.nodeStyle||(()=>({})),o=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,a,o){var i,c,s,l,u;const d=[],h=[],f=[],y=r.treeOrientation||"vertical",g="radial"===y,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;g&&(e+=p,n+=v);const o=a(t);let c=o.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(c=b[t.depth%b.length]);const s={fill:c,stroke:o.stroke||"#fff",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:o.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(c=r.edgeOpacity)&&void 0!==c?c:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,a=t.y,i=r.x,c=r.y;g&&(n+=p,a+=v,i+=p,c+=v);const u=ye(n,a,i,c,y),d=o(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=pe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,a,o,i=r.x,c=r.y;if(g&&(i+=p,c+=v),g){const e=i-p,t=c-v,r=Math.sqrt(e*e+t*t);r>0?(n=i+e/r*10,a=c+t/r*10,o=0>e?"end":"start"):(n=i,a=c-12,o="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=i-m-6,o="end"):(n=i+m+6,o="start"),a=c):(n=i,a=c+m+14,o="middle");f.push({x:n,y:a,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,a,o);case"treemap":case"partition":return function(e,t,r,n){var a,o;const i=[],c=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,o=r.y1-r.y0;if(0>=e||0>=o)continue;const c=n(r);let l=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(l=s[r.depth%s.length]);const u={fill:l,stroke:c.stroke||"#fff",strokeWidth:null!==(a=c.strokeWidth)&&void 0!==a?a:1,opacity:c.opacity};i.push({type:"rect",x:r.x0,y:r.y0,w:e,h:o,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;if((null===(o=n.data)||void 0===o?void 0:o.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const i=r?r(n):n.id;i&&(30>e||16>a||c.push({x:n.x0+e/2,y:n.y0+a/2,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,a)/6))}))}}return{sceneNodes:i,sceneEdges:[],labels:c}}(e,r,0,a);case"circlepack":return function(e,t,r,n){var a,o,i,c,s;const l=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(a=r.__radius)&&void 0!==a?a:5;if(0>=e)continue;const c=n(r);let s=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:c.stroke||"#fff",strokeWidth:null!==(o=c.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=c.opacity)&&void 0!==i?i:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const t of e){const e=null!==(c=t.__radius)&&void 0!==c?c:5,n=r?r(t):t.id;if(!n)continue;if(15>e)continue;const a=!((null===(s=t.data)||void 0===s?void 0:s.children)&&t.data.children.length>0);u.push({x:t.x,y:a?t.y:t.y-e+14,text:n+"",anchor:"middle",baseline:a?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:a?void 0:"#000",stroke:a?void 0:"#fff",strokeWidth:a?void 0:3,paintOrder:a?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,a);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function de(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function he(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function fe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ye(e,t,r,n,a){if("horizontal"===a){const a=(e+r)/2;return`M ${e},${t} C ${a},${t} ${a},${n} ${r},${n}`}if("radial"===a){const a=(e+r)/2;return`M ${e},${t} Q ${a},${t} ${a},${(t+n)/2} T ${r},${n}`}{const a=(t+n)/2;return`M ${e},${t} C ${e},${a} ${r},${a} ${r},${n}`}}function ge(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function pe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}const ve={sankey:ae,force:oe,chord:se,tree:ue,cluster:ue,treemap:ue,circlepack:ue,partition:ue};function me(e){return ve[e]}class be{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles?this.particlePool||(this.particlePool=new f(2e3)):this.particlePool=null}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:a="source",targetAccessor:o="target",valueAccessor:i="value"}=this.config,c="function"==typeof n?n:e=>e[n],s="function"==typeof a?a:e=>e[a],l="function"==typeof o?o:e=>e[o],u="function"==typeof i?i:e=>{var t;return null!==(t=e[i])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=c(t)+"";this.nodes.set(e,Object.assign(Object.assign({},xe(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=l(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},xe(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},xe(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,a=0===this.nodes.size;let o=!1;const i="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=i,this.nodes.has(t)||(this.nodes.set(t,xe(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(r)||(this.nodes.set(r,xe(r)),this.nodeTimestamps.set(r,i),this.tension+=this.tensionConfig.newNode,o=!0);const c=this.edgeKey(t,r),s=this.edges.get(c);return s?(s.value+=n,this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.weightChange):(this.edges.set(c,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.newEdge,o=!0),a||o||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=me(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(r,n,this.config,e),t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear();for(const e of r)this.nodes.set(e.id,e);for(const e of n)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const a=new Set(this.nodes.keys()),o=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of a)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)a.has(e)||this.removedNodes.add(e);for(const e of o)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)o.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=a,this.previousEdgeKeys=o,this.layoutVersion++}buildScene(e){const t=me(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:a,sceneEdges:o,labels:i}=t.buildScene(r,n,this.config,e);this.sceneNodes=a,this.sceneEdges=o,this.labels=i}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),r=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*r,e.x1=e._prevX1+(e._targetX1-e._prevX1)*r,e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*r);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const a=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=r.y1,i=n.y0,c=t.interpolateNumber(o,i);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:c(.5)},{x:e.y1,y:c(.5)},{x:e.y1,y:i}],halfWidth:a}}const o=r.x1,i=n.x0,c=t.interpolateNumber(o,i);return{circular:!1,points:[{x:o,y:e.y0},{x:c(.5),y:e.y0},{x:c(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:a}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const a=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],o=r.x-t.x,i=r.y-t.y;a.push([t,{x:t.x+o/3,y:t.y+i/3},{x:t.x+2*o/3,y:t.y+2*i/3},r])}return{circular:!0,segments:a,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,a,o;const i=this.config.pulse;if(!i)return;const c=null!==(t=i.duration)&&void 0!==t?t:500,s=null!==(r=i.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(n=i.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const a=e-n;c>a&&(t._pulseIntensity=1-a/c,t._pulseColor=s,t._pulseGlowRadius=l)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(a=r.source)||void 0===a?void 0:a.id:r.source,i="object"==typeof r.target?null===(o=r.target)||void 0===o?void 0:o.id:r.target;if(!n||!i)continue;const l=this.edgeTimestamps.get(`${n}\0${i}`);if(!l)continue;const u=e-l;c>u&&(t._pulseIntensity=1-u/c,t._pulseColor=s)}}applyDecay(){var e,t,r,n,a;const o=this.config.decay;if(!o)return;const i=null!==(e=o.minOpacity)&&void 0!==e?e:.1,c=this.nodeTimestamps.size;if(1>=c)return;const s=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),l=new Map;for(let e=0;s.length>e;e++)l.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=l.get(s);if(void 0===u)continue;const d=c-1-u;let h;switch(o.type){case"linear":h=i+(1-d/(c-1))*(1-i);break;case"exponential":{const e=null!==(t=o.halfLife)&&void 0!==t?t:c/2;h=i+Math.pow(.5,d/e)*(1-i);break}case"step":h=(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*c)>d?1:i;break;default:h=1}const f=null!==(a=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==a?a:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const a=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",o=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",i=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const c=this.nodes.get(r);if(!c)continue;const s=n.metric(c);let l=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(l=a):l=o,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),i&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=l,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function xe(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ke(e,t,r,n,a=30){let o=null,i=a,c=1/0;for(const t of e){const e=we(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;c>r&&(o=e,c=r)}else i>e.distance&&(o=e,i=e.distance)}if(o)return o;for(const e of t){const t=Le(e,r,n);t&&i>t.distance&&(o=t,i=t.distance)}return o}function we(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,a=r-e.cy,o=Math.sqrt(n*n+a*a);return o>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:o}}(e,t,r);case"rect":return function(e,t,r){return e.x>t||t>e.x+e.w||e.y>r||r>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,a=r-e.cy,o=Math.sqrt(n*n+a*a);if(e.innerR-2>o||o>e.outerR+2)return null;let i=Math.atan2(a,n);0>i&&(i+=2*Math.PI);let c,s=e.startAngle,l=e.endAngle;if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),c=s>l?i>=s||l>=i:i>=s&&l>=i,c){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}function Le(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,a;if(!e.pathD)return null;try{const o=new Path2D(e.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(o,t,r)){const o="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,i="object"==typeof(null===(a=e.datum)||void 0===a?void 0:a.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:o&&i?(o.x1+i.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,a=e.y2-e.y1,o=n*n+a*a;if(0===o)return null;let i=((t-e.x1)*n+(r-e.y1)*a)/o;i=Math.max(0,Math.min(1,i));const c=e.x1+i*n,s=e.y1+i*a,l=Math.sqrt(Math.pow(t-c,2)+Math.pow(r-s,2));return l>5?null:{type:"edge",datum:e.datum,x:c,y:s,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0}}catch(e){}return null}(e,t,r);default:return null}}function Ee(e){const{width:t,height:r,totalWidth:n,totalHeight:a,margin:o,labels:i,title:c,legend:s,foregroundGraphics:l,annotations:d,svgAnnotationRules:h}=e;return u.createElement("svg",{width:n,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${o.left},${o.top})`},i.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),d&&h&&d.map((e,n)=>{const a=h(e,n,{width:t,height:r});return a?u.createElement(u.Fragment,{key:"annotation-"+n},a):null}),l),c&&"string"==typeof c?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},c):c?u.createElement("foreignObject",{x:0,y:0,width:n,height:o.top},c):null,s&&"object"==typeof s&&"legendGroups"in s?u.createElement("g",{transform:`translate(${n-o.right+10},${o.top})`},s.legendGroups.map((e,t)=>{var r;return u.createElement("g",{key:"legend-group-"+t},null===(r=e.items)||void 0===r?void 0:r.map((e,t)=>u.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},u.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),u.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):s?u.createElement("g",{transform:`translate(${n-o.right+10},${o.top})`},s):null)}function De(e,t){var r,n,a,o,i,c;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const i=t._gradient;if(i){const a=e.createLinearGradient(i.x0,0,i.x1,0),o=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,c=t.style.fill;a.addColorStop(0,1===i.from?c:"transparent"),a.addColorStop(1,1===i.to?c:"transparent"),e.fillStyle=a,e.globalAlpha=o}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:t.style.opacity)&&void 0!==o?o:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.5*(null!==(c=t.style.opacity)&&void 0!==c?c:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function Ae(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Se(e,t){var r,n,a,o;if(!t.pathD)return;e.save();const i=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.3*(null!==(o=t.style.opacity)&&void 0!==o?o:1),e.stroke(i)),e.restore()}function Pe(e,t){var r,n;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(a),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(a)),e.restore()}Ee.displayName="NetworkSVGOverlay";const Te={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},Me=n.schemeCategory10,Oe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function _e(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):Me[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Me.length]}function $e(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>e[t]))),a=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return o.scaleOrdinal().domain(n).range(r).unknown("#999");const i=Te[r]||Te.category10;if(a&&"function"==typeof i)return e=>i(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(i)?i:Me;return o.scaleOrdinal().domain(n).range(e).unknown("#999")}}const Ne={top:20,right:80,bottom:20,left:80},Ie={top:40,right:40,bottom:40,left:40},We=new Set(["chord","force","circlepack"]),Ce=[800,600],je={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Re({data:e}){var t,r,n,a,o,i;if("edge"===e.type){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:je},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const c=e.data,s=null==c?void 0:c.__hierarchyNode;if(s){const e=[];let o=s;for(;o;){const i=null!==(a=null!==(r=null===(t=o.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=o.data)||void 0===n?void 0:n.id)&&void 0!==a?a:c.id;null!=i&&e.unshift(i+""),o=o.parent}e.length>1&&e.shift();const i=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:je},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===i?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof c.value?c.value.toLocaleString():c.value+""))}const l=((null===(o=c.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(i=c.targetLinks)||void 0===i?void 0:i.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:je},u.createElement("div",{style:{fontWeight:600}},c.id),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const Be=e.forwardRef(function(t,r){const{chartType:n,nodes:a,edges:o,data:i,initialEdges:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:f="target",valueAccessor:y="value",childrenAccessor:g,hierarchySum:p,orientation:v="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,iterations:k=300,forceStrength:w=.1,padAngle:L=.01,groupWidth:E=20,sortGroups:D,edgeSort:A,treeOrientation:S="vertical",edgeType:P="curve",padding:T,paddingTop:M,tensionConfig:O,showParticles:_=!1,particleStyle:$,nodeStyle:N,edgeStyle:I,colorBy:W,colorScheme:C="category10",edgeColorBy:j="source",edgeOpacity:R=.5,colorByDepth:B=!1,nodeSize:z=8,nodeSizeRange:F=[5,20],nodeLabel:Y,showLabels:X=!0,size:H=Ce,margin:G,className:q,background:V,enableHover:Z=!0,tooltipContent:K,customHoverBehavior:Q,customClickBehavior:J,onObservation:U,chartId:ee,onTopologyChange:te,annotations:re,svgAnnotationRules:ne,legend:ae,title:oe,foregroundGraphics:ie,backgroundGraphics:ce,decay:se,pulse:le,staleness:ue,thresholds:de}=t,he=We.has(n)?Ie:Ne,fe=Object.assign(Object.assign({},he),G),ye=H[0]-fe.left-fe.right,ge=H[1]-fe.top-fe.bottom,pe=e.useMemo(()=>Object.assign(Object.assign({},d),O),[O]),ve=e.useMemo(()=>Object.assign(Object.assign({},h),$),[$]),me=e.useMemo(()=>({chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:f,valueAccessor:y,childrenAccessor:g,hierarchySum:p,orientation:v,nodeAlign:m,nodePaddingRatio:b,nodeWidth:x,iterations:k,forceStrength:w,padAngle:L,groupWidth:E,sortGroups:D,edgeSort:A,treeOrientation:S,edgeType:P,padding:T,paddingTop:M,tensionConfig:pe,showParticles:_,particleStyle:ve,nodeStyle:N,edgeStyle:I,nodeLabel:Y,showLabels:X,colorBy:W,colorScheme:C,edgeColorBy:j,edgeOpacity:R,colorByDepth:B,nodeSize:z,nodeSizeRange:F,decay:se,pulse:le,staleness:ue,thresholds:de}),[n,s,l,f,y,g,p,v,m,b,x,k,w,L,E,D,A,S,P,T,M,pe,_,ve,N,I,Y,X,W,C,j,R,B,z,F,se,le,ue,de]),xe=e.useRef(null),we=e.useRef(0),Le=e.useRef(0),Te=e.useRef(!0),Oe=e.useRef(()=>{}),_e=e.useRef(null);_e.current||(_e.current=new be(me));const[$e,je]=e.useState(null),[Be,ze]=e.useState(0),[Fe,Ye]=e.useState(0),[Xe,He]=e.useState(!1),Ge=e.useRef(null),qe=e.useRef(new Map),Ve=e.useRef(0),Ze=e.useCallback(e=>{if("function"==typeof W)return W(e);if("string"==typeof W&&e.data){const t=e.data[W];if(void 0!==t){if(!qe.current.has(t+"")){const e=Array.isArray(C)?C:Me;qe.current.set(t+"",e[Ve.current++%e.length])}return qe.current.get(t+"")}}if(!qe.current.has(e.id)){const t=Array.isArray(C)?C:Me;qe.current.set(e.id,t[Ve.current++%t.length])}return qe.current.get(e.id)},[W,C]),Ke=e.useCallback(e=>{if("function"==typeof j)return j(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===j&&r?Ze(r):t?Ze(t):"#999"},[j,Ze]),Qe=e.useCallback(e=>{if(!(null==$?void 0:$.colorBy))return Ke(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===ve.colorBy&&r?Ze(r):t?Ze(t):"#999"},[null==$?void 0:$.colorBy,ve.colorBy,Ze,Ke]),Je="sankey"===n&&_||!!le,Ue=e.useCallback(()=>{we.current&&!Je||we.current||(we.current=requestAnimationFrame(()=>Oe.current()))},[Je]);e.useEffect(()=>{var e;null===(e=_e.current)||void 0===e||e.updateConfig(me),Te.current=!0,Ue()},[me,Ue]);const et=e.useCallback(()=>{const e=_e.current;if(!e)return;e.runLayout([ye,ge]),e.buildScene([ye,ge]),Te.current=!0;const t=Array.isArray(C)?C:Me,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];qe.current.has(n.id)||qe.current.set(n.id,t[e%t.length])}if(Ve.current=r.length,ze(e.layoutVersion),te){const{nodes:t,edges:r}=e.getLayoutData();te(t,r)}},[ye,ge,te,C]),tt=e.useCallback(e=>{const t=_e.current;t&&(t.ingestEdge(e)&&et(),Ue())},[et,Ue]),rt=e.useCallback(e=>{const t=_e.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&et(),Ue()},[et,Ue]),nt=e.useCallback(()=>{var e;null===(e=_e.current)||void 0===e||e.clear(),qe.current.clear(),Ve.current=0,ze(0),je(null),Ge.current=null,Te.current=!0,Ue()},[Ue]),at=e.useCallback(()=>{const e=_e.current;e&&(e.tension+=999,et(),Ue())},[et,Ue]);e.useImperativeHandle(r,()=>({push:tt,pushMany:rt,clear:nt,getTopology:()=>{var e,t;return null!==(t=null===(e=_e.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=_e.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:at,getTension:()=>{var e,t;return null!==(t=null===(e=_e.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[tt,rt,nt,at]);const ot=["tree","cluster","treemap","circlepack","partition"].includes(n),it=ot?i||(Array.isArray(o)?void 0:o):void 0;e.useEffect(()=>{const e=_e.current;if(e)if(ot&&it)e.ingestHierarchy(it,[ye,ge]),e.buildScene([ye,ge]),Te.current=!0,Ue();else{const t=a||[],r=Array.isArray(o)?o:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[ye,ge]),e.buildScene([ye,ge]);const n=Array.isArray(C)?C:Me,i=Array.from(e.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];qe.current.has(t.id)||qe.current.set(t.id,n[e%n.length])}Ve.current=i.length,Te.current=!0,Ue()}},[a,o,i,it,ot,ye,ge,me,Ue,C]),e.useEffect(()=>{c&&c.length>0&&rt(c)},[]);const ct=e.useCallback(e=>{if(Q&&Q(e),U){const t=Date.now();U(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ee}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ee})}},[Q,U,ee]),st=e.useCallback(e=>{if(J&&J(e),U){const t=Date.now();U(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ee}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ee})}},[J,U,ee]),lt=e.useRef(()=>{}),ut=e.useRef(()=>{});lt.current=e=>{if(!Z)return;const t=xe.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-fe.left,a=e.clientY-r.top-fe.top;if(0>n||n>ye||0>a||a>ge)return void(Ge.current&&(Ge.current=null,je(null),ct&&ct(null),Ue()));const o=_e.current;if(!o)return;const i=ke(o.sceneNodes,o.sceneEdges,n,a);if(!i)return void(Ge.current&&(Ge.current=null,je(null),ct&&ct(null),Ue()));const c={type:i.type,data:i.datum,x:i.x,y:i.y};Ge.current=c,je(c),ct&&ct(c),Ue()},ut.current=()=>{Ge.current&&(Ge.current=null,je(null),ct&&ct(null),Ue())};const dt=e.useRef(()=>{});dt.current=e=>{if(!J&&!U)return;const t=xe.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-fe.left,a=e.clientY-r.top-fe.top;if(0>n||n>ye||0>a||a>ge)return;const o=_e.current;if(!o)return;const i=ke(o.sceneNodes,o.sceneEdges,n,a);st(i?{type:i.type,data:i.datum,x:i.x,y:i.y}:null)};const ht=e.useCallback(e=>lt.current(e),[]),ft=e.useCallback(()=>ut.current(),[]),yt=e.useCallback(e=>dt.current(e),[]);Oe.current=()=>{var e,t,r;we.current=0;const n=xe.current;if(!n)return;const a=n.getContext("2d");if(!a)return;const o=_e.current;if(!o)return;const i=performance.now(),c=Le.current?Math.min((i-Le.current)/1e3,.1):.016;Le.current=i;const s=o.advanceTransition(i);(s||Te.current)&&o.buildScene([ye,ge]);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=H[0]*l,n.height=H[1]*l,n.style.width=H[0]+"px",n.style.height=H[1]+"px",a.scale(l,l),a.translate(fe.left,fe.top),a.clearRect(-fe.left,-fe.top,H[0],H[1]),V&&(a.fillStyle=V,a.fillRect(0,0,ye,ge)),se&&o.applyDecay(),le&&o.applyPulse(i),de&&o.applyThresholds(i),o.applyTopologyDiff(i);const u=null!==(e=null==ue?void 0:ue.threshold)&&void 0!==e?e:5e3,d=ue&&o.lastIngestTime>0&&i-o.lastIngestTime>u;if(d&&(a.globalAlpha=null!==(t=null==ue?void 0:ue.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":De(e,r);break;case"line":Ae(e,r);break;case"ribbon":Se(e,r);break;case"curved":Pe(e,r)}}(a,o.sceneEdges),function(e,t){var r,n,a;for(const o of t){if("rect"!==o.type)continue;const t=o;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(a=t.style.opacity)&&void 0!==a?a:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(a,o.sceneNodes),function(e,t){var r,n,a,o;for(const i of t){if("circle"!==i.type)continue;const t=i;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(a=t.style.opacity)&&void 0!==a?a:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const r=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,n=t.r+r*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,n,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(a,o.sceneNodes),function(e,t){var r,n,a;for(const o of t){if("arc"!==o.type)continue;const t=o;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(a=t.style.opacity)&&void 0!==a?a:1,e.stroke()),e.restore()}}(a,o.sceneNodes),_&&o.particlePool&&!d){const e=Array.from(o.edges.values());if(e.length>0){!function(e,t,r,n){var a,o;const i=null!==(a=n.spawnRate)&&void 0!==a?a:h.spawnRate,c=null!==(o=n.maxPerEdge)&&void 0!==o?o:h.maxPerEdge;for(let n=0;t.length>n;n++){const a=t[n];if(!a.bezier)continue;if(e.countForEdge(n)>=c)continue;const o=a.value*i*r*(a.bezier.circular?.3:1),s=Math.floor(o),l=o-s;let u=s;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<c;t++)e.spawn(n)}}(o.particlePool,e,c,ve);const t=.5*(null!==(r=ve.speedMultiplier)&&void 0!==r?r:1);let n;if(ve.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}o.particlePool.step(c,t,e,n),function(e,t,r,n,a){var o,i;const c=null!==(o=n.radius)&&void 0!==o?o:h.radius,s=null!==(i=n.opacity)&&void 0!==i?i:h.opacity;e.globalAlpha=s;for(let o=0;t.particles.length>o;o++){const i=t.particles[o];if(!i.active)continue;const s=r[i.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:a(s);e.beginPath(),e.arc(i.x,i.y,c,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(a,o.particlePool,e,ve,Qe)}}d&&(a.globalAlpha=1);const f=Te.current;Te.current=!1,(f||s)&&Ye(e=>e+1),(Je||s||o.hasActivePulses||o.hasActiveThresholds||o.hasActiveTopologyDiff)&&(we.current=requestAnimationFrame(()=>Oe.current()))},e.useEffect(()=>(Ue(),()=>{we.current&&cancelAnimationFrame(we.current)}),[Ue]),e.useEffect(()=>{Te.current=!0,Ue()},[n,ye,ge,V,Ue]),e.useEffect(()=>{if(!ue)return;const e=setInterval(()=>{var e;const t=_e.current;if(!t||0===t.lastIngestTime)return;const r="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=ue.threshold)&&void 0!==e?e:5e3,a=r-t.lastIngestTime>n;a!==Xe&&(He(a),Te.current=!0,Ue())},1e3);return()=>clearInterval(e)},[ue,Xe,Ue]);const gt=Z&&$e?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:fe.left+$e.x,top:fe.top+$e.y,transform:`translate(${$e.x>.6*ye?"calc(-100% - 12px)":"12px"}, ${.3*ge>$e.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},K?K($e):u.createElement(Re,{data:$e})):null,pt=_e.current;return u.createElement("div",{className:"stream-network-frame"+(q?" "+q:""),role:"img","aria-label":"string"==typeof oe?oe:"Network chart",style:{position:"relative",width:H[0],height:H[1]},onMouseMove:Z?ht:void 0,onMouseLeave:Z?ft:void 0,onClick:J||U?yt:void 0},ce&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:H[0],height:H[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${fe.left},${fe.top})`},ce)),u.createElement("canvas",{ref:xe,style:{position:"absolute",top:0,left:0}}),u.createElement(Ee,{width:ye,height:ge,totalWidth:H[0],totalHeight:H[1],margin:fe,labels:(null==pt?void 0:pt.labels)||[],title:oe,legend:ae,foregroundGraphics:ie,annotations:re,svgAnnotationRules:ne,annotationFrame:Fe}),gt,(null==ue?void 0:ue.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ue.badgePosition?{top:4,left:4}:"bottom-left"===ue.badgePosition?{bottom:4,left:4}:"bottom-right"===ue.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Xe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Xe?"STALE":"LIVE"))});Be.displayName="StreamNetworkFrame";const ze={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Fe(e,t){return"function"==typeof t?t(e):e[t]}function Ye(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Xe(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:r,format:n,style:a={},className:o=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let i;const c=[];if(r){const t=Fe(e,r);i=Ye(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,a,o;"string"==typeof t?(r=t,a=t,o=n):(r=t.label,a=t.accessor||t.key||"",o=t.format||n);const i=Fe(e,a);c.push({label:r,value:Ye(i,o)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){i=Ye(e[r],n);break}if(!i){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(i=Ye(e[t[0]],n))}}const s=Object.assign(Object.assign({},ze),a);return u.createElement("div",{className:("semiotic-tooltip "+o).trim(),style:s},i&&u.createElement("div",{style:{fontWeight:c.length>0?"bold":"normal"}},i),c.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&i?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}(e)))}function He(t){const r=e.createContext(null),n=Ge(t);return[function({children:n}){const a=e.useMemo(()=>Ge(t),[]);return u.createElement(r.Provider,{value:a,children:n})},t=>{var a;const o=null!==(a=e.useContext(r))&&void 0!==a?a:n;return function(t,r){const[n,a]=e.useState(r);return e.useLayoutEffect(()=>t(()=>a(r)),[t]),n}(o.subscribe,()=>t(o.getState()))}]}function Ge(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function qe(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,a]=n.range;t.push(t=>{const n=t[r];return n>=e&&a>=n})}return e=>t.every(t=>t(e))}function Ve(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Ze,Ke]=He(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),a=Ve(n,t),o=new Map(a.clauses);return o.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},a),{clauses:o})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const a=new Map(e.selections),o=new Map(n.clauses);return o.delete(r),a.set(t,Object.assign(Object.assign({},n),{clauses:o})),{selections:a}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),a=Ve(n,t);return n.set(t,Object.assign(Object.assign({},a),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}}));function Qe(t){const r=e.useId(),n=t.clientId||r,{name:a}=t,o=Ke(e=>e.selections.get(a)),i=Ke(e=>e.setClause),c=Ke(e=>e.clearClause),s=e.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:e.useMemo(()=>o&&0!==o.clauses.size?function(e,t){const r=[];for(const[n,a]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(qe(a));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};i(a,{clientId:n,type:"point",fields:t})},[n,a,i]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};i(a,{clientId:n,type:"interval",fields:t})},[n,a,i]),clear:e.useCallback(()=>{c(a,n)},[c,a,n]),clientId:n}}const[Je,Ue]=He(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),et="#007bff";function tt(t,r,n="category10"){return e.useMemo(()=>{if(r&&"function"!=typeof r)return $e(t,r,n)},[t,r,n])}const rt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function nt(e,t,r){var n,a,o,i,c,s;const l=rt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?l.width:r.width,height:null!==(a=t.height)&&void 0!==a?a:e&&"primary"!==e||!(null==r?void 0:r.height)?l.height:r.height,showAxes:l.showAxes,showGrid:null!==(o=t.showGrid)&&void 0!==o?o:l.showGrid,enableHover:null!==(i=t.enableHover)&&void 0!==i?i:!!t.linkedHover||l.enableHover,showLegend:null!==(c=t.showLegend)&&void 0!==c?c:l.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:l.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:l.marginDefaults}}function at({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function ot({data:e,dataLabel:t="data"}){return null==e?`No ${t} provided. Pass a hierarchical data object to the ${t} prop.`:null}function it({nodes:e,edges:t,nodesRequired:r=!1,edgesRequired:n=!0,accessors:a}){if(n&&(!t||!Array.isArray(t)||0===t.length))return"No edges provided. Pass a non-empty array to the edges prop.";if(r&&(!e||!Array.isArray(e)||0===e.length))return"No nodes provided. Pass a non-empty array to the nodes prop.";if(a&&e&&e.length>0)for(const t of(o=e).length>3?[o[0],o[Math.floor(o.length/2)],o[o.length-1]]:o)if(t&&"object"==typeof t)for(const[e,r]of Object.entries(a))if(r&&"string"==typeof r&&!(r in t))return`${e} "${r}" not found in node data. Available fields: ${Object.keys(t).join(", ")}.`;var o;return null}function ct(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:o,margin:i,className:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:y="category10",nodeSize:g=8,nodeSizeRange:p=[5,20],edgeWidth:v=1,edgeColor:m="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:L={},onObservation:E,chartId:D}=t,A=n.width,S=n.height,P=n.enableHover,T=n.showLegend,M=null!==(r=n.showLabels)&&void 0!==r&&r,O=n.title,_=a||[],$=o||[],N=tt(_,f,y),I=e.useMemo(()=>e=>{const t={};return t.fill=f?_e(e.data||e,f,N):et,"number"==typeof g&&(t.r=g),t},[f,N,g]),W=e.useMemo(()=>e=>({stroke:m,strokeWidth:"number"==typeof v?v:"function"==typeof v?v(e):e[v]||1,opacity:b}),[v,m,b]),C=e.useMemo(()=>{if(M&&h)return"function"==typeof h?h:e=>e[h]},[M,h]),{legend:j,margin:R}=function({data:t,colorBy:r,colorScale:n,showLegend:a,userMargin:o,defaults:i={top:50,bottom:60,left:70,right:40}}){const c=void 0!==a?a:!!r,s=e.useMemo(()=>{if(c&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:a,strokeWidth:o}){const i=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(a=>{const o=e.find("function"==typeof t?e=>t(e)===a:e=>e[t]===a),i=o?n(o,t,r):r?r(a):"#000000";return{label:a+"",color:i}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==a&&(t.stroke=a),void 0!==o&&(t.strokeWidth=o),t},type:"fill",items:i,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:_e})},[c,r,t,n]),l=e.useMemo(()=>{const e=Object.assign(Object.assign({},i),o);return s&&120>e.right&&(e.right=120),e},[i,o,s]);return{legend:s,margin:l}}({data:_,colorBy:f,colorScale:N,showLegend:T,userMargin:i,defaults:n.marginDefaults}),B=e.useCallback(e=>{if(!E)return;const t=Date.now();E(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"ForceDirectedGraph",chartId:D}:{type:"hover-end",timestamp:t,chartType:"ForceDirectedGraph",chartId:D})},[E,D]),z=it({componentName:"ForceDirectedGraph",nodes:a,edges:o,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:s}});return z?u.createElement(at,{componentName:"ForceDirectedGraph",message:z,width:A,height:S}):u.createElement(Be,Object.assign({chartType:"force",nodes:_,edges:$,size:[A,S],margin:R,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:d,iterations:x,forceStrength:k,nodeStyle:I,edgeStyle:W,colorBy:f,colorScheme:y,nodeSize:g,nodeSizeRange:p,nodeLabel:C,showLabels:M,enableHover:P,tooltipContent:w?e=>Xe(w)(e.data):void 0,customHoverBehavior:E?B:void 0,legend:j,className:c,title:O},L))}function st(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const a="function"==typeof t?t(e):e[t];a&&Array.isArray(a)&&a.forEach(n)};return n(e),r}function lt(e,t,r,n){if(e&&e.length>0)return e;const a=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],o="function"==typeof n?n(e):e[n];a.add(t),a.add(o)}),Array.from(a).map(e=>({id:e}))}function ut(e){return"function"==typeof e?e:t=>t[e]||1}function dt({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:a,baseStyle:o={}}){return i=>{const c=Object.assign({fillOpacity:a},o);if("function"==typeof e)c.fill=e(i);else if("source"===e){const e="object"==typeof i.source?i.source:null;t&&e?c.fill=_e(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof i.target?i.target:null;t&&e?c.fill=_e(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else"gradient"===e&&(c.fill="#999",c.fillOpacity=.7*a);return c}}function ht(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:a,edges:o,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",orientation:p="horizontal",nodeAlign:v="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:L,frameProps:E={},onObservation:D,chartId:A}=t,S=n.width,P=n.height,T=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,O=n.title,_=o||[],$=e.useMemo(()=>lt(a,_,s,l),[a,_,s,l]),N=tt($,f,y),I=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?_e(e.data||e,f,N):"#4d430c",t},[f,N]),W=e.useMemo(()=>dt({edgeColorBy:g,colorBy:f,colorScale:N,nodeStyleFn:I,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,N,I,k]),C=e.useMemo(()=>{if(!M)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[M,x,h]),j=Object.assign(Object.assign({},n.marginDefaults),i),R=Ue(e=>e.pushObservation),B=e.useCallback(e=>{const t=Date.now();if(e){const r={type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(r),R&&R(r)}else{const e={type:"hover-end",timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(e),R&&R(e)}},[D,A,R]),z=e.useCallback(e=>{const t=Date.now();if(e){const r={type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(r),R&&R(r)}else{const e={type:"click-end",timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(e),R&&R(e)}},[D,A,R]),F=it({componentName:"SankeyDiagram",edges:o,edgesRequired:!0});return F?u.createElement(at,{componentName:"SankeyDiagram",message:F,width:S,height:P}):u.createElement(Be,Object.assign({chartType:"sankey",nodes:$,edges:_,size:[S,P],margin:j,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,orientation:p,nodeAlign:v,nodePaddingRatio:m,nodeWidth:b,nodeStyle:I,edgeStyle:W,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:k,edgeSort:w,nodeLabel:C,showLabels:M,enableHover:T,tooltipContent:L?e=>Xe(L)(e.data):void 0,customHoverBehavior:D?B:void 0,customClickBehavior:D?z:void 0,className:c,title:O},E))}function ft(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:o,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",padAngle:p=.01,groupWidth:v=20,sortGroups:m,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:L,chartId:E}=t,D=n.width,A=n.height,S=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,T=n.title,M=o||[],O=e.useMemo(()=>lt(a,M,s,l),[a,M,s,l]),_=tt(O,f,y),$=e.useMemo(()=>(e,t)=>{var r,n;const a={stroke:"black",strokeWidth:1};if(f)a.fill=_e(e.data||e,f,_);else{const o=Array.isArray(y)?y:Te[y]||Me,i=Array.isArray(o)?o:Me,c=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;a.fill=i[c%i.length]}return a},[f,_,y]),N=e.useMemo(()=>dt({edgeColorBy:g,colorBy:f,colorScale:_,nodeStyleFn:$,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,_,$,x]),I=e.useMemo(()=>{if(!P)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[P,b,h]),W=Object.assign(Object.assign({},n.marginDefaults),i),C=e.useCallback(e=>{if(!L)return;const t=Date.now();L(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"ChordDiagram",chartId:E}:{type:"hover-end",timestamp:t,chartType:"ChordDiagram",chartId:E})},[L,E]),j=it({componentName:"ChordDiagram",edges:o,edgesRequired:!0});return j?u.createElement(at,{componentName:"ChordDiagram",message:j,width:D,height:A}):u.createElement(Be,Object.assign({chartType:"chord",nodes:O,edges:M,size:[D,A],margin:W,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,padAngle:p,groupWidth:v,sortGroups:m,nodeStyle:$,edgeStyle:N,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:x,nodeLabel:I,showLabels:P,enableHover:S,tooltipContent:k?e=>Xe(k)(e.data):void 0,customHoverBehavior:L?C:void 0,className:c,title:T},w))}function yt(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:a,margin:o,className:i,layout:c="tree",orientation:s="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:y="category10",colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w}=t,L=n.width,E=n.height,D=n.enableHover,A=null===(r=n.showLabels)||void 0===r||r,S=n.title,P=e.useMemo(()=>st(a,l),[a,l]),T=e.useMemo(()=>{if(!g&&f&&"function"!=typeof f)return $e(P,f,y)},[P,f,g,y]),M=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Oe[(e.depth||0)%Oe.length]:f?_e(e.data||e,f,T):et,t},[f,g,T]),O=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),_=e.useMemo(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return ut(d)},[c,d]),$=Object.assign(Object.assign({},n.marginDefaults),o),N=e.useCallback(e=>{if(!k)return;const t=Date.now();k(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"TreeDiagram",chartId:w}:{type:"hover-end",timestamp:t,chartType:"TreeDiagram",chartId:w})},[k,w]),I=ot({componentName:"TreeDiagram",data:a});return I?u.createElement(at,{componentName:"TreeDiagram",message:I,width:L,height:E}):u.createElement(Be,Object.assign({chartType:c,data:a,size:[L,E],margin:$,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:_,treeOrientation:s,edgeType:p,nodeStyle:M,edgeStyle:O,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:A?v||h:void 0,showLabels:A,enableHover:D,tooltipContent:b?e=>Xe(b)(e.data):void 0,customHoverBehavior:k?N:void 0,className:i,title:S},x))}function gt(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:a,margin:o,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:y="leaf",nodeLabel:g,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:L}=t,E=n.width,D=n.height,A=n.enableHover,S=null===(r=n.showLabels)||void 0===r||r,P=n.title,{activeSelectionHook:T,customHoverBehavior:M}=function({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:a=!1,onObservation:o,chartType:i,chartId:c}){const s=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(r,n),l=Qe({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:a,isActive:o,selectPoints:i,clear:c}=Qe({name:r});return{onHover:e.useCallback(e=>{if(!e)return void c();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&i(t)},[n,i,c]),predicate:a,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||[]}),d=Ue(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:l.isActive,predicate:l.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r){let t=e&&(e.data||e.datum)||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}if(o||d){const r={timestamp:Date.now(),chartType:i,chartId:c};if(e){let a=e.data||e.datum||e;Array.isArray(a)&&(a=a[0]);const i=Object.assign(Object.assign({},r),{type:"hover",datum:a||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});o&&o(i),d&&d(i)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});o&&o(e),d&&d(e)}}},[r,u,o,i,c,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(o||d){const n={timestamp:Date.now(),chartType:i,chartId:c};if(e){let a=e.data||e.datum||e;Array.isArray(a)&&(a=a[0]);const i=Object.assign(Object.assign({},n),{type:"click",datum:a||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});o&&o(i),d&&d(i)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});o&&o(e),d&&d(e)}}},[o,d,i,c])}}({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:L}),O=e.useCallback(e=>{if(!e)return M(null);const t=e.data||e;M({data:(null==t?void 0:t.data)||t})},[M]),_=e.useMemo(()=>st(a,c),[a,c]),$=e.useMemo(()=>{if(f)return;if(!d||"function"==typeof d)return;const e=d;return $e(_.filter(t=>null!=t[e]),e,h)},[_,d,f,h]),N=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?Oe[(e.depth||0)%Oe.length]:d?_e(e.data||e,d,$):et,t},[d,f,$]),I=e.useMemo(()=>T?e=>{var t,r;const n=Object.assign({},N(e));return T.isActive&&(T.predicate(e.data||e)?(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle):(n.fillOpacity=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2,n.strokeOpacity=null!==(r=null==x?void 0:x.unselectedOpacity)&&void 0!==r?r:.2,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle))),n}:N,[N,T,x]),W=e.useMemo(()=>ut(s),[s]),C=void 0!==v?v:S&&"parent"===y?18:void 0,j=Object.assign(Object.assign({},n.marginDefaults),o),R=ot({componentName:"Treemap",data:a});return R?u.createElement(at,{componentName:"Treemap",message:R,width:E,height:D}):u.createElement(Be,Object.assign({chartType:"treemap",data:a,size:[E,D],margin:j,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:W,padding:p,paddingTop:C,nodeStyle:I,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:S?g||l:void 0,showLabels:S,enableHover:A,tooltipContent:m?e=>Xe(m)(e.data):void 0},(k||w)&&{customHoverBehavior:O},{className:i,title:P},b))}function pt(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:a,margin:o,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:y,circleOpacity:g=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x}=t,k=n.width,w=n.height,L=n.enableHover,E=null===(r=n.showLabels)||void 0===r||r,D=n.title,A=e.useMemo(()=>st(a,c),[a,c]),S=e.useMemo(()=>{if(!f&&d&&"function"!=typeof d)return $e(A,d,h)},[A,d,f,h]),P=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?Oe[(e.depth||0)%Oe.length]:d?_e(e.data||e,d,S):et,t},[d,f,S,g]),T=e.useMemo(()=>ut(s),[s]),M=Object.assign(Object.assign({},n.marginDefaults),o),O=e.useCallback(e=>{if(!b)return;const t=Date.now();b(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"CirclePack",chartId:x}:{type:"hover-end",timestamp:t,chartType:"CirclePack",chartId:x})},[b,x]),_=ot({componentName:"CirclePack",data:a});return _?u.createElement(at,{componentName:"CirclePack",message:_,width:k,height:w}):u.createElement(Be,Object.assign({chartType:"circlepack",data:a,size:[k,w],margin:M,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:T,padding:p,nodeStyle:P,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:E?y||l:void 0,showLabels:E,enableHover:L,tooltipContent:v?e=>Xe(v)(e.data):void 0,customHoverBehavior:b?O:void 0,className:i,title:D},m))}ct.displayName="ForceDirectedGraph",ht.displayName="SankeyDiagram",ft.displayName="ChordDiagram",yt.displayName="TreeDiagram",gt.displayName="Treemap",pt.displayName="CirclePack",exports.ChordDiagram=ft,exports.CirclePack=pt,exports.ForceDirectedGraph=ct,exports.SankeyDiagram=ht,exports.StreamNetworkFrame=Be,exports.TreeDiagram=yt,exports.Treemap=gt;
1
+ "use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),o=require("d3-force"),a=require("d3-scale"),i=require("d3-chord"),c=require("d3-shape"),s=require("d3-hierarchy");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=l(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var o;for(let a=0;this.capacity>a;a++){const i=this.particles[a];if(!i.active)continue;const c=r[i.edgeIndex];if(!c||!c.bezier){i.active=!1;continue}const s=n&&null!==(o=n[i.edgeIndex])&&void 0!==o?o:1;if(i.t+=e*t*s*(c.bezier.circular?.3:1),i.t>=1){i.active=!1;continue}const l=y(c.bezier,i.t,i.offset);i.x=l.x,i.y=l.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function y(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const o=e.length,a=t*o,i=Math.min(Math.floor(a),o-1),c=a-i,[s,l,u,d]=e[i],h=g(s,l,u,d,c),f=d.x-s.x,y=d.y-s.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;h.x+=-y/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,o,a,i]=e.points,c=g(n,o,a,i,t),s=i.x-n.x,l=i.y-n.y,u=Math.sqrt(s*s+l*l);if(u>.001){const t=s/u;c.x+=-l/u*r*e.halfWidth*2,c.y+=t*r*e.halfWidth*2}return c}function g(e,t,r,n,o){const a=1-o,i=a*a,c=i*a,s=o*o,l=s*o;return{x:c*e.x+3*i*o*t.x+3*a*s*r.x+l*n.x,y:c*e.y+3*i*o*t.y+3*a*s*r.y+l*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],o=[],a=[],i={},c=[];function s(e){a[e]=!1,i.hasOwnProperty(e)&&Object.keys(i[e]).forEach(function(t){delete i[e][t],a[t]&&s(t)})}function l(e){var t,n,d=!1;for(o.push(e),a[e]=!0,t=0;c[e].length>t;t++)(n=c[e][t])===r?(u(r,o),d=!0):a[n]||(d=l(n));if(d)s(e);else for(t=0;c[e].length>t;t++){var h=i[n=c[e][t]];h||(i[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),a=Array(t),i=Array(t),c=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,o[s]=!1,a[s]=0,i[s]=-1,c[s]=[];var l,u=0,d=[],h=[];function f(t){var s=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>a[t]){for(var y=a[t];f.length>y;++y){var g=f[y];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,s.push(g),l.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>i[g]||c[t].push(i[g])}a[t]=y}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var b=s[y];if(o[b]=!1,p.push(b),v.push(c[b]),m+=c[b].length,i[b]=d.length,b===t){s.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}l.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);h[s]=l}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),a=1/0,i=0;o.length>i;i++)for(var c=0;o[i].length>c;c++)a>o[i][c]&&(a=o[i][c],r=i);var s=o[r];if(!s)return!1;var l=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:a,adjList:l}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,c=f.adjList){for(var y=0;c.length>y;y++)for(var g=0;c[y].length>g;g++){var p=c[y][g];a[+p]=!1,i[p]={}}l(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function L(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function E(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function A(e,t){return t(e)}function D(e){return P(e.source)}function S(e){return P(e.target)}function P(e){return(e.y0+e.y1)/2}function M(e){return e.virtual?0:e.value}function O(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function T(e){return e.target.depth}function W(e,t){return e.sourceLinks.length?e.depth:t-1}function _(e,t){return e.y0-t.y0}function N(e,t){return t.y0-e.y0}function $(e,t){return e.y1-t.y1}function I(e,t){return t.y1-e.y1}function C(e,t){return j(e.source,t.source)||e.index-t.index}function R(e,t){return j(e.target,t.target)||e.index-t.index}function j(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function B(e,t){return F(e)==F(t)?"bottom"==e.circularLinkType?N(e,t):_(e,t):F(t)-F(e)}function F(e){return e.target.column-e.source.column}function z(e,t){return H(e)==H(t)}function H(e){return e.y0-e.y1>0?"up":"down"}function Y(e,t,n,o,a){let i=e;var c=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,c))});var s=r.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),X(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),X(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+a+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-a-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==r&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?N:_);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(l=i.links.filter(function(e){return e.target.column==r&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?I:$),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+a+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-a-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,a=(t+n)/2;return"M"+t+","+r+"C"+a+","+r+" "+a+","+o+" "+n+","+o}(e)}),i}function X(e,t,r){e.sort(B);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var a=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=a+e._circularWidth/2;else{for(var i=0;n.length>i;i++){var c=n[i];if(c!==e&&c.circularPathData&&void 0!==c.circularPathData.verticalBuffer&&G(e,c)){var s=c.circularPathData.verticalBuffer+(c._circularWidth||c.width)/2+r;a=s>a?s:a}}e.circularPathData.verticalBuffer=a+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function Z(e){return e.nodes}function K(e){return e.links}function Q(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var a=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?O(t,n)-O(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==O(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,o,a,i){var c=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,l=i;l>0;--l)u(s*=.99,n),d();function u(t,n){var o=c.length;c.forEach(function(a){var i=a.length,c=a[0].depth;a.forEach(function(a){var s;if(a.sourceLinks.length||a.targetLinks.length)if(a.partOfCycle&&O(a,n)>0){var l=r.mean(a.sourceLinks,S),u=r.mean(a.targetLinks,D),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-P(a))*t*.3;a.y0+=h,a.y1+=h}}else if(0==c&&1==i)a.y0=e.y1/2-(s=a.y1-a.y0)/2,a.y1=e.y1/2+s/2;else if(c==o-1&&1==i)a.y0=e.y1/2-(s=a.y1-a.y0)/2,a.y1=e.y1/2+s/2;else if(1==a.targetLinks.length&&1==a.targetLinks[0].source.sourceLinks.length)s=a.y1-a.y0,a.y0=a.targetLinks[0].source.y0,a.y1=a.y0+s;else{var f=r.mean(a.sourceLinks,S),y=r.mean(a.targetLinks,D),g=((f&&y?(f+y)/2:f||y)-P(a))*t;a.y0+=g,a.y1+=g}})})}function d(){c.forEach(function(r){var n,i,c,s=e.y0,l=r.length;for(r.sort(t||j),c=0;l>c;++c)(i=s-(n=r[c]).y0)>0&&(n.y0+=i,n.y1+=i),s=n.y1+o;if((i=s-o-e.y1)>0)for(s=n.y0-=i,n.y1-=i,c=l-2;c>=0;--c)(i=(n=r[c]).y1+a-s)>0&&(n.y0-=i,n.y1-=i),s=n.y0})}}function U(e){e.nodes.forEach(function(e){e.sourceLinks.sort(R),e.targetLinks.sort(C)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,a=24,i=8,c=null,s=V,l=W,u=void 0,d=32,h=2,f=Z,y=K;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof o&&(o=e.target=p(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var a=e.links[o],i=a.source.index,c=a.target.index;n[i]||(n[i]=[]),n[c]||(n[c]=[]),-1===n[i].indexOf(c)&&n[i].push(c)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var l={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){A(e,t)!=A(o.source,t)&&A(e,t)!=A(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,M),r.sum(e.targetLinks,M)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,o,a;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var i=0,c=t(e.nodes[0]);e.nodes.forEach(function(e){i=t(e)==c?i:i+1,c=t(e)==c?c:t(e),e.column=i})}for(n=e.nodes,o=[],a=0;n.length;++a,n=o,o=[])n.forEach(function(e){e.depth=a,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],a=0;n.length;++a,n=o,o=[])n.forEach(function(e){e.height=a,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,a):e.column})}(f,u,l);var y=i;if(null!==c){var g=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(g,function(e){return e.length});m>1&&(y=Math.max(1,(o-t)*c/(m-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var a=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=a,e.links.forEach(function(t){t.width=t.value*e.ky});var i=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,a),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return A(r.source,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!z(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var a=e.y0;n.forEach(function(e){e.y0=a+e.width/2,a+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var a=r+1,i=0;o>a;a++)i+=n[a].width;t.y0=e.y1-i-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return A(r.target,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!z(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=L(t,e);return e.y0-r}if(t.source.column>e.source.column)return L(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var a=e.y0;n.forEach(function(e){e.y1=a+e.width/2,a+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var a=r+1,i=0;o>a;a++)i+=n[a].width;t.y1=e.y1-i-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,o=!1,a=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(a=!0)}),0==o||0==a){var i=r.min(t,function(e){return e.y0}),c=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(c-i);function l(t){return(t-i)/(c-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),Y(f,s,h,10,8)}(g),g}return g.update=function(e){return U(e),Y(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(a=+e,g):a},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(c=+e,g):c},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:q(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:q(e),g):l},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],g):[[e,t],[n,o]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],g):[n-e,o-t]},g}const te=e=>{let r,n,o,a,i,c,s,l,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,a=e.y0+e.sankeyWidth/2,i=e.source.y1,c=e.target.y0,s=t.interpolateNumber(i,c),l=s(.5),u=s(.5),`M${r},${i}C${r},${l} ${n},${u} ${n},${c}L${o},${c}C${o},${u} ${a},${l} ${a},${i}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),o=s(.5),a=s(.5),i=e.y0-e.sankeyWidth/2,c=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${i}C${o},${i} ${a},${c} ${n},${c}L${n},${l}C${a},${l} ${o},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,a=o.targetX,i=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const c=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(a-o.leftFullExtent)));return`M${t},${n-r}L${t+c},${n-r}L${t+c},${n+r}L${t},${n+r}ZM${a},${i-r}L${a-s},${i-r}L${a-s},${i+r}L${a},${i+r}Z`}const a=o.sourceX,i=o.sourceY,c=o.targetX,s=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${a},${i-h*r}L${l},${i-h*r}L${l+n},${i-h*r+h*f}L${l+n},${d+h*n-h*f}L${l+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${c},${s-h*r}L${c},${s+h*r}L${u+n},${s+h*r}L${u+n},${d-h*n}L${l-n},${d-h*n}L${l-n},${i+h*r}L${a},${i+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(T))-1:0},justify:W},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,a,i,c,s,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(o=r.nodeWidth)&&void 0!==o?o:15,y=null!==(a=r.nodePaddingRatio)&&void 0!==a?a:.05,g=null!==(i=r.iterations)&&void 0!==i?i:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||W).nodeId(e=>e.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const a=n.circularPathData,i=(null!==(s=null!==(c=n._circularWidth)&&void 0!==c?c:n.width)&&void 0!==s?s:0)/2;e>a.leftFullExtent-i&&(e=a.leftFullExtent-i),a.rightFullExtent+i>t&&(t=a.rightFullExtent+i),r>a.verticalFullExtent-i&&(r=a.verticalFullExtent-i),a.verticalFullExtent+i>o&&(o=a.verticalFullExtent+i)}const a=t-e,i=o-r,u=n[0],d=n[1];if(a>0&&i>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/a,d/i),n=-e*t+(u-a*t)/2,o=-r*t+(d-i*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(l=e.width)&&void 0!==l?l:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",a=k.get(`${n}\0${o}`);if(a){a.y0=e.y0,a.y1=e.y1,a.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,a.circular=!!e.circular,a.circularPathData=e.circularPathData,a._circularWidth=e._circularWidth,a._circularStub=e._circularStub,a.path=e.path,a.circularLinkType=e.circularLinkType,a.direction=d;const t=x.get(n),r=x.get(o);t&&(a.source=t),r&&(a.target=r)}}},buildScene(e,t,r,o){var a,i,c,s;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(a=r.edgeOpacity)&&void 0!==a?a:.5,f=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},o={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const o=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=o.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+a},${t.sourceY-r}L${t.sourceX+a},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+a}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let a;if(a=e.circular&&e.circularPathData?re(e):te(e),!a)continue;const l={fill:o.fill||n,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};v.push({type:"bezier",pathD:a,bezierCache:e.bezier,style:l,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const a=t?t(r):r.id;if(!a)continue;let i,c,s;"down"===l?(i=r.x0+e/2,c=r.y1+14,s="middle"):(o[0]/2>r.x0+e/2?(i=r.x0-6,s="end"):(i=r.x1+6,s="start"),c=r.y0+n/2),m.push({x:i,y:c,text:a+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},ae={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var a,i;if(0===e.length)return;const c=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,l=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const r=e[t];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;r.x=l+e*Math.cos(n),r.y=u+e*Math.sin(n)}}const d=ie(r.nodeSize,r.nodeSizeRange,e),h=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),f=n[1]/n[0],y=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",o.forceX(n[0]/2).strength(.1*f)).force("y",o.forceY(n[1]/2).strength(.1));if(y.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));y.force("link",h),y.force("link").links(e)}.1>y.alpha()&&y.alpha(1),y.stop();for(let e=0;c>e;++e)y.tick();const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var a,i,c;const s=r.nodeStyle,l=r.edgeStyle,u=ie(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=l?l(e):{},o={stroke:n.stroke||"#999",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(c=n.opacity)&&void 0!==c?c:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:o,datum:e})}if(!1!==r.showLabels){const t=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ie(e,t,n){var o,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const c=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>c[0];const l=null!==(o=r.min(s))&&void 0!==o?o:0,u=null!==(i=r.max(s))&&void 0!==i?i:1;if(l===u)return()=>(c[0]+c[1])/2;const d=a.scaleLinear().domain([l,u]).range(c).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?c[0]:d(n)}}const ce=n.schemeCategory10,se={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:a=20,sortGroups:s}=r,l=Math.min(n[0],n[1])/2,u=l-a,d=n[0]/2,h=n[1]/2,f=(y=r.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=g.get("string"==typeof e.source?e.source:e.source.id),n=g.get(t);if(void 0===r||void 0===n)continue;const o=f(e);v[r][n]=o}const m=i.chord().padAngle(o);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const L=new Map;for(const e of t)L.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=L.get(`${r}\0${n}`)||L.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,a;const{groupWidth:c=20,edgeOpacity:s=.5}=r,l=Math.min(n[0],n[1])/2,u=l-c,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:ce,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=i.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let a;a=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const i=f?f(r):{},c={fill:a,stroke:i.stroke||"black",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:i.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:c,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=le(r,d,h);let o="#999";if(y)o=y(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===g&&r?o=v.get(r.id)||o:t&&(o=v.get(t.id)||o)}const i=y?y(e):{},c={fill:o,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};x.push({type:"ribbon",pathD:n,style:c,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=l+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const a=(e.startAngle+e.endAngle)/2,i=a-Math.PI/2;k.push({x:d+Math.cos(i)*n,y:h+Math.sin(i)*n,text:o+"",anchor:a>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function le(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let a=0;for(;n.length>a;){const e=n[a];if("M"===e||"L"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)o.push(Number(n[a])+t+""),a++,n.length>a&&!isNaN(Number(n[a]))&&(o.push(Number(n[a])+r+""),a++);else if("C"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)for(let e=0;3>e&&n.length>a&&!isNaN(Number(n[a]));e++)o.push(Number(n[a])+t+""),a++,n.length>a&&!isNaN(Number(n[a]))&&(o.push(Number(n[a])+r+""),a++);else if("Q"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)for(let e=0;2>e&&n.length>a&&!isNaN(Number(n[a]));e++)o.push(Number(n[a])+t+""),a++,n.length>a&&!isNaN(Number(n[a]))&&(o.push(Number(n[a])+r+""),a++);else if("A"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&(o.push(Number(n[a])+t+""),a++),n.length>a&&(o.push(Number(n[a])+r+""),a++);else"Z"===e||"z"===e?(o.push(e),a++):(o.push(n[a]),a++)}return o.join(" ")}const ue={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const a=r.__hierarchyRoot;if(!a)return;const i=r.chartType,c=(l=r.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(a,c);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(i){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",a=s.tree();a.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),a(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",a=s.cluster();a.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),a(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var o,a;const i=null!==(o=t.padding)&&void 0!==o?o:4,c=null!==(a=t.paddingTop)&&void 0!==a?a:0,l=s.treemap().size([r,n]).tile(s.treemapBinary).padding(i);c>0&&l.paddingTop(c),l(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var o;const a=null!==(o=t.padding)&&void 0!==o?o:4;s.pack().size([r,n]).padding(a)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var o;s.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],a={id:ge(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?de(a,n,r):"treemap"===i||"partition"===i?he(a,n):"circlepack"===i&&fe(a,n),a.__hierarchyNode=n,e.push(a),g.set(n,a)}if("tree"===i||"cluster"===i)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),a=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,a){var i,c,s,l,u;const d=[],h=[],f=[],y=r.treeOrientation||"vertical",g="radial"===y,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;g&&(e+=p,n+=v);const a=o(t);let c=a.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(c=b[t.depth%b.length]);const s={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(c=r.edgeOpacity)&&void 0!==c?c:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,o=t.y,i=r.x,c=r.y;g&&(n+=p,o+=v,i+=p,c+=v);const u=ye(n,o,i,c,y),d=a(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=pe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,a,i=r.x,c=r.y;if(g&&(i+=p,c+=v),g){const e=i-p,t=c-v,r=Math.sqrt(e*e+t*t);r>0?(n=i+e/r*10,o=c+t/r*10,a=0>e?"end":"start"):(n=i,o=c-12,a="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=i-m-6,a="end"):(n=i+m+6,a="start"),o=c):(n=i,o=c+m+14,a="middle");f.push({x:n,y:o,text:e+"",anchor:a,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,o,a);case"treemap":case"partition":return function(e,t,r,n){var o,a;const i=[],c=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,a=r.y1-r.y0;if(0>=e||0>=a)continue;const c=n(r);let l=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(l=s[r.depth%s.length]);const u={fill:l,stroke:c.stroke||"#fff",strokeWidth:null!==(o=c.strokeWidth)&&void 0!==o?o:1,opacity:c.opacity};i.push({type:"rect",x:r.x0,y:r.y0,w:e,h:a,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;if((null===(a=n.data)||void 0===a?void 0:a.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const i=r?r(n):n.id;i&&(30>e||16>o||c.push({x:n.x0+e/2,y:n.y0+o/2,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,o)/6))}))}}return{sceneNodes:i,sceneEdges:[],labels:c}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,a,i,c,s;const l=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const c=n(r);let s=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:c.stroke||"#fff",strokeWidth:null!==(a=c.strokeWidth)&&void 0!==a?a:1,opacity:null!==(i=c.opacity)&&void 0!==i?i:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const t of e){const e=null!==(c=t.__radius)&&void 0!==c?c:5,n=r?r(t):t.id;if(!n)continue;if(15>e)continue;const o=!((null===(s=t.data)||void 0===s?void 0:s.children)&&t.data.children.length>0);u.push({x:t.x,y:o?t.y:t.y-e+14,text:n+"",anchor:"middle",baseline:o?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:o?void 0:"#000",stroke:o?void 0:"#fff",strokeWidth:o?void 0:3,paintOrder:o?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function de(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function he(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function fe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ye(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}function ge(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function pe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}const ve={sankey:oe,force:ae,chord:se,tree:ue,cluster:ue,treemap:ue,circlepack:ue,partition:ue};function me(e){return ve[e]}class be{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new f(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:a="target",valueAccessor:i="value"}=this.config,c="function"==typeof n?n:e=>e[n],s="function"==typeof o?o:e=>e[o],l="function"==typeof a?a:e=>e[a],u="function"==typeof i?i:e=>{var t;return null!==(t=e[i])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=c(t)+"";this.nodes.set(e,Object.assign(Object.assign({},xe(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=l(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},xe(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},xe(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let a=!1;const i="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=i,this.nodes.has(t)||(this.nodes.set(t,xe(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,a=!0),this.nodes.has(r)||(this.nodes.set(r,xe(r)),this.nodeTimestamps.set(r,i),this.tension+=this.tensionConfig.newNode,a=!0);const c=this.edgeKey(t,r),s=this.edges.get(c);return s?(s.value+=n,this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.weightChange):(this.edges.set(c,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.newEdge,a=!0),o||a||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=me(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(r,n,this.config,e),t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear();for(const e of r)this.nodes.set(e.id,e);for(const e of n)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const o=new Set(this.nodes.keys()),a=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of o)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)o.has(e)||this.removedNodes.add(e);for(const e of a)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)a.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=o,this.previousEdgeKeys=a,this.layoutVersion++}buildScene(e){const t=me(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:a,labels:i}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=a,this.labels=i}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),r=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*r,e.x1=e._prevX1+(e._targetX1-e._prevX1)*r,e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*r);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const a=r.y1,i=n.y0,c=t.interpolateNumber(a,i);return{circular:!1,points:[{x:e.y0,y:a},{x:e.y0,y:c(.5)},{x:e.y1,y:c(.5)},{x:e.y1,y:i}],halfWidth:o}}const a=r.x1,i=n.x0,c=t.interpolateNumber(a,i);return{circular:!1,points:[{x:a,y:e.y0},{x:c(.5),y:e.y0},{x:c(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],a=r.x-t.x,i=r.y-t.y;o.push([t,{x:t.x+a/3,y:t.y+i/3},{x:t.x+2*a/3,y:t.y+2*i/3},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,a;const i=this.config.pulse;if(!i)return;const c=null!==(t=i.duration)&&void 0!==t?t:500,s=null!==(r=i.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(n=i.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;c>o&&(t._pulseIntensity=1-o/c,t._pulseColor=s,t._pulseGlowRadius=l)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,i="object"==typeof r.target?null===(a=r.target)||void 0===a?void 0:a.id:r.target;if(!n||!i)continue;const l=this.edgeTimestamps.get(`${n}\0${i}`);if(!l)continue;const u=e-l;c>u&&(t._pulseIntensity=1-u/c,t._pulseColor=s)}}applyDecay(){var e,t,r,n,o;const a=this.config.decay;if(!a)return;const i=null!==(e=a.minOpacity)&&void 0!==e?e:.1,c=this.nodeTimestamps.size;if(1>=c)return;const s=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),l=new Map;for(let e=0;s.length>e;e++)l.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=l.get(s);if(void 0===u)continue;const d=c-1-u;let h;switch(a.type){case"linear":h=i+(1-d/(c-1))*(1-i);break;case"exponential":{const e=null!==(t=a.halfLife)&&void 0!==t?t:c/2;h=i+Math.pow(.5,d/e)*(1-i);break}case"step":h=(null!==(r=a.stepThreshold)&&void 0!==r?r:.5*c)>d?1:i;break;default:h=1}const f=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",a=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",i=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const c=this.nodes.get(r);if(!c)continue;const s=n.metric(c);let l=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(l=o):l=a,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),i&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=l,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function xe(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ke(e,t,r,n,o=30){let a=null,i=o,c=1/0;for(const t of e){const e=we(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;c>r&&(a=e,c=r)}else i>e.distance&&(a=e,i=e.distance)}if(a)return a;for(const e of t){const t=Le(e,r,n);t&&i>t.distance&&(a=t,i=t.distance)}return a}function we(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,o=r-e.cy,a=Math.sqrt(n*n+o*o);return a>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r);case"rect":return function(e,t,r){return e.x>t||t>e.x+e.w||e.y>r||r>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,a=Math.sqrt(n*n+o*o);if(e.innerR-2>a||a>e.outerR+2)return null;let i=Math.atan2(o,n);0>i&&(i+=2*Math.PI);let c,s=e.startAngle,l=e.endAngle;if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),c=s>l?i>=s||l>=i:i>=s&&l>=i,c){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}function Le(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;try{const a=new Path2D(e.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(a,t,r)){const a="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:a&&i?(a.x1+i.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,a=n*n+o*o;if(0===a)return null;let i=((t-e.x1)*n+(r-e.y1)*o)/a;i=Math.max(0,Math.min(1,i));const c=e.x1+i*n,s=e.y1+i*o,l=Math.sqrt(Math.pow(t-c,2)+Math.pow(r-s,2));return l>5?null:{type:"edge",datum:e.datum,x:c,y:s,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=document.createElement("canvas").getContext("2d");if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0}}catch(e){}return null}(e,t,r);default:return null}}function Ee(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:a,labels:i,title:c,legend:s,foregroundGraphics:l,annotations:d,svgAnnotationRules:h}=e;return u.createElement("svg",{width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${a.left},${a.top})`},i.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),d&&h&&d.map((e,n)=>{const o=h(e,n,{width:t,height:r});return o?u.createElement(u.Fragment,{key:"annotation-"+n},o):null}),l),c&&"string"==typeof c?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},c):c?u.createElement("foreignObject",{x:0,y:0,width:n,height:a.top},c):null,s&&"object"==typeof s&&"legendGroups"in s?u.createElement("g",{transform:`translate(${n-a.right+10},${a.top})`},s.legendGroups.map((e,t)=>{var r;return u.createElement("g",{key:"legend-group-"+t},null===(r=e.items)||void 0===r?void 0:r.map((e,t)=>u.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},u.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),u.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):s?u.createElement("g",{transform:`translate(${n-a.right+10},${a.top})`},s):null)}function Ae(e,t){var r,n,o,a,i,c;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const i=t._gradient;if(i){const o=e.createLinearGradient(i.x0,0,i.x1,0),a=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,c=t.style.fill;o.addColorStop(0,1===i.from?c:"transparent"),o.addColorStop(1,1===i.to?c:"transparent"),e.fillStyle=o,e.globalAlpha=a}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(a=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==a?a:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.5*(null!==(c=t.style.opacity)&&void 0!==c?c:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function De(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Se(e,t){var r,n,o,a;if(!t.pathD)return;e.save();const i=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(i)),e.restore()}function Pe(e,t){var r,n;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}Ee.displayName="NetworkSVGOverlay";const Me={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},Oe=n.schemeCategory10,Te=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function We(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):Oe[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Oe.length]}function _e(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>e[t]))),o=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return a.scaleOrdinal().domain(n).range(r).unknown("#999");const i=Me[r]||Me.category10;if(o&&"function"==typeof i)return e=>i(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(i)?i:Oe;return a.scaleOrdinal().domain(n).range(e).unknown("#999")}}const Ne={top:20,right:80,bottom:20,left:80},$e={top:40,right:40,bottom:40,left:40},Ie=new Set(["chord","force","circlepack"]),Ce=[800,600],Re={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function je({data:e}){var t,r,n,o,a,i;if("edge"===e.type){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:Re},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const c=e.data,s=null==c?void 0:c.__hierarchyNode;if(s){const e=[];let a=s;for(;a;){const i=null!==(o=null!==(r=null===(t=a.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=a.data)||void 0===n?void 0:n.id)&&void 0!==o?o:c.id;null!=i&&e.unshift(i+""),a=a.parent}e.length>1&&e.shift();const i=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:Re},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===i?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof c.value?c.value.toLocaleString():c.value+""))}const l=((null===(a=c.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(i=c.targetLinks)||void 0===i?void 0:i.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:Re},u.createElement("div",{style:{fontWeight:600}},c.id),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const Be=e.forwardRef(function(t,r){const{chartType:n,nodes:o,edges:a,data:i,initialEdges:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:f="target",valueAccessor:y="value",childrenAccessor:g,hierarchySum:p,orientation:v="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,iterations:k=300,forceStrength:w=.1,padAngle:L=.01,groupWidth:E=20,sortGroups:A,edgeSort:D,treeOrientation:S="vertical",edgeType:P="curve",padding:M,paddingTop:O,tensionConfig:T,showParticles:W=!1,particleStyle:_,nodeStyle:N,edgeStyle:$,colorBy:I,colorScheme:C="category10",edgeColorBy:R="source",edgeOpacity:j=.5,colorByDepth:B=!1,nodeSize:F=8,nodeSizeRange:z=[5,20],nodeLabel:H,showLabels:Y=!0,size:X=Ce,responsiveWidth:G,responsiveHeight:q,margin:V,className:Z,background:K,enableHover:Q=!0,tooltipContent:J,customHoverBehavior:U,customClickBehavior:ee,onObservation:te,chartId:re,onTopologyChange:ne,annotations:oe,svgAnnotationRules:ae,legend:ie,title:ce,foregroundGraphics:se,backgroundGraphics:le,decay:ue,pulse:de,staleness:he,thresholds:fe}=t,ye=Ie.has(n)?$e:Ne,[ge,pe]=function(t,r,n){const o=e.useRef(null),[a,i]=e.useState(null);return e.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;i(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&a?a.w:t[0],n&&a?a.h:t[1]]]}(X,G,q),ve=Object.assign(Object.assign({},ye),V),me=pe[0]-ve.left-ve.right,xe=pe[1]-ve.top-ve.bottom,we=e.useMemo(()=>Object.assign(Object.assign({},d),T),[T]),Le=e.useMemo(()=>Object.assign(Object.assign({},h),_),[_]),Me=e.useMemo(()=>({chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:f,valueAccessor:y,childrenAccessor:g,hierarchySum:p,orientation:v,nodeAlign:m,nodePaddingRatio:b,nodeWidth:x,iterations:k,forceStrength:w,padAngle:L,groupWidth:E,sortGroups:A,edgeSort:D,treeOrientation:S,edgeType:P,padding:M,paddingTop:O,tensionConfig:we,showParticles:W,particleStyle:Le,nodeStyle:N,edgeStyle:$,nodeLabel:H,showLabels:Y,colorBy:I,colorScheme:C,edgeColorBy:R,edgeOpacity:j,colorByDepth:B,nodeSize:F,nodeSizeRange:z,decay:ue,pulse:de,staleness:he,thresholds:fe}),[n,s,l,f,y,g,p,v,m,b,x,k,w,L,E,A,D,S,P,M,O,we,W,Le,N,$,H,Y,I,C,R,j,B,F,z,ue,de,he,fe]),Te=e.useRef(null),We=e.useRef(0),_e=e.useRef(0),Re=e.useRef(!0),Be=e.useRef(()=>{}),Fe=e.useRef(null);Fe.current||(Fe.current=new be(Me));const[ze,He]=e.useState(null),[Ye,Xe]=e.useState(0),[Ge,qe]=e.useState(0),[Ve,Ze]=e.useState(!1),Ke=e.useRef(null),Qe=e.useRef(new Map),Je=e.useRef(0),Ue=e.useCallback(e=>{if("function"==typeof I)return I(e);if("string"==typeof I&&e.data){const t=e.data[I];if(void 0!==t){if(!Qe.current.has(t+"")){const e=Array.isArray(C)?C:Oe;Qe.current.set(t+"",e[Je.current++%e.length])}return Qe.current.get(t+"")}}if(!Qe.current.has(e.id)){const t=Array.isArray(C)?C:Oe;Qe.current.set(e.id,t[Je.current++%t.length])}return Qe.current.get(e.id)},[I,C]),et=e.useCallback(e=>{if("function"==typeof R)return R(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===R&&r?Ue(r):t?Ue(t):"#999"},[R,Ue]),tt=e.useCallback(e=>{if(!(null==_?void 0:_.colorBy))return et(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Le.colorBy&&r?Ue(r):t?Ue(t):"#999"},[null==_?void 0:_.colorBy,Le.colorBy,Ue,et]),rt="sankey"===n&&W||!!de,nt=e.useCallback(()=>{We.current&&!rt||We.current||(We.current=requestAnimationFrame(()=>Be.current()))},[rt]);e.useEffect(()=>{var e;null===(e=Fe.current)||void 0===e||e.updateConfig(Me),Re.current=!0,nt()},[Me,nt]);const ot=e.useCallback(()=>{const e=Fe.current;if(!e)return;e.runLayout([me,xe]),e.buildScene([me,xe]),Re.current=!0;const t=Array.isArray(C)?C:Oe,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];Qe.current.has(n.id)||Qe.current.set(n.id,t[e%t.length])}if(Je.current=r.length,Xe(e.layoutVersion),ne){const{nodes:t,edges:r}=e.getLayoutData();ne(t,r)}},[me,xe,ne,C]),at=e.useCallback(e=>{const t=Fe.current;t&&(t.ingestEdge(e)&&ot(),nt())},[ot,nt]),it=e.useCallback(e=>{const t=Fe.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&ot(),nt()},[ot,nt]),ct=e.useCallback(()=>{var e;null===(e=Fe.current)||void 0===e||e.clear(),Qe.current.clear(),Je.current=0,Xe(0),He(null),Ke.current=null,Re.current=!0,nt()},[nt]),st=e.useCallback(()=>{const e=Fe.current;e&&(e.tension+=999,ot(),nt())},[ot,nt]);e.useImperativeHandle(r,()=>({push:at,pushMany:it,clear:ct,getTopology:()=>{var e,t;return null!==(t=null===(e=Fe.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Fe.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:st,getTension:()=>{var e,t;return null!==(t=null===(e=Fe.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[at,it,ct,st]);const lt=["tree","cluster","treemap","circlepack","partition"].includes(n),ut=lt?i||(Array.isArray(a)?void 0:a):void 0;e.useEffect(()=>{const e=Fe.current;if(e)if(lt&&ut)e.ingestHierarchy(ut,[me,xe]),e.buildScene([me,xe]),Re.current=!0,nt();else{const t=o||[],r=Array.isArray(a)?a:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[me,xe]),e.buildScene([me,xe]);const n=Array.isArray(C)?C:Oe,i=Array.from(e.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Qe.current.has(t.id)||Qe.current.set(t.id,n[e%n.length])}Je.current=i.length,Re.current=!0,nt()}},[o,a,i,ut,lt,me,xe,Me,nt,C]),e.useEffect(()=>{c&&c.length>0&&it(c)},[]);const dt=e.useCallback(e=>{if(U&&U(e),te){const t=Date.now();te(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:re}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:re})}},[U,te,re]),ht=e.useCallback(e=>{if(ee&&ee(e),te){const t=Date.now();te(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:re}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:re})}},[ee,te,re]),ft=e.useRef(()=>{}),yt=e.useRef(()=>{});ft.current=e=>{if(!Q)return;const t=Te.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ve.left,o=e.clientY-r.top-ve.top;if(0>n||n>me||0>o||o>xe)return void(Ke.current&&(Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),nt()));const a=Fe.current;if(!a)return;const i=ke(a.sceneNodes,a.sceneEdges,n,o);if(!i)return void(Ke.current&&(Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),nt()));const c={type:i.type,data:i.datum,x:i.x,y:i.y};Ke.current=c,He(c),dt&&(dt(c),Re.current=!0),nt()},yt.current=()=>{Ke.current&&(Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),nt())};const gt=e.useRef(()=>{});gt.current=e=>{if(!ee&&!te)return;const t=Te.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ve.left,o=e.clientY-r.top-ve.top;if(0>n||n>me||0>o||o>xe)return;const a=Fe.current;if(!a)return;const i=ke(a.sceneNodes,a.sceneEdges,n,o);ht(i?{type:i.type,data:i.datum,x:i.x,y:i.y}:null)},e.useCallback(e=>ft.current(e),[]);const pt=e.useCallback(()=>yt.current(),[]),vt=e.useCallback(e=>gt.current(e),[]),mt=e.useRef(-1),bt=e.useCallback(e=>{const t=Fe.current;if(!t)return;const r=function(e){const t=[];for(const r of e)"circle"===r.type&&null!=r.cx?t.push({x:r.cx,y:r.cy,datum:r.datum}):"rect"===r.type&&null!=r.x?t.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum}):"arc"===r.type&&null!=r.cx&&t.push({x:r.cx,y:r.cy,datum:r.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return;const n=mt.current,o=function(e,t,r){switch(e){case"ArrowRight":case"ArrowDown":return r-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return r-1;case"Escape":return-1;default:return null}}(e.key,0>n?-1:n,r.length);if(null===o)return;if(e.preventDefault(),0>o)return mt.current=-1,Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),void nt();const a=0>n?0:o;mt.current=a;const i=r[a],c={type:"node",data:i.datum,x:i.x,y:i.y};Ke.current=c,He(c),dt&&(dt(c),Re.current=!0),nt()},[dt,nt]),xt=e.useCallback(e=>{mt.current=-1,ft.current(e)},[]);Be.current=()=>{var e,t,r;We.current=0;const n=Te.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const a=Fe.current;if(!a)return;const i=performance.now(),c=_e.current?Math.min((i-_e.current)/1e3,.1):.016;_e.current=i;const s=a.advanceTransition(i);(s||Re.current)&&a.buildScene([me,xe]);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=pe[0]*l,n.height=pe[1]*l,n.style.width=pe[0]+"px",n.style.height=pe[1]+"px",o.scale(l,l),o.translate(ve.left,ve.top),o.clearRect(-ve.left,-ve.top,pe[0],pe[1]),K&&(o.fillStyle=K,o.fillRect(0,0,me,xe)),ue&&a.applyDecay(),de&&a.applyPulse(i),fe&&a.applyThresholds(i),a.applyTopologyDiff(i);const u=null!==(e=null==he?void 0:he.threshold)&&void 0!==e?e:5e3,d=he&&a.lastIngestTime>0&&i-a.lastIngestTime>u;if(d&&(o.globalAlpha=null!==(t=null==he?void 0:he.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Ae(e,r);break;case"line":De(e,r);break;case"ribbon":Se(e,r);break;case"curved":Pe(e,r)}}(o,a.sceneEdges),function(e,t){var r,n,o;for(const a of t){if("rect"!==a.type)continue;const t=a;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(o,a.sceneNodes),function(e,t){var r,n,o,a;for(const i of t){if("circle"!==i.type)continue;const t=i;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const r=null!==(a=t._pulseGlowRadius)&&void 0!==a?a:4,n=t.r+r*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,n,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(o,a.sceneNodes),function(e,t){var r,n,o;for(const a of t){if("arc"!==a.type)continue;const t=a;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(o,a.sceneNodes),W&&a.particlePool&&!d){const e=Array.from(a.edges.values());if(e.length>0){!function(e,t,r,n){var o,a;const i=null!==(o=n.spawnRate)&&void 0!==o?o:h.spawnRate,c=null!==(a=n.maxPerEdge)&&void 0!==a?a:h.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=c)continue;const a=o.value*i*r*(o.bezier.circular?.3:1),s=Math.floor(a),l=a-s;let u=s;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<c;t++)e.spawn(n)}}(a.particlePool,e,c,Le);const t=.5*(null!==(r=Le.speedMultiplier)&&void 0!==r?r:1);let n;if(Le.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}a.particlePool.step(c,t,e,n),function(e,t,r,n,o){var a,i;const c=null!==(a=n.radius)&&void 0!==a?a:h.radius,s=null!==(i=n.opacity)&&void 0!==i?i:h.opacity;e.globalAlpha=s;for(let a=0;t.particles.length>a;a++){const i=t.particles[a];if(!i.active)continue;const s=r[i.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(s);e.beginPath(),e.arc(i.x,i.y,c,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(o,a.particlePool,e,Le,tt)}}d&&(o.globalAlpha=1);const f=Re.current;Re.current=!1,(f||s)&&qe(e=>e+1),(rt||s||a.hasActivePulses||a.hasActiveThresholds||a.hasActiveTopologyDiff)&&(We.current=requestAnimationFrame(()=>Be.current()))},e.useEffect(()=>(nt(),()=>{We.current&&cancelAnimationFrame(We.current)}),[nt]),e.useEffect(()=>{Re.current=!0,nt()},[n,me,xe,K,nt]),e.useEffect(()=>{if(!he)return;const e=setInterval(()=>{var e;const t=Fe.current;if(!t||0===t.lastIngestTime)return;const r="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=he.threshold)&&void 0!==e?e:5e3,o=r-t.lastIngestTime>n;o!==Ve&&(Ze(o),Re.current=!0,nt())},1e3);return()=>clearInterval(e)},[he,Ve,nt]);const kt=Q&&ze?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ve.left+ze.x,top:ve.top+ze.y,transform:`translate(${ze.x>.6*me?"calc(-100% - 12px)":"12px"}, ${.3*xe>ze.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},J?J(ze):u.createElement(je,{data:ze})):null,wt=Fe.current;return u.createElement("div",{ref:ge,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":"string"==typeof ce?ce:"Network chart",tabIndex:0,style:{position:"relative",width:G?"100%":pe[0],height:q?"100%":pe[1]},onMouseMove:Q?xt:void 0,onMouseLeave:Q?pt:void 0,onClick:ee||te?vt:void 0,onKeyDown:bt},le&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:pe[0],height:pe[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${ve.left},${ve.top})`},le)),u.createElement("canvas",{ref:Te,style:{position:"absolute",top:0,left:0}}),u.createElement(Ee,{width:me,height:xe,totalWidth:pe[0],totalHeight:pe[1],margin:ve,labels:(null==wt?void 0:wt.labels)||[],title:ce,legend:ie,foregroundGraphics:se,annotations:oe,svgAnnotationRules:ae,annotationFrame:Ge}),kt,(null==he?void 0:he.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===he.badgePosition?{top:4,left:4}:"bottom-left"===he.badgePosition?{bottom:4,left:4}:"bottom-right"===he.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ve?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ve?"STALE":"LIVE"))});Be.displayName="StreamNetworkFrame";const Fe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function ze(e,t){return"function"==typeof t?t(e):e[t]}function He(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Ye(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:r,format:n,style:o={},className:a=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let i;const c=[];if(r){const t=ze(e,r);i=He(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,o,a;"string"==typeof t?(r=t,o=t,a=n):(r=t.label,o=t.accessor||t.key||"",a=t.format||n);const i=ze(e,o);c.push({label:r,value:He(i,a)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){i=He(e[r],n);break}if(!i){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(i=He(e[t[0]],n))}}const s=Object.assign(Object.assign({},Fe),o);return u.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:s},i&&u.createElement("div",{style:{fontWeight:c.length>0?"bold":"normal"}},i),c.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&i?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}(e)))}const Xe=e.createContext(null);function Ge(t){const r=e.createContext(null),n=qe(t);return[function({children:n}){const o=e.useMemo(()=>qe(t),[]);return u.createElement(r.Provider,{value:o,children:n})},t=>{var o;const a=null!==(o=e.useContext(r))&&void 0!==o?o:n;return function(t,r){const[n,o]=e.useState(r);return e.useLayoutEffect(()=>t(()=>o(r)),[t]),n}(a.subscribe,()=>t(a.getState()))}]}function qe(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function Ve(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function Ze(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Ke,Qe]=Ge(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Ze(n,t),a=new Map(o.clauses);return a.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:a})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),a=new Map(n.clauses);return a.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:a})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=Ze(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}}));function Je(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,a=Qe(e=>e.selections.get(o)),i=Qe(e=>e.setClause),c=Qe(e=>e.clearClause),s=e.useMemo(()=>!!a&&a.clauses.size>0,[a]);return{predicate:e.useMemo(()=>a&&0!==a.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(Ve(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(a,n):()=>!0,[a,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};i(o,{clientId:n,type:"point",fields:t})},[n,o,i]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};i(o,{clientId:n,type:"interval",fields:t})},[n,o,i]),clear:e.useCallback(()=>{c(o,n)},[c,o,n]),clientId:n}}const[Ue,et]=Ge(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),tt="#007bff";function rt(t,r,n="category10"){const o=e.useContext(Xe);return e.useMemo(()=>{if(r&&"function"!=typeof r)return o&&Object.keys(o).length>0?e=>o[e]||_e(t,r,n)(e):_e(t,r,n)},[t,r,n,o])}function nt({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:a,chartType:i,chartId:c}){const s=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(r,n),l=Je({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:a,selectPoints:i,clear:c}=Je({name:r});return{onHover:e.useCallback(e=>{if(!e)return void c();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&i(t)},[n,i,c,r]),predicate:o,isActive:a}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),d=et(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:l.isActive,predicate:l.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(a||d){const r={timestamp:Date.now(),chartType:i||"unknown",chartId:c};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const i=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});a&&a(i),d&&d(i)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});a&&a(e),d&&d(e)}}},[r,u,a,i,c,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(a||d){const n={timestamp:Date.now(),chartType:i||"unknown",chartId:c};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const i=Object.assign(Object.assign({},n),{type:"click",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});a&&a(i),d&&d(i)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});a&&a(e),d&&d(e)}}},[a,d,i,c])}}const ot={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function at(e,t,r){var n,o,a,i,c,s;const l=ot[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?l.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?l.height:r.height,showAxes:l.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:l.showGrid,enableHover:null!==(i=t.enableHover)&&void 0!==i?i:!!t.linkedHover||l.enableHover,showLegend:null!==(c=t.showLegend)&&void 0!==c?c:l.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:l.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:l.marginDefaults}}function it({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function ct({data:e,dataLabel:t="data"}){return null==e?`No ${t} provided. Pass a hierarchical data object to the ${t} prop.`:null}function st({nodes:e,edges:t,nodesRequired:r=!1,edgesRequired:n=!0,accessors:o}){if(n&&(!t||!Array.isArray(t)||0===t.length))return"No edges provided. Pass a non-empty array to the edges prop.";if(r&&(!e||!Array.isArray(e)||0===e.length))return"No nodes provided. Pass a non-empty array to the nodes prop.";if(o&&e&&e.length>0)for(const t of(a=e).length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a)if(t&&"object"==typeof t)for(const[e,r]of Object.entries(o))if(r&&"string"==typeof r&&!(r in t))return`${e} "${r}" not found in node data. Available fields: ${Object.keys(t).join(", ")}.`;var a;return null}function lt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:a,margin:i,className:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:y="category10",nodeSize:g=8,nodeSizeRange:p=[5,20],edgeWidth:v=1,edgeColor:m="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:L={},onObservation:E,chartId:A,selection:D,linkedHover:S}=t,P=n.width,M=n.height,O=n.enableHover,T=n.showLegend,W=null!==(r=n.showLabels)&&void 0!==r&&r,_=n.title,N=o||[],$=a||[],I=rt(N,f,y),C=e.useMemo(()=>e=>{const t={};return t.fill=f?We(e.data||e,f,I):tt,"number"==typeof g&&(t.r=g),t},[f,I,g]),R=e.useMemo(()=>e=>({stroke:m,strokeWidth:"number"==typeof v?v:"function"==typeof v?v(e):e[v]||1,opacity:b}),[v,m,b]),j=e.useMemo(()=>{if(W&&h)return"function"==typeof h?h:e=>e[h]},[W,h]),{legend:B,margin:F}=function({data:t,colorBy:r,colorScale:n,showLegend:o,userMargin:a,defaults:i={top:50,bottom:60,left:70,right:40}}){const c=void 0!==o?o:!!r,s=e.useMemo(()=>{if(c&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:a}){const i=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(o=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),i=a?n(a,t,r):r?r(o):"#000000";return{label:o+"",color:i}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==o&&(t.stroke=o),void 0!==a&&(t.strokeWidth=a),t},type:"fill",items:i,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:We})},[c,r,t,n]),l=e.useMemo(()=>{const e=Object.assign(Object.assign({},i),a);return s&&120>e.right&&(e.right=120),e},[i,a,s]);return{legend:s,margin:l}}({data:N,colorBy:f,colorScale:I,showLegend:T,userMargin:i,defaults:n.marginDefaults}),{customHoverBehavior:z}=nt({selection:D,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ForceDirectedGraph",chartId:A}),H=st({componentName:"ForceDirectedGraph",nodes:o,edges:a,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:s}});return H?u.createElement(it,{componentName:"ForceDirectedGraph",message:H,width:P,height:M}):u.createElement(Be,Object.assign({chartType:"force",nodes:N,edges:$,size:[P,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:d,iterations:x,forceStrength:k,nodeStyle:C,edgeStyle:R,colorBy:f,colorScheme:y,nodeSize:g,nodeSizeRange:p,nodeLabel:j,showLabels:W,enableHover:O,tooltipContent:w?e=>Ye(w)(e.data):void 0,customHoverBehavior:S||E?z:void 0,legend:B,className:c,title:_},L))}function ut(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function dt(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],a="function"==typeof n?n(e):e[n];o.add(t),o.add(a)}),Array.from(o).map(e=>({id:e}))}function ht(e){return"function"==typeof e?e:t=>t[e]||1}function ft({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:a={}}){return i=>{const c=Object.assign({fillOpacity:o},a);if("function"==typeof e)c.fill=e(i);else if("source"===e){const e="object"==typeof i.source?i.source:null;t&&e?c.fill=We(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof i.target?i.target:null;t&&e?c.fill=We(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else"gradient"===e&&(c.fill="#999",c.fillOpacity=.7*o);return c}}function yt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:o,edges:a,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",orientation:p="horizontal",nodeAlign:v="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:L,frameProps:E={},onObservation:A,chartId:D,selection:S,linkedHover:P}=t,M=n.width,O=n.height,T=n.enableHover,W=null===(r=n.showLabels)||void 0===r||r,_=n.title,N=a||[],$=e.useMemo(()=>dt(o,N,s,l),[o,N,s,l]),I=rt($,f,y),C=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?We(e.data||e,f,I):"#4d430c",t},[f,I]),R=e.useMemo(()=>ft({edgeColorBy:g,colorBy:f,colorScale:I,nodeStyleFn:C,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,I,C,k]),j=e.useMemo(()=>{if(!W)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[W,x,h]),B=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:F,customClickBehavior:z}=nt({selection:S,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:A,chartType:"SankeyDiagram",chartId:D}),H=st({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return H?u.createElement(it,{componentName:"SankeyDiagram",message:H,width:M,height:O}):u.createElement(Be,Object.assign({chartType:"sankey",nodes:$,edges:N,size:[M,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,orientation:p,nodeAlign:v,nodePaddingRatio:m,nodeWidth:b,nodeStyle:C,edgeStyle:R,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:k,edgeSort:w,nodeLabel:j,showLabels:W,enableHover:T,tooltipContent:L?e=>Ye(L)(e.data):void 0,customHoverBehavior:P||A?F:void 0,customClickBehavior:A?z:void 0,className:c,title:_},E))}function gt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:a,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",padAngle:p=.01,groupWidth:v=20,sortGroups:m,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:L,chartId:E,selection:A,linkedHover:D}=t,S=n.width,P=n.height,M=n.enableHover,O=null===(r=n.showLabels)||void 0===r||r,T=n.title,W=a||[],_=e.useMemo(()=>dt(o,W,s,l),[o,W,s,l]),N=rt(_,f,y),$=e.useMemo(()=>(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=We(e.data||e,f,N);else{const a=Array.isArray(y)?y:Me[y]||Oe,i=Array.isArray(a)?a:Oe,c=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=i[c%i.length]}return o},[f,N,y]),I=e.useMemo(()=>ft({edgeColorBy:g,colorBy:f,colorScale:N,nodeStyleFn:$,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,N,$,x]),C=e.useMemo(()=>{if(!O)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[O,b,h]),R=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:j}=nt({selection:A,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,chartType:"ChordDiagram",chartId:E}),B=st({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return B?u.createElement(it,{componentName:"ChordDiagram",message:B,width:S,height:P}):u.createElement(Be,Object.assign({chartType:"chord",nodes:_,edges:W,size:[S,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,padAngle:p,groupWidth:v,sortGroups:m,nodeStyle:$,edgeStyle:I,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:x,nodeLabel:C,showLabels:O,enableHover:M,tooltipContent:k?e=>Ye(k)(e.data):void 0,customHoverBehavior:D||L?j:void 0,className:c,title:T},w))}function pt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:i,layout:c="tree",orientation:s="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:y="category10",colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:L,linkedHover:E}=t,A=n.width,D=n.height,S=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,M=n.title,O=rt(e.useMemo(()=>ut(o,l),[o,l]),g?void 0:f,y),T=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Te[(e.depth||0)%Te.length]:f?We(e.data||e,f,O):tt,t},[f,g,O]),W=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),_=e.useMemo(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return ht(d)},[c,d]),N=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:$}=nt({selection:L,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),I=ct({componentName:"TreeDiagram",data:o});return I?u.createElement(it,{componentName:"TreeDiagram",message:I,width:A,height:D}):u.createElement(Be,Object.assign({chartType:c,data:o,size:[A,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:N,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:_,treeOrientation:s,edgeType:p,nodeStyle:T,edgeStyle:W,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:P?v||h:void 0,showLabels:P,enableHover:S,tooltipContent:b?e=>Ye(b)(e.data):void 0,customHoverBehavior:E||k?$:void 0,className:i,title:M},x))}function vt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:a,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:y="leaf",nodeLabel:g,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:L}=t,E=n.width,A=n.height,D=n.enableHover,S=null===(r=n.showLabels)||void 0===r||r,P=n.title,{activeSelectionHook:M,customHoverBehavior:O}=nt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:L}),T=e.useCallback(e=>{if(!e)return O(null);const t=e.data||e;O({data:(null==t?void 0:t.data)||t})},[O]),W=rt(e.useMemo(()=>ut(o,c),[o,c]),f?void 0:d,h),_=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?Te[(e.depth||0)%Te.length]:d?We(e.data||e,d,W):tt,t},[d,f,W]),N=e.useMemo(()=>M?e=>{var t,r;const n=Object.assign({},_(e));return M.isActive&&(M.predicate(e.data||e)?(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle):(n.fillOpacity=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2,n.strokeOpacity=null!==(r=null==x?void 0:x.unselectedOpacity)&&void 0!==r?r:.2,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle))),n}:_,[_,M,x]),$=e.useMemo(()=>ht(s),[s]),I=void 0!==v?v:S&&"parent"===y?18:void 0,C=Object.assign(Object.assign({},n.marginDefaults),a),R=ct({componentName:"Treemap",data:o});return R?u.createElement(it,{componentName:"Treemap",message:R,width:E,height:A}):u.createElement(Be,Object.assign({chartType:"treemap",data:o,size:[E,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:$,padding:p,paddingTop:I,nodeStyle:N,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:S?g||l:void 0,showLabels:S,enableHover:D,tooltipContent:m?e=>Ye(m)(e.data):void 0},(k||w)&&{customHoverBehavior:T},{className:i,title:P},b))}function mt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:y,circleOpacity:g=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x,selection:k,linkedHover:w}=t,L=n.width,E=n.height,A=n.enableHover,D=null===(r=n.showLabels)||void 0===r||r,S=n.title,P=rt(e.useMemo(()=>ut(o,c),[o,c]),f?void 0:d,h),M=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?Te[(e.depth||0)%Te.length]:d?We(e.data||e,d,P):tt,t},[d,f,P,g]),O=e.useMemo(()=>ht(s),[s]),T=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:W}=nt({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),_=ct({componentName:"CirclePack",data:o});return _?u.createElement(it,{componentName:"CirclePack",message:_,width:L,height:E}):u.createElement(Be,Object.assign({chartType:"circlepack",data:o,size:[L,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:O,padding:p,nodeStyle:M,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:D?y||l:void 0,showLabels:D,enableHover:A,tooltipContent:v?e=>Ye(v)(e.data):void 0,customHoverBehavior:w||b?W:void 0,className:i,title:S},m))}lt.displayName="ForceDirectedGraph",yt.displayName="SankeyDiagram",gt.displayName="ChordDiagram",pt.displayName="TreeDiagram",vt.displayName="Treemap",mt.displayName="CirclePack",exports.ChordDiagram=gt,exports.CirclePack=mt,exports.ForceDirectedGraph=lt,exports.SankeyDiagram=yt,exports.StreamNetworkFrame=Be,exports.TreeDiagram=pt,exports.Treemap=vt;