semiotic 3.8.8 → 3.8.9
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.
- package/CLAUDE.md +5 -4
- package/README.md +44 -44
- package/ai/schema.json +263 -1
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/dist/chunk-chunk-2X3FJCME.module.min.js +1 -0
- package/dist/{chunk-chunk-UEZ6SHW5.module.min.js → chunk-chunk-2ZHHWZQM.module.min.js} +1 -1
- package/dist/chunk-chunk-5ZON5NMV.module.min.js +2 -0
- package/dist/{chunk-chunk-L6FFYGYS.module.min.js → chunk-chunk-6S3YGYW7.module.min.js} +1 -1
- package/dist/chunk-chunk-7C5EDZ3Z.module.min.js +2 -0
- package/dist/chunk-chunk-A3I4HBD5.module.min.js +1 -0
- package/dist/{chunk-chunk-4MLLQUGW.module.min.js → chunk-chunk-AFQHURLO.module.min.js} +1 -1
- package/dist/{chunk-chunk-OG3TTJGJ.module.min.js → chunk-chunk-DDB4TLQG.module.min.js} +1 -1
- package/dist/{chunk-chunk-W5HWGQMD.module.min.js → chunk-chunk-DTH3SUOU.module.min.js} +1 -1
- package/dist/{chunk-chunk-H5IFO6CU.module.min.js → chunk-chunk-DVCWU7MT.module.min.js} +1 -1
- package/dist/{chunk-chunk-JRHXQGEV.module.min.js → chunk-chunk-FSIHAW6L.module.min.js} +1 -1
- package/dist/{chunk-chunk-BWV55BZK.module.min.js → chunk-chunk-G2RGVEYY.module.min.js} +1 -1
- package/dist/chunk-chunk-HAJVODLO.module.min.js +2 -0
- package/dist/{chunk-chunk-BZNOAHJV.module.min.js → chunk-chunk-HIV7AW2V.module.min.js} +1 -1
- package/dist/{chunk-chunk-LJDH3WV3.module.min.js → chunk-chunk-JZAMMSQQ.module.min.js} +1 -1
- package/dist/{chunk-chunk-VUWYT7DY.module.min.js → chunk-chunk-MXMRXSCI.module.min.js} +1 -1
- package/dist/chunk-chunk-MXVBXFKW.module.min.js +2 -0
- package/dist/{chunk-chunk-7LE56WAE.module.min.js → chunk-chunk-OFAP623Y.module.min.js} +1 -1
- package/dist/{chunk-chunk-SFLUSZ73.module.min.js → chunk-chunk-OHLRAEQZ.module.min.js} +1 -1
- package/dist/{chunk-chunk-CD6PVVS3.module.min.js → chunk-chunk-PRNXOCYZ.module.min.js} +1 -1
- package/dist/chunk-chunk-RLKZVJMQ.module.min.js +2 -0
- package/dist/chunk-chunk-SK2TQMG4.module.min.js +2 -0
- package/dist/chunk-chunk-SKLYXNYW.module.min.js +2 -0
- package/dist/{chunk-chunk-57RBPDBQ.module.min.js → chunk-chunk-U4NZCU5T.module.min.js} +1 -1
- package/dist/{chunk-chunk-QQJNG23C.module.min.js → chunk-chunk-VKL6DI43.module.min.js} +1 -1
- package/dist/chunk-chunk-W62673ZE.module.min.js +1 -0
- package/dist/{chunk-chunk-WSDJFBKX.module.min.js → chunk-chunk-XCC25CZZ.module.min.js} +1 -1
- package/dist/{chunk-chunk-AF53TBSN.module.min.js → chunk-chunk-XECNOUZY.module.min.js} +1 -1
- package/dist/{chunk-chunk-FC3NZWYR.module.min.js → chunk-chunk-XYZDTYAF.module.min.js} +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +54 -1
- package/dist/components/charts/physics/chainReactionTypes.d.ts +1 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +1 -1
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
- package/dist/components/charts/shared/formatUtils.d.ts +40 -9
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +1 -0
- package/dist/components/charts/shared/types.d.ts +8 -1
- package/dist/components/semiotic-utils-core.d.ts +1 -0
- package/dist/components/semiotic.d.ts +4 -3
- package/dist/components/stream/GeoTileRenderer.d.ts +1 -0
- package/dist/components/stream/canvasSetup.d.ts +15 -4
- package/dist/components/stream/geoTypes.d.ts +2 -0
- package/dist/components/stream/networkFramePaint.d.ts +8 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalTypes.d.ts +2 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +2 -0
- package/dist/components/stream/pipelineConfig.d.ts +2 -0
- package/dist/components/stream/pipelineDomainResolution.d.ts +1 -1
- package/dist/components/stream/types.d.ts +8 -1
- package/dist/components/stream/useCanvasFrameHost.d.ts +9 -0
- package/dist/components/stream/xyFrameAxisTypes.d.ts +5 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.d.ts +1 -0
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic.d.ts +4 -3
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-chunk-3GCILWPB.module.min.js +0 -2
- package/dist/chunk-chunk-46KRGJQP.module.min.js +0 -1
- package/dist/chunk-chunk-7T25U75Z.module.min.js +0 -2
- package/dist/chunk-chunk-BTZYH2IE.module.min.js +0 -1
- package/dist/chunk-chunk-FRGBMTZR.module.min.js +0 -1
- package/dist/chunk-chunk-HCNDE26Q.module.min.js +0 -2
- package/dist/chunk-chunk-JJ4BSUYL.module.min.js +0 -2
- package/dist/chunk-chunk-N3Q33XCB.module.min.js +0 -2
- package/dist/chunk-chunk-RGJ6TKAH.module.min.js +0 -2
- package/dist/chunk-chunk-WGROBM3I.module.min.js +0 -2
package/dist/network.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,s=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))a.call(e,l)||l===i||n(e,l,{get:()=>t[l],enumerable:!(s=r(t,l))||s.enumerable});return e},l=(e,r,o)=>(o=null!=e?t(i(e)):{},s(!r&&e&&e.__esModule?o:n(o,"default",{value:e,enumerable:!0}),e)),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{ChordDiagram:()=>nc,CirclePack:()=>hc,DEFAULT_HIT_RADIUS:()=>Md,ForceDirectedGraph:()=>Bl,NetworkCustomChart:()=>wd,OrbitDiagram:()=>yc,ProcessSankey:()=>bd,SankeyDiagram:()=>Jl,StreamNetworkFrame:()=>Cs,TreeDiagram:()=>ic,Treemap:()=>cc,composeStyleRules:()=>Pl,diagnoseProcessSankeyLayout:()=>Tu,diagnoseProcessSankeyProps:()=>Nu,explainProcessSankeyLayout:()=>ju,formatProcessSankeyIssue:()=>Sc,glyphExtent:()=>mn,glyphPlacement:()=>yn,hatchFillId:()=>Wo,hatchPatternDef:()=>zo,inventoryAtTime:()=>Pu,isHatchFill:()=>Oo,makeNodeRuleContext:()=>Cl,makeRuleValueResolver:()=>Al,matchesThreshold:()=>Tl,networkHitTarget:()=>Ad,resolveResponsiveRules:()=>Us,resolveStyleRules:()=>Nl,resolveSvgFill:()=>Fo,responsiveRuleMatches:()=>Vs,ruleMatches:()=>jl,toProcessSankeyTime:()=>Iu,useCustomLayoutSelection:()=>dn,useForceLayout:()=>Ql,validateProcessSankey:()=>wc}),module.exports=(e=c,s(n({},"__esModule",{value:!0}),e));var u=l(require("react")),d=require("react");function h(e){return Array.isArray(e)?e[0]:e}function f(e,t,n,r){return{data:h(e),x:t,y:n,__semioticHoverData:!0,...r}}var g={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},p={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},y=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=n[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?m(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function m(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];b(c,u,d,h,l,o);const f=h.x-c.x,g=h.y-c.y,p=Math.sqrt(f*f+g*g);if(p>.001){const e=f/p;o.x+=-g/p*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,a,s]=e.points;b(o,i,a,s,t,r);const l=s.x-o.x,c=s.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function b(e,t,n,r,o,i){const a=1-o,s=a*a,l=s*a,c=o*o,u=c*o;i.x=l*e.x+3*s*o*t.x+3*a*c*n.x+u*r.x,i.y=l*e.y+3*s*o*t.y+3*a*c*n.y+u*r.y}function v(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function x(e,t){var n,r=[],o=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(r=s[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[r=s[e][t]];h||(a[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var p=f[g];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(r[t]=0|Math.min(r[t],r[p])),0>a[p]||s[t].push(a[p])}i[t]=g}else{if(r[t]===n[t]){var y=[],m=[],b=0;for(g=l.length-1;g>=0;--g){var v=l[g];if(o[v]=!1,y.push(v),m.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){l.length=g;break}}d.push(y);var x=Array(b);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--b]=m[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&c.push(g[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],n=a);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var p=0;s[g].length>p;p++){var y=s[g][p];i[+y]=!1,a[y]={}}c(n),n+=1}else n=h}return t?void 0:r}function k(e){return e.y0-e.y1>0?"up":"down"}function w(e,t){return t(e.source)==t(e.target)}function S(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function M(e){return e.target.x0-e.source.x1}function A(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1-r:e.y1+r}function C(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1+r:e.y1-r}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function T(e,t){return t(e)}function j(e){return P(e.source)}function N(e){return P(e.target)}function P(e){return(e.y0+e.y1)/2}function I(e){return e.virtual?0:e.value}function E(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!w(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!w(e,t)?r+1:r}),n+r}function R(e){return e.target.depth}function D(e,t){return e.sourceLinks.length?e.depth:t-1}function _(e,t){return e.y0-t.y0}function O(e,t){return t.y0-e.y0}function $(e,t){return e.y1-t.y1}function W(e,t){return t.y1-e.y1}function B(e,t){return F(e.source,t.source)||e.index-t.index}function z(e,t){return F(e.target,t.target)||e.index-t.index}function F(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function H(e,t){return q(e)==q(t)?"bottom"==e.circularLinkType?O(e,t):_(e,t):q(t)-q(e)}function q(e){return e.target.column-e.source.column}function Y(e,t){return X(e)==X(t)}function X(e){return e.y0-e.y1>0?"up":"down"}var G=require("d3-array");function V(e,t,n,r,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=(0,G.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}),U(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),U(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+r,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,w(e,t)&&S(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+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 a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?O:_);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?W:$),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*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,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function U(e,t,n){e.sort(H);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(w(e,t)&&S(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Q(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Q(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var K=require("d3-array");function Z(e){return function(){return e}}function J(e){return e.index}function ee(e){return e.nodes}function te(e){return e.links}function ne(e,t,n){var r=(0,K.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=P(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=P(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=s.get(e),r=s.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?E(t,n)-E(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.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==E(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function re(e,t,n,r,o,i){var a=(0,K.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,n),u();function c(t,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&E(o,n)>0){var l=(0,K.mean)(o.sourceLinks,N),c=(0,K.mean)(o.targetLinks,j),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-P(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-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 h=(0,K.mean)(o.sourceLinks,N),f=(0,K.mean)(o.targetLinks,j),g=((h&&f?(h+f)/2:h||f)-P(o))*t;o.y0+=g,o.y1+=g}})})}function u(){a.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||F),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+r;if((a=l-r-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+o-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function oe(e){e.nodes.forEach(function(e){e.sourceLinks.sort(z),e.targetLinks.sort(B)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=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=n+e.width/2,n+=e.width)})})}function ie(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,s=J,l=D,c=void 0,u=32,d=2,h=ee,f=te;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=r,h.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(0,K.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=v(n,r)),"object"!=typeof o&&(o=e.target=v(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=x(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,r=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:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){T(e,t)!=T(o.source,t)&&T(e,t)!=T(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),w(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,K.sum)(e.sourceLinks,I),(0,K.sum)(e.targetLinks,I)),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)})})}(h),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,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?n(e,i):e.column})}(h,c,l);var f=i;if(null!==a){var g=(0,K.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=(0,K.max)(g,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*a/(p-1)))}(function(e,t,n){var r=(0,K.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=(0,K.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,K.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,K.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})})(h,f,o),ne(h,c,s),re(h,c,s,f,f,u),oe(h),V(h,s,d,10,8),ne(h,c,s),re(h,c,s,f,f,u),oe(h),V(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return T(n.source,t)==T(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Y(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=A(t,e);return e.y1-n}if(t.target.column>e.target.column)return A(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 i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return T(n.target,t)==T(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Y(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=C(t,e);return e.y0-n}if(t.source.column>e.source.column)return C(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 i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=(0,K.min)(t,function(e){return e.y0}),a=(0,K.max)(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),V(h,s,d,10,8)}(g),g}return g.update=function(e){return oe(e),V(e,s,d,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?(a=+e,g):a},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Z(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:Z(e),g):f},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Z(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Z(e),g):l},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(u=+e,g):u},g.circularLinkGap=function(e){return arguments.length?(d=+e,g):d},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}function ae(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function se(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function le(e){const t=e.map(ae),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return se(e,n,r)}if(e>=1){const[e,r,o]=t[n];return se(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return se(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}var ce=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ue=le(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),de=le(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),he=le(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),fe=le(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ge=le(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),pe=le(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ye={blues:ue,reds:de,greens:he,viridis:le(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oranges:fe,purples:ge,greys:pe,plasma:le(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:le(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:le(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:le(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:le(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])},me=(le(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),le(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),le(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),le(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),le(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),require("d3-interpolate"));function be(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(n+r)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${l},${i} ${o},${i}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}require("d3-shape");var ve=e=>{let t,n,r,o,i,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=(0,me.interpolateNumber)(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,d=(0,me.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=be({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function xe(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+s},${o-t}L${n+s},${o+t}L${n},${o+t}ZM${i},${a-t}L${i-l},${a-t}L${i-l},${a+t}L${i},${a+t}Z`}const o=r.sourceX,i=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${o},${i-d*t}L${l},${i-d*t}L${l+n},${i-d*t+d*h}L${l+n},${u+d*n-d*h}L${l+n-h},${u+d*n}L${c-n+h},${u+d*n}L${c-n},${u+d*n-d*h}L${c-n},${s-d*t+d*h}L${c-n+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+n},${s+d*t}L${c+n},${u-d*n}L${l-n},${u-d*n}L${l-n},${i+d*t}L${o},${i+d*t}Z`}var ke=new Set,we=new WeakMap;function Se(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=we.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,we.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ke.has(e)||(ke.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}function Me(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function Ae(e){return"string"==typeof e?e:e.id}var Ce={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(R))-1:0},justify:D},Le={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",a=n.nodeWidth??15,s=n.nodePaddingRatio??.05,l=n.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:Ae(e.source),target:Ae(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const h=ie().extent(d).links(u).nodes(c).nodeAlign(Ce[i]||D).nodeId(e=>e.id).nodeWidth(a).iterations(l);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-n,s=r[0],l=r[1];if(i>0&&a>0&&(0>e||0>n||t>s||o>l)){const t=Math.min(s/i,l/a),r=-e*t+(s-i*t)/2,o=-n*t+(l-a*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of c){const t=f.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 g=new Map;for(const e of t)if(e._edgeKey)g.set(e._edgeKey,e);else{const t=Ae(e.source),n=Ae(e.target);g.set(`${t}\0${n}`,e)}for(const e of u){const t=Ae(e.source),n=Ae(e.target),r=g.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),a=f.get(n);i&&(r.source=i),a&&(r.target=a)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,a=n.edgeStyle,s=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const d=[],h=[],f=[],g=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(Se(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};g.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:a,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){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 o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?g.get(r.id)||u.get(r.id)||o:g.get(t.id)||u.get(t.id)||o;const i=a?a(Se(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-a},${t.targetY-n}L${t.targetX-a},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?xe(e):ve(e),c)&&h.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=Me(n.nodeLabel);for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=t?t(n):n.id;if(!a)continue;let s,l,c;"down"===o?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(s=n.x0-6,c="end"):(s=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:s,y:l,text:a+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}},Te=require("d3-force"),je=require("d3-scale");function Ne(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var Pe=()=>"undefined"!=typeof performance?performance.now():Date.now();function Ie(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ee(e,t){const n=e();return Number.isFinite(n)?n:t}var Re=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Pe,this.lastWallTime=Ee(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Ee(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Pe;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Ee(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Ie(n)))}},De={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=c?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const r=_e(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Oe(e.id),i=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(i),e.y=n/r.length+a*Math.sin(i)}else{const t=Oe(e.id),n=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=i+r*Math.cos(n),e.y=a+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5)*s,o=n*t;r.x=i+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}const f=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=$e(n.nodeSize,n.nodeSizeRange,e),p=e=>g(e);if(f>0){const c=new Map,u=new Map;for(const t of e)c.set(t.id,0),u.set(t.id,t);for(const e of t){const t=Ae(e.source),n=Ae(e.target);c.set(t,(c.get(t)??0)+1),c.set(n,(c.get(n)??0)+1)}const d=(0,Te.forceLink)().strength(e=>{const t=e.weight,n=Ae(e.source),r=Ae(e.target),i=Math.max(1,Math.min(c.get(n)??1,c.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,r=(t?p(t):0)+(n?p(n):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),g=(0,Te.forceSimulation)();if(void 0===n.random&&void 0===n.seed||g.randomSource(n.random??Ie(n.seed)),g.force("charge",(0,Te.forceManyBody)().strength(e=>{const t=c.get(e.id)??0;return-15*s*p(e)*Math.sqrt(t+1)})).force("collide",(0,Te.forceCollide)(e=>p(e)+3*s).strength(.9).iterations(2)).force("center",(0,Te.forceCenter)(i,a).strength(.8)).force("x",(0,Te.forceX)(i).strength(l)).force("y",(0,Te.forceY)(a).strength(l)).force("bounds",function(e,t,n=2,r=.6){let o=[];const i=i=>{const a=r*Math.max(i,.2);for(const r of o){const o=r.x??e[0]/2,i=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+n,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),g=o+s,p=i+l;u>g?r.vx=s+(u-g)*a:g>d&&(r.vx=s+(d-g)*a),h>p?r.vy=l+(h-p)*a:p>f&&(r.vy=l+(f-p)*a)}};return i.initialize=e=>{o=e},i}(r,p)),g.nodes(e),t.length>0){const e=t.map(e=>({...e,source:Ae(e.source),target:Ae(e.target)}));d.links(e),g.force("link",d)}h?g.alpha(.3):.1>g.alpha()&&g.alpha(1),g.stop();for(let e=0;f>e;++e)g.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=p(t),n=f>0?2:0,o=Math.min(r[0]/2,e+n),i=Math.min(r[1]/2,e+n);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(i,Math.min(r[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,a=$e(n.nodeSize,n.nodeSizeRange,e),s=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});const c=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(Se(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=Me(n.nodeLabel);for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=a(Se(n,"nodeSize"));d.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};function _e(e,t,n){const r=[];for(const o of t){const t=Ae(o.source),i=Ae(o.target);let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Oe(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function $e(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,a]=Ne(o);if(i===a)return()=>(r[0]+r[1])/2;const s=(0,je.scaleLinear)().domain([i,a]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:s(n)}}var We=require("d3-chord"),Be=require("d3-shape"),ze=ce,Fe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(r[0],r[1])/2,l=s-i,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t=Ae(e.source),n=Ae(e.target),r=f.get(t),o=f.get(n);if(void 0===r||void 0===o)continue;const i=d(e);p[r][o]=i}const y=(0,We.chord)().padAngle(o);a&&y.sortGroups(a);const m=y(p),b=m.groups,v=(0,Be.arc)().innerRadius(l).outerRadius(s);for(const t of b){const n=e[t.index],r=v.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t=Ae(e.source),n=Ae(e.target),r=x.get(t),o=x.get(n);r&&(e.source=r),o&&(e.target=o)}const k=new Map;for(const e of t){const t=Ae(e.source),n=Ae(e.target);k.set(`${t}\0${n}`,e)}for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ze,g=new Map;e.forEach((e,t)=>{g.set(e.id,f[t%f.length])});const p=(0,We.ribbon)().radius(s),y=[],m=[],b=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(Se(n,"nodeStyle")).fill||g.get(n.id)||f[t%f.length]:g.get(n.id)||f[t%f.length];const i=u?u(Se(n,"nodeStyle")):{};y.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const o=He(r,l,c);let a=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)a=d(Se(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?a=g.get(n.id)||a:t&&(a=g.get(t.id)||a)}const s=d?d(Se(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==n.showLabels){const t=Me(n.nodeLabel),r=a+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;b.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:y,sceneEdges:m,labels:b}}};function He(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}var qe=require("d3-hierarchy"),Ye=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xe(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Ge(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Ve(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Ue(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Ye}function Qe(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ke(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Ze={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=(0,qe.hierarchy)(o,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,qe.tree)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,qe.cluster)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,a=(0,qe.treemap)().size([n,r]).tile(qe.treemapBinary).padding(o);i>0&&a.paddingTop(i),a(e)}(c,n,u,d);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;(0,qe.pack)().size([n,r]).padding(o)(e)}(c,n,u,d);break;case"partition":!function(e,t,n,r){(0,qe.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,d)}const h=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const r=h[t],o={id:Ge(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Je(o,r,n):"treemap"===i||"partition"===i?et(o,r):"circlepack"===i&&tt(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const a=[],s=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(g=n.nodeSize)?g:5;var g;for(const t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);const i=o(Se(t,"nodeStyle"));let s=i.fill||Qe(n);if(n.colorByDepth&&void 0!==t.depth){const e=Ue(n);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:f,style:{fill:s,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.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 o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);const g=Ke(o,a,l,f,c),y=i(Se(e,"edgeStyle"));s.push({type:"curved",pathD:g,style:{fill:"none",stroke:y.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:y.strokeWidth??1.5,opacity:y.opacity??p},datum:e})}if(!1!==n.showLabels){const t=Ve(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,a=n.x,s=n.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,n=Math.sqrt(e*e+t*t);n>0?(r=a+e/n*10,o=s+t/n*10,i=0>e?"end":"start"):(r=a,o=s-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=a-f-6,i="end"):(r=a+f+6,i="start"),o=s):(r=a,o=s+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=r(Se(n,"nodeStyle"));let s=a.fill||Qe(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ue(t);s=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,fillOpacity:a.fillOpacity,strokeOpacity:a.strokeOpacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ve(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;const c=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Se(s,"nodeStyle")).fill||Qe(t);if(t.colorByDepth&&void 0!==s.depth){const e=Ue(t);d=e[s.depth%e.length]}const h="string"==typeof d?Xe(d):t.themeSemantic?.text??"#000";i.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(Se(n,"nodeStyle"));let a=i.fill||Qe(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ue(t);a=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ve(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=n?n(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let l=r(Se(o,"nodeStyle")).fill||Qe(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ue(t);l=e[o.depth%e.length]}if(s){const n="string"==typeof l?Xe(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Je(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(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 et(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 tt(e,t){const n=t.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}var nt=require("d3-shape");function rt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var ot={sankey:Le,force:De,chord:Fe,tree:Ze,cluster:Ze,treemap:Ze,circlepack:Ze,partition:Ze,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=rt(n);h.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function g(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,y=t[1]/2,m=Math.min(t[0],t[1])/2*.85,b=g(a(e));r.push({id:b,x:p,y:y,x0:p,x1:p,y0:y,y1:y,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,p,y){const m=i(t);if(!m?.length)return;const b=m.length;let v=0,x=0,k=0;for(;b>x;)x+=s[Math.min(k,s.length-1)],k++,v++;let w=0;for(let b=0;v>b;b++){const x=s[Math.min(b,s.length-1)],k=m.slice(w,w+x);if(!k.length)break;const S=(b+1)/v,M={id:n,depth:p,data:t,parentId:n},A=y?f/u(M)*S:f*S,C=(0,nt.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),L=d(M);for(let t=0;k.length>t;t++){const i=(C[t].startAngle+C[t].endAngle)/2,s=k[t],u=g(a(s)),d=l+A*Math.sin(i),f=c+A*Math.cos(i)*L;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:s}),h.metaMap.set(u,{ring:A,angle:i,depth:p,parentId:n,eccentricity:L}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,A,p+1,!0)}w+=x}}(e,b,p,y,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=rt(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=a(Se(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=rt(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=s.get(e.parentId);if(!r)continue;const l=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function it(e){return ot[e]}function at(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(at))}function st(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function lt(e,t,n){return e+(t-e)*n}var ct=require("d3-quadtree");function ut(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 dt(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!ht(e))return!1;return!0}return ht(t.points)}function ht(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}var ft=require("d3-interpolate");function gt(e,t,n){if(1>=n)return 1;const r=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}var pt="rgba(34, 197, 94, 0.7)",yt=2e3,mt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function bt(e,t){const n={...e};for(const e of t)n[mt[e]]++;return n}function vt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:bt(n,r)}}var xt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=vt({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=vt(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},kt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],wt=["scene-style","data-paint","accessibility","evidence"],St=(e,t)=>({retainedData:e,invalidations:t}),Mt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],At=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ct=["scene-geometry","data-paint","overlay","accessibility","evidence"],Lt=["scene-style","data-paint","accessibility","evidence"],Tt=["scene-geometry","data-paint","overlay","accessibility","evidence"],jt=[],Nt={chartType:St("rebuild",Mt),nodeIDAccessor:St("rebuild",Mt),sourceAccessor:St("rebuild",Mt),targetAccessor:St("rebuild",Mt),valueAccessor:St("rebuild",Mt),edgeIdAccessor:St("rebuild",Mt),childrenAccessor:St("rebuild",Mt),hierarchySum:St("rebuild",Mt),orientation:St("preserve",At),nodeAlign:St("preserve",At),nodePaddingRatio:St("preserve",At),nodeWidth:St("preserve",At),edgeSort:St("preserve",At),iterations:St("preserve",At),forceStrength:St("preserve",At),padAngle:St("preserve",At),groupWidth:St("preserve",At),sortGroups:St("preserve",At),treeOrientation:St("preserve",At),edgeType:St("preserve",At),padding:St("preserve",At),paddingTop:St("preserve",At),orbitMode:St("preserve",At),orbitSize:St("preserve",At),orbitSpeed:St("preserve",At),orbitRevolution:St("preserve",At),orbitRevolutionStyle:St("preserve",At),orbitEccentricity:St("preserve",At),orbitShowRings:St("preserve",At),orbitAnimated:St("preserve",At),customNetworkLayout:St("preserve",At),layoutConfig:St("preserve",At),nodeSize:St("preserve",Ct),nodeSizeRange:St("preserve",Ct),colorByDepth:St("preserve",Ct),nodeLabel:St("preserve",Tt),showLabels:St("preserve",Tt),labelMode:St("preserve",Tt),nodeStyle:St("preserve",Lt),edgeStyle:St("preserve",Lt),colorBy:St("preserve",Lt),colorScheme:St("preserve",Lt),themeCategorical:St("preserve",Lt),themeSemantic:St("preserve",Lt),edgeColorBy:St("preserve",Lt),edgeOpacity:St("preserve",Lt),showParticles:St("preserve",Lt),particleStyle:St("preserve",Lt),decay:St("preserve",Lt),pulse:St("preserve",Lt),thresholds:St("preserve",Lt),staleness:St("preserve",Lt),layoutSelection:St("preserve",Lt),clock:St("preserve",jt),random:St("preserve",jt),seed:St("preserve",jt),tensionConfig:St("preserve",jt),transition:St("preserve",jt),introAnimation:St("preserve",jt),onLayoutError:St("preserve",jt),__skipForceSimulation:St("preserve",jt),__hierarchyRoot:St("preserve",jt),__orbitState:St("preserve",jt),__previousPositions:St("preserve",jt)},Pt=St("preserve",At),It=class{constructor(){this.tracker=new xt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},kt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},wt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Nt[r]??Pt;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Et=new WeakMap;var Rt=require("d3-scale"),Dt={category10:ce,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ye},_t=ce,Ot="#007bff";function $t(e,t,n=_t){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Dt[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var Wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Bt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],zt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Ft(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||zt.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):_t[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%_t.length]}function Ht(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function qt(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>Ht(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,Rt.scaleOrdinal)().domain(r).range(n).unknown("#999");const i=Dt[n]||Dt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:_t;return(0,Rt.scaleOrdinal)().domain(r).range(e).unknown("#999")}}function Yt(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&Ht(n,e)||"#4e79a7":t=>{if(n){const e=Ht(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Xt({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:a}){const s=$t(e.colorScheme,e.themeCategorical,ce),l={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...s]},resolveColor:Yt(s,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==i,r=function(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}("network",t,n,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}var Gt=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new It,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,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._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...g,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new y(2e3))}currentTime(){return this.config.clock?.()??("undefined"!=typeof performance?performance.now():Date.now())}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...g,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new y(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...ut(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",o=u(n)+"",i=d(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,{...ut(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...ut(o),data:n});const l=`${r}\0${o}\0${e}`,h={source:r,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&dt(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,ut(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,ut(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;l?(l.value+=r,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=it(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&n.length>0&&a>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const a=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=Xt({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;at(r)&&0===n.length&&st(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&st(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=it(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=(0,ct.quadtree)().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=it(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=it(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=lt(e._prevX0,e._targetX0,n),e.x1=lt(e._prevX1,e._targetX1,n),e.y0=lt(e._prevY0,e._targetY0,n),e.y1=lt(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=lt(e._prevY0,e._targetY0,n),e.y1=lt(e._prevY1,e._targetY1,n),e.sankeyWidth=lt(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}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),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,a=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=(0,ft.interpolateNumber)(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(r)},{x:e.y1,y:s(1-r)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=n.x0,s=(0,ft.interpolateNumber)(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(r),y:e.y0},{x:s(1-r),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}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){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const l=i-s;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const a="object"==typeof o.source?o.source?.id:o.source,s="object"==typeof o.target?o.target?.id:o.target;if(!a||!s)continue;const l=e.edgeTimestamps.get(`${a}\0${s}`);if(!l)continue;const c=i-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const a=gt(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*a}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===pt&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=yt)return;const n=1-t/yt;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=pt,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&yt>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const l=t.metric(s);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Gt.QUADTREE_THRESHOLD=500;var Vt=Gt;Object.assign(Vt.prototype,{getLastUpdateResult:function(){return this.updateResults.last},getUpdateSnapshot:function(){return this.updateResults.last},subscribeUpdateResult:function(e){return this.updateResults.subscribe(e)},setLayoutSelection:function(e){this.config.layoutSelection=e},markStylePaintPending:function(){Et.set(this,!0)},consumeStylePaintPending:function(){const e=!0===Et.get(this);return Et.delete(this),e}});var Ut=require("react"),Qt={sceneGeometry:0,layout:0,domain:0};function Kt(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function Zt(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Jt="production"!==process.env.NODE_ENV,en={revisions:Qt,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},tn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=Qt,this.lastObserved=Qt,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Jt&&(this.lastObserved=Zt(this.lastObserved,Kt(e)))}beforeCompute(e,t){if(!Jt)return en;const n=Zt(Kt(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(Jt){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},nn=(0,Ut.memo)(function({store:e,diagnostics:t}){return(0,Ut.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),rn=l(require("react"));function on(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:rn.createElement(rn.Fragment,null,...t)}var an=l(require("react")),sn=require("react/jsx-runtime"),ln={isActive:!1,predicate:()=>!0},cn=an.createContext(null);function un({value:e,children:t}){return(0,sn.jsx)(cn.Provider,{value:e,children:t})}function dn(){return an.useContext(cn)??ln}function hn(e,t){return null!=e?(0,sn.jsx)(un,{value:t,children:e}):e}var fn=require("react"),gn=[40,40],pn=[.5,.5];function yn(e,t){const[n,r]=e.viewBox??gn,[o,i]=e.anchor??pn,a=r>0?r:1,s=Math.max(0,t)/a,l=(n>0?n:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-o*l,offsetY:-i*c}}function mn(e,t){const n=yn(e,t),r=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let o=0;for(const[e,t]of r){const n=Math.sqrt(e*e+t*t);n>o&&(o=n)}return o}function bn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var vn=null;function xn(e){if("undefined"==typeof Path2D)return null;vn||(vn=new Map);const t=vn.get(e);if(t)return t;const n=new Path2D(e);return vn.size>1024&&vn.clear(),vn.set(e,n),n}function kn(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??gn,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:i*(1-s),width:o,height:i*(s-a)}:{x:o*a,y:0,width:o*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function wn(e,t){const n=yn(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Sn(e,t,n,r,o,i=e=>e){for(const a of t.parts){const t=xn(a.d);if(!t)continue;const s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);const c=o?"none"===a.fill?void 0:o:bn(a.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?a.stroke&&"none"!==a.stroke?o:void 0:bn(a.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function Mn(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?An(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?An(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function An(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function Cn(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}var Ln=require("react/jsx-runtime"),Tn="var(--semiotic-focus, #005fcc)";function jn({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!s)if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=(0,Ln.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Tn,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Ln.jsx)("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:Tn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Tn,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Ln.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Ln.jsx)("path",{d:s,fill:"none",stroke:Tn,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Ln.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Nn=l(require("react")),Pn=["name","label","title"],In=["type","kind","category","group","class","status","role","shape"],En=["value","amount","total","count","weight","score"],Rn=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Dn(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function _n(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&Rn.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>Pn.includes(e.lower));const a=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=Dn(l,In),u=Dn(l,En),d=new Set(In),h=new Set(En),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:f}}var On=require("react/jsx-runtime"),$n={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Wn(e,t){return"function"==typeof t?t(e):e[t]}function Bn(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 zn(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=Wn(e,n);a=Bn(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=Wn(e,o);s.push({label:n,value:Bn(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Bn(e[n],r);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Bn(e[t[0]],r))}}const l={...$n,...o};return(0,On.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&(0,On.jsx)("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>(0,On.jsxs)("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&(0,On.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function Fn(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{const n=!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType);let r=h(n?e.data??{}:e);if(!r)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof r?.x0&&"number"==typeof r?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof r?.sankeyWidth)&&r.data&&"object"==typeof r.data&&(r=r.data),!r)return null;if(n&&(void 0!==e.allSeries||void 0!==e.xValue)){const t={...r};void 0!==e.allSeries&&void 0===t.allSeries&&(t.allSeries=e.allSeries),void 0!==e.xValue&&void 0===t.xValue&&(t.xValue=e.xValue),r=t}const o=t(r);return null==o?null:(0,On.jsx)("div",{className:"semiotic-tooltip",style:$n,children:o})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?zn(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:r,style:o={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=Wn(e,n);l.push({value:Bn(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=Bn(Wn(e,o),i);l.push({label:a?n:void 0,value:s})});else{const t=_n(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:Bn(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:a?e.key:void 0,value:Bn(e.value,r)})})}const c={...$n,...o};return Array.isArray(l)&&0!==l.length?(0,On.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>(0,On.jsxs)("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,On.jsxs)("strong",{children:[e.label,s]}),e.value]},t))}):null}}()):zn())}}var Hn=require("react/jsx-runtime");function qn({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=Nn.useRef(null),[u,d]=Nn.useState(null);Nn.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[a,n,r,l]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Nn.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),g=f?null:$n;return l?(0,Hn.jsx)("div",{ref:c,className:f?a:(a+" semiotic-tooltip").trim(),style:{...g||{},position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}var Yn=l(require("react")),Xn=require("react"),Gn=require("react"),Vn=require("react/jsx-runtime");function Un(e){let t=null;const n=()=>(t||(t=(0,Gn.createContext)(null)),t),r=Qn(e);return[function({children:t,initialState:r}){const o=(0,Gn.useRef)(r),i=(0,Gn.useMemo)(()=>Qn(e,o.current),[]),a=n();return(0,Vn.jsx)(a.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=(0,Gn.useContext)(o)??r,a=(0,Gn.useRef)(e);a.current=e;const s=(0,Gn.useRef)({hasValue:!1,value:void 0}),l=(0,Gn.useCallback)(()=>{const e=a.current(i.getState()),n=s.current;return n.hasValue&&t&&t(n.value,e)?n.value:(s.current={hasValue:!0,value:e},e)},[i,t]),c=(0,Gn.useCallback)(()=>a.current(i.getState()),[i]);return(0,Gn.useSyncExternalStore)(i.subscribe,l,c)}]}function Qn(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(Kn(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Kn(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Zn(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function Jn(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:er}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var er=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],tr={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},nr={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},rr={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:er,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function or(e,t){if("light"===t)return tr;if("dark"===t)return nr;if("high-contrast"===t)return rr;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?nr:tr;return Jn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Jn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[ir,ar]=Un(e=>({theme:tr,setTheme(t){e(e=>({theme:or(e.theme,t)}))}})),sr=require("react");var lr=require("react"),cr=new WeakMap,ur=0,dr=!1,hr=null,fr=null;function gr(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),r=n.indexOf(",");if(-1===r){const e=n.trim();return e.startsWith("--")?{name:e}:null}const o=n.slice(0,r).trim(),i=n.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:i||void 0}:null}(t);if(!n)return t;const r=()=>n.fallback?gr(e,n.fallback):t,o=e.canvas;if(!o)return r();!function(){if(dr)return;if("undefined"==typeof window||"undefined"==typeof document)return;dr=!0;const e=()=>{ur++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{hr=window.matchMedia("(prefers-color-scheme: dark)"),fr=e,"function"==typeof hr.addEventListener?hr.addEventListener("change",fr):"function"==typeof hr.addListener&&hr.addListener(fr)}catch{}}();let i=cr.get(o);i&&i.version===ur||(i={version:ur,map:new Map},cr.set(o,i));const a=i.map.get(t);if(void 0!==a)return a;const s=getComputedStyle(o).getPropertyValue(n.name).trim()||r()||t;return i.map.set(t,s),s}var pr="undefined"==typeof window?Xn.useEffect:Xn.useLayoutEffect,yr={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function mr(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function br(e){const t=function(){const[e,t]=(0,sr.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,sr.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,Xn.useRef)(t);n.current=t;const[r,o]=function(e,t,n){const r=(0,lr.useRef)(null),[o,i]=(0,lr.useState)(null);return(0,lr.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,a=!!e.legend&&"top"===e.legendPosition,s=(0,Xn.useMemo)(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,a),[e.marginDefault,e.userMargin,i,a]),l=o[0]-s.left-s.right,c=o[1]-s.top-s.bottom,u=mr(e.foregroundGraphics,o,s),d=mr(e.backgroundGraphics,o,s),h=ar(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+Yn.useId(),y=(0,Xn.useRef)(null);if(!y.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;y.current=new Re({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=y.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const b=(0,Xn.useRef)(null),v=(0,Xn.useRef)(e.frameScheduler??yr);v.current=e.frameScheduler??yr;const x=(0,Xn.useRef)(null),k=(0,Xn.useRef)(!1),w=(0,Xn.useRef)(()=>{}),S=(0,Xn.useCallback)(()=>{if(null!==b.current||k.current)return;const e=v.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),b.current=null,x.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(b.current=r,x.current=e)},[]),M=(0,Xn.useCallback)(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);pr(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,Xn.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,Xn.useEffect)(()=>()=>{M()},[M]);const A=(0,Xn.useRef)(()=>{}),C=(0,Xn.useRef)(()=>{}),L=(0,Xn.useRef)(null),T=(0,Xn.useRef)(null),j=(0,Xn.useRef)(null),N=(0,Xn.useCallback)(()=>{const e=L.current;L.current=null,e&&A.current(e)},[]),P=(0,Xn.useCallback)(e=>{if(L.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===T.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,T.current=null,j.current=null,N()});t||(T.current=n,j.current=e)}},[N]),I=(0,Xn.useCallback)(()=>{L.current=null,null!==T.current&&((j.current??v.current).cancelAnimationFrame(T.current),T.current=null,j.current=null),C.current()},[]);(0,Xn.useEffect)(()=>()=>{L.current=null,null!==T.current&&((j.current??v.current).cancelAnimationFrame(T.current),T.current=null,j.current=null)},[]);const E=e.themeDirtyRef;return pr(()=>{E&&(ur++,E.current=!0,S())},[h,S,E]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:s,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:p,frameRuntime:m,rafRef:b,renderFnRef:w,scheduleRender:S,cancelRender:M,hoverHandlerRef:A,hoverLeaveRef:C,onPointerMove:P,onPointerLeave:I}}var vr=require("react"),xr={fresh:1,aging:.7,stale:.45,expired:.25},kr={alpha:1,band:"fresh",isStale:!1};var wr=require("react/jsx-runtime");function Sr({isStale:e,position:t}){return(0,wr.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var Mr=l(require("react")),Ar=l(require("react"));function Cr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function Lr(e){return"object"==typeof e&&null!==e&&"gradient"in e}var Tr=16,jr=6,Nr=10,Pr=22,Ir=100,Er=10;function Rr(e){return Math.ceil(7*e.length)}function Dr(e,t){if(Cr(e)){const n=Hr(t),r=e.legendGroups.flatMap(e=>[e.label?Rr(e.label):0,...e.items.map(e=>n.swatchSize+n.labelGap+Rr(e.label))]);return Math.max(Ir,...r)}if(Lr(e)){const{gradient:t}=e,n=t.format||(e=>Math.round(100*e)/100+""),r=Math.max(Rr(n(t.domain[0])),Rr(n(t.domain[1]))),o=t.label?Rr(t.label):0;return Math.max(Ir,19+r,o)}return Ir}function _r(e){return(Cr(e)||Lr(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):Er}function Or(e){return Math.max(0,e?.sideGutter??0)}var $r=22,Wr=46,Br=64;function zr(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?Br:Wr:$r:0}function Fr(e,t,n){if(Lr(e))return e.gradient.label?34:26;if(!Cr(e))return 20;const r=Hr(n),o=Math.max(1,n?.maxWidth??t);let i=r.rowHeight;for(const t of e.legendGroups){let e=0,n=0;for(const i of t.items){const t=r.swatchSize+r.labelGap+Rr(i.label),a=0===n?t:n+r.itemGap+t;n>0&&a>o?(e+=1,n=t):n=a}t.items.length>0&&(e+=1),i=Math.max(i,e*r.rowHeight,t.label?Rr(t.label):0)}return i+(e.legendGroups.length>1?16:0)}function Hr(e){const t=Math.max(1,e?.swatchSize??Tr),n=Math.max(t,e?.rowHeight??Pr);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??jr),itemGap:Math.max(0,e?.itemGap??Nr),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}var qr=require("react/jsx-runtime"),Yr={fill:(e,t)=>(0,qr.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,qr.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Xr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Yr[n])(r(e,t),o),i}function Gr({swatchSize:e}){return(0,qr.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Vr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Ur=(e,t,n,r,o,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:b,labelGap:v,rowHeight:x}=u;return f.forEach((e,c)=>{const u=Xr(e,c,d,h,b),k=Vr(e,r,o),w=o&&o.size>0&&o.has(e.label);g.push((0,qr.jsxs)("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&c===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?w||!1:void 0,"aria-current":y&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:y?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(s,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&(0,qr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+v+2+7*e.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,qr.jsx)(Gr,{swatchSize:b}),(0,qr.jsx)("text",{y:b/2,x:b+v,dominantBaseline:"central",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),p+=x}),g};function Qr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Ar.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,qr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return(0,qr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,qr.jsx)("defs",{children:(0,qr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&(0,qr.jsx)("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,qr.jsx)("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,qr.jsx)("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])}),(0,qr.jsx)("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,qr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return(0,qr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,qr.jsx)("text",{x:0,y:-6,textAnchor:"start",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,qr.jsx)("defs",{children:(0,qr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,qr.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,qr.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])}),(0,qr.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])})]})}function Kr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=Hr(d),[f,g]=Ar.useState(0),[p,y]=Ar.useState(0),m=Ar.useCallback((e,t)=>{g(e),y(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const d=[],h=function(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const a=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:a,endY:n}})}(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const g=h[f];d.push((0,qr.jsx)("line",{stroke:"gray",x1:0,y1:g.lineY,x2:t,y2:g.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=g.labelY&&d.push((0,qr.jsx)("text",{y:g.labelY,className:"legend-group-label",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d.push((0,qr.jsx)("g",{className:"legend-item",transform:`translate(0,${g.itemsY})`,children:Ur(e,n,r,o,i,a,s,f,l,c,u)},"legend-group-"+f))}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const p=((e,t,n,r,o,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,p=[],{swatchSize:y,labelGap:m,itemGap:b,rowHeight:v,align:x}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,S=g.map(e=>y+m+7*e.label.length),M=[];let A=0,C=0;S.forEach((e,t)=>{const n=0===C?e:C+b+e;d&&d>0&&C>0&&n>d?(M.push({start:A,end:t,width:C}),A=t,C=e):C=n}),g.length>0&&M.push({start:A,end:g.length,width:C}),M.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=g[d],x=Xr(e,d,h,f,y),M=Vr(e,r,o),A=o&&o.size>0&&o.has(e.label);p.push((0,qr.jsxs)("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?s===i&&d===a?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?A||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(s,d),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&(0,qr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:y+m+2+7*e.label.length,height:y+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,A&&(0,qr.jsx)(Gr,{swatchSize:y}),(0,qr.jsx)("text",{y:y/2,x:y+m,dominantBaseline:"central",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const L=Math.max(0,...M.map(e=>e.width)),T=M.length;return{items:p,offset:L,totalRows:T,totalHeight:T*v}})(e,r,o,i,a,s,l,t,c,u,d,d.maxWidth??n);g+=p.offset+5,f.push({label:e.label,...p,offset:g,totalRows:p.totalRows,totalHeight:p.totalHeight}),h+=g+12});const g=d.maxWidth??n;let p=h>g?0:"center"===d.align?Math.max(0,(g-h)/2):"end"===d.align?Math.max(0,g-h):0;const y=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(y.push((0,qr.jsx)("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),p+=16),y.push((0,qr.jsx)("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&y.push((0,qr.jsx)("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),(0,qr.jsx)("g",{children:y})})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:a,metrics:h}),v=!(!n&&!r);return(0,qr.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==s&&""!==s&&"vertical"===u&&(0,qr.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}var Zr=require("react/jsx-runtime");function Jr(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:a,legendHoverBehavior:s,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i,f=Math.max(0,n-o.left-o.right),g=Math.max(1,h?a?.maxWidth??f:Dr(t,a)),p=_r(t),y=Or(a),m=zr(e.axisChrome,a),b=zr(void 0,a),v=Fr(t,f,a);let x,k;if("left"===i)x=o.left-y-g-p,k=o.top;else if("top"===i)x=o.left,k=o.top-b-p-v;else if("bottom"===i){x=o.left;const e=r-o.bottom;k=Math.max(e+p,Math.min(e+m+p,r-v))}else x=n-o.right+y+p,k=o.top;return(0,Zr.jsx)("g",{transform:`translate(${x}, ${k})`,children:Lr(t)?(0,Zr.jsx)(Qr,{config:t.gradient,orientation:h?"horizontal":"vertical",width:g}):Cr(t)?(0,Zr.jsx)(Kr,{legendGroups:t.legendGroups,title:"",width:g,orientation:h?"horizontal":"vertical",legendLayout:a,customHoverBehavior:s,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t})}var eo=require("react/jsx-runtime"),to={secondary:0,primary:3},no=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function ro(e){return!0===e?._annotationDeferred}function oo(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function io(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function ao(e){return Math.max(.72,.95-.06*e)}var so=l(require("react")),lo=require("react/jsx-runtime");function co(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let a="";for(const e of o)a&&a.length+1+e.length>r?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function uo(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function ho(e,t,n,r){if(!e)return(0,lo.jsx)("g",{className:"annotation-note"});const{label:o,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!i)return(0,lo.jsx)("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,g=i?c?[i]:co(i,l):[],p=o?c?[o]:co(o,l):[],y="leftRight"===u?"end"===h?-4:4:0;let m=0;const b=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push((0,lo.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?y-l:"middle"===h?y-l/2:y,y:-16,width:l,height:Math.max(f,(g.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:(0,lo.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,lo.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&(0,lo.jsx)("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(g.length>0&&(b.push((0,lo.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:g.map((e,t)=>(0,lo.jsx)("tspan",{x:y,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=g.length*f),p.length>0&&b.push((0,lo.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:m,children:p.map((e,t)=>(0,lo.jsx)("tspan",{x:y,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let x=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=(0,lo.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=(0,lo.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+f+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),(0,lo.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,lo.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:b}),x]})}function fo(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,lo.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push((0,lo.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,a=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push((0,lo.jsx)("line",{x1:r,y1:(t.y1||0)-a,x2:r,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-a;i.push((0,lo.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,lo.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,lo.jsx)("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push((0,lo.jsx)("path",{d:uo(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,lo.jsx)("g",{className:"annotation-subject",children:i})}function go(e,t,n,r,o,i){const a=[];let s=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,a=e-o,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;s=o+a*h,l=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);s=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-s)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-s);if(i){const r=(s+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-s)/c,f=(n?.curve??.25)*c,g=r+d*f,p=i+h*f;a.push((0,lo.jsx)("path",{className:"connector-curve",d:`M${s},${l}Q${g},${p} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-l,g-s)}else a.push((0,lo.jsx)("line",{x1:s,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push((0,lo.jsx)("path",{d:`M${s},${l}L${s+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return(0,lo.jsx)("g",{className:"annotation-connector",children:a})}function po(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:g,strokeDasharray:p,events:y={},"data-testid":m}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-b),null!=a&&(w=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return(0,lo.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":m,...null!=g&&{opacity:g},...p&&{strokeDasharray:p},...y,children:[!x.has("connector")&&go(k,w,l,d,S,c),!x.has("subject")&&fo(S,c,d,b,v),!x.has("note")&&ho(s,k,w,d)]})}function yo(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return(0,lo.jsx)(po,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+i)});return(0,lo.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return(0,lo.jsx)(po,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}var mo=require("d3-hierarchy"),bo=require("d3-shape");function vo(e){return Math.round(100*e)/100}function xo(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const a=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));a.push(r)}r.push(a)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(vo);return{points:e.map(([e])=>[vo(e),vo(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function ko(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function wo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function So(e){return null==e?null:e+""}function Mo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Ao(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return Mo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:r(i),y:o(a)}}(n);return r?Mo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return So(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>So(e.pointId)===r);if(o)return Mo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return So(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const a=ko(i,n),s=wo(i,n);return null==a||null==s?null:Mo(t,n,{x:a,y:s})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=ko(e,n),i=wo(e,n)),null!=o&&null!=i)return Mo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Co(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var Lo=l(require("react")),[To,jo]=Un(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function No(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var Po=require("react/jsx-runtime"),Io="var(--semiotic-bg, #ffffff)";function Eo(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,Po.jsx)("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:a,fontFamily:s,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??Io,strokeWidth:h.haloWidth??3});const g=h.padding??{x:6,y:3},p="number"==typeof g?g:g.x,y="number"==typeof g?g:g.y,m=function(e,t){return(e+"").length*t*.6}(r,i),b=i+2*y;let v,x;return v="middle"===l?t-m/2-p:"end"===l?t-m-p:t-p,x="middle"===c||"central"===c?n-b/2:"hanging"===c||"text-before-edge"===c?n-y:n-.8*i-y,(0,Po.jsxs)("g",{className:d,children:[(0,Po.jsx)("rect",{x:v,y:x,width:m+2*p,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Io,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function Ro(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var Do=null;var _o=require("react/jsx-runtime");function Oo(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function $o(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Wo(e,t){let n=2166136261;const r=$o(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}var Bo=new Map;function zo(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*i));return(0,_o.jsxs)("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[n&&"transparent"!==n&&(0,_o.jsx)("rect",{width:l,height:l,fill:n}),(0,_o.jsx)("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s}),(0,_o.jsx)("line",{x1:i,y1:0,x2:i,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s})]},t)}function Fo(e,t,n="#4e79a7"){if(Oo(e)){const n=Wo(t,e);return{fill:`url(#${n})`,def:zo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Ho=require("react/jsx-runtime"),qo={linear:bo.curveLinear,monotoneX:bo.curveMonotoneX,monotoneY:bo.curveMonotoneY,step:bo.curveStep,stepAfter:bo.curveStepAfter,stepBefore:bo.curveStepBefore,basis:bo.curveBasis,cardinal:bo.curveCardinal,catmullRom:bo.curveCatmullRom};var Yo=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Xo(e){return!!e&&"object"==typeof e&&Yo.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Go(e){return"primary"===e?.emphasis||!0===e?.defensive}function Vo(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Uo(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var Qo=32,Ko=6,Zo=4,Jo=8,ei=72;var ti={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ni(e){if(!ri(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function ri(e){return Xo(e)}function oi(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function ii(e,t,n,r,o){const i=e+n,a=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?a-o.height:a,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?a-o.height-4:a+4,width:o.width,height:o.height}}function ai(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function si(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function li(e,t,n,r,o,i,a,s){const l=ai(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,s);for(const e of n)c+=12*si(l,e);for(const e of r)c+=4*si(l,e);return c}function ci(e){const{annotations:t,context:n,defaultOffset:r=Qo,notePadding:o=Ko,markPadding:i=Zo,edgePadding:a=Jo,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=ei,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:g,cohesion:p,audience:y}=e,m=n.width||0,b=n.height||0,v="object"==typeof g?g:{},x=v.breakpoint??480,k=!!g&&x>=m,w=k&&!1!==v.preferShortText?t.map(ni):t,S=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,M=d||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),A=k&&!f?v.responsive??{minWidth:x}:f,C=k&&!p?v.cohesion:p;if(0===w.length||0>=m||0>=b)return w.slice();const L=[],T=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let j=!1;const N=w.map((e,t)=>{if(!ri(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ao(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...oi("string"==typeof e.title?e.title:void 0,t),...oi("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return L.push(ai(ii(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=li(ii(i.x,i.y,e.dx,e.dy,u),e,L,T,m,b,o,a);f>t&&(h=e,f=t)}if(!h)return e;const g=ai(ii(i.x,i.y,h.dx,h.dy,u),o);L.push(g);const p=Math.hypot(h.dx,h.dy),y=l&&p>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:h.dx,dy:h.dy,...y?{connector:y}:{}}}),P=j?N:w.slice();let I=P;if(h){let e=!1;const t=P.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});I=e?t:P}{let e=!1;const t=I.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?ti[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});I=e?t:I}const E=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(y),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Vo(m,b,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=Vo(n,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Xo(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const l=s.filter(e=>Go(e.annotation)),c=s.filter(e=>!Go(e.annotation)).sort((e,t)=>Uo(t.annotation)-Uo(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:I,width:m,height:b,...n});for(const e of r)E.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:480)>=m)for(const e of I)ri(e)&&"secondary"===e.emphasis&&E.add(e);if(E.size>0)for(const e of I)!0===e?.defensive&&E.delete(e);let R;return R=0===E.size?I:M?I.map(e=>E.has(e)?{...e,_annotationDeferred:!0}:e):I.filter(e=>!E.has(e)),C?function(e,t){let n=!1;const r=e.map(e=>ri(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(R,C):R}var ui=require("d3-shape"),di={circle:ui.symbolCircle,square:ui.symbolSquare,triangle:ui.symbolTriangle,diamond:ui.symbolDiamond,star:ui.symbolStar,cross:ui.symbolCross,wye:ui.symbolWye};function hi(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*fi(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,ui.symbol)(di[r]??ui.symbolCircle,Math.max(1,t))()??""}function fi(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var gi=require("react/jsx-runtime");function pi(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:g,foregroundGraphics:p,sceneNodes:y,annotations:m,onAnnotationActivate:b,onObservation:v,chartId:x,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=e,M=function(e){const t=jo(e=>e.pushObservation),n=Lo.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Lo.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:b,onObservation:v,chartId:x,chartType:k}),A=Mr.useMemo(()=>{const e=(y||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=wn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,fi(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:y}},[n,y,t]),C=Mr.useMemo(()=>{if(!m)return m;const e=function(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}(m);return w?ci({annotations:e,context:A,..."object"==typeof w?w:{}}):e},[m,w,A]),L=Mr.useMemo(()=>function(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=Ao(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!Co(o,i,r))return null;const a="callout"===e.type?"callout-circle":e.type,s="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return(0,Ho.jsx)(yo,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=ko(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const s=t>.6*(r.width||0),l=s?t-4:t+4,c=s?"end":"start";return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[(0,Ho.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ho.jsx)(Eo,{x:l,y:a,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=wo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,l;"left"===i?(a=4,l="start"):"center"===i?(a=(r.width||0)/2,l="middle"):(a=(r.width||0)-4,l="end");const c=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[(0,Ho.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ho.jsx)(Eo,{x:a,y:c,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:ko({...e,type:"point"},r),y:wo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=(0,mo.packEnclose)(t),i=e.padding||10;return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ho.jsx)(Eo,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:ko({...e,type:"point"},r),y:wo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),a=t.map(e=>e.y),[s,l]=Ne(i),[c,u]=Ne(a),d=s-o,h=l+o,f=c-o;return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("rect",{x:d,y:f,width:h-d,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ho.jsx)(Eo,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Ho.jsx)("g",{children:o.map((t,n)=>{const o=ko(t,r),a=wo(t,r);if(null==o||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return(0,Ho.jsx)("circle",{cx:o,cy:a,r:s,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=ko(e,r),o=wo(e,r);return(0,Ho.jsx)(yo,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",a="ordinal"===r.frameType,s="horizontal"===r.projection,l=a?o:null,c=a?i:null;let u;const d=[],h=new Map;if(a&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=h.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,g=r.scales?.y??r.scales?.value;if(!f||!g)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,n+1),o=t-n,i=e(d[n]);return i+(e(d[r])-i)*o},y=f,m=g;let b;if(a)if(s){const e=p(m);b=(t,n)=>[y(n),e(t)]}else{const e=p(y);b=(t,n)=>[e(t),m(n)]}else b=(e,t)=>[y(e),m(t)];const v=e.method||"linear";let x;if("loess"===v)x=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],g+=t*o[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const p=u*f-d*d;if(1e-12>Math.abs(p))s.push([t,h/u]);else{const e=(u*g-d*h)/p;s.push([t,(h-e*d)/u+e*t])}}return s}(u,e.bandwidth??.3);else{const t="polynomial"===v?xo(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:vo((n*t[3]-t[0]*t[1])/r),i=vo(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[vo(e),vo(o*e+i)]),equation:[o,i]}}(u);x=t.points}const k=x.map(([e,t])=>{const[n,r]=b(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",S=x[x.length-1],[M,A]=b(S[0],S[1]);return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ho.jsx)("text",{x:M+4,y:A-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,o=t?.domain?.(),s=e.y0??o?.[0],l=e.y1??o?.[1],c=null!=s&&t?t(s):0,u=null!=l&&t?t(l):r.height||0,d=Fo(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Ho.jsx)("defs",{children:d.def}),(0,Ho.jsx)("rect",{x:0,y:Math.min(c,u),width:r.width||0,height:Math.abs(u-c),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,Ho.jsx)(Eo,{x:(r.width||0)-4,y:(i=c,a=u,Math.max(Math.min(i,a),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=t?.domain?.(),i=e.x0??o?.[0],a=e.x1??o?.[1],s=null!=i&&t?t(i):null,l=null!=a&&t?t(a):null;if(null==s||null==l)return null;const c=Fo(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[c.def&&(0,Ho.jsx)("defs",{children:c.def}),(0,Ho.jsx)("rect",{x:Math.min(s,l),y:0,width:Math.abs(l-s),height:r.height||0,fill:c.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,Ho.jsx)(Eo,{x:Math.min(s,l)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const d=qo[r.curve||"linear"]||bo.curveLinear,h=(0,bo.area)().x(e=>i(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Ho.jsx)("text",{x:i(u[u.length-1][o])+4,y:a(u[u.length-1][s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=!1!==e.showBand,g=e.fill||"#6366f1",p=e.fillOpacity??.1,y=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,b=a(l+d*u),v=a(h),x=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>d*u});return(0,Ho.jsxs)("g",{children:[f&&(0,Ho.jsx)("rect",{x:0,y:Math.min(b,v),width:r.width||0,height:Math.abs(v-b),fill:g,fillOpacity:p}),x.map((e,t)=>{const n=ko(e,r),o=wo(e,r);return null==n||null==o?null:(0,Ho.jsx)("circle",{cx:n,cy:o,r:m,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Ho.jsx)("text",{x:(r.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const i=r.xAccessor||"x",a=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,l=r.scales?.y??r.scales?.value;if(!s||!l)return null;const c=t.map(e=>[e[i],e[a]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=xo(c,e.order||2).equation;u=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=function(e){const t=e.length;let n=0,r=0,o=0,i=0;for(const[t,a]of e)n+=t,r+=a,o+=t*t,i+=t*a;const a=t*o-n*n;if(1e-12>Math.abs(a))return null;const s=(t*i-n*r)/a,l=(r-s*n)/t;return e=>l+s*e}(c);if(!e)return null;u=e}const d=c.length,{se:h,meanX:f,ssX:g}=function(e,t){const n=e.length,r=e.map(([e,n])=>n-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(r/Math.max(n-2,1)),i=e.reduce((e,t)=>e+t[0],0)/n,a=e.reduce((e,t)=>e+(t[0]-i)**2,0);return{se:o,meanX:i,ssX:a}}(c,u),p=.99>(o=e.confidence??.95)?.95>o?.9>o?1:1.645:1.96:2.576,y=e.steps??5,m=c[d-1][0],b=(m-c[0][0])/Math.max(d-1,1),v=[];for(let e=1;y>=e;e++)v.push(m+e*b);const x=[];for(const e of v){const t=u(e),n=h*Math.sqrt(1+1/d+(g>0?(e-f)**2/g:0))*p;x.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${x.map(e=>`${s(e.x)},${l(e.yUpper)}`).join(" L")} L${x.slice().reverse().map(e=>`${s(e.x)},${l(e.yLower)}`).join(" L")} Z`,w=x.map(e=>`${s(e.x)},${l(e.yCenter)}`).join(" "),S=`${s(m)},${l(u(m))}`,M=e.strokeColor||"#6366f1";return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("path",{d:k,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Ho.jsx)("polyline",{points:`${S} ${w}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&x.length>0&&(0,Ho.jsx)("text",{x:s(x[x.length-1].x)+4,y:l(x[x.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=Ao(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!Co(o,i,r))return null;const a=e.dx??0,s=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??(0,Ho.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,Ho.jsx)("foreignObject",{x:o+a-l/2,y:i+s-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Ho.jsx)("div",{...No(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=Ao(e,n,r);if(!t)return null;const{x:o,y:i}=t,a=o+(e.dx||0),s=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,Ho.jsx)("text",{x:a,y:s,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?so.cloneElement(c,{key:"ann-text-"+n}):(0,Ho.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Ho.jsx)("line",{x1:o,y1:i,x2:a,y2:s,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),so.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,a=r.scales?.x,s=r.scales?.y,l=o(i)?i:o(a)?a:o(s)?s:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Ho.jsxs)("g",(r.projection?"vertical"===r.projection:l===a)?{children:[(0,Ho.jsx)("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),f&&(0,Ho.jsx)(Eo,{x:c+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,Ho.jsx)("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Ho.jsx)(Eo,{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,a,s}}(),[]),T=C?function(e,t,n,r){const o=[];return e.forEach((e,i)=>{let a;if(n){const o=n(e,i,r);a=null!=o?o:t(e,i,r)}else a=t(e,i,r);a&&o.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:io(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>ro(e.annotation)),o=e.some(e=>null!=oo(e.annotation)),i=e.some(e=>"layer"===oo(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=to[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=ro(t.annotation);let a=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;a=(0,eo.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:ao(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const s=oo(t.annotation);return s&&(a=(0,eo.jsx)("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+n)),i&&(a=(0,eo.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return r&&s.unshift((0,eo.jsx)("style",{children:no},"annotation-disclosure-style")),i&&s.unshift((0,eo.jsx)("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(o)}(C.filter(e=>"widget"!==e.type),L,S,A):null,j=!0===C?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,gi.jsxs)(gi.Fragment,{children:[j&&(0,gi.jsx)("style",{children:no},"annotation-widget-disclosure-style"),(0,gi.jsxs)("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,gi.jsx)("title",{children:"string"==typeof s?s:"Network Chart"}),(0,gi.jsx)("desc",{children:"string"==typeof s?s+" (network data visualization)":"Network data visualization"}),(0,gi.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>(0,gi.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),T,p]}),s&&"string"==typeof s?(0,gi.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",fontSize:14,className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,gi.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:s}):null,Jr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:s,legendLayout:g,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),C?.filter(e=>"widget"===e.type&&e.nodeId&&y).map((e,t)=>{const n=!0===e._annotationDeferred,r=y.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),a=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),s=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??(0,gi.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,gi.jsx)("div",{...No(e,M),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+s-c/2,top:a+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}pi.displayName="NetworkSVGOverlay";var yi=l(require("react")),mi=require("react/jsx-runtime"),bi={position:"absolute",top:0,left:0,pointerEvents:"none"};function vi({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=yi.useRef(null),i=function(e,t,n){const[r,o]=yi.useState(null);return yi.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",a),s.disconnect()}},[t,e,n]),yi.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,a=t.left-n,s=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(a>t+e.width||t>s||l>n+e.height||n>c)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const a=(0,mi.jsx)("div",{className:"semiotic-network-html-marks",ref:o,style:{...bi,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,mi.jsx)("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?(0,mi.jsx)(un,{value:n,children:a}):a}function xi(e,t,n){if(null==t)return n;if(Oo(t)){const r=function(e,t){const n=e.background??"transparent",r=e.stroke??"#000",o="transparent"===n||"none"===n?n:gr(t,n)||n,i=gr(t,r)||r||"#000",a="undefined"!=typeof window&&window.devicePixelRatio||1,s=`${$o(e)}|${o}|${i}@${a}`,l=Bo.get(s);if(void 0!==l)return l;const c=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45}=e,s={background:n,stroke:r,lineWidth:o,spacing:i,angle:a},l=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Do||(Do=document.createElement("canvas")),Do.width=e,Do.height=e,Do)}(l)}catch{return Ro(s)}const u=c.getContext("2d");if(!u)return Ro(s);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,l,l)):u.clearRect(0,0,l,l),u.strokeStyle=r,u.lineWidth=o,u.lineCap="square";const d=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-l;2*l>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*l,l),u.stroke()}else{u.save(),u.translate(l/2,l/2),u.rotate(d);const e=2*l;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(c,"repeat")}({background:o,stroke:i,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),u=Oo(c)?null:c;return Bo.set(s,u),u}(t,e);return r||t.background&&gr(e,t.background)||n}return"string"!=typeof t?t:gr(e,t)||n}function ki(e,t,n,r){t.fill&&(e.fillStyle=xi(e,t.fill,n),void 0!==t.fillOpacity&&(e.globalAlpha=(t.opacity??1)*t.fillOpacity),r())}function wi(e,t,n){t.stroke&&"none"!==t.stroke&&(e.strokeStyle=gr(e,t.stroke)||t.stroke,e.lineWidth=t.strokeWidth??1,e.globalAlpha=(t.opacity??1)*(t.strokeOpacity??1),n())}l(require("react")),require("d3-shape"),require("d3-shape");var Si=require("react/jsx-runtime"),Mi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Ai(e,t="#4e79a7"){return Oo(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}var Ci=l(require("react")),Li=require("d3-shape"),Ti=require("react/jsx-runtime");require("react/jsx-runtime");var ji="undefined"==typeof window||"undefined"==typeof document,Ni=l(require("react")),Pi=l(require("react")),Ii=(require("react/jsx-runtime"),Pi.createContext(null)),Ei=require("react/jsx-runtime"),Ri={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Di({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Ei.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ri,children:t})}var _i=require("react/jsx-runtime");function Oi(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var $i=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Wi="semiotic-accessible-data-table",Bi=Wi+" semiotic-accessible-data-table-hidden",zi=Wi+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",Fi={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Hi={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},qi={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Yi={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Xi={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Gi={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Vi={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ui={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Qi({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,a]=Ni.useState(!1),[s,l]=Ni.useState(5),c=Pi.useContext(Ii),u=c?.visible??!1,d=i||u,h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ni.useRef(null);Ni.useEffect(()=>{d||l(5)},[d]);const g=Ni.useCallback(e=>{e.target===e.currentTarget&&(i||u||a(!0))},[i,u]),p=Ni.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||a(!1)},[u]);if(!e||0===e.length)return r?(0,_i.jsx)("span",{id:r,tabIndex:-1,style:Ri}):null;if(!d)return(0,_i.jsx)("div",{id:r,className:Bi,tabIndex:-1,onFocus:g,style:Ri,role:"region","aria-label":h,children:(0,_i.jsxs)("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const y=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],b=new Map,v=new Map,x=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),x.set(e,(x.get(e)??0)+o)}}const w=[];for(let e=0;y.length>e;e++){const t=y[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=b.get(r)??0,i=v.get(r)??0,a=x.get(r)??0,s=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}w.sort((e,t)=>t.degree-e.degree);let S=0,M=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>M&&(M=t.degree);S=e/w.length}const A=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),C=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&C.push(`Mean degree: ${$i(S)}, max degree: ${M}.`);const L=Math.min(s,w.length),T=w.slice(0,L),j=w.length-L;return(0,_i.jsxs)("div",{ref:f,id:r,className:zi,tabIndex:-1,onBlur:p,style:Fi,role:"region","aria-label":h,children:[(0,_i.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:qi,children:"×"}),(0,_i.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Hi,children:C.join(" ")}),(0,_i.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Yi,children:[(0,_i.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Vi,children:j>0?`Top ${L} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,_i.jsx)("thead",{children:(0,_i.jsxs)("tr",{children:[(0,_i.jsx)("th",{style:Xi,children:"id"}),(0,_i.jsx)("th",{style:Xi,children:"degree"}),(0,_i.jsx)("th",{style:Xi,children:"in"}),(0,_i.jsx)("th",{style:Xi,children:"out"}),A&&(0,_i.jsx)("th",{style:Xi,children:"w. degree"}),A&&(0,_i.jsx)("th",{style:Xi,children:"w. in"}),A&&(0,_i.jsx)("th",{style:Xi,children:"w. out"})]})}),(0,_i.jsx)("tbody",{children:T.map((e,t)=>(0,_i.jsxs)("tr",{children:[(0,_i.jsx)("td",{style:Gi,children:e.id}),(0,_i.jsx)("td",{style:Gi,children:e.degree}),(0,_i.jsx)("td",{style:Gi,children:e.inDeg}),(0,_i.jsx)("td",{style:Gi,children:e.outDeg}),A&&(0,_i.jsx)("td",{style:Gi,children:$i(e.wDegree)}),A&&(0,_i.jsx)("td",{style:Gi,children:$i(e.wInDeg)}),A&&(0,_i.jsx)("td",{style:Gi,children:$i(e.wOutDeg)})]},t))})]}),j>0&&(0,_i.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:Ui,children:["Show ",Math.min(25,j)," more"," ",1===j?"node":"nodes"," (",j," remaining)"]})]})}function Ki({summary:e}){return e?(0,_i.jsx)("div",{role:"note",style:Ri,children:e}):null}function Zi({tableId:e}){return(0,_i.jsx)("a",{href:"#"+e,style:Ri,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ri)},children:"Skip to data table"})}var Ji=new Set;function ea(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function ta(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Ji.has(n)||(Ji.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function na(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let a=[];const s=()=>{a.length&&(i(a),a=[])};for(const e of n){const n=ea(r,e);if(!n){a.push(e);continue}let l;s(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}l||(ta(n.id,e.type??"unknown"),i([e]))}s()}function ra(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=ea(r,t);if(!i)return o();const a=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=a?a:(ta(i.id,t.type??"unknown"),o())}var oa=Object.freeze([]);function ia(e){if(!e)return oa;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var aa=require("react/jsx-runtime");function sa({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:a,resolvedBackground:s,resolvedForeground:l}){const{chartType:c,nodes:u,edges:d,data:h,className:f,description:g,title:p,responsiveWidth:y,responsiveHeight:m,summary:b,background:v,renderMode:x,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,layoutSelection:T,annotations:j,onAnnotationActivate:N,annotationObservationCallback:P,onObservation:I,chartId:E,autoPlaceAnnotations:R,svgAnnotationRules:D}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(c),n=e?h||(Array.isArray(d)?void 0:d):void 0;if(e&&n)t.ingestHierarchy(n,[i,a]),t.buildScene([i,a]);else{const e=ia(u),n=Array.isArray(d)?ia(d):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,a]),t.buildScene([i,a]))}}const _=t?.sceneNodes??[],O=t?.sceneEdges??[],$=t?.labels??[];return(0,aa.jsxs)("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:y?"100%":r[0],height:m?"100%":r[1]},children:[(0,aa.jsx)(Ki,{summary:b}),(0,aa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[s&&(0,aa.jsx)("g",{transform:`translate(${o.left},${o.top})`,children:s}),(0,aa.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[v&&(0,aa.jsx)("rect",{x:0,y:0,width:i,height:a,fill:v}),O.map((e,t)=>ra({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"line":return(0,Ti.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e,r=`net-bezier-${t}-hatch`,o=Oo(n.style.fill)?zo(n.style.fill,r):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[o&&(0,Ti.jsx)("defs",{children:o}),(0,Ti.jsx)("path",{d:n.pathD,fill:o?`url(#${r})`:Ai(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-edge-"+t)}case"ribbon":{const n=e,r=`net-ribbon-${t}-hatch`,o=Oo(n.style.fill)?zo(n.style.fill,r):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[o&&(0,Ti.jsx)("defs",{children:o}),(0,Ti.jsx)("path",{d:n.pathD,fill:o?`url(#${r})`:Ai(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-edge-"+t)}case"curved":{const n=e;return(0,Ti.jsx)("path",{d:n.pathD,fill:Ai(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),_.map((e,t)=>ra({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Oo(n.style.fill)?zo(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[r&&(0,Ti.jsx)("defs",{children:r}),(0,Ti.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Oo(n.style.fill)?zo(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[r&&(0,Ti.jsx)("defs",{children:r}),(0,Ti.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,Li.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Mi)||"",o=Oo(n.style.fill)?zo(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[o&&(0,Ti.jsx)("defs",{children:o}),(0,Ti.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=hi(n.symbolType,n.size,n.path);return(0,Ti.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Ai(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return function(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=yn(o,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=kn(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:bn(n.fill,s,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:bn(n.stroke??"none",s,e.accent);return o||i?(0,Si.jsx)("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,Si.jsxs)("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&(0,Si.jsx)("clipPath",{id:c,children:(0,Si.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,Si.jsx)("g",{children:d(e.ghostColor)}):null,l&&c?(0,Si.jsx)("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>function(e,t){return(0,Ti.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),(0,aa.jsx)(pi,{width:i,height:a,totalWidth:r[0],totalHeight:r[1],margin:o,labels:$,sceneNodes:_,title:p,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,foregroundGraphics:on(l,hn(t?.customLayoutOverlays,T??null)),annotations:j,onAnnotationActivate:N,onObservation:P??I,chartId:E,chartType:"StreamNetworkFrame",autoPlaceAnnotations:R,svgAnnotationRules:D,annotationFrame:0}),(0,aa.jsx)(vi,{marks:t?.customLayoutHtmlMarks,margin:o,selection:T??null})]})}var la=require("react"),ca="undefined"!=typeof window?la.useLayoutEffect:la.useEffect,ua=()=>()=>{},da=()=>!1,ha=()=>!0;function fa(){const e=(0,la.useSyncExternalStore)(ua,da,ha);return(0,la.useRef)(e).current}var ga=require("react"),pa=require("react/jsx-runtime");function ya({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,pa.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,pa.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}var ma=require("react");function ba(e){const t=(0,ma.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return xa(e,t);if(!ka(e)||!ka(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!xa(n,o))return!1}else{if(!ka(n)||!ka(o))return!1;if(!va(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function va(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function xa(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function ka(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}var wa=l(require("react")),Sa=require("react/jsx-runtime");function Ma({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return(0,Sa.jsx)("div",{role:"alert",style:{width:r,height:Math.max(o,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"},children:(0,Sa.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Sa.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Sa.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Sa.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Aa=require("react/jsx-runtime"),Ca=class extends wa.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Aa.jsx)(Ma,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},La=require("react/jsx-runtime");function Ta({componentName:e,width:t,height:n,children:r}){return(0,La.jsx)(Ca,{fallback:r=>(0,La.jsx)(Ma,{componentName:e,message:r.message,width:t,height:n}),children:r})}"undefined"!=typeof process&&process;var ja={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Na={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Pa(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,La.jsx)("div",{style:{...ja,width:t,height:n},children:r||"No data available"}):null}function Ia(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,La.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(i+a)-a))/2);return(0,La.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>(0,La.jsx)("div",{className:"semiotic-loading-bar",style:{...Na,position:"absolute",top:s+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Ea(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}function Ra(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function Da(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function _a(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}var Oa=class{constructor(e){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(e.data),n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==r&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}r.cleanup(),t.ok?r.resolve(t.payload):r.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(Ra(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const r=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(Ra(this.options.name))},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),a(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}};function $a(e){let t=null;return{get:()=>(t&&!t.isDead||(t=e()),t),resetForTest:()=>{if(t){try{t.terminate()}catch{}t=null}}}}var Wa={},Ba=4e4;function za(e,t,n,r,o=Ba){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}function Fa(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}var Ha=class{constructor(e=function(){const e="string"==typeof Wa.url&&Wa.url?new URL("./forceLayoutWorker.js",Wa.url):Ea("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new Oa({name:"Force layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:r}=_a(t);return r?{requestId:n,ok:!1,error:Da(r)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},qa=$a(()=>new Ha);function Ya(e,t){return Fa()?qa.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}require("react/jsx-runtime");var Xa=require("react/jsx-runtime"),Ga=/^(value|amount|total|count|weight|score)$/i;function Va({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,Xa.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[(0,Xa.jsxs)("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&(0,Xa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return(0,Xa.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[(0,Xa.jsx)("div",{children:e.map((e,t)=>(0,Xa.jsxs)("span",{children:[t>0&&(0,Xa.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?(0,Xa.jsx)("strong",{children:e}):(0,Xa.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,Xa.jsx)("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=_n(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>Ga.test(e.key));return(0,Xa.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[(0,Xa.jsx)("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>{return(0,Xa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!s&&null!=t.value&&t.value>0&&(0,Xa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,Xa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Ua(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Qa(e,t){if(!t.pathD)return;e.save();const n=Ua(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,r.y0??0,r.x1,r.y1??0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=gr(e,i)||i;n.addColorStop(0,1===r.from?a:"transparent"),n.addColorStop(1,1===r.to?a:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=xi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=gr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function Ka(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=gr(e,n)||n,e.lineWidth=t.style.strokeWidth??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=(t.style.strokeWidth??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 Za(e,t){if(!t.pathD)return;e.save();const n=Ua(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=xi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=gr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function Ja(e,t){if(!t.pathD)return;e.save();const n=Ua(t),r=t.style.stroke||"#999";e.strokeStyle=gr(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=xi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}function es(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ts(e,t,n=.3){es(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function ns(e,t,n=.6){if(!es(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}Va.ownsChrome=!0;var rs=new Map;function os(e,t,n,r,o,i){if(0>=t.size)return;const a=function(e,t,n){try{if(n)return new Path2D(n);const r=`${e??"circle"}:${Math.round(t)}`;let o=rs.get(r);return o||(o=new Path2D(hi(e,t)),rs.size>256&&rs.clear(),rs.set(r,o)),o}catch{return null}}(t.symbolType,t.size,t.path);if(!a)return;e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation);const s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=o*s*(t.style.fillOpacity??1),e.fillStyle=xi(e,t.style.fill,i),e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*s,e.strokeStyle=gr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(a)),e.restore()}function is(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=yn(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const l=t=>{const n=xi(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=o*s*(t.style.fillOpacity??1);const u=kn(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Sn(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Sn(e,i,c,t.accent,void 0,l),e.restore()}function as(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:a,adjustedHeight:s,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:f,random:g,reducedMotion:p,showParticles:y,isContinuous:m,animate:b,decay:v,pulse:x,thresholds:k,staleness:w,particleStyle:S,getParticleColor:M,pendingAnnotationFrameRef:A,lastAnnotationFrameTimeRef:C,setAnnotationFrame:L,scheduleNextFrame:T,syncColorMap:j}=e,N=t.getContext("2d");if(!N)return;const P=h.current?Math.min((f-h.current)/1e3,.1):.016;h.current=f;const I=n.advanceTransition(p?f+1e6:f),E=!p&&I,R=!p&&n.tickAnimation([a,s],P),D=d.current,_=r?.beforeCompute(n.getLastUpdateResult(),E),O=I||D||R;O&&(n.buildScene([a,s]),D&&j?.()),_&&r?.afterCompute(_,O,!1);const $=y&&!p&&!!n.particlePool,W=!!((B={dirtyOrRebuilt:D,transitioning:E,animationTicked:R,continuous:$||m,liveEncoding:!!v||!!x||!!k||!1!==b&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||B.transitioning||B.animationTicked||B.continuous||B.liveEncoding||B.forced);var B;const z=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(W){const e=function(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}();if(!function(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),a=Math.round(t[1]*r),s=i/t[0],l=a/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(s,0,0,l,0,0),o.translate(n.left,n.top),o}(t,o,i,e))return;if(N.clearRect(-i.left,-i.top,o[0],o[1]),function(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:a=0,width:s,height:l}=t,c=function(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:r=""}=e;return"transparent"===t||n?null:t||(r&&"transparent"!==r?r:"")||null}({background:n,hasBackgroundGraphics:r,themeBackground:o});if(!c)return!1;const u=gr(e,c);u&&(e.fillStyle=u,e.fillRect(i,a,s,l))}(N,{background:l,hasBackgroundGraphics:u,width:a,height:s}),v&&n.applyDecay(),x&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==b&&n.applyTopologyDiff(f),z&&(N.globalAlpha=w?.dimOpacity??.5),na({context:N,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Qa(e,n);break;case"line":Ka(e,n);break;case"ribbon":Za(e,n);break;case"curved":Ja(e,n)}}(N,e)}),na({context:N,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),ki(e,t.style,"#007bff",()=>e.fillRect(t.x,t.y,t.w,t.h)),wi(e,t.style,()=>e.strokeRect(t.x,t.y,t.w,t.h)),ts(e,t),e.restore())}}(N,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(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),ki(e,t.style,"#007bff",()=>e.fill()),wi(e,t.style,()=>e.stroke()),ns(e,t),e.restore())}}(N,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;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(),ki(e,t.style,"#007bff",()=>e.fill()),wi(e,t.style,()=>e.stroke()),e.restore()}}(N,t),function(e,t){const n=e.globalAlpha;for(const r of t)"symbol"===r.type&&os(e,r,r.cx,r.cy,n,"#007bff");e.globalAlpha=n}(N,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&is(e,r,r.cx,r.cy,n);e.globalAlpha=n}(N,t)}}),$&&!z){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,a=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const s=t[r];if(!s.bezier)continue;if(e.countForEdge(r)>=a)continue;const l=s.value*i*n*(s.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(r)<a;t++)e.spawn(r,o)}}(n.particlePool,e,P,S,g);const t=.5*(S.speedMultiplier??1);let r;if(S.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(P,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const l=n[s.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=gr(e,c)||c,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(N,n.particlePool,e,S,M)}}z&&(N.globalAlpha=1)}d.current=!1,(D||E||R)&&t.setAttribute("aria-label",Oi(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const F=D||E||R||A.current;F&&f-C.current>=33?(L(e=>e+1),C.current=f,A.current=!1):A.current=!!F,(m||E||null!=n.transition||R||n.hasActivePulses||n.hasActiveThresholds||!1!==b&&n.hasActiveTopologyDiff||A.current)&&T()}function ss(e,t=30){return Math.max((e??4)+5,12,t)}function ls(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function cs(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>ss(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"rect":return function(e,t,n){const r=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=ls(Math.atan2(o,r)),s=ls(e.startAngle),l=ls(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>ss(fi(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=wn(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,l=n-a,c=Math.sqrt(s*s+l*l);return c>ss(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:a,distance:c}}(e,t,n,r);default:return null}}var us=null,ds=null;function hs(){return ds||((us=document.createElement("canvas")).width=1,us.height=1,ds=us.getContext("2d")),ds}function fs(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function gs(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=fs(e),o=hs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let a=((t-e.x1)*r+(n-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*r,l=e.y1+a*o,c=Math.sqrt((t-s)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=fs(e),o=hs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function ps(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-r.left-o.left,g=n-r.top-o.top;if(0>h||h>i||0>g||g>a)return{kind:"miss-outside"};const p=function(e,t,n,r,o=30,i,a=0){let s=null,l=o,c=1/0;if(i){const e=function(e,t,n,r,o,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,o,l,p,y)=>{if(o>u||c>p||l>h||d>y)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=a(e)-n,u=Math.sqrt(l*l+c*c);ss(s(e),r)>=u&&g>u&&(f=e,g=u),o=o.next}while(o)}return!1}),f?{node:f,distance:g}:null}(i,n,r,o,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=cs(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(s=e,c=n)}else l>e.distance&&(s=e,l=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=gs(e,n,r);t&&l>t.distance&&(s=t,l=t.distance)}return s}(s,l,h,g,d,c,u);return p?{kind:"hit",hover:f(p.datum||{},p.x,p.y,{nodeOrEdge:p.type})}:{kind:"miss"}}function ys(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:a}),"focus"===s?.type&&t({type:"focus",datum:n,inputType:"touch"===s.inputType?"pointer":s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"hover-end",timestamp:l,chartType:i,chartId:a}))}function ms(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:a}),"activate"===s?.type&&t({type:"activate",datum:n,inputType:s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"click-end",timestamp:l,chartType:i,chartId:a}))}var bs=require("react"),vs="StreamNetworkFrame",xs=require("react/jsx-runtime"),ks={top:20,right:80,bottom:20,left:80},ws={top:40,right:40,bottom:40,left:40},Ss=new Set(["chord","force","circlepack","orbit"]),Ms=[800,600],As=(0,d.memo)((0,d.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:h="value",edgeIdAccessor:y,childrenAccessor:m,hierarchySum:b,orientation:v="horizontal",nodeAlign:x="justify",nodePaddingRatio:k=.05,nodeWidth:w=15,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,padAngle:T=.01,groupWidth:j=20,sortGroups:N,edgeSort:P,treeOrientation:I="vertical",edgeType:E="curve",padding:R,paddingTop:D,tensionConfig:_,showParticles:O=!1,particleStyle:$,renderMode:W,nodeStyle:B,edgeStyle:z,colorBy:F,colorScheme:H="category10",edgeColorBy:q="source",edgeOpacity:Y=.5,colorByDepth:X=!1,nodeSize:G=8,nodeSizeRange:V=[5,20],nodeLabel:U,showLabels:Q=!0,labelMode:K,size:Z=Ms,responsiveWidth:J,responsiveHeight:ee,margin:te,className:ne,background:re,enableHover:oe=!0,tooltipContent:ie,customHoverBehavior:ae,customClickBehavior:se,onObservation:le,annotationObservationCallback:ce,chartId:ue,onTopologyChange:de,annotations:he,onAnnotationActivate:fe,autoPlaceAnnotations:ge,svgAnnotationRules:pe,legend:ye,legendPosition:me,legendLayout:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:ke,legendIsolatedCategories:we,title:Se,foregroundGraphics:Me,backgroundGraphics:Ae,decay:Ce,pulse:Le,transition:Te,animate:je,staleness:Ne,frameScheduler:Pe,clock:Ie,random:Ee,seed:Re,paused:De=!1,suspendWhenHidden:_e=!0,thresholds:Oe,accessibleTable:We=!0,description:Be,summary:ze,orbitMode:Fe,orbitSize:He,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Xe,orbitEccentricity:Ge,orbitShowRings:Ve,orbitAnimated:Ue,customNetworkLayout:Qe,onLayoutError:Ke,layoutConfig:Ze,layoutSelection:Je}=e,et=Ss.has(n)?ws:ks,tt=(0,d.useRef)(!0),nt=br({sizeProp:Z,responsiveWidth:J,responsiveHeight:ee,userMargin:te,marginDefault:et,title:Se,legend:ye,legendPosition:me,foregroundGraphics:Me,backgroundGraphics:Ae,animate:je,transitionProp:Te,frameScheduler:Pe,clock:Ie,random:Ee,seed:Re,paused:De,suspendWhenHidden:_e,themeDirtyRef:tt}),{reducedMotionRef:rt,responsiveRef:ot,size:it,margin:at,adjustedWidth:st,adjustedHeight:lt,resolvedForeground:ct,resolvedBackground:ut,transition:dt,introEnabled:ht,tableId:ft,rafRef:gt,renderFnRef:pt,scheduleRender:yt,frameRuntime:mt,currentTheme:bt}=nt,vt=function(){const[e,t]=(0,la.useState)(!1);return ca(()=>{t(!0)},[]),e}(),xt=fa(),kt=(0,d.useMemo)(()=>ia(r),[r]),wt=(0,d.useMemo)(()=>Array.isArray(o)?ia(o):o,[o]),St=(0,d.useMemo)(()=>({...g,..._}),[_]),Mt=(0,d.useMemo)(()=>({...p,...$}),[$]),At=(0,d.useMemo)(()=>{return{chartType:(e={chartType:n,clock:mt.now,random:Ee,seed:Re,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:y,childrenAccessor:m,hierarchySum:b,orientation:v,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:T,groupWidth:j,sortGroups:N,edgeSort:P,treeOrientation:I,edgeType:E,padding:R,paddingTop:D,tensionConfig:St,showParticles:O,particleStyle:Mt,nodeStyle:B,edgeStyle:z,nodeLabel:U,showLabels:Q,labelMode:K,colorBy:F,colorScheme:H,edgeColorBy:q,edgeOpacity:Y,colorByDepth:X,nodeSize:G,nodeSizeRange:V,decay:Ce,pulse:Le,transition:dt,introAnimation:ht,staleness:Ne,thresholds:Oe,orbitMode:Fe,orbitSize:He,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Xe,orbitEccentricity:Ge,orbitShowRings:Ve,orbitAnimated:Ue,customNetworkLayout:Qe,onLayoutError:Ke,layoutConfig:Ze,currentTheme:bt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Zn(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,mt.now,Ee,Re,s,l,c,h,y,m,b,v,x,k,w,S,M,T,j,N,P,I,E,R,D,St,O,Mt,B,z,U,Q,K,F,H,q,Y,X,G,V,Ce,Le,dt,ht,Ne,Oe,Fe,He,qe,Ye,Xe,Ge,Ve,Ue,Qe,Ke,Ze,bt]),Ct=ba(At),Lt=ba({chartType:(Tt={chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:y,childrenAccessor:m,hierarchySum:b,orientation:v,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:T,groupWidth:j,sortGroups:N,edgeSort:P,treeOrientation:I,edgeType:E,padding:R,paddingTop:D,random:Ee,seed:Re,tensionConfig:St,customNetworkLayout:Qe,orbitMode:Fe,orbitSize:He,orbitEccentricity:Ge}).chartType,nodeIDAccessor:Tt.nodeIDAccessor,sourceAccessor:Tt.sourceAccessor,targetAccessor:Tt.targetAccessor,valueAccessor:Tt.valueAccessor,edgeIdAccessor:Tt.edgeIdAccessor,childrenAccessor:Tt.childrenAccessor,hierarchySum:Tt.hierarchySum,orientation:Tt.orientation,nodeAlign:Tt.nodeAlign,nodePaddingRatio:Tt.nodePaddingRatio,nodeWidth:Tt.nodeWidth,iterations:Tt.iterations,forceStrength:Tt.forceStrength,padAngle:Tt.padAngle,groupWidth:Tt.groupWidth,sortGroups:Tt.sortGroups,edgeSort:Tt.edgeSort,treeOrientation:Tt.treeOrientation,edgeType:Tt.edgeType,padding:Tt.padding,paddingTop:Tt.paddingTop,random:Tt.random,seed:Tt.seed,tensionConfig:Tt.tensionConfig,customNetworkLayout:Tt.customNetworkLayout,orbitMode:Tt.orbitMode,orbitSize:Tt.orbitSize,orbitEccentricity:Tt.orbitEccentricity});var Tt;const jt=(0,d.useRef)(0),Nt=(0,d.useRef)(0),Pt=(0,d.useRef)(!1),It=(0,d.useRef)(null);It.current||(It.current=new Vt(Ct));const Et=(0,Ut.useRef)(new tn("StreamNetworkFrame")),Rt=(0,d.useCallback)((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(Et.current,e,()=>e.buildScene(t),n),[Et]),[Dt,Ot]=(0,d.useState)(null),[$t,Wt]=(0,d.useState)(0),[Bt,zt]=(0,d.useState)(0),[Ft,Ht]=(0,d.useState)(!1),[qt,Yt]=(0,d.useState)(!1),Xt=(0,d.useRef)(0),Gt=(0,d.useRef)(null),Qt=(0,d.useRef)(!1),Kt=(0,d.useRef)(L);Kt.current=L;const Zt=(0,d.useRef)(Ct);Zt.current=Ct;const Jt=(0,d.useRef)(null),en=(0,d.useRef)(new Map),rn=(0,d.useRef)(0),an=(0,d.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:_t;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const a=Array.isArray(r)?r:_t,s=n?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:F,colorScheme:H,nodeColorMap:en.current,colorIndexRef:rn}),[F,H]),sn=(0,d.useCallback)(e=>{rn.current=function(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:_t,a=Array.from(n);for(let e=0;a.length>e;e++){const t=a[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return a.length}({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:en.current,colorScheme:H})},[H]),ln=(0,d.useCallback)((e,t)=>{Rt(e,t),sn(e),tt.current=!1,e.markStylePaintPending()},[Rt,sn]),cn=(0,d.useCallback)(()=>{It.current?.markStylePaintPending()},[]),un=(dn=bt,dn?.colors?.border||dn?.colors?.secondary||dn?.colors?.primary||"#999");var dn;const gn=(0,d.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,It.current?.nodes),[]),pn=(0,d.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const a=o(t.source),s=o(t.target);return"target"===n&&s?r(s):a?r(a):i}({edge:e,edgeColorBy:q,getNodeColor:an,resolveEndpoint:gn,fallback:un}),[q,an,un,gn]),yn=(0,d.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:l}=e;if("function"==typeof n){const e=s(t.source);return e?n(t,e):l}if(!o)return i(t);const c=r,u=s(t.source),d=s(t.target);return"target"===c&&d?a(d):u?a(u):l}({edge:e,particleStyleColor:Mt.color,particleColorBy:Mt.colorBy,hasExplicitParticleColorBy:!!$?.colorBy,getEdgeColor:pn,getNodeColor:an,resolveEndpoint:gn,fallback:un}),[$?.colorBy,Mt.color,Mt.colorBy,an,pn,un,gn]),mn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Qe,O,!!Le,It.current?.isAnimating??!1);!function(e,t,n,r){(0,fn.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}(It,Ct,tt,yt),function(e,t,n,r){const o=(0,fn.useRef)(null);(0,fn.useEffect)(()=>{const i=e.current;if(!i)return;const a=t??null;o.current!==a&&(o.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):n.current=!0,r())},[t,r,e,n])}(It,Je,tt,yt),(0,d.useEffect)(()=>{const e=It.current;e&&(ln(e,[st,lt]),Wt(e=>e+1),yt())},[bt,st,lt,ln,yt]);const bn=(0,d.useCallback)(()=>{const e=It.current;if(e&&(e.runLayout([st,lt]),ln(e,[st,lt]),Wt(e.layoutVersion),de)){const{nodes:t,edges:n}=e.getLayoutData();de(t,n)}},[st,lt,ln,de]),vn=(0,d.useRef)(!1),xn=(0,d.useCallback)((e=!1)=>!(!e&&!vn.current||(vn.current=!1,bn(),0)),[bn]),kn=(0,d.useCallback)(()=>xn(!1),[xn]),Sn=(0,d.useCallback)(e=>{const t=It.current;if(!t)return!1;let n=!1,r=vn.current;for(const o of e)null!=o&&"object"==typeof o&&(n=!0,t.ingestEdge(o)&&(r=!0));const o=xn(r);return n||o},[xn]),An=(0,d.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=It.current;t&&(t.ingestEdge(e)&&(vn.current=!0),mt.isActive?yt():kn())},[kn,mt,yt]),Ln=(0,d.useCallback)(e=>{Sn(e)&&yt()},[Sn,yt]);(0,d.useEffect)(()=>mt.subscribe(()=>{mt.isActive||kn()}),[kn,mt]);const Tn=(0,d.useCallback)(()=>{vn.current=!1,It.current?.clear(),en.current.clear(),rn.current=0,Wt(It.current?.layoutVersion??0),Ot(null),Jt.current=null,tt.current=!0,yt()},[yt]),Nn=(0,d.useCallback)(()=>{const e=It.current;e&&(e.tension+=999,xn(!0),yt())},[xn,yt]);(0,d.useImperativeHandle)(t,()=>({push:An,pushMany:Ln,removeNode:e=>{const t=It.current?.removeNode(e)??!1;if(t){const t=Jt.current?.data?"function"==typeof s?s(Jt.current.data):Jt.current.data[s]:void 0;Jt.current&&"node"===Jt.current.nodeOrEdge&&t===e&&(Jt.current=null,Ot(null)),en.current.delete(e)}return xn(t)&&(tt.current=!0,yt()),t},removeEdge:(e,t)=>{const n=It.current?.removeEdge(e,t)??!1;if(n&&Jt.current&&"edge"===Jt.current.nodeOrEdge){const n=Jt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!y||!n||("function"==typeof y?y:e=>e?.[y])(n)===e,r&&(Jt.current=null,Ot(null))}return xn(n)&&(tt.current=!0,yt()),n},updateNode:(e,t)=>{const n=It.current?.updateNode(e,t)??null;return xn(null!==n)&&(tt.current=!0,yt()),n},updateEdge:(e,t,n)=>{const r=It.current?.updateEdge(e,t,n)??[];return xn(r.length>0)&&(tt.current=!0,yt()),r},clear:Tn,getTopology:()=>(kn(),It.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(kn(),It.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(kn(),It.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{kn();const e=It.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:Nn,getTension:()=>(kn(),It.current?.tension??0)}),[An,Ln,Tn,Nn,kn,xn,s,yt,y]);const Pn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),In=Pn?i||(Array.isArray(o)?void 0:o):void 0;(0,d.useEffect)(()=>{const e=It.current;if(!e)return;const t=++Xt.current;if(Gt.current?.abort(),Gt.current=null,Pn&&In)vn.current=!1,e.ingestHierarchy(In,[st,lt]),ln(e,[st,lt]),Wt(e.layoutVersion),Yt(!1),Kt.current?.("ready"),yt();else{const i=kt,a=Array.isArray(wt)?wt:[];if(null==r&&null==o||(vn.current=!1),0===i.length&&0===a.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||Tn(),Yt(!1),void Kt.current?.("ready");const s=[st,lt],l="force"===n&&!Qe&&Fa()&&!Ee&&za(A,i.length,a.length,S);if(l&&xt&&!Qt.current&&e.sceneNodes.length>0)return Qt.current=!0,Yt(!1),Kt.current?.("ready"),tt.current=!0,void yt();if(l){const n=new AbortController;Gt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,a,s,{deferLayout:!0});const o=e.getLayoutData(),l=function(e,t,n,r,o){const i=$e(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Zt.current,s,r);return Yt(!0),Kt.current?.("pending"),Ya(l,n.signal).then(({positions:n})=>{t===Xt.current&&(e.applyForceLayoutPositions(n,s),ln(e,s),Yt(!1),Kt.current?.("ready"),Wt(e.layoutVersion),yt())}).catch(n=>{"AbortError"!==n.name&&t===Xt.current&&(e.runLayout(s),ln(e,s),Yt(!1),Kt.current?.("error"),Wt(e.layoutVersion),yt())}),()=>n.abort()}e.ingestBounded(i,a,s),ln(e,s),Wt(e.layoutVersion),Yt(!1),Kt.current?.("ready"),yt()}},[kt,wt,r,o,i,In,Pn,st,lt,Lt,A,S,xt,n,Qe,Ee,yt,Tn,ln]);const En=u.useRef(!1);(0,d.useEffect)(()=>{En.current||a&&a.length>0&&(En.current=!0,Ln(a))},[a,Ln]);const{customHoverBehavior:Rn,customClickBehavior:Dn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:(0,bs.useCallback)((t,o)=>{e?.(t,o),ys({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:vs,chartId:r,context:o})},[e,n,r]),customClickBehavior:(0,bs.useCallback)((e,o)=>{t?.(e,o),ms({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:vs,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:ae,customClickBehavior:se,onObservation:le,chartId:ue}),{hoverHandlerRef:_n,hoverLeaveRef:On,onPointerMove:$n,onPointerLeave:Wn}=nt,Bn=()=>!Qe||(It.current?.hasCustomRestyle??!1);_n.current=e=>{if(!oe)return;const t=Bn(),n=Un.current;if(!n)return;const r=It.current;if(!r)return;const o=ps({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:at,adjustedWidth:st,adjustedHeight:lt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Jt.current=o.hover,Ot(o.hover),Rn?.(o.hover),t&&yt()):Jt.current&&(Jt.current=null,Ot(null),Rn?.(null),t&&yt())},On.current=()=>{if(Jt.current){const e=Bn();Jt.current=null,Ot(null),Rn?.(null),e&&yt()}};const zn=(0,d.useRef)(()=>{});zn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!se&&!le)return;const n=Un.current;if(!n)return;const r=It.current;if(!r)return;const o=ps({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:at,adjustedWidth:st,adjustedHeight:lt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});var i;"hit"===o.kind?Dn(o.hover,{type:"activate",inputType:(i=e.nativeEvent.pointerType,"touch"===i?"touch":"pointer")}):"miss"===o.kind&&Dn(null)};const Fn=(0,d.useCallback)(e=>zn.current(e),[]),Hn=(0,d.useRef)(-1),Yn=(0,d.useRef)(null),Xn=(0,d.useRef)(-1),Gn=(0,d.useCallback)(e=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(e))return;const t=It.current;if(!t)return;const n=()=>{Hn.current=-1,Yn.current=null,Xn.current=-1,Jt.current=null,Ot(null),Rn?.(null),yt()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=wn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Hn.current||n());const o=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}(r);let i=Hn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void Dn?.(f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Hn.current=0,Xn.current=-1;const t=o.flat[0];Yn.current={shape:t.shape,w:t.w,h:t.h};const n=f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Jt.current=n,Ot(n),Rn?.(n,{type:"focus",inputType:"keyboard"}),void yt()}const a=function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}(o,i),s=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Mn(e,t,n);const a=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==a)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=Cn(t.source),i=Cn(t.target),a=null!=o,s=null!=i;a&&o+""===n&&s?r.push(i+""):s&&i+""===n&&a&&r.push(o+"")}return r}(a,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Mn(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,a,o,t.sceneEdges??[],Xn);if(null===s)return;if(e.preventDefault(),0>s)return void n();Hn.current=s;const l=o.flat[s];Yn.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Jt.current=c,Ot(c),Rn?.(c,{type:"focus",inputType:"keyboard"}),yt()},[Dn,Rn,yt]),Vn=(0,d.useCallback)(e=>{Hn.current=-1,Yn.current=null,$n(e)},[$n]);pt.current=()=>{if(gt.current=null,kn(),!mt.isActive)return;const e=Un.current;if(!e)return;const t=It.current;t&&as({canvas:e,store:t,sceneRevisionDiagnostics:Et.current,size:it,margin:at,adjustedWidth:st,adjustedHeight:lt,background:re,renderMode:W,hasBackgroundGraphics:!!Ae,dirtyRef:tt,lastFrameTimeRef:jt,now:mt.now(),random:mt.random,reducedMotion:!!rt.current,showParticles:O,isContinuous:mn,animate:je,decay:Ce,pulse:Le,thresholds:Oe,staleness:Ne,particleStyle:Mt,getParticleColor:yn,pendingAnnotationFrameRef:Pt,lastAnnotationFrameTimeRef:Nt,setAnnotationFrame:zt,scheduleNextFrame:()=>{yt()},syncColorMap:()=>sn(t)})};const{canvasRef:Un}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,a=(0,ga.useRef)(null),s=(0,ga.useRef)(null),l=(0,ga.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:a,cleanup:s}=e;ca(()=>{const e=r.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():o.current=!0,a?.(),i.current()},[t,n]);const l=(0,la.useRef)(s);l.current=s,(0,la.useEffect)(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,ga.useEffect)(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),(0,ga.useEffect)(()=>{!l.current&&(l.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.canvasPaintInvalidator?e.canvasPaintInvalidator():e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:a,interactionCanvasRef:s}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(nt,{hydrated:vt,wasHydratingFromSSR:xt,storeRef:It,dirtyRef:tt,skipInitialCanvasPaintInvalidation:!0,canvasPaintInvalidator:cn,canvasPaintDependencies:[n,st,lt,re,Ae,W,yt]});!function(e,t,n,r,o,i){const a=(0,vr.useRef)("fresh");(0,vr.useEffect)(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){if(!e||0>=t)return kr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...xr,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:kr}(e,l-s.lastIngestTime);c.band===a.current&&c.isStale===o||(a.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(s)},[e,o,r,t,i,n])}(Ne,It,tt,yt,Ft,Ht);const Qn=oe&&Dt?(0,xs.jsx)(qn,{x:Dt.x,y:Dt.y,containerWidth:st,containerHeight:lt,margin:at,className:"stream-network-tooltip",zIndex:2,children:ie?ie(Dt):(0,xs.jsx)(Va,{data:Dt})}):null;if(ji||!vt&&xt)return(0,xs.jsx)(sa,{props:e,store:It.current,responsiveRef:ot,size:it,margin:at,adjustedWidth:st,adjustedHeight:lt,resolvedBackground:ut,resolvedForeground:ct});const Kn=It.current;return(0,xs.jsxs)("div",{ref:ot,className:"stream-network-frame"+(ne?" "+ne:""),role:"group","aria-label":Be||("string"==typeof Se?Se:"Network chart"),tabIndex:0,"aria-busy":qt||void 0,style:{position:"relative",width:J?"100%":it[0],height:ee?"100%":it[1],overflow:"visible"},onKeyDown:Gn,children:["production"!==process.env.NODE_ENV&&It.current&&(0,xs.jsx)(nn,{store:It.current,diagnostics:Et.current}),We&&(0,xs.jsx)(Zi,{tableId:ft}),We&&(0,xs.jsx)(Qi,{nodes:Kn?.sceneNodes??[],edges:Kn?.sceneEdges??[],chartType:"Network chart",tableId:ft,chartTitle:"string"==typeof Se?Se:void 0}),(0,xs.jsx)(Ki,{summary:ze}),(0,xs.jsx)(Di,{hoverPoint:Dt}),(0,xs.jsxs)("div",{role:"img","aria-label":Be||("string"==typeof Se?Se:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:oe?Vn:void 0,onMouseLeave:oe?Wn:void 0,onClick:se||le?Fn:void 0,children:[qt&&!1!==C&&(0,xs.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Ia(!0,it[0],it[1],C)}),(0,xs.jsx)(ya,{size:it,margin:at,overflowVisible:!0,children:ut}),(0,xs.jsx)("canvas",{ref:Un,"aria-label":Oi(Kn?.sceneNodes?.length??0,Kn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,xs.jsx)(pi,{width:st,height:lt,totalWidth:it[0],totalHeight:it[1],margin:at,labels:Kn?.labels||[],sceneNodes:Kn?.sceneNodes,title:Se,legend:ye,legendPosition:me,legendLayout:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:ke,legendIsolatedCategories:we,foregroundGraphics:on(ct,hn(It.current?.customLayoutOverlays,Je??null)),annotations:he,onAnnotationActivate:fe,onObservation:ce??le,chartId:ue,chartType:"StreamNetworkFrame",autoPlaceAnnotations:ge,svgAnnotationRules:pe,annotationFrame:Bt}),(0,xs.jsx)(vi,{marks:Kn?.customLayoutHtmlMarks,margin:at,selection:Je??null}),(0,xs.jsx)(jn,{active:Hn.current>=0,hoverPoint:Dt,margin:at,size:it,shape:Yn.current?.shape,width:Yn.current?.w,height:Yn.current?.h}),Qn,Ne?.showBadge&&(0,xs.jsx)(Sr,{isStale:Ft,position:Ne.badgePosition})]})]})}));As.displayName="StreamNetworkFrame";var Cs=As,Ls=require("react");function Ts(e,t){const{variant:n,frameRef:r,overrides:o}=t,i=(0,Ls.useRef)(o);i.current=o,(0,Ls.useImperativeHandle)(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,n)=>e.current?.update(t,n)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const n=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],o=[];for(const t of n){const n=r.find(e=>e.id===t);n&&o.push({...n.data??{},id:t}),e.current?.removeNode(t)}return o},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,n);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,n)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(n(t));return r},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const r=n.current?.removeLine(e)??[];for(const e of r)n.current?.pushLine(t(e));return r},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,r);return new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}var js=require("react"),Ns=require("react"),Ps=require("react"),Is=(require("react/jsx-runtime"),(0,Ps.createContext)(null)),Es=.5,Rs=require("react");function Ds(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function _s(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Os(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[$s,Ws]=Un(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!Os(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),a=_s(i,t),s=new Map(a.clauses);return s.set(n.clientId,n),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=_s(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),Bs=(require("react"),{positions:new Map}),zs=new Set;function Fs(){for(const e of zs)e()}function Hs(e,t){const n=Bs.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Bs.positions);r.delete(e),Bs={positions:r},Fs()}function qs(e,t){const n=Bs.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Bs.positions);r.delete(e),Bs={positions:r},Fs()}function Ys(e){const t=(0,Rs.useId)(),n=e.clientId||t,{name:r}=e,o=Ws(e=>e.selections.get(r)),i=Ws(e=>e.setClause),a=Ws(e=>e.clearClause),s=(0,Rs.useMemo)(()=>!!o&&o.clauses.size>0,[o]);return{predicate:(0,Rs.useMemo)(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Ds(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:s,selectPoints:(0,Rs.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:(0,Rs.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:(0,Rs.useCallback)(()=>{a(r,n)},[a,r,n]),clientId:n}}var Xs=l(require("react"));function Gs(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Vs(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function Us(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>Vs(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])Gs(e[r])&&Gs(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}require("react/jsx-runtime"),Xs.createContext(void 0);var Qs=44,Ks={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Qs,snap:"nearestDatum",brushHandleSize:Qs,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Zs(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!i)return Ks;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??Qs,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??Qs,standardControls:s.standardControls??!1}}var Js={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}},el={top:10,bottom:10,left:10,right:10};function tl(e){return e.compactMode?e.marginDefaults:el}function nl(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function rl(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function ol(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function il(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var al=require("react"),sl=require("react"),ll=(require("react/jsx-runtime"),(0,sl.createContext)(!1));(0,sl.createContext)(!1);var cl=(0,sl.createContext)(null),ul="undefined"==typeof window?sl.useEffect:sl.useLayoutEffect;function dl(e,t){if(!t)return[];const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)}function hl({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s,additionalLegend:l,chartWidth:c,legendLayout:u,hasTitle:d=!1,axisChrome:h}){const f=(0,sl.useContext)(ll),g=null!==(0,sl.useContext)(cl),p=void 0!==r?r:!f&&!!t,y=!!t&&(p||g),m=(0,al.useMemo)(()=>y?void 0!==s?s:dl(e,t):[],[s,t,e,y]);!function(e){const t=(0,sl.useContext)(cl),n=(0,sl.useId)(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=(0,sl.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(o.current,r)||(o.current=r);const i=o.current;ul(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),ul(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(g&&t?m:[]);const b=(0,al.useMemo)(()=>{if(!p||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?r(a,t,n):n?n(o):Wt[i%Wt.length];return{label:o+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Ft,categories:m});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[p,t,e,n,m]),v=(0,al.useMemo)(()=>function(...e){let t;for(const n of e)n&&(t=Cr(t)&&Cr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups],legendDistance:n.legendDistance??t.legendDistance}:n);return t}(b,l),[b,l]),{hasAxis:x,hasAxisLabel:k,rotatedTicks:w}=h??{},S=(0,al.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];if(v){const e=function(e,t){return Dr(e,t)+_r(e)+Or(t)}(v,u),t=void 0===x?{hasAxis:!0,hasAxisLabel:!0}:{hasAxis:x,hasAxisLabel:k,rotatedTicks:w},i=Fr(v,Math.max(1,(c??600)-n.left-n.right),u)+_r(v)+zr("bottom"===o?t:void 0,u)+("top"===o&&d?24:0);"right"===o&&!r("right")&&e>n.right?n.right=e:"left"===o&&!r("left")&&e>n.left?n.left=e:"top"!==o||r("top")?"bottom"!==o||r("bottom")||(n.bottom=Math.max(n.bottom,80,i)):n.top=Math.max(n.top,50,i)}return n},[a,i,v,o,c,u,d,x,k,w]);return{legend:v,margin:S,legendPosition:o}}var fl=[];function gl(){const e=ar(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function pl(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=Ht(n,r);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=Dt[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:Ot}function yl({selection:e,linkedHover:t,fallbackFields:n=fl,unwrapData:r=!1,onObservation:o,chartType:i,chartId:a,onClick:s,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=(0,Ns.useId)(),h=(0,Ns.useMemo)(()=>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||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,Ns.useMemo)(()=>"series"===h?.mode?[h.seriesField||c||n[0]].filter(e=>!!e):h?.fields||n,[h,c,n]),g=Ys({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:a}=Ys({name:t,fields:n});return{onHover:(0,Rs.useCallback)(e=>{if(!e)return void a();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Kn(t)&&i(t)},[n,i,a]),predicate:r,isActive:o}}({name:h?.name||"hover",fields:f}),y=jo(e=>e.pushObservation),m=(0,Ns.useCallback)(e=>{o?.(e),y?.(e)},[o,y]),b=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,x]=(0,Ns.useState)(null),k=(0,Ns.useRef)(!1),w=c||n[0],S=(0,Ns.useMemo)(()=>{if(!l||null==v||!w)return null;const e=v,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,v,w]),M=(0,Ns.useCallback)((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=rl(e,t,h.xField);null!=n&&function(e,t,n){const r=Bs.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Bs={positions:new Map(Bs.positions).set(e,{xValue:t,sourceId:n})},Fs())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&p.onHover(t)}else"x-position"!==h?.mode||r||Hs(h.name||"hover",d),"x-position"===h?.mode||r||p.onHover(null);if(l&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];x(null!=n?n+"":null)}else r||x(null);(o||y)&&ys({onObservation:m,datum:e?ol(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:a,context:n})},[t,p,h,d,o,i,a,y,m,l,w,u]),A=(0,Ns.useCallback)((n=!0)=>{k.current=!1,t&&"x-position"!==h?.mode&&p.onHover(null),e&&u?.tapToSelect&&g.clear(),n&&l&&x(null),"x-position"===h?.mode&&(qs(h.name||"hover",d),Hs(h.name||"hover",d))},[t,h,p,e,u,g,l,d]),C=(0,Ns.useCallback)((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),b=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=rl(n,e,h.xField);null!=t&&function(e,t,n){const r=Bs.positions.get(e);if(r?.locked){const t=new Map(Bs.positions);return t.delete(e),Bs={positions:t},Fs(),!1}Bs={positions:new Map(Bs.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Fs()}(h.name||"hover",t,d)}if(c)if(n){k.current=!0;const r=ol(n);if(t&&"x-position"!==h?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}il(e)&&g.selectPoints(e)}if(l&&w){const e=r?.[w];x(null!=e?e+"":null)}}else b&&A();if(n||b){if(n&&s){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),s(e,{x:n.x??0,y:n.y??0})}(o||y)&&ms({onObservation:m,datum:n?ol(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:a,context:r})}},[s,o,y,m,i,a,h,d,u,t,p,e,g,f,l,w,A]);return(0,Ns.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,Ns.useEffect)(()=>()=>{k.current&&A(!1)},[A]),(0,Ns.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{qs(e,d),Hs(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:d}}function ml(e,t,n){return function(e,t,n){const r=Js[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,a=Us({...t,mode:e},{width:t.width??o,height:t.height??i}).props,s=a.mode||e||"primary",l=Js[s],c="context"===s||"sparkline"===s,u="primary"===s&&n?.width?n.width:l.width;return{mode:s,width:a.width??u,height:a.height??("primary"===s&&n?.height?n.height:l.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:nl(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:Zs(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}(e,t,n)}var bl=require("react");function vl(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function xl(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function kl(e){return"function"==typeof e?e:t=>t[e]||1}function wl({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return a=>{const s={fillOpacity:o,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=Ft(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ft(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function Sl(e){const{nodes:t,edges:n,inferNodes:r=!0,sourceAccessor:o="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:l,legendPosition:c,legendInteraction:u,selection:d,linkedHover:h,onObservation:f,onClick:g,mobileInteraction:p,mobileSemantics:y,chartType:m,chartId:b,marginDefaults:v,userMargin:x,width:k,height:w,hasTitle:S,loading:M,loadingContent:A,emptyContent:C,emptyDataKey:L="edges"}=e,T=(0,bl.useMemo)(()=>ia(n),[n]),j=(0,bl.useMemo)(()=>ia(t),[t]),N=Ia(M,k,w,A),P=N?null:Pa("nodes"===L?void 0===t?void 0:j:void 0===n?void 0:T,k,w,C),I=(0,bl.useMemo)(()=>r?xl(j,T,o,i):j,[r,j,T,o,i]),E=function(e,t,n){const r=(0,Ps.useContext)(Is),o=gl();return(0,Ns.useMemo)(()=>{if(!t)return;const i=r??void 0,a=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&il(i)){const e=qt(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return qt(n.map(e=>({_cat:e})),"_cat",a)}if(i&&il(i)){const n=qt(e,t,a);return e=>i[e]||n(e)}return qt(e,t,a)}if(i&&il(i)){const e=qt([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,r,o])}(I,a,s),R=gl(),D=(0,bl.useMemo)(()=>Array.isArray(s)&&s.length>0?s:[...$t(s,R,_t)],[s,R]),_=(0,bl.useMemo)(()=>dl(I,a),[I,a]),O=function(e,t,n){const[r,o]=(0,al.useState)(null),[i,a]=(0,al.useState)(new Set),s=(0,al.useMemo)(()=>new Set,[]),l=(0,al.useCallback)(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=(0,al.useCallback)(t=>{"isolate"===e&&a(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),u=(0,al.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return("string"==typeof o?o:(o??"")+"")===r}}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has("string"==typeof r?r:(r??"")+"")}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(u,a,_),{legend:$,margin:W,legendPosition:B}=hl({data:I,colorBy:a,colorScale:E,showLegend:l,legendPosition:c,userMargin:x,defaults:v,categories:_,chartWidth:k,hasTitle:S}),z=(0,bl.useMemo)(()=>Zs(p,{width:k,mobileSemantics:y}),[p,k,y]),F=yl({selection:d,linkedHover:h,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:g,mobileInteraction:z,chartType:m,chartId:b}),{customHoverBehavior:H,customClickBehavior:q,activeSelectionHook:Y,hoverSelectionHook:X,crosshairSourceId:G}=F;return{safeNodes:I,safeEdges:T,colorScale:E,effectivePalette:D,themeCategorical:R,allCategories:_,legendState:O,legend:$,margin:W,legendPosition:B,mobileInteraction:z,customHoverBehavior:H,customClickBehavior:q,activeSelectionHook:Y,hoverSelectionHook:X,crosshairSourceId:G,loadingEl:N,emptyEl:P}}function Ml(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function Al(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Ll(t(e))}function Cl(e,t){const n=Al(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=r?r(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Ll(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function Tl(e,t,n){const r=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&r!==e.eq)return!1;if(void 0!==e.ne&&r===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(r))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=Ll(r);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>o||o>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(o>=t&&n>=o)return!1}return!0}function jl(e,t,n){const r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,n):Tl(r,t,n))}function Nl(e,t,n){if(!t||0===t.length)return{};let r={};for(const o of t){if(!jl(o,e,n))continue;const t="function"==typeof o.style?o.style(e,n):o.style;t&&(r={...r,...t})}return r}function Pl(e,t,n,r=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const a=r(e),s={...o(e,i)};return Object.assign(s,Nl(a,t,n(a,i))),s}:o}function Il(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let a=1;r>=a;a++){const r=o[a];o[a]=e[i-1]===t[a-1]?n:1+Math.min(n,o[a],o[a-1]),n=r}}return o[r]}function El(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(function(e,t,n=3){let r,o=n+1;for(const n of t){const t=Il(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3)??null)}function Rl(e){return` Or use a function: ${e}={d => d.myValue}.`}function Dl({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function _l({componentName:e,nodes:t,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==n)return null;if(o&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:[...a]).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=El(o,t),i=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`+Rl(r)}}}var a;return null}function Ol(e){const{title:t,description:n,summary:r,accessibleTable:o,className:i,animate:a,axisExtent:s,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),n&&(c.description=n),r&&(c.summary=r),void 0!==o&&(c.accessibleTable=o),i&&(c.className=i),null!=a&&(c.animate=a),void 0!==s&&(c.axisExtent=s),void 0!==l&&(c.autoPlaceAnnotations=l),c}function $l(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};r&&(f.annotationObservationCallback=r);const g=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(s||t||r||o||a)&&(f.customHoverBehavior=u),d&&(l||(h?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||a||n))&&(f.customClickBehavior=d),null!=g&&(f.hoverRadius=g),f}var Wl=require("react/jsx-runtime"),Bl=(0,js.forwardRef)(function(e,t){const n=(0,js.useRef)(null);Ts(t,{variant:"network",frameRef:n});const r=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:s,nodeIdAccessor:l,nodeIDAccessor:c,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:g,styleRules:p,nodeSize:y=8,nodeSizeRange:m=[5,20],nodeStroke:b,nodeStrokeWidth:v,edgeWidth:x,edgeColor:k,edgeOpacity:w,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,tooltip:T,frameProps:j={},onObservation:N,onClick:P,chartId:I,selection:E,linkedHover:R,loading:D,loadingContent:_,emptyContent:O,legendInteraction:$,legendPosition:W,stroke:B,strokeWidth:z,opacity:F}=e,H=l??c??"id",{width:q,height:Y,enableHover:X,showLegend:G,showLabels:V=!1,title:U,description:Q,summary:K,accessibleTable:Z}=r,J=Sl({nodes:o,edges:i,inferNodes:!1,nodeIdAccessor:H,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:g,showLegend:G,legendPosition:W,legendInteraction:$,selection:E,linkedHover:R,onObservation:N,onClick:P,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ForceDirectedGraph",chartId:I,marginDefaults:r.marginDefaults,userMargin:a,width:q,height:Y,hasTitle:!!U,loading:D,loadingContent:_,emptyContent:O,emptyDataKey:"nodes"}),ee=(0,js.useMemo)(()=>new Map,[]),te=(0,js.useMemo)(()=>e=>{const t={};return t.fill=f?Ft(e.data||e,f,J.colorScale):pl(void 0,J.themeCategorical,g,void 0,ee),"number"==typeof y&&(t.r=y),t},[f,J.colorScale,y,J.themeCategorical,g,ee]),ne=(0,js.useMemo)(()=>Cl(f,"number"==typeof y?void 0:y),[f,y]),re=(0,js.useMemo)(()=>Ml(Pl(te,p,ne,e=>e.data||e),{stroke:b??B,strokeWidth:v??z,opacity:F}),[te,p,ne,b,B,v,z,F]),oe=k??B??"#999",ie=w??F??.6,ae=z??1,se=(0,js.useMemo)(()=>e=>{const t=e.data||e;let n;if(void 0===x)n=ae;else if("number"==typeof x)n=x;else if("function"==typeof x)n=x(t);else{const e=t[x],r="number"==typeof e?e:Number(e);n=Number.isFinite(r)&&r>0?r:ae}return{stroke:oe,strokeWidth:n,opacity:ie}},[x,oe,ie,ae]),le=(0,js.useMemo)(()=>{if(V&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[V,h]),ce=_l({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:H}});return ce?(0,Wl.jsx)(Ma,{componentName:"ForceDirectedGraph",message:ce,width:q,height:Y}):J.loadingEl?J.loadingEl:J.emptyEl?J.emptyEl:(0,Wl.jsx)(Ta,{componentName:"ForceDirectedGraph",width:q,height:Y,children:(0,Wl.jsx)(Cs,{ref:n,chartType:"force",...null!=o&&{nodes:J.safeNodes},...null!=i&&{edges:J.safeEdges},size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:J.margin,nodeIDAccessor:H,sourceAccessor:u,targetAccessor:d,iterations:S,forceStrength:M,layoutExecution:A,layoutLoadingContent:C,onLayoutStateChange:L,nodeStyle:re,edgeStyle:se,colorBy:f,colorScheme:J.effectivePalette,nodeSize:y,nodeSizeRange:m,nodeLabel:le,showLabels:V,enableHover:X,tooltipContent:!1===T?()=>null:Fn(T)||void 0,...$l({linkedHover:R,selection:E,onObservation:N,onClick:P,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:J.legend,legendPosition:J.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:J.legendState.onLegendHover,legendClickBehavior:J.legendState.onLegendClick,legendHighlightedCategory:J.legendState.highlightedCategory,legendIsolatedCategories:J.legendState.isolatedCategories},className:s,title:U,description:Q,summary:K,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...j})})});Bl.displayName="ForceDirectedGraph";var zl=require("react"),Fl=require("d3-force"),Hl=1e3;function ql(e,t,n={}){const r=n.iterations??260,o=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,l=n.damping??.84,c=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=function(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const g=Hl/2,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),y=new Set(e.map(e=>e.id)),m=t.filter(e=>y.has(e.source)&&y.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,Fl.forceSimulation)(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,Fl.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",(0,Fl.forceCollide)(e=>(e=>"function"==typeof c?c(e.data):c)(e)+u).strength(.9).iterations(2)).force("center",(0,Fl.forceCenter)(g,g).strength(.8)).force("x",(0,Fl.forceX)(g).strength(s)).force("y",(0,Fl.forceY)(g).strength(s));m.length>0&&e.force("link",(0,Fl.forceLink)(m).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/n})),e.stop();for(let t=0;r>t;t+=1)e.tick()}let b=1/0,v=1/0,x=-1/0,k=-1/0;for(const e of p){const t=e.x??g,n=e.y??g;b>t&&(b=t),v>n&&(v=n),t>x&&(x=t),n>k&&(k=n)}const w=x-b,S=k-v,M={};for(const e of p)M[e.id]={x:0===w?.5:d+((e.x??g)-b)/w*(1-2*d),y:0===S?.5:d+((e.y??g)-v)/S*(1-2*d)};return M}var Yl=16,Xl=new WeakMap;function Gl(e){const t=[];for(const n of Object.keys(e).sort()){const r=e[n];if(void 0!==r){if("function"==typeof r)return null;t.push(`${n}:${r+""}`)}}return t.join("|")}function Vl(e,t,n){return null==n?null:Xl.get(e)?.get(t)?.get(n)??null}function Ul(e,t,n,r){if(null==n)return;let o=Xl.get(e);o||(o=new WeakMap,Xl.set(e,o));let i=o.get(t);if(i||(i=new Map,o.set(t,i)),!i.has(n)&&i.size>=Yl){const e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(n,r)}function Ql(e,t,n={}){const r=fa(),{seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:p}=n,y=(0,zl.useMemo)(()=>({seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:p}),[o,i,a,s,l,c,u,d,h,f,g,p]),m=(0,zl.useRef)(r),[b,v]=(0,zl.useState)(()=>{if("undefined"==typeof window||r){const n=ql(e,t,y);return Ul(e,t,Gl(y),n),{positions:n,status:"ready",error:null}}const n=Vl(e,t,Gl(y));return n?{positions:n,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return(0,zl.useEffect)(()=>{if(m.current)return void(m.current=!1);const n=Gl(y),r=Vl(e,t,n);if(r)return void v(e=>"ready"===e.status&&e.positions===r?e:{positions:r,status:"ready",error:null});const o=new AbortController;return v(e=>({positions:e.positions,status:"pending",error:null})),async function(e,t,n={}){const{execution:r="auto",signal:o,workerThreshold:i,nodeRadius:a,...s}=n,l=s.iterations??260;if(!Fa()||!za(r,e.length,t.length,l,i))return ql(e,t,{...s,nodeRadius:a});const c={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:s,nodeRadii:"function"==typeof a?Object.fromEntries(e.map(e=>[e.id,a(e)])):null==a?void 0:Object.fromEntries(e.map(e=>[e.id,a]))};try{return(await Ya(c,o)).positions}catch(n){if("AbortError"===n?.name)throw n;return ql(e,t,{...s,nodeRadius:a})}}(e,t,{...y,signal:o.signal}).then(r=>{Ul(e,t,n,r),v({positions:r,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&v(t=>({positions:t.positions,status:"error",error:e}))}),()=>o.abort()},[e,t,y]),b}var Kl=require("react"),Zl=require("react/jsx-runtime"),Jl=(0,Kl.forwardRef)(function(e,t){const n=(0,Kl.useRef)(null);Ts(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:p="source",orientation:y="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:v=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:S,frameProps:M={},onObservation:A,onClick:C,chartId:L,selection:T,linkedHover:j,loading:N,loadingContent:P,emptyContent:I,showLegend:E,legendPosition:R,legendInteraction:D,stroke:_,strokeWidth:O,opacity:$}=e,{width:W,height:B,enableHover:z,showLabels:F=!0,title:H,description:q,summary:Y,accessibleTable:X}=r,G=Sl({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:E,legendPosition:R,legendInteraction:D,selection:T,linkedHover:j,onObservation:A,onClick:C,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SankeyDiagram",chartId:L,marginDefaults:r.marginDefaults,userMargin:a,width:W,height:B,hasTitle:!!H,loading:N,loadingContent:P,emptyContent:I}),V=(0,Kl.useMemo)(()=>new Map,[]),U=(0,Kl.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Ft(e.data||e,h,G.colorScale):pl(void 0,G.themeCategorical,f,void 0,V),t},[h,G.colorScale,G.themeCategorical,f,V]),Q=(0,Kl.useMemo)(()=>Cl(h,u),[h,u]),K=(0,Kl.useMemo)(()=>Ml(Pl(U,g,Q,e=>e.data||e),{stroke:_,strokeWidth:O,opacity:$}),[U,g,Q,_,O,$]),Z=(0,Kl.useMemo)(()=>wl({edgeColorBy:p,colorBy:h,colorScale:G.colorScale,nodeStyleFn:K,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[p,h,G.colorScale,K,k]),J=(0,Kl.useMemo)(()=>Ml(Z,{stroke:_,strokeWidth:O,opacity:$}),[Z,_,O,$]),ee=(0,Kl.useMemo)(()=>{if(!F)return;const e=x||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[F,x,d]),te=_l({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?(0,Zl.jsx)(Ma,{componentName:"SankeyDiagram",message:te,width:W,height:B}):G.loadingEl?G.loadingEl:G.emptyEl?G.emptyEl:(0,Zl.jsx)(Ta,{componentName:"SankeyDiagram",width:W,height:B,children:(0,Zl.jsx)(Cs,{ref:n,chartType:"sankey",...G.safeNodes.length>0&&{nodes:G.safeNodes},...null!=i&&{edges:G.safeEdges},size:[W,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:G.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:y,nodeAlign:m,nodePaddingRatio:b,nodeWidth:v,nodeStyle:K,edgeStyle:J,colorBy:h,colorScheme:G.effectivePalette,edgeColorBy:p,edgeOpacity:k,edgeSort:w,nodeLabel:ee,showLabels:F,enableHover:z,tooltipContent:!1===S?()=>null:Fn(S)||void 0,...$l({linkedHover:j,selection:T,onObservation:A,onClick:C,mobileInteraction:G.mobileInteraction,customHoverBehavior:G.customHoverBehavior,customClickBehavior:G.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:G.legend,legendPosition:G.legendPosition,...D&&"none"!==D&&{legendHoverBehavior:G.legendState.onLegendHover,legendClickBehavior:G.legendState.onLegendClick,legendHighlightedCategory:G.legendState.highlightedCategory,legendIsolatedCategories:G.legendState.isolatedCategories},className:s,title:H,description:q,summary:Y,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...M})})});Jl.displayName="SankeyDiagram";var ec=require("react"),tc=require("react/jsx-runtime"),nc=(0,ec.forwardRef)(function(e,t){const n=(0,ec.useRef)(null);Ts(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:p="source",padAngle:y=.01,groupWidth:m=20,sortGroups:b,nodeLabel:v,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:S,onClick:M,chartId:A,selection:C,linkedHover:L,loading:T,loadingContent:j,emptyContent:N,legendInteraction:P,stroke:I,strokeWidth:E,opacity:R}=e,{width:D,height:_,enableHover:O,showLabels:$=!0,title:W,description:B,summary:z,accessibleTable:F}=r,H=Sl({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:!1,legendInteraction:P,selection:C,linkedHover:L,onObservation:S,onClick:M,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ChordDiagram",chartId:A,marginDefaults:r.marginDefaults,userMargin:a,width:D,height:_,hasTitle:!!W,loading:T,loadingContent:j,emptyContent:N}),q=(0,ec.useMemo)(()=>new Map,[]),Y=(0,ec.useMemo)(()=>new Map,[]),X=H.safeNodes.length>0,G=(0,ec.useMemo)(()=>{if(X)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=Ft(e.data||e,h,H.colorScale);else{const r=Array.isArray(f)?f:Dt[f]||_t,o=Array.isArray(r)?r:_t,i=(e.id??e.data?.[d]??"")+"";Y.has(i)||Y.set(i,Y.size);const a=e.index??t??Y.get(i);n.fill=o[a%o.length]}return n}},[X,h,H.colorScale,f,d,Y]),V=(0,ec.useMemo)(()=>Cl(h),[h]),U=(0,ec.useMemo)(()=>{if(G||g&&g.length>0)return Ml(Pl(G,g,V,e=>e.data||e),{stroke:I,strokeWidth:E,opacity:R})},[G,g,V,I,E,R]),Q=(0,ec.useMemo)(()=>{if(X)return wl({edgeColorBy:p,colorBy:h,colorScale:H.colorScale,nodeStyleFn:U||(e=>({fill:pl(void 0,H.themeCategorical,f,void 0,q)})),edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}})},[X,p,h,H.colorScale,U,x,H.themeCategorical,f,q]),K=(0,ec.useMemo)(()=>Q?Ml(Q,{stroke:I,strokeWidth:E,opacity:R}):void 0,[Q,I,E,R]),Z=(0,ec.useMemo)(()=>{if(!$)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[$,v,d]),J=_l({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return J?(0,tc.jsx)(Ma,{componentName:"ChordDiagram",message:J,width:D,height:_}):H.loadingEl?H.loadingEl:H.emptyEl?H.emptyEl:(0,tc.jsx)(Ta,{componentName:"ChordDiagram",width:D,height:_,children:(0,tc.jsx)(Cs,{ref:n,chartType:"chord",...H.safeNodes.length>0&&{nodes:H.safeNodes},...null!=i&&{edges:H.safeEdges},size:[D,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:H.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:y,groupWidth:m,sortGroups:b,nodeStyle:U,edgeStyle:K,colorBy:h,colorScheme:H.effectivePalette,edgeColorBy:p,edgeOpacity:x,nodeLabel:Z,showLabels:$,enableHover:O,tooltipContent:!1===k?()=>null:Fn(k)||void 0,...$l({linkedHover:L,selection:C,onObservation:S,onClick:M,mobileInteraction:H.mobileInteraction,customHoverBehavior:H.customHoverBehavior,customClickBehavior:H.customClickBehavior,linkedHoverInClickPredicate:!1}),...P&&"none"!==P&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},className:s,title:W,description:B,summary:z,accessibleTable:F,...null!=e.animate&&{animate:e.animate},...w})})});nc.displayName="ChordDiagram";var rc=require("react"),oc=require("react/jsx-runtime");function ic(e){const t=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,layout:i="tree",orientation:a="vertical",childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:f="curve",nodeLabel:g,nodeSize:p=5,tooltip:y,frameProps:m={},onObservation:b,onClick:v,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:T}=e,{width:j,height:N,enableHover:P,showLabels:I=!0,title:E,description:R,summary:D,accessibleTable:_}=t,O=Sl({nodes:(0,rc.useMemo)(()=>vl(n??null,s),[n,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:A,selection:k,linkedHover:w,onObservation:b,onClick:v,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:t.marginDefaults,userMargin:r,width:j,height:N,hasTitle:!!E,loading:S,loadingContent:M}),$=(0,rc.useMemo)(()=>new Map,[]),W=(0,rc.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Bt[(e.depth||0)%Bt.length]:u?Ft(e.data||e,u,O.colorScale):pl(void 0,O.themeCategorical,d,void 0,$),t},[u,h,O.colorScale,O.themeCategorical,d,$]),B=(0,rc.useMemo)(()=>Ml(W,{stroke:C,strokeWidth:L,opacity:T}),[W,C,L,T]),z=(0,rc.useMemo)(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),F=(0,rc.useMemo)(()=>Ml(z,{stroke:C,strokeWidth:L,opacity:T}),[z,C,L,T]),H=(0,rc.useMemo)(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return kl(l)},[i,l]),q=Dl({componentName:"TreeDiagram",data:n});return q?(0,oc.jsx)(Ma,{componentName:"TreeDiagram",message:q,width:j,height:N}):O.loadingEl?O.loadingEl:(0,oc.jsx)(Ta,{componentName:"TreeDiagram",width:j,height:N,children:(0,oc.jsx)(Cs,{chartType:i,...null!=n&&{data:n},size:[j,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:O.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:H,treeOrientation:a,edgeType:f,nodeStyle:B,edgeStyle:F,colorBy:u,colorScheme:O.effectivePalette,colorByDepth:h,nodeSize:p,nodeLabel:I?g||c:void 0,showLabels:I,enableHover:P,tooltipContent:!1===y?()=>null:Fn(y)||void 0,...$l({linkedHover:w,selection:k,onObservation:b,onClick:v,mobileInteraction:O.mobileInteraction,customHoverBehavior:O.customHoverBehavior,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:O.legendState.onLegendHover,legendClickBehavior:O.legendState.onLegendClick,legendHighlightedCategory:O.legendState.highlightedCategory,legendIsolatedCategories:O.legendState.isolatedCategories},className:o,title:E,description:R,summary:D,accessibleTable:_,...null!=e.animate&&{animate:e.animate},...m})})}ic.displayName="TreeDiagram";var ac=require("react"),sc=require("react"),lc=require("react/jsx-runtime");function cc(e){const t=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:f=4,paddingTop:g,nodeStyle:p,tooltip:y,frameProps:m={},selection:b,linkedHover:v,onObservation:x,onClick:k,chartId:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:T}=e,{nodeStyle:j,...N}=m,{width:P,height:I,enableHover:E,showLabels:R=!0,title:D,description:_,summary:O,accessibleTable:$}=t,W=Sl({nodes:(0,ac.useMemo)(()=>vl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:A,selection:b,linkedHover:v,onObservation:x,onClick:k,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:w,marginDefaults:t.marginDefaults,userMargin:r,width:P,height:I,hasTitle:!!D,loading:S,loadingContent:M}),B=function(e){const t=ar(e=>e.theme.colors.selectionOpacity);return(0,sc.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(b),z=W.customHoverBehavior,F=(0,ac.useCallback)(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),H=(0,ac.useMemo)(()=>new Map,[]),q=(0,ac.useMemo)(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?Bt[(e.depth||0)%Bt.length]:l?Ft(e.data||e,l,W.colorScale):pl(void 0,W.themeCategorical,c,void 0,H),t},[l,u,W.colorScale,W.themeCategorical,c,H]),Y=(0,ac.useMemo)(()=>p||j?e=>({...q(e),...j?j(e)??{}:{},...p?p(e)??{}:{}}):q,[q,p,j]),X=(0,ac.useMemo)(()=>Ml(Y,{stroke:C,strokeWidth:L,opacity:T}),[Y,C,L,T]),G=(0,ac.useMemo)(()=>W.activeSelectionHook?e=>{const t={...X(e)};if(W.activeSelectionHook.isActive)if(W.activeSelectionHook.predicate(e.data||e))B?.selectedStyle&&Object.assign(t,B.selectedStyle);else{const e=B?.unselectedOpacity??Es;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,B?.unselectedStyle&&Object.assign(t,B.unselectedStyle)}return t}:X,[X,W.activeSelectionHook,B]),V=(0,ac.useMemo)(()=>kl(a),[a]),U=void 0!==g?g:!R||"parent"!==d&&"all"!==d?void 0:18,Q=Dl({componentName:"Treemap",data:n});return Q?(0,lc.jsx)(Ma,{componentName:"Treemap",message:Q,width:P,height:I}):W.loadingEl?W.loadingEl:(0,lc.jsx)(Ta,{componentName:"Treemap",width:P,height:I,children:(0,lc.jsx)(Cs,{chartType:"treemap",...null!=n&&{data:n},size:[P,I],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:W.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:V,padding:f,paddingTop:U,nodeStyle:G,colorBy:l,colorScheme:W.effectivePalette,colorByDepth:u,nodeLabel:R?h||s:void 0,showLabels:R,labelMode:d,enableHover:E,tooltipContent:!1===y?()=>null:Fn(y)||void 0,...$l({linkedHover:v,selection:b,onObservation:x,onClick:k,mobileInteraction:W.mobileInteraction,customHoverBehavior:F,customClickBehavior:W.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},className:o,title:D,description:_,summary:O,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...N})})}cc.displayName="Treemap";var uc=require("react"),dc=require("react/jsx-runtime");function hc(e){const t=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:f=4,tooltip:g,frameProps:p={},onObservation:y,onClick:m,chartId:b,selection:v,linkedHover:x,loading:k,loadingContent:w,legendInteraction:S,stroke:M,strokeWidth:A,opacity:C}=e,{width:L,height:T,enableHover:j,showLabels:N=!0,title:P,description:I,summary:E,accessibleTable:R}=t,D=Sl({nodes:(0,uc.useMemo)(()=>vl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:S,selection:v,linkedHover:x,onObservation:y,onClick:m,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:r,width:L,height:T,hasTitle:!!P,loading:k,loadingContent:w}),_=(0,uc.useMemo)(()=>new Map,[]),O=(0,uc.useMemo)(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Bt[(e.depth||0)%Bt.length]:l?Ft(e.data||e,l,D.colorScale):pl(void 0,D.themeCategorical,c,void 0,_),t},[l,u,D.colorScale,h,D.themeCategorical,c,_]),$=(0,uc.useMemo)(()=>Ml(O,{stroke:M,strokeWidth:A,opacity:C}),[O,M,A,C]),W=(0,uc.useMemo)(()=>kl(a),[a]),B=Dl({componentName:"CirclePack",data:n});return B?(0,dc.jsx)(Ma,{componentName:"CirclePack",message:B,width:L,height:T}):D.loadingEl?D.loadingEl:(0,dc.jsx)(Ta,{componentName:"CirclePack",width:L,height:T,children:(0,dc.jsx)(Cs,{chartType:"circlepack",...null!=n&&{data:n},size:[L,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:D.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:W,padding:f,nodeStyle:$,colorBy:l,colorScheme:D.effectivePalette,colorByDepth:u,nodeLabel:N?d||s:void 0,showLabels:N,enableHover:j,tooltipContent:!1===g?()=>null:Fn(g)||void 0,...$l({linkedHover:x,selection:v,onObservation:y,onClick:m,mobileInteraction:D.mobileInteraction,customHoverBehavior:D.customHoverBehavior,customClickBehavior:D.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:D.legendState.onLegendHover,legendClickBehavior:D.legendState.onLegendClick,legendHighlightedCategory:D.legendState.highlightedCategory,legendIsolatedCategories:D.legendState.isolatedCategories},className:o,title:P,description:I,summary:E,accessibleTable:R,...null!=e.animate&&{animate:e.animate},...p})})}hc.displayName="CirclePack";var fc=require("react"),gc=require("react/jsx-runtime"),pc=Bt;function yc(e){const t=ml(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",nodeIdAccessor:a="name",colorBy:s,colorScheme:l,colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:f,revolutionStyle:g,eccentricity:p=1,showRings:y=!0,nodeRadius:m=6,showLabels:b=!1,animated:v=!0,tooltip:x,foregroundGraphics:k,annotations:w,frameProps:S={},onObservation:M,onClick:A,chartId:C,selection:L,linkedHover:T,loading:j,loadingContent:N,stroke:P,strokeWidth:I,opacity:E}=e,{width:R,height:D,enableHover:_,title:O,description:$,summary:W,accessibleTable:B}=t,z=Sl({nodes:(0,fc.useMemo)(()=>vl(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:c?void 0:s,colorScheme:l,showLegend:!1,legendInteraction:void 0,selection:L,linkedHover:T,onObservation:M,onClick:A,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:C,marginDefaults:tl(t),userMargin:r,width:R,height:D,hasTitle:!!O,loading:j,loadingContent:N}),F=(0,fc.useMemo)(()=>new Map,[]),{colorScale:H,customClickBehavior:q,customHoverBehavior:Y,themeCategorical:X}=z,G=(0,fc.useMemo)(()=>{if(Array.isArray(l))return l;const e=Dt[l];return Array.isArray(e)?e:_t},[l]),V=(0,fc.useMemo)(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=c?n?G[0]:pc[(e.depth||0)%pc.length]:s?Ft(e.data||e,s,H):pl(void 0,X,l,void 0,F),t.opacity=n?1:.85,t},[s,c,H,G,X,l,F]),U=(0,fc.useMemo)(()=>Ml(V,{stroke:P,strokeWidth:I,opacity:E}),[V,P,I,E]),Q=(0,fc.useMemo)(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),K=(0,fc.useMemo)(()=>e=>{Y(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Y]),Z=(0,fc.useMemo)(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=Dl({componentName:"OrbitDiagram",data:n});return J?(0,gc.jsx)(Ma,{componentName:"OrbitDiagram",message:J,width:R,height:D}):z.loadingEl?z.loadingEl:(0,gc.jsx)(Ta,{componentName:"OrbitDiagram",width:R,height:D,children:(0,gc.jsx)(Cs,{chartType:"orbit",...null!=n&&{data:n},size:[R,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,nodeIDAccessor:a,childrenAccessor:i,nodeStyle:U,edgeStyle:Q,colorBy:s,colorScheme:z.effectivePalette,colorByDepth:c,nodeSize:m,nodeLabel:b?a:void 0,showLabels:b,enableHover:!v&&_,tooltipContent:v?void 0:!1===x?()=>null:Fn(x)||void 0,...$l({linkedHover:T,selection:L,onObservation:M,onClick:A,mobileInteraction:z.mobileInteraction,customHoverBehavior:K,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:k,annotations:w,className:o,title:O,description:$,summary:W,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:f,orbitRevolutionStyle:g,orbitEccentricity:p,orbitShowRings:y,orbitAnimated:v,accessibleTable:B,...null!=e.animate&&{animate:e.animate},...S})})}yc.displayName="OrbitDiagram";var mc=require("react"),bc={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function vc(e="static"){return bc[e]??bc.static}var xc=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function kc(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:xc.has(e.kind)?"fatal":"warn"}function wc(e,t,n,r={}){const o=vc(r.usageMode??"static"),i=[],a=new Set;for(const t of e)a.has(t.id)&&i.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),a.add(t.id);const s=new Set,l=Array.isArray(n)&&2===n.length,c=l&&Number.isFinite(n[0])&&Number.isFinite(n[1]);l&&c&&c&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)s.has(e.id)&&i.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),a.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&i.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&i.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}function Sc(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function Mc(e){const{desired:t,minGaps:n,weights:r}=e,o=t.length;if(0===o)return[];if(n.length!==Math.max(0,o-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(o).fill(0);for(let e=1;o>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const a=[];for(let e=0;o>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(r?.[e])?r[e]:1),o=(Number.isFinite(t[e])?t[e]:0)-i[e];for(a.push({start:e,end:e,weight:n,mean:o});a.length>1;){const e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const s=Number.isFinite(e.min)?e.min:-1/0,l=Number.isFinite(e.max)?e.max-i[o-1]:1/0,c=s>l?s:l,u=Array(o);for(const e of a){const t=Math.max(s,Math.min(c,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function Ac(e,t){let n=0,r=e.length-1,o=-1;for(;r>=n;){const i=n+r>>>1;e[i].at>t?r=i-1:(o=i,n=i+1)}return 0>o?{at:t,before:0,after:0}:e[o]}function Cc(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],r=[0];for(let o=0;e.length-1>o;o++){const i=e[o],a=e[o+1],s=[...new Set([...i.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t);let l=0;for(const e of s){const t=Ac(i,e),n=Ac(a,e);l=Math.max(l,t.after+n.before)}n.push(l),r.push(r[r.length-1]+l+t)}return{adjacentClearance:n,positions:r}}function Lc(e,t,n,r={}){let o=[...e];if(1>=o.length)return o;let i=[...o],a=n(o),s=1;const l=Math.max(0,r.passes??6),c=Math.max(1,r.maxEvaluations??1/0);for(let e=0;l>e&&c>s;e++){const e=new Map(o.map((e,t)=>[e,t])),l=new Map,c=new Map;for(const n of t){const t=e.get(n.source),r=e.get(n.target);if(null==t||null==r)continue;const o=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;l.set(n.source,(l.get(n.source)??0)+r*o),c.set(n.source,(c.get(n.source)??0)+o),l.set(n.target,(l.get(n.target)??0)+t*o),c.set(n.target,(c.get(n.target)??0)+o)}o=o.map((e,t)=>({item:e,index:t,barycenter:(l.get(e)??t)/(c.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(r.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(o);if(s++,a>u)a=u,i=[...o];else if(u===a)break}return i}function Tc(e,t,n={}){const r=[...e],o=r.length;if(1>=o||o>(n.maxItems??8))return r;const i=Math.max(1,n.maxEvaluations??1/0);let a=0,s=[...r],l=1/0;const c=()=>{if(a>=i)return;const e=t(r);a++,l>e&&(l=e,s=[...r])};c();const u=Array(o).fill(0);let d=0;for(;o>d&&i>a;)if(d>u[d]){const e=d%2==0?0:u[d];[r[e],r[d]]=[r[d],r[e]],c(),u[d]++,d=0}else u[d]=0,d++;return s}function jc(e,t){return t>e?-1:e>t?1:0}function Nc(e){return e.occupants.map(e=>e.id).sort(jc).join("\0")}function Pc(e,t,n=0){return e.slice(0,-1).map((r,o)=>null!=r.group&&r.group===e[o+1].group?n:t)}function Ic(e,t){return e.map(e=>{const n=new Map;for(const r of e.occupants){const e=t[r.id];if(e)for(const t of e.samples){const e=n.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;n.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function Ec(e,t,n){if(0===e.length)return[];const{padding:r,plotH:o,valueScale:i}=n,a=n.stackValueScale??i,s=Pc(e,r,n.groupPadding??0),l=[r+e[0].peak.topPeak*a];for(let n=1;e.length>n;n++)l.push(l[n-1]+t[n-1]*a+s[n-1]);const c=l[l.length-1]+e[e.length-1].peak.botPeak*a+r;if(c>o&&c>0){const e=o/c;for(let t=0;l.length>t;t++)l[t]*=e}return l}function Rc(e,t){const n=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){const o=e.sideMassBefore*t;return n+("top"===e.side?r/2-o:o-r/2)}const o=e.sideMassAfter*t;return n+("top"===e.side?r/2-o:o-r/2)}function Dc(e,t,n,r,o,i){const a=i.adjacentClearance?[...i.adjacentClearance]:Cc(Ic(r,n)).adjacentClearance,s=Ec(r,a,i);let l="hug"===i.lanePlacement?function(e,t,n,r,o,i,a){const s=e.length;if(0===s)return[];const{padding:l,plotH:c,valueScale:u}=a,d=Pc(e,l,a.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=l+e[0].peak.topPeak*u,g=c-l-e[s-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=g-f)return Ec(e,o,a);let p=1===s?[(f+g)/2]:[...i];for(let e=0;12>e;e++){const e=Array(s).fill(0),o=Array(s).fill(0);for(const i of n){const n=t[i.source],a=t[i.target];if(null==n||null==a||n===a)continue;const s=r[i.source]?.localAttachments.get(i.id),l=r[i.target]?.localAttachments.get(i.id);if(!s||!l)continue;const c=i.value>0&&Number.isFinite(i.value)?i.value:1,d=Rc(s,u),h=Rc(l,u);e[n]+=(p[a]+h-d)*c,o[n]+=c,e[a]+=(p[n]+d-h)*c,o[a]+=c}const i=Mc({desired:p.map((t,n)=>0===o[n]?t:.45*t+e[n]/o[n]*.55),minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:g});let a=0;for(let e=0;s>e;e++)a=Math.max(a,Math.abs(i[e]-p[e]));if(p=i,.01>a)break}return p}(r,o,t,n,a,s,i):[...s];if("hug"===i.lanePlacement){const n=t=>{const n={};for(const r of e)n[r.id]=t[o[r.id]];return n};_c(n(l),t)>_c(n(s),t)+1e-6&&(l=[...s])}const c={};for(const t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(const t of e){const e=c[t.id],r=n[t.id];Number.isFinite(e)&&r&&(u=Math.min(u,e-r.topPeak*i.valueScale),d=Math.max(d,e+r.botPeak*i.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&i.plotH>0?Math.max(0,Math.min(1,(d-u)/i.plotH)):0}}function _c(e,t){let n=0;for(const r of t){const t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(n+=Math.abs(t-o)*(r.value>0?r.value:1))}return n}function Oc(e,t){const n=e?.samples;if(!n||0===n.length||n[0].t>t)return{top:0,bot:0};let r=0,o=n.length-1,i=0;for(;o>=r;){const e=r+o>>>1;n[e].t>t?o=e-1:(i=e,r=e+1)}const a=n[i].boundaryOffset??0;return{top:n[i].topMass-a,bot:n[i].botMass+a}}function $c(e,t,n,r,o){const i=1-o;return i*i*i*e+3*i*i*o*t+3*i*o*o*n+o*o*o*r}function Wc(e,t){let n=0,r=1;for(let o=0;28>o;o++){const o=(n+r)/2;e>$c(0,t,t,1,o)?n=o:r=o}return(n+r)/2}function Bc(e,t,n){const r=t+Rc(e,n),o=e.value*n/2;return[r-o,r+o]}function zc(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))/Math.max(1e-9,t-e)}function Fc(e,t,n,r,o,i,a){const{valueScale:s,domain:l,mode:c="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5;let d=0;for(const a of e){const e=r[a.source],h=r[a.target];if(null==e||null==h||2>Math.abs(e-h))continue;const f=t[a.source]?.localAttachments.get(a.id),g=t[a.target]?.localAttachments.get(a.id);if(!f||!g)continue;const p=Math.max(a.startTime,l?.[0]??-1/0),y=Math.min(a.endTime,l?.[1]??1/0);if(p>=y)continue;const[m,b]=Bc(f,o[a.source],s),[v,x]=Bc(g,o[a.target],s),k=Math.min(e,h)+1,w=Math.max(e,h)-1;for(let e=k;w>=e;e++){const r=n[e];if(!r)continue;const l=[p,y];if("quality"===c)for(const e of r.occupants)for(const n of t[e.id]?.samples??[])n.t>p&&y>n.t&&l.push(n.t);const h=e=>{const n=Wc((e-p)/(y-p),u),l=$c(m,m,v,v,n),c=$c(b,b,x,x,n);let d=0;for(const n of r.occupants){if(n.id===a.source||n.id===a.target)continue;const r=i[n.id];if(null!=r?.start&&r.start>e)continue;if(null!=r?.end&&e>r.end)continue;const u=Oc(t[n.id],e),h=o[n.id];d=Math.max(d,zc(l,c,h-u.top*s,h+u.bot*s))}return d},f=[...new Set(l)].sort((e,t)=>e-t);let g=0;for(let e=0;f.length-1>e;e++){const t=f[e],n=f[e+1]-t;g+=(h(t+.25*n)+h(t+.5*n)+h(t+.75*n))/3*n}d+=g/(y-p)*(a.value>0?a.value:1)}}return d}function Hc(e,t,n,r,o,i,a,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:_c(a,n),transitOcclusion:Fc(n,r,o,i,a,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function qc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Yc(e,t){return e.map(e=>({t:qc(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Xc(e,t,n){const r=t+(e.boundaryOffset??0)*n,o=e.value*n;if("out"===e.kind){const t=e.sideMassBefore*n;if("top"===e.side){const e=r-t;return[e,e+o]}const i=r+t;return[i-o,i]}const i=e.sideMassAfter*n;if("top"===e.side){const e=r-i;return[e,e+o]}const a=r+i;return[a-o,a]}function Gc(e,t,n,r,o="temporal"){const i=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(const e of i)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{s.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(l[e.kind]??99)-(l[t.kind]??99)||((e,t)=>{if(!r||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const n=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof o&&Number.isFinite(o)&&n!==o?"top"===e.side?n-o:o-n:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const n=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof o&&Number.isFinite(o)&&n!==o?"top"===e.side?o-n:n-o:0}return 0})(e,t)||jc(e.edge?.id??"",t.edge?.id??"")||jc(e.side,t.side)||e.delta-t.delta)},u=s.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(s.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;c();let f=null,g=0;for(const e of s)e.time!==f&&(f=e.time,g=0),e.sequence=g++;const p=e=>({time:e.time,phase:0,sequence:e.sequence??0}),y=[];let m=0,b=0;for(const e of s)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?m:b);if(n>0){const t="top"===e.side?"bot":"top",r=Math.min(n,"top"===t?m:b);if(r>0){const o=p(e);y.push({...o,delta:-r,kind:"transfer-out",side:t}),y.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?m-=r:b-=r,"top"===e.side?m+=r:b+=r,n-=r}n>0&&null!==h&&(y.push({time:h,delta:+n,kind:"create",side:e.side}),"top"===e.side?m+=n:b+=n)}"top"===e.side?m-=t:b-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?m+=t:b+=t}s.push(...y),c();let v=0,x=0,k=0,w=0,S=0,M=0;const A=[],C=new Map,L=e=>{A.push({t:e,topMass:v,botMass:x,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},T=()=>{w=Math.max(w,v+x),S=Math.max(S,v-k),M=Math.max(M,x+k)};for(const e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&L(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:x;C.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:x+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,T(),L(e.time)):"transfer-out"!==e.kind&&(T(),"out"!==e.kind||v+x>1e-12||(k=0),L(e.time))}const j=[];let N=0;for(;A.length>N;){let e=N;for(;A.length>e+1&&A[e+1].t===A[N].t;)e++;j.push(A[N]);for(let t=N+1;e>=t;t++){const e=j[j.length-1];A[t].topMass===e.topMass&&A[t].botMass===e.botMass&&(A[t].boundaryOffset??0)===(e.boundaryOffset??0)||j.push(A[t])}N=e+1}const P=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let I=null;for(const e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===I||I>e.systemInTime)&&(I=e.systemInTime);let E=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===E||e.systemOutTime>E)&&(E=e.systemOutTime);if(j.length>0){const e=j[j.length-1],t=Math.max(null!=P?P:-1/0,null!=E?E:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&j.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const n=j[0],r=j.find(e=>e.topMass+e.botMass>0);let o,i=1/0;null!=d&&Number.isFinite(d)&&n.t>d&&n.topMass+n.botMass>0&&(i=d,o=n),r&&null!=I&&Number.isFinite(I)&&r.t>I&&i>I&&(i=I,o=r),o&&Number.isFinite(i)&&j.unshift({t:i,topMass:o.topMass,botMass:o.botMass,...null!=o.boundaryOffset&&{boundaryOffset:o.boundaryOffset}})}let R=j;if("max"===o&&null!=d&&null!=P&&P>d){let e,t=0;for(const n of j){const r=n.topMass+n.botMass;r>t&&(t=r,e=n)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};R=[...j.filter(e=>d>e.t),{t:d,...t},{t:P,...t},...j.filter(e=>e.t>P)]}}return{samples:R,peak:w,topPeak:S,botPeak:M,localAttachments:C}}function Vc(e){const t={};return e.forEach((e,n)=>{for(const r of e.occupants)t[r.id]=n}),t}function Uc(e,t,n){e.splice(0,e.length,...n);const r=Vc(n);for(const e of Object.keys(t))delete t[e];Object.assign(t,r)}function Qc(e){const t=new Map,n=[];e.forEach((e,r)=>{if(!e.group)return void n.push({anchor:r,stableId:Nc(e),slots:[e]});const o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(const[e,r]of t)n.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(Nc).join("\0")}`,slots:r.slots});return n.sort((e,t)=>e.anchor-t.anchor||jc(e.stableId,t.stableId))}function Kc(e){return e.some(e=>e.group)?Qc(e).flatMap(e=>e.slots):[...e]}function Zc(e){return e.flatMap(e=>e.slots)}function Jc(e,t,n){const r=new Map;return e.forEach((e,t)=>{for(const n of e.slots)r.set(n,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;const i=new Map;for(const t of e.slots)i.set(t,0);for(const e of t){const t=r.get(e.source),n=r.get(e.target);if(null==t||null==n)continue;const a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&n!==o){const t=n>o?1:-1;i.set(e.source,(i.get(e.source)??0)+a*t)}else if(n===o&&t!==o){const n=t>o?1:-1;i.set(e.target,(i.get(e.target)??0)+a*n)}}const a=[...e.slots].sort((e,t)=>(i.get(e)??0)-(i.get(t)??0)||n(e,t));return{...e,slots:a}})}function eu(e,t){e.some(e=>e.group)&&Uc(e,t,Kc(e))}function tu(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function nu(e,t){return function(e,t,n=()=>!0){let r=0;for(let o=0;e.length>o;o++){const[i,a]=t(e[o]);for(let s=o+1;e.length>s;s++){if(!n(e[o],e[s]))continue;const[l,c]=t(e[s]);0>(i-l)*(a-c)&&r++}}return r}(t,t=>[e[t.source],e[t.target]],tu)}function ru(e,t){let n=0;for(const r of t){const t=e[r.source],o=e[r.target];null!=t&&null!=o&&(n+=Math.abs(t-o)*(r.value>0?r.value:1))}return n}function ou(e,t,n){const[r,o]=n.get(e.first),[i,a]=n.get(e.second);return 0>(t.get(r)-t.get(i))*(t.get(o)-t.get(a))?1:0}var iu=e=>{let t=1;for(let n=2;e>=n;n++)t*=n;return t},au=828*iu(8),su=3e3;function lu(e,t,n,r,o,i,a){const s=[...o],l=new Map(o.map(e=>[e,Nc(e)])),c=new Map;for(const e of o)for(const t of e.occupants)c.set(t.id,e);const u=new Map,d=[];for(const e of t){const t=c.get(e.source),n=c.get(e.target);t&&n&&(u.set(e,[t,n]),t!==n&&d.push({source:t,target:n,weight:e.value}))}const h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let n=e+1;t.length>n;n++){if(!u.has(t[n])||!tu(t[e],t[n]))continue;const r=new Set([...u.get(t[e]),...u.get(t[n])]);h.push({index:h.length,first:t[e],second:t[n],involvedSlots:r})}const f=new Map;for(const e of o)f.set(e,[]);for(const e of h)for(const t of e.involvedSlots)f.get(t)?.push(e);const g=new Uint32Array(h.length);let p=0;const y=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=a.plotH/Math.max(1,o.length),b=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),v=Math.max(1,y)*(Math.max(1,a.plotH)+m*Math.max(b,o.length)+1e-6*Math.max(1,o.length-1))+1,x=4*m,k={fullCrossing:0,localCrossing:0},w=new Map,S=(e,t)=>{let r=w.get(e);r||(r=new Map,w.set(e,r));const o=r.get(t);if(null!=o)return o;const i=function(e,t,n){return Cc(Ic([e,t],n)).adjacentClearance[0]??0}(e,t,n);return r.set(t,i),i},M=new Map(o.map((e,t)=>[e,t])),A=t.flatMap(e=>{const t=u.get(e);return t?[{source:M.get(t[0]),target:M.get(t[1]),weight:e.value>0?e.value:1}]:[]}),C=new Map;for(const e of t){const t=u.get(e);t&&C.set(e,{source:M.get(t[0]),target:M.get(t[1])})}const L=new Map,T=new Map;for(const e of t)L.has(e.source)||L.set(e.source,new Set),T.has(e.target)||T.set(e.target,new Set),L.get(e.source).add(e.target),T.get(e.target).add(e.source);const j=t.flatMap(e=>{if(!(e=>{const t=new Set([...L.get(e.source)??[],...T.get(e.source)??[]]),n=new Set([...L.get(e.target)??[],...T.get(e.target)??[]]);return 1===L.get(e.source)?.size&&L.get(e.source).has(e.target)||1===t.size&&t.has(e.target)||1===n.size&&n.has(e.source)})(e))return[];const t=C.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),N=e=>{let t=0;for(const n of j)t+=Math.max(0,Math.abs(e[n.source]-e[n.target])-1)*n.weight;return t*x},P=e=>{const t=new Int16Array(o.length);for(let n=0;e.length>n;n++)t[M.get(e[n])]=n;return N(t)},I=h.map(e=>{const t=C.get(e.first),n=C.get(e.second);return[t.source,t.target,n.source,n.target]}),E=new Int16Array(o.length),R=new Float64Array(o.length),D=new Float64Array(o.length+1),_=e=>{for(let t=0;e.length>t;t++)E[M.get(e[t])]=t;let t=0;for(const[e,n,r,o]of I)0>(E[e]-E[r])*(E[n]-E[o])&&t++;if(e.length>0){const t=M.get(e[0]);R[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;e.length>t;t++){const n=M.get(e[t-1]),r=M.get(e[t]);R[r]=R[n]+S(e[t-1],e[t])*a.valueScale+a.padding}const n=M.get(e[e.length-1]),r=R[n]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(r>a.plotH&&r>0){const e=a.plotH/r;for(let t=0;R.length>t;t++)R[t]*=e}}D[0]=0;for(let t=0;e.length>t;t++)D[t+1]=D[t]+e[t].peak.topPeak+e[t].peak.botPeak;let n=0,r=0,o=0;for(const e of A){const t=E[e.source],i=E[e.target];if(n+=Math.abs(t-i)*e.weight,r+=Math.abs(R[e.source]-R[e.target])*e.weight,Math.abs(t-i)>=2){const n=Math.min(t,i)+1;o+=(D[Math.max(t,i)]-D[n])*e.weight}}return t*v+r+o*m+N(E)+1e-6*n},O=(e,n)=>{const r=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(const e of t){const t=n[e.source],i=n[e.target];if(null==t||null==i||2>Math.abs(t-i))continue;const a=Math.min(t,i)+1;o+=(r[Math.max(t,i)]-r[a])*(e.value>0?e.value:1)}return o},$=r=>{const o=Vc(r),i=r.slice(0,-1).map((e,t)=>S(e,r[t+1])),s=Dc(e,t,n,r,o,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:i});return{map:o,geometry:s,weightedLength:ru(o,t),pixelLength:_c(s.centerlines,t),transitOcclusion:O(r,o)}},W=(e,t,n)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*v+t.pixelLength+t.transitOcclusion*m+P(n)+1e-6*t.weightedLength}),B=(e,t)=>{let n=t;if(null==n){const t=new Map(e.map((e,t)=>[e,t]));n=h.reduce((e,n)=>e+ou(n,t,u),0),k.fullCrossing++}return W(n,$(e),e)},z=(e,o,i="quality")=>{let s=o;if(null==s){const t=new Map(e.map((e,t)=>[e,t]));s=h.reduce((e,n)=>e+ou(n,t,u),0),k.fullCrossing++}const l=$(e);return W(s,{...l,transitOcclusion:Fc(t,n,e,l.map,l.geometry.centerlines,r,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:i})},e)};let F=[...s];const H=(e,t)=>jc(l.get(e),l.get(t)),q=function(e){const t=new Set;for(const n of e)if(n.group){if(t.has(n.group))return!0;t.add(n.group)}return!1}(F),Y=e=>{const t=(e=>{const t=Lc(e,d,e=>B(e).cost,{passes:6,compare:H,maxEvaluations:su});let n=B(t),r=su;for(let e=0;6>e&&r>0;e++){let o=!1;const i=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&i.reverse();for(const e of i){if(0>=r--)break;const i=t[e],a=t[e+1],s=new Map(t.map((e,t)=>[e,t]));let l=0;const c=[];p++;for(const e of[...f.get(i)??[],...f.get(a)??[]])g[e.index]!==p&&(g[e.index]=p,c.push(e),l+=ou(e,s,u));[t[e],t[e+1]]=[a,i];const d=new Map(s);d.set(i,e+1),d.set(a,e);let h=0;for(const e of c)h+=ou(e,d,u);k.localCrossing+=c.length;const y=B(t,n.crossings-l+h);n.cost>y.cost?(n=y,o=!0):[t[e],t[e+1]]=[i,a]}if(!o)break}return t})(e);if((e.length>8?1/0:iu(e.length)*(e.length+A.length+I.length))>au)return t;const n=Tc(e,_,{maxItems:8,maxEvaluations:5e4}),r=z(n),o=z(t);return r.crossings!==o.crossings&&o.crossings>r.crossings?n:t},X="geometry-refine"===a.mode;if(X||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder){if(!X&&"inside-out"===a.laneOrder)if(q){const e=Qc(F),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),n=[...e].sort((e,n)=>t(n)-t(e)||jc(e.stableId,n.stableId)),r=Array(n.length);let o=Math.floor((n.length-1)/2)-1,i=Math.floor((n.length-1)/2)+1;n.length>0&&(r[Math.floor((n.length-1)/2)]=n[0]);for(let e=1;n.length>e;e++)e%2==1&&n.length>i||0>o?r[i++]=n[e]:r[o--]=n[e];F=Zc(r)}else{const e=[...F].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||H(e,t)),t=Array(e.length);let n=Math.floor((e.length-1)/2)-1,r=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>r||0>n?t[r++]=e[o]:t[n--]=e[o];F=t}}else F=q?(e=>{let t=Qc(e);if(1>=t.length)return Zc(t);const n=e=>B(Zc(e)).cost;t=Qc(Y(e)),t=Jc(t,d,H);const r=function(e,t){const n=new Map;for(const t of e)for(const e of t.slots)n.set(e,t);const r=new Map;for(const e of t){const t=n.get(e.source),o=n.get(e.target);if(!t||!o||t===o)continue;const i=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(a);s?s.weight=(s.weight??0)+i:r.set(a,{source:t,target:o,weight:i})}return[...r.values()]}(t,d);t=Lc(t,r,n,{passes:6,compare:(e,t)=>jc(e.stableId,t.stableId),maxEvaluations:su}),t=function(e,t,n={}){const r=[...e];if(1>=r.length)return r;let o=t(r),i=1;const a=Math.max(0,n.passes??6),s=Math.max(1,n.maxEvaluations??1/0);for(let e=0;a>e&&s>i;e++){let e=!1;for(let n=0;r.length-1>n&&s>i;n++){[r[n],r[n+1]]=[r[n+1],r[n]];const a=t(r);i++,o>a?(o=a,e=!0):[r[n],r[n+1]]=[r[n+1],r[n]]}if(!e)break}return r}(t,n,{passes:8,maxEvaluations:su});const o=t.length>8?1/0:iu(t.length)*(t.length+A.length+I.length);if(au>=o){const e=Tc(t,e=>_(Zc(e)),{maxItems:8,maxEvaluations:5e4}),n=Zc(e),r=Zc(t),o=z(n),i=z(r);o.crossings!==i.crossings?t=i.crossings>o.crossings?e:t:i.cost>o.cost&&(t=e)}return t=Jc(t,d,H),Zc(t)})(F):Y(F);if(!X&&"crossing-min+inside-out"===a.laneOrder&&F.length>1)if(q){const e=Qc(F);let t=B(Zc(e)),n=Zc(e),r=t;const o=Math.floor((e.length-1)/2),i=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),a=[...e].sort((e,t)=>i(t)-i(e)||jc(e.stableId,t.stableId));for(const i of a){const a=e.indexOf(i);if(a===o)continue;e.splice(a,1),e.splice(o,0,i);const s=Zc(e),l=B(s);l.cost>t.cost?(e.splice(o,1),e.splice(a,0,i)):(t=l,r.cost>l.cost&&(n=s,r=l))}F=n}else{let e=B(F),t=[...F],n=e;const r=Math.floor((F.length-1)/2),o=[...F].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||H(e,t));for(const i of o){const o=F.indexOf(i);if(o===r)continue;F.splice(o,1),F.splice(r,0,i);const a=B(F);a.cost>e.cost?(F.splice(r,1),F.splice(o,0,i)):(e=a,n.cost>a.cost&&(t=[...F],n=a))}F=t}if((X||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&F.length>1)if(q){let e=Qc(F),t=z(Zc(e),void 0,"score");for(let n=0;6>n&&e.length>1;n++){let n=!1;for(let r=0;e.length-1>r;r++){[e[r],e[r+1]]=[e[r+1],e[r]];const o=Zc(e),i=z(o,void 0,"score");t.cost>i.cost?(F=o,t=i,n=!0):[e[r],e[r+1]]=[e[r+1],e[r]]}if(!n)break}e=Jc(Qc(F),d,H),F=Zc(e)}else{let e=z(F,void 0,"score");for(let t=0;F.length-1>t;t++){const n=F[t],r=F[t+1],o=new Map(F.map((e,t)=>[e,t]));let i=0;const a=[];p++;for(const e of[...f.get(n)??[],...f.get(r)??[]])g[e.index]!==p&&(g[e.index]=p,a.push(e),i+=ou(e,o,u));[F[t],F[t+1]]=[r,n];const s=new Map(o);s.set(n,t+1),s.set(r,t);let l=0;for(const e of a)l+=ou(e,s,u);k.localCrossing+=a.length;const c=z(F,e.crossings-i+l,"score");e.cost>c.cost?e=c:[F[t],F[t+1]]=[n,r]}}const G=Kc(s);F=Kc(F);let V=z(F);const U=z(G);if(X){const e=P(G),t=P(F);(V.crossings>U.crossings||V.crossings===U.crossings&&t>e+1e-9||V.cost>U.cost)&&(F=G,V=U)}else V.cost>U.cost&&(F=G,V=U);return Uc(o,i,F),{before:U,after:V,initialOrder:s.map(e=>l.get(e)),evaluations:k}}function cu(e,t,n){const r=e.map(e=>{const r=e.occupants.map(e=>({id:e.id,end:n[e.id]?.end??e.end}));let o=0,i=0;for(const e of r){const n=t[e.id];o=Math.max(o,n?.topPeak||0),i=Math.max(i,n?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:i},...null!=e.group?{group:e.group}:{}}}),o={};return r.forEach((e,t)=>{for(const n of e.occupants)o[n.id]=t}),{slots:r,slotByNode:o}}var uu=new Map,du=1e-9,hu=1e5;function fu(e,t){let n=1/0,r=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>du&&(n=Math.min(n,t.t),r=Math.max(r,t.t));return Number.isFinite(n)&&Number.isFinite(r)?(null!=t.start&&(n=Math.max(n,t.start)),null!=t.end&&(r=Math.min(r,t.end)),n>r?{start:null,end:null}:{start:n,end:r}):{start:null,end:null}}function gu(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function pu(e,t){return jc(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function yu(e){const t=new Map,n=new Map;for(const r of e)n.has(r.source)||n.set(r.source,new Set),t.has(r.target)||t.set(r.target,new Set),n.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...n].map(([e,t])=>[e,t.size]))}}function mu(e){const t=new Map,n=new Map,r=(e,t,n,r)=>{let o=e.get(t);o||(o=new Map,e.set(t,o)),o.set(n,(o.get(n)??0)+r)};for(const o of e){const e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(n,o.target,o.source,e)}const o=new Map,i=e=>{if(o.has(e))return;const r=t.get(e),i=n.get(e);if(r&&1===r.size&&(!i||0===i.size)){const[t,n]=[...r][0];return void o.set(e,{partner:t,weight:n})}const a=new Map;for(const[e,t]of r??[])a.set(e,(a.get(e)??0)+t);for(const[e,t]of i??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){const[t,n]=[...a][0];o.set(e,{partner:t,weight:n})}};for(const t of e)i(t.source),i(t.target);return o}function bu(e,t,n){const r=n.get(e),o=n.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function vu(e,t,n){return!!n.has(e)&&t.some(t=>!bu(e,t,n))}function xu(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function ku(e,t,n,r){if(12>=e.length||1>=r.slotCount)return r.assignment;const o=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Map),a=yu(n);for(const e of n){const t=o.get(e.source),n=o.get(e.target);if(null==t||null==n||t===n)continue;const r=xu(e,a);i[t].set(n,(i[t].get(n)??0)+r),i[n].set(t,(i[n].get(t)??0)+r)}const s=mu(n),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>new Map);let u=0;for(let n=0;e.length-1>n&&5e4>u;n++)if(s.has(e[n]))for(let r=n+1;e.length>r;r++){if(!s.has(e[r]))continue;if(t.conflicts(e[n],e[r]))continue;u++;const o=Math.min(l[n],l[r])||Math.max(l[n],l[r]),i=bu(e[n],e[r],s)?o:-o;if(Math.abs(i)>du&&(c[n].set(r,i),c[r].set(n,i),u>=5e4))break}const d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));const f=(e,t,n)=>{const r=d[t],o=d[n];let i=0;const a=new Set;for(const s of[t,n])for(const[l,c]of e[s]){const e=l>s?`${s}:${l}`:`${l}:${s}`;if(a.has(e))continue;a.add(e);const u=(s===t?o:r)===(l===t?o:l===n?r:d[l]);d[s]===d[l]!==u&&(i+=u?c:-c)}return i},g=(e,t,n)=>{let r=0;for(const[o,i]of e[t]){const e=n===d[o];d[t]===d[o]!==e&&(r+=e?i:-i)}return r},p=(e,t)=>e>du||du>=Math.abs(e)&&t>du,y=(e,t,n,r)=>e>n+du||du>=Math.abs(e-n)&&t>r+du;let m=0;for(let n=0;32>n&&hu>m;n++){let n=null,r=-1,o=-1,a=-1,s=-1/0,l=-1/0;for(let u=0;e.length>u;u++){for(let f=0;h.length>f&&m++<hu;f++){if(f===d[u])continue;if(!h[f].every(n=>!t.conflicts(e[u],e[n])))continue;const m=g(i,u,f),b=g(c,u,f);p(m,b)&&y(m,b,s,l)&&(n="move",r=u,o=-1,a=f,s=m,l=b)}if(m>=hu)break}for(let u=0;e.length-1>u;u++){for(let g=u+1;e.length>g&&m++<hu;g++){const m=d[u],b=d[g];if(m===b)continue;if(!h[b].every(n=>n===g||!t.conflicts(e[u],e[n])))continue;if(!h[m].every(n=>n===u||!t.conflicts(e[g],e[n])))continue;const v=f(i,u,g),x=f(c,u,g);p(v,x)&&y(v,x,s,l)&&(n="swap",r=u,o=g,a=-1,s=v,l=x)}if(m>=hu)break}if(null==n||-1===r)break;if("move"===n){const e=d[r];h[e].splice(h[e].indexOf(r),1),h[a].push(r),d[r]=a;continue}const u=d[r],b=d[o];h[u].splice(h[u].indexOf(r),1,o),h[b].splice(h[b].indexOf(o),1,r),d[r]=b,d[o]=u}return d}function wu(e,t,n,r){const o=function(e,t,n,r){return`${e.map(e=>{const t=n[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,n,r),i=uu.get(o);if(i)return cu(i.slots,n,r);const a={};for(const t of e)a[t.id]=fu(n[t.id],r[t.id]);const s=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,n)=>t[e.id].start-t[n.id].start||t[e.id].end-t[n.id].end||jc(e.id,n.id)).map(e=>e.id)}(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=function(e,t,n,r,o){const i=new Set,a=new Map(e.map(e=>[e,new Set])),s=new Map(e.map(e=>[e,new Set]));for(const e of r)i.add(pu(e.source,e.target)),a.get(e.target)?.add(e.source),s.get(e.source)?.add(e.target);const l=new Map,c=new Set,u=(e,t)=>{for(let n=0;e.length>n;n++)for(let r=n+1;e.length>r;r++){const o=pu(e[n],e[r]);t instanceof Map?t.set(o,[e[n],e[r]]):t.add(o)}};for(const e of s.values())u([...e],l);for(const e of a.values())u([...e],c);const d=new Set;for(const[e,[r,o]]of l)c.has(e)&&(gu(t[r],t[o])||gu(n[r],n[o])&&(d.add(r),d.add(o)));return{conflicts:(e,n)=>{const r=o.get(e),a=o.get(n);return null!=r&&null!=a&&r!==a||null!=r!=(null!=a)&&!i.has(pu(e,n))||!!gu(t[e],t[n])||!(!d.has(e)&&!d.has(n))&&!i.has(pu(e,n))}}}(s,a,r,t,c),d=function(e,t,n=new Map){const r=[],o=[];for(const i of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(i,e))&&!vu(i,e,n));-1!==e||n.has(i)||(e=r.findIndex(e=>e.every(e=>!t.conflicts(i,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(i),o.push(e)}return{assignment:o,slotCount:r.length}}(s,u,mu(t)),h=function(e,t,n,r){if(0===e.length||e.length>12||1>=r.slotCount)return r.assignment;const o=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>new Map),s=Array.from({length:e.length},()=>new Map),l=yu(n);for(const e of n){const t=o.get(e.source),n=o.get(e.target);if(null==t||null==n||t===n)continue;const r=xu(e,l);i[t][n]+=r,i[n][t]+=r,s[t].set(n,(s[t].get(n)??0)+r),a[n].set(t,(a[n].get(t)??0)+r)}const c=mu(n),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let n=t+1;e.length>n;n++){for(const[e,r]of a[t])d[t][n]+=Math.min(r,a[n].get(e)??0);for(const[e,r]of s[t])d[t][n]+=Math.min(r,s[n].get(e)??0);if(c.has(e[t])&&c.has(e[n])){const r=Math.min(u[t],u[n])||Math.max(u[t],u[n]);d[t][n]+=bu(e[t],e[n],c)?r:-r}d[n][t]=d[t][n]}let h=[...r.assignment],f=(t=>{let n=0,r=0;for(let o=0;e.length>o;o++)for(let a=o+1;e.length>a;a++)t[o]===t[a]&&(n+=i[o][a],r+=d[o][a]);return{flow:n,affinity:r}})(h),g=0;const p=Array(e.length).fill(-1),y=Array.from({length:r.slotCount},()=>[]),m=(n,o,a,s)=>{if(g>=75e3)return;if(n===e.length)return g++,void((a>f.flow||a===f.flow&&s>f.affinity||a===f.flow&&s===f.affinity&&function(e,t){for(let n=0;Math.min(e.length,t.length)>n;n++)if(e[n]!==t[n])return t[n]>e[n];return t.length>e.length}(p,h))&&(h=[...p],f={flow:a,affinity:s}));const l=Math.min(o+1,r.slotCount-1);for(let r=0;l>=r;r++){if(y[r].some(r=>t.conflicts(e[n],e[r])))continue;let l=0,c=0;for(const e of y[r])l+=i[n][e],c+=d[n][e];if(p[n]=r,y[r].push(n),m(n+1,Math.max(o,r),a+l,s+c),y[r].pop(),p[n]=-1,g>=75e3)return}};return p[0]=0,y[0].push(0),m(1,0,0,0),h}(s,u,t,{...d,assignment:ku(s,u,t,d)}),f=new Map,g=h.map(e=>(f.has(e)||f.set(e,f.size),f.get(e))),p=Array.from({length:f.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),y={};s.forEach((e,t)=>{const n=g[t],r=p[n];r.occupants.push({id:e,end:a[e].end??-1/0});const o=l.get(e)?.group;o&&(r.group=o),y[e]=n});for(const t of[...e].sort((e,t)=>jc(e.id,t.id)))null==y[t.id]&&(p[0].occupants.push({id:t.id,end:-1/0}),y[t.id]=0);for(const e of p){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||jc(e.id,t.id));for(const t of e.occupants){const r=n[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}const m={slots:p,slotByNode:y};return function(e,t){for(uu.has(e)&&uu.delete(e),uu.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:{...t.slotByNode}});uu.size>12;){const e=uu.keys().next().value;if(null==e)break;uu.delete(e)}}(o,m),m}function Su(e){return e.topMass+e.botMass}function Mu(e,t){const n=e.samples.filter(e=>e.t===t);if(n.length>0)return n.reduce((e,t)=>Su(t)<Su(e)?e:t,n[0]);let r=null;for(const n of e.samples){if(n.t>t)break;r=n}return r}function Au(e,t,n,r,o,i,a=0){const s=new Map;for(const n of e){if(!n.group||!t[n.id])continue;const e=s.get(n.group)??[];e.push(n),s.set(n.group,e)}if(0===s.size||0>=i)return t;const l=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,c]of s){const s=n.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;const u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;const g=(h-u.peak.topPeak*i+(f+d.peak.botPeak*i))/2,p=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),y=new Map;for(const e of c)y.set(e.id,new Map);for(const e of p){const n=new Map;for(const o of c){const i=Mu(t[o.id],e);if(!i||1e-9>=Su(i))continue;const a=r[o.id];if(null==a)continue;const s=n.get(a)??[];s.push({node:o,sample:i}),n.set(a,s)}const s=[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Su(e)))}));if(0===s.length)continue;let l=g-(s.reduce((e,t)=>e+t.mass,0)*i+Math.max(0,a)*Math.max(0,s.length-1))/2;for(const t of s){for(const{node:n,sample:r}of t.active){const t=(l-o[n.id])/i+r.topMass-(r.boundaryOffset??0);y.get(n.id).set(e,t)}l+=t.mass*i+Math.max(0,a)}}for(const e of c){const n=t[e.id],r=l[e.id],o=y.get(e.id),i=[];for(const e of p){const t=o.get(e),r=n.samples.filter(t=>t.t===e);if(r.length>0){i.push(...r.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}})));continue}const a=Mu(n,e);null!=t&&a&&Su(a)>1e-9&&i.push({...a,t:e,boundaryOffset:(a.boundaryOffset??0)+t})}r.samples=i,r.localAttachments=new Map([...n.localAttachments].map(([e,t])=>{const n=o.get(t.time);return[e,{...t,...null!=n?{boundaryOffset:(t.boundaryOffset??0)+n}:{}}]}))}}return l}function Cu(e,t,n,r,o){const{plotH:i,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:g}=o,p={},y={};for(const t of e)p[t.id]=n[t.id].topPeak||0,y[t.id]=n[t.id].botPeak||0;const m="half"===u,b={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=m?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}b[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(i)?i:null}}let v={},x=[],k=[];if(o.frozenSlots){const e=cu(o.frozenSlots,n,b);x=e.slots,v=e.slotByNode,k=x.map(Nc)}else if("reuse"===l){const r=wu(e,t,n,b);x=r.slots,v=r.slotByNode}else e.forEach((e,t)=>{x.push({occupants:[{id:e.id,end:b[e.id]?.end??-1/0}],peak:{topPeak:p[e.id],botPeak:y[e.id]},...e.group?{group:e.group}:{}}),v[e.id]=t});eu(x,v),0===k.length&&(k=x.map(Nc));let w=null;o.frozenSlots||(o.fixedSlotOrder?function(e,t,n){const r=new Map(n.map((e,t)=>[e,t]));Uc(e,t,[...e].sort((e,t)=>(r.get(Nc(e))??1/0)-(r.get(Nc(t))??1/0)||jc(Nc(e),Nc(t))))}(x,v,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(w=lu(e,t,n,b,x,v,{plotH:i,padding:a,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:f,domain:g}))),eu(x,v);const S=Dc(e,t,n,x,v,{plotH:i,padding:a,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),M=0===x.length?0:x[0].peak.topPeak+S.adjacentClearance.reduce((e,t)=>e+t,0)+x[x.length-1].peak.botPeak,A=w?.before.crossings??null,C=w?.after.crossings??null,L=w?.before.weightedLength??null,T=w?.after.weightedLength??null;return{effectiveSlotsHeight:M,centerlines:S.centerlines,laneLifetime:b,slots:x,slotByNode:v,slotCenter:S.slotCenter,stackCenter:S.stackCenter,verticalUtilization:S.verticalUtilization,selectedSlotOrder:x.map(Nc),initialSlotOrder:k,ordering:w,crossingsBefore:A,crossingsAfter:C,lengthBefore:L,lengthAfter:T}}var Lu={highTransitOcclusion:8,highLaneUtilization:.92,residualCrossings:3};function Tu(e){if(!e?.layoutQuality)return[];const t=[],n=e.layoutQuality,r=e.layoutQualityBefore;e.compressedPadding&&t.push({severity:"warning",code:"PROCESS_SANKEY_COMPRESSED_PADDING",message:"Lane gaps were compressed to fit peaks into the plot height.",fix:'Increase height, lower maxValueScale, use packing="reuse", or reduce concurrent peaks.'}),Lu.highTransitOcclusion>n.transitOcclusion||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_TRANSIT",message:`High transit occlusion (${n.transitOcclusion.toFixed(1)}) — ribbons cross dense intermediate lanes.`,fix:'Try laneOrder="crossing-min+inside-out", packing="reuse", or lanePlacement="hug" with a modest maxValueScale.'}),Lu.highLaneUtilization>n.verticalUtilization||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_UTILIZATION",message:`Lane utilization is ${Math.round(100*n.verticalUtilization)}% of plot height.`,fix:"Increase chart height or cap band scale with maxValueScale."});const o=e.crossingsAfter??n.crossings;return null==o||Lu.residualCrossings>o||t.push({severity:"warning",code:"PROCESS_SANKEY_RESIDUAL_CROSSINGS",message:`Ordering left ${o} edge-pair crossings`+(r?` (from ${r.crossings})`:"")+".",fix:'Prefer laneOrder="crossing-min" or "crossing-min+inside-out"; check for unavoidable fan-outs.'}),t}function ju(e){if(!e?.layoutQuality)return null;const t=e.layoutQuality,n=e.layoutQualityBefore,r=e.crossingsAfter??t.crossings;return[`ProcessSankey layout uses ${e.slots?.length??"?"} packed lane(s).`,null!=r?`Edge-pair crossings ${n?n.crossings+" → ":""}${r}.`:null,`Pixel path length ${n?Math.round(n.pixelLength)+" → ":""}${Math.round(t.pixelLength)}.`,`Transit occlusion ${n?n.transitOcclusion.toFixed(1)+" → ":""}${t.transitOcclusion.toFixed(1)}.`,`Lane utilization ${Math.round(100*t.verticalUtilization)}%.`,e.compressedPadding?"Lane gaps were compressed to fit the plot.":null].filter(Boolean).join(" ")}function Nu(e){const t=[],n=e.domain;null==n?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(n)&&2===n.length&&Number.isFinite(Number(n[0]))&&Number.isFinite(Number(n[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const r=e.edges;if(Array.isArray(r)&&r.length>0){const e=r[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const o=e.nodes,i=Array.isArray(o)?o.length:0;return!0!==e.showLabels||24>i||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${i} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(r)?r.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function Pu(e,t,n,r={}){const o=!1!==r.inferOpeningStock,i=[];for(const t of n){const n=Number(t.value);if(!Number.isFinite(n))continue;const r=Number(t.endTime);t.target===e&&Number.isFinite(r)&&i.push({time:r,delta:n});const o=Number(t.startTime);if(t.source===e&&Number.isFinite(o)&&i.push({time:o,delta:-n}),t.target===e&&null!=t.systemOutTime){const e=Number(t.systemOutTime);Number.isFinite(e)&&i.push({time:e,delta:-n})}}i.sort((e,t)=>e.time-t.time||t.delta-e.delta);let a=0,s=0,l=0;for(const e of i)a+=e.delta,s=Math.min(s,a),e.time>t||(l+=e.delta);return o?l-s:l}function Iu(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Eu(e,t,n,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:n?72:24}:{top:e?30:t?24:8,right:80,bottom:n?28:8,left:80}}var Ru=require("react/jsx-runtime"),Du="var(--semiotic-grid, #94a3b8)",_u="var(--semiotic-text-secondary, #475569)",Ou="var(--semiotic-text-secondary, #94a3b8)",$u=require("react"),Wu=require("d3-scale"),Bu=require("d3-scale");function zu(e,t,n,r,o,i,a,s,l={}){const c=o,u=e=>s?Math.max(s[0],Math.min(s[1],e)):e;let d=i(u(e.time));const h=i(u(n.time)),f=e.value*c,g=n.value*c,p=t+(e.boundaryOffset??0)*c,y=r+(n.boundaryOffset??0)*c,m=e.sideMassBefore*c,b=n.sideMassAfter*c;let v,x,k,w;"top"===e.side?(v=p-m,x=v+f):(x=p+m,v=x-f),"top"===n.side?(k=y-b,w=k+g):(w=y+b,k=w-g);const S=l.sourceRunwayStart,M=l.minRun,A=Math.abs((k+w)/2-(v+x)/2),C=h-d,L="number"==typeof S&&Number.isFinite(S),T="number"==typeof M&&Number.isFinite(M)&&M>0;if(L&&A>1e-9&&C>0&&("auto"===M||T)){const t="source"===a?.85:"target"===a?.15:.5,n="auto"===M?Math.min(144,Math.sqrt(8*A/(1.5*Math.min(t*t,(1-t)*(1-t))))):M;if(n>C){const t=i(u(Math.min(S,e.time)));Number.isFinite(t)&&(d=Math.min(d,Math.max(Math.min(d,t),h-n)))}}const j="source"===a?d+.85*(h-d):"target"===a?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:v,sBot:x,tx:h,tTop:k,tBot:w,cp1X:j,cp2X:j}}function Fu(e){return Math.max(18,11*e.length*.58)}function Hu(e){const t=1.22*Fu(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function qu(e,t){const n=e.labelX-Fu(e.labelText),r=t.labelX-Fu(t.labelText);return t.labelX+3>=n&&e.labelX+3>=r}var Yu=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function Xu(e){return e.replace(Yu,(e,t,n)=>`${n},${t}`)}function Gu(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Vu(e){return{...e,pathD:Xu(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Uu(e){const{nodes:t,edges:n,domain:r,plotW:o,plotH:i,ribbonLane:a,ribbonMinRun:s=0,edgeOpacity:l,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:g,selectionDatum:p="raw",styleRules:y,colorBy:m,valueAccessor:b,usageMode:v="static"}=e,x="vertical"===d?i:o,k="vertical"===d?o:i,w=wc(t,n,r,{usageMode:v}),{fatal:S,warnings:M}=function(e){const t=[],n=[];for(const r of e)"fatal"===kc(r)?t.push(r):n.push(r);return{fatal:t,warnings:n}}(w),A=function(e,t,n="static"){if("strip"!==vc(n).invalidSystemTime)return e;const r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;const t={...e};return null==t.systemInTime||Number.isFinite(t.systemInTime)||delete t.systemInTime,null==t.systemOutTime||Number.isFinite(t.systemOutTime)||delete t.systemOutTime,t})}(n,w,v),C=(0,Bu.scaleTime)().domain(r).range([0,x]);if(S.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:S,warnings:M,xScale:C};const L=function(e,t,n){const{plotH:r,pairing:o="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=n,g=Number.isFinite(d)?Math.max(0,d):0,p=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),y=function(e,t,n,r="temporal"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime||jc(e.id,t.id):(e,t)=>t.value-e.value||jc(e.id,t.id),i="temporal"===r?(e,t)=>e.startTime-t.startTime||jc(e.id,t.id):(e,t)=>t.value-e.value||jc(e.id,t.id),a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const n=new Map;for(const r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const a=[...n.values()];a.sort("temporal"===r?(e,n)=>"target"===t?e.earliestStart-n.earliestStart||jc(e.partner,n.partner):e.latestEnd-n.latestEnd||jc(e.partner,n.partner):(e,t)=>t.total-e.total||jc(e.partner,t.partner));for(const e of a)e.edges.sort("target"===t?i:o);return a};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)s(r,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(r,"source"),n=s(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,p,o);let m={};for(const t of e)m[t.id]=Gc(t,p,y,void 0,u);const b=Cu(e,t,m,p,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:g,ribbonLane:h,domain:f}),v=b.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),x=new Set;for(const e of t){const t=b.slotByNode[e.source],n=b.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=y.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(x.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=p.outgoing[t.id],n=p.incoming[t.id],r=new Set(e.map(e=>y.get(e.id).sourceSide)),o=new Set(n.map(e=>y.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)b.slotByNode[t.source]===b.slotByNode[t.target]&&(y.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)b.slotByNode[n.source]===b.slotByNode[n.target]&&(y.get(n.id).sourceSide=t)}}!function(e,t,n){const r=new Map,o=[];for(const t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||jc(e.edge.id,t.edge.id));const i=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},a=(e,t,n)=>{const r="top"===t?"bot":"top",o=Math.min(n,e[t]);e[t]-=o;const i=n-o;i>0&&(e[r]=Math.max(0,e[r]-i))};for(const e of o){const{edge:r}=e;if("in"===e.kind){const e=t.get(r.id)?.targetSide??"bot";i(r.target)[e]+=r.value;continue}const o=i(r.source),s=t.get(r.id);let l=s.sourceSide??"bot";if(n[r.source]===n[r.target]){const e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":e||t||o.top===o.bot||(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}a(o,l,r.value)}}(t,y,b.slotByNode),function(e,t,n,r){for(const o of e){const e=t.incoming[o.id],i=t.outgoing[o.id];if(0===e.length||0===i.length)continue;const a=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const r of e)"top"===n.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(const e of i)"top"===n.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{const o=a(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=s||0>=l)return!1;const c=Math.min(s,l),u=i.filter(t=>!r.has(t.id)&&n.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||jc(e.id,t.id));return 0!==u.length&&(n.get(u[0].id).sourceSide=t,!0)};let l=i.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}(e,p,y,x),m={};for(const t of e)m[t.id]=Gc(t,p,y,void 0,u);const k=Cu(e,t,m,p,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:v,lanePlacement:"stack",groupPadding:g,ribbonLane:h,domain:f}),w=k.effectiveSlotsHeight??k.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),S=k.slots.slice(0,-1).reduce((e,t,n)=>e+(null!=t.group&&t.group===k.slots[n+1].group?1:0),0),M=Math.max(1,k.slots.length+1-S),A=Math.min(12,Math.max(0,.35*r-S*g)/M),C=2*A+Pc(k.slots,A,g).reduce((e,t)=>e+t,0),L=w>0?Math.max(0,(r-C)/w):1,T=Number.isFinite(l)&&l>0?Math.min(L,l):L;let j=Cu(e,t,m,p,{plotH:r,padding:A,valueScale:T,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:v,lanePlacement:c,groupPadding:g,ribbonLane:h,domain:f,stackValueScale:L});const N=Number.isFinite(l)&&l>0&&L>l+1e-12;if("insertion"!==a&&("hug"===c||N)&&j.slots.length>1&&(lu(e,t,m,j.laneLifetime,j.slots,j.slotByNode,{plotH:r,padding:A,valueScale:T,groupPadding:g,laneOrder:a,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),j=Cu(e,t,m,p,{plotH:r,padding:A,valueScale:T,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(Nc),lanePlacement:c,groupPadding:g,ribbonLane:h,domain:f,stackValueScale:L})),function(e,t){const n=(e,n)=>{for(const r of e){const e=new Map;for(const o of r){const r=`${("out"===n?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===n?o.startTime:o.endTime}`,i="out"===n?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,a=e.get(r);if(null!=a&&a!==i)return!0;e.set(r,i)}}return!1};return n(Object.values(e.outgoing),"out")||n(Object.values(e.incoming),"in")}(p,y)){const n=function(e,t,n,r){const o=new Map;for(const i of e){const e=t[i.source]?.localAttachments.get(i.id),a=t[i.target]?.localAttachments.get(i.id),s=n[i.source],l=n[i.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(l)))continue;const c=Xc(e,s,r),u=Xc(a,l,r);o.set(i.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}(t,m,j.centerlines,T);m={};for(const t of e)m[t.id]=Gc(t,p,y,n,u);j=Cu(e,t,m,p,{plotH:r,padding:A,valueScale:T,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(Nc),lanePlacement:c,groupPadding:g,ribbonLane:h,domain:f,stackValueScale:L})}const P=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),I=[...j.slots].sort((e,t)=>(P.get(Nc(e))??1/0)-(P.get(Nc(t))??1/0)||jc(Nc(e),Nc(t))),E={};I.forEach((e,t)=>{for(const n of e.occupants)E[n.id]=t});const R=Dc(e,t,m,I,E,{plotH:r,padding:A,valueScale:T,stackValueScale:L,lanePlacement:"stack",groupPadding:g}),D=Au(e,m,I,E,R.centerlines,T,g),_=Hc(nu(E,t),ru(E,t),t,D,I,E,R.centerlines,j.laneLifetime,T,R.verticalUtilization,h,f);m=Au(e,m,j.slots,j.slotByNode,j.centerlines,T,g);const O=Hc(nu(j.slotByNode,t),ru(j.slotByNode,t),t,m,j.slots,j.slotByNode,j.centerlines,j.laneLifetime,T,j.verticalUtilization,h,f);return{nodeData:m,sides:y,valueScale:T,padding:A,compressedPadding:12>A,centerlines:j.centerlines,laneLifetime:j.laneLifetime,slots:j.slots,slotByNode:j.slotByNode,crossingsBefore:"insertion"===a?null:_.crossings,crossingsAfter:"insertion"===a?null:O.crossings,lengthBefore:"insertion"===a?null:_.weightedLength,lengthAfter:"insertion"===a?null:O.weightedLength,layoutQualityBefore:_,layoutQuality:O}}(t,A,{plotH:k,...u,ribbonLane:a,domain:r}),{centerlines:T,nodeData:j,valueScale:N}=L,P=Cl(m,b),I=[],E=[],R=0===s?new Map:function(e,t,n){const r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),i=new Map;for(const e of t){if(r.has(e.source))continue;const t=i.get(e.source)??[];t.push(e),i.set(e.source,t)}const a=new Map;for(const t of e){if(!t.group)continue;const e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}const s=new Set;for(const[e,t]of a){const n=t.flatMap(e=>i.get(e.id)??[]),o=new Set(n.map(e=>e.startTime));n.length>0&&1===o.size&&t.every(e=>{const t=e.xExtent?.[0],o=n[0].startTime;return!r.has(e.id)&&(i.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&s.add(e)}const l=new Map;for(const[e,t]of i){const r=o.get(e);if(r?.group&&!s.has(r.group))continue;const i=r?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1;let u=null;for(let e=0;a.length>e;){const t=a[e].startTime;let r=e+1;for(;a.length>r&&a[r].startTime===t;)r++;for(let t=e;r>t;t++){const e=a[t],r=Number.isFinite(i)&&e.startTime>i,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!r&&!o)continue;let s=n[0];r&&(s=Math.max(s,i)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),e.startTime>s&&l.set(e.id,s)}u=t,e=r}}for(const[e,t]of a){if(!s.has(e))continue;const n=t.flatMap(e=>i.get(e.id)??[]);if(!n.every(e=>l.has(e.id))){for(const e of n)l.delete(e.id);continue}const r=Math.max(...n.map(e=>l.get(e.id)));for(const e of n)l.set(e.id,r)}return l}(t,A,r),D=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),_=new Map;for(const e of A){const t=j[e.source]?.localAttachments.get(e.id),n=j[e.target]?.localAttachments.get(e.id);t&&n&&_.set(e.id,zu(t,T[e.source],n,T[e.target],N,C,a,r,{minRun:s,sourceRunwayStart:R.get(e.id)}))}const O=function(e,t,n,r,o,i){const a=new Map(t),s=new Map;for(const t of e){const e=i?.get(t.source),n=null==e?"node:"+t.source:"group:"+e,r=s.get(n)??new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(n,r)}for(const e of s.values())for(const[i,s]of e){if(!s.some(e=>n.has(e.id)))continue;const e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const l=r(i),c=Math.min(...e.map(e=>e.sx));if(c>=l-1e-9)continue;const u=Math.max(...s.map(e=>{const t=n.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(const e of s){const n=t.get(e.id),r=d+(n.tx-d)*("source"===o?.85:"target"===o?.15:.5);a.set(e.id,{...n,sx:d,cp1X:r,cp2X:r})}}return a}(A,_,R,C,a,D),$=function(e,t,n,r,o){const i=new Map;for(const a of e){if(!n.has(a.id))continue;const e=t.get(a.id);if(!e||e.sx>=r(a.startTime)-1e-9)continue;const s=o(e.sx);Number.isFinite(s)&&a.startTime>s&&i.set(a.id,s)}return i}(A,O,R,C,e=>r[0]+e/x*(r[1]-r[0])),W=function(e,t,n){const r=new Map,o=new Map;for(const[e,t]of n??[]){const n=o.get(t)??[];n.push(e),o.set(t,n)}for(const i of e){const e=t.get(i.id);if(null==e||!Number.isFinite(e)||e>=i.startTime)continue;const a=n?.get(i.source),s=null==a?[i.source]:o.get(a)??[i.source];for(const t of s){const n=r.get(t)??new Map,o=n.get(i.startTime);n.set(i.startTime,null==o?e:Math.min(o,e)),r.set(t,n)}}return r}(A,$,D);t.forEach((e,t)=>{const n=j[e.id];if(!n||0===n.samples.length)return;const o=(i=n.samples,(a=W.get(e.id))&&0!==a.size?i.map(e=>{const t=a.get(e.t);return null==t?e:{...e,t:t}}):i);var i,a;const s=function(e,t,n,r,o){if(0===e.length)return null;const i=Yc(e,o),a=e=>t+(i[e].boundaryOffset??0)*n,s=e=>a(e)-i[e].topMass*n,l=e=>a(e)+i[e].botMass*n;let c=`M${r(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)c+=` L${r(i[e].t)},${s(e)}`;c+=` L${r(i[i.length-1].t)},${l(i.length-1)}`;for(let e=i.length-2;e>=0;e--)c+=` L${r(i[e].t)},${l(e)}`;return c+" Z"}(o,T[e.id],N,C,r);if(!s)return;const l=Yc(o,r),u=l.find(e=>e.topMass+e.botMass>0)||l[0],h=T[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*N/2;let f,g,p=c(e.id,t),m=p,b=.5;const v=e.__raw??e;if(y&&y.length>0){const e=Nl(v,y,P(v));"string"==typeof e.fill?p=e.fill:null!=e.fill&&Oo(e.fill)&&(g=e.fill,p=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:p),"string"==typeof e.stroke&&(m=e.stroke),"number"==typeof e.strokeWidth&&(b=e.strokeWidth),"number"==typeof e.fillOpacity&&(f=e.fillOpacity),"number"==typeof e.opacity&&null==f&&(f=e.opacity)}const x=function(e,t,n,r,o,i){const a=n.nodeData[e];if(!a||0===a.samples.length)return[];const s=n.valueScale,l=n.centerlines[e],c=Yc(a.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),g=e=>r(qc(e,o)),p=[],y=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=a.localAttachments.get(n.id),t=i?.get(n.id)??n.startTime;if(e&&"out"===e.kind&&t>n.systemInTime){const r=g(n.systemInTime),i=g(t),a=null!=o&&o[0]>n.systemInTime,c=a?r:r-20,u=a?Math.min(i,r+20):r,d=Math.max(h,c);if(i>d){const[t,n]=Xc(e,l,s);p.push({pathD:y(d,t,i,n),x0:c,x1:u,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=a.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=g(n.systemOutTime),r=g(n.endTime),o=t+20,i=Math.min(f,o);if(i>r){const[n,a]=Xc(e,l,s);p.push({pathD:y(r,n,i,a),x0:t,x1:o,from:1,to:0})}}}}return p}(e.id,A,L,C,r,$);I.push({id:e.id,pathD:s,fill:p,stroke:m,strokeWidth:b,...null!=f&&{fillOpacity:f},...g&&{hatchFill:g},...x.length>0&&{gradientStubs:x},rawDatum:v,labelX:C("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:h,labelText:e.label??e.id})});const B=new Map;t.forEach((e,t)=>B.set(e.id,t)),A.forEach(e=>{const t=O.get(e.id);if(!t)return;const n=B.get(e.source)??0,r=c(e.source,n),{pathD:o,bezier:i}=be(t),a=e.__raw??e,s="function"==typeof l?Number(l(a)):l,u=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;E.push({id:e.id,pathD:o,fill:r,opacity:u,rawDatum:a,bezier:i})});const z=function(e,t,n){const r=e.map(e=>({...e})),o=new Map;for(const e of r){const n=t[e.id];if(null==n)continue;const r=o.get(n)??[];r.push(e),o.set(n,r)}const i=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(n-8,t+16*(o-r)))})};for(const e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],n=-1/0;for(const r of e){const e=r.labelX-Fu(r.labelText);t.length>0&&e>n+3&&(i(t),t=[],n=-1/0),t.push(r),n=Math.max(n,r.labelX)}i(t)}return function(e,t){const n=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;n.length>e;e+=1){let t=8;for(let r=0;e>r;r+=1)qu(n[e],n[r])&&(t=Math.max(t,n[r].labelY+16));n[e].labelY=Math.max(n[e].labelY,t)}for(let e=n.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;n.length>t;t+=1)qu(n[e],n[t])&&(r=Math.min(r,n[t].labelY-16));n[e].labelY=Math.min(n[e].labelY,r)}}}(r,n),r}(I,L.slotByNode,k).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Xu(e.pathD),gradientStubs:e.gradientStubs?.map(Vu),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),F="vertical"===d?function(e,t,n){const r=e.map(e=>({...e}));for(const e of r){const n=1.22*Fu(e.labelText)+4;e.labelX=t-4>n?Math.max(n/2+2,Math.min(t-n/2-2,e.labelX)):t/2}const o=[],i=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of i){const t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(const e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],r=new Map;for(const n of e){const[e,o]=Hu(n);let i=t.findIndex(t=>e>t+8);-1===i&&(i=t.length),t[i]=o,r.set(n,i)}const o=e.reduce((e,t)=>e+t.labelY,0)/e.length,i=14*t.length+8>o;for(const t of e){const e=r.get(t)??0;t.labelY=i?Math.min(n-8,12+14*e):Math.max(8,o-14*e)}}return r}(z,o,i):z,H=new Map;if(null!=f)for(const e of t){const t=e.__raw??e,n="function"==typeof f?f(t):Number(t[f]);Number.isFinite(n)&&H.set(e.id,n)}const q=function(e,t,n,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let i=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*n)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(i=Math.min(i,Math.floor(o.maxLabels)));const a=e.map((e,t)=>{const n=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=n&&Number.isFinite(n)?1e6*n+Fu(e.labelText):Fu(e.labelText)+.01*r}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),s=new Set(a.slice(0,i).map(e=>e.band.id));return e.map(e=>s.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(F,o,i,h,{...H.size>0&&{priorityById:H},...null!=g&&{maxLabels:g}});return{layout:L,layoutConfig:{bands:q,ribbons:E.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Xu(e.pathD),bezier:Gu(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:p},issues:[],warnings:M,xScale:C}}var Qu=require("d3-scale"),Ku={};function Zu(e,t,n,r="reuse",o="crossing-min",i=5e4){return"sync"!==e&&("worker"===e||function(e,t,n="reuse",r="crossing-min"){return e*e*("reuse"===n?80:1)+t*t*(r&&"insertion"!==r?40:1)+10*(e+t)}(t,n,r,o)>=i)}function Ju(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function ed(e){if(!e)return null;const t=e.sides,n=t instanceof Map?t:new Map(Array.isArray(t)?t:[]);return{...e,sides:n}}var td=class{constructor(e=function(){const e="string"==typeof Ku.url&&Ku.url?new URL("./processSankeyLayoutWorker.js",Ku.url):Ea("processSankeyLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-process-sankey-layout"})}()){this.session=new Oa({name:"ProcessSankey layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:r}=_a(t);return r?{requestId:n,ok:!1,error:Da(r)}:{requestId:n,ok:!0,payload:{layout:ed(t.layout),layoutConfig:t.layoutConfig??{bands:[],ribbons:[],showLabels:!0},issues:t.issues??[],warnings:t.warnings??[],domain:t.domain??[0,1],timelineExtent:t.timelineExtent??0}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},nd=$a(()=>new td);function rd(e){if(function(e){if(!e||0===e.length)return!1;for(const t of e){if("function"==typeof t.when)return!0;if("function"==typeof t.style)return!0}return!1}(e.styleRules))return!0;if("function"==typeof e.edgeOpacity)return!0;if("function"==typeof e.labelPriorityAccessor)return!0;if(e.styleRules&&e.styleRules.length>0){if("function"==typeof e.colorBy)return!0;if("function"==typeof e.valueAccessor)return!0}return!1}function od(e){if(null!=e&&"object"==typeof e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return}}}function id(e){const t=od(e.__raw);return{id:e.id,...null!=e.label&&{label:e.label},...null!=e.group&&{group:e.group},...null!=e.xExtent&&{xExtent:e.xExtent},...null!=t&&{__raw:t}}}function ad(e){const t=od(e.__raw);return{id:e.id,source:e.source,target:e.target,value:e.value,startTime:e.startTime,endTime:e.endTime,...null!=e.systemInTime&&{systemInTime:e.systemInTime},...null!=e.systemOutTime&&{systemOutTime:e.systemOutTime},...null!=t&&{__raw:t}}}var sd=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:(0,Wu.scaleTime)().domain(e).range([0,t])});function ld(e,t){const n=fa(),{execution:r="auto",workerThreshold:o,colorById:i,fallbackPalette:a,rawNodeById:s,rawEdgeById:l}=t,c=(0,$u.useMemo)(()=>Object.keys(i).sort().map(e=>`${e}:${i[e]}`).join("|"),[i]),u=(0,$u.useMemo)(()=>e?[e.nodes,e.edges,e.plotW,e.plotH,e.orientation??"horizontal",e.ribbonLane,(e.ribbonMinRun??0)+"",e.edgeOpacity,(e.showLabels??!0)+"",e.layoutOpts.pairing??"temporal",e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",e.layoutOpts.lifetimeMode??"half",e.layoutOpts.maxValueScale??"",e.layoutOpts.lanePlacement??"stack",e.layoutOpts.nodeSizing??"temporal",e.layoutOpts.groupPadding??0,e.domain[0],e.domain[1],e.styleRules,c]:"null",[e,c]),d=!!e&&!n&&function(e,t,n){return"undefined"!=typeof window&&!!Ju()&&!rd(e)&&Zu(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",n)}(e,r,o),h=(0,$u.useMemo)(()=>e?d?null:Uu(e):sd([0,1],1),[u,d,e]),f=(0,$u.useRef)(n),[g,p]=(0,$u.useState)(()=>e?n?{...Uu(e),status:"ready",error:null}:d?{...sd(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...Uu(e),status:"ready",error:null}:{...sd([0,1],1),status:"ready",error:null});return(0,$u.useEffect)(()=>{if(f.current)return void(f.current=!1);if(!e||!d)return;const t=new AbortController;return p(e=>({...e,status:"pending",error:null})),async function(e,t){const{execution:n="auto",workerThreshold:r,signal:o,colorById:i,fallbackPalette:a=["#475569"],rawNodeById:s=new Map,rawEdgeById:l=new Map}=t,c=e.layoutOpts.packing??"reuse",u=e.layoutOpts.laneOrder??"crossing-min";if(!Ju()||rd(e)||!Zu(n,e.nodes.length,e.edges.length,c,u,r))return Uu(e);try{const t=await function(e,t){return Ju()?nd.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(function(e,t,n){return{input:{nodes:e.nodes.map(id),edges:e.edges.map(ad),domain:e.domain,plotW:e.plotW,plotH:e.plotH,orientation:e.orientation,ribbonLane:e.ribbonLane,ribbonMinRun:e.ribbonMinRun,edgeOpacity:"number"==typeof e.edgeOpacity?e.edgeOpacity:.35,layoutOpts:{...e.layoutOpts},showLabels:e.showLabels,..."string"==typeof e.labelPriorityAccessor&&{labelPriorityAccessor:e.labelPriorityAccessor},...null!=e.maxLabels&&{maxLabels:e.maxLabels},...null!=e.selectionDatum&&{selectionDatum:e.selectionDatum},...null!=e.usageMode&&{usageMode:e.usageMode},styleRules:e.styleRules,colorBy:"string"==typeof e.colorBy?e.colorBy:void 0,valueAccessor:"string"==typeof e.valueAccessor?e.valueAccessor:void 0},colorById:t,fallbackPalette:n}}(e,i,a),o);return function(e,t,n){const r=(e.layoutConfig.bands??[]).map(e=>({...e,rawDatum:t.get(e.id)??{id:e.id}})),o=(e.layoutConfig.ribbons??[]).map(e=>({...e,rawDatum:n.get(e.id)??{id:e.id}})),i=(0,Qu.scaleTime)().domain(e.domain).range([0,e.timelineExtent]);return{layout:e.layout,layoutConfig:{bands:r,ribbons:o,showLabels:e.layoutConfig.showLabels},issues:e.issues,warnings:e.warnings,xScale:i}}(t,s,l)}catch(t){if("AbortError"===t?.name)throw t;return Uu(e)}}(e,{execution:r,workerThreshold:o,signal:t.signal,colorById:i,fallbackPalette:a,rawNodeById:s,rawEdgeById:l}).then(e=>{p({...e,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&p(t=>({...t,status:"error",error:e}))}),()=>t.abort()},[u,d,r,o,a,s,l]),h?{...h,status:"ready",error:null}:g}var cd=require("react");function ud(e,t){return"function"==typeof e?e(t):t[e]}var dd=require("react"),hd=.22;function fd(e,t,n){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,n))}var gd=e=>{const{bands:t=[],ribbons:n=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,i=e.selection??null,a=[];for(const e of n){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},n=!fd(t,i,o);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:n?Math.min(e.opacity,hd):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!fd({__kind:"band",data:e.rawDatum,id:e.id},i,o);for(let n=0;e.gradientStubs.length>n;n++){const r=e.gradientStubs[n];a.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?hd:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${n}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),n={__kind:"band",data:e.rawDatum,id:e.id},r=!fd(n,i,o);a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:r?hd:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:hd}:{}},datum:n})}const s=r?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),n=e.labelText.trim().length>0,r=t&&i?.isActive&&fd({__kind:"band",data:e.rawDatum,id:e.id},i,o),a=n?e.labelText:r?e.labelFullText:"";return a.trim()?[{x:e.labelX,y:e.labelY,text:a,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:s}};function pd(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}var yd=require("react/jsx-runtime");var md=require("react/jsx-runtime"),bd=(0,mc.forwardRef)(function(e,t){const{nodes:n,edges:r,domain:o,axisTicks:i=[],nodeIdAccessor:a="id",nodeLabel:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",startTimeAccessor:d="startTime",endTimeAccessor:h="endTime",systemInTimeAccessor:f,systemOutTimeAccessor:g,xExtentAccessor:p="xExtent",groupBy:y,edgeIdAccessor:m="id",colorBy:b,colorScheme:v,showLegend:x,legendPosition:k="right",orientation:w="horizontal",pairing:S="temporal",packing:M="reuse",laneOrder:A="crossing-min",maxValueScale:C,lanePlacement:L="stack",nodeSizing:T="temporal",groupPadding:j=0,ribbonLane:N="both",ribbonMinRun:P=0,lifetimeMode:I="half",showLaneRails:E=!1,showQualityReadout:R=!1,showLabels:D=!0,labelPriorityAccessor:_,maxLabels:O,selectionDatum:$="raw",styleRules:W,layoutExecution:B="auto",layoutWorkerThreshold:z,layoutLoadingContent:F,onLayoutStateChange:H,width:q=600,height:Y=400,margin:X,title:G,description:V,summary:U,accessibleTable:Q,responsiveWidth:K,responsiveHeight:Z,loading:J,loadingContent:ee,emptyContent:te,edgeOpacity:ne=.35,timeFormat:re,valueFormat:oe,tooltip:ie,enableHover:ae=!0,onObservation:se,onClick:le,selection:ce,linkedHover:ue,showParticles:de=!1,particleStyle:he,chartId:fe,frameProps:ge={}}=e,pe=(0,mc.useRef)(null),ye=(0,mc.useRef)(null),{rawNodes:me,rawEdges:be,frameRef:ve,getNodeId:xe,getEdgeId:ke}=function(e){const{ref:t,rawNodesProp:n,rawEdgesProp:r,nodeIdAccessor:o,edgeIdAccessor:i,sourceAccessor:a,targetAccessor:s,scalesRef:l,layoutSnapshotRef:c}=e,[u,d]=(0,cd.useState)([]),[h,f]=(0,cd.useState)([]),g=(0,cd.useRef)(u),p=(0,cd.useRef)(h);g.current=u,p.current=h;const y=(0,cd.useCallback)(e=>{g.current=e,d(e)},[]),m=(0,cd.useCallback)(e=>{p.current=e,f(e)},[]),b=void 0!==r,v=ia(b?r:u),x=(0,cd.useMemo)(()=>{const e=ia(n??[]),t=h;if(0===e.length&&0===t.length)return xl([],v,a,s);const r=new Set,i=[];for(const t of e){const e=ud(o,t)+"";r.has(e)||(r.add(e),i.push(t))}for(const e of t){const t=ud(o,e)+"";r.has(t)||(r.add(t),i.push(e))}const l=xl([],v,a,s);for(const e of l)r.has(e.id)||(r.add(e.id),i.push(e));return i},[n,h,v,o,a,s]),k=(0,cd.useRef)(null),w=(0,cd.useCallback)((e,t)=>{const n=ud(i,e);return null!=n?n+"":`${ud(a,e)}-${ud(s,e)}-${t}`},[i,a,s]),S=(0,cd.useCallback)(e=>{if(null==e)return!1;const t=e;return null!=ud(a,t)&&null!=ud(s,t)},[a,s]),M=(0,cd.useCallback)(e=>ud(o,e)+"",[o]);return Ts(t,{variant:"network",frameRef:k,overrides:{push(e){if(S(e)){if(b)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");y([...g.current,e])}else m([...p.current,e])},pushMany(e){const t=[],n=[];for(const r of e)S(r)?t.push(r):n.push(r);t.length>0&&(b?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):y([...g.current,...t])),n.length>0&&m([...p.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!b){const e=g.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(w(i,o))?n.push(i):r.push(i)}r.length!==e.length&&y(r)}const r=p.current,i=[];for(const e of r){const r=ud(o,e)+"";t.has(r)?n.push(e):i.push(e)}return i.length!==r.length&&m(i),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!b){let e=!1;const o=g.current.map((o,i)=>n.has(w(o,i))?(r.push(o),e=!0,t(o)):o);e&&y(o)}let i=!1;const a=p.current.map(e=>{const a=ud(o,e)+"";return n.has(a)?(r.push(e),i=!0,t(e)):e});return i&&m(a),r},clear(){b||y([]),m([]),k.current?.clear()},getData:()=>v??[],getScales:()=>l.current,getCustomLayout:()=>c.current}}),{rawNodes:x,rawEdges:v,frameRef:k,getNodeId:M,getEdgeId:w,isControlled:b}}({ref:t,rawNodesProp:n,rawEdgesProp:r,nodeIdAccessor:a,edgeIdAccessor:m,sourceAccessor:l,targetAccessor:c,scalesRef:pe,layoutSnapshotRef:ye}),{nodes:we,edges:Se,domain:Me,rawNodeById:Ae,rawEdgeById:Ce}=(0,mc.useMemo)(()=>{const e=(me??[]).map(e=>{const t=xe(e),n=s?ud(s,e):t,r={id:t,label:null==n?t:n+"",__raw:e},o=y?ud(y,e):null;null!=o&&o+""!=""&&(r.group=o+"");const i=p?ud(p,e):null;if(Array.isArray(i)&&2===i.length){const e=Iu(i[0]),t=Iu(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(r.xExtent=[e,t])}return r}),t=(be??[]).map((e,t)=>{const n={id:ke(e,t),source:ud(l,e)+"",target:ud(c,e)+"",value:Number(ud(u,e)),startTime:Iu(ud(d,e)),endTime:Iu(ud(h,e)),__raw:e};if(f){const t=Iu(ud(f,e));Number.isFinite(t)&&(n.systemInTime=t)}if(g){const t=Iu(ud(g,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Iu(o[0]),Iu(o[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:r,rawEdgeById:i}},[me,be,o,xe,ke,s,p,y,l,c,u,d,h,f,g]),Le=Sl({nodes:me,edges:be,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:l,targetAccessor:c,colorBy:b,colorScheme:v,showLegend:!1,legendPosition:k,selection:ce,linkedHover:ue,onObservation:se,onClick:le?(e,t)=>{pd(e)?le(e.data,t):le(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:fe,marginDefaults:Eu(!!G,R,i.length>0,w),userMargin:X,width:q,height:Y,hasTitle:!!G,loading:J,loadingContent:ee,emptyContent:te}),Te=(x??!!b)&&!!b,je=(0,mc.useCallback)(e=>null!=X&&("number"==typeof X||null!=X[e]),[X]),Ne=(0,mc.useMemo)(()=>{const e={...Le.margin};return Te&&("right"===k&&!je("right")&&140>e.right?e.right=140:"bottom"===k&&!je("bottom")&&80>e.bottom&&(e.bottom=80)),e},[Le.margin,Te,k,je]),Pe=q-Ne.left-Ne.right,Ie=Y-Ne.top-Ne.bottom,Ee="vertical"===w?Ie:Pe,Re=(0,mc.useCallback)((e,t)=>{if(b&&me){const t=Ae.get(e);if(t)return Ft(t,b,Le.colorScale)}return Le.effectivePalette[t%Le.effectivePalette.length]||"#475569"},[b,me,Ae,Le.colorScale,Le.effectivePalette]),De=ld((0,mc.useMemo)(()=>Pe>0&&Ie>0?{nodes:we,edges:Se,domain:Me,plotW:Pe,plotH:Ie,orientation:w,ribbonLane:N,ribbonMinRun:P,edgeOpacity:"function"==typeof ne?e=>ne(e):ne,colorOf:Re,showLabels:D,labelPriorityAccessor:_,maxLabels:O,selectionDatum:$,styleRules:W,usageMode:"push",colorBy:b,valueAccessor:u,layoutOpts:{pairing:S,packing:M,laneOrder:A,lifetimeMode:I,maxValueScale:C,lanePlacement:L,nodeSizing:T,groupPadding:j}}:null,[we,Se,Me,Pe,Ie,w,N,P,ne,Re,D,_,O,$,W,b,u,S,M,A,I,C,L,T,j]),{execution:B,workerThreshold:z,colorById:(0,mc.useMemo)(()=>{const e={};return we.forEach((t,n)=>{e[t.id]=Re(t.id,n)}),e},[we,Re]),fallbackPalette:Le.effectivePalette,rawNodeById:Ae,rawEdgeById:Ce}),{issues:_e,warnings:Oe,layout:$e,xScale:We}=De,Be=De.layoutConfig,ze=De.status;pe.current=$e?{time:We,centerlines:$e.centerlines}:{time:We},ye.current=$e?{layout:$e,nodes:we,edges:Se,bands:Be.bands,ribbons:Be.ribbons,warnings:Oe,status:ze}:null;const Fe=(0,mc.useRef)(H);Fe.current=H,(0,mc.useEffect)(()=>{Fe.current?.(ze)},[ze]),(0,mc.useEffect)(()=>{0!==Oe.length&&console.warn("ProcessSankey warnings:",Oe.map(Sc).join("; "))},[Oe]);const He=(0,mc.useMemo)(()=>{if(!Te||!b)return;const e=new Map;(me??[]).forEach((t,n)=>{const r=ud(b,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:Re(xe(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[Te,b,me,Re,xe]),qe=function(e){const{tooltip:t,enableHover:n,layout:r,timeFormat:o,valueFormat:i,sourceAccessor:a,targetAccessor:s,valueAccessor:l,startTimeAccessor:c,endTimeAccessor:u}=e,d=(0,dd.useMemo)(()=>!1!==t&&n?void 0===t||!0===t?null:Fn(t)||null:null,[t,n]),h=(0,dd.useCallback)(e=>o?o(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[o]),f=(0,dd.useCallback)(e=>i?i(e):e+"",[i]);return(0,dd.useCallback)(e=>{if(!e||!e.data)return null;const t=e.data;if(!pd(t))return null;const n=t.data;if(d)return d(n);if("band"===t.__kind){const e=t.id,n=r?function(e){if(!e)return[];const t=new Set,n=[];for(const r of e.samples){const e=r.topMass+r.botMass,o=`${r.t}:${e}`;t.has(o)||(t.add(o),n.push({t:r.t,total:e}))}return n}(r.nodeData[e]):[],o=5,i=n.length>o?n.length:null,a=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),r=n.length-1,o=[{...n[0],mark:"min"},{...n[Math.floor(.25*r)],mark:"q25"},{...n[Math.floor(.5*r)],mark:"median"},{...n[Math.floor(.75*r)],mark:"q75"},{...n[r],mark:"max"}],i=new Set,a=[];for(const e of o)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(n,o);return(0,yd.jsxs)("div",{style:{minWidth:160},children:[(0,yd.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:e}),a.length>0&&(0,yd.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[(0,yd.jsx)("thead",{children:(0,yd.jsxs)("tr",{style:{opacity:.6},children:[(0,yd.jsx)("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),(0,yd.jsx)("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&(0,yd.jsx)("th",{})]})}),(0,yd.jsx)("tbody",{children:a.map((e,t)=>(0,yd.jsxs)("tr",{children:[(0,yd.jsx)("td",{style:{paddingRight:8},children:h(e.t)}),(0,yd.jsx)("td",{style:{textAlign:"right"},children:f(e.total)}),null!=i&&(0,yd.jsx)("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&(0,yd.jsxs)("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",a.length," of ",i," samples"]})]})}const o=n,i=ud(a,o),g=ud(s,o),p=ud(l,o),y=ud(c,o),m=ud(u,o);return(0,yd.jsxs)("div",{style:{minWidth:160},children:[(0,yd.jsxs)("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",g+""]}),(0,yd.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=p&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("span",{style:{opacity:.6},children:"value"}),(0,yd.jsx)("span",{style:{textAlign:"right"},children:f(Number(p))})]}),null!=y&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("span",{style:{opacity:.6},children:"start"}),(0,yd.jsx)("span",{style:{textAlign:"right"},children:h(Iu(y))})]}),null!=m&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("span",{style:{opacity:.6},children:"end"}),(0,yd.jsx)("span",{style:{textAlign:"right"},children:h(Iu(m))})]})]})]})},[r,d,h,f,a,s,l,c,u])}({tooltip:ie,enableHover:ae,layout:$e,timeFormat:re,valueFormat:oe,sourceAccessor:l,targetAccessor:c,valueAccessor:u,startTimeAccessor:d,endTimeAccessor:h}),Ye=(0,mc.useMemo)(()=>{if(!$e)return null;const e=Oe.map(e=>Sc(e));return function(e){const t=e.layout,n=e.nodes,r=e.orientation,o=e.plotW,i=e.plotH,a=e.timelineExtent,s=e.axisTicks,l=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,f=e.toTime,g=e.xScale,{centerlines:p,laneLifetime:y,nodeData:m,valueScale:b,compressedPadding:v,crossingsBefore:x,crossingsAfter:k,layoutQualityBefore:w,layoutQuality:S}=t;let M=null,A=null;for(const e of n){const t=y[e.id];if(!t||null===t.start||null===t.end)continue;const n=g(t.start),r=g(t.end);(null===M||M>n)&&(M=n),(null===A||r>A)&&(A=r)}const C=e=>Math.max(0,Math.min(a,e)),L=C(M??0),T=Math.max(L,C(A??a)),j=s.map((e,t)=>({tick:e,index:t,coordinate:g(f(e.date))})).filter(({coordinate:e})=>e>=L-.5&&T+.5>=e),N=null!==(k??null)&&null!=w&&null!=S,P=l&&(N||u.length>0)?(0,Ru.jsxs)("g",{fill:Ou,fontSize:10,textAnchor:"end",children:[N&&(0,Ru.jsxs)(Ru.Fragment,{children:[(0,Ru.jsxs)("text",{x:o,y:-14,children:["crossings: ",x," → ",k," ","pixel length: ",Math.round(w.pixelLength)," → ",Math.round(S.pixelLength)]}),(0,Ru.jsxs)("text",{x:o,y:-3,children:["transit: ",w.transitOcclusion.toFixed(1)," → ",S.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*S.verticalUtilization),"%"]})]}),u.map((e,t)=>(0,Ru.jsxs)("text",{x:o,y:N?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,I=v?(0,Ru.jsx)("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:Ou,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,E=(e,t)=>h?h(e,t):Du;return(0,Ru.jsxs)("g","vertical"===r?{children:[P,I,j.map(({index:e,coordinate:t})=>(0,Ru.jsx)("line",{x1:0,y1:t,x2:o,y2:t,stroke:Du,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&n.map((e,t)=>{const n=y[e.id];if(!n||null===n.start)return null;const r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},i=p[e.id]+(o.botPeak-o.topPeak)*b/2,a=g(n.start),s=g(n.end),l=E(e.id,t);return(0,Ru.jsxs)("g",{children:[(0,Ru.jsx)("line",{x1:i,y1:a,x2:i,y2:s,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Ru.jsx)("line",{x1:i-4,y1:a,x2:i+4,y2:a,stroke:l,strokeOpacity:.5}),(0,Ru.jsx)("line",{x1:i-4,y1:s,x2:i+4,y2:s,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),(0,Ru.jsx)("line",{x1:-4,y1:L,x2:-4,y2:T,stroke:Du}),j.map(({tick:e,index:t,coordinate:n})=>{const r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return(0,Ru.jsxs)("g",{transform:`translate(-4,${n})`,children:[(0,Ru.jsx)("line",{x2:-6,stroke:Du}),(0,Ru.jsx)("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:_u,children:o})]},t)})]}:{children:[P,I,j.map(({index:e,coordinate:t})=>(0,Ru.jsx)("line",{x1:t,y1:0,x2:t,y2:i,stroke:Du,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&n.map((e,t)=>{const n=y[e.id];if(!n||null===n.start)return null;const r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},i=p[e.id]+(o.botPeak-o.topPeak)*b/2,a=g(n.start),s=g(n.end),l=E(e.id,t);return(0,Ru.jsxs)("g",{children:[(0,Ru.jsx)("line",{x1:a,y1:i,x2:s,y2:i,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Ru.jsx)("line",{x1:a,y1:i-4,x2:a,y2:i+4,stroke:l,strokeOpacity:.5}),(0,Ru.jsx)("line",{x1:s,y1:i-4,x2:s,y2:i+4,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),(0,Ru.jsx)("line",{x1:L,y1:i+4,x2:T,y2:i+4,stroke:Du}),j.map(({tick:e,index:t,coordinate:n})=>{const r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return(0,Ru.jsxs)("g",{transform:`translate(${n},${i+4})`,children:[(0,Ru.jsx)("line",{y2:6,stroke:Du}),(0,Ru.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:_u,children:o})]},t)})]})}({layout:$e,nodes:we,orientation:w,plotW:Pe,plotH:Ie,timelineExtent:Ee,axisTicks:i,showQualityReadout:R,showLaneRails:E,warnings:e,timeFormat:re?e=>re(e):void 0,colorOf:Re,toTime:Iu,xScale:e=>Number(We(e))})},[$e,we,w,Pe,Ie,Ee,i,R,E,Oe,re,Re,We]),Xe=(0,mc.useMemo)(()=>(me??[]).map(e=>({id:xe(e),data:e})),[me,xe]),Ge=(0,mc.useMemo)(()=>{const e=new Map;for(const t of Be.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Be]),Ve=(0,mc.useMemo)(()=>(be??[]).map((e,t)=>{const n=ke(e,t),r=Number(ud(u,e));return{id:n,source:ud(l,e)+"",target:ud(c,e)+"",value:Number.isFinite(r)?r:0,bezier:Ge.get(n),data:e}}),[be,ke,l,c,u,Ge]);return _e.length>0?(0,md.jsxs)("svg",{width:q,height:Y,role:"img","aria-label":G??"Process Sankey validation failed",children:[(0,md.jsx)("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),_e.map((e,t)=>(0,md.jsx)("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+Sc(e)},t))]}):Le.loadingEl?Le.loadingEl:Le.emptyEl?Le.emptyEl:(0,md.jsxs)("div",{style:{position:"relative",width:q,height:Y},children:["pending"===ze&&!1!==F&&!$e&&(0,md.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Ia(!0,q,Y,F)}),(0,md.jsx)(Cs,{ref:ve,chartType:"force",nodes:Xe,edges:Ve,customNetworkLayout:gd,layoutConfig:Be,size:[q,Y],responsiveWidth:K,responsiveHeight:Z,margin:Ne,title:G,description:V??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:U,accessibleTable:Q,enableHover:ae,tooltipContent:!1===ie?()=>null:qe,backgroundGraphics:Ye,showParticles:de,particleStyle:he,legend:He,legendPosition:k,...$l({linkedHover:ue,selection:ce,onObservation:se,onClick:le,mobileInteraction:Le.mobileInteraction,customHoverBehavior:Le.customHoverBehavior,customClickBehavior:Le.customClickBehavior,linkedHoverInClickPredicate:!1}),chartId:fe,colorScheme:Array.isArray(v)?v:void 0,layoutSelection:Le.activeSelectionHook,...ge})]})});bd.displayName="ProcessSankey";var vd=require("react"),xd=require("react"),kd=require("react/jsx-runtime"),wd=(0,vd.forwardRef)(function(e,t){const{nodes:n,edges:r,layout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",margin:u,className:d,colorBy:h,colorScheme:f,selection:g,linkedHover:p,onObservation:y,onClick:m,chartId:b,annotations:v,autoPlaceAnnotations:x,frameProps:k={}}=e,{frameRef:w,resolved:S,normalizedMargin:M}=function(e){const t=(0,xd.useRef)(null);return Ts(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:ml(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:(0,xd.useMemo)(()=>function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),A=(0,vd.useMemo)(()=>ia(n),[n]),C=(0,vd.useMemo)(()=>ia(r),[r]),L=(0,vd.useMemo)(()=>void 0===n&&void 0===r?void 0:[...A,...C],[r,n,C,A]),T=Zs(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:j,customClickBehavior:N,activeSelectionHook:P}=yl({selection:g,linkedHover:p,fallbackFields:"string"==typeof h?[h]:[],onObservation:y,onClick:m,chartType:"NetworkCustomChart",chartId:b,colorByField:"string"==typeof h?h:void 0,mobileInteraction:T}),I=(0,vd.useMemo)(()=>P?.isActive?{isActive:!0,predicate:P.predicate}:null,[P?.isActive,P?.predicate]),{width:E,height:R,enableHover:D,title:_,description:O,summary:$,accessibleTable:W}=S,B=Ia(e.loading,E,R,e.loadingContent),z=B?null:Pa(L,E,R,e.emptyContent);if(B||z)return B||z;const F={chartType:"force",...null!=n&&{nodes:A},...null!=r&&{edges:C},customNetworkLayout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,size:[E,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:M,enableHover:D,...Ol({title:_,description:O,summary:$,accessibleTable:W,className:d,animate:e.animate,autoPlaceAnnotations:x}),...$l({linkedHover:p,selection:g,onObservation:y,onClick:m,mobileInteraction:T,customHoverBehavior:j,customClickBehavior:N,linkedHoverInClickPredicate:!1}),layoutSelection:I,...null!=v&&{annotations:v},...k};return(0,kd.jsx)(Ta,{componentName:"NetworkCustomChart",width:E,height:R,children:(0,kd.jsx)(Cs,{ref:w,...F})})});wd.displayName="NetworkCustomChart";var Sd={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Md=8;function Ad(e){const t=function(e){return null==e?void 0:e+""}(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Sd},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??Md,style:{...Sd},datum:e.datum,id:t,label:e.label}}
|
|
2
|
+
var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,s=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))a.call(e,l)||l===i||n(e,l,{get:()=>t[l],enumerable:!(s=r(t,l))||s.enumerable});return e},l=(e,r,o)=>(o=null!=e?t(i(e)):{},s(!r&&e&&e.__esModule?o:n(o,"default",{value:e,enumerable:!0}),e)),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{ChordDiagram:()=>rc,CirclePack:()=>fc,DEFAULT_HIT_RADIUS:()=>Ad,ForceDirectedGraph:()=>zl,NetworkCustomChart:()=>Sd,OrbitDiagram:()=>yc,ProcessSankey:()=>vd,SankeyDiagram:()=>ec,StreamNetworkFrame:()=>Ls,TreeDiagram:()=>ac,Treemap:()=>uc,composeStyleRules:()=>Nl,diagnoseProcessSankeyLayout:()=>Pu,diagnoseProcessSankeyProps:()=>Eu,explainProcessSankeyLayout:()=>ju,formatProcessSankeyIssue:()=>Mc,glyphExtent:()=>yn,glyphPlacement:()=>mn,hatchFillId:()=>Wo,hatchPatternDef:()=>zo,inventoryAtTime:()=>Nu,isHatchFill:()=>Oo,makeNodeRuleContext:()=>Ll,makeRuleValueResolver:()=>Cl,matchesThreshold:()=>Pl,networkHitTarget:()=>Cd,resolveResponsiveRules:()=>Qs,resolveStyleRules:()=>El,resolveSvgFill:()=>Fo,responsiveRuleMatches:()=>Us,ruleMatches:()=>jl,toProcessSankeyTime:()=>Iu,useCustomLayoutSelection:()=>dn,useForceLayout:()=>Kl,validateProcessSankey:()=>Sc}),module.exports=(e=c,s(n({},"__esModule",{value:!0}),e));var u=l(require("react")),d=require("react");function h(e){return Array.isArray(e)?e[0]:e}function f(e,t,n,r){return{data:h(e),x:t,y:n,__semioticHoverData:!0,...r}}var g={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},p={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},m=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=n[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?y(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function y(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];b(c,u,d,h,l,o);const f=h.x-c.x,g=h.y-c.y,p=Math.sqrt(f*f+g*g);if(p>.001){const e=f/p;o.x+=-g/p*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,a,s]=e.points;b(o,i,a,s,t,r);const l=s.x-o.x,c=s.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function b(e,t,n,r,o,i){const a=1-o,s=a*a,l=s*a,c=o*o,u=c*o;i.x=l*e.x+3*s*o*t.x+3*a*c*n.x+u*r.x,i.y=l*e.y+3*s*o*t.y+3*a*c*n.y+u*r.y}function v(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function x(e,t){var n,r=[],o=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(r=s[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[r=s[e][t]];h||(a[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var p=f[g];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(r[t]=0|Math.min(r[t],r[p])),0>a[p]||s[t].push(a[p])}i[t]=g}else{if(r[t]===n[t]){var m=[],y=[],b=0;for(g=l.length-1;g>=0;--g){var v=l[g];if(o[v]=!1,m.push(v),y.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){l.length=g;break}}d.push(m);var x=Array(b);for(g=0;y.length>g;g++)for(var k=0;y[g].length>k;k++)x[--b]=y[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&c.push(g[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],n=a);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var p=0;s[g].length>p;p++){var m=s[g][p];i[+m]=!1,a[m]={}}c(n),n+=1}else n=h}return t?void 0:r}function k(e){return e.y0-e.y1>0?"up":"down"}function w(e,t){return t(e.source)==t(e.target)}function S(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function M(e){return e.target.x0-e.source.x1}function A(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1-r:e.y1+r}function C(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1+r:e.y1-r}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function T(e,t){return t(e)}function P(e){return E(e.source)}function j(e){return E(e.target)}function E(e){return(e.y0+e.y1)/2}function N(e){return e.virtual?0:e.value}function I(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!w(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!w(e,t)?r+1:r}),n+r}function R(e){return e.target.depth}function D(e,t){return e.sourceLinks.length?e.depth:t-1}function _(e,t){return e.y0-t.y0}function O(e,t){return t.y0-e.y0}function $(e,t){return e.y1-t.y1}function W(e,t){return t.y1-e.y1}function B(e,t){return F(e.source,t.source)||e.index-t.index}function z(e,t){return F(e.target,t.target)||e.index-t.index}function F(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function H(e,t){return q(e)==q(t)?"bottom"==e.circularLinkType?O(e,t):_(e,t):q(t)-q(e)}function q(e){return e.target.column-e.source.column}function Y(e,t){return X(e)==X(t)}function X(e){return e.y0-e.y1>0?"up":"down"}var G=require("d3-array");function V(e,t,n,r,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=(0,G.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}),U(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),U(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+r,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,w(e,t)&&S(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+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 a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?O:_);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?W:$),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*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,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function U(e,t,n){e.sort(H);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(w(e,t)&&S(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Q(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Q(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var K=require("d3-array");function Z(e){return function(){return e}}function J(e){return e.index}function ee(e){return e.nodes}function te(e){return e.links}function ne(e,t,n){var r=(0,K.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=E(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=E(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=s.get(e),r=s.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?I(t,n)-I(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.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==I(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function re(e,t,n,r,o,i){var a=(0,K.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,n),u();function c(t,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&I(o,n)>0){var l=(0,K.mean)(o.sourceLinks,j),c=(0,K.mean)(o.targetLinks,P),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-E(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-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 h=(0,K.mean)(o.sourceLinks,j),f=(0,K.mean)(o.targetLinks,P),g=((h&&f?(h+f)/2:h||f)-E(o))*t;o.y0+=g,o.y1+=g}})})}function u(){a.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||F),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+r;if((a=l-r-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+o-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function oe(e){e.nodes.forEach(function(e){e.sourceLinks.sort(z),e.targetLinks.sort(B)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=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=n+e.width/2,n+=e.width)})})}function ie(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,s=J,l=D,c=void 0,u=32,d=2,h=ee,f=te;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=r,h.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(0,K.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=v(n,r)),"object"!=typeof o&&(o=e.target=v(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=x(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,r=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:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){T(e,t)!=T(o.source,t)&&T(e,t)!=T(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),w(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,K.sum)(e.sourceLinks,N),(0,K.sum)(e.targetLinks,N)),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)})})}(h),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,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?n(e,i):e.column})}(h,c,l);var f=i;if(null!==a){var g=(0,K.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=(0,K.max)(g,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*a/(p-1)))}(function(e,t,n){var r=(0,K.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=(0,K.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,K.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,K.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})})(h,f,o),ne(h,c,s),re(h,c,s,f,f,u),oe(h),V(h,s,d,10,8),ne(h,c,s),re(h,c,s,f,f,u),oe(h),V(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return T(n.source,t)==T(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Y(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=A(t,e);return e.y1-n}if(t.target.column>e.target.column)return A(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 i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return T(n.target,t)==T(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Y(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=C(t,e);return e.y0-n}if(t.source.column>e.source.column)return C(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 i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=(0,K.min)(t,function(e){return e.y0}),a=(0,K.max)(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),V(h,s,d,10,8)}(g),g}return g.update=function(e){return oe(e),V(e,s,d,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?(a=+e,g):a},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Z(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:Z(e),g):f},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Z(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Z(e),g):l},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(u=+e,g):u},g.circularLinkGap=function(e){return arguments.length?(d=+e,g):d},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}function ae(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function se(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function le(e){const t=e.map(ae),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return se(e,n,r)}if(e>=1){const[e,r,o]=t[n];return se(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return se(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}var ce=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ue=le(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),de=le(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),he=le(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),fe=le(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ge=le(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),pe=le(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),me={blues:ue,reds:de,greens:he,viridis:le(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oranges:fe,purples:ge,greys:pe,plasma:le(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:le(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:le(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:le(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:le(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])},ye=(le(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),le(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),le(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),le(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),le(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),require("d3-interpolate"));function be(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(n+r)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${l},${i} ${o},${i}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}require("d3-shape");var ve=e=>{let t,n,r,o,i,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=(0,ye.interpolateNumber)(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,d=(0,ye.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=be({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function xe(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+s},${o-t}L${n+s},${o+t}L${n},${o+t}ZM${i},${a-t}L${i-l},${a-t}L${i-l},${a+t}L${i},${a+t}Z`}const o=r.sourceX,i=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${o},${i-d*t}L${l},${i-d*t}L${l+n},${i-d*t+d*h}L${l+n},${u+d*n-d*h}L${l+n-h},${u+d*n}L${c-n+h},${u+d*n}L${c-n},${u+d*n-d*h}L${c-n},${s-d*t+d*h}L${c-n+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+n},${s+d*t}L${c+n},${u-d*n}L${l-n},${u-d*n}L${l-n},${i+d*t}L${o},${i+d*t}Z`}var ke=new Set,we=new WeakMap;function Se(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=we.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,we.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ke.has(e)||(ke.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}function Me(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function Ae(e){return"string"==typeof e?e:e.id}var Ce={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(R))-1:0},justify:D},Le={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",a=n.nodeWidth??15,s=n.nodePaddingRatio??.05,l=n.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:Ae(e.source),target:Ae(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const h=ie().extent(d).links(u).nodes(c).nodeAlign(Ce[i]||D).nodeId(e=>e.id).nodeWidth(a).iterations(l);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-n,s=r[0],l=r[1];if(i>0&&a>0&&(0>e||0>n||t>s||o>l)){const t=Math.min(s/i,l/a),r=-e*t+(s-i*t)/2,o=-n*t+(l-a*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of c){const t=f.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 g=new Map;for(const e of t)if(e._edgeKey)g.set(e._edgeKey,e);else{const t=Ae(e.source),n=Ae(e.target);g.set(`${t}\0${n}`,e)}for(const e of u){const t=Ae(e.source),n=Ae(e.target),r=g.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),a=f.get(n);i&&(r.source=i),a&&(r.target=a)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,a=n.edgeStyle,s=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const d=[],h=[],f=[],g=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(Se(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};g.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:a,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){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 o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?g.get(r.id)||u.get(r.id)||o:g.get(t.id)||u.get(t.id)||o;const i=a?a(Se(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-a},${t.targetY-n}L${t.targetX-a},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?xe(e):ve(e),c)&&h.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=Me(n.nodeLabel);for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=t?t(n):n.id;if(!a)continue;let s,l,c;"down"===o?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(s=n.x0-6,c="end"):(s=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:s,y:l,text:a+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}},Te=require("d3-force"),Pe=require("d3-scale");function je(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var Ee=()=>"undefined"!=typeof performance?performance.now():Date.now();function Ne(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ie(e,t){const n=e();return Number.isFinite(n)?n:t}var Re=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Ee,this.lastWallTime=Ie(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Ie(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Ee;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Ie(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Ne(n)))}},De={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=c?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const r=_e(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Oe(e.id),i=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(i),e.y=n/r.length+a*Math.sin(i)}else{const t=Oe(e.id),n=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=i+r*Math.cos(n),e.y=a+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5)*s,o=n*t;r.x=i+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}const f=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=$e(n.nodeSize,n.nodeSizeRange,e),p=e=>g(e);if(f>0){const c=new Map,u=new Map;for(const t of e)c.set(t.id,0),u.set(t.id,t);for(const e of t){const t=Ae(e.source),n=Ae(e.target);c.set(t,(c.get(t)??0)+1),c.set(n,(c.get(n)??0)+1)}const d=(0,Te.forceLink)().strength(e=>{const t=e.weight,n=Ae(e.source),r=Ae(e.target),i=Math.max(1,Math.min(c.get(n)??1,c.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,r=(t?p(t):0)+(n?p(n):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),g=(0,Te.forceSimulation)();if(void 0===n.random&&void 0===n.seed||g.randomSource(n.random??Ne(n.seed)),g.force("charge",(0,Te.forceManyBody)().strength(e=>{const t=c.get(e.id)??0;return-15*s*p(e)*Math.sqrt(t+1)})).force("collide",(0,Te.forceCollide)(e=>p(e)+3*s).strength(.9).iterations(2)).force("center",(0,Te.forceCenter)(i,a).strength(.8)).force("x",(0,Te.forceX)(i).strength(l)).force("y",(0,Te.forceY)(a).strength(l)).force("bounds",function(e,t,n=2,r=.6){let o=[];const i=i=>{const a=r*Math.max(i,.2);for(const r of o){const o=r.x??e[0]/2,i=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+n,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),g=o+s,p=i+l;u>g?r.vx=s+(u-g)*a:g>d&&(r.vx=s+(d-g)*a),h>p?r.vy=l+(h-p)*a:p>f&&(r.vy=l+(f-p)*a)}};return i.initialize=e=>{o=e},i}(r,p)),g.nodes(e),t.length>0){const e=t.map(e=>({...e,source:Ae(e.source),target:Ae(e.target)}));d.links(e),g.force("link",d)}h?g.alpha(.3):.1>g.alpha()&&g.alpha(1),g.stop();for(let e=0;f>e;++e)g.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=p(t),n=f>0?2:0,o=Math.min(r[0]/2,e+n),i=Math.min(r[1]/2,e+n);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(i,Math.min(r[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,a=$e(n.nodeSize,n.nodeSizeRange,e),s=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});const c=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(Se(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=Me(n.nodeLabel);for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=a(Se(n,"nodeSize"));d.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};function _e(e,t,n){const r=[];for(const o of t){const t=Ae(o.source),i=Ae(o.target);let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Oe(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function $e(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,a]=je(o);if(i===a)return()=>(r[0]+r[1])/2;const s=(0,Pe.scaleLinear)().domain([i,a]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:s(n)}}var We=require("d3-chord"),Be=require("d3-shape"),ze=ce,Fe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(r[0],r[1])/2,l=s-i,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t=Ae(e.source),n=Ae(e.target),r=f.get(t),o=f.get(n);if(void 0===r||void 0===o)continue;const i=d(e);p[r][o]=i}const m=(0,We.chord)().padAngle(o);a&&m.sortGroups(a);const y=m(p),b=y.groups,v=(0,Be.arc)().innerRadius(l).outerRadius(s);for(const t of b){const n=e[t.index],r=v.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t=Ae(e.source),n=Ae(e.target),r=x.get(t),o=x.get(n);r&&(e.source=r),o&&(e.target=o)}const k=new Map;for(const e of t){const t=Ae(e.source),n=Ae(e.target);k.set(`${t}\0${n}`,e)}for(const t of y){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ze,g=new Map;e.forEach((e,t)=>{g.set(e.id,f[t%f.length])});const p=(0,We.ribbon)().radius(s),m=[],y=[],b=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(Se(n,"nodeStyle")).fill||g.get(n.id)||f[t%f.length]:g.get(n.id)||f[t%f.length];const i=u?u(Se(n,"nodeStyle")):{};m.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const o=He(r,l,c);let a=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)a=d(Se(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?a=g.get(n.id)||a:t&&(a=g.get(t.id)||a)}const s=d?d(Se(e,"edgeStyle")):{};y.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==n.showLabels){const t=Me(n.nodeLabel),r=a+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;b.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:m,sceneEdges:y,labels:b}}};function He(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}var qe=require("d3-hierarchy"),Ye=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xe(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Ge(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Ve(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Ue(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Ye}function Qe(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ke(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Ze={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=(0,qe.hierarchy)(o,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,qe.tree)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,qe.cluster)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,a=(0,qe.treemap)().size([n,r]).tile(qe.treemapBinary).padding(o);i>0&&a.paddingTop(i),a(e)}(c,n,u,d);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;(0,qe.pack)().size([n,r]).padding(o)(e)}(c,n,u,d);break;case"partition":!function(e,t,n,r){(0,qe.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,d)}const h=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const r=h[t],o={id:Ge(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Je(o,r,n):"treemap"===i||"partition"===i?et(o,r):"circlepack"===i&&tt(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const a=[],s=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(g=n.nodeSize)?g:5;var g;for(const t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);const i=o(Se(t,"nodeStyle"));let s=i.fill||Qe(n);if(n.colorByDepth&&void 0!==t.depth){const e=Ue(n);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:f,style:{fill:s,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.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 o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);const g=Ke(o,a,l,f,c),m=i(Se(e,"edgeStyle"));s.push({type:"curved",pathD:g,style:{fill:"none",stroke:m.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:m.strokeWidth??1.5,opacity:m.opacity??p},datum:e})}if(!1!==n.showLabels){const t=Ve(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,a=n.x,s=n.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,n=Math.sqrt(e*e+t*t);n>0?(r=a+e/n*10,o=s+t/n*10,i=0>e?"end":"start"):(r=a,o=s-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=a-f-6,i="end"):(r=a+f+6,i="start"),o=s):(r=a,o=s+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=r(Se(n,"nodeStyle"));let s=a.fill||Qe(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ue(t);s=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,fillOpacity:a.fillOpacity,strokeOpacity:a.strokeOpacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ve(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;const c=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Se(s,"nodeStyle")).fill||Qe(t);if(t.colorByDepth&&void 0!==s.depth){const e=Ue(t);d=e[s.depth%e.length]}const h="string"==typeof d?Xe(d):t.themeSemantic?.text??"#000";i.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(Se(n,"nodeStyle"));let a=i.fill||Qe(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ue(t);a=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ve(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=n?n(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let l=r(Se(o,"nodeStyle")).fill||Qe(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ue(t);l=e[o.depth%e.length]}if(s){const n="string"==typeof l?Xe(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Je(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(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 et(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 tt(e,t){const n=t.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}var nt=require("d3-shape");function rt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var ot={sankey:Le,force:De,chord:Fe,tree:Ze,cluster:Ze,treemap:Ze,circlepack:Ze,partition:Ze,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=rt(n);h.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function g(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,m=t[1]/2,y=Math.min(t[0],t[1])/2*.85,b=g(a(e));r.push({id:b,x:p,y:m,x0:p,x1:p,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:y,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,p,m){const y=i(t);if(!y?.length)return;const b=y.length;let v=0,x=0,k=0;for(;b>x;)x+=s[Math.min(k,s.length-1)],k++,v++;let w=0;for(let b=0;v>b;b++){const x=s[Math.min(b,s.length-1)],k=y.slice(w,w+x);if(!k.length)break;const S=(b+1)/v,M={id:n,depth:p,data:t,parentId:n},A=m?f/u(M)*S:f*S,C=(0,nt.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),L=d(M);for(let t=0;k.length>t;t++){const i=(C[t].startAngle+C[t].endAngle)/2,s=k[t],u=g(a(s)),d=l+A*Math.sin(i),f=c+A*Math.cos(i)*L;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:s}),h.metaMap.set(u,{ring:A,angle:i,depth:p,parentId:n,eccentricity:L}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,A,p+1,!0)}w+=x}}(e,b,p,m,y,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=rt(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=a(Se(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=rt(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=s.get(e.parentId);if(!r)continue;const l=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function it(e){return ot[e]}function at(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(at))}function st(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function lt(e,t,n){return e+(t-e)*n}var ct=require("d3-quadtree");function ut(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 dt(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!ht(e))return!1;return!0}return ht(t.points)}function ht(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}var ft=require("d3-interpolate");function gt(e,t,n){if(1>=n)return 1;const r=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}var pt="rgba(34, 197, 94, 0.7)",mt=2e3,yt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function bt(e,t){const n={...e};for(const e of t)n[yt[e]]++;return n}function vt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:bt(n,r)}}var xt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=vt({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=vt(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},kt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],wt=["scene-style","data-paint","accessibility","evidence"],St=(e,t)=>({retainedData:e,invalidations:t}),Mt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],At=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ct=["scene-geometry","data-paint","overlay","accessibility","evidence"],Lt=["scene-style","data-paint","accessibility","evidence"],Tt=["scene-geometry","data-paint","overlay","accessibility","evidence"],Pt=[],jt={chartType:St("rebuild",Mt),nodeIDAccessor:St("rebuild",Mt),sourceAccessor:St("rebuild",Mt),targetAccessor:St("rebuild",Mt),valueAccessor:St("rebuild",Mt),edgeIdAccessor:St("rebuild",Mt),childrenAccessor:St("rebuild",Mt),hierarchySum:St("rebuild",Mt),orientation:St("preserve",At),nodeAlign:St("preserve",At),nodePaddingRatio:St("preserve",At),nodeWidth:St("preserve",At),edgeSort:St("preserve",At),iterations:St("preserve",At),forceStrength:St("preserve",At),padAngle:St("preserve",At),groupWidth:St("preserve",At),sortGroups:St("preserve",At),treeOrientation:St("preserve",At),edgeType:St("preserve",At),padding:St("preserve",At),paddingTop:St("preserve",At),orbitMode:St("preserve",At),orbitSize:St("preserve",At),orbitSpeed:St("preserve",At),orbitRevolution:St("preserve",At),orbitRevolutionStyle:St("preserve",At),orbitEccentricity:St("preserve",At),orbitShowRings:St("preserve",At),orbitAnimated:St("preserve",At),customNetworkLayout:St("preserve",At),layoutConfig:St("preserve",At),nodeSize:St("preserve",Ct),nodeSizeRange:St("preserve",Ct),colorByDepth:St("preserve",Ct),nodeLabel:St("preserve",Tt),showLabels:St("preserve",Tt),labelMode:St("preserve",Tt),nodeStyle:St("preserve",Lt),edgeStyle:St("preserve",Lt),colorBy:St("preserve",Lt),colorScheme:St("preserve",Lt),themeCategorical:St("preserve",Lt),themeSemantic:St("preserve",Lt),edgeColorBy:St("preserve",Lt),edgeOpacity:St("preserve",Lt),showParticles:St("preserve",Lt),particleStyle:St("preserve",Lt),decay:St("preserve",Lt),pulse:St("preserve",Lt),thresholds:St("preserve",Lt),staleness:St("preserve",Lt),layoutSelection:St("preserve",Lt),clock:St("preserve",Pt),random:St("preserve",Pt),seed:St("preserve",Pt),tensionConfig:St("preserve",Pt),transition:St("preserve",Pt),introAnimation:St("preserve",Pt),onLayoutError:St("preserve",Pt),__skipForceSimulation:St("preserve",Pt),__hierarchyRoot:St("preserve",Pt),__orbitState:St("preserve",Pt),__previousPositions:St("preserve",Pt)},Et=St("preserve",At),Nt=class{constructor(){this.tracker=new xt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},kt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},wt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=jt[r]??Et;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},It=new WeakMap;var Rt=require("d3-scale"),Dt={category10:ce,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...me},_t=ce,Ot="#007bff";function $t(e,t,n=_t){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Dt[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var Wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Bt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],zt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Ft(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||zt.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):_t[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%_t.length]}function Ht(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function qt(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>Ht(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,Rt.scaleOrdinal)().domain(r).range(n).unknown("#999");const i=Dt[n]||Dt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:_t;return(0,Rt.scaleOrdinal)().domain(r).range(e).unknown("#999")}}function Yt(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&Ht(n,e)||"#4e79a7":t=>{if(n){const e=Ht(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Xt({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:a}){const s=$t(e.colorScheme,e.themeCategorical,ce),l={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...s]},resolveColor:Yt(s,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==i,r=function(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}("network",t,n,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}var Gt=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Nt,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,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._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...g,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new m(2e3))}currentTime(){return this.config.clock?.()??("undefined"!=typeof performance?performance.now():Date.now())}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...g,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new m(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...ut(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",o=u(n)+"",i=d(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,{...ut(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...ut(o),data:n});const l=`${r}\0${o}\0${e}`,h={source:r,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&dt(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,ut(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,ut(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;l?(l.value+=r,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=it(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&n.length>0&&a>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const a=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=Xt({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;at(r)&&0===n.length&&st(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&st(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=it(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=(0,ct.quadtree)().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=it(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=it(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=lt(e._prevX0,e._targetX0,n),e.x1=lt(e._prevX1,e._targetX1,n),e.y0=lt(e._prevY0,e._targetY0,n),e.y1=lt(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=lt(e._prevY0,e._targetY0,n),e.y1=lt(e._prevY1,e._targetY1,n),e.sankeyWidth=lt(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}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),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,a=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=(0,ft.interpolateNumber)(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(r)},{x:e.y1,y:s(1-r)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=n.x0,s=(0,ft.interpolateNumber)(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(r),y:e.y0},{x:s(1-r),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}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){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const l=i-s;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const a="object"==typeof o.source?o.source?.id:o.source,s="object"==typeof o.target?o.target?.id:o.target;if(!a||!s)continue;const l=e.edgeTimestamps.get(`${a}\0${s}`);if(!l)continue;const c=i-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const a=gt(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*a}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===pt&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=mt)return;const n=1-t/mt;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=pt,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&mt>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const l=t.metric(s);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Gt.QUADTREE_THRESHOLD=500;var Vt=Gt;Object.assign(Vt.prototype,{getLastUpdateResult:function(){return this.updateResults.last},getUpdateSnapshot:function(){return this.updateResults.last},subscribeUpdateResult:function(e){return this.updateResults.subscribe(e)},setLayoutSelection:function(e){this.config.layoutSelection=e},markStylePaintPending:function(){It.set(this,!0)},consumeStylePaintPending:function(){const e=!0===It.get(this);return It.delete(this),e}});var Ut=require("react"),Qt={sceneGeometry:0,layout:0,domain:0};function Kt(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function Zt(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Jt="production"!==process.env.NODE_ENV,en={revisions:Qt,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},tn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=Qt,this.lastObserved=Qt,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Jt&&(this.lastObserved=Zt(this.lastObserved,Kt(e)))}beforeCompute(e,t){if(!Jt)return en;const n=Zt(Kt(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(Jt){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},nn=(0,Ut.memo)(function({store:e,diagnostics:t}){return(0,Ut.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),rn=l(require("react"));function on(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:rn.createElement(rn.Fragment,null,...t)}var an=l(require("react")),sn=require("react/jsx-runtime"),ln={isActive:!1,predicate:()=>!0},cn=an.createContext(null);function un({value:e,children:t}){return(0,sn.jsx)(cn.Provider,{value:e,children:t})}function dn(){return an.useContext(cn)??ln}function hn(e,t){return null!=e?(0,sn.jsx)(un,{value:t,children:e}):e}var fn=require("react"),gn=[40,40],pn=[.5,.5];function mn(e,t){const[n,r]=e.viewBox??gn,[o,i]=e.anchor??pn,a=r>0?r:1,s=Math.max(0,t)/a,l=(n>0?n:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-o*l,offsetY:-i*c}}function yn(e,t){const n=mn(e,t),r=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let o=0;for(const[e,t]of r){const n=Math.sqrt(e*e+t*t);n>o&&(o=n)}return o}function bn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var vn=null;function xn(e){if("undefined"==typeof Path2D)return null;vn||(vn=new Map);const t=vn.get(e);if(t)return t;const n=new Path2D(e);return vn.size>1024&&vn.clear(),vn.set(e,n),n}function kn(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??gn,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:i*(1-s),width:o,height:i*(s-a)}:{x:o*a,y:0,width:o*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function wn(e,t){const n=mn(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Sn(e,t,n,r,o,i=e=>e){for(const a of t.parts){const t=xn(a.d);if(!t)continue;const s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);const c=o?"none"===a.fill?void 0:o:bn(a.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?a.stroke&&"none"!==a.stroke?o:void 0:bn(a.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function Mn(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?An(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?An(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function An(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function Cn(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}var Ln=require("react/jsx-runtime"),Tn="var(--semiotic-focus, #005fcc)";function Pn({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!s)if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=(0,Ln.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Tn,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Ln.jsx)("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:Tn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Tn,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Ln.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Ln.jsx)("path",{d:s,fill:"none",stroke:Tn,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Ln.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var jn=l(require("react")),En=["name","label","title"],Nn=["type","kind","category","group","class","status","role","shape"],In=["value","amount","total","count","weight","score"],Rn=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Dn(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function _n(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&Rn.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>En.includes(e.lower));const a=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=Dn(l,Nn),u=Dn(l,In),d=new Set(Nn),h=new Set(In),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:f}}var On=require("react/jsx-runtime"),$n={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Wn(e,t){return"function"==typeof t?t(e):e[t]}function Bn(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 zn(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=Wn(e,n);a=Bn(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=Wn(e,o);s.push({label:n,value:Bn(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Bn(e[n],r);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Bn(e[t[0]],r))}}const l={...$n,...o};return(0,On.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&(0,On.jsx)("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>(0,On.jsxs)("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&(0,On.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function Fn(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{const n=!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType);let r=h(n?e.data??{}:e);if(!r)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof r?.x0&&"number"==typeof r?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof r?.sankeyWidth)&&r.data&&"object"==typeof r.data&&(r=r.data),!r)return null;if(n&&(void 0!==e.allSeries||void 0!==e.xValue)){const t={...r};void 0!==e.allSeries&&void 0===t.allSeries&&(t.allSeries=e.allSeries),void 0!==e.xValue&&void 0===t.xValue&&(t.xValue=e.xValue),r=t}const o=t(r);return null==o?null:(0,On.jsx)("div",{className:"semiotic-tooltip",style:$n,children:o})}}return!1!==e&&void 0!==e&&(function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&"mode"in e&&"multi"===e.mode}(e)?"function"==typeof e.content?Fn(e.content):("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip={{ mode: "multi" }} reached normalizeTooltip without a chart that wires tooltipMode. Prefer LineChart/AreaChart/StackedAreaChart/DifferenceChart, or pass frameProps.tooltipMode: "multi".'),e=>{const t=e.allSeries;if(!t||0===t.length)return(0,On.jsx)("div",{className:"semiotic-tooltip",style:$n,children:(0,On.jsx)("div",{children:Bn(e.data?.value??e.data?.y)})});const n=e.xValue??e.data?.time??e.data?.x;return(0,On.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[null!=n&&(0,On.jsx)("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:Bn(n)}),t.map((e,t)=>(0,On.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[(0,On.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),(0,On.jsx)("span",{style:{flex:1,fontSize:"0.85em"},children:e.group}),(0,On.jsx)("span",{style:{fontWeight:500,fontSize:"0.85em"},children:Bn(e.value)})]},t))]})}):"object"==typeof e&&null!==e&&("fields"in e||"title"in e)?zn(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:r,style:o={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=Wn(e,n);l.push({value:Bn(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=Bn(Wn(e,o),i);l.push({label:a?n:void 0,value:s})});else{const t=_n(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:Bn(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:a?e.key:void 0,value:Bn(e.value,r)})})}const c={...$n,...o};return Array.isArray(l)&&0!==l.length?(0,On.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>(0,On.jsxs)("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,On.jsxs)("strong",{children:[e.label,s]}),e.value]},t))}):null}}()):zn())}}var Hn=require("react/jsx-runtime");function qn({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=jn.useRef(null),[u,d]=jn.useState(null);jn.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[a,n,r,l]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!jn.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),g=f?null:$n;return l?(0,Hn.jsx)("div",{ref:c,className:f?a:(a+" semiotic-tooltip").trim(),style:{...g||{},position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}var Yn=l(require("react")),Xn=require("react"),Gn=require("react"),Vn=require("react/jsx-runtime");function Un(e){let t=null;const n=()=>(t||(t=(0,Gn.createContext)(null)),t),r=Qn(e);return[function({children:t,initialState:r}){const o=(0,Gn.useRef)(r),i=(0,Gn.useMemo)(()=>Qn(e,o.current),[]),a=n();return(0,Vn.jsx)(a.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=(0,Gn.useContext)(o)??r,a=(0,Gn.useRef)(e);a.current=e;const s=(0,Gn.useRef)({hasValue:!1,value:void 0}),l=(0,Gn.useCallback)(()=>{const e=a.current(i.getState()),n=s.current;return n.hasValue&&t&&t(n.value,e)?n.value:(s.current={hasValue:!0,value:e},e)},[i,t]),c=(0,Gn.useCallback)(()=>a.current(i.getState()),[i]);return(0,Gn.useSyncExternalStore)(i.subscribe,l,c)}]}function Qn(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(Kn(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Kn(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Zn(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function Jn(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:er}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var er=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],tr={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},nr={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},rr={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:er,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function or(e,t){if("light"===t)return tr;if("dark"===t)return nr;if("high-contrast"===t)return rr;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?nr:tr;return Jn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Jn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[ir,ar]=Un(e=>({theme:tr,setTheme(t){e(e=>({theme:or(e.theme,t)}))}})),sr=require("react");var lr=require("react"),cr=new WeakMap,ur=0,dr=!1,hr=null,fr=null;function gr(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),r=n.indexOf(",");if(-1===r){const e=n.trim();return e.startsWith("--")?{name:e}:null}const o=n.slice(0,r).trim(),i=n.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:i||void 0}:null}(t);if(!n)return t;const r=()=>n.fallback?gr(e,n.fallback):t,o=e.canvas;if(!o)return r();!function(){if(dr)return;if("undefined"==typeof window||"undefined"==typeof document)return;dr=!0;const e=()=>{ur++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{hr=window.matchMedia("(prefers-color-scheme: dark)"),fr=e,"function"==typeof hr.addEventListener?hr.addEventListener("change",fr):"function"==typeof hr.addListener&&hr.addListener(fr)}catch{}}();let i=cr.get(o);i&&i.version===ur||(i={version:ur,map:new Map},cr.set(o,i));const a=i.map.get(t);if(void 0!==a)return a;const s=getComputedStyle(o).getPropertyValue(n.name).trim()||r()||t;return i.map.set(t,s),s}var pr="undefined"==typeof window?Xn.useEffect:Xn.useLayoutEffect,mr={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function yr(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function br(e){const t=function(){const[e,t]=(0,sr.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,sr.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,Xn.useRef)(t);n.current=t;const[r,o]=function(e,t,n){const r=(0,lr.useRef)(null),[o,i]=(0,lr.useState)(null);return(0,lr.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,a=!!e.legend&&"top"===e.legendPosition,s=(0,Xn.useMemo)(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,a),[e.marginDefault,e.userMargin,i,a]),l=o[0]-s.left-s.right,c=o[1]-s.top-s.bottom,u=yr(e.foregroundGraphics,o,s),d=yr(e.backgroundGraphics,o,s),h=ar(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+Yn.useId(),m=(0,Xn.useRef)(null);if(!m.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;m.current=new Re({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const y=m.current;y.configure({clock:e.clock,random:e.random,seed:e.seed});const b=(0,Xn.useRef)(null),v=(0,Xn.useRef)(e.frameScheduler??mr);v.current=e.frameScheduler??mr;const x=(0,Xn.useRef)(null),k=(0,Xn.useRef)(!1),w=(0,Xn.useRef)(()=>{}),S=(0,Xn.useCallback)(()=>{if(null!==b.current||k.current)return;const e=v.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),b.current=null,x.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(b.current=r,x.current=e)},[]),M=(0,Xn.useCallback)(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);pr(()=>{y.setPaused(!0===e.paused)},[y,e.paused]),(0,Xn.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void y.setVisible(!0);const t=()=>y.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[y,e.suspendWhenHidden]),(0,Xn.useEffect)(()=>()=>{M()},[M]);const A=(0,Xn.useRef)(()=>{}),C=(0,Xn.useRef)(()=>{}),L=(0,Xn.useRef)(null),T=(0,Xn.useRef)(null),P=(0,Xn.useRef)(null),j=(0,Xn.useCallback)(()=>{const e=L.current;L.current=null,e&&A.current(e)},[]),E=(0,Xn.useCallback)(e=>{if(L.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===T.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,T.current=null,P.current=null,j()});t||(T.current=n,P.current=e)}},[j]),N=(0,Xn.useCallback)(()=>{L.current=null,null!==T.current&&((P.current??v.current).cancelAnimationFrame(T.current),T.current=null,P.current=null),C.current()},[]);(0,Xn.useEffect)(()=>()=>{L.current=null,null!==T.current&&((P.current??v.current).cancelAnimationFrame(T.current),T.current=null,P.current=null)},[]);const I=e.themeDirtyRef;return pr(()=>{I&&(ur++,I.current=!0,S())},[h,S,I]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:s,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:p,frameRuntime:y,rafRef:b,renderFnRef:w,scheduleRender:S,cancelRender:M,hoverHandlerRef:A,hoverLeaveRef:C,onPointerMove:E,onPointerLeave:N}}var vr=require("react"),xr={fresh:1,aging:.7,stale:.45,expired:.25},kr={alpha:1,band:"fresh",isStale:!1};var wr=require("react/jsx-runtime");function Sr({isStale:e,position:t}){return(0,wr.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var Mr=l(require("react")),Ar=l(require("react"));function Cr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function Lr(e){return"object"==typeof e&&null!==e&&"gradient"in e}var Tr=16,Pr=6,jr=10,Er=22,Nr=100,Ir=10;function Rr(e){return Math.ceil(7*e.length)}function Dr(e,t){if(Cr(e)){const n=Hr(t),r=e.legendGroups.flatMap(e=>[e.label?Rr(e.label):0,...e.items.map(e=>n.swatchSize+n.labelGap+Rr(e.label))]);return Math.max(Nr,...r)}if(Lr(e)){const{gradient:t}=e,n=t.format||(e=>Math.round(100*e)/100+""),r=Math.max(Rr(n(t.domain[0])),Rr(n(t.domain[1]))),o=t.label?Rr(t.label):0;return Math.max(Nr,19+r,o)}return Nr}function _r(e){return(Cr(e)||Lr(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):Ir}function Or(e){return Math.max(0,e?.sideGutter??0)}var $r=22,Wr=46,Br=64;function zr(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?Br:Wr:$r:0}function Fr(e,t,n){if(Lr(e))return e.gradient.label?34:26;if(!Cr(e))return 20;const r=Hr(n),o=Math.max(1,n?.maxWidth??t);let i=r.rowHeight;for(const t of e.legendGroups){let e=0,n=0;for(const i of t.items){const t=r.swatchSize+r.labelGap+Rr(i.label),a=0===n?t:n+r.itemGap+t;n>0&&a>o?(e+=1,n=t):n=a}t.items.length>0&&(e+=1),i=Math.max(i,e*r.rowHeight,t.label?Rr(t.label):0)}return i+(e.legendGroups.length>1?16:0)}function Hr(e){const t=Math.max(1,e?.swatchSize??Tr),n=Math.max(t,e?.rowHeight??Er);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??Pr),itemGap:Math.max(0,e?.itemGap??jr),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}var qr=require("react/jsx-runtime"),Yr={fill:(e,t)=>(0,qr.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,qr.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Xr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Yr[n])(r(e,t),o),i}function Gr({swatchSize:e}){return(0,qr.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Vr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Ur=(e,t,n,r,o,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let p=0;const m=!(!t&&!n),y="isolate"===c||void 0===c&&null!=o,{swatchSize:b,labelGap:v,rowHeight:x}=u;return f.forEach((e,c)=>{const u=Xr(e,c,d,h,b),k=Vr(e,r,o),w=o&&o.size>0&&o.has(e.label);g.push((0,qr.jsxs)("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?s===i&&c===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&y?w||!1:void 0,"aria-current":m&&!y&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:m?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:m?t=>{l(s,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&(0,qr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+v+2+7*e.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,qr.jsx)(Gr,{swatchSize:b}),(0,qr.jsx)("text",{y:b/2,x:b+v,dominantBaseline:"central",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),p+=x}),g};function Qr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Ar.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,qr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return(0,qr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,qr.jsx)("defs",{children:(0,qr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&(0,qr.jsx)("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,qr.jsx)("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,qr.jsx)("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])}),(0,qr.jsx)("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,qr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return(0,qr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,qr.jsx)("text",{x:0,y:-6,textAnchor:"start",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,qr.jsx)("defs",{children:(0,qr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,qr.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,qr.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])}),(0,qr.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])})]})}function Kr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=Hr(d),[f,g]=Ar.useState(0),[p,m]=Ar.useState(0),y=Ar.useCallback((e,t)=>{g(e),m(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const d=[],h=function(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const a=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:a,endY:n}})}(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const g=h[f];d.push((0,qr.jsx)("line",{stroke:"gray",x1:0,y1:g.lineY,x2:t,y2:g.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=g.labelY&&d.push((0,qr.jsx)("text",{y:g.labelY,className:"legend-group-label",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d.push((0,qr.jsx)("g",{className:"legend-item",transform:`translate(0,${g.itemsY})`,children:Ur(e,n,r,o,i,a,s,f,l,c,u)},"legend-group-"+f))}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:y,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const p=((e,t,n,r,o,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,p=[],{swatchSize:m,labelGap:y,itemGap:b,rowHeight:v,align:x}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,S=g.map(e=>m+y+7*e.label.length),M=[];let A=0,C=0;S.forEach((e,t)=>{const n=0===C?e:C+b+e;d&&d>0&&C>0&&n>d?(M.push({start:A,end:t,width:C}),A=t,C=e):C=n}),g.length>0&&M.push({start:A,end:g.length,width:C}),M.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=g[d],x=Xr(e,d,h,f,m),M=Vr(e,r,o),A=o&&o.size>0&&o.has(e.label);p.push((0,qr.jsxs)("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?s===i&&d===a?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?A||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(s,d),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&(0,qr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+y+2+7*e.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,A&&(0,qr.jsx)(Gr,{swatchSize:m}),(0,qr.jsx)("text",{y:m/2,x:m+y,dominantBaseline:"central",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const L=Math.max(0,...M.map(e=>e.width)),T=M.length;return{items:p,offset:L,totalRows:T,totalHeight:T*v}})(e,r,o,i,a,s,l,t,c,u,d,d.maxWidth??n);g+=p.offset+5,f.push({label:e.label,...p,offset:g,totalRows:p.totalRows,totalHeight:p.totalHeight}),h+=g+12});const g=d.maxWidth??n;let p=h>g?0:"center"===d.align?Math.max(0,(g-h)/2):"end"===d.align?Math.max(0,g-h):0;const m=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(m.push((0,qr.jsx)("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),p+=16),m.push((0,qr.jsx)("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&m.push((0,qr.jsx)("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),(0,qr.jsx)("g",{children:m})})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:y,legendInteraction:a,metrics:h}),v=!(!n&&!r);return(0,qr.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==s&&""!==s&&"vertical"===u&&(0,qr.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}var Zr=require("react/jsx-runtime");function Jr(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:a,legendHoverBehavior:s,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i,f=Math.max(0,n-o.left-o.right),g=Math.max(1,h?a?.maxWidth??f:Dr(t,a)),p=_r(t),m=Or(a),y=zr(e.axisChrome,a),b=zr(void 0,a),v=Fr(t,f,a);let x,k;if("left"===i)x=o.left-m-g-p,k=o.top;else if("top"===i)x=o.left,k=o.top-b-p-v;else if("bottom"===i){x=o.left;const e=r-o.bottom;k=Math.max(e+p,Math.min(e+y+p,r-v))}else x=n-o.right+m+p,k=o.top;return(0,Zr.jsx)("g",{transform:`translate(${x}, ${k})`,children:Lr(t)?(0,Zr.jsx)(Qr,{config:t.gradient,orientation:h?"horizontal":"vertical",width:g}):Cr(t)?(0,Zr.jsx)(Kr,{legendGroups:t.legendGroups,title:"",width:g,orientation:h?"horizontal":"vertical",legendLayout:a,customHoverBehavior:s,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t})}var eo=require("react/jsx-runtime"),to={secondary:0,primary:3},no=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function ro(e){return!0===e?._annotationDeferred}function oo(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function io(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function ao(e){return Math.max(.72,.95-.06*e)}var so=l(require("react")),lo=require("react/jsx-runtime");function co(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let a="";for(const e of o)a&&a.length+1+e.length>r?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function uo(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function ho(e,t,n,r){if(!e)return(0,lo.jsx)("g",{className:"annotation-note"});const{label:o,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!i)return(0,lo.jsx)("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,g=i?c?[i]:co(i,l):[],p=o?c?[o]:co(o,l):[],m="leftRight"===u?"end"===h?-4:4:0;let y=0;const b=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push((0,lo.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?m-l:"middle"===h?m-l/2:m,y:-16,width:l,height:Math.max(f,(g.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:(0,lo.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,lo.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&(0,lo.jsx)("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(g.length>0&&(b.push((0,lo.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:g.map((e,t)=>(0,lo.jsx)("tspan",{x:m,dy:0===t?0:f,children:e},t))},"annotation-note-title")),y=g.length*f),p.length>0&&b.push((0,lo.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:y,children:p.map((e,t)=>(0,lo.jsx)("tspan",{x:m,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let x=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=(0,lo.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=(0,lo.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+f+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),(0,lo.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,lo.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:b}),x]})}function fo(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,lo.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push((0,lo.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,a=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push((0,lo.jsx)("line",{x1:r,y1:(t.y1||0)-a,x2:r,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-a;i.push((0,lo.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,lo.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,lo.jsx)("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push((0,lo.jsx)("path",{d:uo(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,lo.jsx)("g",{className:"annotation-subject",children:i})}function go(e,t,n,r,o,i){const a=[];let s=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,a=e-o,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;s=o+a*h,l=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);s=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-s)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-s);if(i){const r=(s+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-s)/c,f=(n?.curve??.25)*c,g=r+d*f,p=i+h*f;a.push((0,lo.jsx)("path",{className:"connector-curve",d:`M${s},${l}Q${g},${p} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-l,g-s)}else a.push((0,lo.jsx)("line",{x1:s,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push((0,lo.jsx)("path",{d:`M${s},${l}L${s+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return(0,lo.jsx)("g",{className:"annotation-connector",children:a})}function po(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:g,strokeDasharray:p,events:m={},"data-testid":y}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-b),null!=a&&(w=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return(0,lo.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":y,...null!=g&&{opacity:g},...p&&{strokeDasharray:p},...m,children:[!x.has("connector")&&go(k,w,l,d,S,c),!x.has("subject")&&fo(S,c,d,b,v),!x.has("note")&&ho(s,k,w,d)]})}function mo(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return(0,lo.jsx)(po,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+i)});return(0,lo.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return(0,lo.jsx)(po,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}var yo=require("d3-hierarchy"),bo=require("d3-shape");function vo(e){return Math.round(100*e)/100}function xo(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const a=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));a.push(r)}r.push(a)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(vo);return{points:e.map(([e])=>[vo(e),vo(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function ko(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function wo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function So(e){return null==e?null:e+""}function Mo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Ao(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return Mo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:r(i),y:o(a)}}(n);return r?Mo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return So(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>So(e.pointId)===r);if(o)return Mo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return So(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const a=ko(i,n),s=wo(i,n);return null==a||null==s?null:Mo(t,n,{x:a,y:s})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=ko(e,n),i=wo(e,n)),null!=o&&null!=i)return Mo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Co(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var Lo=l(require("react")),[To,Po]=Un(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function jo(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var Eo=require("react/jsx-runtime"),No="var(--semiotic-bg, #ffffff)";function Io(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,Eo.jsx)("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:a,fontFamily:s,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??No,strokeWidth:h.haloWidth??3});const g=h.padding??{x:6,y:3},p="number"==typeof g?g:g.x,m="number"==typeof g?g:g.y,y=function(e,t){return(e+"").length*t*.6}(r,i),b=i+2*m;let v,x;return v="middle"===l?t-y/2-p:"end"===l?t-y-p:t-p,x="middle"===c||"central"===c?n-b/2:"hanging"===c||"text-before-edge"===c?n-m:n-.8*i-m,(0,Eo.jsxs)("g",{className:d,children:[(0,Eo.jsx)("rect",{x:v,y:x,width:y+2*p,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??No,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function Ro(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var Do=null;var _o=require("react/jsx-runtime");function Oo(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function $o(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Wo(e,t){let n=2166136261;const r=$o(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}var Bo=new Map;function zo(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*i));return(0,_o.jsxs)("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[n&&"transparent"!==n&&(0,_o.jsx)("rect",{width:l,height:l,fill:n}),(0,_o.jsx)("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s}),(0,_o.jsx)("line",{x1:i,y1:0,x2:i,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s})]},t)}function Fo(e,t,n="#4e79a7"){if(Oo(e)){const n=Wo(t,e);return{fill:`url(#${n})`,def:zo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Ho=require("react/jsx-runtime"),qo={linear:bo.curveLinear,monotoneX:bo.curveMonotoneX,monotoneY:bo.curveMonotoneY,step:bo.curveStep,stepAfter:bo.curveStepAfter,stepBefore:bo.curveStepBefore,basis:bo.curveBasis,cardinal:bo.curveCardinal,catmullRom:bo.curveCatmullRom};var Yo=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Xo(e){return!!e&&"object"==typeof e&&Yo.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Go(e){return"primary"===e?.emphasis||!0===e?.defensive}function Vo(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Uo(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var Qo=32,Ko=6,Zo=4,Jo=8,ei=72;var ti={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ni(e){if(!ri(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function ri(e){return Xo(e)}function oi(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function ii(e,t,n,r,o){const i=e+n,a=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?a-o.height:a,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?a-o.height-4:a+4,width:o.width,height:o.height}}function ai(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function si(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function li(e,t,n,r,o,i,a,s){const l=ai(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,s);for(const e of n)c+=12*si(l,e);for(const e of r)c+=4*si(l,e);return c}function ci(e){const{annotations:t,context:n,defaultOffset:r=Qo,notePadding:o=Ko,markPadding:i=Zo,edgePadding:a=Jo,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=ei,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:g,cohesion:p,audience:m}=e,y=n.width||0,b=n.height||0,v="object"==typeof g?g:{},x=v.breakpoint??480,k=!!g&&x>=y,w=k&&!1!==v.preferShortText?t.map(ni):t,S=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,M=d||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),A=k&&!f?v.responsive??{minWidth:x}:f,C=k&&!p?v.cohesion:p;if(0===w.length||0>=y||0>=b)return w.slice();const L=[],T=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let P=!1;const j=w.map((e,t)=>{if(!ri(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ao(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...oi("string"==typeof e.title?e.title:void 0,t),...oi("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return L.push(ai(ii(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=li(ii(i.x,i.y,e.dx,e.dy,u),e,L,T,y,b,o,a);f>t&&(h=e,f=t)}if(!h)return e;const g=ai(ii(i.x,i.y,h.dx,h.dy,u),o);L.push(g);const p=Math.hypot(h.dx,h.dy),m=l&&p>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return P=!0,{...e,dx:h.dx,dy:h.dy,...m?{connector:m}:{}}}),E=P?j:w.slice();let N=E;if(h){let e=!1;const t=E.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});N=e?t:E}{let e=!1;const t=N.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?ti[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});N=e?t:N}const I=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(m),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Vo(y,b,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=Vo(n,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Xo(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const l=s.filter(e=>Go(e.annotation)),c=s.filter(e=>!Go(e.annotation)).sort((e,t)=>Uo(t.annotation)-Uo(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:N,width:y,height:b,...n});for(const e of r)I.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:480)>=y)for(const e of N)ri(e)&&"secondary"===e.emphasis&&I.add(e);if(I.size>0)for(const e of N)!0===e?.defensive&&I.delete(e);let R;return R=0===I.size?N:M?N.map(e=>I.has(e)?{...e,_annotationDeferred:!0}:e):N.filter(e=>!I.has(e)),C?function(e,t){let n=!1;const r=e.map(e=>ri(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(R,C):R}var ui=require("d3-shape"),di={circle:ui.symbolCircle,square:ui.symbolSquare,triangle:ui.symbolTriangle,diamond:ui.symbolDiamond,star:ui.symbolStar,cross:ui.symbolCross,wye:ui.symbolWye};function hi(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*fi(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,ui.symbol)(di[r]??ui.symbolCircle,Math.max(1,t))()??""}function fi(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var gi=require("react/jsx-runtime");function pi(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:g,foregroundGraphics:p,sceneNodes:m,annotations:y,onAnnotationActivate:b,onObservation:v,chartId:x,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=e,M=function(e){const t=Po(e=>e.pushObservation),n=Lo.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Lo.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:b,onObservation:v,chartId:x,chartType:k}),A=Mr.useMemo(()=>{const e=(m||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=wn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,fi(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:m}},[n,m,t]),C=Mr.useMemo(()=>{if(!y)return y;const e=function(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}(y);return w?ci({annotations:e,context:A,..."object"==typeof w?w:{}}):e},[y,w,A]),L=Mr.useMemo(()=>function(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=Ao(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!Co(o,i,r))return null;const a="callout"===e.type?"callout-circle":e.type,s="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return(0,Ho.jsx)(mo,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=ko(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const s=t>.6*(r.width||0),l=s?t-4:t+4,c=s?"end":"start";return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[(0,Ho.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ho.jsx)(Io,{x:l,y:a,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=wo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,l;"left"===i?(a=4,l="start"):"center"===i?(a=(r.width||0)/2,l="middle"):(a=(r.width||0)-4,l="end");const c=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[(0,Ho.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ho.jsx)(Io,{x:a,y:c,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:ko({...e,type:"point"},r),y:wo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=(0,yo.packEnclose)(t),i=e.padding||10;return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ho.jsx)(Io,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:ko({...e,type:"point"},r),y:wo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),a=t.map(e=>e.y),[s,l]=je(i),[c,u]=je(a),d=s-o,h=l+o,f=c-o;return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("rect",{x:d,y:f,width:h-d,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ho.jsx)(Io,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Ho.jsx)("g",{children:o.map((t,n)=>{const o=ko(t,r),a=wo(t,r);if(null==o||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return(0,Ho.jsx)("circle",{cx:o,cy:a,r:s,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=ko(e,r),o=wo(e,r);return(0,Ho.jsx)(mo,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",a="ordinal"===r.frameType,s="horizontal"===r.projection,l=a?o:null,c=a?i:null;let u;const d=[],h=new Map;if(a&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=h.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,g=r.scales?.y??r.scales?.value;if(!f||!g)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,n+1),o=t-n,i=e(d[n]);return i+(e(d[r])-i)*o},m=f,y=g;let b;if(a)if(s){const e=p(y);b=(t,n)=>[m(n),e(t)]}else{const e=p(m);b=(t,n)=>[e(t),y(n)]}else b=(e,t)=>[m(e),y(t)];const v=e.method||"linear";let x;if("loess"===v)x=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],g+=t*o[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const p=u*f-d*d;if(1e-12>Math.abs(p))s.push([t,h/u]);else{const e=(u*g-d*h)/p;s.push([t,(h-e*d)/u+e*t])}}return s}(u,e.bandwidth??.3);else{const t="polynomial"===v?xo(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:vo((n*t[3]-t[0]*t[1])/r),i=vo(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[vo(e),vo(o*e+i)]),equation:[o,i]}}(u);x=t.points}const k=x.map(([e,t])=>{const[n,r]=b(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",S=x[x.length-1],[M,A]=b(S[0],S[1]);return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ho.jsx)("text",{x:M+4,y:A-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,o=t?.domain?.(),s=e.y0??o?.[0],l=e.y1??o?.[1],c=null!=s&&t?t(s):0,u=null!=l&&t?t(l):r.height||0,d=Fo(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Ho.jsx)("defs",{children:d.def}),(0,Ho.jsx)("rect",{x:0,y:Math.min(c,u),width:r.width||0,height:Math.abs(u-c),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,Ho.jsx)(Io,{x:(r.width||0)-4,y:(i=c,a=u,Math.max(Math.min(i,a),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=t?.domain?.(),i=e.x0??o?.[0],a=e.x1??o?.[1],s=null!=i&&t?t(i):null,l=null!=a&&t?t(a):null;if(null==s||null==l)return null;const c=Fo(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Ho.jsxs)("g",{opacity:e.opacity,children:[c.def&&(0,Ho.jsx)("defs",{children:c.def}),(0,Ho.jsx)("rect",{x:Math.min(s,l),y:0,width:Math.abs(l-s),height:r.height||0,fill:c.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,Ho.jsx)(Io,{x:Math.min(s,l)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const d=qo[r.curve||"linear"]||bo.curveLinear,h=(0,bo.area)().x(e=>i(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Ho.jsx)("text",{x:i(u[u.length-1][o])+4,y:a(u[u.length-1][s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=!1!==e.showBand,g=e.fill||"#6366f1",p=e.fillOpacity??.1,m=e.anomalyColor||"#ef4444",y=e.anomalyRadius??6,b=a(l+d*u),v=a(h),x=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>d*u});return(0,Ho.jsxs)("g",{children:[f&&(0,Ho.jsx)("rect",{x:0,y:Math.min(b,v),width:r.width||0,height:Math.abs(v-b),fill:g,fillOpacity:p}),x.map((e,t)=>{const n=ko(e,r),o=wo(e,r);return null==n||null==o?null:(0,Ho.jsx)("circle",{cx:n,cy:o,r:y,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Ho.jsx)("text",{x:(r.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const i=r.xAccessor||"x",a=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,l=r.scales?.y??r.scales?.value;if(!s||!l)return null;const c=t.map(e=>[e[i],e[a]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=xo(c,e.order||2).equation;u=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=function(e){const t=e.length;let n=0,r=0,o=0,i=0;for(const[t,a]of e)n+=t,r+=a,o+=t*t,i+=t*a;const a=t*o-n*n;if(1e-12>Math.abs(a))return null;const s=(t*i-n*r)/a,l=(r-s*n)/t;return e=>l+s*e}(c);if(!e)return null;u=e}const d=c.length,{se:h,meanX:f,ssX:g}=function(e,t){const n=e.length,r=e.map(([e,n])=>n-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(r/Math.max(n-2,1)),i=e.reduce((e,t)=>e+t[0],0)/n,a=e.reduce((e,t)=>e+(t[0]-i)**2,0);return{se:o,meanX:i,ssX:a}}(c,u),p=.99>(o=e.confidence??.95)?.95>o?.9>o?1:1.645:1.96:2.576,m=e.steps??5,y=c[d-1][0],b=(y-c[0][0])/Math.max(d-1,1),v=[];for(let e=1;m>=e;e++)v.push(y+e*b);const x=[];for(const e of v){const t=u(e),n=h*Math.sqrt(1+1/d+(g>0?(e-f)**2/g:0))*p;x.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${x.map(e=>`${s(e.x)},${l(e.yUpper)}`).join(" L")} L${x.slice().reverse().map(e=>`${s(e.x)},${l(e.yLower)}`).join(" L")} Z`,w=x.map(e=>`${s(e.x)},${l(e.yCenter)}`).join(" "),S=`${s(y)},${l(u(y))}`,M=e.strokeColor||"#6366f1";return(0,Ho.jsxs)("g",{children:[(0,Ho.jsx)("path",{d:k,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Ho.jsx)("polyline",{points:`${S} ${w}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&x.length>0&&(0,Ho.jsx)("text",{x:s(x[x.length-1].x)+4,y:l(x[x.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=Ao(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!Co(o,i,r))return null;const a=e.dx??0,s=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??(0,Ho.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,Ho.jsx)("foreignObject",{x:o+a-l/2,y:i+s-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Ho.jsx)("div",{...jo(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=Ao(e,n,r);if(!t)return null;const{x:o,y:i}=t,a=o+(e.dx||0),s=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,Ho.jsx)("text",{x:a,y:s,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?so.cloneElement(c,{key:"ann-text-"+n}):(0,Ho.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Ho.jsx)("line",{x1:o,y1:i,x2:a,y2:s,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),so.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,a=r.scales?.x,s=r.scales?.y,l=o(i)?i:o(a)?a:o(s)?s:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Ho.jsxs)("g",(r.projection?"vertical"===r.projection:l===a)?{children:[(0,Ho.jsx)("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),f&&(0,Ho.jsx)(Io,{x:c+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,Ho.jsx)("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Ho.jsx)(Io,{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,a,s}}(),[]),T=C?function(e,t,n,r){const o=[];return e.forEach((e,i)=>{let a;if(n){const o=n(e,i,r);a=null!=o?o:t(e,i,r)}else a=t(e,i,r);a&&o.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:io(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>ro(e.annotation)),o=e.some(e=>null!=oo(e.annotation)),i=e.some(e=>"layer"===oo(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=to[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=ro(t.annotation);let a=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;a=(0,eo.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:ao(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const s=oo(t.annotation);return s&&(a=(0,eo.jsx)("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+n)),i&&(a=(0,eo.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return r&&s.unshift((0,eo.jsx)("style",{children:no},"annotation-disclosure-style")),i&&s.unshift((0,eo.jsx)("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(o)}(C.filter(e=>"widget"!==e.type),L,S,A):null,P=!0===C?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,gi.jsxs)(gi.Fragment,{children:[P&&(0,gi.jsx)("style",{children:no},"annotation-widget-disclosure-style"),(0,gi.jsxs)("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,gi.jsx)("title",{children:"string"==typeof s?s:"Network Chart"}),(0,gi.jsx)("desc",{children:"string"==typeof s?s+" (network data visualization)":"Network data visualization"}),(0,gi.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>(0,gi.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),T,p]}),s&&"string"==typeof s?(0,gi.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",fontSize:14,className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,gi.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:s}):null,Jr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:s,legendLayout:g,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),C?.filter(e=>"widget"===e.type&&e.nodeId&&m).map((e,t)=>{const n=!0===e._annotationDeferred,r=m.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),a=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),s=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??(0,gi.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,gi.jsx)("div",{...jo(e,M),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+s-c/2,top:a+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}pi.displayName="NetworkSVGOverlay";var mi=l(require("react")),yi=require("react/jsx-runtime"),bi={position:"absolute",top:0,left:0,pointerEvents:"none"};function vi({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=mi.useRef(null),i=function(e,t,n){const[r,o]=mi.useState(null);return mi.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",a),s.disconnect()}},[t,e,n]),mi.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,a=t.left-n,s=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(a>t+e.width||t>s||l>n+e.height||n>c)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const a=(0,yi.jsx)("div",{className:"semiotic-network-html-marks",ref:o,style:{...bi,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,yi.jsx)("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?(0,yi.jsx)(un,{value:n,children:a}):a}function xi(e,t,n){if(null==t)return n;if(Oo(t)){const r=function(e,t){const n=e.background??"transparent",r=e.stroke??"#000",o="transparent"===n||"none"===n?n:gr(t,n)||n,i=gr(t,r)||r||"#000",a="undefined"!=typeof window&&window.devicePixelRatio||1,s=`${$o(e)}|${o}|${i}@${a}`,l=Bo.get(s);if(void 0!==l)return l;const c=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45}=e,s={background:n,stroke:r,lineWidth:o,spacing:i,angle:a},l=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Do||(Do=document.createElement("canvas")),Do.width=e,Do.height=e,Do)}(l)}catch{return Ro(s)}const u=c.getContext("2d");if(!u)return Ro(s);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,l,l)):u.clearRect(0,0,l,l),u.strokeStyle=r,u.lineWidth=o,u.lineCap="square";const d=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-l;2*l>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*l,l),u.stroke()}else{u.save(),u.translate(l/2,l/2),u.rotate(d);const e=2*l;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(c,"repeat")}({background:o,stroke:i,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),u=Oo(c)?null:c;return Bo.set(s,u),u}(t,e);return r||t.background&&gr(e,t.background)||n}return"string"!=typeof t?t:gr(e,t)||n}function ki(e,t,n,r){t.fill&&(e.fillStyle=xi(e,t.fill,n),void 0!==t.fillOpacity&&(e.globalAlpha=(t.opacity??1)*t.fillOpacity),r())}function wi(e,t,n){t.stroke&&"none"!==t.stroke&&(e.strokeStyle=gr(e,t.stroke)||t.stroke,e.lineWidth=t.strokeWidth??1,e.globalAlpha=(t.opacity??1)*(t.strokeOpacity??1),n())}l(require("react")),require("d3-shape"),require("d3-shape");var Si=require("react/jsx-runtime"),Mi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Ai(e,t="#4e79a7"){return Oo(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}var Ci=l(require("react")),Li=require("d3-shape"),Ti=require("react/jsx-runtime");require("react/jsx-runtime");var Pi="undefined"==typeof window||"undefined"==typeof document,ji=l(require("react")),Ei=l(require("react")),Ni=(require("react/jsx-runtime"),Ei.createContext(null)),Ii=require("react/jsx-runtime"),Ri={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Di({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Ii.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ri,children:t})}var _i=require("react/jsx-runtime");function Oi(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var $i=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Wi="semiotic-accessible-data-table",Bi=Wi+" semiotic-accessible-data-table-hidden",zi=Wi+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",Fi={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Hi={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},qi={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Yi={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Xi={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Gi={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Vi={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ui={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Qi({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,a]=ji.useState(!1),[s,l]=ji.useState(5),c=Ei.useContext(Ni),u=c?.visible??!1,d=i||u,h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=ji.useRef(null);ji.useEffect(()=>{d||l(5)},[d]);const g=ji.useCallback(e=>{e.target===e.currentTarget&&(i||u||a(!0))},[i,u]),p=ji.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||a(!1)},[u]);if(!e||0===e.length)return r?(0,_i.jsx)("span",{id:r,tabIndex:-1,style:Ri}):null;if(!d)return(0,_i.jsx)("div",{id:r,className:Bi,tabIndex:-1,onFocus:g,style:Ri,role:"region","aria-label":h,children:(0,_i.jsxs)("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const m=Array.isArray(e)?e:[],y=Array.isArray(t)?t:[],b=new Map,v=new Map,x=new Map,k=new Map;for(const e of y){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),x.set(e,(x.get(e)??0)+o)}}const w=[];for(let e=0;m.length>e;e++){const t=m[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=b.get(r)??0,i=v.get(r)??0,a=x.get(r)??0,s=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}w.sort((e,t)=>t.degree-e.degree);let S=0,M=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>M&&(M=t.degree);S=e/w.length}const A=y.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),C=[`${w.length} nodes, ${y.length} edges.`];w.length>0&&C.push(`Mean degree: ${$i(S)}, max degree: ${M}.`);const L=Math.min(s,w.length),T=w.slice(0,L),P=w.length-L;return(0,_i.jsxs)("div",{ref:f,id:r,className:zi,tabIndex:-1,onBlur:p,style:Fi,role:"region","aria-label":h,children:[(0,_i.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:qi,children:"×"}),(0,_i.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Hi,children:C.join(" ")}),(0,_i.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Yi,children:[(0,_i.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Vi,children:P>0?`Top ${L} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,_i.jsx)("thead",{children:(0,_i.jsxs)("tr",{children:[(0,_i.jsx)("th",{style:Xi,children:"id"}),(0,_i.jsx)("th",{style:Xi,children:"degree"}),(0,_i.jsx)("th",{style:Xi,children:"in"}),(0,_i.jsx)("th",{style:Xi,children:"out"}),A&&(0,_i.jsx)("th",{style:Xi,children:"w. degree"}),A&&(0,_i.jsx)("th",{style:Xi,children:"w. in"}),A&&(0,_i.jsx)("th",{style:Xi,children:"w. out"})]})}),(0,_i.jsx)("tbody",{children:T.map((e,t)=>(0,_i.jsxs)("tr",{children:[(0,_i.jsx)("td",{style:Gi,children:e.id}),(0,_i.jsx)("td",{style:Gi,children:e.degree}),(0,_i.jsx)("td",{style:Gi,children:e.inDeg}),(0,_i.jsx)("td",{style:Gi,children:e.outDeg}),A&&(0,_i.jsx)("td",{style:Gi,children:$i(e.wDegree)}),A&&(0,_i.jsx)("td",{style:Gi,children:$i(e.wInDeg)}),A&&(0,_i.jsx)("td",{style:Gi,children:$i(e.wOutDeg)})]},t))})]}),P>0&&(0,_i.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:Ui,children:["Show ",Math.min(25,P)," more"," ",1===P?"node":"nodes"," (",P," remaining)"]})]})}function Ki({summary:e}){return e?(0,_i.jsx)("div",{role:"note",style:Ri,children:e}):null}function Zi({tableId:e}){return(0,_i.jsx)("a",{href:"#"+e,style:Ri,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ri)},children:"Skip to data table"})}var Ji=new Set;function ea(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function ta(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Ji.has(n)||(Ji.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function na(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let a=[];const s=()=>{a.length&&(i(a),a=[])};for(const e of n){const n=ea(r,e);if(!n){a.push(e);continue}let l;s(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}l||(ta(n.id,e.type??"unknown"),i([e]))}s()}function ra(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=ea(r,t);if(!i)return o();const a=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=a?a:(ta(i.id,t.type??"unknown"),o())}var oa=Object.freeze([]);function ia(e){if(!e)return oa;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var aa=require("react/jsx-runtime");function sa({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:a,resolvedBackground:s,resolvedForeground:l}){const{chartType:c,nodes:u,edges:d,data:h,className:f,description:g,title:p,responsiveWidth:m,responsiveHeight:y,summary:b,background:v,renderMode:x,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,layoutSelection:T,annotations:P,onAnnotationActivate:j,annotationObservationCallback:E,onObservation:N,chartId:I,autoPlaceAnnotations:R,svgAnnotationRules:D}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(c),n=e?h||(Array.isArray(d)?void 0:d):void 0;if(e&&n)t.ingestHierarchy(n,[i,a]),t.buildScene([i,a]);else{const e=ia(u),n=Array.isArray(d)?ia(d):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,a]),t.buildScene([i,a]))}}const _=t?.sceneNodes??[],O=t?.sceneEdges??[],$=t?.labels??[];return(0,aa.jsxs)("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:m?"100%":r[0],height:y?"100%":r[1]},children:[(0,aa.jsx)(Ki,{summary:b}),(0,aa.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[s&&(0,aa.jsx)("g",{transform:`translate(${o.left},${o.top})`,children:s}),(0,aa.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[v&&(0,aa.jsx)("rect",{x:0,y:0,width:i,height:a,fill:v}),O.map((e,t)=>ra({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"line":return(0,Ti.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e,r=`net-bezier-${t}-hatch`,o=Oo(n.style.fill)?zo(n.style.fill,r):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[o&&(0,Ti.jsx)("defs",{children:o}),(0,Ti.jsx)("path",{d:n.pathD,fill:o?`url(#${r})`:Ai(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-edge-"+t)}case"ribbon":{const n=e,r=`net-ribbon-${t}-hatch`,o=Oo(n.style.fill)?zo(n.style.fill,r):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[o&&(0,Ti.jsx)("defs",{children:o}),(0,Ti.jsx)("path",{d:n.pathD,fill:o?`url(#${r})`:Ai(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-edge-"+t)}case"curved":{const n=e;return(0,Ti.jsx)("path",{d:n.pathD,fill:Ai(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),_.map((e,t)=>ra({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Oo(n.style.fill)?zo(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[r&&(0,Ti.jsx)("defs",{children:r}),(0,Ti.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Oo(n.style.fill)?zo(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[r&&(0,Ti.jsx)("defs",{children:r}),(0,Ti.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,Li.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Mi)||"",o=Oo(n.style.fill)?zo(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,Ti.jsxs)(Ci.Fragment,{children:[o&&(0,Ti.jsx)("defs",{children:o}),(0,Ti.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:Ai(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=hi(n.symbolType,n.size,n.path);return(0,Ti.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Ai(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return function(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=mn(o,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=kn(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:bn(n.fill,s,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:bn(n.stroke??"none",s,e.accent);return o||i?(0,Si.jsx)("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,Si.jsxs)("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&(0,Si.jsx)("clipPath",{id:c,children:(0,Si.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,Si.jsx)("g",{children:d(e.ghostColor)}):null,l&&c?(0,Si.jsx)("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>function(e,t){return(0,Ti.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),(0,aa.jsx)(pi,{width:i,height:a,totalWidth:r[0],totalHeight:r[1],margin:o,labels:$,sceneNodes:_,title:p,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,foregroundGraphics:on(l,hn(t?.customLayoutOverlays,T??null)),annotations:P,onAnnotationActivate:j,onObservation:E??N,chartId:I,chartType:"StreamNetworkFrame",autoPlaceAnnotations:R,svgAnnotationRules:D,annotationFrame:0}),(0,aa.jsx)(vi,{marks:t?.customLayoutHtmlMarks,margin:o,selection:T??null})]})}var la=require("react"),ca="undefined"!=typeof window?la.useLayoutEffect:la.useEffect,ua=()=>()=>{},da=()=>!1,ha=()=>!0;function fa(){const e=(0,la.useSyncExternalStore)(ua,da,ha);return(0,la.useRef)(e).current}var ga=require("react");var pa=require("react/jsx-runtime");function ma(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,maxDevicePixelRatio:i,scheduleRender:a}=e,s=(0,ga.useRef)(null),l=(0,ga.useRef)(null),c=(0,ga.useRef)(!1),u=(0,ga.useRef)(!1),d=(0,ga.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:a,cleanup:s}=e;ca(()=>{const e=r.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():o.current=!0,a?.(),i.current()},[t,n]);const l=(0,la.useRef)(s);l.current=s,(0,la.useEffect)(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,ga.useEffect)(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,a()):t()})},[t,n,r,o,a]),(0,ga.useEffect)(()=>function(){if("undefined"==typeof window||"function"!=typeof window.matchMedia)return()=>{};let e=null,t=!1;const n=()=>{e&&("function"==typeof e.removeEventListener?e.removeEventListener("change",o):"function"==typeof e.removeListener&&e.removeListener(o))},r=()=>{const t=`(resolution: ${window.devicePixelRatio||1}dppx)`;e=window.matchMedia(t),e.media.includes("resolution")?"function"==typeof e.addEventListener?e.addEventListener("change",o):"function"==typeof e.addListener&&e.addListener(o):e=null};function o(){t||(n(),e=null,c.current=!0,a(),queueMicrotask(()=>{t||r()}))}return r(),()=>{t=!0,n(),e=null}}(),[a]),(0,ga.useEffect)(()=>{d.current?(c.current=!0,a()):d.current=!0},[i,a]),(0,ga.useEffect)(()=>{!u.current&&(u.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.canvasPaintInvalidator?e.canvasPaintInvalidator():e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:l,resolutionDirtyRef:c}}function ya({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,pa.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,pa.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}var ba=require("react");function va(e){const t=(0,ba.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return ka(e,t);if(!wa(e)||!wa(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!ka(n,o))return!1}else{if(!wa(n)||!wa(o))return!1;if(!xa(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function xa(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function ka(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function wa(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}var Sa=l(require("react")),Ma=require("react/jsx-runtime");function Aa({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return(0,Ma.jsx)("div",{role:"alert",style:{width:r,height:Math.max(o,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"},children:(0,Ma.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Ma.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Ma.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Ma.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Ca=require("react/jsx-runtime"),La=class extends Sa.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Ca.jsx)(Aa,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},Ta=require("react/jsx-runtime");function Pa({componentName:e,width:t,height:n,children:r}){return(0,Ta.jsx)(La,{fallback:r=>(0,Ta.jsx)(Aa,{componentName:e,message:r.message,width:t,height:n}),children:r})}"undefined"!=typeof process&&process;var ja={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Ea={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Na(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Ta.jsx)("div",{style:{...ja,width:t,height:n},children:r||"No data available"}):null}function Ia(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,Ta.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(i+a)-a))/2);return(0,Ta.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>(0,Ta.jsx)("div",{className:"semiotic-loading-bar",style:{...Ea,position:"absolute",top:s+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Ra(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}function Da(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function _a(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function Oa(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}var $a=class{constructor(e){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(e.data),n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==r&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}r.cleanup(),t.ok?r.resolve(t.payload):r.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(Da(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const r=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(Da(this.options.name))},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),a(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}};function Wa(e){let t=null;return{get:()=>(t&&!t.isDead||(t=e()),t),resetForTest:()=>{if(t){try{t.terminate()}catch{}t=null}}}}var Ba={},za=4e4;function Fa(e,t,n,r,o=za){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}function Ha(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}var qa=class{constructor(e=function(){const e="string"==typeof Ba.url&&Ba.url?new URL("./forceLayoutWorker.js",Ba.url):Ra("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new $a({name:"Force layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:r}=Oa(t);return r?{requestId:n,ok:!1,error:_a(r)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},Ya=Wa(()=>new qa);function Xa(e,t){return Ha()?Ya.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}require("react/jsx-runtime");var Ga=require("react/jsx-runtime"),Va=/^(value|amount|total|count|weight|score)$/i;function Ua({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,Ga.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[(0,Ga.jsxs)("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&(0,Ga.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return(0,Ga.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[(0,Ga.jsx)("div",{children:e.map((e,t)=>(0,Ga.jsxs)("span",{children:[t>0&&(0,Ga.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?(0,Ga.jsx)("strong",{children:e}):(0,Ga.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,Ga.jsx)("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=_n(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>Va.test(e.key));return(0,Ga.jsxs)("div",{className:"semiotic-tooltip",style:$n,children:[(0,Ga.jsx)("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>{return(0,Ga.jsxs)("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!s&&null!=t.value&&t.value>0&&(0,Ga.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,Ga.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Qa(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Ka(e,t){if(!t.pathD)return;e.save();const n=Qa(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,r.y0??0,r.x1,r.y1??0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=gr(e,i)||i;n.addColorStop(0,1===r.from?a:"transparent"),n.addColorStop(1,1===r.to?a:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=xi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=gr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function Za(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=gr(e,n)||n,e.lineWidth=t.style.strokeWidth??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=(t.style.strokeWidth??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 Ja(e,t){if(!t.pathD)return;e.save();const n=Qa(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=xi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=gr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function es(e,t){if(!t.pathD)return;e.save();const n=Qa(t),r=t.style.stroke||"#999";e.strokeStyle=gr(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=xi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}function ts(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ns(e,t,n=.3){ts(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function rs(e,t,n=.6){if(!ts(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}Ua.ownsChrome=!0;var os=new Map;function is(e,t,n,r,o,i){if(0>=t.size)return;const a=function(e,t,n){try{if(n)return new Path2D(n);const r=`${e??"circle"}:${Math.round(t)}`;let o=os.get(r);return o||(o=new Path2D(hi(e,t)),os.size>256&&os.clear(),os.set(r,o)),o}catch{return null}}(t.symbolType,t.size,t.path);if(!a)return;e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation);const s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=o*s*(t.style.fillOpacity??1),e.fillStyle=xi(e,t.style.fill,i),e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*s,e.strokeStyle=gr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(a)),e.restore()}function as(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=mn(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const l=t=>{const n=xi(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=o*s*(t.style.fillOpacity??1);const u=kn(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Sn(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Sn(e,i,c,t.accent,void 0,l),e.restore()}function ss(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:a,adjustedHeight:s,background:l,maxDevicePixelRatio:c,renderMode:u,hasBackgroundGraphics:d=!1,dirtyRef:h,resolutionDirtyRef:f,lastFrameTimeRef:g,now:p,random:m,reducedMotion:y,showParticles:b,isContinuous:v,animate:x,decay:k,pulse:w,thresholds:S,staleness:M,particleStyle:A,getParticleColor:C,pendingAnnotationFrameRef:L,lastAnnotationFrameTimeRef:T,setAnnotationFrame:P,scheduleNextFrame:j,syncColorMap:E}=e,N=t.getContext("2d");if(!N)return;const I=g.current?Math.min((p-g.current)/1e3,.1):.016;g.current=p;const R=n.advanceTransition(y?p+1e6:p),D=!y&&R,_=!y&&n.tickAnimation([a,s],I),O=h.current,$=r?.beforeCompute(n.getLastUpdateResult(),D),W=R||O||_;W&&(n.buildScene([a,s]),O&&E?.()),$&&r?.afterCompute($,W,!1);const B=b&&!y&&!!n.particlePool,z=!!((F={dirtyOrRebuilt:O,transitioning:D,animationTicked:_,continuous:B||v,liveEncoding:!!k||!!w||!!S||!1!==x&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()||!0===f?.current}).dirtyOrRebuilt||F.transitioning||F.animationTicked||F.continuous||F.liveEncoding||F.forced);var F;f&&(f.current=!1);const H=!!M&&n.lastIngestTime>0&&p-n.lastIngestTime>(M?.threshold??5e3);if(z){const e=function(e){if("undefined"==typeof window)return 1;const t=window.devicePixelRatio||1,n=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(t,"number"==typeof e&&e>0?e:n))}(c);if(!function(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),a=Math.round(t[1]*r),s=i/t[0],l=a/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(s,0,0,l,0,0),o.translate(n.left,n.top),o}(t,o,i,e))return;if(N.clearRect(-i.left,-i.top,o[0],o[1]),function(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:a=0,width:s,height:l}=t,c=function(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:r=""}=e;return"transparent"===t||n?null:t||(r&&"transparent"!==r?r:"")||null}({background:n,hasBackgroundGraphics:r,themeBackground:o});if(!c)return!1;const u=gr(e,c);u&&(e.fillStyle=u,e.fillRect(i,a,s,l))}(N,{background:l,hasBackgroundGraphics:d,width:a,height:s}),k&&n.applyDecay(),w&&n.applyPulse(p),S&&n.applyThresholds(p),!1!==x&&n.applyTopologyDiff(p),H&&(N.globalAlpha=M?.dimOpacity??.5),na({context:N,nodes:n.sceneEdges,renderMode:u,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Ka(e,n);break;case"line":Za(e,n);break;case"ribbon":Ja(e,n);break;case"curved":es(e,n)}}(N,e)}),na({context:N,nodes:n.sceneNodes,renderMode:u,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),ki(e,t.style,"#007bff",()=>e.fillRect(t.x,t.y,t.w,t.h)),wi(e,t.style,()=>e.strokeRect(t.x,t.y,t.w,t.h)),ns(e,t),e.restore())}}(N,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(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),ki(e,t.style,"#007bff",()=>e.fill()),wi(e,t.style,()=>e.stroke()),rs(e,t),e.restore())}}(N,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;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(),ki(e,t.style,"#007bff",()=>e.fill()),wi(e,t.style,()=>e.stroke()),e.restore()}}(N,t),function(e,t){const n=e.globalAlpha;for(const r of t)"symbol"===r.type&&is(e,r,r.cx,r.cy,n,"#007bff");e.globalAlpha=n}(N,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&as(e,r,r.cx,r.cy,n);e.globalAlpha=n}(N,t)}}),B&&!H){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,a=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const s=t[r];if(!s.bezier)continue;if(e.countForEdge(r)>=a)continue;const l=s.value*i*n*(s.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(r)<a;t++)e.spawn(r,o)}}(n.particlePool,e,I,A,m);const t=.5*(A.speedMultiplier??1);let r;if(A.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(I,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const l=n[s.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=gr(e,c)||c,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(N,n.particlePool,e,A,C)}}H&&(N.globalAlpha=1)}h.current=!1,(O||D||_)&&t.setAttribute("aria-label",Oi(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const q=O||D||_||L.current;q&&p-T.current>=33?(P(e=>e+1),T.current=p,L.current=!1):L.current=!!q,(v||D||null!=n.transition||_||n.hasActivePulses||n.hasActiveThresholds||!1!==x&&n.hasActiveTopologyDiff||L.current)&&j()}function ls(e,t=30){return Math.max((e??4)+5,12,t)}function cs(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function us(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>ls(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"rect":return function(e,t,n){const r=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=cs(Math.atan2(o,r)),s=cs(e.startAngle),l=cs(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>ls(fi(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=wn(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,l=n-a,c=Math.sqrt(s*s+l*l);return c>ls(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:a,distance:c}}(e,t,n,r);default:return null}}var ds=null,hs=null;function fs(){return hs||((ds=document.createElement("canvas")).width=1,ds.height=1,hs=ds.getContext("2d")),hs}function gs(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function ps(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=gs(e),o=fs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let a=((t-e.x1)*r+(n-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*r,l=e.y1+a*o,c=Math.sqrt((t-s)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=gs(e),o=fs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function ms(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-r.left-o.left,g=n-r.top-o.top;if(0>h||h>i||0>g||g>a)return{kind:"miss-outside"};const p=function(e,t,n,r,o=30,i,a=0){let s=null,l=o,c=1/0;if(i){const e=function(e,t,n,r,o,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,o,l,p,m)=>{if(o>u||c>p||l>h||d>m)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=a(e)-n,u=Math.sqrt(l*l+c*c);ls(s(e),r)>=u&&g>u&&(f=e,g=u),o=o.next}while(o)}return!1}),f?{node:f,distance:g}:null}(i,n,r,o,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=us(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(s=e,c=n)}else l>e.distance&&(s=e,l=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=ps(e,n,r);t&&l>t.distance&&(s=t,l=t.distance)}return s}(s,l,h,g,d,c,u);return p?{kind:"hit",hover:f(p.datum||{},p.x,p.y,{nodeOrEdge:p.type})}:{kind:"miss"}}function ys(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:a}),"focus"===s?.type&&t({type:"focus",datum:n,inputType:"touch"===s.inputType?"pointer":s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"hover-end",timestamp:l,chartType:i,chartId:a}))}function bs(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:a}),"activate"===s?.type&&t({type:"activate",datum:n,inputType:s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"click-end",timestamp:l,chartType:i,chartId:a}))}var vs=require("react"),xs="StreamNetworkFrame",ks=require("react/jsx-runtime"),ws={top:20,right:80,bottom:20,left:80},Ss={top:40,right:40,bottom:40,left:40},Ms=new Set(["chord","force","circlepack","orbit"]),As=[800,600],Cs=(0,d.memo)((0,d.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:h="value",edgeIdAccessor:m,childrenAccessor:y,hierarchySum:b,orientation:v="horizontal",nodeAlign:x="justify",nodePaddingRatio:k=.05,nodeWidth:w=15,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,padAngle:T=.01,groupWidth:P=20,sortGroups:j,edgeSort:E,treeOrientation:N="vertical",edgeType:I="curve",padding:R,paddingTop:D,tensionConfig:_,showParticles:O=!1,particleStyle:$,renderMode:W,nodeStyle:B,edgeStyle:z,colorBy:F,colorScheme:H="category10",edgeColorBy:q="source",edgeOpacity:Y=.5,colorByDepth:X=!1,nodeSize:G=8,nodeSizeRange:V=[5,20],nodeLabel:U,showLabels:Q=!0,labelMode:K,size:Z=As,responsiveWidth:J,responsiveHeight:ee,margin:te,className:ne,background:re,maxDevicePixelRatio:oe,enableHover:ie=!0,tooltipContent:ae,customHoverBehavior:se,customClickBehavior:le,onObservation:ce,annotationObservationCallback:ue,chartId:de,onTopologyChange:he,annotations:fe,onAnnotationActivate:ge,autoPlaceAnnotations:pe,svgAnnotationRules:me,legend:ye,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:ke,legendHighlightedCategory:we,legendIsolatedCategories:Se,title:Me,foregroundGraphics:Ae,backgroundGraphics:Ce,decay:Le,pulse:Te,transition:Pe,animate:je,staleness:Ee,frameScheduler:Ne,clock:Ie,random:Re,seed:De,paused:_e=!1,suspendWhenHidden:Oe=!0,thresholds:We,accessibleTable:Be=!0,description:ze,summary:Fe,orbitMode:He,orbitSize:qe,orbitSpeed:Ye,orbitRevolution:Xe,orbitRevolutionStyle:Ge,orbitEccentricity:Ve,orbitShowRings:Ue,orbitAnimated:Qe,customNetworkLayout:Ke,onLayoutError:Ze,layoutConfig:Je,layoutSelection:et}=e,tt=Ms.has(n)?Ss:ws,nt=(0,d.useRef)(!0),rt=br({sizeProp:Z,responsiveWidth:J,responsiveHeight:ee,userMargin:te,marginDefault:tt,title:Me,legend:ye,legendPosition:be,foregroundGraphics:Ae,backgroundGraphics:Ce,animate:je,transitionProp:Pe,frameScheduler:Ne,clock:Ie,random:Re,seed:De,paused:_e,suspendWhenHidden:Oe,themeDirtyRef:nt}),{reducedMotionRef:ot,responsiveRef:it,size:at,margin:st,adjustedWidth:lt,adjustedHeight:ct,resolvedForeground:ut,resolvedBackground:dt,transition:ht,introEnabled:ft,tableId:gt,rafRef:pt,renderFnRef:mt,scheduleRender:yt,frameRuntime:bt,currentTheme:vt}=rt,xt=function(){const[e,t]=(0,la.useState)(!1);return ca(()=>{t(!0)},[]),e}(),kt=fa(),wt=(0,d.useMemo)(()=>ia(r),[r]),St=(0,d.useMemo)(()=>Array.isArray(o)?ia(o):o,[o]),Mt=(0,d.useMemo)(()=>({...g,..._}),[_]),At=(0,d.useMemo)(()=>({...p,...$}),[$]),Ct=(0,d.useMemo)(()=>{return{chartType:(e={chartType:n,clock:bt.now,random:Re,seed:De,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:m,childrenAccessor:y,hierarchySum:b,orientation:v,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:T,groupWidth:P,sortGroups:j,edgeSort:E,treeOrientation:N,edgeType:I,padding:R,paddingTop:D,tensionConfig:Mt,showParticles:O,particleStyle:At,nodeStyle:B,edgeStyle:z,nodeLabel:U,showLabels:Q,labelMode:K,colorBy:F,colorScheme:H,edgeColorBy:q,edgeOpacity:Y,colorByDepth:X,nodeSize:G,nodeSizeRange:V,decay:Le,pulse:Te,transition:ht,introAnimation:ft,staleness:Ee,thresholds:We,orbitMode:He,orbitSize:qe,orbitSpeed:Ye,orbitRevolution:Xe,orbitRevolutionStyle:Ge,orbitEccentricity:Ve,orbitShowRings:Ue,orbitAnimated:Qe,customNetworkLayout:Ke,onLayoutError:Ze,layoutConfig:Je,currentTheme:vt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Zn(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,bt.now,Re,De,s,l,c,h,m,y,b,v,x,k,w,S,M,T,P,j,E,N,I,R,D,Mt,O,At,B,z,U,Q,K,F,H,q,Y,X,G,V,Le,Te,ht,ft,Ee,We,He,qe,Ye,Xe,Ge,Ve,Ue,Qe,Ke,Ze,Je,vt]),Lt=va(Ct),Tt=va({chartType:(Pt={chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:m,childrenAccessor:y,hierarchySum:b,orientation:v,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:T,groupWidth:P,sortGroups:j,edgeSort:E,treeOrientation:N,edgeType:I,padding:R,paddingTop:D,random:Re,seed:De,tensionConfig:Mt,customNetworkLayout:Ke,orbitMode:He,orbitSize:qe,orbitEccentricity:Ve}).chartType,nodeIDAccessor:Pt.nodeIDAccessor,sourceAccessor:Pt.sourceAccessor,targetAccessor:Pt.targetAccessor,valueAccessor:Pt.valueAccessor,edgeIdAccessor:Pt.edgeIdAccessor,childrenAccessor:Pt.childrenAccessor,hierarchySum:Pt.hierarchySum,orientation:Pt.orientation,nodeAlign:Pt.nodeAlign,nodePaddingRatio:Pt.nodePaddingRatio,nodeWidth:Pt.nodeWidth,iterations:Pt.iterations,forceStrength:Pt.forceStrength,padAngle:Pt.padAngle,groupWidth:Pt.groupWidth,sortGroups:Pt.sortGroups,edgeSort:Pt.edgeSort,treeOrientation:Pt.treeOrientation,edgeType:Pt.edgeType,padding:Pt.padding,paddingTop:Pt.paddingTop,random:Pt.random,seed:Pt.seed,tensionConfig:Pt.tensionConfig,customNetworkLayout:Pt.customNetworkLayout,orbitMode:Pt.orbitMode,orbitSize:Pt.orbitSize,orbitEccentricity:Pt.orbitEccentricity});var Pt;const jt=(0,d.useRef)(0),Et=(0,d.useRef)(0),Nt=(0,d.useRef)(!1),It=(0,d.useRef)(null);It.current||(It.current=new Vt(Lt));const Rt=(0,Ut.useRef)(new tn("StreamNetworkFrame")),Dt=(0,d.useCallback)((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(Rt.current,e,()=>e.buildScene(t),n),[Rt]),[Ot,$t]=(0,d.useState)(null),[Wt,Bt]=(0,d.useState)(0),[zt,Ft]=(0,d.useState)(0),[Ht,qt]=(0,d.useState)(!1),[Yt,Xt]=(0,d.useState)(!1),Gt=(0,d.useRef)(0),Qt=(0,d.useRef)(null),Kt=(0,d.useRef)(!1),Zt=(0,d.useRef)(L);Zt.current=L;const Jt=(0,d.useRef)(Lt);Jt.current=Lt;const en=(0,d.useRef)(null),rn=(0,d.useRef)(new Map),an=(0,d.useRef)(0),sn=(0,d.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:_t;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const a=Array.isArray(r)?r:_t,s=n?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:F,colorScheme:H,nodeColorMap:rn.current,colorIndexRef:an}),[F,H]),ln=(0,d.useCallback)(e=>{an.current=function(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:_t,a=Array.from(n);for(let e=0;a.length>e;e++){const t=a[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return a.length}({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:rn.current,colorScheme:H})},[H]),cn=(0,d.useCallback)((e,t)=>{Dt(e,t),ln(e),nt.current=!1,e.markStylePaintPending()},[Dt,ln]),un=(0,d.useCallback)(()=>{It.current?.markStylePaintPending()},[]),dn=(gn=vt,gn?.colors?.border||gn?.colors?.secondary||gn?.colors?.primary||"#999");var gn;const pn=(0,d.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,It.current?.nodes),[]),mn=(0,d.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const a=o(t.source),s=o(t.target);return"target"===n&&s?r(s):a?r(a):i}({edge:e,edgeColorBy:q,getNodeColor:sn,resolveEndpoint:pn,fallback:dn}),[q,sn,dn,pn]),yn=(0,d.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:l}=e;if("function"==typeof n){const e=s(t.source);return e?n(t,e):l}if(!o)return i(t);const c=r,u=s(t.source),d=s(t.target);return"target"===c&&d?a(d):u?a(u):l}({edge:e,particleStyleColor:At.color,particleColorBy:At.colorBy,hasExplicitParticleColorBy:!!$?.colorBy,getEdgeColor:mn,getNodeColor:sn,resolveEndpoint:pn,fallback:dn}),[$?.colorBy,At.color,At.colorBy,sn,mn,dn,pn]),bn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ke,O,!!Te,It.current?.isAnimating??!1);!function(e,t,n,r){(0,fn.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}(It,Lt,nt,yt),function(e,t,n,r){const o=(0,fn.useRef)(null);(0,fn.useEffect)(()=>{const i=e.current;if(!i)return;const a=t??null;o.current!==a&&(o.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):n.current=!0,r())},[t,r,e,n])}(It,et,nt,yt),(0,d.useEffect)(()=>{const e=It.current;e&&(cn(e,[lt,ct]),Bt(e=>e+1),yt())},[vt,lt,ct,cn,yt]);const vn=(0,d.useCallback)(()=>{const e=It.current;if(e&&(e.runLayout([lt,ct]),cn(e,[lt,ct]),Bt(e.layoutVersion),he)){const{nodes:t,edges:n}=e.getLayoutData();he(t,n)}},[lt,ct,cn,he]),xn=(0,d.useRef)(!1),kn=(0,d.useCallback)((e=!1)=>!(!e&&!xn.current||(xn.current=!1,vn(),0)),[vn]),Sn=(0,d.useCallback)(()=>kn(!1),[kn]),An=(0,d.useCallback)(e=>{const t=It.current;if(!t)return!1;let n=!1,r=xn.current;for(const o of e)null!=o&&"object"==typeof o&&(n=!0,t.ingestEdge(o)&&(r=!0));const o=kn(r);return n||o},[kn]),Ln=(0,d.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=It.current;t&&(t.ingestEdge(e)&&(xn.current=!0),bt.isActive?yt():Sn())},[Sn,bt,yt]),Tn=(0,d.useCallback)(e=>{An(e)&&yt()},[An,yt]);(0,d.useEffect)(()=>bt.subscribe(()=>{bt.isActive||Sn()}),[Sn,bt]);const jn=(0,d.useCallback)(()=>{xn.current=!1,It.current?.clear(),rn.current.clear(),an.current=0,Bt(It.current?.layoutVersion??0),$t(null),en.current=null,nt.current=!0,yt()},[yt]),En=(0,d.useCallback)(()=>{const e=It.current;e&&(e.tension+=999,kn(!0),yt())},[kn,yt]);(0,d.useImperativeHandle)(t,()=>({push:Ln,pushMany:Tn,removeNode:e=>{const t=It.current?.removeNode(e)??!1;if(t){const t=en.current?.data?"function"==typeof s?s(en.current.data):en.current.data[s]:void 0;en.current&&"node"===en.current.nodeOrEdge&&t===e&&(en.current=null,$t(null)),rn.current.delete(e)}return kn(t)&&(nt.current=!0,yt()),t},removeEdge:(e,t)=>{const n=It.current?.removeEdge(e,t)??!1;if(n&&en.current&&"edge"===en.current.nodeOrEdge){const n=en.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!m||!n||("function"==typeof m?m:e=>e?.[m])(n)===e,r&&(en.current=null,$t(null))}return kn(n)&&(nt.current=!0,yt()),n},updateNode:(e,t)=>{const n=It.current?.updateNode(e,t)??null;return kn(null!==n)&&(nt.current=!0,yt()),n},updateEdge:(e,t,n)=>{const r=It.current?.updateEdge(e,t,n)??[];return kn(r.length>0)&&(nt.current=!0,yt()),r},clear:jn,getTopology:()=>(Sn(),It.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(Sn(),It.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(Sn(),It.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{Sn();const e=It.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:En,getTension:()=>(Sn(),It.current?.tension??0)}),[Ln,Tn,jn,En,Sn,kn,s,yt,m]);const Nn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),In=Nn?i||(Array.isArray(o)?void 0:o):void 0;(0,d.useEffect)(()=>{const e=It.current;if(!e)return;const t=++Gt.current;if(Qt.current?.abort(),Qt.current=null,Nn&&In)xn.current=!1,e.ingestHierarchy(In,[lt,ct]),cn(e,[lt,ct]),Bt(e.layoutVersion),Xt(!1),Zt.current?.("ready"),yt();else{const i=wt,a=Array.isArray(St)?St:[];if(null==r&&null==o||(xn.current=!1),0===i.length&&0===a.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||jn(),Xt(!1),void Zt.current?.("ready");const s=[lt,ct],l="force"===n&&!Ke&&Ha()&&!Re&&Fa(A,i.length,a.length,S);if(l&&kt&&!Kt.current&&e.sceneNodes.length>0)return Kt.current=!0,Xt(!1),Zt.current?.("ready"),nt.current=!0,void yt();if(l){const n=new AbortController;Qt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,a,s,{deferLayout:!0});const o=e.getLayoutData(),l=function(e,t,n,r,o){const i=$e(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Jt.current,s,r);return Xt(!0),Zt.current?.("pending"),Xa(l,n.signal).then(({positions:n})=>{t===Gt.current&&(e.applyForceLayoutPositions(n,s),cn(e,s),Xt(!1),Zt.current?.("ready"),Bt(e.layoutVersion),yt())}).catch(n=>{"AbortError"!==n.name&&t===Gt.current&&(e.runLayout(s),cn(e,s),Xt(!1),Zt.current?.("error"),Bt(e.layoutVersion),yt())}),()=>n.abort()}e.ingestBounded(i,a,s),cn(e,s),Bt(e.layoutVersion),Xt(!1),Zt.current?.("ready"),yt()}},[wt,St,r,o,i,In,Nn,lt,ct,Tt,A,S,kt,n,Ke,Re,yt,jn,cn]);const Rn=u.useRef(!1);(0,d.useEffect)(()=>{Rn.current||a&&a.length>0&&(Rn.current=!0,Tn(a))},[a,Tn]);const{customHoverBehavior:Dn,customClickBehavior:_n}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:(0,vs.useCallback)((t,o)=>{e?.(t,o),ys({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:xs,chartId:r,context:o})},[e,n,r]),customClickBehavior:(0,vs.useCallback)((e,o)=>{t?.(e,o),bs({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:xs,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:se,customClickBehavior:le,onObservation:ce,chartId:de}),{hoverHandlerRef:On,hoverLeaveRef:$n,onPointerMove:Wn,onPointerLeave:Bn}=rt,zn=()=>!Ke||(It.current?.hasCustomRestyle??!1);On.current=e=>{if(!ie)return;const t=zn(),n=Qn.current;if(!n)return;const r=It.current;if(!r)return;const o=ms({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:st,adjustedWidth:lt,adjustedHeight:ct,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(en.current=o.hover,$t(o.hover),Dn?.(o.hover),t&&yt()):en.current&&(en.current=null,$t(null),Dn?.(null),t&&yt())},$n.current=()=>{if(en.current){const e=zn();en.current=null,$t(null),Dn?.(null),e&&yt()}};const Fn=(0,d.useRef)(()=>{});Fn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!le&&!ce)return;const n=Qn.current;if(!n)return;const r=It.current;if(!r)return;const o=ms({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:st,adjustedWidth:lt,adjustedHeight:ct,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});var i;"hit"===o.kind?_n(o.hover,{type:"activate",inputType:(i=e.nativeEvent.pointerType,"touch"===i?"touch":"pointer")}):"miss"===o.kind&&_n(null)};const Hn=(0,d.useCallback)(e=>Fn.current(e),[]),Yn=(0,d.useRef)(-1),Xn=(0,d.useRef)(null),Gn=(0,d.useRef)(-1),Vn=(0,d.useCallback)(e=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(e))return;const t=It.current;if(!t)return;const n=()=>{Yn.current=-1,Xn.current=null,Gn.current=-1,en.current=null,$t(null),Dn?.(null),yt()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=wn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Yn.current||n());const o=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}(r);let i=Yn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void _n?.(f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Yn.current=0,Gn.current=-1;const t=o.flat[0];Xn.current={shape:t.shape,w:t.w,h:t.h};const n=f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return en.current=n,$t(n),Dn?.(n,{type:"focus",inputType:"keyboard"}),void yt()}const a=function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}(o,i),s=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Mn(e,t,n);const a=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==a)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=Cn(t.source),i=Cn(t.target),a=null!=o,s=null!=i;a&&o+""===n&&s?r.push(i+""):s&&i+""===n&&a&&r.push(o+"")}return r}(a,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Mn(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,a,o,t.sceneEdges??[],Gn);if(null===s)return;if(e.preventDefault(),0>s)return void n();Yn.current=s;const l=o.flat[s];Xn.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};en.current=c,$t(c),Dn?.(c,{type:"focus",inputType:"keyboard"}),yt()},[_n,Dn,yt]),Un=(0,d.useCallback)(e=>{Yn.current=-1,Xn.current=null,Wn(e)},[Wn]);mt.current=()=>{if(pt.current=null,Sn(),!bt.isActive)return;const e=Qn.current;if(!e)return;const t=It.current;t&&ss({canvas:e,store:t,sceneRevisionDiagnostics:Rt.current,size:at,margin:st,adjustedWidth:lt,adjustedHeight:ct,background:re,maxDevicePixelRatio:oe,renderMode:W,hasBackgroundGraphics:!!Ce,dirtyRef:nt,resolutionDirtyRef:Kn,lastFrameTimeRef:jt,now:bt.now(),random:bt.random,reducedMotion:!!ot.current,showParticles:O,isContinuous:bn,animate:je,decay:Le,pulse:Te,thresholds:We,staleness:Ee,particleStyle:At,getParticleColor:yn,pendingAnnotationFrameRef:Nt,lastAnnotationFrameTimeRef:Et,setAnnotationFrame:Ft,scheduleNextFrame:()=>{yt()},syncColorMap:()=>ln(t)})};const{canvasRef:Qn,resolutionDirtyRef:Kn}=function(e,t){return ma({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(rt,{hydrated:xt,wasHydratingFromSSR:kt,storeRef:It,dirtyRef:nt,skipInitialCanvasPaintInvalidation:!0,canvasPaintInvalidator:un,maxDevicePixelRatio:oe,canvasPaintDependencies:[n,lt,ct,re,Ce,W,yt]});!function(e,t,n,r,o,i){const a=(0,vr.useRef)("fresh");(0,vr.useEffect)(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){if(!e||0>=t)return kr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...xr,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:kr}(e,l-s.lastIngestTime);c.band===a.current&&c.isStale===o||(a.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(s)},[e,o,r,t,i,n])}(Ee,It,nt,yt,Ht,qt);const Jn=ie&&Ot?(0,ks.jsx)(qn,{x:Ot.x,y:Ot.y,containerWidth:lt,containerHeight:ct,margin:st,className:"stream-network-tooltip",zIndex:2,children:ae?ae(Ot):(0,ks.jsx)(Ua,{data:Ot})}):null;if(Pi||!xt&&kt)return(0,ks.jsx)(sa,{props:e,store:It.current,responsiveRef:it,size:at,margin:st,adjustedWidth:lt,adjustedHeight:ct,resolvedBackground:dt,resolvedForeground:ut});const er=It.current;return(0,ks.jsxs)("div",{ref:it,className:"stream-network-frame"+(ne?" "+ne:""),role:"group","aria-label":ze||("string"==typeof Me?Me:"Network chart"),tabIndex:0,"aria-busy":Yt||void 0,style:{position:"relative",width:J?"100%":at[0],height:ee?"100%":at[1],overflow:"visible"},onKeyDown:Vn,children:["production"!==process.env.NODE_ENV&&It.current&&(0,ks.jsx)(nn,{store:It.current,diagnostics:Rt.current}),Be&&(0,ks.jsx)(Zi,{tableId:gt}),Be&&(0,ks.jsx)(Qi,{nodes:er?.sceneNodes??[],edges:er?.sceneEdges??[],chartType:"Network chart",tableId:gt,chartTitle:"string"==typeof Me?Me:void 0}),(0,ks.jsx)(Ki,{summary:Fe}),(0,ks.jsx)(Di,{hoverPoint:Ot}),(0,ks.jsxs)("div",{role:"img","aria-label":ze||("string"==typeof Me?Me:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ie?Un:void 0,onMouseLeave:ie?Bn:void 0,onClick:le||ce?Hn:void 0,children:[Yt&&!1!==C&&(0,ks.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Ia(!0,at[0],at[1],C)}),(0,ks.jsx)(ya,{size:at,margin:st,overflowVisible:!0,children:dt}),(0,ks.jsx)("canvas",{ref:Qn,"aria-label":Oi(er?.sceneNodes?.length??0,er?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,ks.jsx)(pi,{width:lt,height:ct,totalWidth:at[0],totalHeight:at[1],margin:st,labels:er?.labels||[],sceneNodes:er?.sceneNodes,title:Me,legend:ye,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:ke,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:on(ut,hn(It.current?.customLayoutOverlays,et??null)),annotations:fe,onAnnotationActivate:ge,onObservation:ue??ce,chartId:de,chartType:"StreamNetworkFrame",autoPlaceAnnotations:pe,svgAnnotationRules:me,annotationFrame:zt}),(0,ks.jsx)(vi,{marks:er?.customLayoutHtmlMarks,margin:st,selection:et??null}),(0,ks.jsx)(Pn,{active:Yn.current>=0,hoverPoint:Ot,margin:st,size:at,shape:Xn.current?.shape,width:Xn.current?.w,height:Xn.current?.h}),Jn,Ee?.showBadge&&(0,ks.jsx)(Sr,{isStale:Ht,position:Ee.badgePosition})]})]})}));Cs.displayName="StreamNetworkFrame";var Ls=Cs,Ts=require("react");function Ps(e,t){const{variant:n,frameRef:r,overrides:o}=t,i=(0,Ts.useRef)(o);i.current=o,(0,Ts.useImperativeHandle)(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,n)=>e.current?.update(t,n)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const n=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],o=[];for(const t of n){const n=r.find(e=>e.id===t);n&&o.push({...n.data??{},id:t}),e.current?.removeNode(t)}return o},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,n);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,n)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(n(t));return r},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const r=n.current?.removeLine(e)??[];for(const e of r)n.current?.pushLine(t(e));return r},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,r);return new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}var js=require("react"),Es=require("react"),Ns=require("react"),Is=(require("react/jsx-runtime"),(0,Ns.createContext)(null)),Rs=.5,Ds=require("react");function _s(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Os(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function $s(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Ws,Bs]=Un(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!$s(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),a=Os(i,t),s=new Map(a.clauses);return s.set(n.clientId,n),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Os(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),zs=(require("react"),{positions:new Map}),Fs=new Set;function Hs(){for(const e of Fs)e()}function qs(e,t){const n=zs.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(zs.positions);r.delete(e),zs={positions:r},Hs()}function Ys(e,t){const n=zs.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(zs.positions);r.delete(e),zs={positions:r},Hs()}function Xs(e){const t=(0,Ds.useId)(),n=e.clientId||t,{name:r}=e,o=Bs(e=>e.selections.get(r)),i=Bs(e=>e.setClause),a=Bs(e=>e.clearClause),s=(0,Ds.useMemo)(()=>!!o&&o.clauses.size>0,[o]);return{predicate:(0,Ds.useMemo)(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(_s(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:s,selectPoints:(0,Ds.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:(0,Ds.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:(0,Ds.useCallback)(()=>{a(r,n)},[a,r,n]),clientId:n}}var Gs=l(require("react"));function Vs(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Us(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function Qs(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>Us(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])Vs(e[r])&&Vs(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}require("react/jsx-runtime"),Gs.createContext(void 0);var Ks=44,Zs={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Ks,snap:"nearestDatum",brushHandleSize:Ks,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Js(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!i)return Zs;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??Ks,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??Ks,standardControls:s.standardControls??!1}}var el={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}},tl={top:10,bottom:10,left:10,right:10};function nl(e){return e.compactMode?e.marginDefaults:tl}function rl(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function ol(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function il(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function al(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var sl=require("react"),ll=require("react"),cl=(require("react/jsx-runtime"),(0,ll.createContext)(!1));(0,ll.createContext)(!1);var ul=(0,ll.createContext)(null),dl="undefined"==typeof window?ll.useEffect:ll.useLayoutEffect;function hl(e,t){if(!t)return[];const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)}function fl({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s,additionalLegend:l,chartWidth:c,legendLayout:u,hasTitle:d=!1,axisChrome:h}){const f=(0,ll.useContext)(cl),g=null!==(0,ll.useContext)(ul),p=void 0!==r?r:!f&&!!t,m=!!t&&(p||g),y=(0,sl.useMemo)(()=>m?void 0!==s?s:hl(e,t):[],[s,t,e,m]);!function(e){const t=(0,ll.useContext)(ul),n=(0,ll.useId)(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=(0,ll.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(o.current,r)||(o.current=r);const i=o.current;dl(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),dl(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(g&&t?y:[]);const b=(0,sl.useMemo)(()=>{if(!p||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?r(a,t,n):n?n(o):Wt[i%Wt.length];return{label:o+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Ft,categories:y});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[p,t,e,n,y]),v=(0,sl.useMemo)(()=>function(...e){let t;for(const n of e)n&&(t=Cr(t)&&Cr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups],legendDistance:n.legendDistance??t.legendDistance}:n);return t}(b,l),[b,l]),{hasAxis:x,hasAxisLabel:k,rotatedTicks:w}=h??{},S=(0,sl.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];if(v){const e=function(e,t){return Dr(e,t)+_r(e)+Or(t)}(v,u),t=void 0===x?{hasAxis:!0,hasAxisLabel:!0}:{hasAxis:x,hasAxisLabel:k,rotatedTicks:w},i=Fr(v,Math.max(1,(c??600)-n.left-n.right),u)+_r(v)+zr("bottom"===o?t:void 0,u)+("top"===o&&d?24:0);"right"===o&&!r("right")&&e>n.right?n.right=e:"left"===o&&!r("left")&&e>n.left?n.left=e:"top"!==o||r("top")?"bottom"!==o||r("bottom")||(n.bottom=Math.max(n.bottom,80,i)):n.top=Math.max(n.top,50,i)}return n},[a,i,v,o,c,u,d,x,k,w]);return{legend:v,margin:S,legendPosition:o}}var gl=[];function pl(){const e=ar(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function ml(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=Ht(n,r);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=Dt[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:Ot}function yl({selection:e,linkedHover:t,fallbackFields:n=gl,unwrapData:r=!1,onObservation:o,chartType:i,chartId:a,onClick:s,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=(0,Es.useId)(),h=(0,Es.useMemo)(()=>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||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,Es.useMemo)(()=>"series"===h?.mode?[h.seriesField||c||n[0]].filter(e=>!!e):h?.fields||n,[h,c,n]),g=Xs({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:a}=Xs({name:t,fields:n});return{onHover:(0,Ds.useCallback)(e=>{if(!e)return void a();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Kn(t)&&i(t)},[n,i,a]),predicate:r,isActive:o}}({name:h?.name||"hover",fields:f}),m=Po(e=>e.pushObservation),y=(0,Es.useCallback)(e=>{o?.(e),m?.(e)},[o,m]),b=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,x]=(0,Es.useState)(null),k=(0,Es.useRef)(!1),w=c||n[0],S=(0,Es.useMemo)(()=>{if(!l||null==v||!w)return null;const e=v,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,v,w]),M=(0,Es.useCallback)((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=ol(e,t,h.xField);null!=n&&function(e,t,n){const r=zs.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(zs={positions:new Map(zs.positions).set(e,{xValue:t,sourceId:n})},Hs())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&p.onHover(t)}else"x-position"!==h?.mode||r||qs(h.name||"hover",d),"x-position"===h?.mode||r||p.onHover(null);if(l&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];x(null!=n?n+"":null)}else r||x(null);(o||m)&&ys({onObservation:y,datum:e?il(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:a,context:n})},[t,p,h,d,o,i,a,m,y,l,w,u]),A=(0,Es.useCallback)((n=!0)=>{k.current=!1,t&&"x-position"!==h?.mode&&p.onHover(null),e&&u?.tapToSelect&&g.clear(),n&&l&&x(null),"x-position"===h?.mode&&(Ys(h.name||"hover",d),qs(h.name||"hover",d))},[t,h,p,e,u,g,l,d]),C=(0,Es.useCallback)((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),b=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=ol(n,e,h.xField);null!=t&&function(e,t,n){const r=zs.positions.get(e);if(r?.locked){const t=new Map(zs.positions);return t.delete(e),zs={positions:t},Hs(),!1}zs={positions:new Map(zs.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Hs()}(h.name||"hover",t,d)}if(c)if(n){k.current=!0;const r=il(n);if(t&&"x-position"!==h?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}al(e)&&g.selectPoints(e)}if(l&&w){const e=r?.[w];x(null!=e?e+"":null)}}else b&&A();if(n||b){if(n&&s){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),s(e,{x:n.x??0,y:n.y??0})}(o||m)&&bs({onObservation:y,datum:n?il(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:a,context:r})}},[s,o,m,y,i,a,h,d,u,t,p,e,g,f,l,w,A]);return(0,Es.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,Es.useEffect)(()=>()=>{k.current&&A(!1)},[A]),(0,Es.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Ys(e,d),qs(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:d}}function bl(e,t,n){return function(e,t,n){const r=el[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,a=Qs({...t,mode:e},{width:t.width??o,height:t.height??i}).props,s=a.mode||e||"primary",l=el[s],c="context"===s||"sparkline"===s,u="primary"===s&&n?.width?n.width:l.width;return{mode:s,width:a.width??u,height:a.height??("primary"===s&&n?.height?n.height:l.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:rl(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:Js(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}(e,t,n)}var vl=require("react");function xl(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function kl(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function wl(e){return"function"==typeof e?e:t=>t[e]||1}function Sl({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return a=>{const s={fillOpacity:o,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=Ft(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ft(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function Ml(e){const{nodes:t,edges:n,inferNodes:r=!0,sourceAccessor:o="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:l,legendPosition:c,legendInteraction:u,selection:d,linkedHover:h,onObservation:f,onClick:g,mobileInteraction:p,mobileSemantics:m,chartType:y,chartId:b,marginDefaults:v,userMargin:x,width:k,height:w,hasTitle:S,loading:M,loadingContent:A,emptyContent:C,emptyDataKey:L="edges"}=e,T=(0,vl.useMemo)(()=>ia(n),[n]),P=(0,vl.useMemo)(()=>ia(t),[t]),j=Ia(M,k,w,A),E=j?null:Na("nodes"===L?void 0===t?void 0:P:void 0===n?void 0:T,k,w,C),N=(0,vl.useMemo)(()=>r?kl(P,T,o,i):P,[r,P,T,o,i]),I=function(e,t,n){const r=(0,Ns.useContext)(Is),o=pl();return(0,Es.useMemo)(()=>{if(!t)return;const i=r??void 0,a=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&al(i)){const e=qt(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return qt(n.map(e=>({_cat:e})),"_cat",a)}if(i&&al(i)){const n=qt(e,t,a);return e=>i[e]||n(e)}return qt(e,t,a)}if(i&&al(i)){const e=qt([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,r,o])}(N,a,s),R=pl(),D=(0,vl.useMemo)(()=>Array.isArray(s)&&s.length>0?s:[...$t(s,R,_t)],[s,R]),_=(0,vl.useMemo)(()=>hl(N,a),[N,a]),O=function(e,t,n){const[r,o]=(0,sl.useState)(null),[i,a]=(0,sl.useState)(new Set),s=(0,sl.useMemo)(()=>new Set,[]),l=(0,sl.useCallback)(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=(0,sl.useCallback)(t=>{"isolate"===e&&a(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),u=(0,sl.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return("string"==typeof o?o:(o??"")+"")===r}}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has("string"==typeof r?r:(r??"")+"")}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(u,a,_),{legend:$,margin:W,legendPosition:B}=fl({data:N,colorBy:a,colorScale:I,showLegend:l,legendPosition:c,userMargin:x,defaults:v,categories:_,chartWidth:k,hasTitle:S}),z=(0,vl.useMemo)(()=>Js(p,{width:k,mobileSemantics:m}),[p,k,m]),F=yl({selection:d,linkedHover:h,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:g,mobileInteraction:z,chartType:y,chartId:b}),{customHoverBehavior:H,customClickBehavior:q,activeSelectionHook:Y,hoverSelectionHook:X,crosshairSourceId:G}=F;return{safeNodes:N,safeEdges:T,colorScale:I,effectivePalette:D,themeCategorical:R,allCategories:_,legendState:O,legend:$,margin:W,legendPosition:B,mobileInteraction:z,customHoverBehavior:H,customClickBehavior:q,activeSelectionHook:Y,hoverSelectionHook:X,crosshairSourceId:G,loadingEl:j,emptyEl:E}}function Al(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function Cl(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Tl(t(e))}function Ll(e,t){const n=Cl(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=r?r(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Tl(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function Pl(e,t,n){const r=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&r!==e.eq)return!1;if(void 0!==e.ne&&r===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(r))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=Tl(r);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>o||o>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(o>=t&&n>=o)return!1}return!0}function jl(e,t,n){const r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,n):Pl(r,t,n))}function El(e,t,n){if(!t||0===t.length)return{};let r={};for(const o of t){if(!jl(o,e,n))continue;const t="function"==typeof o.style?o.style(e,n):o.style;t&&(r={...r,...t})}return r}function Nl(e,t,n,r=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const a=r(e),s={...o(e,i)};return Object.assign(s,El(a,t,n(a,i))),s}:o}function Il(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let a=1;r>=a;a++){const r=o[a];o[a]=e[i-1]===t[a-1]?n:1+Math.min(n,o[a],o[a-1]),n=r}}return o[r]}function Rl(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(function(e,t,n=3){let r,o=n+1;for(const n of t){const t=Il(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3)??null)}function Dl(e){return` Or use a function: ${e}={d => d.myValue}.`}function _l({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Ol({componentName:e,nodes:t,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==n)return null;if(o&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:[...a]).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=Rl(o,t),i=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`+Dl(r)}}}var a;return null}function $l(e){const{title:t,description:n,summary:r,accessibleTable:o,className:i,animate:a,maxDevicePixelRatio:s,axisExtent:l,autoPlaceAnnotations:c}=e,u={};return t&&(u.title=t),n&&(u.description=n),r&&(u.summary=r),void 0!==o&&(u.accessibleTable=o),i&&(u.className=i),null!=a&&(u.animate=a),void 0!==s&&(u.maxDevicePixelRatio=s),void 0!==l&&(u.axisExtent=l),void 0!==c&&(u.autoPlaceAnnotations=c),u}function Wl(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};r&&(f.annotationObservationCallback=r);const g=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(s||t||r||o||a)&&(f.customHoverBehavior=u),d&&(l||(h?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||a||n))&&(f.customClickBehavior=d),null!=g&&(f.hoverRadius=g),f}var Bl=require("react/jsx-runtime"),zl=(0,js.forwardRef)(function(e,t){const n=(0,js.useRef)(null);Ps(t,{variant:"network",frameRef:n});const r=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:s,nodeIdAccessor:l,nodeIDAccessor:c,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:g,styleRules:p,nodeSize:m=8,nodeSizeRange:y=[5,20],nodeStroke:b,nodeStrokeWidth:v,edgeWidth:x,edgeColor:k,edgeOpacity:w,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,tooltip:T,frameProps:P={},onObservation:j,onClick:E,chartId:N,selection:I,linkedHover:R,loading:D,loadingContent:_,emptyContent:O,legendInteraction:$,legendPosition:W,stroke:B,strokeWidth:z,opacity:F}=e,H=l??c??"id",{width:q,height:Y,enableHover:X,showLegend:G,showLabels:V=!1,title:U,description:Q,summary:K,accessibleTable:Z}=r,J=Ml({nodes:o,edges:i,inferNodes:!1,nodeIdAccessor:H,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:g,showLegend:G,legendPosition:W,legendInteraction:$,selection:I,linkedHover:R,onObservation:j,onClick:E,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ForceDirectedGraph",chartId:N,marginDefaults:r.marginDefaults,userMargin:a,width:q,height:Y,hasTitle:!!U,loading:D,loadingContent:_,emptyContent:O,emptyDataKey:"nodes"}),ee=(0,js.useMemo)(()=>new Map,[]),te=(0,js.useMemo)(()=>e=>{const t={};return t.fill=f?Ft(e.data||e,f,J.colorScale):ml(void 0,J.themeCategorical,g,void 0,ee),"number"==typeof m&&(t.r=m),t},[f,J.colorScale,m,J.themeCategorical,g,ee]),ne=(0,js.useMemo)(()=>Ll(f,"number"==typeof m?void 0:m),[f,m]),re=(0,js.useMemo)(()=>Al(Nl(te,p,ne,e=>e.data||e),{stroke:b??B,strokeWidth:v??z,opacity:F}),[te,p,ne,b,B,v,z,F]),oe=k??B??"#999",ie=w??F??.6,ae=z??1,se=(0,js.useMemo)(()=>e=>{const t=e.data||e;let n;if(void 0===x)n=ae;else if("number"==typeof x)n=x;else if("function"==typeof x)n=x(t);else{const e=t[x],r="number"==typeof e?e:Number(e);n=Number.isFinite(r)&&r>0?r:ae}return{stroke:oe,strokeWidth:n,opacity:ie}},[x,oe,ie,ae]),le=(0,js.useMemo)(()=>{if(V&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[V,h]),ce=Ol({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:H}});return ce?(0,Bl.jsx)(Aa,{componentName:"ForceDirectedGraph",message:ce,width:q,height:Y}):J.loadingEl?J.loadingEl:J.emptyEl?J.emptyEl:(0,Bl.jsx)(Pa,{componentName:"ForceDirectedGraph",width:q,height:Y,children:(0,Bl.jsx)(Ls,{ref:n,chartType:"force",...null!=o&&{nodes:J.safeNodes},...null!=i&&{edges:J.safeEdges},size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:J.margin,nodeIDAccessor:H,sourceAccessor:u,targetAccessor:d,iterations:S,forceStrength:M,layoutExecution:A,layoutLoadingContent:C,onLayoutStateChange:L,nodeStyle:re,edgeStyle:se,colorBy:f,colorScheme:J.effectivePalette,nodeSize:m,nodeSizeRange:y,nodeLabel:le,showLabels:V,enableHover:X,tooltipContent:!1===T?()=>null:Fn(T)||void 0,...Wl({linkedHover:R,selection:I,onObservation:j,onClick:E,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:J.legend,legendPosition:J.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:J.legendState.onLegendHover,legendClickBehavior:J.legendState.onLegendClick,legendHighlightedCategory:J.legendState.highlightedCategory,legendIsolatedCategories:J.legendState.isolatedCategories},className:s,title:U,description:Q,summary:K,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...P})})});zl.displayName="ForceDirectedGraph";var Fl=require("react"),Hl=require("d3-force"),ql=1e3;function Yl(e,t,n={}){const r=n.iterations??260,o=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,l=n.damping??.84,c=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=function(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const g=ql/2,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),m=new Set(e.map(e=>e.id)),y=t.filter(e=>m.has(e.source)&&m.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,Hl.forceSimulation)(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,Hl.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",(0,Hl.forceCollide)(e=>(e=>"function"==typeof c?c(e.data):c)(e)+u).strength(.9).iterations(2)).force("center",(0,Hl.forceCenter)(g,g).strength(.8)).force("x",(0,Hl.forceX)(g).strength(s)).force("y",(0,Hl.forceY)(g).strength(s));y.length>0&&e.force("link",(0,Hl.forceLink)(y).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/n})),e.stop();for(let t=0;r>t;t+=1)e.tick()}let b=1/0,v=1/0,x=-1/0,k=-1/0;for(const e of p){const t=e.x??g,n=e.y??g;b>t&&(b=t),v>n&&(v=n),t>x&&(x=t),n>k&&(k=n)}const w=x-b,S=k-v,M={};for(const e of p)M[e.id]={x:0===w?.5:d+((e.x??g)-b)/w*(1-2*d),y:0===S?.5:d+((e.y??g)-v)/S*(1-2*d)};return M}var Xl=16,Gl=new WeakMap;function Vl(e){const t=[];for(const n of Object.keys(e).sort()){const r=e[n];if(void 0!==r){if("function"==typeof r)return null;t.push(`${n}:${r+""}`)}}return t.join("|")}function Ul(e,t,n){return null==n?null:Gl.get(e)?.get(t)?.get(n)??null}function Ql(e,t,n,r){if(null==n)return;let o=Gl.get(e);o||(o=new WeakMap,Gl.set(e,o));let i=o.get(t);if(i||(i=new Map,o.set(t,i)),!i.has(n)&&i.size>=Xl){const e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(n,r)}function Kl(e,t,n={}){const r=fa(),{seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:p}=n,m=(0,Fl.useMemo)(()=>({seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:p}),[o,i,a,s,l,c,u,d,h,f,g,p]),y=(0,Fl.useRef)(r),[b,v]=(0,Fl.useState)(()=>{if("undefined"==typeof window||r){const n=Yl(e,t,m);return Ql(e,t,Vl(m),n),{positions:n,status:"ready",error:null}}const n=Ul(e,t,Vl(m));return n?{positions:n,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return(0,Fl.useEffect)(()=>{if(y.current)return void(y.current=!1);const n=Vl(m),r=Ul(e,t,n);if(r)return void v(e=>"ready"===e.status&&e.positions===r?e:{positions:r,status:"ready",error:null});const o=new AbortController;return v(e=>({positions:e.positions,status:"pending",error:null})),async function(e,t,n={}){const{execution:r="auto",signal:o,workerThreshold:i,nodeRadius:a,...s}=n,l=s.iterations??260;if(!Ha()||!Fa(r,e.length,t.length,l,i))return Yl(e,t,{...s,nodeRadius:a});const c={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:s,nodeRadii:"function"==typeof a?Object.fromEntries(e.map(e=>[e.id,a(e)])):null==a?void 0:Object.fromEntries(e.map(e=>[e.id,a]))};try{return(await Xa(c,o)).positions}catch(n){if("AbortError"===n?.name)throw n;return Yl(e,t,{...s,nodeRadius:a})}}(e,t,{...m,signal:o.signal}).then(r=>{Ql(e,t,n,r),v({positions:r,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&v(t=>({positions:t.positions,status:"error",error:e}))}),()=>o.abort()},[e,t,m]),b}var Zl=require("react"),Jl=require("react/jsx-runtime"),ec=(0,Zl.forwardRef)(function(e,t){const n=(0,Zl.useRef)(null);Ps(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:p="source",orientation:m="horizontal",nodeAlign:y="justify",nodePaddingRatio:b=.05,nodeWidth:v=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:S,frameProps:M={},onObservation:A,onClick:C,chartId:L,selection:T,linkedHover:P,loading:j,loadingContent:E,emptyContent:N,showLegend:I,legendPosition:R,legendInteraction:D,stroke:_,strokeWidth:O,opacity:$}=e,{width:W,height:B,enableHover:z,showLabels:F=!0,title:H,description:q,summary:Y,accessibleTable:X}=r,G=Ml({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:I,legendPosition:R,legendInteraction:D,selection:T,linkedHover:P,onObservation:A,onClick:C,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SankeyDiagram",chartId:L,marginDefaults:r.marginDefaults,userMargin:a,width:W,height:B,hasTitle:!!H,loading:j,loadingContent:E,emptyContent:N}),V=(0,Zl.useMemo)(()=>new Map,[]),U=(0,Zl.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Ft(e.data||e,h,G.colorScale):ml(void 0,G.themeCategorical,f,void 0,V),t},[h,G.colorScale,G.themeCategorical,f,V]),Q=(0,Zl.useMemo)(()=>Ll(h,u),[h,u]),K=(0,Zl.useMemo)(()=>Al(Nl(U,g,Q,e=>e.data||e),{stroke:_,strokeWidth:O,opacity:$}),[U,g,Q,_,O,$]),Z=(0,Zl.useMemo)(()=>Sl({edgeColorBy:p,colorBy:h,colorScale:G.colorScale,nodeStyleFn:K,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[p,h,G.colorScale,K,k]),J=(0,Zl.useMemo)(()=>Al(Z,{stroke:_,strokeWidth:O,opacity:$}),[Z,_,O,$]),ee=(0,Zl.useMemo)(()=>{if(!F)return;const e=x||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[F,x,d]),te=Ol({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?(0,Jl.jsx)(Aa,{componentName:"SankeyDiagram",message:te,width:W,height:B}):G.loadingEl?G.loadingEl:G.emptyEl?G.emptyEl:(0,Jl.jsx)(Pa,{componentName:"SankeyDiagram",width:W,height:B,children:(0,Jl.jsx)(Ls,{ref:n,chartType:"sankey",...G.safeNodes.length>0&&{nodes:G.safeNodes},...null!=i&&{edges:G.safeEdges},size:[W,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:G.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:m,nodeAlign:y,nodePaddingRatio:b,nodeWidth:v,nodeStyle:K,edgeStyle:J,colorBy:h,colorScheme:G.effectivePalette,edgeColorBy:p,edgeOpacity:k,edgeSort:w,nodeLabel:ee,showLabels:F,enableHover:z,tooltipContent:!1===S?()=>null:Fn(S)||void 0,...Wl({linkedHover:P,selection:T,onObservation:A,onClick:C,mobileInteraction:G.mobileInteraction,customHoverBehavior:G.customHoverBehavior,customClickBehavior:G.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:G.legend,legendPosition:G.legendPosition,...D&&"none"!==D&&{legendHoverBehavior:G.legendState.onLegendHover,legendClickBehavior:G.legendState.onLegendClick,legendHighlightedCategory:G.legendState.highlightedCategory,legendIsolatedCategories:G.legendState.isolatedCategories},className:s,title:H,description:q,summary:Y,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...M})})});ec.displayName="SankeyDiagram";var tc=require("react"),nc=require("react/jsx-runtime"),rc=(0,tc.forwardRef)(function(e,t){const n=(0,tc.useRef)(null);Ps(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:p="source",padAngle:m=.01,groupWidth:y=20,sortGroups:b,nodeLabel:v,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:S,onClick:M,chartId:A,selection:C,linkedHover:L,loading:T,loadingContent:P,emptyContent:j,legendInteraction:E,stroke:N,strokeWidth:I,opacity:R}=e,{width:D,height:_,enableHover:O,showLabels:$=!0,title:W,description:B,summary:z,accessibleTable:F}=r,H=Ml({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:!1,legendInteraction:E,selection:C,linkedHover:L,onObservation:S,onClick:M,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ChordDiagram",chartId:A,marginDefaults:r.marginDefaults,userMargin:a,width:D,height:_,hasTitle:!!W,loading:T,loadingContent:P,emptyContent:j}),q=(0,tc.useMemo)(()=>new Map,[]),Y=(0,tc.useMemo)(()=>new Map,[]),X=H.safeNodes.length>0,G=(0,tc.useMemo)(()=>{if(X)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=Ft(e.data||e,h,H.colorScale);else{const r=Array.isArray(f)?f:Dt[f]||_t,o=Array.isArray(r)?r:_t,i=(e.id??e.data?.[d]??"")+"";Y.has(i)||Y.set(i,Y.size);const a=e.index??t??Y.get(i);n.fill=o[a%o.length]}return n}},[X,h,H.colorScale,f,d,Y]),V=(0,tc.useMemo)(()=>Ll(h),[h]),U=(0,tc.useMemo)(()=>{if(G||g&&g.length>0)return Al(Nl(G,g,V,e=>e.data||e),{stroke:N,strokeWidth:I,opacity:R})},[G,g,V,N,I,R]),Q=(0,tc.useMemo)(()=>{if(X)return Sl({edgeColorBy:p,colorBy:h,colorScale:H.colorScale,nodeStyleFn:U||(e=>({fill:ml(void 0,H.themeCategorical,f,void 0,q)})),edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}})},[X,p,h,H.colorScale,U,x,H.themeCategorical,f,q]),K=(0,tc.useMemo)(()=>Q?Al(Q,{stroke:N,strokeWidth:I,opacity:R}):void 0,[Q,N,I,R]),Z=(0,tc.useMemo)(()=>{if(!$)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[$,v,d]),J=Ol({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return J?(0,nc.jsx)(Aa,{componentName:"ChordDiagram",message:J,width:D,height:_}):H.loadingEl?H.loadingEl:H.emptyEl?H.emptyEl:(0,nc.jsx)(Pa,{componentName:"ChordDiagram",width:D,height:_,children:(0,nc.jsx)(Ls,{ref:n,chartType:"chord",...H.safeNodes.length>0&&{nodes:H.safeNodes},...null!=i&&{edges:H.safeEdges},size:[D,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:H.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:m,groupWidth:y,sortGroups:b,nodeStyle:U,edgeStyle:K,colorBy:h,colorScheme:H.effectivePalette,edgeColorBy:p,edgeOpacity:x,nodeLabel:Z,showLabels:$,enableHover:O,tooltipContent:!1===k?()=>null:Fn(k)||void 0,...Wl({linkedHover:L,selection:C,onObservation:S,onClick:M,mobileInteraction:H.mobileInteraction,customHoverBehavior:H.customHoverBehavior,customClickBehavior:H.customClickBehavior,linkedHoverInClickPredicate:!1}),...E&&"none"!==E&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},className:s,title:W,description:B,summary:z,accessibleTable:F,...null!=e.animate&&{animate:e.animate},...w})})});rc.displayName="ChordDiagram";var oc=require("react"),ic=require("react/jsx-runtime");function ac(e){const t=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,layout:i="tree",orientation:a="vertical",childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:f="curve",nodeLabel:g,nodeSize:p=5,tooltip:m,frameProps:y={},onObservation:b,onClick:v,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:T}=e,{width:P,height:j,enableHover:E,showLabels:N=!0,title:I,description:R,summary:D,accessibleTable:_}=t,O=Ml({nodes:(0,oc.useMemo)(()=>xl(n??null,s),[n,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:A,selection:k,linkedHover:w,onObservation:b,onClick:v,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:t.marginDefaults,userMargin:r,width:P,height:j,hasTitle:!!I,loading:S,loadingContent:M}),$=(0,oc.useMemo)(()=>new Map,[]),W=(0,oc.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Bt[(e.depth||0)%Bt.length]:u?Ft(e.data||e,u,O.colorScale):ml(void 0,O.themeCategorical,d,void 0,$),t},[u,h,O.colorScale,O.themeCategorical,d,$]),B=(0,oc.useMemo)(()=>Al(W,{stroke:C,strokeWidth:L,opacity:T}),[W,C,L,T]),z=(0,oc.useMemo)(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),F=(0,oc.useMemo)(()=>Al(z,{stroke:C,strokeWidth:L,opacity:T}),[z,C,L,T]),H=(0,oc.useMemo)(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return wl(l)},[i,l]),q=_l({componentName:"TreeDiagram",data:n});return q?(0,ic.jsx)(Aa,{componentName:"TreeDiagram",message:q,width:P,height:j}):O.loadingEl?O.loadingEl:(0,ic.jsx)(Pa,{componentName:"TreeDiagram",width:P,height:j,children:(0,ic.jsx)(Ls,{chartType:i,...null!=n&&{data:n},size:[P,j],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:O.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:H,treeOrientation:a,edgeType:f,nodeStyle:B,edgeStyle:F,colorBy:u,colorScheme:O.effectivePalette,colorByDepth:h,nodeSize:p,nodeLabel:N?g||c:void 0,showLabels:N,enableHover:E,tooltipContent:!1===m?()=>null:Fn(m)||void 0,...Wl({linkedHover:w,selection:k,onObservation:b,onClick:v,mobileInteraction:O.mobileInteraction,customHoverBehavior:O.customHoverBehavior,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:O.legendState.onLegendHover,legendClickBehavior:O.legendState.onLegendClick,legendHighlightedCategory:O.legendState.highlightedCategory,legendIsolatedCategories:O.legendState.isolatedCategories},className:o,title:I,description:R,summary:D,accessibleTable:_,...null!=e.animate&&{animate:e.animate},...y})})}ac.displayName="TreeDiagram";var sc=require("react"),lc=require("react"),cc=require("react/jsx-runtime");function uc(e){const t=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:f=4,paddingTop:g,nodeStyle:p,tooltip:m,frameProps:y={},selection:b,linkedHover:v,onObservation:x,onClick:k,chartId:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:T}=e,{nodeStyle:P,...j}=y,{width:E,height:N,enableHover:I,showLabels:R=!0,title:D,description:_,summary:O,accessibleTable:$}=t,W=Ml({nodes:(0,sc.useMemo)(()=>xl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:A,selection:b,linkedHover:v,onObservation:x,onClick:k,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:w,marginDefaults:t.marginDefaults,userMargin:r,width:E,height:N,hasTitle:!!D,loading:S,loadingContent:M}),B=function(e){const t=ar(e=>e.theme.colors.selectionOpacity);return(0,lc.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(b),z=W.customHoverBehavior,F=(0,sc.useCallback)(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),H=(0,sc.useMemo)(()=>new Map,[]),q=(0,sc.useMemo)(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?Bt[(e.depth||0)%Bt.length]:l?Ft(e.data||e,l,W.colorScale):ml(void 0,W.themeCategorical,c,void 0,H),t},[l,u,W.colorScale,W.themeCategorical,c,H]),Y=(0,sc.useMemo)(()=>p||P?e=>({...q(e),...P?P(e)??{}:{},...p?p(e)??{}:{}}):q,[q,p,P]),X=(0,sc.useMemo)(()=>Al(Y,{stroke:C,strokeWidth:L,opacity:T}),[Y,C,L,T]),G=(0,sc.useMemo)(()=>W.activeSelectionHook?e=>{const t={...X(e)};if(W.activeSelectionHook.isActive)if(W.activeSelectionHook.predicate(e.data||e))B?.selectedStyle&&Object.assign(t,B.selectedStyle);else{const e=B?.unselectedOpacity??Rs;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,B?.unselectedStyle&&Object.assign(t,B.unselectedStyle)}return t}:X,[X,W.activeSelectionHook,B]),V=(0,sc.useMemo)(()=>wl(a),[a]),U=void 0!==g?g:!R||"parent"!==d&&"all"!==d?void 0:18,Q=_l({componentName:"Treemap",data:n});return Q?(0,cc.jsx)(Aa,{componentName:"Treemap",message:Q,width:E,height:N}):W.loadingEl?W.loadingEl:(0,cc.jsx)(Pa,{componentName:"Treemap",width:E,height:N,children:(0,cc.jsx)(Ls,{chartType:"treemap",...null!=n&&{data:n},size:[E,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:W.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:V,padding:f,paddingTop:U,nodeStyle:G,colorBy:l,colorScheme:W.effectivePalette,colorByDepth:u,nodeLabel:R?h||s:void 0,showLabels:R,labelMode:d,enableHover:I,tooltipContent:!1===m?()=>null:Fn(m)||void 0,...Wl({linkedHover:v,selection:b,onObservation:x,onClick:k,mobileInteraction:W.mobileInteraction,customHoverBehavior:F,customClickBehavior:W.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},className:o,title:D,description:_,summary:O,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...j})})}uc.displayName="Treemap";var dc=require("react"),hc=require("react/jsx-runtime");function fc(e){const t=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:f=4,tooltip:g,frameProps:p={},onObservation:m,onClick:y,chartId:b,selection:v,linkedHover:x,loading:k,loadingContent:w,legendInteraction:S,stroke:M,strokeWidth:A,opacity:C}=e,{width:L,height:T,enableHover:P,showLabels:j=!0,title:E,description:N,summary:I,accessibleTable:R}=t,D=Ml({nodes:(0,dc.useMemo)(()=>xl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:S,selection:v,linkedHover:x,onObservation:m,onClick:y,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:r,width:L,height:T,hasTitle:!!E,loading:k,loadingContent:w}),_=(0,dc.useMemo)(()=>new Map,[]),O=(0,dc.useMemo)(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Bt[(e.depth||0)%Bt.length]:l?Ft(e.data||e,l,D.colorScale):ml(void 0,D.themeCategorical,c,void 0,_),t},[l,u,D.colorScale,h,D.themeCategorical,c,_]),$=(0,dc.useMemo)(()=>Al(O,{stroke:M,strokeWidth:A,opacity:C}),[O,M,A,C]),W=(0,dc.useMemo)(()=>wl(a),[a]),B=_l({componentName:"CirclePack",data:n});return B?(0,hc.jsx)(Aa,{componentName:"CirclePack",message:B,width:L,height:T}):D.loadingEl?D.loadingEl:(0,hc.jsx)(Pa,{componentName:"CirclePack",width:L,height:T,children:(0,hc.jsx)(Ls,{chartType:"circlepack",...null!=n&&{data:n},size:[L,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:D.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:W,padding:f,nodeStyle:$,colorBy:l,colorScheme:D.effectivePalette,colorByDepth:u,nodeLabel:j?d||s:void 0,showLabels:j,enableHover:P,tooltipContent:!1===g?()=>null:Fn(g)||void 0,...Wl({linkedHover:x,selection:v,onObservation:m,onClick:y,mobileInteraction:D.mobileInteraction,customHoverBehavior:D.customHoverBehavior,customClickBehavior:D.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:D.legendState.onLegendHover,legendClickBehavior:D.legendState.onLegendClick,legendHighlightedCategory:D.legendState.highlightedCategory,legendIsolatedCategories:D.legendState.isolatedCategories},className:o,title:E,description:N,summary:I,accessibleTable:R,...null!=e.animate&&{animate:e.animate},...p})})}fc.displayName="CirclePack";var gc=require("react"),pc=require("react/jsx-runtime"),mc=Bt;function yc(e){const t=bl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",nodeIdAccessor:a="name",colorBy:s,colorScheme:l,colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:f,revolutionStyle:g,eccentricity:p=1,showRings:m=!0,nodeRadius:y=6,showLabels:b=!1,animated:v=!0,tooltip:x,foregroundGraphics:k,annotations:w,frameProps:S={},onObservation:M,onClick:A,chartId:C,selection:L,linkedHover:T,loading:P,loadingContent:j,stroke:E,strokeWidth:N,opacity:I}=e,{width:R,height:D,enableHover:_,title:O,description:$,summary:W,accessibleTable:B}=t,z=Ml({nodes:(0,gc.useMemo)(()=>xl(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:c?void 0:s,colorScheme:l,showLegend:!1,legendInteraction:void 0,selection:L,linkedHover:T,onObservation:M,onClick:A,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:C,marginDefaults:nl(t),userMargin:r,width:R,height:D,hasTitle:!!O,loading:P,loadingContent:j}),F=(0,gc.useMemo)(()=>new Map,[]),{colorScale:H,customClickBehavior:q,customHoverBehavior:Y,themeCategorical:X}=z,G=(0,gc.useMemo)(()=>{if(Array.isArray(l))return l;const e=Dt[l];return Array.isArray(e)?e:_t},[l]),V=(0,gc.useMemo)(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=c?n?G[0]:mc[(e.depth||0)%mc.length]:s?Ft(e.data||e,s,H):ml(void 0,X,l,void 0,F),t.opacity=n?1:.85,t},[s,c,H,G,X,l,F]),U=(0,gc.useMemo)(()=>Al(V,{stroke:E,strokeWidth:N,opacity:I}),[V,E,N,I]),Q=(0,gc.useMemo)(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),K=(0,gc.useMemo)(()=>e=>{Y(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Y]),Z=(0,gc.useMemo)(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=_l({componentName:"OrbitDiagram",data:n});return J?(0,pc.jsx)(Aa,{componentName:"OrbitDiagram",message:J,width:R,height:D}):z.loadingEl?z.loadingEl:(0,pc.jsx)(Pa,{componentName:"OrbitDiagram",width:R,height:D,children:(0,pc.jsx)(Ls,{chartType:"orbit",...null!=n&&{data:n},size:[R,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:z.margin,nodeIDAccessor:a,childrenAccessor:i,nodeStyle:U,edgeStyle:Q,colorBy:s,colorScheme:z.effectivePalette,colorByDepth:c,nodeSize:y,nodeLabel:b?a:void 0,showLabels:b,enableHover:!v&&_,tooltipContent:v?void 0:!1===x?()=>null:Fn(x)||void 0,...Wl({linkedHover:T,selection:L,onObservation:M,onClick:A,mobileInteraction:z.mobileInteraction,customHoverBehavior:K,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:k,annotations:w,className:o,title:O,description:$,summary:W,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:f,orbitRevolutionStyle:g,orbitEccentricity:p,orbitShowRings:m,orbitAnimated:v,accessibleTable:B,...null!=e.animate&&{animate:e.animate},...S})})}yc.displayName="OrbitDiagram";var bc=require("react"),vc={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function xc(e="static"){return vc[e]??vc.static}var kc=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function wc(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:kc.has(e.kind)?"fatal":"warn"}function Sc(e,t,n,r={}){const o=xc(r.usageMode??"static"),i=[],a=new Set;for(const t of e)a.has(t.id)&&i.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),a.add(t.id);const s=new Set,l=Array.isArray(n)&&2===n.length,c=l&&Number.isFinite(n[0])&&Number.isFinite(n[1]);l&&c&&c&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)s.has(e.id)&&i.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),a.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&i.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&i.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}function Mc(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function Ac(e){const{desired:t,minGaps:n,weights:r}=e,o=t.length;if(0===o)return[];if(n.length!==Math.max(0,o-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(o).fill(0);for(let e=1;o>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const a=[];for(let e=0;o>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(r?.[e])?r[e]:1),o=(Number.isFinite(t[e])?t[e]:0)-i[e];for(a.push({start:e,end:e,weight:n,mean:o});a.length>1;){const e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const s=Number.isFinite(e.min)?e.min:-1/0,l=Number.isFinite(e.max)?e.max-i[o-1]:1/0,c=s>l?s:l,u=Array(o);for(const e of a){const t=Math.max(s,Math.min(c,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function Cc(e,t){let n=0,r=e.length-1,o=-1;for(;r>=n;){const i=n+r>>>1;e[i].at>t?r=i-1:(o=i,n=i+1)}return 0>o?{at:t,before:0,after:0}:e[o]}function Lc(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],r=[0];for(let o=0;e.length-1>o;o++){const i=e[o],a=e[o+1],s=[...new Set([...i.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t);let l=0;for(const e of s){const t=Cc(i,e),n=Cc(a,e);l=Math.max(l,t.after+n.before)}n.push(l),r.push(r[r.length-1]+l+t)}return{adjacentClearance:n,positions:r}}function Tc(e,t,n,r={}){let o=[...e];if(1>=o.length)return o;let i=[...o],a=n(o),s=1;const l=Math.max(0,r.passes??6),c=Math.max(1,r.maxEvaluations??1/0);for(let e=0;l>e&&c>s;e++){const e=new Map(o.map((e,t)=>[e,t])),l=new Map,c=new Map;for(const n of t){const t=e.get(n.source),r=e.get(n.target);if(null==t||null==r)continue;const o=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;l.set(n.source,(l.get(n.source)??0)+r*o),c.set(n.source,(c.get(n.source)??0)+o),l.set(n.target,(l.get(n.target)??0)+t*o),c.set(n.target,(c.get(n.target)??0)+o)}o=o.map((e,t)=>({item:e,index:t,barycenter:(l.get(e)??t)/(c.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(r.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(o);if(s++,a>u)a=u,i=[...o];else if(u===a)break}return i}function Pc(e,t,n={}){const r=[...e],o=r.length;if(1>=o||o>(n.maxItems??8))return r;const i=Math.max(1,n.maxEvaluations??1/0);let a=0,s=[...r],l=1/0;const c=()=>{if(a>=i)return;const e=t(r);a++,l>e&&(l=e,s=[...r])};c();const u=Array(o).fill(0);let d=0;for(;o>d&&i>a;)if(d>u[d]){const e=d%2==0?0:u[d];[r[e],r[d]]=[r[d],r[e]],c(),u[d]++,d=0}else u[d]=0,d++;return s}function jc(e,t){return t>e?-1:e>t?1:0}function Ec(e){return e.occupants.map(e=>e.id).sort(jc).join("\0")}function Nc(e,t,n=0){return e.slice(0,-1).map((r,o)=>null!=r.group&&r.group===e[o+1].group?n:t)}function Ic(e,t){return e.map(e=>{const n=new Map;for(const r of e.occupants){const e=t[r.id];if(e)for(const t of e.samples){const e=n.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;n.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function Rc(e,t,n){if(0===e.length)return[];const{padding:r,plotH:o,valueScale:i}=n,a=n.stackValueScale??i,s=Nc(e,r,n.groupPadding??0),l=[r+e[0].peak.topPeak*a];for(let n=1;e.length>n;n++)l.push(l[n-1]+t[n-1]*a+s[n-1]);const c=l[l.length-1]+e[e.length-1].peak.botPeak*a+r;if(c>o&&c>0){const e=o/c;for(let t=0;l.length>t;t++)l[t]*=e}return l}function Dc(e,t){const n=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){const o=e.sideMassBefore*t;return n+("top"===e.side?r/2-o:o-r/2)}const o=e.sideMassAfter*t;return n+("top"===e.side?r/2-o:o-r/2)}function _c(e,t,n,r,o,i){const a=i.adjacentClearance?[...i.adjacentClearance]:Lc(Ic(r,n)).adjacentClearance,s=Rc(r,a,i);let l="hug"===i.lanePlacement?function(e,t,n,r,o,i,a){const s=e.length;if(0===s)return[];const{padding:l,plotH:c,valueScale:u}=a,d=Nc(e,l,a.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=l+e[0].peak.topPeak*u,g=c-l-e[s-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=g-f)return Rc(e,o,a);let p=1===s?[(f+g)/2]:[...i];for(let e=0;12>e;e++){const e=Array(s).fill(0),o=Array(s).fill(0);for(const i of n){const n=t[i.source],a=t[i.target];if(null==n||null==a||n===a)continue;const s=r[i.source]?.localAttachments.get(i.id),l=r[i.target]?.localAttachments.get(i.id);if(!s||!l)continue;const c=i.value>0&&Number.isFinite(i.value)?i.value:1,d=Dc(s,u),h=Dc(l,u);e[n]+=(p[a]+h-d)*c,o[n]+=c,e[a]+=(p[n]+d-h)*c,o[a]+=c}const i=Ac({desired:p.map((t,n)=>0===o[n]?t:.45*t+e[n]/o[n]*.55),minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:g});let a=0;for(let e=0;s>e;e++)a=Math.max(a,Math.abs(i[e]-p[e]));if(p=i,.01>a)break}return p}(r,o,t,n,a,s,i):[...s];if("hug"===i.lanePlacement){const n=t=>{const n={};for(const r of e)n[r.id]=t[o[r.id]];return n};Oc(n(l),t)>Oc(n(s),t)+1e-6&&(l=[...s])}const c={};for(const t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(const t of e){const e=c[t.id],r=n[t.id];Number.isFinite(e)&&r&&(u=Math.min(u,e-r.topPeak*i.valueScale),d=Math.max(d,e+r.botPeak*i.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&i.plotH>0?Math.max(0,Math.min(1,(d-u)/i.plotH)):0}}function Oc(e,t){let n=0;for(const r of t){const t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(n+=Math.abs(t-o)*(r.value>0?r.value:1))}return n}function $c(e,t){const n=e?.samples;if(!n||0===n.length||n[0].t>t)return{top:0,bot:0};let r=0,o=n.length-1,i=0;for(;o>=r;){const e=r+o>>>1;n[e].t>t?o=e-1:(i=e,r=e+1)}const a=n[i].boundaryOffset??0;return{top:n[i].topMass-a,bot:n[i].botMass+a}}function Wc(e,t,n,r,o){const i=1-o;return i*i*i*e+3*i*i*o*t+3*i*o*o*n+o*o*o*r}function Bc(e,t){let n=0,r=1;for(let o=0;28>o;o++){const o=(n+r)/2;e>Wc(0,t,t,1,o)?n=o:r=o}return(n+r)/2}function zc(e,t,n){const r=t+Dc(e,n),o=e.value*n/2;return[r-o,r+o]}function Fc(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))/Math.max(1e-9,t-e)}function Hc(e,t,n,r,o,i,a){const{valueScale:s,domain:l,mode:c="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5;let d=0;for(const a of e){const e=r[a.source],h=r[a.target];if(null==e||null==h||2>Math.abs(e-h))continue;const f=t[a.source]?.localAttachments.get(a.id),g=t[a.target]?.localAttachments.get(a.id);if(!f||!g)continue;const p=Math.max(a.startTime,l?.[0]??-1/0),m=Math.min(a.endTime,l?.[1]??1/0);if(p>=m)continue;const[y,b]=zc(f,o[a.source],s),[v,x]=zc(g,o[a.target],s),k=Math.min(e,h)+1,w=Math.max(e,h)-1;for(let e=k;w>=e;e++){const r=n[e];if(!r)continue;const l=[p,m];if("quality"===c)for(const e of r.occupants)for(const n of t[e.id]?.samples??[])n.t>p&&m>n.t&&l.push(n.t);const h=e=>{const n=Bc((e-p)/(m-p),u),l=Wc(y,y,v,v,n),c=Wc(b,b,x,x,n);let d=0;for(const n of r.occupants){if(n.id===a.source||n.id===a.target)continue;const r=i[n.id];if(null!=r?.start&&r.start>e)continue;if(null!=r?.end&&e>r.end)continue;const u=$c(t[n.id],e),h=o[n.id];d=Math.max(d,Fc(l,c,h-u.top*s,h+u.bot*s))}return d},f=[...new Set(l)].sort((e,t)=>e-t);let g=0;for(let e=0;f.length-1>e;e++){const t=f[e],n=f[e+1]-t;g+=(h(t+.25*n)+h(t+.5*n)+h(t+.75*n))/3*n}d+=g/(m-p)*(a.value>0?a.value:1)}}return d}function qc(e,t,n,r,o,i,a,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:Oc(a,n),transitOcclusion:Hc(n,r,o,i,a,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function Yc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Xc(e,t){return e.map(e=>({t:Yc(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Gc(e,t,n){const r=t+(e.boundaryOffset??0)*n,o=e.value*n;if("out"===e.kind){const t=e.sideMassBefore*n;if("top"===e.side){const e=r-t;return[e,e+o]}const i=r+t;return[i-o,i]}const i=e.sideMassAfter*n;if("top"===e.side){const e=r-i;return[e,e+o]}const a=r+i;return[a-o,a]}function Vc(e,t,n,r,o="temporal"){const i=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(const e of i)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{s.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(l[e.kind]??99)-(l[t.kind]??99)||((e,t)=>{if(!r||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const n=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof o&&Number.isFinite(o)&&n!==o?"top"===e.side?n-o:o-n:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const n=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof o&&Number.isFinite(o)&&n!==o?"top"===e.side?o-n:n-o:0}return 0})(e,t)||jc(e.edge?.id??"",t.edge?.id??"")||jc(e.side,t.side)||e.delta-t.delta)},u=s.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(s.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;c();let f=null,g=0;for(const e of s)e.time!==f&&(f=e.time,g=0),e.sequence=g++;const p=e=>({time:e.time,phase:0,sequence:e.sequence??0}),m=[];let y=0,b=0;for(const e of s)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:b);if(n>0){const t="top"===e.side?"bot":"top",r=Math.min(n,"top"===t?y:b);if(r>0){const o=p(e);m.push({...o,delta:-r,kind:"transfer-out",side:t}),m.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?y-=r:b-=r,"top"===e.side?y+=r:b+=r,n-=r}n>0&&null!==h&&(m.push({time:h,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:b+=n)}"top"===e.side?y-=t:b-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:b+=t}s.push(...m),c();let v=0,x=0,k=0,w=0,S=0,M=0;const A=[],C=new Map,L=e=>{A.push({t:e,topMass:v,botMass:x,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},T=()=>{w=Math.max(w,v+x),S=Math.max(S,v-k),M=Math.max(M,x+k)};for(const e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&L(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:x;C.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:x+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,T(),L(e.time)):"transfer-out"!==e.kind&&(T(),"out"!==e.kind||v+x>1e-12||(k=0),L(e.time))}const P=[];let j=0;for(;A.length>j;){let e=j;for(;A.length>e+1&&A[e+1].t===A[j].t;)e++;P.push(A[j]);for(let t=j+1;e>=t;t++){const e=P[P.length-1];A[t].topMass===e.topMass&&A[t].botMass===e.botMass&&(A[t].boundaryOffset??0)===(e.boundaryOffset??0)||P.push(A[t])}j=e+1}const E=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let N=null;for(const e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===N||N>e.systemInTime)&&(N=e.systemInTime);let I=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===I||e.systemOutTime>I)&&(I=e.systemOutTime);if(P.length>0){const e=P[P.length-1],t=Math.max(null!=E?E:-1/0,null!=I?I:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&P.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const n=P[0],r=P.find(e=>e.topMass+e.botMass>0);let o,i=1/0;null!=d&&Number.isFinite(d)&&n.t>d&&n.topMass+n.botMass>0&&(i=d,o=n),r&&null!=N&&Number.isFinite(N)&&r.t>N&&i>N&&(i=N,o=r),o&&Number.isFinite(i)&&P.unshift({t:i,topMass:o.topMass,botMass:o.botMass,...null!=o.boundaryOffset&&{boundaryOffset:o.boundaryOffset}})}let R=P;if("max"===o&&null!=d&&null!=E&&E>d){let e,t=0;for(const n of P){const r=n.topMass+n.botMass;r>t&&(t=r,e=n)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};R=[...P.filter(e=>d>e.t),{t:d,...t},{t:E,...t},...P.filter(e=>e.t>E)]}}return{samples:R,peak:w,topPeak:S,botPeak:M,localAttachments:C}}function Uc(e){const t={};return e.forEach((e,n)=>{for(const r of e.occupants)t[r.id]=n}),t}function Qc(e,t,n){e.splice(0,e.length,...n);const r=Uc(n);for(const e of Object.keys(t))delete t[e];Object.assign(t,r)}function Kc(e){const t=new Map,n=[];e.forEach((e,r)=>{if(!e.group)return void n.push({anchor:r,stableId:Ec(e),slots:[e]});const o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(const[e,r]of t)n.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(Ec).join("\0")}`,slots:r.slots});return n.sort((e,t)=>e.anchor-t.anchor||jc(e.stableId,t.stableId))}function Zc(e){return e.some(e=>e.group)?Kc(e).flatMap(e=>e.slots):[...e]}function Jc(e){return e.flatMap(e=>e.slots)}function eu(e,t,n){const r=new Map;return e.forEach((e,t)=>{for(const n of e.slots)r.set(n,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;const i=new Map;for(const t of e.slots)i.set(t,0);for(const e of t){const t=r.get(e.source),n=r.get(e.target);if(null==t||null==n)continue;const a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&n!==o){const t=n>o?1:-1;i.set(e.source,(i.get(e.source)??0)+a*t)}else if(n===o&&t!==o){const n=t>o?1:-1;i.set(e.target,(i.get(e.target)??0)+a*n)}}const a=[...e.slots].sort((e,t)=>(i.get(e)??0)-(i.get(t)??0)||n(e,t));return{...e,slots:a}})}function tu(e,t){e.some(e=>e.group)&&Qc(e,t,Zc(e))}function nu(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function ru(e,t){return function(e,t,n=()=>!0){let r=0;for(let o=0;e.length>o;o++){const[i,a]=t(e[o]);for(let s=o+1;e.length>s;s++){if(!n(e[o],e[s]))continue;const[l,c]=t(e[s]);0>(i-l)*(a-c)&&r++}}return r}(t,t=>[e[t.source],e[t.target]],nu)}function ou(e,t){let n=0;for(const r of t){const t=e[r.source],o=e[r.target];null!=t&&null!=o&&(n+=Math.abs(t-o)*(r.value>0?r.value:1))}return n}function iu(e,t,n){const[r,o]=n.get(e.first),[i,a]=n.get(e.second);return 0>(t.get(r)-t.get(i))*(t.get(o)-t.get(a))?1:0}var au=e=>{let t=1;for(let n=2;e>=n;n++)t*=n;return t},su=828*au(8),lu=3e3;function cu(e,t,n,r,o,i,a){const s=[...o],l=new Map(o.map(e=>[e,Ec(e)])),c=new Map;for(const e of o)for(const t of e.occupants)c.set(t.id,e);const u=new Map,d=[];for(const e of t){const t=c.get(e.source),n=c.get(e.target);t&&n&&(u.set(e,[t,n]),t!==n&&d.push({source:t,target:n,weight:e.value}))}const h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let n=e+1;t.length>n;n++){if(!u.has(t[n])||!nu(t[e],t[n]))continue;const r=new Set([...u.get(t[e]),...u.get(t[n])]);h.push({index:h.length,first:t[e],second:t[n],involvedSlots:r})}const f=new Map;for(const e of o)f.set(e,[]);for(const e of h)for(const t of e.involvedSlots)f.get(t)?.push(e);const g=new Uint32Array(h.length);let p=0;const m=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),y=a.plotH/Math.max(1,o.length),b=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),v=Math.max(1,m)*(Math.max(1,a.plotH)+y*Math.max(b,o.length)+1e-6*Math.max(1,o.length-1))+1,x=4*y,k={fullCrossing:0,localCrossing:0},w=new Map,S=(e,t)=>{let r=w.get(e);r||(r=new Map,w.set(e,r));const o=r.get(t);if(null!=o)return o;const i=function(e,t,n){return Lc(Ic([e,t],n)).adjacentClearance[0]??0}(e,t,n);return r.set(t,i),i},M=new Map(o.map((e,t)=>[e,t])),A=t.flatMap(e=>{const t=u.get(e);return t?[{source:M.get(t[0]),target:M.get(t[1]),weight:e.value>0?e.value:1}]:[]}),C=new Map;for(const e of t){const t=u.get(e);t&&C.set(e,{source:M.get(t[0]),target:M.get(t[1])})}const L=new Map,T=new Map;for(const e of t)L.has(e.source)||L.set(e.source,new Set),T.has(e.target)||T.set(e.target,new Set),L.get(e.source).add(e.target),T.get(e.target).add(e.source);const P=t.flatMap(e=>{if(!(e=>{const t=new Set([...L.get(e.source)??[],...T.get(e.source)??[]]),n=new Set([...L.get(e.target)??[],...T.get(e.target)??[]]);return 1===L.get(e.source)?.size&&L.get(e.source).has(e.target)||1===t.size&&t.has(e.target)||1===n.size&&n.has(e.source)})(e))return[];const t=C.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),j=e=>{let t=0;for(const n of P)t+=Math.max(0,Math.abs(e[n.source]-e[n.target])-1)*n.weight;return t*x},E=e=>{const t=new Int16Array(o.length);for(let n=0;e.length>n;n++)t[M.get(e[n])]=n;return j(t)},N=h.map(e=>{const t=C.get(e.first),n=C.get(e.second);return[t.source,t.target,n.source,n.target]}),I=new Int16Array(o.length),R=new Float64Array(o.length),D=new Float64Array(o.length+1),_=e=>{for(let t=0;e.length>t;t++)I[M.get(e[t])]=t;let t=0;for(const[e,n,r,o]of N)0>(I[e]-I[r])*(I[n]-I[o])&&t++;if(e.length>0){const t=M.get(e[0]);R[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;e.length>t;t++){const n=M.get(e[t-1]),r=M.get(e[t]);R[r]=R[n]+S(e[t-1],e[t])*a.valueScale+a.padding}const n=M.get(e[e.length-1]),r=R[n]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(r>a.plotH&&r>0){const e=a.plotH/r;for(let t=0;R.length>t;t++)R[t]*=e}}D[0]=0;for(let t=0;e.length>t;t++)D[t+1]=D[t]+e[t].peak.topPeak+e[t].peak.botPeak;let n=0,r=0,o=0;for(const e of A){const t=I[e.source],i=I[e.target];if(n+=Math.abs(t-i)*e.weight,r+=Math.abs(R[e.source]-R[e.target])*e.weight,Math.abs(t-i)>=2){const n=Math.min(t,i)+1;o+=(D[Math.max(t,i)]-D[n])*e.weight}}return t*v+r+o*y+j(I)+1e-6*n},O=(e,n)=>{const r=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(const e of t){const t=n[e.source],i=n[e.target];if(null==t||null==i||2>Math.abs(t-i))continue;const a=Math.min(t,i)+1;o+=(r[Math.max(t,i)]-r[a])*(e.value>0?e.value:1)}return o},$=r=>{const o=Uc(r),i=r.slice(0,-1).map((e,t)=>S(e,r[t+1])),s=_c(e,t,n,r,o,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:i});return{map:o,geometry:s,weightedLength:ou(o,t),pixelLength:Oc(s.centerlines,t),transitOcclusion:O(r,o)}},W=(e,t,n)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*v+t.pixelLength+t.transitOcclusion*y+E(n)+1e-6*t.weightedLength}),B=(e,t)=>{let n=t;if(null==n){const t=new Map(e.map((e,t)=>[e,t]));n=h.reduce((e,n)=>e+iu(n,t,u),0),k.fullCrossing++}return W(n,$(e),e)},z=(e,o,i="quality")=>{let s=o;if(null==s){const t=new Map(e.map((e,t)=>[e,t]));s=h.reduce((e,n)=>e+iu(n,t,u),0),k.fullCrossing++}const l=$(e);return W(s,{...l,transitOcclusion:Hc(t,n,e,l.map,l.geometry.centerlines,r,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:i})},e)};let F=[...s];const H=(e,t)=>jc(l.get(e),l.get(t)),q=function(e){const t=new Set;for(const n of e)if(n.group){if(t.has(n.group))return!0;t.add(n.group)}return!1}(F),Y=e=>{const t=(e=>{const t=Tc(e,d,e=>B(e).cost,{passes:6,compare:H,maxEvaluations:lu});let n=B(t),r=lu;for(let e=0;6>e&&r>0;e++){let o=!1;const i=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&i.reverse();for(const e of i){if(0>=r--)break;const i=t[e],a=t[e+1],s=new Map(t.map((e,t)=>[e,t]));let l=0;const c=[];p++;for(const e of[...f.get(i)??[],...f.get(a)??[]])g[e.index]!==p&&(g[e.index]=p,c.push(e),l+=iu(e,s,u));[t[e],t[e+1]]=[a,i];const d=new Map(s);d.set(i,e+1),d.set(a,e);let h=0;for(const e of c)h+=iu(e,d,u);k.localCrossing+=c.length;const m=B(t,n.crossings-l+h);n.cost>m.cost?(n=m,o=!0):[t[e],t[e+1]]=[i,a]}if(!o)break}return t})(e);if((e.length>8?1/0:au(e.length)*(e.length+A.length+N.length))>su)return t;const n=Pc(e,_,{maxItems:8,maxEvaluations:5e4}),r=z(n),o=z(t);return r.crossings!==o.crossings&&o.crossings>r.crossings?n:t},X="geometry-refine"===a.mode;if(X||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder){if(!X&&"inside-out"===a.laneOrder)if(q){const e=Kc(F),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),n=[...e].sort((e,n)=>t(n)-t(e)||jc(e.stableId,n.stableId)),r=Array(n.length);let o=Math.floor((n.length-1)/2)-1,i=Math.floor((n.length-1)/2)+1;n.length>0&&(r[Math.floor((n.length-1)/2)]=n[0]);for(let e=1;n.length>e;e++)e%2==1&&n.length>i||0>o?r[i++]=n[e]:r[o--]=n[e];F=Jc(r)}else{const e=[...F].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||H(e,t)),t=Array(e.length);let n=Math.floor((e.length-1)/2)-1,r=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>r||0>n?t[r++]=e[o]:t[n--]=e[o];F=t}}else F=q?(e=>{let t=Kc(e);if(1>=t.length)return Jc(t);const n=e=>B(Jc(e)).cost;t=Kc(Y(e)),t=eu(t,d,H);const r=function(e,t){const n=new Map;for(const t of e)for(const e of t.slots)n.set(e,t);const r=new Map;for(const e of t){const t=n.get(e.source),o=n.get(e.target);if(!t||!o||t===o)continue;const i=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(a);s?s.weight=(s.weight??0)+i:r.set(a,{source:t,target:o,weight:i})}return[...r.values()]}(t,d);t=Tc(t,r,n,{passes:6,compare:(e,t)=>jc(e.stableId,t.stableId),maxEvaluations:lu}),t=function(e,t,n={}){const r=[...e];if(1>=r.length)return r;let o=t(r),i=1;const a=Math.max(0,n.passes??6),s=Math.max(1,n.maxEvaluations??1/0);for(let e=0;a>e&&s>i;e++){let e=!1;for(let n=0;r.length-1>n&&s>i;n++){[r[n],r[n+1]]=[r[n+1],r[n]];const a=t(r);i++,o>a?(o=a,e=!0):[r[n],r[n+1]]=[r[n+1],r[n]]}if(!e)break}return r}(t,n,{passes:8,maxEvaluations:lu});const o=t.length>8?1/0:au(t.length)*(t.length+A.length+N.length);if(su>=o){const e=Pc(t,e=>_(Jc(e)),{maxItems:8,maxEvaluations:5e4}),n=Jc(e),r=Jc(t),o=z(n),i=z(r);o.crossings!==i.crossings?t=i.crossings>o.crossings?e:t:i.cost>o.cost&&(t=e)}return t=eu(t,d,H),Jc(t)})(F):Y(F);if(!X&&"crossing-min+inside-out"===a.laneOrder&&F.length>1)if(q){const e=Kc(F);let t=B(Jc(e)),n=Jc(e),r=t;const o=Math.floor((e.length-1)/2),i=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),a=[...e].sort((e,t)=>i(t)-i(e)||jc(e.stableId,t.stableId));for(const i of a){const a=e.indexOf(i);if(a===o)continue;e.splice(a,1),e.splice(o,0,i);const s=Jc(e),l=B(s);l.cost>t.cost?(e.splice(o,1),e.splice(a,0,i)):(t=l,r.cost>l.cost&&(n=s,r=l))}F=n}else{let e=B(F),t=[...F],n=e;const r=Math.floor((F.length-1)/2),o=[...F].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||H(e,t));for(const i of o){const o=F.indexOf(i);if(o===r)continue;F.splice(o,1),F.splice(r,0,i);const a=B(F);a.cost>e.cost?(F.splice(r,1),F.splice(o,0,i)):(e=a,n.cost>a.cost&&(t=[...F],n=a))}F=t}if((X||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&F.length>1)if(q){let e=Kc(F),t=z(Jc(e),void 0,"score");for(let n=0;6>n&&e.length>1;n++){let n=!1;for(let r=0;e.length-1>r;r++){[e[r],e[r+1]]=[e[r+1],e[r]];const o=Jc(e),i=z(o,void 0,"score");t.cost>i.cost?(F=o,t=i,n=!0):[e[r],e[r+1]]=[e[r+1],e[r]]}if(!n)break}e=eu(Kc(F),d,H),F=Jc(e)}else{let e=z(F,void 0,"score");for(let t=0;F.length-1>t;t++){const n=F[t],r=F[t+1],o=new Map(F.map((e,t)=>[e,t]));let i=0;const a=[];p++;for(const e of[...f.get(n)??[],...f.get(r)??[]])g[e.index]!==p&&(g[e.index]=p,a.push(e),i+=iu(e,o,u));[F[t],F[t+1]]=[r,n];const s=new Map(o);s.set(n,t+1),s.set(r,t);let l=0;for(const e of a)l+=iu(e,s,u);k.localCrossing+=a.length;const c=z(F,e.crossings-i+l,"score");e.cost>c.cost?e=c:[F[t],F[t+1]]=[n,r]}}const G=Zc(s);F=Zc(F);let V=z(F);const U=z(G);if(X){const e=E(G),t=E(F);(V.crossings>U.crossings||V.crossings===U.crossings&&t>e+1e-9||V.cost>U.cost)&&(F=G,V=U)}else V.cost>U.cost&&(F=G,V=U);return Qc(o,i,F),{before:U,after:V,initialOrder:s.map(e=>l.get(e)),evaluations:k}}function uu(e,t,n){const r=e.map(e=>{const r=e.occupants.map(e=>({id:e.id,end:n[e.id]?.end??e.end}));let o=0,i=0;for(const e of r){const n=t[e.id];o=Math.max(o,n?.topPeak||0),i=Math.max(i,n?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:i},...null!=e.group?{group:e.group}:{}}}),o={};return r.forEach((e,t)=>{for(const n of e.occupants)o[n.id]=t}),{slots:r,slotByNode:o}}var du=new Map,hu=1e-9,fu=1e5;function gu(e,t){let n=1/0,r=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>hu&&(n=Math.min(n,t.t),r=Math.max(r,t.t));return Number.isFinite(n)&&Number.isFinite(r)?(null!=t.start&&(n=Math.max(n,t.start)),null!=t.end&&(r=Math.min(r,t.end)),n>r?{start:null,end:null}:{start:n,end:r}):{start:null,end:null}}function pu(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function mu(e,t){return jc(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function yu(e){const t=new Map,n=new Map;for(const r of e)n.has(r.source)||n.set(r.source,new Set),t.has(r.target)||t.set(r.target,new Set),n.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...n].map(([e,t])=>[e,t.size]))}}function bu(e){const t=new Map,n=new Map,r=(e,t,n,r)=>{let o=e.get(t);o||(o=new Map,e.set(t,o)),o.set(n,(o.get(n)??0)+r)};for(const o of e){const e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(n,o.target,o.source,e)}const o=new Map,i=e=>{if(o.has(e))return;const r=t.get(e),i=n.get(e);if(r&&1===r.size&&(!i||0===i.size)){const[t,n]=[...r][0];return void o.set(e,{partner:t,weight:n})}const a=new Map;for(const[e,t]of r??[])a.set(e,(a.get(e)??0)+t);for(const[e,t]of i??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){const[t,n]=[...a][0];o.set(e,{partner:t,weight:n})}};for(const t of e)i(t.source),i(t.target);return o}function vu(e,t,n){const r=n.get(e),o=n.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function xu(e,t,n){return!!n.has(e)&&t.some(t=>!vu(e,t,n))}function ku(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function wu(e,t,n,r){if(12>=e.length||1>=r.slotCount)return r.assignment;const o=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Map),a=yu(n);for(const e of n){const t=o.get(e.source),n=o.get(e.target);if(null==t||null==n||t===n)continue;const r=ku(e,a);i[t].set(n,(i[t].get(n)??0)+r),i[n].set(t,(i[n].get(t)??0)+r)}const s=bu(n),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>new Map);let u=0;for(let n=0;e.length-1>n&&5e4>u;n++)if(s.has(e[n]))for(let r=n+1;e.length>r;r++){if(!s.has(e[r]))continue;if(t.conflicts(e[n],e[r]))continue;u++;const o=Math.min(l[n],l[r])||Math.max(l[n],l[r]),i=vu(e[n],e[r],s)?o:-o;if(Math.abs(i)>hu&&(c[n].set(r,i),c[r].set(n,i),u>=5e4))break}const d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));const f=(e,t,n)=>{const r=d[t],o=d[n];let i=0;const a=new Set;for(const s of[t,n])for(const[l,c]of e[s]){const e=l>s?`${s}:${l}`:`${l}:${s}`;if(a.has(e))continue;a.add(e);const u=(s===t?o:r)===(l===t?o:l===n?r:d[l]);d[s]===d[l]!==u&&(i+=u?c:-c)}return i},g=(e,t,n)=>{let r=0;for(const[o,i]of e[t]){const e=n===d[o];d[t]===d[o]!==e&&(r+=e?i:-i)}return r},p=(e,t)=>e>hu||hu>=Math.abs(e)&&t>hu,m=(e,t,n,r)=>e>n+hu||hu>=Math.abs(e-n)&&t>r+hu;let y=0;for(let n=0;32>n&&fu>y;n++){let n=null,r=-1,o=-1,a=-1,s=-1/0,l=-1/0;for(let u=0;e.length>u;u++){for(let f=0;h.length>f&&y++<fu;f++){if(f===d[u])continue;if(!h[f].every(n=>!t.conflicts(e[u],e[n])))continue;const y=g(i,u,f),b=g(c,u,f);p(y,b)&&m(y,b,s,l)&&(n="move",r=u,o=-1,a=f,s=y,l=b)}if(y>=fu)break}for(let u=0;e.length-1>u;u++){for(let g=u+1;e.length>g&&y++<fu;g++){const y=d[u],b=d[g];if(y===b)continue;if(!h[b].every(n=>n===g||!t.conflicts(e[u],e[n])))continue;if(!h[y].every(n=>n===u||!t.conflicts(e[g],e[n])))continue;const v=f(i,u,g),x=f(c,u,g);p(v,x)&&m(v,x,s,l)&&(n="swap",r=u,o=g,a=-1,s=v,l=x)}if(y>=fu)break}if(null==n||-1===r)break;if("move"===n){const e=d[r];h[e].splice(h[e].indexOf(r),1),h[a].push(r),d[r]=a;continue}const u=d[r],b=d[o];h[u].splice(h[u].indexOf(r),1,o),h[b].splice(h[b].indexOf(o),1,r),d[r]=b,d[o]=u}return d}function Su(e,t,n,r){const o=function(e,t,n,r){return`${e.map(e=>{const t=n[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,n,r),i=du.get(o);if(i)return uu(i.slots,n,r);const a={};for(const t of e)a[t.id]=gu(n[t.id],r[t.id]);const s=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,n)=>t[e.id].start-t[n.id].start||t[e.id].end-t[n.id].end||jc(e.id,n.id)).map(e=>e.id)}(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=function(e,t,n,r,o){const i=new Set,a=new Map(e.map(e=>[e,new Set])),s=new Map(e.map(e=>[e,new Set]));for(const e of r)i.add(mu(e.source,e.target)),a.get(e.target)?.add(e.source),s.get(e.source)?.add(e.target);const l=new Map,c=new Set,u=(e,t)=>{for(let n=0;e.length>n;n++)for(let r=n+1;e.length>r;r++){const o=mu(e[n],e[r]);t instanceof Map?t.set(o,[e[n],e[r]]):t.add(o)}};for(const e of s.values())u([...e],l);for(const e of a.values())u([...e],c);const d=new Set;for(const[e,[r,o]]of l)c.has(e)&&(pu(t[r],t[o])||pu(n[r],n[o])&&(d.add(r),d.add(o)));return{conflicts:(e,n)=>{const r=o.get(e),a=o.get(n);return null!=r&&null!=a&&r!==a||null!=r!=(null!=a)&&!i.has(mu(e,n))||!!pu(t[e],t[n])||!(!d.has(e)&&!d.has(n))&&!i.has(mu(e,n))}}}(s,a,r,t,c),d=function(e,t,n=new Map){const r=[],o=[];for(const i of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(i,e))&&!xu(i,e,n));-1!==e||n.has(i)||(e=r.findIndex(e=>e.every(e=>!t.conflicts(i,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(i),o.push(e)}return{assignment:o,slotCount:r.length}}(s,u,bu(t)),h=function(e,t,n,r){if(0===e.length||e.length>12||1>=r.slotCount)return r.assignment;const o=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>new Map),s=Array.from({length:e.length},()=>new Map),l=yu(n);for(const e of n){const t=o.get(e.source),n=o.get(e.target);if(null==t||null==n||t===n)continue;const r=ku(e,l);i[t][n]+=r,i[n][t]+=r,s[t].set(n,(s[t].get(n)??0)+r),a[n].set(t,(a[n].get(t)??0)+r)}const c=bu(n),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let n=t+1;e.length>n;n++){for(const[e,r]of a[t])d[t][n]+=Math.min(r,a[n].get(e)??0);for(const[e,r]of s[t])d[t][n]+=Math.min(r,s[n].get(e)??0);if(c.has(e[t])&&c.has(e[n])){const r=Math.min(u[t],u[n])||Math.max(u[t],u[n]);d[t][n]+=vu(e[t],e[n],c)?r:-r}d[n][t]=d[t][n]}let h=[...r.assignment],f=(t=>{let n=0,r=0;for(let o=0;e.length>o;o++)for(let a=o+1;e.length>a;a++)t[o]===t[a]&&(n+=i[o][a],r+=d[o][a]);return{flow:n,affinity:r}})(h),g=0;const p=Array(e.length).fill(-1),m=Array.from({length:r.slotCount},()=>[]),y=(n,o,a,s)=>{if(g>=75e3)return;if(n===e.length)return g++,void((a>f.flow||a===f.flow&&s>f.affinity||a===f.flow&&s===f.affinity&&function(e,t){for(let n=0;Math.min(e.length,t.length)>n;n++)if(e[n]!==t[n])return t[n]>e[n];return t.length>e.length}(p,h))&&(h=[...p],f={flow:a,affinity:s}));const l=Math.min(o+1,r.slotCount-1);for(let r=0;l>=r;r++){if(m[r].some(r=>t.conflicts(e[n],e[r])))continue;let l=0,c=0;for(const e of m[r])l+=i[n][e],c+=d[n][e];if(p[n]=r,m[r].push(n),y(n+1,Math.max(o,r),a+l,s+c),m[r].pop(),p[n]=-1,g>=75e3)return}};return p[0]=0,m[0].push(0),y(1,0,0,0),h}(s,u,t,{...d,assignment:wu(s,u,t,d)}),f=new Map,g=h.map(e=>(f.has(e)||f.set(e,f.size),f.get(e))),p=Array.from({length:f.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m={};s.forEach((e,t)=>{const n=g[t],r=p[n];r.occupants.push({id:e,end:a[e].end??-1/0});const o=l.get(e)?.group;o&&(r.group=o),m[e]=n});for(const t of[...e].sort((e,t)=>jc(e.id,t.id)))null==m[t.id]&&(p[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(const e of p){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||jc(e.id,t.id));for(const t of e.occupants){const r=n[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}const y={slots:p,slotByNode:m};return function(e,t){for(du.has(e)&&du.delete(e),du.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:{...t.slotByNode}});du.size>12;){const e=du.keys().next().value;if(null==e)break;du.delete(e)}}(o,y),y}function Mu(e){return e.topMass+e.botMass}function Au(e,t){const n=e.samples.filter(e=>e.t===t);if(n.length>0)return n.reduce((e,t)=>Mu(t)<Mu(e)?e:t,n[0]);let r=null;for(const n of e.samples){if(n.t>t)break;r=n}return r}function Cu(e,t,n,r,o,i,a=0){const s=new Map;for(const n of e){if(!n.group||!t[n.id])continue;const e=s.get(n.group)??[];e.push(n),s.set(n.group,e)}if(0===s.size||0>=i)return t;const l=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,c]of s){const s=n.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;const u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;const g=(h-u.peak.topPeak*i+(f+d.peak.botPeak*i))/2,p=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),m=new Map;for(const e of c)m.set(e.id,new Map);for(const e of p){const n=new Map;for(const o of c){const i=Au(t[o.id],e);if(!i||1e-9>=Mu(i))continue;const a=r[o.id];if(null==a)continue;const s=n.get(a)??[];s.push({node:o,sample:i}),n.set(a,s)}const s=[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Mu(e)))}));if(0===s.length)continue;let l=g-(s.reduce((e,t)=>e+t.mass,0)*i+Math.max(0,a)*Math.max(0,s.length-1))/2;for(const t of s){for(const{node:n,sample:r}of t.active){const t=(l-o[n.id])/i+r.topMass-(r.boundaryOffset??0);m.get(n.id).set(e,t)}l+=t.mass*i+Math.max(0,a)}}for(const e of c){const n=t[e.id],r=l[e.id],o=m.get(e.id),i=[];for(const e of p){const t=o.get(e),r=n.samples.filter(t=>t.t===e);if(r.length>0){i.push(...r.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}})));continue}const a=Au(n,e);null!=t&&a&&Mu(a)>1e-9&&i.push({...a,t:e,boundaryOffset:(a.boundaryOffset??0)+t})}r.samples=i,r.localAttachments=new Map([...n.localAttachments].map(([e,t])=>{const n=o.get(t.time);return[e,{...t,...null!=n?{boundaryOffset:(t.boundaryOffset??0)+n}:{}}]}))}}return l}function Lu(e,t,n,r,o){const{plotH:i,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:g}=o,p={},m={};for(const t of e)p[t.id]=n[t.id].topPeak||0,m[t.id]=n[t.id].botPeak||0;const y="half"===u,b={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=y?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=y?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}b[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(i)?i:null}}let v={},x=[],k=[];if(o.frozenSlots){const e=uu(o.frozenSlots,n,b);x=e.slots,v=e.slotByNode,k=x.map(Ec)}else if("reuse"===l){const r=Su(e,t,n,b);x=r.slots,v=r.slotByNode}else e.forEach((e,t)=>{x.push({occupants:[{id:e.id,end:b[e.id]?.end??-1/0}],peak:{topPeak:p[e.id],botPeak:m[e.id]},...e.group?{group:e.group}:{}}),v[e.id]=t});tu(x,v),0===k.length&&(k=x.map(Ec));let w=null;o.frozenSlots||(o.fixedSlotOrder?function(e,t,n){const r=new Map(n.map((e,t)=>[e,t]));Qc(e,t,[...e].sort((e,t)=>(r.get(Ec(e))??1/0)-(r.get(Ec(t))??1/0)||jc(Ec(e),Ec(t))))}(x,v,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(w=cu(e,t,n,b,x,v,{plotH:i,padding:a,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:f,domain:g}))),tu(x,v);const S=_c(e,t,n,x,v,{plotH:i,padding:a,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),M=0===x.length?0:x[0].peak.topPeak+S.adjacentClearance.reduce((e,t)=>e+t,0)+x[x.length-1].peak.botPeak,A=w?.before.crossings??null,C=w?.after.crossings??null,L=w?.before.weightedLength??null,T=w?.after.weightedLength??null;return{effectiveSlotsHeight:M,centerlines:S.centerlines,laneLifetime:b,slots:x,slotByNode:v,slotCenter:S.slotCenter,stackCenter:S.stackCenter,verticalUtilization:S.verticalUtilization,selectedSlotOrder:x.map(Ec),initialSlotOrder:k,ordering:w,crossingsBefore:A,crossingsAfter:C,lengthBefore:L,lengthAfter:T}}var Tu={highTransitOcclusion:8,highLaneUtilization:.92,residualCrossings:3};function Pu(e){if(!e?.layoutQuality)return[];const t=[],n=e.layoutQuality,r=e.layoutQualityBefore;e.compressedPadding&&t.push({severity:"warning",code:"PROCESS_SANKEY_COMPRESSED_PADDING",message:"Lane gaps were compressed to fit peaks into the plot height.",fix:'Increase height, lower maxValueScale, use packing="reuse", or reduce concurrent peaks.'}),Tu.highTransitOcclusion>n.transitOcclusion||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_TRANSIT",message:`High transit occlusion (${n.transitOcclusion.toFixed(1)}) — ribbons cross dense intermediate lanes.`,fix:'Try laneOrder="crossing-min+inside-out", packing="reuse", or lanePlacement="hug" with a modest maxValueScale.'}),Tu.highLaneUtilization>n.verticalUtilization||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_UTILIZATION",message:`Lane utilization is ${Math.round(100*n.verticalUtilization)}% of plot height.`,fix:"Increase chart height or cap band scale with maxValueScale."});const o=e.crossingsAfter??n.crossings;return null==o||Tu.residualCrossings>o||t.push({severity:"warning",code:"PROCESS_SANKEY_RESIDUAL_CROSSINGS",message:`Ordering left ${o} edge-pair crossings`+(r?` (from ${r.crossings})`:"")+".",fix:'Prefer laneOrder="crossing-min" or "crossing-min+inside-out"; check for unavoidable fan-outs.'}),t}function ju(e){if(!e?.layoutQuality)return null;const t=e.layoutQuality,n=e.layoutQualityBefore,r=e.crossingsAfter??t.crossings;return[`ProcessSankey layout uses ${e.slots?.length??"?"} packed lane(s).`,null!=r?`Edge-pair crossings ${n?n.crossings+" → ":""}${r}.`:null,`Pixel path length ${n?Math.round(n.pixelLength)+" → ":""}${Math.round(t.pixelLength)}.`,`Transit occlusion ${n?n.transitOcclusion.toFixed(1)+" → ":""}${t.transitOcclusion.toFixed(1)}.`,`Lane utilization ${Math.round(100*t.verticalUtilization)}%.`,e.compressedPadding?"Lane gaps were compressed to fit the plot.":null].filter(Boolean).join(" ")}function Eu(e){const t=[],n=e.domain;null==n?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(n)&&2===n.length&&Number.isFinite(Number(n[0]))&&Number.isFinite(Number(n[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const r=e.edges;if(Array.isArray(r)&&r.length>0){const e=r[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const o=e.nodes,i=Array.isArray(o)?o.length:0;return!0!==e.showLabels||24>i||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${i} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(r)?r.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function Nu(e,t,n,r={}){const o=!1!==r.inferOpeningStock,i=[];for(const t of n){const n=Number(t.value);if(!Number.isFinite(n))continue;const r=Number(t.endTime);t.target===e&&Number.isFinite(r)&&i.push({time:r,delta:n});const o=Number(t.startTime);if(t.source===e&&Number.isFinite(o)&&i.push({time:o,delta:-n}),t.target===e&&null!=t.systemOutTime){const e=Number(t.systemOutTime);Number.isFinite(e)&&i.push({time:e,delta:-n})}}i.sort((e,t)=>e.time-t.time||t.delta-e.delta);let a=0,s=0,l=0;for(const e of i)a+=e.delta,s=Math.min(s,a),e.time>t||(l+=e.delta);return o?l-s:l}function Iu(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Ru(e,t,n,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:n?72:24}:{top:e?30:t?24:8,right:80,bottom:n?28:8,left:80}}var Du=require("react/jsx-runtime"),_u="var(--semiotic-grid, #94a3b8)",Ou="var(--semiotic-text-secondary, #475569)",$u="var(--semiotic-text-secondary, #94a3b8)",Wu=require("react"),Bu=require("d3-scale"),zu=require("d3-scale");function Fu(e,t,n,r,o,i,a,s,l={}){const c=o,u=e=>s?Math.max(s[0],Math.min(s[1],e)):e;let d=i(u(e.time));const h=i(u(n.time)),f=e.value*c,g=n.value*c,p=t+(e.boundaryOffset??0)*c,m=r+(n.boundaryOffset??0)*c,y=e.sideMassBefore*c,b=n.sideMassAfter*c;let v,x,k,w;"top"===e.side?(v=p-y,x=v+f):(x=p+y,v=x-f),"top"===n.side?(k=m-b,w=k+g):(w=m+b,k=w-g);const S=l.sourceRunwayStart,M=l.minRun,A=Math.abs((k+w)/2-(v+x)/2),C=h-d,L="number"==typeof S&&Number.isFinite(S),T="number"==typeof M&&Number.isFinite(M)&&M>0;if(L&&A>1e-9&&C>0&&("auto"===M||T)){const t="source"===a?.85:"target"===a?.15:.5,n="auto"===M?Math.min(144,Math.sqrt(8*A/(1.5*Math.min(t*t,(1-t)*(1-t))))):M;if(n>C){const t=i(u(Math.min(S,e.time)));Number.isFinite(t)&&(d=Math.min(d,Math.max(Math.min(d,t),h-n)))}}const P="source"===a?d+.85*(h-d):"target"===a?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:v,sBot:x,tx:h,tTop:k,tBot:w,cp1X:P,cp2X:P}}function Hu(e){return Math.max(18,11*e.length*.58)}function qu(e){const t=1.22*Hu(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Yu(e,t){const n=e.labelX-Hu(e.labelText),r=t.labelX-Hu(t.labelText);return t.labelX+3>=n&&e.labelX+3>=r}var Xu=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function Gu(e){return e.replace(Xu,(e,t,n)=>`${n},${t}`)}function Vu(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Uu(e){return{...e,pathD:Gu(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Qu(e){const{nodes:t,edges:n,domain:r,plotW:o,plotH:i,ribbonLane:a,ribbonMinRun:s=0,edgeOpacity:l,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:g,selectionDatum:p="raw",styleRules:m,colorBy:y,valueAccessor:b,usageMode:v="static"}=e,x="vertical"===d?i:o,k="vertical"===d?o:i,w=Sc(t,n,r,{usageMode:v}),{fatal:S,warnings:M}=function(e){const t=[],n=[];for(const r of e)"fatal"===wc(r)?t.push(r):n.push(r);return{fatal:t,warnings:n}}(w),A=function(e,t,n="static"){if("strip"!==xc(n).invalidSystemTime)return e;const r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;const t={...e};return null==t.systemInTime||Number.isFinite(t.systemInTime)||delete t.systemInTime,null==t.systemOutTime||Number.isFinite(t.systemOutTime)||delete t.systemOutTime,t})}(n,w,v),C=(0,zu.scaleTime)().domain(r).range([0,x]);if(S.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:S,warnings:M,xScale:C};const L=function(e,t,n){const{plotH:r,pairing:o="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=n,g=Number.isFinite(d)?Math.max(0,d):0,p=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),m=function(e,t,n,r="temporal"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime||jc(e.id,t.id):(e,t)=>t.value-e.value||jc(e.id,t.id),i="temporal"===r?(e,t)=>e.startTime-t.startTime||jc(e.id,t.id):(e,t)=>t.value-e.value||jc(e.id,t.id),a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const n=new Map;for(const r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const a=[...n.values()];a.sort("temporal"===r?(e,n)=>"target"===t?e.earliestStart-n.earliestStart||jc(e.partner,n.partner):e.latestEnd-n.latestEnd||jc(e.partner,n.partner):(e,t)=>t.total-e.total||jc(e.partner,t.partner));for(const e of a)e.edges.sort("target"===t?i:o);return a};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)s(r,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(r,"source"),n=s(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,p,o);let y={};for(const t of e)y[t.id]=Vc(t,p,m,void 0,u);const b=Lu(e,t,y,p,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:g,ribbonLane:h,domain:f}),v=b.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),x=new Set;for(const e of t){const t=b.slotByNode[e.source],n=b.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=m.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(x.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=p.outgoing[t.id],n=p.incoming[t.id],r=new Set(e.map(e=>m.get(e.id).sourceSide)),o=new Set(n.map(e=>m.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)b.slotByNode[t.source]===b.slotByNode[t.target]&&(m.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)b.slotByNode[n.source]===b.slotByNode[n.target]&&(m.get(n.id).sourceSide=t)}}!function(e,t,n){const r=new Map,o=[];for(const t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||jc(e.edge.id,t.edge.id));const i=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},a=(e,t,n)=>{const r="top"===t?"bot":"top",o=Math.min(n,e[t]);e[t]-=o;const i=n-o;i>0&&(e[r]=Math.max(0,e[r]-i))};for(const e of o){const{edge:r}=e;if("in"===e.kind){const e=t.get(r.id)?.targetSide??"bot";i(r.target)[e]+=r.value;continue}const o=i(r.source),s=t.get(r.id);let l=s.sourceSide??"bot";if(n[r.source]===n[r.target]){const e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":e||t||o.top===o.bot||(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}a(o,l,r.value)}}(t,m,b.slotByNode),function(e,t,n,r){for(const o of e){const e=t.incoming[o.id],i=t.outgoing[o.id];if(0===e.length||0===i.length)continue;const a=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const r of e)"top"===n.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(const e of i)"top"===n.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{const o=a(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=s||0>=l)return!1;const c=Math.min(s,l),u=i.filter(t=>!r.has(t.id)&&n.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||jc(e.id,t.id));return 0!==u.length&&(n.get(u[0].id).sourceSide=t,!0)};let l=i.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}(e,p,m,x),y={};for(const t of e)y[t.id]=Vc(t,p,m,void 0,u);const k=Lu(e,t,y,p,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:v,lanePlacement:"stack",groupPadding:g,ribbonLane:h,domain:f}),w=k.effectiveSlotsHeight??k.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),S=k.slots.slice(0,-1).reduce((e,t,n)=>e+(null!=t.group&&t.group===k.slots[n+1].group?1:0),0),M=Math.max(1,k.slots.length+1-S),A=Math.min(12,Math.max(0,.35*r-S*g)/M),C=2*A+Nc(k.slots,A,g).reduce((e,t)=>e+t,0),L=w>0?Math.max(0,(r-C)/w):1,T=Number.isFinite(l)&&l>0?Math.min(L,l):L;let P=Lu(e,t,y,p,{plotH:r,padding:A,valueScale:T,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:v,lanePlacement:c,groupPadding:g,ribbonLane:h,domain:f,stackValueScale:L});const j=Number.isFinite(l)&&l>0&&L>l+1e-12;if("insertion"!==a&&("hug"===c||j)&&P.slots.length>1&&(cu(e,t,y,P.laneLifetime,P.slots,P.slotByNode,{plotH:r,padding:A,valueScale:T,groupPadding:g,laneOrder:a,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),P=Lu(e,t,y,p,{plotH:r,padding:A,valueScale:T,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:P.slots,fixedSlotOrder:P.slots.map(Ec),lanePlacement:c,groupPadding:g,ribbonLane:h,domain:f,stackValueScale:L})),function(e,t){const n=(e,n)=>{for(const r of e){const e=new Map;for(const o of r){const r=`${("out"===n?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===n?o.startTime:o.endTime}`,i="out"===n?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,a=e.get(r);if(null!=a&&a!==i)return!0;e.set(r,i)}}return!1};return n(Object.values(e.outgoing),"out")||n(Object.values(e.incoming),"in")}(p,m)){const n=function(e,t,n,r){const o=new Map;for(const i of e){const e=t[i.source]?.localAttachments.get(i.id),a=t[i.target]?.localAttachments.get(i.id),s=n[i.source],l=n[i.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(l)))continue;const c=Gc(e,s,r),u=Gc(a,l,r);o.set(i.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}(t,y,P.centerlines,T);y={};for(const t of e)y[t.id]=Vc(t,p,m,n,u);P=Lu(e,t,y,p,{plotH:r,padding:A,valueScale:T,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:P.slots,fixedSlotOrder:P.slots.map(Ec),lanePlacement:c,groupPadding:g,ribbonLane:h,domain:f,stackValueScale:L})}const E=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),N=[...P.slots].sort((e,t)=>(E.get(Ec(e))??1/0)-(E.get(Ec(t))??1/0)||jc(Ec(e),Ec(t))),I={};N.forEach((e,t)=>{for(const n of e.occupants)I[n.id]=t});const R=_c(e,t,y,N,I,{plotH:r,padding:A,valueScale:T,stackValueScale:L,lanePlacement:"stack",groupPadding:g}),D=Cu(e,y,N,I,R.centerlines,T,g),_=qc(ru(I,t),ou(I,t),t,D,N,I,R.centerlines,P.laneLifetime,T,R.verticalUtilization,h,f);y=Cu(e,y,P.slots,P.slotByNode,P.centerlines,T,g);const O=qc(ru(P.slotByNode,t),ou(P.slotByNode,t),t,y,P.slots,P.slotByNode,P.centerlines,P.laneLifetime,T,P.verticalUtilization,h,f);return{nodeData:y,sides:m,valueScale:T,padding:A,compressedPadding:12>A,centerlines:P.centerlines,laneLifetime:P.laneLifetime,slots:P.slots,slotByNode:P.slotByNode,crossingsBefore:"insertion"===a?null:_.crossings,crossingsAfter:"insertion"===a?null:O.crossings,lengthBefore:"insertion"===a?null:_.weightedLength,lengthAfter:"insertion"===a?null:O.weightedLength,layoutQualityBefore:_,layoutQuality:O}}(t,A,{plotH:k,...u,ribbonLane:a,domain:r}),{centerlines:T,nodeData:P,valueScale:j}=L,E=Ll(y,b),N=[],I=[],R=0===s?new Map:function(e,t,n){const r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),i=new Map;for(const e of t){if(r.has(e.source))continue;const t=i.get(e.source)??[];t.push(e),i.set(e.source,t)}const a=new Map;for(const t of e){if(!t.group)continue;const e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}const s=new Set;for(const[e,t]of a){const n=t.flatMap(e=>i.get(e.id)??[]),o=new Set(n.map(e=>e.startTime));n.length>0&&1===o.size&&t.every(e=>{const t=e.xExtent?.[0],o=n[0].startTime;return!r.has(e.id)&&(i.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&s.add(e)}const l=new Map;for(const[e,t]of i){const r=o.get(e);if(r?.group&&!s.has(r.group))continue;const i=r?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1;let u=null;for(let e=0;a.length>e;){const t=a[e].startTime;let r=e+1;for(;a.length>r&&a[r].startTime===t;)r++;for(let t=e;r>t;t++){const e=a[t],r=Number.isFinite(i)&&e.startTime>i,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!r&&!o)continue;let s=n[0];r&&(s=Math.max(s,i)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),e.startTime>s&&l.set(e.id,s)}u=t,e=r}}for(const[e,t]of a){if(!s.has(e))continue;const n=t.flatMap(e=>i.get(e.id)??[]);if(!n.every(e=>l.has(e.id))){for(const e of n)l.delete(e.id);continue}const r=Math.max(...n.map(e=>l.get(e.id)));for(const e of n)l.set(e.id,r)}return l}(t,A,r),D=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),_=new Map;for(const e of A){const t=P[e.source]?.localAttachments.get(e.id),n=P[e.target]?.localAttachments.get(e.id);t&&n&&_.set(e.id,Fu(t,T[e.source],n,T[e.target],j,C,a,r,{minRun:s,sourceRunwayStart:R.get(e.id)}))}const O=function(e,t,n,r,o,i){const a=new Map(t),s=new Map;for(const t of e){const e=i?.get(t.source),n=null==e?"node:"+t.source:"group:"+e,r=s.get(n)??new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(n,r)}for(const e of s.values())for(const[i,s]of e){if(!s.some(e=>n.has(e.id)))continue;const e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const l=r(i),c=Math.min(...e.map(e=>e.sx));if(c>=l-1e-9)continue;const u=Math.max(...s.map(e=>{const t=n.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(const e of s){const n=t.get(e.id),r=d+(n.tx-d)*("source"===o?.85:"target"===o?.15:.5);a.set(e.id,{...n,sx:d,cp1X:r,cp2X:r})}}return a}(A,_,R,C,a,D),$=function(e,t,n,r,o){const i=new Map;for(const a of e){if(!n.has(a.id))continue;const e=t.get(a.id);if(!e||e.sx>=r(a.startTime)-1e-9)continue;const s=o(e.sx);Number.isFinite(s)&&a.startTime>s&&i.set(a.id,s)}return i}(A,O,R,C,e=>r[0]+e/x*(r[1]-r[0])),W=function(e,t,n){const r=new Map,o=new Map;for(const[e,t]of n??[]){const n=o.get(t)??[];n.push(e),o.set(t,n)}for(const i of e){const e=t.get(i.id);if(null==e||!Number.isFinite(e)||e>=i.startTime)continue;const a=n?.get(i.source),s=null==a?[i.source]:o.get(a)??[i.source];for(const t of s){const n=r.get(t)??new Map,o=n.get(i.startTime);n.set(i.startTime,null==o?e:Math.min(o,e)),r.set(t,n)}}return r}(A,$,D);t.forEach((e,t)=>{const n=P[e.id];if(!n||0===n.samples.length)return;const o=(i=n.samples,(a=W.get(e.id))&&0!==a.size?i.map(e=>{const t=a.get(e.t);return null==t?e:{...e,t:t}}):i);var i,a;const s=function(e,t,n,r,o){if(0===e.length)return null;const i=Xc(e,o),a=e=>t+(i[e].boundaryOffset??0)*n,s=e=>a(e)-i[e].topMass*n,l=e=>a(e)+i[e].botMass*n;let c=`M${r(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)c+=` L${r(i[e].t)},${s(e)}`;c+=` L${r(i[i.length-1].t)},${l(i.length-1)}`;for(let e=i.length-2;e>=0;e--)c+=` L${r(i[e].t)},${l(e)}`;return c+" Z"}(o,T[e.id],j,C,r);if(!s)return;const l=Xc(o,r),u=l.find(e=>e.topMass+e.botMass>0)||l[0],h=T[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*j/2;let f,g,p=c(e.id,t),y=p,b=.5;const v=e.__raw??e;if(m&&m.length>0){const e=El(v,m,E(v));"string"==typeof e.fill?p=e.fill:null!=e.fill&&Oo(e.fill)&&(g=e.fill,p=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:p),"string"==typeof e.stroke&&(y=e.stroke),"number"==typeof e.strokeWidth&&(b=e.strokeWidth),"number"==typeof e.fillOpacity&&(f=e.fillOpacity),"number"==typeof e.opacity&&null==f&&(f=e.opacity)}const x=function(e,t,n,r,o,i){const a=n.nodeData[e];if(!a||0===a.samples.length)return[];const s=n.valueScale,l=n.centerlines[e],c=Xc(a.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),g=e=>r(Yc(e,o)),p=[],m=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=a.localAttachments.get(n.id),t=i?.get(n.id)??n.startTime;if(e&&"out"===e.kind&&t>n.systemInTime){const r=g(n.systemInTime),i=g(t),a=null!=o&&o[0]>n.systemInTime,c=a?r:r-20,u=a?Math.min(i,r+20):r,d=Math.max(h,c);if(i>d){const[t,n]=Gc(e,l,s);p.push({pathD:m(d,t,i,n),x0:c,x1:u,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=a.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=g(n.systemOutTime),r=g(n.endTime),o=t+20,i=Math.min(f,o);if(i>r){const[n,a]=Gc(e,l,s);p.push({pathD:m(r,n,i,a),x0:t,x1:o,from:1,to:0})}}}}return p}(e.id,A,L,C,r,$);N.push({id:e.id,pathD:s,fill:p,stroke:y,strokeWidth:b,...null!=f&&{fillOpacity:f},...g&&{hatchFill:g},...x.length>0&&{gradientStubs:x},rawDatum:v,labelX:C("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:h,labelText:e.label??e.id})});const B=new Map;t.forEach((e,t)=>B.set(e.id,t)),A.forEach(e=>{const t=O.get(e.id);if(!t)return;const n=B.get(e.source)??0,r=c(e.source,n),{pathD:o,bezier:i}=be(t),a=e.__raw??e,s="function"==typeof l?Number(l(a)):l,u=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;I.push({id:e.id,pathD:o,fill:r,opacity:u,rawDatum:a,bezier:i})});const z=function(e,t,n){const r=e.map(e=>({...e})),o=new Map;for(const e of r){const n=t[e.id];if(null==n)continue;const r=o.get(n)??[];r.push(e),o.set(n,r)}const i=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(n-8,t+16*(o-r)))})};for(const e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],n=-1/0;for(const r of e){const e=r.labelX-Hu(r.labelText);t.length>0&&e>n+3&&(i(t),t=[],n=-1/0),t.push(r),n=Math.max(n,r.labelX)}i(t)}return function(e,t){const n=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;n.length>e;e+=1){let t=8;for(let r=0;e>r;r+=1)Yu(n[e],n[r])&&(t=Math.max(t,n[r].labelY+16));n[e].labelY=Math.max(n[e].labelY,t)}for(let e=n.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;n.length>t;t+=1)Yu(n[e],n[t])&&(r=Math.min(r,n[t].labelY-16));n[e].labelY=Math.min(n[e].labelY,r)}}}(r,n),r}(N,L.slotByNode,k).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Gu(e.pathD),gradientStubs:e.gradientStubs?.map(Uu),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),F="vertical"===d?function(e,t,n){const r=e.map(e=>({...e}));for(const e of r){const n=1.22*Hu(e.labelText)+4;e.labelX=t-4>n?Math.max(n/2+2,Math.min(t-n/2-2,e.labelX)):t/2}const o=[],i=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of i){const t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(const e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],r=new Map;for(const n of e){const[e,o]=qu(n);let i=t.findIndex(t=>e>t+8);-1===i&&(i=t.length),t[i]=o,r.set(n,i)}const o=e.reduce((e,t)=>e+t.labelY,0)/e.length,i=14*t.length+8>o;for(const t of e){const e=r.get(t)??0;t.labelY=i?Math.min(n-8,12+14*e):Math.max(8,o-14*e)}}return r}(z,o,i):z,H=new Map;if(null!=f)for(const e of t){const t=e.__raw??e,n="function"==typeof f?f(t):Number(t[f]);Number.isFinite(n)&&H.set(e.id,n)}const q=function(e,t,n,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let i=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*n)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(i=Math.min(i,Math.floor(o.maxLabels)));const a=e.map((e,t)=>{const n=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=n&&Number.isFinite(n)?1e6*n+Hu(e.labelText):Hu(e.labelText)+.01*r}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),s=new Set(a.slice(0,i).map(e=>e.band.id));return e.map(e=>s.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(F,o,i,h,{...H.size>0&&{priorityById:H},...null!=g&&{maxLabels:g}});return{layout:L,layoutConfig:{bands:q,ribbons:I.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Gu(e.pathD),bezier:Vu(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:p},issues:[],warnings:M,xScale:C}}var Ku=require("d3-scale"),Zu={};function Ju(e,t,n,r="reuse",o="crossing-min",i=5e4){return"sync"!==e&&("worker"===e||function(e,t,n="reuse",r="crossing-min"){return e*e*("reuse"===n?80:1)+t*t*(r&&"insertion"!==r?40:1)+10*(e+t)}(t,n,r,o)>=i)}function ed(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function td(e){if(!e)return null;const t=e.sides,n=t instanceof Map?t:new Map(Array.isArray(t)?t:[]);return{...e,sides:n}}var nd=class{constructor(e=function(){const e="string"==typeof Zu.url&&Zu.url?new URL("./processSankeyLayoutWorker.js",Zu.url):Ra("processSankeyLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-process-sankey-layout"})}()){this.session=new $a({name:"ProcessSankey layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:r}=Oa(t);return r?{requestId:n,ok:!1,error:_a(r)}:{requestId:n,ok:!0,payload:{layout:td(t.layout),layoutConfig:t.layoutConfig??{bands:[],ribbons:[],showLabels:!0},issues:t.issues??[],warnings:t.warnings??[],domain:t.domain??[0,1],timelineExtent:t.timelineExtent??0}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},rd=Wa(()=>new nd);function od(e){if(function(e){if(!e||0===e.length)return!1;for(const t of e){if("function"==typeof t.when)return!0;if("function"==typeof t.style)return!0}return!1}(e.styleRules))return!0;if("function"==typeof e.edgeOpacity)return!0;if("function"==typeof e.labelPriorityAccessor)return!0;if(e.styleRules&&e.styleRules.length>0){if("function"==typeof e.colorBy)return!0;if("function"==typeof e.valueAccessor)return!0}return!1}function id(e){if(null!=e&&"object"==typeof e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return}}}function ad(e){const t=id(e.__raw);return{id:e.id,...null!=e.label&&{label:e.label},...null!=e.group&&{group:e.group},...null!=e.xExtent&&{xExtent:e.xExtent},...null!=t&&{__raw:t}}}function sd(e){const t=id(e.__raw);return{id:e.id,source:e.source,target:e.target,value:e.value,startTime:e.startTime,endTime:e.endTime,...null!=e.systemInTime&&{systemInTime:e.systemInTime},...null!=e.systemOutTime&&{systemOutTime:e.systemOutTime},...null!=t&&{__raw:t}}}var ld=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:(0,Bu.scaleTime)().domain(e).range([0,t])});function cd(e,t){const n=fa(),{execution:r="auto",workerThreshold:o,colorById:i,fallbackPalette:a,rawNodeById:s,rawEdgeById:l}=t,c=(0,Wu.useMemo)(()=>Object.keys(i).sort().map(e=>`${e}:${i[e]}`).join("|"),[i]),u=(0,Wu.useMemo)(()=>e?[e.nodes,e.edges,e.plotW,e.plotH,e.orientation??"horizontal",e.ribbonLane,(e.ribbonMinRun??0)+"",e.edgeOpacity,(e.showLabels??!0)+"",e.layoutOpts.pairing??"temporal",e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",e.layoutOpts.lifetimeMode??"half",e.layoutOpts.maxValueScale??"",e.layoutOpts.lanePlacement??"stack",e.layoutOpts.nodeSizing??"temporal",e.layoutOpts.groupPadding??0,e.domain[0],e.domain[1],e.styleRules,c]:"null",[e,c]),d=!!e&&!n&&function(e,t,n){return"undefined"!=typeof window&&!!ed()&&!od(e)&&Ju(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",n)}(e,r,o),h=(0,Wu.useMemo)(()=>e?d?null:Qu(e):ld([0,1],1),[u,d,e]),f=(0,Wu.useRef)(n),[g,p]=(0,Wu.useState)(()=>e?n?{...Qu(e),status:"ready",error:null}:d?{...ld(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...Qu(e),status:"ready",error:null}:{...ld([0,1],1),status:"ready",error:null});return(0,Wu.useEffect)(()=>{if(f.current)return void(f.current=!1);if(!e||!d)return;const t=new AbortController;return p(e=>({...e,status:"pending",error:null})),async function(e,t){const{execution:n="auto",workerThreshold:r,signal:o,colorById:i,fallbackPalette:a=["#475569"],rawNodeById:s=new Map,rawEdgeById:l=new Map}=t,c=e.layoutOpts.packing??"reuse",u=e.layoutOpts.laneOrder??"crossing-min";if(!ed()||od(e)||!Ju(n,e.nodes.length,e.edges.length,c,u,r))return Qu(e);try{const t=await function(e,t){return ed()?rd.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(function(e,t,n){return{input:{nodes:e.nodes.map(ad),edges:e.edges.map(sd),domain:e.domain,plotW:e.plotW,plotH:e.plotH,orientation:e.orientation,ribbonLane:e.ribbonLane,ribbonMinRun:e.ribbonMinRun,edgeOpacity:"number"==typeof e.edgeOpacity?e.edgeOpacity:.35,layoutOpts:{...e.layoutOpts},showLabels:e.showLabels,..."string"==typeof e.labelPriorityAccessor&&{labelPriorityAccessor:e.labelPriorityAccessor},...null!=e.maxLabels&&{maxLabels:e.maxLabels},...null!=e.selectionDatum&&{selectionDatum:e.selectionDatum},...null!=e.usageMode&&{usageMode:e.usageMode},styleRules:e.styleRules,colorBy:"string"==typeof e.colorBy?e.colorBy:void 0,valueAccessor:"string"==typeof e.valueAccessor?e.valueAccessor:void 0},colorById:t,fallbackPalette:n}}(e,i,a),o);return function(e,t,n){const r=(e.layoutConfig.bands??[]).map(e=>({...e,rawDatum:t.get(e.id)??{id:e.id}})),o=(e.layoutConfig.ribbons??[]).map(e=>({...e,rawDatum:n.get(e.id)??{id:e.id}})),i=(0,Ku.scaleTime)().domain(e.domain).range([0,e.timelineExtent]);return{layout:e.layout,layoutConfig:{bands:r,ribbons:o,showLabels:e.layoutConfig.showLabels},issues:e.issues,warnings:e.warnings,xScale:i}}(t,s,l)}catch(t){if("AbortError"===t?.name)throw t;return Qu(e)}}(e,{execution:r,workerThreshold:o,signal:t.signal,colorById:i,fallbackPalette:a,rawNodeById:s,rawEdgeById:l}).then(e=>{p({...e,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&p(t=>({...t,status:"error",error:e}))}),()=>t.abort()},[u,d,r,o,a,s,l]),h?{...h,status:"ready",error:null}:g}var ud=require("react");function dd(e,t){return"function"==typeof e?e(t):t[e]}var hd=require("react"),fd=.22;function gd(e,t,n){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,n))}var pd=e=>{const{bands:t=[],ribbons:n=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,i=e.selection??null,a=[];for(const e of n){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},n=!gd(t,i,o);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:n?Math.min(e.opacity,fd):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!gd({__kind:"band",data:e.rawDatum,id:e.id},i,o);for(let n=0;e.gradientStubs.length>n;n++){const r=e.gradientStubs[n];a.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?fd:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${n}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),n={__kind:"band",data:e.rawDatum,id:e.id},r=!gd(n,i,o);a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:r?fd:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:fd}:{}},datum:n})}const s=r?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),n=e.labelText.trim().length>0,r=t&&i?.isActive&&gd({__kind:"band",data:e.rawDatum,id:e.id},i,o),a=n?e.labelText:r?e.labelFullText:"";return a.trim()?[{x:e.labelX,y:e.labelY,text:a,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:s}};function md(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}var yd=require("react/jsx-runtime");var bd=require("react/jsx-runtime"),vd=(0,bc.forwardRef)(function(e,t){const{nodes:n,edges:r,domain:o,axisTicks:i=[],nodeIdAccessor:a="id",nodeLabel:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",startTimeAccessor:d="startTime",endTimeAccessor:h="endTime",systemInTimeAccessor:f,systemOutTimeAccessor:g,xExtentAccessor:p="xExtent",groupBy:m,edgeIdAccessor:y="id",colorBy:b,colorScheme:v,showLegend:x,legendPosition:k="right",orientation:w="horizontal",pairing:S="temporal",packing:M="reuse",laneOrder:A="crossing-min",maxValueScale:C,lanePlacement:L="stack",nodeSizing:T="temporal",groupPadding:P=0,ribbonLane:j="both",ribbonMinRun:E=0,lifetimeMode:N="half",showLaneRails:I=!1,showQualityReadout:R=!1,showLabels:D=!0,labelPriorityAccessor:_,maxLabels:O,selectionDatum:$="raw",styleRules:W,layoutExecution:B="auto",layoutWorkerThreshold:z,layoutLoadingContent:F,onLayoutStateChange:H,width:q=600,height:Y=400,margin:X,title:G,description:V,summary:U,accessibleTable:Q,responsiveWidth:K,responsiveHeight:Z,loading:J,loadingContent:ee,emptyContent:te,edgeOpacity:ne=.35,timeFormat:re,valueFormat:oe,tooltip:ie,enableHover:ae=!0,onObservation:se,onClick:le,selection:ce,linkedHover:ue,showParticles:de=!1,particleStyle:he,chartId:fe,frameProps:ge={}}=e,pe=(0,bc.useRef)(null),me=(0,bc.useRef)(null),{rawNodes:ye,rawEdges:be,frameRef:ve,getNodeId:xe,getEdgeId:ke}=function(e){const{ref:t,rawNodesProp:n,rawEdgesProp:r,nodeIdAccessor:o,edgeIdAccessor:i,sourceAccessor:a,targetAccessor:s,scalesRef:l,layoutSnapshotRef:c}=e,[u,d]=(0,ud.useState)([]),[h,f]=(0,ud.useState)([]),g=(0,ud.useRef)(u),p=(0,ud.useRef)(h);g.current=u,p.current=h;const m=(0,ud.useCallback)(e=>{g.current=e,d(e)},[]),y=(0,ud.useCallback)(e=>{p.current=e,f(e)},[]),b=void 0!==r,v=ia(b?r:u),x=(0,ud.useMemo)(()=>{const e=ia(n??[]),t=h;if(0===e.length&&0===t.length)return kl([],v,a,s);const r=new Set,i=[];for(const t of e){const e=dd(o,t)+"";r.has(e)||(r.add(e),i.push(t))}for(const e of t){const t=dd(o,e)+"";r.has(t)||(r.add(t),i.push(e))}const l=kl([],v,a,s);for(const e of l)r.has(e.id)||(r.add(e.id),i.push(e));return i},[n,h,v,o,a,s]),k=(0,ud.useRef)(null),w=(0,ud.useCallback)((e,t)=>{const n=dd(i,e);return null!=n?n+"":`${dd(a,e)}-${dd(s,e)}-${t}`},[i,a,s]),S=(0,ud.useCallback)(e=>{if(null==e)return!1;const t=e;return null!=dd(a,t)&&null!=dd(s,t)},[a,s]),M=(0,ud.useCallback)(e=>dd(o,e)+"",[o]);return Ps(t,{variant:"network",frameRef:k,overrides:{push(e){if(S(e)){if(b)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");m([...g.current,e])}else y([...p.current,e])},pushMany(e){const t=[],n=[];for(const r of e)S(r)?t.push(r):n.push(r);t.length>0&&(b?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):m([...g.current,...t])),n.length>0&&y([...p.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!b){const e=g.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(w(i,o))?n.push(i):r.push(i)}r.length!==e.length&&m(r)}const r=p.current,i=[];for(const e of r){const r=dd(o,e)+"";t.has(r)?n.push(e):i.push(e)}return i.length!==r.length&&y(i),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!b){let e=!1;const o=g.current.map((o,i)=>n.has(w(o,i))?(r.push(o),e=!0,t(o)):o);e&&m(o)}let i=!1;const a=p.current.map(e=>{const a=dd(o,e)+"";return n.has(a)?(r.push(e),i=!0,t(e)):e});return i&&y(a),r},clear(){b||m([]),y([]),k.current?.clear()},getData:()=>v??[],getScales:()=>l.current,getCustomLayout:()=>c.current}}),{rawNodes:x,rawEdges:v,frameRef:k,getNodeId:M,getEdgeId:w,isControlled:b}}({ref:t,rawNodesProp:n,rawEdgesProp:r,nodeIdAccessor:a,edgeIdAccessor:y,sourceAccessor:l,targetAccessor:c,scalesRef:pe,layoutSnapshotRef:me}),{nodes:we,edges:Se,domain:Me,rawNodeById:Ae,rawEdgeById:Ce}=(0,bc.useMemo)(()=>{const e=(ye??[]).map(e=>{const t=xe(e),n=s?dd(s,e):t,r={id:t,label:null==n?t:n+"",__raw:e},o=m?dd(m,e):null;null!=o&&o+""!=""&&(r.group=o+"");const i=p?dd(p,e):null;if(Array.isArray(i)&&2===i.length){const e=Iu(i[0]),t=Iu(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(r.xExtent=[e,t])}return r}),t=(be??[]).map((e,t)=>{const n={id:ke(e,t),source:dd(l,e)+"",target:dd(c,e)+"",value:Number(dd(u,e)),startTime:Iu(dd(d,e)),endTime:Iu(dd(h,e)),__raw:e};if(f){const t=Iu(dd(f,e));Number.isFinite(t)&&(n.systemInTime=t)}if(g){const t=Iu(dd(g,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Iu(o[0]),Iu(o[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:r,rawEdgeById:i}},[ye,be,o,xe,ke,s,p,m,l,c,u,d,h,f,g]),Le=Ml({nodes:ye,edges:be,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:l,targetAccessor:c,colorBy:b,colorScheme:v,showLegend:!1,legendPosition:k,selection:ce,linkedHover:ue,onObservation:se,onClick:le?(e,t)=>{md(e)?le(e.data,t):le(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:fe,marginDefaults:Ru(!!G,R,i.length>0,w),userMargin:X,width:q,height:Y,hasTitle:!!G,loading:J,loadingContent:ee,emptyContent:te}),Te=(x??!!b)&&!!b,Pe=(0,bc.useCallback)(e=>null!=X&&("number"==typeof X||null!=X[e]),[X]),je=(0,bc.useMemo)(()=>{const e={...Le.margin};return Te&&("right"===k&&!Pe("right")&&140>e.right?e.right=140:"bottom"===k&&!Pe("bottom")&&80>e.bottom&&(e.bottom=80)),e},[Le.margin,Te,k,Pe]),Ee=q-je.left-je.right,Ne=Y-je.top-je.bottom,Ie="vertical"===w?Ne:Ee,Re=(0,bc.useCallback)((e,t)=>{if(b&&ye){const t=Ae.get(e);if(t)return Ft(t,b,Le.colorScale)}return Le.effectivePalette[t%Le.effectivePalette.length]||"#475569"},[b,ye,Ae,Le.colorScale,Le.effectivePalette]),De=cd((0,bc.useMemo)(()=>Ee>0&&Ne>0?{nodes:we,edges:Se,domain:Me,plotW:Ee,plotH:Ne,orientation:w,ribbonLane:j,ribbonMinRun:E,edgeOpacity:"function"==typeof ne?e=>ne(e):ne,colorOf:Re,showLabels:D,labelPriorityAccessor:_,maxLabels:O,selectionDatum:$,styleRules:W,usageMode:"push",colorBy:b,valueAccessor:u,layoutOpts:{pairing:S,packing:M,laneOrder:A,lifetimeMode:N,maxValueScale:C,lanePlacement:L,nodeSizing:T,groupPadding:P}}:null,[we,Se,Me,Ee,Ne,w,j,E,ne,Re,D,_,O,$,W,b,u,S,M,A,N,C,L,T,P]),{execution:B,workerThreshold:z,colorById:(0,bc.useMemo)(()=>{const e={};return we.forEach((t,n)=>{e[t.id]=Re(t.id,n)}),e},[we,Re]),fallbackPalette:Le.effectivePalette,rawNodeById:Ae,rawEdgeById:Ce}),{issues:_e,warnings:Oe,layout:$e,xScale:We}=De,Be=De.layoutConfig,ze=De.status;pe.current=$e?{time:We,centerlines:$e.centerlines}:{time:We},me.current=$e?{layout:$e,nodes:we,edges:Se,bands:Be.bands,ribbons:Be.ribbons,warnings:Oe,status:ze}:null;const Fe=(0,bc.useRef)(H);Fe.current=H,(0,bc.useEffect)(()=>{Fe.current?.(ze)},[ze]),(0,bc.useEffect)(()=>{0!==Oe.length&&console.warn("ProcessSankey warnings:",Oe.map(Mc).join("; "))},[Oe]);const He=(0,bc.useMemo)(()=>{if(!Te||!b)return;const e=new Map;(ye??[]).forEach((t,n)=>{const r=dd(b,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:Re(xe(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[Te,b,ye,Re,xe]),qe=function(e){const{tooltip:t,enableHover:n,layout:r,timeFormat:o,valueFormat:i,sourceAccessor:a,targetAccessor:s,valueAccessor:l,startTimeAccessor:c,endTimeAccessor:u}=e,d=(0,hd.useMemo)(()=>!1!==t&&n?void 0===t||!0===t?null:Fn(t)||null:null,[t,n]),h=(0,hd.useCallback)(e=>o?o(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[o]),f=(0,hd.useCallback)(e=>i?i(e):e+"",[i]);return(0,hd.useCallback)(e=>{if(!e||!e.data)return null;const t=e.data;if(!md(t))return null;const n=t.data;if(d)return d(n);if("band"===t.__kind){const e=t.id,n=r?function(e){if(!e)return[];const t=new Set,n=[];for(const r of e.samples){const e=r.topMass+r.botMass,o=`${r.t}:${e}`;t.has(o)||(t.add(o),n.push({t:r.t,total:e}))}return n}(r.nodeData[e]):[],o=5,i=n.length>o?n.length:null,a=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),r=n.length-1,o=[{...n[0],mark:"min"},{...n[Math.floor(.25*r)],mark:"q25"},{...n[Math.floor(.5*r)],mark:"median"},{...n[Math.floor(.75*r)],mark:"q75"},{...n[r],mark:"max"}],i=new Set,a=[];for(const e of o)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(n,o);return(0,yd.jsxs)("div",{style:{minWidth:160},children:[(0,yd.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:e}),a.length>0&&(0,yd.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[(0,yd.jsx)("thead",{children:(0,yd.jsxs)("tr",{style:{opacity:.6},children:[(0,yd.jsx)("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),(0,yd.jsx)("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&(0,yd.jsx)("th",{})]})}),(0,yd.jsx)("tbody",{children:a.map((e,t)=>(0,yd.jsxs)("tr",{children:[(0,yd.jsx)("td",{style:{paddingRight:8},children:h(e.t)}),(0,yd.jsx)("td",{style:{textAlign:"right"},children:f(e.total)}),null!=i&&(0,yd.jsx)("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&(0,yd.jsxs)("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",a.length," of ",i," samples"]})]})}const o=n,i=dd(a,o),g=dd(s,o),p=dd(l,o),m=dd(c,o),y=dd(u,o);return(0,yd.jsxs)("div",{style:{minWidth:160},children:[(0,yd.jsxs)("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",g+""]}),(0,yd.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=p&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("span",{style:{opacity:.6},children:"value"}),(0,yd.jsx)("span",{style:{textAlign:"right"},children:f(Number(p))})]}),null!=m&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("span",{style:{opacity:.6},children:"start"}),(0,yd.jsx)("span",{style:{textAlign:"right"},children:h(Iu(m))})]}),null!=y&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("span",{style:{opacity:.6},children:"end"}),(0,yd.jsx)("span",{style:{textAlign:"right"},children:h(Iu(y))})]})]})]})},[r,d,h,f,a,s,l,c,u])}({tooltip:ie,enableHover:ae,layout:$e,timeFormat:re,valueFormat:oe,sourceAccessor:l,targetAccessor:c,valueAccessor:u,startTimeAccessor:d,endTimeAccessor:h}),Ye=(0,bc.useMemo)(()=>{if(!$e)return null;const e=Oe.map(e=>Mc(e));return function(e){const t=e.layout,n=e.nodes,r=e.orientation,o=e.plotW,i=e.plotH,a=e.timelineExtent,s=e.axisTicks,l=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,f=e.toTime,g=e.xScale,{centerlines:p,laneLifetime:m,nodeData:y,valueScale:b,compressedPadding:v,crossingsBefore:x,crossingsAfter:k,layoutQualityBefore:w,layoutQuality:S}=t;let M=null,A=null;for(const e of n){const t=m[e.id];if(!t||null===t.start||null===t.end)continue;const n=g(t.start),r=g(t.end);(null===M||M>n)&&(M=n),(null===A||r>A)&&(A=r)}const C=e=>Math.max(0,Math.min(a,e)),L=C(M??0),T=Math.max(L,C(A??a)),P=s.map((e,t)=>({tick:e,index:t,coordinate:g(f(e.date))})).filter(({coordinate:e})=>e>=L-.5&&T+.5>=e),j=null!==(k??null)&&null!=w&&null!=S,E=l&&(j||u.length>0)?(0,Du.jsxs)("g",{fill:$u,fontSize:10,textAnchor:"end",children:[j&&(0,Du.jsxs)(Du.Fragment,{children:[(0,Du.jsxs)("text",{x:o,y:-14,children:["crossings: ",x," → ",k," ","pixel length: ",Math.round(w.pixelLength)," → ",Math.round(S.pixelLength)]}),(0,Du.jsxs)("text",{x:o,y:-3,children:["transit: ",w.transitOcclusion.toFixed(1)," → ",S.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*S.verticalUtilization),"%"]})]}),u.map((e,t)=>(0,Du.jsxs)("text",{x:o,y:j?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,N=v?(0,Du.jsx)("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:$u,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,I=(e,t)=>h?h(e,t):_u;return(0,Du.jsxs)("g","vertical"===r?{children:[E,N,P.map(({index:e,coordinate:t})=>(0,Du.jsx)("line",{x1:0,y1:t,x2:o,y2:t,stroke:_u,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&n.map((e,t)=>{const n=m[e.id];if(!n||null===n.start)return null;const r=y[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},i=p[e.id]+(o.botPeak-o.topPeak)*b/2,a=g(n.start),s=g(n.end),l=I(e.id,t);return(0,Du.jsxs)("g",{children:[(0,Du.jsx)("line",{x1:i,y1:a,x2:i,y2:s,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Du.jsx)("line",{x1:i-4,y1:a,x2:i+4,y2:a,stroke:l,strokeOpacity:.5}),(0,Du.jsx)("line",{x1:i-4,y1:s,x2:i+4,y2:s,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),(0,Du.jsx)("line",{x1:-4,y1:L,x2:-4,y2:T,stroke:_u}),P.map(({tick:e,index:t,coordinate:n})=>{const r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return(0,Du.jsxs)("g",{transform:`translate(-4,${n})`,children:[(0,Du.jsx)("line",{x2:-6,stroke:_u}),(0,Du.jsx)("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:Ou,children:o})]},t)})]}:{children:[E,N,P.map(({index:e,coordinate:t})=>(0,Du.jsx)("line",{x1:t,y1:0,x2:t,y2:i,stroke:_u,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&n.map((e,t)=>{const n=m[e.id];if(!n||null===n.start)return null;const r=y[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},i=p[e.id]+(o.botPeak-o.topPeak)*b/2,a=g(n.start),s=g(n.end),l=I(e.id,t);return(0,Du.jsxs)("g",{children:[(0,Du.jsx)("line",{x1:a,y1:i,x2:s,y2:i,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Du.jsx)("line",{x1:a,y1:i-4,x2:a,y2:i+4,stroke:l,strokeOpacity:.5}),(0,Du.jsx)("line",{x1:s,y1:i-4,x2:s,y2:i+4,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),(0,Du.jsx)("line",{x1:L,y1:i+4,x2:T,y2:i+4,stroke:_u}),P.map(({tick:e,index:t,coordinate:n})=>{const r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return(0,Du.jsxs)("g",{transform:`translate(${n},${i+4})`,children:[(0,Du.jsx)("line",{y2:6,stroke:_u}),(0,Du.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:Ou,children:o})]},t)})]})}({layout:$e,nodes:we,orientation:w,plotW:Ee,plotH:Ne,timelineExtent:Ie,axisTicks:i,showQualityReadout:R,showLaneRails:I,warnings:e,timeFormat:re?e=>re(e):void 0,colorOf:Re,toTime:Iu,xScale:e=>Number(We(e))})},[$e,we,w,Ee,Ne,Ie,i,R,I,Oe,re,Re,We]),Xe=(0,bc.useMemo)(()=>(ye??[]).map(e=>({id:xe(e),data:e})),[ye,xe]),Ge=(0,bc.useMemo)(()=>{const e=new Map;for(const t of Be.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Be]),Ve=(0,bc.useMemo)(()=>(be??[]).map((e,t)=>{const n=ke(e,t),r=Number(dd(u,e));return{id:n,source:dd(l,e)+"",target:dd(c,e)+"",value:Number.isFinite(r)?r:0,bezier:Ge.get(n),data:e}}),[be,ke,l,c,u,Ge]);return _e.length>0?(0,bd.jsxs)("svg",{width:q,height:Y,role:"img","aria-label":G??"Process Sankey validation failed",children:[(0,bd.jsx)("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),_e.map((e,t)=>(0,bd.jsx)("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+Mc(e)},t))]}):Le.loadingEl?Le.loadingEl:Le.emptyEl?Le.emptyEl:(0,bd.jsxs)("div",{style:{position:"relative",width:q,height:Y},children:["pending"===ze&&!1!==F&&!$e&&(0,bd.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Ia(!0,q,Y,F)}),(0,bd.jsx)(Ls,{ref:ve,chartType:"force",nodes:Xe,edges:Ve,customNetworkLayout:pd,layoutConfig:Be,size:[q,Y],responsiveWidth:K,responsiveHeight:Z,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:je,title:G,description:V??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:U,accessibleTable:Q,enableHover:ae,tooltipContent:!1===ie?()=>null:qe,backgroundGraphics:Ye,showParticles:de,particleStyle:he,legend:He,legendPosition:k,...Wl({linkedHover:ue,selection:ce,onObservation:se,onClick:le,mobileInteraction:Le.mobileInteraction,customHoverBehavior:Le.customHoverBehavior,customClickBehavior:Le.customClickBehavior,linkedHoverInClickPredicate:!1}),chartId:fe,colorScheme:Array.isArray(v)?v:void 0,layoutSelection:Le.activeSelectionHook,...ge})]})});vd.displayName="ProcessSankey";var xd=require("react"),kd=require("react"),wd=require("react/jsx-runtime"),Sd=(0,xd.forwardRef)(function(e,t){const{nodes:n,edges:r,layout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",margin:u,className:d,colorBy:h,colorScheme:f,selection:g,linkedHover:p,onObservation:m,onClick:y,chartId:b,annotations:v,autoPlaceAnnotations:x,frameProps:k={}}=e,{frameRef:w,resolved:S,normalizedMargin:M}=function(e){const t=(0,kd.useRef)(null);return Ps(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:bl(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:(0,kd.useMemo)(()=>function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),A=(0,xd.useMemo)(()=>ia(n),[n]),C=(0,xd.useMemo)(()=>ia(r),[r]),L=(0,xd.useMemo)(()=>void 0===n&&void 0===r?void 0:[...A,...C],[r,n,C,A]),T=Js(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:P,customClickBehavior:j,activeSelectionHook:E}=yl({selection:g,linkedHover:p,fallbackFields:"string"==typeof h?[h]:[],onObservation:m,onClick:y,chartType:"NetworkCustomChart",chartId:b,colorByField:"string"==typeof h?h:void 0,mobileInteraction:T}),N=(0,xd.useMemo)(()=>E?.isActive?{isActive:!0,predicate:E.predicate}:null,[E?.isActive,E?.predicate]),{width:I,height:R,enableHover:D,title:_,description:O,summary:$,accessibleTable:W}=S,B=Ia(e.loading,I,R,e.loadingContent),z=B?null:Na(L,I,R,e.emptyContent);if(B||z)return B||z;const F={chartType:"force",...null!=n&&{nodes:A},...null!=r&&{edges:C},customNetworkLayout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,size:[I,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:M,enableHover:D,...$l({title:_,description:O,summary:$,accessibleTable:W,className:d,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,autoPlaceAnnotations:x}),...Wl({linkedHover:p,selection:g,onObservation:m,onClick:y,mobileInteraction:T,customHoverBehavior:P,customClickBehavior:j,linkedHoverInClickPredicate:!1}),layoutSelection:N,...null!=v&&{annotations:v},...k};return(0,wd.jsx)(Pa,{componentName:"NetworkCustomChart",width:I,height:R,children:(0,wd.jsx)(Ls,{ref:w,...F})})});Sd.displayName="NetworkCustomChart";var Md={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Ad=8;function Cd(e){const t=function(e){return null==e?void 0:e+""}(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Md},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??Ad,style:{...Md},datum:e.datum,id:t,label:e.label}}
|